blob: 0bce9b88b9c219ba0cacc80a75c1cf23b1e609e7 [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 Morimotodad29d12012-04-06 01:30:09 -070029#include <linux/videodev2.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070030#include <mach/common.h>
31#include <mach/irqs.h>
32#include <asm/page.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36#include <asm/mach/time.h>
37#include <asm/hardware/cache-l2x0.h>
38#include <mach/r8a7740.h>
Kuninori Morimotodad29d12012-04-06 01:30:09 -070039#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto4d22e562012-04-06 01:28:59 -070040
41/*
42 * CON1 Camera Module
43 * CON2 Extension Bus
44 * CON3 HDMI Output
45 * CON4 Composite Video Output
46 * CON5 H-UDI JTAG
47 * CON6 ARM JTAG
48 * CON7 SD1
49 * CON8 SD2
50 * CON9 RTC BackUp
51 * CON10 Monaural Mic Input
52 * CON11 Stereo Headphone Output
53 * CON12 Audio Line Output(L)
54 * CON13 Audio Line Output(R)
55 * CON14 AWL13 Module
56 * CON15 Extension
57 * CON16 LCD1
58 * CON17 LCD2
59 * CON19 Power Input
60 * CON20 USB1
61 * CON21 USB2
62 * CON22 Serial
63 * CON23 LAN
64 * CON24 USB3
65 * LED1 Camera LED(Yellow)
66 * LED2 Power LED (Green)
67 * ED3-LED6 User LED(Yellow)
68 * LED7 LAN link LED(Green)
69 * LED8 LAN activity LED(Yellow)
70 */
71
72/*
73 * DipSwitch
74 *
75 * SW1
76 *
77 * -12345678-+---------------+----------------------------
78 * 1 | boot | hermit
79 * 0 | boot | OS auto boot
80 * -12345678-+---------------+----------------------------
81 * 00 | boot device | eMMC
82 * 10 | boot device | SDHI0 (CON7)
83 * 01 | boot device | -
84 * 11 | boot device | Extension Buss (CS0)
85 * -12345678-+---------------+----------------------------
86 * 0 | Extension Bus | D8-D15 disable, eMMC enable
87 * 1 | Extension Bus | D8-D15 enable, eMMC disable
88 * -12345678-+---------------+----------------------------
89 * 0 | SDHI1 | COM8 enable, COM14 disable
90 * 1 | SDHI1 | COM8 enable, COM14 disable
91 * -12345678-+---------------+----------------------------
92 * 00 | JTAG | SH-X2
93 * 10 | JTAG | ARM
94 * 01 | JTAG | -
95 * 11 | JTAG | Boundary Scan
96 *-----------+---------------+----------------------------
97 */
98
Kuninori Morimotodad29d12012-04-06 01:30:09 -070099/* LCDC */
100static struct fb_videomode lcdc0_mode = {
101 .name = "AMPIER/AM-800480",
102 .xres = 800,
103 .yres = 480,
104 .left_margin = 88,
105 .right_margin = 40,
106 .hsync_len = 128,
107 .upper_margin = 20,
108 .lower_margin = 5,
109 .vsync_len = 5,
110 .sync = 0,
111};
112
113static struct sh_mobile_lcdc_info lcdc0_info = {
114 .clock_source = LCDC_CLK_BUS,
115 .ch[0] = {
116 .chan = LCDC_CHAN_MAINLCD,
117 .fourcc = V4L2_PIX_FMT_RGB565,
118 .interface_type = RGB24,
119 .clock_divider = 5,
120 .flags = 0,
121 .lcd_modes = &lcdc0_mode,
122 .num_modes = 1,
123 .panel_cfg = {
124 .width = 111,
125 .height = 68,
126 },
127 },
128};
129
130static struct resource lcdc0_resources[] = {
131 [0] = {
132 .name = "LCD0",
133 .start = 0xfe940000,
134 .end = 0xfe943fff,
135 .flags = IORESOURCE_MEM,
136 },
137 [1] = {
138 .start = intcs_evt2irq(0x580),
139 .flags = IORESOURCE_IRQ,
140 },
141};
142
143static struct platform_device lcdc0_device = {
144 .name = "sh_mobile_lcdc_fb",
145 .num_resources = ARRAY_SIZE(lcdc0_resources),
146 .resource = lcdc0_resources,
147 .id = 0,
148 .dev = {
149 .platform_data = &lcdc0_info,
150 .coherent_dma_mask = ~0,
151 },
152};
153
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700154/* GPIO KEY */
155#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
156
157static struct gpio_keys_button gpio_buttons[] = {
158 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
159 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
160 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
161 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
162};
163
164static struct gpio_keys_platform_data gpio_key_info = {
165 .buttons = gpio_buttons,
166 .nbuttons = ARRAY_SIZE(gpio_buttons),
167};
168
169static struct platform_device gpio_keys_device = {
170 .name = "gpio-keys",
171 .id = -1,
172 .dev = {
173 .platform_data = &gpio_key_info,
174 },
175};
176
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700177/*
178 * board devices
179 */
180static struct platform_device *eva_devices[] __initdata = {
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700181 &lcdc0_device,
Kuninori Morimotof7e7d312012-04-06 01:31:33 -0700182 &gpio_keys_device,
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700183};
184
185/*
186 * board init
187 */
188static void __init eva_init(void)
189{
190 r8a7740_pinmux_init();
191
192 /* SCIFA1 */
193 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
194 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
195
Kuninori Morimotodad29d12012-04-06 01:30:09 -0700196 /* LCDC0 */
197 gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
198 gpio_request(GPIO_FN_LCD0_D0, NULL);
199 gpio_request(GPIO_FN_LCD0_D1, NULL);
200 gpio_request(GPIO_FN_LCD0_D2, NULL);
201 gpio_request(GPIO_FN_LCD0_D3, NULL);
202 gpio_request(GPIO_FN_LCD0_D4, NULL);
203 gpio_request(GPIO_FN_LCD0_D5, NULL);
204 gpio_request(GPIO_FN_LCD0_D6, NULL);
205 gpio_request(GPIO_FN_LCD0_D7, NULL);
206 gpio_request(GPIO_FN_LCD0_D8, NULL);
207 gpio_request(GPIO_FN_LCD0_D9, NULL);
208 gpio_request(GPIO_FN_LCD0_D10, NULL);
209 gpio_request(GPIO_FN_LCD0_D11, NULL);
210 gpio_request(GPIO_FN_LCD0_D12, NULL);
211 gpio_request(GPIO_FN_LCD0_D13, NULL);
212 gpio_request(GPIO_FN_LCD0_D14, NULL);
213 gpio_request(GPIO_FN_LCD0_D15, NULL);
214 gpio_request(GPIO_FN_LCD0_D16, NULL);
215 gpio_request(GPIO_FN_LCD0_D17, NULL);
216 gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
217 gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
218 gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
219 gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
220 gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
221 gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
222 gpio_request(GPIO_FN_LCD0_DCK, NULL);
223 gpio_request(GPIO_FN_LCD0_VSYN, NULL);
224 gpio_request(GPIO_FN_LCD0_HSYN, NULL);
225 gpio_request(GPIO_FN_LCD0_DISP, NULL);
226 gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
227
228 gpio_request(GPIO_PORT61, NULL); /* LCDDON */
229 gpio_direction_output(GPIO_PORT61, 1);
230
231 gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
232 gpio_direction_output(GPIO_PORT202, 0);
233
234 /*
235 * CAUTION
236 *
237 * DBGMD/LCDC0/FSIA MUX
238 * DBGMD_SELECT_B should be set after setting PFC Function.
239 */
240 gpio_request(GPIO_PORT176, NULL);
241 gpio_direction_output(GPIO_PORT176, 1);
242
Kuninori Morimoto4d22e562012-04-06 01:28:59 -0700243#ifdef CONFIG_CACHE_L2X0
244 /* Early BRESP enable, Shared attribute override enable, 32K*8way */
245 l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
246#endif
247
248 r8a7740_add_standard_devices();
249
250 platform_add_devices(eva_devices,
251 ARRAY_SIZE(eva_devices));
252}
253
254static void __init eva_earlytimer_init(void)
255{
256 struct clk *xtal1;
257
258 r8a7740_clock_init(MD_CK0 | MD_CK2);
259
260 xtal1 = clk_get(NULL, "extal1");
261 if (!IS_ERR(xtal1)) {
262 /* armadillo 800 eva extal1 is 24MHz */
263 clk_set_rate(xtal1, 24000000);
264 clk_put(xtal1);
265 }
266
267 shmobile_earlytimer_init();
268}
269
270static void __init eva_add_early_devices(void)
271{
272 r8a7740_add_early_devices();
273
274 /* override timer setup with board-specific code */
275 shmobile_timer.init = eva_earlytimer_init;
276}
277
278MACHINE_START(ARMADILLO800EVA, "armadillo800eva")
279 .map_io = r8a7740_map_io,
280 .init_early = eva_add_early_devices,
281 .init_irq = r8a7740_init_irq,
282 .handle_irq = shmobile_handle_irq_intc,
283 .init_machine = eva_init,
284 .timer = &shmobile_timer,
285MACHINE_END