Home | History | Annotate | Line # | Download | only in marvell
marvell_intr.h revision 1.14.2.3
      1  1.14.2.3  yamt /*	$NetBSD: marvell_intr.h,v 1.14.2.3 2010/08/11 22:52:35 yamt 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.14.2.3  yamt #ifndef _POWERPC_MARVELL_INTR_H_
     33  1.14.2.3  yamt #define _POWERPC_MARVELL_INTR_H_
     34       1.1  matt 
     35  1.14.2.3  yamt void *intr_establish(int, int, int, int (*)(void *), void *);
     36  1.14.2.3  yamt void intr_disestablish(void *);
     37  1.14.2.3  yamt const char *intr_typename(int);
     38  1.14.2.3  yamt void genppc_cpu_configure(void);
     39      1.14    he 
     40  1.14.2.3  yamt /* 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.14.2.3  yamt #define	IPL_VM		5	/* memory allocation */
     47  1.14.2.3  yamt #define	IPL_SCHED	6
     48  1.14.2.3  yamt #define	IPL_HIGH	7	/* everything */
     49  1.14.2.3  yamt #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.14.2.3  yamt #ifndef _LOCORE
     58       1.1  matt /*
     59  1.14.2.3  yamt  * Interrupt handler chains.  intr_establish() inserts a handler into
     60  1.14.2.3  yamt  * the list.  The handler is called with its (single) argument.
     61       1.1  matt  */
     62  1.14.2.3  yamt struct intrhand {
     63  1.14.2.3  yamt 	int	(*ih_fun)(void *);
     64  1.14.2.3  yamt 	void	*ih_arg;
     65  1.14.2.3  yamt 	struct	intrhand *ih_next;
     66  1.14.2.3  yamt 	int	ih_level;
     67  1.14.2.3  yamt 	int	ih_irq;
     68  1.14.2.3  yamt };
     69  1.14.2.3  yamt 
     70  1.14.2.3  yamt int splraise(int);
     71  1.14.2.3  yamt int spllower(int);
     72  1.14.2.3  yamt void splx(int);
     73  1.14.2.3  yamt void softintr(int);
     74       1.1  matt 
     75  1.14.2.3  yamt typedef uint64_t imask_t;
     76       1.1  matt extern imask_t imask[];
     77       1.1  matt 
     78  1.14.2.3  yamt #define NVIRQ		64	/* 64 virtual IRQs */
     79  1.14.2.3  yamt #define NIRQ		128	/* up to 128 HW IRQs */
     80       1.1  matt 
     81  1.14.2.3  yamt #define HWIRQ_MAX       (NVIRQ - 4 - 1)
     82  1.14.2.3  yamt #define HWIRQ_MASK      0x0ffffffffffffffeULL
     83       1.1  matt 
     84  1.14.2.3  yamt /* Soft interrupt masks. */
     85  1.14.2.3  yamt #define SIR_CLOCK	60
     86  1.14.2.3  yamt #define SIR_BIO		61
     87  1.14.2.3  yamt #define SIR_NET		62
     88  1.14.2.3  yamt #define SIR_SERIAL	63
     89  1.14.2.3  yamt #define SPL_CLOCK	0
     90  1.14.2.3  yamt 
     91  1.14.2.3  yamt #define MS_PENDING(p)	(((p) & (1 << SPL_CLOCK)) ? SPL_CLOCK : \
     92  1.14.2.3  yamt 			    (((p) & (0xffffffffULL << 32)) ? \
     93  1.14.2.3  yamt 						63 - cntlzw((p) >> 32) : \
     94  1.14.2.3  yamt 						32 - cntlzw((p) & 0xffffffff)))
     95  1.14.2.3  yamt 
     96  1.14.2.3  yamt #define setsoftclock()	softintr(SIR_CLOCK)
     97  1.14.2.3  yamt #define setsoftbio()	softintr(SIR_BIO)
     98  1.14.2.3  yamt #define setsoftnet()	softintr(SIR_NET)
     99  1.14.2.3  yamt #define setsoftserial()	softintr(SIR_SERIAL)
    100       1.4  matt 
    101  1.14.2.3  yamt #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.14.2.3  yamt #define ICU_LEN		(64 + 32)	/* Main Interrupt(64) + GPIO(32) */
    125       1.1  matt 
    126  1.14.2.3  yamt extern struct pic_ops *discovery_pic;
    127  1.14.2.3  yamt extern struct pic_ops *discovery_gpp_pic[4];
    128  1.14.2.3  yamt struct pic_ops *setup_discovery_pic(void);
    129  1.14.2.3  yamt 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.14.2.3  yamt #endif /* _POWERPC_MARVELL_INTR_H_ */
    134