Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * arch/m68k/atari/ataints.c -- Atari Linux interrupt handling code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * 5/2/94 Roman Hodek:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Added support for TT interrupts; setup for TT SCU (may someone has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  twiddled there and we won't get the right interrupts :-()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Major change: The device-independent code in m68k/ints.c didn't know
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  about non-autovec ints yet. It hardcoded the number of possible ints to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  7 (IRQ1...IRQ7). But the Atari has lots of non-autovec ints! I made the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  number of possible ints a constant defined in interrupt.h, which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  47 for the Atari. So we can call request_irq() for all Atari interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  just the normal way. Additionally, all vectors >= 48 are initialized to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  call trap() instead of inthandler(). This must be changed here, too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * 1995-07-16 Lars Brinkhoff <f93labr@dd.chalmers.se>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  Corrected a bug in atari_add_isr() which rejected all SCC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  interrupt sources if there were no TT MFP!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * 12/13/95: New interface functions atari_level_triggered_int() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *  atari_register_vme_int() as support for level triggered VME interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * 02/12/96: (Roman)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  Total rewrite of Atari interrupt handling, for new scheme see comments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *  below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * 1996-09-03 lars brinkhoff <f93labr@dd.chalmers.se>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *  Added new function atari_unregister_vme_int(), and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *  modified atari_register_vme_int() as well as IS_VALID_INTNO()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *  to work with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * License.  See the file COPYING in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/kernel_stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <asm/atarihw.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #include <asm/atariints.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <asm/atari_stdma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include <asm/entry.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * Atari interrupt handling scheme:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * All interrupt source have an internal number (defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * <asm/atariints.h>): Autovector interrupts are 1..7, then follow ST-MFP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * TT-MFP, SCC, and finally VME interrupts. Vector numbers for the latter can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * be allocated by atari_register_vme_int().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * Bitmap for free interrupt vector numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * (new vectors starting from 0x70 can be allocated by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * atari_register_vme_int())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static int free_vme_vec_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /* GK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * HBL IRQ handler for Falcon. Nobody needs it :-)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * ++andreas: raise ipl to disable further HBLANK interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) asmlinkage void falcon_hblhandler(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) asm(".text\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) __ALIGN_STR "\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) "falcon_hblhandler:\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	"orw	#0x200,%sp@\n\t"	/* set saved ipl to 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	"rte");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) extern void atari_microwire_cmd(int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static unsigned int atari_irq_startup(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	unsigned int irq = data->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	m68k_irq_startup(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	atari_turnon_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	atari_enable_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static void atari_irq_shutdown(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned int irq = data->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	atari_disable_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	atari_turnoff_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	m68k_irq_shutdown(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	if (irq == IRQ_AUTO_4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	    vectors[VEC_INT4] = falcon_hblhandler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static void atari_irq_enable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	atari_enable_irq(data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static void atari_irq_disable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	atari_disable_irq(data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static struct irq_chip atari_irq_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.name		= "atari",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.irq_startup	= atari_irq_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.irq_shutdown	= atari_irq_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	.irq_enable	= atari_irq_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	.irq_disable	= atari_irq_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * ST-MFP timer D chained interrupts - each driver gets its own timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * interrupt instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct mfptimerbase {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	volatile struct MFP *mfp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	unsigned char mfp_mask, mfp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	unsigned short int_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	int handler_irq, mfptimer_irq, server_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) } stmfp_base = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	.mfp		= &st_mfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	.int_mask	= 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.handler_irq	= IRQ_MFP_TIMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	.mfptimer_irq	= IRQ_MFP_TIMER1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	.name		= "MFP Timer D"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static irqreturn_t mfp_timer_d_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct mfptimerbase *base = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int mach_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	unsigned char ints;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	mach_irq = base->mfptimer_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ints = base->int_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	for (; ints; mach_irq++, ints >>= 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		if (ints & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			generic_handle_irq(mach_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static void atari_mfptimer_enable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	int mfp_num = data->irq - IRQ_MFP_TIMER1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	stmfp_base.int_mask |= 1 << mfp_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	atari_enable_irq(IRQ_MFP_TIMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static void atari_mfptimer_disable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	int mfp_num = data->irq - IRQ_MFP_TIMER1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	stmfp_base.int_mask &= ~(1 << mfp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (!stmfp_base.int_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		atari_disable_irq(IRQ_MFP_TIMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static struct irq_chip atari_mfptimer_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	.name		= "timer_d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.irq_enable	= atari_mfptimer_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	.irq_disable	= atari_mfptimer_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * EtherNAT CPLD interrupt handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * CPLD interrupt register is at phys. 0x80000023
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * Need this mapped in at interrupt startup time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * Possibly need this mapped on demand anyway -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * EtherNAT USB driver needs to disable IRQ before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * startup!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static unsigned char *enat_cpld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static unsigned int atari_ethernat_startup(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int enat_num = 140 - data->irq + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	m68k_irq_startup(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	* map CPLD interrupt register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (!enat_cpld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		enat_cpld = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	 * do _not_ enable the USB chip interrupt here - causes interrupt storm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	 * and triggers dead interrupt watchdog
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	 * Need to reset the USB chip to a sane state in early startup before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 * removing this hack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (enat_num == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		*enat_cpld |= 1 << enat_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static void atari_ethernat_enable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	int enat_num = 140 - data->irq + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	* map CPLD interrupt register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (!enat_cpld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		enat_cpld = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	*enat_cpld |= 1 << enat_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static void atari_ethernat_disable(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	int enat_num = 140 - data->irq + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	* map CPLD interrupt register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (!enat_cpld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		enat_cpld = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	*enat_cpld &= ~(1 << enat_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static void atari_ethernat_shutdown(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	int enat_num = 140 - data->irq + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	if (enat_cpld) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		*enat_cpld &= ~(1 << enat_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		iounmap(enat_cpld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		enat_cpld = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static struct irq_chip atari_ethernat_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	.name		= "ethernat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	.irq_startup	= atari_ethernat_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	.irq_shutdown	= atari_ethernat_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	.irq_enable	= atari_ethernat_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	.irq_disable	= atari_ethernat_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  * void atari_init_IRQ (void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)  * Parameters:	None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  * Returns:	Nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * This function should be called during kernel startup to initialize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  * the atari IRQ handling routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) void __init atari_init_IRQ(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	m68k_setup_user_interrupt(VEC_USER, NUM_ATARI_SOURCES - IRQ_USER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	m68k_setup_irq_controller(&atari_irq_chip, handle_simple_irq, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 				  NUM_ATARI_SOURCES - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/* Initialize the MFP(s) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #ifdef ATARI_USE_SOFTWARE_EOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	st_mfp.vec_adr  = 0x48;	/* Software EOI-Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	st_mfp.vec_adr  = 0x40;	/* Automatic EOI-Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	st_mfp.int_en_a = 0x00;	/* turn off MFP-Ints */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	st_mfp.int_en_b = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	st_mfp.int_mk_a = 0xff;	/* no Masking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	st_mfp.int_mk_b = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (ATARIHW_PRESENT(TT_MFP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #ifdef ATARI_USE_SOFTWARE_EOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		tt_mfp.vec_adr  = 0x58;		/* Software EOI-Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		tt_mfp.vec_adr  = 0x50;		/* Automatic EOI-Mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		tt_mfp.int_en_a = 0x00;		/* turn off MFP-Ints */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		tt_mfp.int_en_b = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		tt_mfp.int_mk_a = 0xff;		/* no Masking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		tt_mfp.int_mk_b = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (ATARIHW_PRESENT(SCC) && !atari_SCC_reset_done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		atari_scc.cha_a_ctrl = 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		MFPDELAY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		atari_scc.cha_a_ctrl = (char) 0xc0; /* hardware reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (ATARIHW_PRESENT(SCU)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		/* init the SCU if present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		tt_scu.sys_mask = 0x10;		/* enable VBL (for the cursor) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 									 * disable HSYNC interrupts (who
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 									 * needs them?)  MFP and SCC are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 									 * enabled in VME mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 									 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		tt_scu.vme_mask = 0x60;		/* enable MFP and SCC ints */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		/* If no SCU and no Hades, the HSYNC interrupt needs to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		 * disabled this way. (Else _inthandler in kernel/sys_call.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		 * gets overruns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		vectors[VEC_INT2] = falcon_hblhandler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		vectors[VEC_INT4] = falcon_hblhandler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	if (ATARIHW_PRESENT(PCM_8BIT) && ATARIHW_PRESENT(MICROWIRE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		/* Initialize the LM1992 Sound Controller to enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		   the PSG sound.  This is misplaced here, it should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		   be in an atasound_init(), that doesn't exist yet. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		atari_microwire_cmd(MW_LM1992_PSG_HIGH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	stdma_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/* Initialize the PSG: all sounds off, both ports output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	sound_ym.rd_data_reg_sel = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	sound_ym.wd_data = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	m68k_setup_irq_controller(&atari_mfptimer_chip, handle_simple_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 				  IRQ_MFP_TIMER1, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	irq_set_status_flags(IRQ_MFP_TIMER1, IRQ_IS_POLLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	irq_set_status_flags(IRQ_MFP_TIMER2, IRQ_IS_POLLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	/* prepare timer D data for use as poll interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	/* set Timer D data Register - needs to be > 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	st_mfp.tim_dt_d = 254;	/* < 100 Hz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	/* start timer D, div = 1:100 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	/* request timer D dispatch handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (request_irq(IRQ_MFP_TIMD, mfp_timer_d_handler, IRQF_SHARED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			stmfp_base.name, &stmfp_base))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	 * EtherNAT ethernet / USB interrupt handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	m68k_setup_irq_controller(&atari_ethernat_chip, handle_simple_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				  139, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  * atari_register_vme_int() returns the number of a free interrupt vector for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  * hardware with a programmable int vector (probably a VME board).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) unsigned int atari_register_vme_int(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	for (i = 0; i < 32; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		if ((free_vme_vec_bitmap & (1 << i)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if (i == 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	free_vme_vec_bitmap |= 1 << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	return VME_SOURCE_BASE + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) EXPORT_SYMBOL(atari_register_vme_int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) void atari_unregister_vme_int(unsigned int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	if (irq >= VME_SOURCE_BASE && irq < VME_SOURCE_BASE + VME_MAX_SOURCES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		irq -= VME_SOURCE_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		free_vme_vec_bitmap &= ~(1 << irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) EXPORT_SYMBOL(atari_unregister_vme_int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)