Commit | Line | Data |
---|---|---|
28626632 MD |
1 | /* |
2 | * kota2 board support | |
3 | * | |
4 | * Copyright (C) 2011 Renesas Solutions Corp. | |
5 | * Copyright (C) 2011 Magnus Damm | |
6 | * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com> | |
7 | * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; version 2 of the License. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | */ | |
22 | ||
23 | #include <linux/kernel.h> | |
24 | #include <linux/init.h> | |
25 | #include <linux/interrupt.h> | |
26 | #include <linux/irq.h> | |
27 | #include <linux/platform_device.h> | |
28 | #include <linux/delay.h> | |
29 | #include <linux/io.h> | |
30 | #include <linux/smsc911x.h> | |
31 | #include <linux/gpio.h> | |
ef4f994a MD |
32 | #include <linux/input.h> |
33 | #include <linux/input/sh_keysc.h> | |
6b7c0ea2 | 34 | #include <linux/gpio_keys.h> |
28626632 MD |
35 | #include <mach/hardware.h> |
36 | #include <mach/sh73a0.h> | |
37 | #include <mach/common.h> | |
38 | #include <asm/mach-types.h> | |
39 | #include <asm/mach/arch.h> | |
40 | #include <asm/mach/map.h> | |
41 | #include <asm/mach/time.h> | |
42 | #include <asm/hardware/gic.h> | |
43 | #include <asm/hardware/cache-l2x0.h> | |
44 | #include <asm/traps.h> | |
45 | ||
46 | static struct resource smsc9220_resources[] = { | |
47 | [0] = { | |
48 | .start = 0x14000000, /* CS5A */ | |
49 | .end = 0x140000ff, /* A1->A7 */ | |
50 | .flags = IORESOURCE_MEM, | |
51 | }, | |
52 | [1] = { | |
53 | .start = gic_spi(33), /* PINTA2 @ PORT144 */ | |
54 | .flags = IORESOURCE_IRQ, | |
55 | }, | |
56 | }; | |
57 | ||
58 | static struct smsc911x_platform_config smsc9220_platdata = { | |
59 | .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */ | |
60 | .phy_interface = PHY_INTERFACE_MODE_MII, | |
61 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
62 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
63 | }; | |
64 | ||
65 | static struct platform_device eth_device = { | |
66 | .name = "smsc911x", | |
67 | .id = 0, | |
68 | .dev = { | |
69 | .platform_data = &smsc9220_platdata, | |
70 | }, | |
71 | .resource = smsc9220_resources, | |
72 | .num_resources = ARRAY_SIZE(smsc9220_resources), | |
73 | }; | |
74 | ||
ef4f994a MD |
75 | static struct sh_keysc_info keysc_platdata = { |
76 | .mode = SH_KEYSC_MODE_6, | |
77 | .scan_timing = 3, | |
78 | .delay = 100, | |
79 | .keycodes = { | |
80 | KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND, | |
81 | 0, 0, 0, 0, 0, | |
82 | KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9, | |
83 | 0, KEY_DOWN, 0, 0, 0, | |
84 | KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6, | |
85 | KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0, | |
86 | KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3, | |
87 | 0, KEY_UP, 0, 0, 0, | |
88 | 0, 0, 0, 0, 0, 0, 0, 0, | |
89 | 0, 0, 0, 0, 0, 0, 0, 0, | |
90 | 0, 0, 0, 0, 0, 0, 0, 0, | |
91 | 0, 0, 0, 0, 0, 0, 0, 0, | |
92 | }, | |
93 | }; | |
94 | ||
95 | static struct resource keysc_resources[] = { | |
96 | [0] = { | |
97 | .name = "KEYSC", | |
98 | .start = 0xe61b0000, | |
99 | .end = 0xe61b0098 - 1, | |
100 | .flags = IORESOURCE_MEM, | |
101 | }, | |
102 | [1] = { | |
103 | .start = gic_spi(71), | |
104 | .flags = IORESOURCE_IRQ, | |
105 | }, | |
106 | }; | |
107 | ||
108 | static struct platform_device keysc_device = { | |
109 | .name = "sh_keysc", | |
110 | .id = 0, | |
111 | .num_resources = ARRAY_SIZE(keysc_resources), | |
112 | .resource = keysc_resources, | |
113 | .dev = { | |
114 | .platform_data = &keysc_platdata, | |
115 | }, | |
116 | }; | |
117 | ||
6b7c0ea2 MD |
118 | #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } |
119 | ||
120 | static struct gpio_keys_button gpio_buttons[] = { | |
121 | GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */ | |
122 | GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */ | |
123 | GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */ | |
124 | GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */ | |
125 | GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */ | |
126 | GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */ | |
127 | GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */ | |
128 | GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */ | |
129 | /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */ | |
130 | GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */ | |
131 | /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */ | |
132 | }; | |
133 | ||
134 | static struct gpio_keys_platform_data gpio_key_info = { | |
135 | .buttons = gpio_buttons, | |
136 | .nbuttons = ARRAY_SIZE(gpio_buttons), | |
137 | .poll_interval = 250, /* polled for now */ | |
138 | }; | |
139 | ||
140 | static struct platform_device gpio_keys_device = { | |
141 | .name = "gpio-keys-polled", /* polled for now */ | |
142 | .id = -1, | |
143 | .dev = { | |
144 | .platform_data = &gpio_key_info, | |
145 | }, | |
146 | }; | |
147 | ||
28626632 MD |
148 | static struct platform_device *kota2_devices[] __initdata = { |
149 | ð_device, | |
ef4f994a | 150 | &keysc_device, |
6b7c0ea2 | 151 | &gpio_keys_device, |
28626632 MD |
152 | }; |
153 | ||
154 | static struct map_desc kota2_io_desc[] __initdata = { | |
155 | /* create a 1:1 entity map for 0xe6xxxxxx | |
156 | * used by CPGA, INTC and PFC. | |
157 | */ | |
158 | { | |
159 | .virtual = 0xe6000000, | |
160 | .pfn = __phys_to_pfn(0xe6000000), | |
161 | .length = 256 << 20, | |
162 | .type = MT_DEVICE_NONSHARED | |
163 | }, | |
164 | }; | |
165 | ||
166 | static void __init kota2_map_io(void) | |
167 | { | |
168 | iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc)); | |
169 | ||
170 | /* setup early devices and console here as well */ | |
171 | sh73a0_add_early_devices(); | |
172 | shmobile_setup_console(); | |
173 | } | |
174 | ||
175 | #define PINTER0A 0xe69000a0 | |
176 | #define PINTCR0A 0xe69000b0 | |
177 | ||
178 | void __init kota2_init_irq(void) | |
179 | { | |
180 | sh73a0_init_irq(); | |
181 | ||
182 | /* setup PINT: enable PINTA2 as active low */ | |
183 | __raw_writel(1 << 29, PINTER0A); | |
184 | __raw_writew(2 << 10, PINTCR0A); | |
185 | } | |
186 | ||
187 | static void __init kota2_init(void) | |
188 | { | |
189 | sh73a0_pinmux_init(); | |
190 | ||
191 | /* SCIFA2 (UART2) */ | |
192 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); | |
193 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); | |
194 | gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL); | |
195 | gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL); | |
196 | ||
197 | /* SMSC911X */ | |
198 | gpio_request(GPIO_FN_D0_NAF0, NULL); | |
199 | gpio_request(GPIO_FN_D1_NAF1, NULL); | |
200 | gpio_request(GPIO_FN_D2_NAF2, NULL); | |
201 | gpio_request(GPIO_FN_D3_NAF3, NULL); | |
202 | gpio_request(GPIO_FN_D4_NAF4, NULL); | |
203 | gpio_request(GPIO_FN_D5_NAF5, NULL); | |
204 | gpio_request(GPIO_FN_D6_NAF6, NULL); | |
205 | gpio_request(GPIO_FN_D7_NAF7, NULL); | |
206 | gpio_request(GPIO_FN_D8_NAF8, NULL); | |
207 | gpio_request(GPIO_FN_D9_NAF9, NULL); | |
208 | gpio_request(GPIO_FN_D10_NAF10, NULL); | |
209 | gpio_request(GPIO_FN_D11_NAF11, NULL); | |
210 | gpio_request(GPIO_FN_D12_NAF12, NULL); | |
211 | gpio_request(GPIO_FN_D13_NAF13, NULL); | |
212 | gpio_request(GPIO_FN_D14_NAF14, NULL); | |
213 | gpio_request(GPIO_FN_D15_NAF15, NULL); | |
214 | gpio_request(GPIO_FN_CS5A_, NULL); | |
215 | gpio_request(GPIO_FN_WE0__FWE, NULL); | |
216 | gpio_request(GPIO_PORT144, NULL); /* PINTA2 */ | |
217 | gpio_direction_input(GPIO_PORT144); | |
218 | gpio_request(GPIO_PORT145, NULL); /* RESET */ | |
219 | gpio_direction_output(GPIO_PORT145, 1); | |
220 | ||
ef4f994a MD |
221 | /* KEYSC */ |
222 | gpio_request(GPIO_FN_KEYIN0_PU, NULL); | |
223 | gpio_request(GPIO_FN_KEYIN1_PU, NULL); | |
224 | gpio_request(GPIO_FN_KEYIN2_PU, NULL); | |
225 | gpio_request(GPIO_FN_KEYIN3_PU, NULL); | |
226 | gpio_request(GPIO_FN_KEYIN4_PU, NULL); | |
227 | gpio_request(GPIO_FN_KEYIN5_PU, NULL); | |
228 | gpio_request(GPIO_FN_KEYIN6_PU, NULL); | |
229 | gpio_request(GPIO_FN_KEYIN7_PU, NULL); | |
230 | gpio_request(GPIO_FN_KEYOUT0, NULL); | |
231 | gpio_request(GPIO_FN_KEYOUT1, NULL); | |
232 | gpio_request(GPIO_FN_KEYOUT2, NULL); | |
233 | gpio_request(GPIO_FN_KEYOUT3, NULL); | |
234 | gpio_request(GPIO_FN_KEYOUT4, NULL); | |
235 | gpio_request(GPIO_FN_KEYOUT5, NULL); | |
236 | gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL); | |
237 | gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL); | |
238 | gpio_request(GPIO_FN_KEYOUT8, NULL); | |
239 | ||
28626632 MD |
240 | #ifdef CONFIG_CACHE_L2X0 |
241 | /* Early BRESP enable, Shared attribute override enable, 64K*8way */ | |
242 | l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff); | |
243 | #endif | |
244 | sh73a0_add_standard_devices(); | |
245 | platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices)); | |
246 | } | |
247 | ||
248 | static void __init kota2_timer_init(void) | |
249 | { | |
250 | sh73a0_clock_init(); | |
251 | shmobile_timer.init(); | |
252 | return; | |
253 | } | |
254 | ||
255 | struct sys_timer kota2_timer = { | |
256 | .init = kota2_timer_init, | |
257 | }; | |
258 | ||
259 | MACHINE_START(KOTA2, "kota2") | |
260 | .map_io = kota2_map_io, | |
261 | .init_irq = kota2_init_irq, | |
262 | .handle_irq = shmobile_handle_irq_gic, | |
263 | .init_machine = kota2_init, | |
264 | .timer = &kota2_timer, | |
265 | MACHINE_END |