blob: adb529d01bae302ce06cfeb3064952670ee31877 [file] [log] [blame]
Paul Mundt5283ecb2006-09-27 15:59:17 +09001/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
Paul Mundt32351a22007-03-12 14:38:59 +09004 * Renesas Solutions Highlander Support.
5 *
Paul Mundt5283ecb2006-09-27 15:59:17 +09006 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
Paul Mundt71074d32007-02-14 14:49:04 +09007 * Copyright (C) 2005 - 2007 Paul Mundt
Paul Mundt5283ecb2006-09-27 15:59:17 +09008 *
Paul Mundt32351a22007-03-12 14:38:59 +09009 * This contains support for the R7780RP-1, R7780MP, and R7785RP
10 * Highlander modules.
Paul Mundt5283ecb2006-09-27 15:59:17 +090011 *
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
14 * for more details.
15 */
16#include <linux/init.h>
17#include <linux/platform_device.h>
Paul Mundt71074d32007-02-14 14:49:04 +090018#include <linux/pata_platform.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090019#include <asm/machvec.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090020#include <asm/r7780rp.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090021#include <asm/clock.h>
22#include <asm/io.h>
23
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090024static struct resource r8a66597_usb_host_resources[] = {
25 [0] = {
26 .name = "r8a66597_hcd",
27 .start = 0xA4200000,
28 .end = 0xA42000FF,
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .name = "r8a66597_hcd",
33 .start = 11, /* irq number */
34 .end = 11,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39static struct platform_device r8a66597_usb_host_device = {
40 .name = "r8a66597_hcd",
41 .id = -1,
42 .dev = {
43 .dma_mask = NULL, /* don't use dma */
44 .coherent_dma_mask = 0xffffffff,
45 },
46 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
47 .resource = r8a66597_usb_host_resources,
48};
49
50static struct resource m66592_usb_peripheral_resources[] = {
51 [0] = {
52 .name = "m66592_udc",
53 .start = 0xb0000000,
54 .end = 0xb00000FF,
55 .flags = IORESOURCE_MEM,
56 },
57 [1] = {
58 .name = "m66592_udc",
59 .start = 9, /* irq number */
60 .end = 9,
61 .flags = IORESOURCE_IRQ,
62 },
63};
64
65static struct platform_device m66592_usb_peripheral_device = {
66 .name = "m66592_udc",
67 .id = -1,
68 .dev = {
69 .dma_mask = NULL, /* don't use dma */
70 .coherent_dma_mask = 0xffffffff,
71 },
72 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
73 .resource = m66592_usb_peripheral_resources,
74};
75
Paul Mundt0c020e32006-12-06 10:43:44 +090076static struct resource cf_ide_resources[] = {
77 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090078 .start = PA_AREA5_IO + 0x1000,
79 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
80 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090081 },
82 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090083 .start = PA_AREA5_IO + 0x80c,
84 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
85 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090086 },
87 [2] = {
Paul Mundt32351a22007-03-12 14:38:59 +090088#ifdef CONFIG_SH_R7780RP
Paul Mundt0c020e32006-12-06 10:43:44 +090089 .start = 4,
Paul Mundt32351a22007-03-12 14:38:59 +090090#else
91 .start = 1,
Paul Mundt0c020e32006-12-06 10:43:44 +090092#endif
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
Paul Mundt71074d32007-02-14 14:49:04 +090097static struct pata_platform_info pata_info = {
98 .ioport_shift = 1,
99};
100
Paul Mundt0c020e32006-12-06 10:43:44 +0900101static struct platform_device cf_ide_device = {
102 .name = "pata_platform",
103 .id = -1,
104 .num_resources = ARRAY_SIZE(cf_ide_resources),
105 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +0900106 .dev = {
107 .platform_data = &pata_info,
108 },
Paul Mundt0c020e32006-12-06 10:43:44 +0900109};
110
Paul Mundt3b4d9532007-02-13 15:42:28 +0900111static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
112
113static struct resource heartbeat_resources[] = {
114 [0] = {
115 .start = PA_OBLED,
116 .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
117 .flags = IORESOURCE_MEM,
118 },
119};
120
121static struct platform_device heartbeat_device = {
122 .name = "heartbeat",
123 .id = -1,
Paul Mundt32351a22007-03-12 14:38:59 +0900124
125 /* R7785RP has a slightly more sensible FPGA.. */
126#ifndef CONFIG_SH_R7785RP
Paul Mundt3b4d9532007-02-13 15:42:28 +0900127 .dev = {
128 .platform_data = heartbeat_bit_pos,
129 },
Paul Mundt32351a22007-03-12 14:38:59 +0900130#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +0900131 .num_resources = ARRAY_SIZE(heartbeat_resources),
132 .resource = heartbeat_resources,
133};
134
Paul Mundt5283ecb2006-09-27 15:59:17 +0900135static struct platform_device *r7780rp_devices[] __initdata = {
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +0900136 &r8a66597_usb_host_device,
137 &m66592_usb_peripheral_device,
Paul Mundt0c020e32006-12-06 10:43:44 +0900138 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900139 &heartbeat_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +0900140};
141
142static int __init r7780rp_devices_setup(void)
143{
144 return platform_add_devices(r7780rp_devices,
145 ARRAY_SIZE(r7780rp_devices));
146}
Paul Mundt32351a22007-03-12 14:38:59 +0900147device_initcall(r7780rp_devices_setup);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900148
149/*
150 * Platform specific clocks
151 */
152static void ivdr_clk_enable(struct clk *clk)
153{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900154 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900155}
156
157static void ivdr_clk_disable(struct clk *clk)
158{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900159 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900160}
161
162static struct clk_ops ivdr_clk_ops = {
163 .enable = ivdr_clk_enable,
164 .disable = ivdr_clk_disable,
165};
166
167static struct clk ivdr_clk = {
168 .name = "ivdr_clk",
169 .ops = &ivdr_clk_ops,
170};
171
172static struct clk *r7780rp_clocks[] = {
173 &ivdr_clk,
174};
175
Paul Mundt5283ecb2006-09-27 15:59:17 +0900176static void r7780rp_power_off(void)
177{
Paul Mundt32351a22007-03-12 14:38:59 +0900178 if (mach_is_r7780mp() || mach_is_r7785rp())
179 ctrl_outw(0x0001, PA_POFF);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900180}
181
182/*
183 * Initialize the board
184 */
Paul Mundt32351a22007-03-12 14:38:59 +0900185static void __init highlander_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900186{
187 u16 ver = ctrl_inw(PA_VERREG);
188 int i;
189
Paul Mundt32351a22007-03-12 14:38:59 +0900190 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
191 mach_is_r7780rp() ? "R7780RP-1" :
192 mach_is_r7780mp() ? "R7780MP" :
193 "R7785RP");
Paul Mundt5283ecb2006-09-27 15:59:17 +0900194
195 printk(KERN_INFO "Board version: %d (revision %d), "
196 "FPGA version: %d (revision %d)\n",
197 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
198 (ver >> 4) & 0xf, ver & 0xf);
199
200 /*
201 * Enable the important clocks right away..
202 */
203 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
204 struct clk *clk = r7780rp_clocks[i];
205
206 clk_register(clk);
207 clk_enable(clk);
208 }
209
210 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
Paul Mundt32351a22007-03-12 14:38:59 +0900211
212 if (mach_is_r7780rp())
213 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
214
Paul Mundt2c081e72006-12-25 18:28:33 +0900215 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900216
217 pm_power_off = r7780rp_power_off;
218}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900219
220/*
221 * The Machine Vector
222 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900223static struct sh_machine_vector mv_highlander __initmv = {
Paul Mundt32351a22007-03-12 14:38:59 +0900224 .mv_name = "Highlander",
Paul Mundt2c7834a2006-09-27 18:17:31 +0900225 .mv_nr_irqs = 109,
Paul Mundt32351a22007-03-12 14:38:59 +0900226 .mv_setup = highlander_setup,
227 .mv_init_irq = highlander_init_irq,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900228};