blob: 20fe72c515d520d732f5b373b93c11c7cac252ff [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 Mundtc2933962008-03-25 16:49:30 +09007 * Copyright (C) 2005 - 2008 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>
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050018#include <linux/ata_platform.h>
Paul Mundtb5751e22007-11-02 14:17:19 +090019#include <linux/types.h>
Paul Mundtc2933962008-03-25 16:49:30 +090020#include <linux/i2c.h>
Paul Mundt604437f2009-01-09 15:11:58 +090021#include <linux/irq.h>
Magnus Dammc6f93a32007-10-15 10:36:45 +090022#include <net/ax88796.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090023#include <asm/machvec.h>
Paul Mundt7639a452008-10-20 13:02:48 +090024#include <mach/highlander.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090025#include <asm/clock.h>
Paul Mundt8786c952007-08-20 13:03:41 +090026#include <asm/heartbeat.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090027#include <asm/io.h>
Magnus Dammc1a34e42008-02-07 20:23:53 +090028#include <asm/io_trapped.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090029
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090030static struct resource r8a66597_usb_host_resources[] = {
31 [0] = {
32 .name = "r8a66597_hcd",
33 .start = 0xA4200000,
34 .end = 0xA42000FF,
35 .flags = IORESOURCE_MEM,
36 },
37 [1] = {
38 .name = "r8a66597_hcd",
Magnus Damm897cfcd82007-09-10 12:06:03 +090039 .start = IRQ_EXT1, /* irq number */
40 .end = IRQ_EXT1,
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090041 .flags = IORESOURCE_IRQ,
42 },
43};
44
45static struct platform_device r8a66597_usb_host_device = {
46 .name = "r8a66597_hcd",
47 .id = -1,
48 .dev = {
49 .dma_mask = NULL, /* don't use dma */
50 .coherent_dma_mask = 0xffffffff,
51 },
52 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
53 .resource = r8a66597_usb_host_resources,
54};
55
56static struct resource m66592_usb_peripheral_resources[] = {
57 [0] = {
58 .name = "m66592_udc",
59 .start = 0xb0000000,
60 .end = 0xb00000FF,
61 .flags = IORESOURCE_MEM,
62 },
63 [1] = {
64 .name = "m66592_udc",
Magnus Damm897cfcd82007-09-10 12:06:03 +090065 .start = IRQ_EXT4, /* irq number */
66 .end = IRQ_EXT4,
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090067 .flags = IORESOURCE_IRQ,
68 },
69};
70
71static struct platform_device m66592_usb_peripheral_device = {
72 .name = "m66592_udc",
73 .id = -1,
74 .dev = {
75 .dma_mask = NULL, /* don't use dma */
76 .coherent_dma_mask = 0xffffffff,
77 },
78 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
79 .resource = m66592_usb_peripheral_resources,
80};
81
Paul Mundt0c020e32006-12-06 10:43:44 +090082static struct resource cf_ide_resources[] = {
83 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090084 .start = PA_AREA5_IO + 0x1000,
85 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
86 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090087 },
88 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090089 .start = PA_AREA5_IO + 0x80c,
90 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
91 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090092 },
93 [2] = {
Magnus Damm897cfcd82007-09-10 12:06:03 +090094 .start = IRQ_CF,
Paul Mundt0c020e32006-12-06 10:43:44 +090095 .flags = IORESOURCE_IRQ,
96 },
97};
98
Paul Mundt71074d32007-02-14 14:49:04 +090099static struct pata_platform_info pata_info = {
100 .ioport_shift = 1,
101};
102
Paul Mundt0c020e32006-12-06 10:43:44 +0900103static struct platform_device cf_ide_device = {
104 .name = "pata_platform",
105 .id = -1,
106 .num_resources = ARRAY_SIZE(cf_ide_resources),
107 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +0900108 .dev = {
109 .platform_data = &pata_info,
110 },
Paul Mundt0c020e32006-12-06 10:43:44 +0900111};
112
Paul Mundt3b4d9532007-02-13 15:42:28 +0900113static struct resource heartbeat_resources[] = {
114 [0] = {
115 .start = PA_OBLED,
Paul Mundta1fd3062007-08-23 15:11:44 +0900116 .end = PA_OBLED,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900117 .flags = IORESOURCE_MEM,
118 },
119};
120
Paul Mundt8786c952007-08-20 13:03:41 +0900121#ifndef CONFIG_SH_R7785RP
122static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
123
124static struct heartbeat_data heartbeat_data = {
125 .bit_pos = heartbeat_bit_pos,
126 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
127};
128#endif
129
Paul Mundt3b4d9532007-02-13 15:42:28 +0900130static struct platform_device heartbeat_device = {
131 .name = "heartbeat",
132 .id = -1,
Paul Mundt32351a22007-03-12 14:38:59 +0900133
134 /* R7785RP has a slightly more sensible FPGA.. */
135#ifndef CONFIG_SH_R7785RP
Paul Mundt3b4d9532007-02-13 15:42:28 +0900136 .dev = {
Paul Mundta1fd3062007-08-23 15:11:44 +0900137 .platform_data = &heartbeat_data,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900138 },
Paul Mundt32351a22007-03-12 14:38:59 +0900139#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +0900140 .num_resources = ARRAY_SIZE(heartbeat_resources),
141 .resource = heartbeat_resources,
142};
143
Magnus Dammc6f93a32007-10-15 10:36:45 +0900144static struct ax_plat_data ax88796_platdata = {
145 .flags = AXFLG_HAS_93CX6,
146 .wordlength = 2,
147 .dcr_val = 0x1,
148 .rcr_val = 0x40,
149};
150
151static struct resource ax88796_resources[] = {
152 {
153#ifdef CONFIG_SH_R7780RP
154 .start = 0xa5800400,
155 .end = 0xa5800400 + (0x20 * 0x2) - 1,
156#else
157 .start = 0xa4100400,
158 .end = 0xa4100400 + (0x20 * 0x2) - 1,
159#endif
160 .flags = IORESOURCE_MEM,
161 },
162 {
163 .start = IRQ_AX88796,
164 .end = IRQ_AX88796,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169static struct platform_device ax88796_device = {
170 .name = "ax88796",
171 .id = 0,
172
173 .dev = {
174 .platform_data = &ax88796_platdata,
175 },
176
177 .num_resources = ARRAY_SIZE(ax88796_resources),
178 .resource = ax88796_resources,
179};
180
Paul Mundtc2933962008-03-25 16:49:30 +0900181static struct resource smbus_resources[] = {
182 [0] = {
183 .start = PA_SMCR,
184 .end = PA_SMCR + 0x100 - 1,
185 .flags = IORESOURCE_MEM,
186 },
187 [1] = {
188 .start = IRQ_SMBUS,
189 .end = IRQ_SMBUS,
190 .flags = IORESOURCE_IRQ,
191 },
192};
193
194static struct platform_device smbus_device = {
195 .name = "i2c-highlander",
196 .id = 0,
197 .num_resources = ARRAY_SIZE(smbus_resources),
198 .resource = smbus_resources,
199};
200
201static struct i2c_board_info __initdata highlander_i2c_devices[] = {
202 {
Jean Delvare3760f732008-04-29 23:11:40 +0200203 I2C_BOARD_INFO("r2025sd", 0x32),
Paul Mundtc2933962008-03-25 16:49:30 +0900204 },
205};
Magnus Dammc6f93a32007-10-15 10:36:45 +0900206
Paul Mundt5283ecb2006-09-27 15:59:17 +0900207static struct platform_device *r7780rp_devices[] __initdata = {
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +0900208 &r8a66597_usb_host_device,
209 &m66592_usb_peripheral_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900210 &heartbeat_device,
Paul Mundtc2933962008-03-25 16:49:30 +0900211 &smbus_device,
Magnus Dammda2d7f42008-01-25 16:04:29 +0900212#ifndef CONFIG_SH_R7780RP
Magnus Dammc6f93a32007-10-15 10:36:45 +0900213 &ax88796_device,
Magnus Dammda2d7f42008-01-25 16:04:29 +0900214#endif
Paul Mundt5283ecb2006-09-27 15:59:17 +0900215};
216
Magnus Dammc1a34e42008-02-07 20:23:53 +0900217/*
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.
221 */
222static struct trapped_io cf_trapped_io = {
223 .resource = cf_ide_resources,
224 .num_resources = 2,
225 .minimum_bus_width = 16,
226};
227
Paul Mundt5283ecb2006-09-27 15:59:17 +0900228static int __init r7780rp_devices_setup(void)
229{
Paul Mundtc2933962008-03-25 16:49:30 +0900230 int ret = 0;
231
Magnus Dammc1a34e42008-02-07 20:23:53 +0900232#ifndef CONFIG_SH_R7780RP
233 if (register_trapped_io(&cf_trapped_io) == 0)
Paul Mundtc2933962008-03-25 16:49:30 +0900234 ret |= platform_device_register(&cf_ide_device);
Magnus Dammc1a34e42008-02-07 20:23:53 +0900235#endif
Paul Mundtc2933962008-03-25 16:49:30 +0900236
237 ret |= platform_add_devices(r7780rp_devices,
Paul Mundt5283ecb2006-09-27 15:59:17 +0900238 ARRAY_SIZE(r7780rp_devices));
Paul Mundtc2933962008-03-25 16:49:30 +0900239
240 ret |= i2c_register_board_info(0, highlander_i2c_devices,
241 ARRAY_SIZE(highlander_i2c_devices));
242
243 return ret;
Paul Mundt5283ecb2006-09-27 15:59:17 +0900244}
Paul Mundt32351a22007-03-12 14:38:59 +0900245device_initcall(r7780rp_devices_setup);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900246
247/*
248 * Platform specific clocks
249 */
250static void ivdr_clk_enable(struct clk *clk)
251{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900252 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900253}
254
255static void ivdr_clk_disable(struct clk *clk)
256{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900257 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900258}
259
260static struct clk_ops ivdr_clk_ops = {
261 .enable = ivdr_clk_enable,
262 .disable = ivdr_clk_disable,
263};
264
265static struct clk ivdr_clk = {
266 .name = "ivdr_clk",
267 .ops = &ivdr_clk_ops,
268};
269
270static struct clk *r7780rp_clocks[] = {
271 &ivdr_clk,
272};
273
Paul Mundt5283ecb2006-09-27 15:59:17 +0900274static void r7780rp_power_off(void)
275{
Paul Mundt32351a22007-03-12 14:38:59 +0900276 if (mach_is_r7780mp() || mach_is_r7785rp())
277 ctrl_outw(0x0001, PA_POFF);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900278}
279
280/*
281 * Initialize the board
282 */
Paul Mundt32351a22007-03-12 14:38:59 +0900283static void __init highlander_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900284{
285 u16 ver = ctrl_inw(PA_VERREG);
286 int i;
287
Paul Mundt32351a22007-03-12 14:38:59 +0900288 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
289 mach_is_r7780rp() ? "R7780RP-1" :
290 mach_is_r7780mp() ? "R7780MP" :
291 "R7785RP");
Paul Mundt5283ecb2006-09-27 15:59:17 +0900292
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);
297
Paul Mundt61dc6eae2008-10-23 12:35:43 +0900298 highlander_plat_pinmux_setup();
299
Paul Mundt5283ecb2006-09-27 15:59:17 +0900300 /*
301 * Enable the important clocks right away..
302 */
303 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
304 struct clk *clk = r7780rp_clocks[i];
305
306 clk_register(clk);
307 clk_enable(clk);
308 }
309
310 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
Paul Mundt32351a22007-03-12 14:38:59 +0900311
312 if (mach_is_r7780rp())
313 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
314
Paul Mundt2c081e72006-12-25 18:28:33 +0900315 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900316
317 pm_power_off = r7780rp_power_off;
318}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900319
Magnus Damm897cfcd82007-09-10 12:06:03 +0900320static unsigned char irl2irq[HL_NR_IRL];
321
Paul Mundtae8a5342008-04-25 17:58:21 +0900322static int highlander_irq_demux(int irq)
Magnus Damm897cfcd82007-09-10 12:06:03 +0900323{
324 if (irq >= HL_NR_IRL || !irl2irq[irq])
325 return irq;
326
327 return irl2irq[irq];
328}
329
Paul Mundtae8a5342008-04-25 17:58:21 +0900330static void __init highlander_init_irq(void)
Magnus Damm897cfcd82007-09-10 12:06:03 +0900331{
Paul Mundtae8a5342008-04-25 17:58:21 +0900332 unsigned char *ucp = highlander_plat_irq_setup();
Magnus Damm897cfcd82007-09-10 12:06:03 +0900333
334 if (ucp) {
335 plat_irq_setup_pins(IRQ_MODE_IRL3210);
336 memcpy(irl2irq, ucp, HL_NR_IRL);
337 }
338}
339
Paul Mundt2c7834a2006-09-27 18:17:31 +0900340/*
341 * The Machine Vector
342 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900343static struct sh_machine_vector mv_highlander __initmv = {
Paul Mundt32351a22007-03-12 14:38:59 +0900344 .mv_name = "Highlander",
Paul Mundt32351a22007-03-12 14:38:59 +0900345 .mv_setup = highlander_setup,
346 .mv_init_irq = highlander_init_irq,
Magnus Damm897cfcd82007-09-10 12:06:03 +0900347 .mv_irq_demux = highlander_irq_demux,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900348};