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 - 2007 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 <net/ax88796.h>
21 #include <asm/machvec.h>
22 #include <asm/r7780rp.h>
23 #include <asm/clock.h>
24 #include <asm/heartbeat.h>
27 static struct resource r8a66597_usb_host_resources[] = {
29 .name = "r8a66597_hcd",
32 .flags = IORESOURCE_MEM,
35 .name = "r8a66597_hcd",
36 .start = IRQ_EXT1, /* irq number */
38 .flags = IORESOURCE_IRQ,
42 static struct platform_device r8a66597_usb_host_device = {
43 .name = "r8a66597_hcd",
46 .dma_mask = NULL, /* don't use dma */
47 .coherent_dma_mask = 0xffffffff,
49 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
50 .resource = r8a66597_usb_host_resources,
53 static struct resource m66592_usb_peripheral_resources[] = {
58 .flags = IORESOURCE_MEM,
62 .start = IRQ_EXT4, /* irq number */
64 .flags = IORESOURCE_IRQ,
68 static struct platform_device m66592_usb_peripheral_device = {
72 .dma_mask = NULL, /* don't use dma */
73 .coherent_dma_mask = 0xffffffff,
75 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
76 .resource = m66592_usb_peripheral_resources,
79 static struct resource cf_ide_resources[] = {
81 .start = PA_AREA5_IO + 0x1000,
82 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
83 .flags = IORESOURCE_MEM,
86 .start = PA_AREA5_IO + 0x80c,
87 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
88 .flags = IORESOURCE_MEM,
92 .flags = IORESOURCE_IRQ,
96 static struct pata_platform_info pata_info = {
100 static struct platform_device cf_ide_device = {
101 .name = "pata_platform",
103 .num_resources = ARRAY_SIZE(cf_ide_resources),
104 .resource = cf_ide_resources,
106 .platform_data = &pata_info,
110 static struct resource heartbeat_resources[] = {
114 .flags = IORESOURCE_MEM,
118 #ifndef CONFIG_SH_R7785RP
119 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
121 static struct heartbeat_data heartbeat_data = {
122 .bit_pos = heartbeat_bit_pos,
123 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
127 static struct platform_device heartbeat_device = {
131 /* R7785RP has a slightly more sensible FPGA.. */
132 #ifndef CONFIG_SH_R7785RP
134 .platform_data = &heartbeat_data,
137 .num_resources = ARRAY_SIZE(heartbeat_resources),
138 .resource = heartbeat_resources,
141 static struct ax_plat_data ax88796_platdata = {
142 .flags = AXFLG_HAS_93CX6,
148 static struct resource ax88796_resources[] = {
150 #ifdef CONFIG_SH_R7780RP
152 .end = 0xa5800400 + (0x20 * 0x2) - 1,
155 .end = 0xa4100400 + (0x20 * 0x2) - 1,
157 .flags = IORESOURCE_MEM,
160 .start = IRQ_AX88796,
162 .flags = IORESOURCE_IRQ,
166 static struct platform_device ax88796_device = {
171 .platform_data = &ax88796_platdata,
174 .num_resources = ARRAY_SIZE(ax88796_resources),
175 .resource = ax88796_resources,
179 static struct platform_device *r7780rp_devices[] __initdata = {
180 &r8a66597_usb_host_device,
181 &m66592_usb_peripheral_device,
183 #ifndef CONFIG_SH_R7780RP
189 static int __init r7780rp_devices_setup(void)
191 return platform_add_devices(r7780rp_devices,
192 ARRAY_SIZE(r7780rp_devices));
194 device_initcall(r7780rp_devices_setup);
197 * Platform specific clocks
199 static void ivdr_clk_enable(struct clk *clk)
201 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
204 static void ivdr_clk_disable(struct clk *clk)
206 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
209 static struct clk_ops ivdr_clk_ops = {
210 .enable = ivdr_clk_enable,
211 .disable = ivdr_clk_disable,
214 static struct clk ivdr_clk = {
216 .ops = &ivdr_clk_ops,
219 static struct clk *r7780rp_clocks[] = {
223 static void r7780rp_power_off(void)
225 if (mach_is_r7780mp() || mach_is_r7785rp())
226 ctrl_outw(0x0001, PA_POFF);
229 static inline unsigned char is_ide_ioaddr(unsigned long addr)
231 return ((cf_ide_resources[0].start <= addr &&
232 addr <= cf_ide_resources[0].end) ||
233 (cf_ide_resources[1].start <= addr &&
234 addr <= cf_ide_resources[1].end));
237 void highlander_writeb(u8 b, void __iomem *addr)
239 unsigned long tmp = (unsigned long __force)addr;
241 if (is_ide_ioaddr(tmp))
242 ctrl_outw((u16)b, tmp);
247 u8 highlander_readb(void __iomem *addr)
249 unsigned long tmp = (unsigned long __force)addr;
251 if (is_ide_ioaddr(tmp))
252 return ctrl_inw(tmp) & 0xff;
254 return ctrl_inb(tmp);
258 * Initialize the board
260 static void __init highlander_setup(char **cmdline_p)
262 u16 ver = ctrl_inw(PA_VERREG);
265 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
266 mach_is_r7780rp() ? "R7780RP-1" :
267 mach_is_r7780mp() ? "R7780MP" :
270 printk(KERN_INFO "Board version: %d (revision %d), "
271 "FPGA version: %d (revision %d)\n",
272 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
273 (ver >> 4) & 0xf, ver & 0xf);
276 * Enable the important clocks right away..
278 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
279 struct clk *clk = r7780rp_clocks[i];
285 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
287 if (mach_is_r7780rp())
288 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
290 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
292 pm_power_off = r7780rp_power_off;
295 static unsigned char irl2irq[HL_NR_IRL];
297 int highlander_irq_demux(int irq)
299 if (irq >= HL_NR_IRL || !irl2irq[irq])
305 void __init highlander_init_irq(void)
307 unsigned char *ucp = NULL;
310 #ifdef CONFIG_SH_R7780MP
311 ucp = highlander_init_irq_r7780mp();
315 #ifdef CONFIG_SH_R7785RP
316 ucp = highlander_init_irq_r7785rp();
320 #ifdef CONFIG_SH_R7780RP
321 ucp = highlander_init_irq_r7780rp();
328 plat_irq_setup_pins(IRQ_MODE_IRL3210);
329 memcpy(irl2irq, ucp, HL_NR_IRL);
336 static struct sh_machine_vector mv_highlander __initmv = {
337 .mv_name = "Highlander",
338 .mv_setup = highlander_setup,
339 .mv_init_irq = highlander_init_irq,
340 .mv_irq_demux = highlander_irq_demux,
341 .mv_readb = highlander_readb,
342 .mv_writeb = highlander_writeb,