blob: 3ab5fc4b55b79b96231342bc408dea99841e039b [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>
Paul Mundt8786c952007-08-20 13:03:41 +090022#include <asm/heartbeat.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090023#include <asm/io.h>
24
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090025static struct resource r8a66597_usb_host_resources[] = {
26 [0] = {
27 .name = "r8a66597_hcd",
28 .start = 0xA4200000,
29 .end = 0xA42000FF,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .name = "r8a66597_hcd",
34 .start = 11, /* irq number */
35 .end = 11,
36 .flags = IORESOURCE_IRQ,
37 },
38};
39
40static struct platform_device r8a66597_usb_host_device = {
41 .name = "r8a66597_hcd",
42 .id = -1,
43 .dev = {
44 .dma_mask = NULL, /* don't use dma */
45 .coherent_dma_mask = 0xffffffff,
46 },
47 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
48 .resource = r8a66597_usb_host_resources,
49};
50
51static struct resource m66592_usb_peripheral_resources[] = {
52 [0] = {
53 .name = "m66592_udc",
54 .start = 0xb0000000,
55 .end = 0xb00000FF,
56 .flags = IORESOURCE_MEM,
57 },
58 [1] = {
59 .name = "m66592_udc",
60 .start = 9, /* irq number */
61 .end = 9,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct platform_device m66592_usb_peripheral_device = {
67 .name = "m66592_udc",
68 .id = -1,
69 .dev = {
70 .dma_mask = NULL, /* don't use dma */
71 .coherent_dma_mask = 0xffffffff,
72 },
73 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
74 .resource = m66592_usb_peripheral_resources,
75};
76
Paul Mundt0c020e32006-12-06 10:43:44 +090077static struct resource cf_ide_resources[] = {
78 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090079 .start = PA_AREA5_IO + 0x1000,
80 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
81 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090082 },
83 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090084 .start = PA_AREA5_IO + 0x80c,
85 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
86 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090087 },
88 [2] = {
Paul Mundt32351a22007-03-12 14:38:59 +090089#ifdef CONFIG_SH_R7780RP
Paul Mundt0c020e32006-12-06 10:43:44 +090090 .start = 4,
Paul Mundt32351a22007-03-12 14:38:59 +090091#else
92 .start = 1,
Paul Mundt0c020e32006-12-06 10:43:44 +090093#endif
94 .flags = IORESOURCE_IRQ,
95 },
96};
97
Paul Mundt71074d32007-02-14 14:49:04 +090098static struct pata_platform_info pata_info = {
99 .ioport_shift = 1,
100};
101
Paul Mundt0c020e32006-12-06 10:43:44 +0900102static struct platform_device cf_ide_device = {
103 .name = "pata_platform",
104 .id = -1,
105 .num_resources = ARRAY_SIZE(cf_ide_resources),
106 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +0900107 .dev = {
108 .platform_data = &pata_info,
109 },
Paul Mundt0c020e32006-12-06 10:43:44 +0900110};
111
Paul Mundt3b4d9532007-02-13 15:42:28 +0900112static struct resource heartbeat_resources[] = {
113 [0] = {
114 .start = PA_OBLED,
Paul Mundta1fd3062007-08-23 15:11:44 +0900115 .end = PA_OBLED,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900116 .flags = IORESOURCE_MEM,
117 },
118};
119
Paul Mundt8786c952007-08-20 13:03:41 +0900120#ifndef CONFIG_SH_R7785RP
121static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
122
123static struct heartbeat_data heartbeat_data = {
124 .bit_pos = heartbeat_bit_pos,
125 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
126};
127#endif
128
Paul Mundt3b4d9532007-02-13 15:42:28 +0900129static struct platform_device heartbeat_device = {
130 .name = "heartbeat",
131 .id = -1,
Paul Mundt32351a22007-03-12 14:38:59 +0900132
133 /* R7785RP has a slightly more sensible FPGA.. */
134#ifndef CONFIG_SH_R7785RP
Paul Mundt3b4d9532007-02-13 15:42:28 +0900135 .dev = {
Paul Mundta1fd3062007-08-23 15:11:44 +0900136 .platform_data = &heartbeat_data,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900137 },
Paul Mundt32351a22007-03-12 14:38:59 +0900138#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +0900139 .num_resources = ARRAY_SIZE(heartbeat_resources),
140 .resource = heartbeat_resources,
141};
142
Paul Mundt5283ecb2006-09-27 15:59:17 +0900143static struct platform_device *r7780rp_devices[] __initdata = {
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +0900144 &r8a66597_usb_host_device,
145 &m66592_usb_peripheral_device,
Paul Mundt0c020e32006-12-06 10:43:44 +0900146 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900147 &heartbeat_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +0900148};
149
150static int __init r7780rp_devices_setup(void)
151{
152 return platform_add_devices(r7780rp_devices,
153 ARRAY_SIZE(r7780rp_devices));
154}
Paul Mundt32351a22007-03-12 14:38:59 +0900155device_initcall(r7780rp_devices_setup);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900156
157/*
158 * Platform specific clocks
159 */
160static void ivdr_clk_enable(struct clk *clk)
161{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900162 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900163}
164
165static void ivdr_clk_disable(struct clk *clk)
166{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900167 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900168}
169
170static struct clk_ops ivdr_clk_ops = {
171 .enable = ivdr_clk_enable,
172 .disable = ivdr_clk_disable,
173};
174
175static struct clk ivdr_clk = {
176 .name = "ivdr_clk",
177 .ops = &ivdr_clk_ops,
178};
179
180static struct clk *r7780rp_clocks[] = {
181 &ivdr_clk,
182};
183
Paul Mundt5283ecb2006-09-27 15:59:17 +0900184static void r7780rp_power_off(void)
185{
Paul Mundt32351a22007-03-12 14:38:59 +0900186 if (mach_is_r7780mp() || mach_is_r7785rp())
187 ctrl_outw(0x0001, PA_POFF);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900188}
189
190/*
191 * Initialize the board
192 */
Paul Mundt32351a22007-03-12 14:38:59 +0900193static void __init highlander_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900194{
195 u16 ver = ctrl_inw(PA_VERREG);
196 int i;
197
Paul Mundt32351a22007-03-12 14:38:59 +0900198 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
199 mach_is_r7780rp() ? "R7780RP-1" :
200 mach_is_r7780mp() ? "R7780MP" :
201 "R7785RP");
Paul Mundt5283ecb2006-09-27 15:59:17 +0900202
203 printk(KERN_INFO "Board version: %d (revision %d), "
204 "FPGA version: %d (revision %d)\n",
205 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
206 (ver >> 4) & 0xf, ver & 0xf);
207
208 /*
209 * Enable the important clocks right away..
210 */
211 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
212 struct clk *clk = r7780rp_clocks[i];
213
214 clk_register(clk);
215 clk_enable(clk);
216 }
217
218 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
Paul Mundt32351a22007-03-12 14:38:59 +0900219
220 if (mach_is_r7780rp())
221 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
222
Paul Mundt2c081e72006-12-25 18:28:33 +0900223 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900224
225 pm_power_off = r7780rp_power_off;
226}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900227
228/*
229 * The Machine Vector
230 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900231static struct sh_machine_vector mv_highlander __initmv = {
Paul Mundt32351a22007-03-12 14:38:59 +0900232 .mv_name = "Highlander",
Paul Mundt2c7834a2006-09-27 18:17:31 +0900233 .mv_nr_irqs = 109,
Paul Mundt32351a22007-03-12 14:38:59 +0900234 .mv_setup = highlander_setup,
235 .mv_init_irq = highlander_init_irq,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900236};