2 * arch/sh/boards/renesas/r7780rp/setup.c
4 * Renesas Solutions Highlander Support.
6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
7 * Copyright (C) 2005 - 2008 Paul Mundt
9 * This contains support for the R7780RP-1, R7780MP, and R7785RP
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/ata_platform.h>
19 #include <linux/types.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/i2c.h>
22 #include <linux/irq.h>
23 #include <linux/interrupt.h>
24 #include <linux/usb/r8a66597.h>
25 #include <linux/usb/m66592.h>
26 #include <net/ax88796.h>
27 #include <asm/machvec.h>
28 #include <mach/highlander.h>
29 #include <asm/clock.h>
30 #include <asm/heartbeat.h>
32 #include <asm/io_trapped.h>
34 static struct r8a66597_platdata r8a66597_data
= {
35 .xtal
= R8A66597_PLATDATA_XTAL_12MHZ
,
39 static struct resource r8a66597_usb_host_resources
[] = {
43 .flags
= IORESOURCE_MEM
,
46 .start
= IRQ_EXT1
, /* irq number */
48 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
,
52 static struct platform_device r8a66597_usb_host_device
= {
53 .name
= "r8a66597_hcd",
56 .dma_mask
= NULL
, /* don't use dma */
57 .coherent_dma_mask
= 0xffffffff,
58 .platform_data
= &r8a66597_data
,
60 .num_resources
= ARRAY_SIZE(r8a66597_usb_host_resources
),
61 .resource
= r8a66597_usb_host_resources
,
64 static struct m66592_platdata usbf_platdata
= {
65 .xtal
= M66592_PLATDATA_XTAL_24MHZ
,
69 static struct resource m66592_usb_peripheral_resources
[] = {
74 .flags
= IORESOURCE_MEM
,
78 .start
= IRQ_EXT4
, /* irq number */
80 .flags
= IORESOURCE_IRQ
,
84 static struct platform_device m66592_usb_peripheral_device
= {
88 .dma_mask
= NULL
, /* don't use dma */
89 .coherent_dma_mask
= 0xffffffff,
90 .platform_data
= &usbf_platdata
,
92 .num_resources
= ARRAY_SIZE(m66592_usb_peripheral_resources
),
93 .resource
= m66592_usb_peripheral_resources
,
96 static struct resource cf_ide_resources
[] = {
98 .start
= PA_AREA5_IO
+ 0x1000,
99 .end
= PA_AREA5_IO
+ 0x1000 + 0x08 - 1,
100 .flags
= IORESOURCE_MEM
,
103 .start
= PA_AREA5_IO
+ 0x80c,
104 .end
= PA_AREA5_IO
+ 0x80c + 0x16 - 1,
105 .flags
= IORESOURCE_MEM
,
109 .flags
= IORESOURCE_IRQ
,
113 static struct pata_platform_info pata_info
= {
117 static struct platform_device cf_ide_device
= {
118 .name
= "pata_platform",
120 .num_resources
= ARRAY_SIZE(cf_ide_resources
),
121 .resource
= cf_ide_resources
,
123 .platform_data
= &pata_info
,
127 static struct resource heartbeat_resources
[] = {
131 .flags
= IORESOURCE_MEM
,
135 #ifndef CONFIG_SH_R7785RP
136 static unsigned char heartbeat_bit_pos
[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
138 static struct heartbeat_data heartbeat_data
= {
139 .bit_pos
= heartbeat_bit_pos
,
140 .nr_bits
= ARRAY_SIZE(heartbeat_bit_pos
),
144 static struct platform_device heartbeat_device
= {
148 /* R7785RP has a slightly more sensible FPGA.. */
149 #ifndef CONFIG_SH_R7785RP
151 .platform_data
= &heartbeat_data
,
154 .num_resources
= ARRAY_SIZE(heartbeat_resources
),
155 .resource
= heartbeat_resources
,
158 static struct ax_plat_data ax88796_platdata
= {
159 .flags
= AXFLG_HAS_93CX6
,
165 static struct resource ax88796_resources
[] = {
167 #ifdef CONFIG_SH_R7780RP
169 .end
= 0xa5800400 + (0x20 * 0x2) - 1,
172 .end
= 0xa4100400 + (0x20 * 0x2) - 1,
174 .flags
= IORESOURCE_MEM
,
177 .start
= IRQ_AX88796
,
179 .flags
= IORESOURCE_IRQ
,
183 static struct platform_device ax88796_device
= {
188 .platform_data
= &ax88796_platdata
,
191 .num_resources
= ARRAY_SIZE(ax88796_resources
),
192 .resource
= ax88796_resources
,
195 static struct mtd_partition nor_flash_partitions
[] = {
198 .offset
= 0x00000000,
203 .offset
= MTDPART_OFS_APPEND
,
208 .offset
= MTDPART_OFS_APPEND
,
209 .size
= 4 * 1024 * 1024,
213 .offset
= MTDPART_OFS_APPEND
,
214 .size
= MTDPART_SIZ_FULL
,
218 static struct physmap_flash_data nor_flash_data
= {
220 .parts
= nor_flash_partitions
,
221 .nr_parts
= ARRAY_SIZE(nor_flash_partitions
),
224 /* This config is flash board for mass production. */
225 static struct resource nor_flash_resources
[] = {
227 .start
= PA_NORFLASH_ADDR
,
228 .end
= PA_NORFLASH_ADDR
+ PA_NORFLASH_SIZE
- 1,
229 .flags
= IORESOURCE_MEM
,
233 static struct platform_device nor_flash_device
= {
234 .name
= "physmap-flash",
236 .platform_data
= &nor_flash_data
,
238 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
239 .resource
= nor_flash_resources
,
242 static struct resource smbus_resources
[] = {
245 .end
= PA_SMCR
+ 0x100 - 1,
246 .flags
= IORESOURCE_MEM
,
251 .flags
= IORESOURCE_IRQ
,
255 static struct platform_device smbus_device
= {
256 .name
= "i2c-highlander",
258 .num_resources
= ARRAY_SIZE(smbus_resources
),
259 .resource
= smbus_resources
,
262 static struct i2c_board_info __initdata highlander_i2c_devices
[] = {
264 I2C_BOARD_INFO("r2025sd", 0x32),
268 static struct platform_device
*r7780rp_devices
[] __initdata
= {
269 &r8a66597_usb_host_device
,
270 &m66592_usb_peripheral_device
,
274 #ifndef CONFIG_SH_R7780RP
280 * The CF is connected using a 16-bit bus where 8-bit operations are
281 * unsupported. The linux ata driver is however using 8-bit operations, so
282 * insert a trapped io filter to convert 8-bit operations into 16-bit.
284 static struct trapped_io cf_trapped_io
= {
285 .resource
= cf_ide_resources
,
287 .minimum_bus_width
= 16,
290 static int __init
r7780rp_devices_setup(void)
294 #ifndef CONFIG_SH_R7780RP
295 if (register_trapped_io(&cf_trapped_io
) == 0)
296 ret
|= platform_device_register(&cf_ide_device
);
299 ret
|= platform_add_devices(r7780rp_devices
,
300 ARRAY_SIZE(r7780rp_devices
));
302 ret
|= i2c_register_board_info(0, highlander_i2c_devices
,
303 ARRAY_SIZE(highlander_i2c_devices
));
307 device_initcall(r7780rp_devices_setup
);
310 * Platform specific clocks
312 static int ivdr_clk_enable(struct clk
*clk
)
314 ctrl_outw(ctrl_inw(PA_IVDRCTL
) | (1 << IVDR_CK_ON
), PA_IVDRCTL
);
318 static void ivdr_clk_disable(struct clk
*clk
)
320 ctrl_outw(ctrl_inw(PA_IVDRCTL
) & ~(1 << IVDR_CK_ON
), PA_IVDRCTL
);
323 static struct clk_ops ivdr_clk_ops
= {
324 .enable
= ivdr_clk_enable
,
325 .disable
= ivdr_clk_disable
,
328 static struct clk ivdr_clk
= {
330 .ops
= &ivdr_clk_ops
,
333 static struct clk
*r7780rp_clocks
[] = {
337 static void r7780rp_power_off(void)
339 if (mach_is_r7780mp() || mach_is_r7785rp())
340 ctrl_outw(0x0001, PA_POFF
);
344 * Initialize the board
346 static void __init
highlander_setup(char **cmdline_p
)
348 u16 ver
= ctrl_inw(PA_VERREG
);
351 printk(KERN_INFO
"Renesas Solutions Highlander %s support.\n",
352 mach_is_r7780rp() ? "R7780RP-1" :
353 mach_is_r7780mp() ? "R7780MP" :
356 printk(KERN_INFO
"Board version: %d (revision %d), "
357 "FPGA version: %d (revision %d)\n",
358 (ver
>> 12) & 0xf, (ver
>> 8) & 0xf,
359 (ver
>> 4) & 0xf, ver
& 0xf);
361 highlander_plat_pinmux_setup();
364 * Enable the important clocks right away..
366 for (i
= 0; i
< ARRAY_SIZE(r7780rp_clocks
); i
++) {
367 struct clk
*clk
= r7780rp_clocks
[i
];
373 ctrl_outw(0x0000, PA_OBLED
); /* Clear LED. */
375 if (mach_is_r7780rp())
376 ctrl_outw(0x0001, PA_SDPOW
); /* SD Power ON */
378 ctrl_outw(ctrl_inw(PA_IVDRCTL
) | 0x01, PA_IVDRCTL
); /* Si13112 */
380 pm_power_off
= r7780rp_power_off
;
383 static unsigned char irl2irq
[HL_NR_IRL
];
385 static int highlander_irq_demux(int irq
)
387 if (irq
>= HL_NR_IRL
|| !irl2irq
[irq
])
393 static void __init
highlander_init_irq(void)
395 unsigned char *ucp
= highlander_plat_irq_setup();
398 plat_irq_setup_pins(IRQ_MODE_IRL3210
);
399 memcpy(irl2irq
, ucp
, HL_NR_IRL
);
406 static struct sh_machine_vector mv_highlander __initmv
= {
407 .mv_name
= "Highlander",
408 .mv_setup
= highlander_setup
,
409 .mv_init_irq
= highlander_init_irq
,
410 .mv_irq_demux
= highlander_irq_demux
,