2 * linux/arch/sh/boards/snapgear/setup.c
4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
5 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
7 * Based on files with the following comments:
9 * Copyright (C) 2000 Kazumoto Kojima
11 * Modified for 7751 Solution Engine by
12 * Ian da Silva and Jeremy Siegel, 2001.
14 #include <linux/init.h>
15 #include <linux/irq.h>
16 #include <linux/interrupt.h>
17 #include <linux/timer.h>
18 #include <linux/delay.h>
19 #include <linux/module.h>
20 #include <linux/sched.h>
21 #include <asm/machvec.h>
22 #include <asm/snapgear.h>
26 #include <asm/cpu/timer.h>
28 #include <linux/platform_device.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/plat-ram.h>
32 extern void pcibios_init(void);
34 /****************************************************************************/
36 * EraseConfig handling functions
39 static irqreturn_t
eraseconfig_interrupt(int irq
, void *dev_id
)
41 volatile char dummy
__attribute__((unused
)) = * (volatile char *)0xb8000000;
44 extern void ledman_signalreset(void);
47 printk("SnapGear: erase switch interrupt!\n");
53 static int __init
eraseconfig_init(void)
55 printk("SnapGear: EraseConfig init\n");
56 /* Setup "EraseConfig" switch on external IRQ 0 */
57 if (request_irq(IRL0_IRQ
, eraseconfig_interrupt
, IRQF_DISABLED
,
58 "Erase Config", NULL
))
59 printk("SnapGear: failed to register IRQ%d for Reset witch\n",
62 printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
67 module_init(eraseconfig_init
);
69 /****************************************************************************/
71 * Initialize IRQ setting
79 static struct ipr_data snapgear_ipr_map
[] = {
80 { IRL0_IRQ
, IRL0_IPR_ADDR
, IRL0_IPR_POS
, IRL0_PRIORITY
},
81 { IRL1_IRQ
, IRL1_IPR_ADDR
, IRL1_IPR_POS
, IRL1_PRIORITY
},
82 { IRL2_IRQ
, IRL2_IPR_ADDR
, IRL2_IPR_POS
, IRL2_PRIORITY
},
83 { IRL3_IRQ
, IRL3_IPR_ADDR
, IRL3_IPR_POS
, IRL3_PRIORITY
},
84 { RTC_PRI_IRQ
, RTC_IPR_ADDR
, RTC_IPR_POS
, RTC_PRIORITY
},
85 { RTC_CUI_IRQ
, RTC_IPR_ADDR
, RTC_IPR_POS
, RTC_PRIORITY
},
86 { RTC_ATI_IRQ
, RTC_IPR_ADDR
, RTC_IPR_POS
, RTC_PRIORITY
},
89 static void __init
init_snapgear_IRQ(void)
91 /* enable individual interrupt mode for externals */
92 ctrl_outw(ctrl_inw(INTC_ICR
) | INTC_ICR_IRLM
, INTC_ICR
);
94 printk("Setup SnapGear IRQ/IPR ...\n");
96 make_ipr_irq(snapgear_ipr_map
, ARRAY_SIZE(snapgear_ipr_map
));
100 * This is set up by the setup-routine at boot-time
102 #define PARAM ((unsigned char *)empty_zero_page)
104 #define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
105 #define INITRD_START (*(unsigned long *) (PARAM+0x010))
106 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
108 static struct resource sg_mtd_ram_resource
= {
109 .flags
= IORESOURCE_MEM
,
112 static struct platdata_mtd_ram sg_mtd_ram_data
= {
118 static struct platform_device sg_mtd_ram_device
= {
121 .dev
.platform_data
= &sg_mtd_ram_data
,
123 .resource
= &sg_mtd_ram_resource
,
126 #ifdef CONFIG_RTC_DRV_DS1302
127 static struct platform_device sg_rtc_device
= {
134 #ifdef CONFIG_RTC_DRV_SH
135 static struct resource sh_rtc_resources
[] = {
138 .end
= RTC_BASE
+ 0x58 - 1,
139 .flags
= IORESOURCE_IO
,
143 .start
= RTC_PRI_IRQ
,
144 .flags
= IORESOURCE_IRQ
,
148 .start
= RTC_CUI_IRQ
,
149 .flags
= IORESOURCE_IRQ
,
153 .start
= RTC_ATI_IRQ
,
154 .flags
= IORESOURCE_IRQ
,
158 static struct platform_device sh_rtc_device
= {
161 .num_resources
= ARRAY_SIZE(sh_rtc_resources
),
162 .resource
= sh_rtc_resources
,
166 static int __init
sg_devices_setup(void)
168 int ret
= 0, ret2
= 0;
170 if (sg_mtd_ram_resource
.start
)
171 ret
= platform_device_register(&sg_mtd_ram_device
);
173 #ifdef CONFIG_RTC_DRV_DS1302
174 ret2
= platform_device_register(&sg_rtc_device
);
178 #ifdef CONFIG_RTC_DRV_SH
179 ret2
= platform_device_register(&sh_rtc_device
);
182 return ret
? ret
: ret2
;
185 __initcall(sg_devices_setup
);
188 * Initialize the board
190 static void __init
snapgear_setup(char **cmdline_p
)
192 if (!LOADER_TYPE
&& INITRD_START
) {
193 sg_mtd_ram_resource
.start
= INITRD_START
;
194 sg_mtd_ram_resource
.end
= INITRD_START
+ INITRD_SIZE
- 1;
201 struct sh_machine_vector mv_snapgear __initmv
= {
202 .mv_name
= "SnapGear SecureEdge5410",
203 .mv_setup
= snapgear_setup
,
206 .mv_inb
= snapgear_inb
,
207 .mv_inw
= snapgear_inw
,
208 .mv_inl
= snapgear_inl
,
209 .mv_outb
= snapgear_outb
,
210 .mv_outw
= snapgear_outw
,
211 .mv_outl
= snapgear_outl
,
213 .mv_inb_p
= snapgear_inb_p
,
214 .mv_inw_p
= snapgear_inw
,
215 .mv_inl_p
= snapgear_inl
,
216 .mv_outb_p
= snapgear_outb_p
,
217 .mv_outw_p
= snapgear_outw
,
218 .mv_outl_p
= snapgear_outl
,
220 .mv_init_irq
= init_snapgear_IRQ
,