blob: d439e7f761874af8edc367754fda22f1150f38bd [file] [log] [blame]
Kuninori Morimoto4d22e562012-04-06 01:28:59 -07001/*
2 * armadillo 800 eva board support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22#include <linux/clk.h>
23#include <linux/err.h>
24#include <linux/kernel.h>
Kuninori Morimotof7e7d312012-04-06 01:31:33 -070025#include <linux/input.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070026#include <linux/platform_device.h>
27#include <linux/gpio.h>
Kuninori Morimotof7e7d312012-04-06 01:31:33 -070028#include <linux/gpio_keys.h>
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -070029#include <linux/sh_eth.h>
Kuninori Morimotodad29d12012-04-06 01:30:09 -070030#include <linux/videodev2.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070031#include <mach/common.h>
32#include <mach/irqs.h>
33#include <asm/page.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/time.h>
38#include <asm/hardware/cache-l2x0.h>
39#include <mach/r8a7740.h>
Kuninori Morimotodad29d12012-04-06 01:30:09 -070040#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070041
42/*
43 * CON1 Camera Module
44 * CON2 Extension Bus
45 * CON3 HDMI Output
46 * CON4 Composite Video Output
47 * CON5 H-UDI JTAG
48 * CON6 ARM JTAG
49 * CON7 SD1
50 * CON8 SD2
51 * CON9 RTC BackUp
52 * CON10 Monaural Mic Input
53 * CON11 Stereo Headphone Output
54 * CON12 Audio Line Output(L)
55 * CON13 Audio Line Output(R)
56 * CON14 AWL13 Module
57 * CON15 Extension
58 * CON16 LCD1
59 * CON17 LCD2
60 * CON19 Power Input
61 * CON20 USB1
62 * CON21 USB2
63 * CON22 Serial
64 * CON23 LAN
65 * CON24 USB3
66 * LED1 Camera LED(Yellow)
67 * LED2 Power LED (Green)
68 * ED3-LED6 User LED(Yellow)
69 * LED7 LAN link LED(Green)
70 * LED8 LAN activity LED(Yellow)
71 */
72
73/*
74 * DipSwitch
75 *
76 * SW1
77 *
78 * -12345678-+---------------+----------------------------
79 * 1 | boot | hermit
80 * 0 | boot | OS auto boot
81 * -12345678-+---------------+----------------------------
82 * 00 | boot device | eMMC
83 * 10 | boot device | SDHI0 (CON7)
84 * 01 | boot device | -
85 * 11 | boot device | Extension Buss (CS0)
86 * -12345678-+---------------+----------------------------
87 * 0 | Extension Bus | D8-D15 disable, eMMC enable
88 * 1 | Extension Bus | D8-D15 enable, eMMC disable
89 * -12345678-+---------------+----------------------------
90 * 0 | SDHI1 | COM8 enable, COM14 disable
91 * 1 | SDHI1 | COM8 enable, COM14 disable
92 * -12345678-+---------------+----------------------------
93 * 00 | JTAG | SH-X2
94 * 10 | JTAG | ARM
95 * 01 | JTAG | -
96 * 11 | JTAG | Boundary Scan
97 *-----------+---------------+----------------------------
98 */
99
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700100/* Ether */
101static struct sh_eth_plat_data sh_eth_platdata = {
102 .phy = 0x00, /* LAN8710A */
103 .edmac_endian = EDMAC_LITTLE_ENDIAN,
104 .register_type = SH_ETH_REG_GIGABIT,
105 .phy_interface = PHY_INTERFACE_MODE_MII,
106};
107
108static struct resource sh_eth_resources[] = {
109 {
110 .start = 0xe9a00000,
111 .end = 0xe9a00800 - 1,
112 .flags = IORESOURCE_MEM,
113 }, {
114 .start = 0xe9a01800,
115 .end = 0xe9a02000 - 1,
116 .flags = IORESOURCE_MEM,
117 }, {
118 .start = evt2irq(0x0500),
119 .flags = IORESOURCE_IRQ,
120 },
121};
122
123static struct platform_device sh_eth_device = {
124 .name = "sh-eth",
125 .dev = {
126 .platform_data = &sh_eth_platdata,
127 },
128 .resource = sh_eth_resources,
129 .num_resources = ARRAY_SIZE(sh_eth_resources),
130};
131
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700132/* LCDC */
133static struct fb_videomode lcdc0_mode = {
134 .name = "AMPIER/AM-800480",
135 .xres = 800,
136 .yres = 480,
137 .left_margin = 88,
138 .right_margin = 40,
139 .hsync_len = 128,
140 .upper_margin = 20,
141 .lower_margin = 5,
142 .vsync_len = 5,
143 .sync = 0,
144};
145
146static struct sh_mobile_lcdc_info lcdc0_info = {
147 .clock_source = LCDC_CLK_BUS,
148 .ch[0] = {
149 .chan = LCDC_CHAN_MAINLCD,
150 .fourcc = V4L2_PIX_FMT_RGB565,
151 .interface_type = RGB24,
152 .clock_divider = 5,
153 .flags = 0,
154 .lcd_modes = &lcdc0_mode,
155 .num_modes = 1,
156 .panel_cfg = {
157 .width = 111,
158 .height = 68,
159 },
160 },
161};
162
163static struct resource lcdc0_resources[] = {
164 [0] = {
165 .name = "LCD0",
166 .start = 0xfe940000,
167 .end = 0xfe943fff,
168 .flags = IORESOURCE_MEM,
169 },
170 [1] = {
171 .start = intcs_evt2irq(0x580),
172 .flags = IORESOURCE_IRQ,
173 },
174};
175
176static struct platform_device lcdc0_device = {
177 .name = "sh_mobile_lcdc_fb",
178 .num_resources = ARRAY_SIZE(lcdc0_resources),
179 .resource = lcdc0_resources,
180 .id = 0,
181 .dev = {
182 .platform_data = &lcdc0_info,
183 .coherent_dma_mask = ~0,
184 },
185};
186
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700187/* GPIO KEY */
188#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
189
190static struct gpio_keys_button gpio_buttons[] = {
191 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
192 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
193 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
194 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
195};
196
197static struct gpio_keys_platform_data gpio_key_info = {
198 .buttons = gpio_buttons,
199 .nbuttons = ARRAY_SIZE(gpio_buttons),
200};
201
202static struct platform_device gpio_keys_device = {
203 .name = "gpio-keys",
204 .id = -1,
205 .dev = {
206 .platform_data = &gpio_key_info,
207 },
208};
209
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700210/*
211 * board devices
212 */
213static struct platform_device *eva_devices[] __initdata = {
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700214 &lcdc0_device,
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700215 &gpio_keys_device,
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700216 &sh_eth_device,
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700217};
218
219/*
220 * board init
221 */
222static void __init eva_init(void)
223{
224 r8a7740_pinmux_init();
225
226 /* SCIFA1 */
227 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
228 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
229
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700230 /* LCDC0 */
231 gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
232 gpio_request(GPIO_FN_LCD0_D0, NULL);
233 gpio_request(GPIO_FN_LCD0_D1, NULL);
234 gpio_request(GPIO_FN_LCD0_D2, NULL);
235 gpio_request(GPIO_FN_LCD0_D3, NULL);
236 gpio_request(GPIO_FN_LCD0_D4, NULL);
237 gpio_request(GPIO_FN_LCD0_D5, NULL);
238 gpio_request(GPIO_FN_LCD0_D6, NULL);
239 gpio_request(GPIO_FN_LCD0_D7, NULL);
240 gpio_request(GPIO_FN_LCD0_D8, NULL);
241 gpio_request(GPIO_FN_LCD0_D9, NULL);
242 gpio_request(GPIO_FN_LCD0_D10, NULL);
243 gpio_request(GPIO_FN_LCD0_D11, NULL);
244 gpio_request(GPIO_FN_LCD0_D12, NULL);
245 gpio_request(GPIO_FN_LCD0_D13, NULL);
246 gpio_request(GPIO_FN_LCD0_D14, NULL);
247 gpio_request(GPIO_FN_LCD0_D15, NULL);
248 gpio_request(GPIO_FN_LCD0_D16, NULL);
249 gpio_request(GPIO_FN_LCD0_D17, NULL);
250 gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
251 gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
252 gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
253 gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
254 gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
255 gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
256 gpio_request(GPIO_FN_LCD0_DCK, NULL);
257 gpio_request(GPIO_FN_LCD0_VSYN, NULL);
258 gpio_request(GPIO_FN_LCD0_HSYN, NULL);
259 gpio_request(GPIO_FN_LCD0_DISP, NULL);
260 gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
261
262 gpio_request(GPIO_PORT61, NULL); /* LCDDON */
263 gpio_direction_output(GPIO_PORT61, 1);
264
265 gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
266 gpio_direction_output(GPIO_PORT202, 0);
267
Kuninori Morimotod8fed1e2012-04-06 01:32:02 -0700268 /* GETHER */
269 gpio_request(GPIO_FN_ET_CRS, NULL);
270 gpio_request(GPIO_FN_ET_MDC, NULL);
271 gpio_request(GPIO_FN_ET_MDIO, NULL);
272 gpio_request(GPIO_FN_ET_TX_ER, NULL);
273 gpio_request(GPIO_FN_ET_RX_ER, NULL);
274 gpio_request(GPIO_FN_ET_ERXD0, NULL);
275 gpio_request(GPIO_FN_ET_ERXD1, NULL);
276 gpio_request(GPIO_FN_ET_ERXD2, NULL);
277 gpio_request(GPIO_FN_ET_ERXD3, NULL);
278 gpio_request(GPIO_FN_ET_TX_CLK, NULL);
279 gpio_request(GPIO_FN_ET_TX_EN, NULL);
280 gpio_request(GPIO_FN_ET_ETXD0, NULL);
281 gpio_request(GPIO_FN_ET_ETXD1, NULL);
282 gpio_request(GPIO_FN_ET_ETXD2, NULL);
283 gpio_request(GPIO_FN_ET_ETXD3, NULL);
284 gpio_request(GPIO_FN_ET_PHY_INT, NULL);
285 gpio_request(GPIO_FN_ET_COL, NULL);
286 gpio_request(GPIO_FN_ET_RX_DV, NULL);
287 gpio_request(GPIO_FN_ET_RX_CLK, NULL);
288
289 gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
290 gpio_direction_output(GPIO_PORT18, 1);
291
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700292 /*
293 * CAUTION
294 *
295 * DBGMD/LCDC0/FSIA MUX
296 * DBGMD_SELECT_B should be set after setting PFC Function.
297 */
298 gpio_request(GPIO_PORT176, NULL);
299 gpio_direction_output(GPIO_PORT176, 1);
300
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700301#ifdef CONFIG_CACHE_L2X0
302 /* Early BRESP enable, Shared attribute override enable, 32K*8way */
303 l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
304#endif
305
306 r8a7740_add_standard_devices();
307
308 platform_add_devices(eva_devices,
309 ARRAY_SIZE(eva_devices));
310}
311
312static void __init eva_earlytimer_init(void)
313{
314 struct clk *xtal1;
315
316 r8a7740_clock_init(MD_CK0 | MD_CK2);
317
318 xtal1 = clk_get(NULL, "extal1");
319 if (!IS_ERR(xtal1)) {
320 /* armadillo 800 eva extal1 is 24MHz */
321 clk_set_rate(xtal1, 24000000);
322 clk_put(xtal1);
323 }
324
325 shmobile_earlytimer_init();
326}
327
328static void __init eva_add_early_devices(void)
329{
330 r8a7740_add_early_devices();
331
332 /* override timer setup with board-specific code */
333 shmobile_timer.init = eva_earlytimer_init;
334}
335
336MACHINE_START(ARMADILLO800EVA, "armadillo800eva")
337 .map_io = r8a7740_map_io,
338 .init_early = eva_add_early_devices,
339 .init_irq = r8a7740_init_irq,
340 .handle_irq = shmobile_handle_irq_intc,
341 .init_machine = eva_init,
342 .timer = &shmobile_timer,
343MACHINE_END