Commit | Line | Data |
---|---|---|
5283ecb5 PM |
1 | /* |
2 | * arch/sh/boards/renesas/r7780rp/setup.c | |
3 | * | |
32351a28 PM |
4 | * Renesas Solutions Highlander Support. |
5 | * | |
5283ecb5 | 6 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. |
71074d3a | 7 | * Copyright (C) 2005 - 2007 Paul Mundt |
5283ecb5 | 8 | * |
32351a28 PM |
9 | * This contains support for the R7780RP-1, R7780MP, and R7785RP |
10 | * Highlander modules. | |
5283ecb5 PM |
11 | * |
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> | |
71074d3a | 18 | #include <linux/pata_platform.h> |
5283ecb5 | 19 | #include <asm/machvec.h> |
082c44d2 | 20 | #include <asm/r7780rp.h> |
5283ecb5 PM |
21 | #include <asm/clock.h> |
22 | #include <asm/io.h> | |
23 | ||
0c020e3d PM |
24 | static struct resource cf_ide_resources[] = { |
25 | [0] = { | |
71074d3a PM |
26 | .start = PA_AREA5_IO + 0x1000, |
27 | .end = PA_AREA5_IO + 0x1000 + 0x08 - 1, | |
28 | .flags = IORESOURCE_MEM, | |
0c020e3d PM |
29 | }, |
30 | [1] = { | |
71074d3a PM |
31 | .start = PA_AREA5_IO + 0x80c, |
32 | .end = PA_AREA5_IO + 0x80c + 0x16 - 1, | |
33 | .flags = IORESOURCE_MEM, | |
0c020e3d PM |
34 | }, |
35 | [2] = { | |
32351a28 | 36 | #ifdef CONFIG_SH_R7780RP |
0c020e3d | 37 | .start = 4, |
32351a28 PM |
38 | #else |
39 | .start = 1, | |
0c020e3d PM |
40 | #endif |
41 | .flags = IORESOURCE_IRQ, | |
42 | }, | |
43 | }; | |
44 | ||
71074d3a PM |
45 | static struct pata_platform_info pata_info = { |
46 | .ioport_shift = 1, | |
47 | }; | |
48 | ||
0c020e3d PM |
49 | static struct platform_device cf_ide_device = { |
50 | .name = "pata_platform", | |
51 | .id = -1, | |
52 | .num_resources = ARRAY_SIZE(cf_ide_resources), | |
53 | .resource = cf_ide_resources, | |
71074d3a PM |
54 | .dev = { |
55 | .platform_data = &pata_info, | |
56 | }, | |
0c020e3d PM |
57 | }; |
58 | ||
3b4d9539 PM |
59 | static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 }; |
60 | ||
61 | static struct resource heartbeat_resources[] = { | |
62 | [0] = { | |
63 | .start = PA_OBLED, | |
64 | .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1, | |
65 | .flags = IORESOURCE_MEM, | |
66 | }, | |
67 | }; | |
68 | ||
69 | static struct platform_device heartbeat_device = { | |
70 | .name = "heartbeat", | |
71 | .id = -1, | |
32351a28 PM |
72 | |
73 | /* R7785RP has a slightly more sensible FPGA.. */ | |
74 | #ifndef CONFIG_SH_R7785RP | |
3b4d9539 PM |
75 | .dev = { |
76 | .platform_data = heartbeat_bit_pos, | |
77 | }, | |
32351a28 | 78 | #endif |
3b4d9539 PM |
79 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
80 | .resource = heartbeat_resources, | |
81 | }; | |
82 | ||
5283ecb5 | 83 | static struct platform_device *r7780rp_devices[] __initdata = { |
0c020e3d | 84 | &cf_ide_device, |
3b4d9539 | 85 | &heartbeat_device, |
5283ecb5 PM |
86 | }; |
87 | ||
88 | static int __init r7780rp_devices_setup(void) | |
89 | { | |
90 | return platform_add_devices(r7780rp_devices, | |
91 | ARRAY_SIZE(r7780rp_devices)); | |
92 | } | |
32351a28 | 93 | device_initcall(r7780rp_devices_setup); |
5283ecb5 PM |
94 | |
95 | /* | |
96 | * Platform specific clocks | |
97 | */ | |
98 | static void ivdr_clk_enable(struct clk *clk) | |
99 | { | |
39374aad | 100 | ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL); |
5283ecb5 PM |
101 | } |
102 | ||
103 | static void ivdr_clk_disable(struct clk *clk) | |
104 | { | |
39374aad | 105 | ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL); |
5283ecb5 PM |
106 | } |
107 | ||
108 | static struct clk_ops ivdr_clk_ops = { | |
109 | .enable = ivdr_clk_enable, | |
110 | .disable = ivdr_clk_disable, | |
111 | }; | |
112 | ||
113 | static struct clk ivdr_clk = { | |
114 | .name = "ivdr_clk", | |
115 | .ops = &ivdr_clk_ops, | |
116 | }; | |
117 | ||
118 | static struct clk *r7780rp_clocks[] = { | |
119 | &ivdr_clk, | |
120 | }; | |
121 | ||
5283ecb5 PM |
122 | static void r7780rp_power_off(void) |
123 | { | |
32351a28 PM |
124 | if (mach_is_r7780mp() || mach_is_r7785rp()) |
125 | ctrl_outw(0x0001, PA_POFF); | |
5283ecb5 PM |
126 | } |
127 | ||
128 | /* | |
129 | * Initialize the board | |
130 | */ | |
32351a28 | 131 | static void __init highlander_setup(char **cmdline_p) |
5283ecb5 PM |
132 | { |
133 | u16 ver = ctrl_inw(PA_VERREG); | |
134 | int i; | |
135 | ||
32351a28 PM |
136 | printk(KERN_INFO "Renesas Solutions Highlander %s support.\n", |
137 | mach_is_r7780rp() ? "R7780RP-1" : | |
138 | mach_is_r7780mp() ? "R7780MP" : | |
139 | "R7785RP"); | |
5283ecb5 PM |
140 | |
141 | printk(KERN_INFO "Board version: %d (revision %d), " | |
142 | "FPGA version: %d (revision %d)\n", | |
143 | (ver >> 12) & 0xf, (ver >> 8) & 0xf, | |
144 | (ver >> 4) & 0xf, ver & 0xf); | |
145 | ||
146 | /* | |
147 | * Enable the important clocks right away.. | |
148 | */ | |
149 | for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) { | |
150 | struct clk *clk = r7780rp_clocks[i]; | |
151 | ||
152 | clk_register(clk); | |
153 | clk_enable(clk); | |
154 | } | |
155 | ||
156 | ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */ | |
32351a28 PM |
157 | |
158 | if (mach_is_r7780rp()) | |
159 | ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */ | |
160 | ||
2c081e71 | 161 | ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */ |
5283ecb5 PM |
162 | |
163 | pm_power_off = r7780rp_power_off; | |
164 | } | |
2c7834a6 PM |
165 | |
166 | /* | |
167 | * The Machine Vector | |
168 | */ | |
82f81f47 | 169 | static struct sh_machine_vector mv_highlander __initmv = { |
32351a28 | 170 | .mv_name = "Highlander", |
2c7834a6 | 171 | .mv_nr_irqs = 109, |
32351a28 PM |
172 | .mv_setup = highlander_setup, |
173 | .mv_init_irq = highlander_init_irq, | |
2c7834a6 | 174 | }; |