diff options
Diffstat (limited to 'arch/sh/boards/mach-r2d')
-rw-r--r-- | arch/sh/boards/mach-r2d/Kconfig | 23 | ||||
-rw-r--r-- | arch/sh/boards/mach-r2d/Makefile | 5 | ||||
-rw-r--r-- | arch/sh/boards/mach-r2d/irq.c | 155 | ||||
-rw-r--r-- | arch/sh/boards/mach-r2d/setup.c | 258 |
4 files changed, 441 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-r2d/Kconfig b/arch/sh/boards/mach-r2d/Kconfig new file mode 100644 index 000000000000..8122a9667fc9 --- /dev/null +++ b/arch/sh/boards/mach-r2d/Kconfig | |||
@@ -0,0 +1,23 @@ | |||
1 | if SH_RTS7751R2D | ||
2 | |||
3 | menu "RTS7751R2D Board Revision" | ||
4 | |||
5 | config RTS7751R2D_PLUS | ||
6 | bool "R2D-PLUS" | ||
7 | help | ||
8 | Selecting this option will configure the kernel for R2D-PLUS. | ||
9 | |||
10 | R2D-PLUS is the smaller of the two R2D board versions, equipped | ||
11 | with a single PCI slot. | ||
12 | |||
13 | config RTS7751R2D_1 | ||
14 | bool "R2D-1" | ||
15 | help | ||
16 | Selecting this option will configure the kernel for R2D-1. | ||
17 | |||
18 | R2D-1 is the larger of the two R2D board versions, equipped | ||
19 | with two PCI slots. | ||
20 | endmenu | ||
21 | |||
22 | endif | ||
23 | |||
diff --git a/arch/sh/boards/mach-r2d/Makefile b/arch/sh/boards/mach-r2d/Makefile new file mode 100644 index 000000000000..0d4c75a72be0 --- /dev/null +++ b/arch/sh/boards/mach-r2d/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for the RTS7751R2D specific parts of the kernel | ||
3 | # | ||
4 | |||
5 | obj-y := setup.o irq.o | ||
diff --git a/arch/sh/boards/mach-r2d/irq.c b/arch/sh/boards/mach-r2d/irq.c new file mode 100644 index 000000000000..8e49f6e51247 --- /dev/null +++ b/arch/sh/boards/mach-r2d/irq.c | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * linux/arch/sh/boards/renesas/rts7751r2d/irq.c | ||
3 | * | ||
4 | * Copyright (C) 2007 Magnus Damm | ||
5 | * Copyright (C) 2000 Kazumoto Kojima | ||
6 | * | ||
7 | * Renesas Technology Sales RTS7751R2D Support, R2D-PLUS and R2D-1. | ||
8 | * | ||
9 | * Modified for RTS7751R2D by | ||
10 | * Atom Create Engineering Co., Ltd. 2002. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/irq.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <asm/rts7751r2d.h> | ||
17 | |||
18 | #define R2D_NR_IRL 13 | ||
19 | |||
20 | enum { | ||
21 | UNUSED = 0, | ||
22 | |||
23 | /* board specific interrupt sources (R2D-1 and R2D-PLUS) */ | ||
24 | EXT, /* EXT_INT0-3 */ | ||
25 | RTC_T, RTC_A, /* Real Time Clock */ | ||
26 | AX88796, /* Ethernet controller (R2D-1 board) */ | ||
27 | KEY, /* Key input (R2D-PLUS board) */ | ||
28 | SDCARD, /* SD Card */ | ||
29 | CF_CD, CF_IDE, /* CF Card Detect + CF IDE */ | ||
30 | SM501, /* SM501 aka Voyager */ | ||
31 | PCI_INTD_RTL8139, /* Ethernet controller */ | ||
32 | PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */ | ||
33 | PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */ | ||
34 | PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */ | ||
35 | PCI_INTA_SLOT, /* PCI Slot 3.3v */ | ||
36 | TP, /* Touch Panel */ | ||
37 | }; | ||
38 | |||
39 | #ifdef CONFIG_RTS7751R2D_1 | ||
40 | |||
41 | /* Vectors for R2D-1 */ | ||
42 | static struct intc_vect vectors_r2d_1[] __initdata = { | ||
43 | INTC_IRQ(EXT, IRQ_EXT), | ||
44 | INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), | ||
45 | INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD), | ||
46 | INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */ | ||
47 | INTC_IRQ(SM501, IRQ_VOYAGER), | ||
48 | INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), | ||
49 | INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), | ||
50 | INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB), | ||
51 | INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), | ||
52 | INTC_IRQ(TP, IRQ_TP), | ||
53 | }; | ||
54 | |||
55 | /* IRLMSK mask register layout for R2D-1 */ | ||
56 | static struct intc_mask_reg mask_registers_r2d_1[] __initdata = { | ||
57 | { 0xa4000000, 0, 16, /* IRLMSK */ | ||
58 | { TP, PCI_INTA_SLOT, PCI_INTB_SLOT, | ||
59 | PCI_INTC_PCI1520, PCI_INTD_RTL8139, | ||
60 | SM501, CF_IDE, CF_CD, SDCARD, AX88796, | ||
61 | RTC_A, RTC_T, 0, 0, 0, EXT } }, | ||
62 | }; | ||
63 | |||
64 | /* IRLn to IRQ table for R2D-1 */ | ||
65 | static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = { | ||
66 | IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, | ||
67 | IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T, | ||
68 | IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, | ||
69 | IRQ_TP, | ||
70 | }; | ||
71 | |||
72 | static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1, | ||
73 | NULL, mask_registers_r2d_1, NULL, NULL); | ||
74 | |||
75 | #endif /* CONFIG_RTS7751R2D_1 */ | ||
76 | |||
77 | #ifdef CONFIG_RTS7751R2D_PLUS | ||
78 | |||
79 | /* Vectors for R2D-PLUS */ | ||
80 | static struct intc_vect vectors_r2d_plus[] __initdata = { | ||
81 | INTC_IRQ(EXT, IRQ_EXT), | ||
82 | INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A), | ||
83 | INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD), | ||
84 | INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), | ||
85 | INTC_IRQ(SM501, IRQ_VOYAGER), | ||
86 | INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD), | ||
87 | INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC), | ||
88 | INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB), | ||
89 | INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA), | ||
90 | INTC_IRQ(TP, IRQ_TP), | ||
91 | }; | ||
92 | |||
93 | /* IRLMSK mask register layout for R2D-PLUS */ | ||
94 | static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = { | ||
95 | { 0xa4000000, 0, 16, /* IRLMSK */ | ||
96 | { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139, | ||
97 | PCI_INTC_PCI1520, PCI_INTD_RTL8139, | ||
98 | SM501, CF_IDE, CF_CD, SDCARD, KEY, | ||
99 | RTC_A, RTC_T, 0, 0, 0, EXT } }, | ||
100 | }; | ||
101 | |||
102 | /* IRLn to IRQ table for R2D-PLUS */ | ||
103 | static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = { | ||
104 | IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC, | ||
105 | IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T, | ||
106 | IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT, | ||
107 | IRQ_TP, | ||
108 | }; | ||
109 | |||
110 | static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus, | ||
111 | NULL, mask_registers_r2d_plus, NULL, NULL); | ||
112 | |||
113 | #endif /* CONFIG_RTS7751R2D_PLUS */ | ||
114 | |||
115 | static unsigned char irl2irq[R2D_NR_IRL]; | ||
116 | |||
117 | int rts7751r2d_irq_demux(int irq) | ||
118 | { | ||
119 | if (irq >= R2D_NR_IRL || !irl2irq[irq]) | ||
120 | return irq; | ||
121 | |||
122 | return irl2irq[irq]; | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * Initialize IRQ setting | ||
127 | */ | ||
128 | void __init init_rts7751r2d_IRQ(void) | ||
129 | { | ||
130 | struct intc_desc *d; | ||
131 | |||
132 | switch (ctrl_inw(PA_VERREG) & 0xf0) { | ||
133 | #ifdef CONFIG_RTS7751R2D_PLUS | ||
134 | case 0x10: | ||
135 | printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n"); | ||
136 | d = &intc_desc_r2d_plus; | ||
137 | memcpy(irl2irq, irl2irq_r2d_plus, R2D_NR_IRL); | ||
138 | break; | ||
139 | #endif | ||
140 | #ifdef CONFIG_RTS7751R2D_1 | ||
141 | case 0x00: /* according to manual */ | ||
142 | case 0x30: /* in reality */ | ||
143 | printk(KERN_INFO "Using R2D-1 interrupt controller.\n"); | ||
144 | d = &intc_desc_r2d_1; | ||
145 | memcpy(irl2irq, irl2irq_r2d_1, R2D_NR_IRL); | ||
146 | break; | ||
147 | #endif | ||
148 | default: | ||
149 | printk(KERN_INFO "Unknown R2D interrupt controller 0x%04x\n", | ||
150 | ctrl_inw(PA_VERREG)); | ||
151 | return; | ||
152 | } | ||
153 | |||
154 | register_intc_controller(d); | ||
155 | } | ||
diff --git a/arch/sh/boards/mach-r2d/setup.c b/arch/sh/boards/mach-r2d/setup.c new file mode 100644 index 000000000000..2308e8753bcd --- /dev/null +++ b/arch/sh/boards/mach-r2d/setup.c | |||
@@ -0,0 +1,258 @@ | |||
1 | /* | ||
2 | * Renesas Technology Sales RTS7751R2D Support. | ||
3 | * | ||
4 | * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd. | ||
5 | * Copyright (C) 2004 - 2007 Paul Mundt | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | */ | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/ata_platform.h> | ||
14 | #include <linux/sm501.h> | ||
15 | #include <linux/sm501-regs.h> | ||
16 | #include <linux/pm.h> | ||
17 | #include <linux/fb.h> | ||
18 | #include <linux/spi/spi.h> | ||
19 | #include <linux/spi/spi_bitbang.h> | ||
20 | #include <asm/machvec.h> | ||
21 | #include <asm/rts7751r2d.h> | ||
22 | #include <asm/io.h> | ||
23 | #include <asm/io_trapped.h> | ||
24 | #include <asm/spi.h> | ||
25 | |||
26 | static struct resource cf_ide_resources[] = { | ||
27 | [0] = { | ||
28 | .start = PA_AREA5_IO + 0x1000, | ||
29 | .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2, | ||
30 | .flags = IORESOURCE_MEM, | ||
31 | }, | ||
32 | [1] = { | ||
33 | .start = PA_AREA5_IO + 0x80c, | ||
34 | .end = PA_AREA5_IO + 0x80c, | ||
35 | .flags = IORESOURCE_MEM, | ||
36 | }, | ||
37 | #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */ | ||
38 | [2] = { | ||
39 | .start = IRQ_CF_IDE, | ||
40 | .flags = IORESOURCE_IRQ, | ||
41 | }, | ||
42 | #endif | ||
43 | }; | ||
44 | |||
45 | static struct pata_platform_info pata_info = { | ||
46 | .ioport_shift = 1, | ||
47 | }; | ||
48 | |||
49 | static struct platform_device cf_ide_device = { | ||
50 | .name = "pata_platform", | ||
51 | .id = -1, | ||
52 | .num_resources = ARRAY_SIZE(cf_ide_resources), | ||
53 | .resource = cf_ide_resources, | ||
54 | .dev = { | ||
55 | .platform_data = &pata_info, | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | static struct spi_board_info spi_bus[] = { | ||
60 | { | ||
61 | .modalias = "rtc-r9701", | ||
62 | .max_speed_hz = 1000000, | ||
63 | .mode = SPI_MODE_3, | ||
64 | }, | ||
65 | }; | ||
66 | |||
67 | static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state) | ||
68 | { | ||
69 | BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */ | ||
70 | ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE); | ||
71 | } | ||
72 | |||
73 | static struct sh_spi_info spi_info = { | ||
74 | .num_chipselect = 1, | ||
75 | .chip_select = r2d_chip_select, | ||
76 | }; | ||
77 | |||
78 | static struct resource spi_sh_sci_resources[] = { | ||
79 | { | ||
80 | .start = 0xffe00000, | ||
81 | .end = 0xffe0001f, | ||
82 | .flags = IORESOURCE_MEM, | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | static struct platform_device spi_sh_sci_device = { | ||
87 | .name = "spi_sh_sci", | ||
88 | .id = -1, | ||
89 | .num_resources = ARRAY_SIZE(spi_sh_sci_resources), | ||
90 | .resource = spi_sh_sci_resources, | ||
91 | .dev = { | ||
92 | .platform_data = &spi_info, | ||
93 | }, | ||
94 | }; | ||
95 | |||
96 | static struct resource heartbeat_resources[] = { | ||
97 | [0] = { | ||
98 | .start = PA_OUTPORT, | ||
99 | .end = PA_OUTPORT, | ||
100 | .flags = IORESOURCE_MEM, | ||
101 | }, | ||
102 | }; | ||
103 | |||
104 | static struct platform_device heartbeat_device = { | ||
105 | .name = "heartbeat", | ||
106 | .id = -1, | ||
107 | .num_resources = ARRAY_SIZE(heartbeat_resources), | ||
108 | .resource = heartbeat_resources, | ||
109 | }; | ||
110 | |||
111 | static struct resource sm501_resources[] = { | ||
112 | [0] = { | ||
113 | .start = 0x10000000, | ||
114 | .end = 0x13e00000 - 1, | ||
115 | .flags = IORESOURCE_MEM, | ||
116 | }, | ||
117 | [1] = { | ||
118 | .start = 0x13e00000, | ||
119 | .end = 0x13ffffff, | ||
120 | .flags = IORESOURCE_MEM, | ||
121 | }, | ||
122 | [2] = { | ||
123 | .start = IRQ_VOYAGER, | ||
124 | .flags = IORESOURCE_IRQ, | ||
125 | }, | ||
126 | }; | ||
127 | |||
128 | static struct fb_videomode sm501_default_mode = { | ||
129 | .pixclock = 35714, | ||
130 | .xres = 640, | ||
131 | .yres = 480, | ||
132 | .left_margin = 105, | ||
133 | .right_margin = 50, | ||
134 | .upper_margin = 35, | ||
135 | .lower_margin = 0, | ||
136 | .hsync_len = 96, | ||
137 | .vsync_len = 2, | ||
138 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | ||
139 | }; | ||
140 | |||
141 | static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = { | ||
142 | .def_bpp = 16, | ||
143 | .def_mode = &sm501_default_mode, | ||
144 | .flags = SM501FB_FLAG_USE_INIT_MODE | | ||
145 | SM501FB_FLAG_USE_HWCURSOR | | ||
146 | SM501FB_FLAG_USE_HWACCEL | | ||
147 | SM501FB_FLAG_DISABLE_AT_EXIT, | ||
148 | }; | ||
149 | |||
150 | static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = { | ||
151 | .flags = (SM501FB_FLAG_USE_INIT_MODE | | ||
152 | SM501FB_FLAG_USE_HWCURSOR | | ||
153 | SM501FB_FLAG_USE_HWACCEL | | ||
154 | SM501FB_FLAG_DISABLE_AT_EXIT), | ||
155 | |||
156 | }; | ||
157 | |||
158 | static struct sm501_platdata_fb sm501_fb_pdata = { | ||
159 | .fb_route = SM501_FB_OWN, | ||
160 | .fb_crt = &sm501_pdata_fbsub_crt, | ||
161 | .fb_pnl = &sm501_pdata_fbsub_pnl, | ||
162 | .flags = SM501_FBPD_SWAP_FB_ENDIAN, | ||
163 | }; | ||
164 | |||
165 | static struct sm501_initdata sm501_initdata = { | ||
166 | .devices = SM501_USE_USB_HOST | SM501_USE_UART0, | ||
167 | }; | ||
168 | |||
169 | static struct sm501_platdata sm501_platform_data = { | ||
170 | .init = &sm501_initdata, | ||
171 | .fb = &sm501_fb_pdata, | ||
172 | }; | ||
173 | |||
174 | static struct platform_device sm501_device = { | ||
175 | .name = "sm501", | ||
176 | .id = -1, | ||
177 | .dev = { | ||
178 | .platform_data = &sm501_platform_data, | ||
179 | }, | ||
180 | .num_resources = ARRAY_SIZE(sm501_resources), | ||
181 | .resource = sm501_resources, | ||
182 | }; | ||
183 | |||
184 | static struct platform_device *rts7751r2d_devices[] __initdata = { | ||
185 | &sm501_device, | ||
186 | &heartbeat_device, | ||
187 | &spi_sh_sci_device, | ||
188 | }; | ||
189 | |||
190 | /* | ||
191 | * The CF is connected with a 16-bit bus where 8-bit operations are | ||
192 | * unsupported. The linux ata driver is however using 8-bit operations, so | ||
193 | * insert a trapped io filter to convert 8-bit operations into 16-bit. | ||
194 | */ | ||
195 | static struct trapped_io cf_trapped_io = { | ||
196 | .resource = cf_ide_resources, | ||
197 | .num_resources = 2, | ||
198 | .minimum_bus_width = 16, | ||
199 | }; | ||
200 | |||
201 | static int __init rts7751r2d_devices_setup(void) | ||
202 | { | ||
203 | if (register_trapped_io(&cf_trapped_io) == 0) | ||
204 | platform_device_register(&cf_ide_device); | ||
205 | |||
206 | spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); | ||
207 | |||
208 | return platform_add_devices(rts7751r2d_devices, | ||
209 | ARRAY_SIZE(rts7751r2d_devices)); | ||
210 | } | ||
211 | __initcall(rts7751r2d_devices_setup); | ||
212 | |||
213 | static void rts7751r2d_power_off(void) | ||
214 | { | ||
215 | ctrl_outw(0x0001, PA_POWOFF); | ||
216 | } | ||
217 | |||
218 | /* | ||
219 | * Initialize the board | ||
220 | */ | ||
221 | static void __init rts7751r2d_setup(char **cmdline_p) | ||
222 | { | ||
223 | void __iomem *sm501_reg; | ||
224 | u16 ver = ctrl_inw(PA_VERREG); | ||
225 | |||
226 | printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n"); | ||
227 | |||
228 | printk(KERN_INFO "FPGA version:%d (revision:%d)\n", | ||
229 | (ver >> 4) & 0xf, ver & 0xf); | ||
230 | |||
231 | ctrl_outw(0x0000, PA_OUTPORT); | ||
232 | pm_power_off = rts7751r2d_power_off; | ||
233 | |||
234 | /* sm501 dram configuration: | ||
235 | * ColSizeX = 11 - External Memory Column Size: 256 words. | ||
236 | * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks. | ||
237 | * RstX = 1 - External Memory Reset: Normal. | ||
238 | * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks. | ||
239 | * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks. | ||
240 | * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock. | ||
241 | * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks. | ||
242 | * Rst = 1 - Internal Memory Reset: Normal. | ||
243 | * RA = 1 - Internal Memory Remain in Active State: Do not remain. | ||
244 | */ | ||
245 | |||
246 | sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL; | ||
247 | writel(readl(sm501_reg) | 0x00f107c0, sm501_reg); | ||
248 | } | ||
249 | |||
250 | /* | ||
251 | * The Machine Vector | ||
252 | */ | ||
253 | static struct sh_machine_vector mv_rts7751r2d __initmv = { | ||
254 | .mv_name = "RTS7751R2D", | ||
255 | .mv_setup = rts7751r2d_setup, | ||
256 | .mv_init_irq = init_rts7751r2d_IRQ, | ||
257 | .mv_irq_demux = rts7751r2d_irq_demux, | ||
258 | }; | ||