Home | History | Annotate | Line # | Download | only in marvell
marvell_intr.h revision 1.17
      1  1.17  kiyohara /*	$NetBSD: marvell_intr.h,v 1.17 2010/04/28 13:51:55 kiyohara Exp $	*/
      2   1.1      matt 
      3   1.1      matt /*-
      4   1.1      matt  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5   1.1      matt  * All rights reserved.
      6   1.1      matt  *
      7   1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1      matt  * by Charles M. Hannum.
      9   1.1      matt  *
     10   1.1      matt  * Redistribution and use in source and binary forms, with or without
     11   1.1      matt  * modification, are permitted provided that the following conditions
     12   1.1      matt  * are met:
     13   1.1      matt  * 1. Redistributions of source code must retain the above copyright
     14   1.1      matt  *    notice, this list of conditions and the following disclaimer.
     15   1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     17   1.1      matt  *    documentation and/or other materials provided with the distribution.
     18   1.1      matt  *
     19   1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1      matt  */
     31   1.1      matt 
     32  1.17  kiyohara #ifndef _POWERPC_MARVELL_INTR_H_
     33  1.17  kiyohara #define _POWERPC_MARVELL_INTR_H_
     34   1.1      matt 
     35  1.17  kiyohara void *intr_establish(int, int, int, int (*)(void *), void *);
     36  1.17  kiyohara void intr_disestablish(void *);
     37  1.17  kiyohara const char *intr_typename(int);
     38  1.17  kiyohara void genppc_cpu_configure(void);
     39  1.14        he 
     40  1.17  kiyohara /* Interrupt priority `levels'. */
     41   1.1      matt #define	IPL_NONE	0	/* nothing */
     42   1.1      matt #define	IPL_SOFTCLOCK	1	/* timeouts */
     43  1.13        ad #define	IPL_SOFTBIO	2	/* block I/O */
     44  1.13        ad #define	IPL_SOFTNET	3	/* protocol stacks */
     45  1.13        ad #define	IPL_SOFTSERIAL	4	/* serial */
     46  1.17  kiyohara #define	IPL_VM		5	/* memory allocation */
     47  1.17  kiyohara #define	IPL_SCHED	6
     48  1.17  kiyohara #define	IPL_HIGH	7	/* everything */
     49  1.17  kiyohara #define	NIPL		8
     50   1.1      matt 
     51   1.1      matt /* Interrupt sharing types. */
     52   1.1      matt #define	IST_NONE	0	/* none */
     53   1.1      matt #define	IST_PULSE	1	/* pulsed */
     54   1.1      matt #define	IST_EDGE	2	/* edge-triggered */
     55   1.1      matt #define	IST_LEVEL	3	/* level-triggered */
     56   1.1      matt 
     57  1.17  kiyohara #ifndef _LOCORE
     58   1.1      matt /*
     59  1.17  kiyohara  * Interrupt handler chains.  intr_establish() inserts a handler into
     60  1.17  kiyohara  * the list.  The handler is called with its (single) argument.
     61   1.1      matt  */
     62  1.17  kiyohara struct intrhand {
     63  1.17  kiyohara 	int	(*ih_fun)(void *);
     64  1.17  kiyohara 	void	*ih_arg;
     65  1.17  kiyohara 	struct	intrhand *ih_next;
     66  1.17  kiyohara 	int	ih_level;
     67  1.17  kiyohara 	int	ih_irq;
     68  1.17  kiyohara };
     69  1.17  kiyohara 
     70  1.17  kiyohara int splraise(int);
     71  1.17  kiyohara int spllower(int);
     72  1.17  kiyohara void splx(int);
     73  1.17  kiyohara void softintr(int);
     74   1.1      matt 
     75  1.17  kiyohara typedef uint64_t imask_t;
     76   1.1      matt extern imask_t imask[];
     77   1.1      matt 
     78  1.17  kiyohara #define NVIRQ		64	/* 64 virtual IRQs */
     79  1.17  kiyohara #define NIRQ		128	/* up to 128 HW IRQs */
     80   1.1      matt 
     81  1.17  kiyohara #define HWIRQ_MAX       (NVIRQ - 4 - 1)
     82  1.17  kiyohara #define HWIRQ_MASK      0x0ffffffffffffffeULL
     83   1.1      matt 
     84  1.17  kiyohara /* Soft interrupt masks. */
     85  1.17  kiyohara #define SIR_CLOCK	60
     86  1.17  kiyohara #define SIR_BIO		61
     87  1.17  kiyohara #define SIR_NET		62
     88  1.17  kiyohara #define SIR_SERIAL	63
     89  1.17  kiyohara #define SPL_CLOCK	0
     90  1.17  kiyohara 
     91  1.17  kiyohara #define MS_PENDING(p)	(((p) & (1 << SPL_CLOCK)) ? SPL_CLOCK : \
     92  1.17  kiyohara 			    (((p) & (0xffffffffULL << 32)) ? \
     93  1.17  kiyohara 						63 - cntlzw((p) >> 32) : \
     94  1.17  kiyohara 						32 - cntlzw((p) & 0xffffffff)))
     95  1.17  kiyohara 
     96  1.17  kiyohara #define setsoftclock()	softintr(SIR_CLOCK)
     97  1.17  kiyohara #define setsoftbio()	softintr(SIR_BIO)
     98  1.17  kiyohara #define setsoftnet()	softintr(SIR_NET)
     99  1.17  kiyohara #define setsoftserial()	softintr(SIR_SERIAL)
    100   1.4      matt 
    101  1.17  kiyohara #define spl0()		spllower(0)
    102   1.1      matt 
    103  1.11      yamt typedef int ipl_t;
    104  1.11      yamt typedef struct {
    105  1.11      yamt 	ipl_t _ipl;
    106  1.11      yamt } ipl_cookie_t;
    107  1.11      yamt 
    108  1.11      yamt static inline ipl_cookie_t
    109  1.11      yamt makeiplcookie(ipl_t ipl)
    110  1.11      yamt {
    111  1.11      yamt 
    112  1.11      yamt 	return (ipl_cookie_t){._ipl = ipl};
    113  1.11      yamt }
    114  1.11      yamt 
    115  1.11      yamt static inline int
    116  1.11      yamt splraiseipl(ipl_cookie_t icookie)
    117  1.11      yamt {
    118  1.11      yamt 
    119  1.11      yamt 	return splraise(icookie._ipl);
    120  1.11      yamt }
    121   1.8      yamt 
    122   1.8      yamt #include <sys/spl.h>
    123   1.8      yamt 
    124  1.17  kiyohara #define ICU_LEN		(64 + 32)	/* Main Interrupt(64) + GPIO(32) */
    125   1.1      matt 
    126  1.17  kiyohara extern struct pic_ops *discovery_pic;
    127  1.17  kiyohara extern struct pic_ops *discovery_gpp_pic[4];
    128  1.17  kiyohara struct pic_ops *setup_discovery_pic(void);
    129  1.17  kiyohara struct pic_ops *setup_discovery_gpp_pic(void *, int);
    130   1.1      matt 
    131   1.1      matt #endif /* !_LOCORE */
    132   1.1      matt 
    133  1.17  kiyohara #endif /* _POWERPC_MARVELL_INTR_H_ */
    134