xref: /linux/arch/sh/boards/mach-highlander/irq-r7785rp.c (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
2da2014a2SPaul Mundt /*
3da2014a2SPaul Mundt  * Renesas Solutions Highlander R7785RP Support.
4da2014a2SPaul Mundt  *
5da2014a2SPaul Mundt  * Copyright (C) 2002  Atom Create Engineering Co., Ltd.
6da2014a2SPaul Mundt  * Copyright (C) 2006 - 2008  Paul Mundt
7da2014a2SPaul Mundt  * Copyright (C) 2007  Magnus Damm
8da2014a2SPaul Mundt  */
9da2014a2SPaul Mundt #include <linux/init.h>
10da2014a2SPaul Mundt #include <linux/irq.h>
11da2014a2SPaul Mundt #include <linux/io.h>
127639a454SPaul Mundt #include <mach/highlander.h>
13da2014a2SPaul Mundt 
14da2014a2SPaul Mundt enum {
15da2014a2SPaul Mundt 	UNUSED = 0,
16da2014a2SPaul Mundt 
17da2014a2SPaul Mundt 	/* FPGA specific interrupt sources */
18da2014a2SPaul Mundt 	CF,		/* Compact Flash */
19da2014a2SPaul Mundt 	SMBUS,		/* SMBUS */
20da2014a2SPaul Mundt 	TP,		/* Touch panel */
21da2014a2SPaul Mundt 	RTC,		/* RTC Alarm */
22da2014a2SPaul Mundt 	TH_ALERT,	/* Temperature sensor */
23da2014a2SPaul Mundt 	AX88796,	/* Ethernet controller */
24da2014a2SPaul Mundt 
25da2014a2SPaul Mundt 	/* external bus connector */
26da2014a2SPaul Mundt 	EXT0, EXT1, EXT2, EXT3, EXT4, EXT5, EXT6, EXT7,
27da2014a2SPaul Mundt };
28da2014a2SPaul Mundt 
29da2014a2SPaul Mundt static struct intc_vect vectors[] __initdata = {
30da2014a2SPaul Mundt 	INTC_IRQ(CF, IRQ_CF),
31da2014a2SPaul Mundt 	INTC_IRQ(SMBUS, IRQ_SMBUS),
32da2014a2SPaul Mundt 	INTC_IRQ(TP, IRQ_TP),
33da2014a2SPaul Mundt 	INTC_IRQ(RTC, IRQ_RTC),
34da2014a2SPaul Mundt 	INTC_IRQ(TH_ALERT, IRQ_TH_ALERT),
35da2014a2SPaul Mundt 
36da2014a2SPaul Mundt 	INTC_IRQ(EXT0, IRQ_EXT0), INTC_IRQ(EXT1, IRQ_EXT1),
37da2014a2SPaul Mundt 	INTC_IRQ(EXT2, IRQ_EXT2), INTC_IRQ(EXT3, IRQ_EXT3),
38da2014a2SPaul Mundt 
39da2014a2SPaul Mundt 	INTC_IRQ(EXT4, IRQ_EXT4), INTC_IRQ(EXT5, IRQ_EXT5),
40da2014a2SPaul Mundt 	INTC_IRQ(EXT6, IRQ_EXT6), INTC_IRQ(EXT7, IRQ_EXT7),
41da2014a2SPaul Mundt 
42da2014a2SPaul Mundt 	INTC_IRQ(AX88796, IRQ_AX88796),
43da2014a2SPaul Mundt };
44da2014a2SPaul Mundt 
45da2014a2SPaul Mundt static struct intc_mask_reg mask_registers[] __initdata = {
46da2014a2SPaul Mundt 	{ 0xa4000010, 0, 16, /* IRLMCR1 */
47da2014a2SPaul Mundt 	  { 0, 0, 0, 0, CF, AX88796, SMBUS, TP,
48da2014a2SPaul Mundt 	    RTC, 0, TH_ALERT, 0, 0, 0, 0, 0 } },
49da2014a2SPaul Mundt 	{ 0xa4000012, 0, 16, /* IRLMCR2 */
50da2014a2SPaul Mundt 	  { 0, 0, 0, 0, 0, 0, 0, 0,
51da2014a2SPaul Mundt 	    EXT7, EXT6, EXT5, EXT4, EXT3, EXT2, EXT1, EXT0 } },
52da2014a2SPaul Mundt };
53da2014a2SPaul Mundt 
54da2014a2SPaul Mundt static unsigned char irl2irq[HL_NR_IRL] __initdata = {
55da2014a2SPaul Mundt 	0, IRQ_CF, IRQ_EXT4, IRQ_EXT5,
56da2014a2SPaul Mundt 	IRQ_EXT6, IRQ_EXT7, IRQ_SMBUS, IRQ_TP,
57da2014a2SPaul Mundt 	IRQ_RTC, IRQ_TH_ALERT, IRQ_AX88796, IRQ_EXT0,
58da2014a2SPaul Mundt 	IRQ_EXT1, IRQ_EXT2, IRQ_EXT3,
59da2014a2SPaul Mundt };
60da2014a2SPaul Mundt 
61da2014a2SPaul Mundt static DECLARE_INTC_DESC(intc_desc, "r7785rp", vectors,
62da2014a2SPaul Mundt 			 NULL, mask_registers, NULL, NULL);
63da2014a2SPaul Mundt 
highlander_plat_irq_setup(void)64da2014a2SPaul Mundt unsigned char * __init highlander_plat_irq_setup(void)
65da2014a2SPaul Mundt {
669d56dd3bSPaul Mundt 	if ((__raw_readw(0xa4000158) & 0xf000) != 0x1000)
67da2014a2SPaul Mundt 		return NULL;
68da2014a2SPaul Mundt 
69da2014a2SPaul Mundt 	printk(KERN_INFO "Using r7785rp interrupt controller.\n");
70da2014a2SPaul Mundt 
719d56dd3bSPaul Mundt 	__raw_writew(0x0000, PA_IRLSSR1);	/* FPGA IRLSSR1(CF_CD clear) */
72da2014a2SPaul Mundt 
73da2014a2SPaul Mundt 	/* Setup the FPGA IRL */
749d56dd3bSPaul Mundt 	__raw_writew(0x0000, PA_IRLPRA);	/* FPGA IRLA */
759d56dd3bSPaul Mundt 	__raw_writew(0xe598, PA_IRLPRB);	/* FPGA IRLB */
769d56dd3bSPaul Mundt 	__raw_writew(0x7060, PA_IRLPRC);	/* FPGA IRLC */
779d56dd3bSPaul Mundt 	__raw_writew(0x0000, PA_IRLPRD);	/* FPGA IRLD */
789d56dd3bSPaul Mundt 	__raw_writew(0x4321, PA_IRLPRE);	/* FPGA IRLE */
799d56dd3bSPaul Mundt 	__raw_writew(0xdcba, PA_IRLPRF);	/* FPGA IRLF */
80da2014a2SPaul Mundt 
81da2014a2SPaul Mundt 	register_intc_controller(&intc_desc);
82da2014a2SPaul Mundt 	return irl2irq;
83da2014a2SPaul Mundt }
84