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/i2c.h>
21 #include <linux/irq.h>
22 #include <net/ax88796.h>
23 #include <asm/machvec.h>
24 #include <mach/highlander.h>
25 #include <asm/clock.h>
26 #include <asm/heartbeat.h>
28 #include <asm/io_trapped.h>
30 static struct resource r8a66597_usb_host_resources
[] = {
32 .name
= "r8a66597_hcd",
35 .flags
= IORESOURCE_MEM
,
38 .name
= "r8a66597_hcd",
39 .start
= IRQ_EXT1
, /* irq number */
41 .flags
= IORESOURCE_IRQ
,
45 static struct platform_device r8a66597_usb_host_device
= {
46 .name
= "r8a66597_hcd",
49 .dma_mask
= NULL
, /* don't use dma */
50 .coherent_dma_mask
= 0xffffffff,
52 .num_resources
= ARRAY_SIZE(r8a66597_usb_host_resources
),
53 .resource
= r8a66597_usb_host_resources
,
56 static struct resource m66592_usb_peripheral_resources
[] = {
61 .flags
= IORESOURCE_MEM
,
65 .start
= IRQ_EXT4
, /* irq number */
67 .flags
= IORESOURCE_IRQ
,
71 static struct platform_device m66592_usb_peripheral_device
= {
75 .dma_mask
= NULL
, /* don't use dma */
76 .coherent_dma_mask
= 0xffffffff,
78 .num_resources
= ARRAY_SIZE(m66592_usb_peripheral_resources
),
79 .resource
= m66592_usb_peripheral_resources
,
82 static struct resource cf_ide_resources
[] = {
84 .start
= PA_AREA5_IO
+ 0x1000,
85 .end
= PA_AREA5_IO
+ 0x1000 + 0x08 - 1,
86 .flags
= IORESOURCE_MEM
,
89 .start
= PA_AREA5_IO
+ 0x80c,
90 .end
= PA_AREA5_IO
+ 0x80c + 0x16 - 1,
91 .flags
= IORESOURCE_MEM
,
95 .flags
= IORESOURCE_IRQ
,
99 static struct pata_platform_info pata_info
= {
103 static struct platform_device cf_ide_device
= {
104 .name
= "pata_platform",
106 .num_resources
= ARRAY_SIZE(cf_ide_resources
),
107 .resource
= cf_ide_resources
,
109 .platform_data
= &pata_info
,
113 static struct resource heartbeat_resources
[] = {
117 .flags
= IORESOURCE_MEM
,
121 #ifndef CONFIG_SH_R7785RP
122 static unsigned char heartbeat_bit_pos
[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
124 static struct heartbeat_data heartbeat_data
= {
125 .bit_pos
= heartbeat_bit_pos
,
126 .nr_bits
= ARRAY_SIZE(heartbeat_bit_pos
),
130 static struct platform_device heartbeat_device
= {
134 /* R7785RP has a slightly more sensible FPGA.. */
135 #ifndef CONFIG_SH_R7785RP
137 .platform_data
= &heartbeat_data
,
140 .num_resources
= ARRAY_SIZE(heartbeat_resources
),
141 .resource
= heartbeat_resources
,
144 static struct ax_plat_data ax88796_platdata
= {
145 .flags
= AXFLG_HAS_93CX6
,
151 static struct resource ax88796_resources
[] = {
153 #ifdef CONFIG_SH_R7780RP
155 .end
= 0xa5800400 + (0x20 * 0x2) - 1,
158 .end
= 0xa4100400 + (0x20 * 0x2) - 1,
160 .flags
= IORESOURCE_MEM
,
163 .start
= IRQ_AX88796
,
165 .flags
= IORESOURCE_IRQ
,
169 static struct platform_device ax88796_device
= {
174 .platform_data
= &ax88796_platdata
,
177 .num_resources
= ARRAY_SIZE(ax88796_resources
),
178 .resource
= ax88796_resources
,
181 static struct resource smbus_resources
[] = {
184 .end
= PA_SMCR
+ 0x100 - 1,
185 .flags
= IORESOURCE_MEM
,
190 .flags
= IORESOURCE_IRQ
,
194 static struct platform_device smbus_device
= {
195 .name
= "i2c-highlander",
197 .num_resources
= ARRAY_SIZE(smbus_resources
),
198 .resource
= smbus_resources
,
201 static struct i2c_board_info __initdata highlander_i2c_devices
[] = {
203 I2C_BOARD_INFO("r2025sd", 0x32),
207 static struct platform_device
*r7780rp_devices
[] __initdata
= {
208 &r8a66597_usb_host_device
,
209 &m66592_usb_peripheral_device
,
212 #ifndef CONFIG_SH_R7780RP
218 * The CF is connected using a 16-bit bus where 8-bit operations are
219 * unsupported. The linux ata driver is however using 8-bit operations, so
220 * insert a trapped io filter to convert 8-bit operations into 16-bit.
222 static struct trapped_io cf_trapped_io
= {
223 .resource
= cf_ide_resources
,
225 .minimum_bus_width
= 16,
228 static int __init
r7780rp_devices_setup(void)
232 #ifndef CONFIG_SH_R7780RP
233 if (register_trapped_io(&cf_trapped_io
) == 0)
234 ret
|= platform_device_register(&cf_ide_device
);
237 ret
|= platform_add_devices(r7780rp_devices
,
238 ARRAY_SIZE(r7780rp_devices
));
240 ret
|= i2c_register_board_info(0, highlander_i2c_devices
,
241 ARRAY_SIZE(highlander_i2c_devices
));
245 device_initcall(r7780rp_devices_setup
);
248 * Platform specific clocks
250 static void ivdr_clk_enable(struct clk
*clk
)
252 ctrl_outw(ctrl_inw(PA_IVDRCTL
) | (1 << IVDR_CK_ON
), PA_IVDRCTL
);
255 static void ivdr_clk_disable(struct clk
*clk
)
257 ctrl_outw(ctrl_inw(PA_IVDRCTL
) & ~(1 << IVDR_CK_ON
), PA_IVDRCTL
);
260 static struct clk_ops ivdr_clk_ops
= {
261 .enable
= ivdr_clk_enable
,
262 .disable
= ivdr_clk_disable
,
265 static struct clk ivdr_clk
= {
267 .ops
= &ivdr_clk_ops
,
270 static struct clk
*r7780rp_clocks
[] = {
274 static void r7780rp_power_off(void)
276 if (mach_is_r7780mp() || mach_is_r7785rp())
277 ctrl_outw(0x0001, PA_POFF
);
281 * Initialize the board
283 static void __init
highlander_setup(char **cmdline_p
)
285 u16 ver
= ctrl_inw(PA_VERREG
);
288 printk(KERN_INFO
"Renesas Solutions Highlander %s support.\n",
289 mach_is_r7780rp() ? "R7780RP-1" :
290 mach_is_r7780mp() ? "R7780MP" :
293 printk(KERN_INFO
"Board version: %d (revision %d), "
294 "FPGA version: %d (revision %d)\n",
295 (ver
>> 12) & 0xf, (ver
>> 8) & 0xf,
296 (ver
>> 4) & 0xf, ver
& 0xf);
298 highlander_plat_pinmux_setup();
301 * Enable the important clocks right away..
303 for (i
= 0; i
< ARRAY_SIZE(r7780rp_clocks
); i
++) {
304 struct clk
*clk
= r7780rp_clocks
[i
];
310 ctrl_outw(0x0000, PA_OBLED
); /* Clear LED. */
312 if (mach_is_r7780rp())
313 ctrl_outw(0x0001, PA_SDPOW
); /* SD Power ON */
315 ctrl_outw(ctrl_inw(PA_IVDRCTL
) | 0x01, PA_IVDRCTL
); /* Si13112 */
317 pm_power_off
= r7780rp_power_off
;
320 static unsigned char irl2irq
[HL_NR_IRL
];
322 static int highlander_irq_demux(int irq
)
324 if (irq
>= HL_NR_IRL
|| !irl2irq
[irq
])
330 static void __init
highlander_init_irq(void)
332 unsigned char *ucp
= highlander_plat_irq_setup();
335 plat_irq_setup_pins(IRQ_MODE_IRL3210
);
336 memcpy(irl2irq
, ucp
, HL_NR_IRL
);
343 static struct sh_machine_vector mv_highlander __initmv
= {
344 .mv_name
= "Highlander",
345 .mv_setup
= highlander_setup
,
346 .mv_init_irq
= highlander_init_irq
,
347 .mv_irq_demux
= highlander_irq_demux
,