sh: rework ipr code
[linux-2.6.git] / arch / sh / boards / sh03 / setup.c
1 /*
2  * linux/arch/sh/boards/sh03/setup.c
3  *
4  * Copyright (C) 2004  Interface Co.,Ltd. Saito.K
5  *
6  */
7
8 #include <linux/init.h>
9 #include <linux/irq.h>
10 #include <linux/pci.h>
11 #include <linux/platform_device.h>
12 #include <asm/io.h>
13 #include <asm/rtc.h>
14 #include <asm/sh03/io.h>
15 #include <asm/sh03/sh03.h>
16 #include <asm/addrspace.h>
17
18 static struct ipr_data ipr_irq_table[] = {
19         { IRL0_IRQ, 0, IRL0_IPR_POS, IRL0_PRIORITY },
20         { IRL1_IRQ, 0, IRL1_IPR_POS, IRL1_PRIORITY },
21         { IRL2_IRQ, 0, IRL2_IPR_POS, IRL2_PRIORITY },
22         { IRL3_IRQ, 0, IRL3_IPR_POS, IRL3_PRIORITY },
23 };
24
25 static unsigned long ipr_offsets[] = {
26         INTC_IPRD,
27 };
28
29 static struct ipr_desc ipr_irq_desc = {
30         .ipr_offsets    = ipr_offsets,
31         .nr_offsets     = ARRAY_SIZE(ipr_offsets),
32
33         .ipr_data       = ipr_irq_table,
34         .nr_irqs        = ARRAY_SIZE(ipr_irq_table),
35
36         .chip = {
37                 .name   = "IPR-sh03",
38         },
39 };
40
41 static void __init init_sh03_IRQ(void)
42 {
43         ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
44         register_ipr_controller(&ipr_irq_desc);
45 }
46
47 extern void *cf_io_base;
48
49 static void __iomem *sh03_ioport_map(unsigned long port, unsigned int size)
50 {
51         if (PXSEG(port))
52                 return (void __iomem *)port;
53         /* CompactFlash (IDE) */
54         if (((port >= 0x1f0) && (port <= 0x1f7)) || (port == 0x3f6))
55                 return (void __iomem *)((unsigned long)cf_io_base + port);
56
57         return (void __iomem *)(port + PCI_IO_BASE);
58 }
59
60 /* arch/sh/boards/sh03/rtc.c */
61 void sh03_time_init(void);
62
63 static void __init sh03_setup(char **cmdline_p)
64 {
65         board_time_init = sh03_time_init;
66 }
67
68 static struct resource heartbeat_resources[] = {
69         [0] = {
70                 .start  = 0xa0800000,
71                 .end    = 0xa0800000 + 8 - 1,
72                 .flags  = IORESOURCE_MEM,
73         },
74 };
75
76 static struct platform_device heartbeat_device = {
77         .name           = "heartbeat",
78         .id             = -1,
79         .num_resources  = ARRAY_SIZE(heartbeat_resources),
80         .resource       = heartbeat_resources,
81 };
82
83 static struct platform_device *sh03_devices[] __initdata = {
84         &heartbeat_device,
85 };
86
87 static int __init sh03_devices_setup(void)
88 {
89         return platform_add_devices(sh03_devices, ARRAY_SIZE(sh03_devices));
90 }
91 __initcall(sh03_devices_setup);
92
93 static struct sh_machine_vector mv_sh03 __initmv = {
94         .mv_name                = "Interface (CTP/PCI-SH03)",
95         .mv_setup               = sh03_setup,
96         .mv_nr_irqs             = 48,
97         .mv_ioport_map          = sh03_ioport_map,
98         .mv_init_irq            = init_sh03_IRQ,
99 };