blob: 476b15c089a722a456926f451b342fa2d2b45799 [file] [log] [blame]
Christer Weinigel95790872008-07-07 18:12:45 +01001/* Machine specific code for the Acer n30, Acer N35, Navman PiN 570,
2 * Yakumo AlphaX and Airis NC05 PDAs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (c) 2003-2005 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 *
Christer Weinigel196a0472008-07-07 18:12:41 +01007 * Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * There is a wiki with more information about the n30 port at
10 * http://handhelds.org/moin/moin.cgi/AcerN30Documentation .
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
Christer Weinigel95790872008-07-07 18:12:45 +010015 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#include <linux/kernel.h>
18#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Christer Weinigel196a0472008-07-07 18:12:41 +010020#include <linux/delay.h>
Christer Weinigel62065752008-07-07 18:12:43 +010021#include <linux/gpio_keys.h>
Christer Weinigel196a0472008-07-07 18:12:41 +010022#include <linux/init.h>
Christer Weinigel62065752008-07-07 18:12:43 +010023#include <linux/input.h>
Christer Weinigel196a0472008-07-07 18:12:41 +010024#include <linux/interrupt.h>
25#include <linux/platform_device.h>
26#include <linux/serial_core.h>
27#include <linux/timer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <asm/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/io.h>
31#include <asm/irq.h>
32#include <asm/mach-types.h>
33
Christer Weinigele43f2382008-07-07 18:12:46 +010034#include <asm/arch/fb.h>
Christer Weinigel865cc632008-07-07 18:12:44 +010035#include <asm/arch/leds-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <asm/arch/regs-gpio.h>
Christer Weinigele43f2382008-07-07 18:12:46 +010037#include <asm/arch/regs-lcd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Christer Weinigel196a0472008-07-07 18:12:41 +010039#include <asm/mach/arch.h>
40#include <asm/mach/irq.h>
41#include <asm/mach/map.h>
42
43#include <asm/plat-s3c/iic.h>
44#include <asm/plat-s3c/regs-serial.h>
45
Ben Dooksa21765a2007-02-11 18:31:01 +010046#include <asm/plat-s3c24xx/clock.h>
Ben Dooksa21765a2007-02-11 18:31:01 +010047#include <asm/plat-s3c24xx/cpu.h>
Christer Weinigel196a0472008-07-07 18:12:41 +010048#include <asm/plat-s3c24xx/devs.h>
49#include <asm/plat-s3c24xx/s3c2410.h>
Christer Weinigeld088e5f2008-07-07 18:12:42 +010050#include <asm/plat-s3c24xx/udc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52static struct map_desc n30_iodesc[] __initdata = {
53 /* nothing here yet */
54};
55
56static struct s3c2410_uartcfg n30_uartcfgs[] = {
57 /* Normal serial port */
58 [0] = {
59 .hwport = 0,
60 .flags = 0,
61 .ucon = 0x2c5,
62 .ulcon = 0x03,
63 .ufcon = 0x51,
64 },
65 /* IR port */
66 [1] = {
67 .hwport = 1,
68 .flags = 0,
69 .uart_flags = UPF_CONS_FLOW,
70 .ucon = 0x2c5,
71 .ulcon = 0x43,
72 .ufcon = 0x51,
73 },
Christer Weinigel95790872008-07-07 18:12:45 +010074 /* On the N30 the bluetooth controller is connected here.
75 * On the N35 and variants the GPS receiver is connected here. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 [2] = {
77 .hwport = 2,
78 .flags = 0,
79 .ucon = 0x2c5,
80 .ulcon = 0x03,
81 .ufcon = 0x51,
82 },
83};
84
Christer Weinigeld088e5f2008-07-07 18:12:42 +010085static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd)
86{
87 switch (cmd)
88 {
89 case S3C2410_UDC_P_ENABLE :
90 s3c2410_gpio_setpin(S3C2410_GPB3, 1);
91 break;
92 case S3C2410_UDC_P_DISABLE :
93 s3c2410_gpio_setpin(S3C2410_GPB3, 0);
94 break;
95 case S3C2410_UDC_P_RESET :
96 break;
97 default:
98 break;
99 }
100}
101
102static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
103 .udc_command = n30_udc_pullup,
104 .vbus_pin = S3C2410_GPG1,
105 .vbus_pin_inverted = 0,
106};
107
Christer Weinigel62065752008-07-07 18:12:43 +0100108static struct gpio_keys_button n30_buttons[] = {
109 {
110 .gpio = S3C2410_GPF0,
111 .code = KEY_POWER,
112 .desc = "Power",
113 .active_low = 0,
114 },
115 {
116 .gpio = S3C2410_GPG9,
117 .code = KEY_UP,
118 .desc = "Thumbwheel Up",
119 .active_low = 0,
120 },
121 {
122 .gpio = S3C2410_GPG8,
123 .code = KEY_DOWN,
124 .desc = "Thumbwheel Down",
125 .active_low = 0,
126 },
127 {
128 .gpio = S3C2410_GPG7,
129 .code = KEY_ENTER,
130 .desc = "Thumbwheel Press",
131 .active_low = 0,
132 },
133 {
134 .gpio = S3C2410_GPF7,
135 .code = KEY_HOMEPAGE,
136 .desc = "Home",
137 .active_low = 0,
138 },
139 {
140 .gpio = S3C2410_GPF6,
141 .code = KEY_CALENDAR,
142 .desc = "Calendar",
143 .active_low = 0,
144 },
145 {
146 .gpio = S3C2410_GPF5,
147 .code = KEY_ADDRESSBOOK,
148 .desc = "Contacts",
149 .active_low = 0,
150 },
151 {
152 .gpio = S3C2410_GPF4,
153 .code = KEY_MAIL,
154 .desc = "Mail",
155 .active_low = 0,
156 },
157};
158
159static struct gpio_keys_platform_data n30_button_data = {
160 .buttons = n30_buttons,
161 .nbuttons = ARRAY_SIZE(n30_buttons),
162};
163
164static struct platform_device n30_button_device = {
165 .name = "gpio-keys",
166 .id = -1,
167 .dev = {
168 .platform_data = &n30_button_data,
169 }
170};
171
Christer Weinigel95790872008-07-07 18:12:45 +0100172static struct gpio_keys_button n35_buttons[] = {
173 {
174 .gpio = S3C2410_GPF0,
175 .code = KEY_POWER,
176 .desc = "Power",
177 .active_low = 0,
178 },
179 {
180 .gpio = S3C2410_GPG9,
181 .code = KEY_UP,
182 .desc = "Joystick Up",
183 .active_low = 0,
184 },
185 {
186 .gpio = S3C2410_GPG8,
187 .code = KEY_DOWN,
188 .desc = "Joystick Down",
189 .active_low = 0,
190 },
191 {
192 .gpio = S3C2410_GPG6,
193 .code = KEY_DOWN,
194 .desc = "Joystick Left",
195 .active_low = 0,
196 },
197 {
198 .gpio = S3C2410_GPG5,
199 .code = KEY_DOWN,
200 .desc = "Joystick Right",
201 .active_low = 0,
202 },
203 {
204 .gpio = S3C2410_GPG7,
205 .code = KEY_ENTER,
206 .desc = "Joystick Press",
207 .active_low = 0,
208 },
209 {
210 .gpio = S3C2410_GPF7,
211 .code = KEY_HOMEPAGE,
212 .desc = "Home",
213 .active_low = 0,
214 },
215 {
216 .gpio = S3C2410_GPF6,
217 .code = KEY_CALENDAR,
218 .desc = "Calendar",
219 .active_low = 0,
220 },
221 {
222 .gpio = S3C2410_GPF5,
223 .code = KEY_ADDRESSBOOK,
224 .desc = "Contacts",
225 .active_low = 0,
226 },
227 {
228 .gpio = S3C2410_GPF4,
229 .code = KEY_MAIL,
230 .desc = "Mail",
231 .active_low = 0,
232 },
233 {
234 .gpio = S3C2410_GPF3,
235 .code = SW_RADIO,
236 .desc = "GPS Antenna",
237 .active_low = 0,
238 },
239 {
240 .gpio = S3C2410_GPG2,
241 .code = SW_HEADPHONE_INSERT,
242 .desc = "Headphone",
243 .active_low = 0,
244 },
245};
246
247static struct gpio_keys_platform_data n35_button_data = {
248 .buttons = n35_buttons,
249 .nbuttons = ARRAY_SIZE(n35_buttons),
250};
251
252static struct platform_device n35_button_device = {
253 .name = "gpio-keys",
254 .id = -1,
255 .num_resources = 0,
256 .dev = {
257 .platform_data = &n35_button_data,
258 }
259};
260
Christer Weinigel865cc632008-07-07 18:12:44 +0100261/* This is the bluetooth LED on the device. */
262static struct s3c24xx_led_platdata n30_blue_led_pdata = {
263 .name = "blue_led",
264 .gpio = S3C2410_GPG6,
265 .def_trigger = "",
266};
267
268/* This LED is driven by the battery microcontroller, and is blinking
269 * red, blinking green or solid green when the battery is low,
270 * charging or full respectively. By driving GPD9 low, it's possible
271 * to force the LED to blink red, so call that warning LED. */
272static struct s3c24xx_led_platdata n30_warning_led_pdata = {
273 .name = "warning_led",
274 .flags = S3C24XX_LEDF_ACTLOW,
275 .gpio = S3C2410_GPD9,
276 .def_trigger = "",
277};
278
279static struct platform_device n30_blue_led = {
280 .name = "s3c24xx_led",
281 .id = 1,
282 .dev = {
283 .platform_data = &n30_blue_led_pdata,
284 },
285};
286
287static struct platform_device n30_warning_led = {
288 .name = "s3c24xx_led",
289 .id = 2,
290 .dev = {
291 .platform_data = &n30_warning_led_pdata,
292 },
293};
294
Christer Weinigele43f2382008-07-07 18:12:46 +0100295static struct s3c2410fb_display n30_display __initdata = {
296 .type = S3C2410_LCDCON1_TFT,
297 .width = 240,
298 .height = 320,
299 .pixclock = 170000,
300 .xres = 240,
301 .yres = 320,
302 .bpp = 16,
303 .left_margin = 3,
304 .right_margin = 40,
305 .hsync_len = 40,
306 .upper_margin = 2,
307 .lower_margin = 3,
308 .vsync_len = 2,
309
310 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
311};
312
313static struct s3c2410fb_mach_info n30_fb_info __initdata = {
314 .displays = &n30_display,
315 .num_displays = 1,
316 .default_display = 0,
317 .lpcsel= 0x06,
318};
319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320static struct platform_device *n30_devices[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 &s3c_device_lcd,
322 &s3c_device_wdt,
323 &s3c_device_i2c,
324 &s3c_device_iis,
Christer Weinigel196a0472008-07-07 18:12:41 +0100325 &s3c_device_usb,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 &s3c_device_usbgadget,
Christer Weinigel62065752008-07-07 18:12:43 +0100327 &n30_button_device,
Christer Weinigel865cc632008-07-07 18:12:44 +0100328 &n30_blue_led,
329 &n30_warning_led,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330};
331
Christer Weinigel95790872008-07-07 18:12:45 +0100332static struct platform_device *n35_devices[] __initdata = {
333 &s3c_device_lcd,
334 &s3c_device_wdt,
335 &s3c_device_i2c,
336 &s3c_device_iis,
337 &s3c_device_usbgadget,
338 &n35_button_device,
339};
340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341static struct s3c2410_platform_i2c n30_i2ccfg = {
342 .flags = 0,
343 .slave_addr = 0x10,
344 .bus_freq = 10*1000,
345 .max_freq = 10*1000,
346};
347
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100348static void __init n30_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
350 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
351 s3c24xx_init_clocks(0);
352 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353}
354
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100355static void __init n30_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356{
357 s3c24xx_init_irq();
358}
359
Ben Dooks027da012005-09-05 20:47:53 +0100360/* GPB3 is the line that controls the pull-up for the USB D+ line */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100362static void __init n30_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363{
Christer Weinigele43f2382008-07-07 18:12:46 +0100364 s3c24xx_fb_set_platdata(&n30_fb_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
Christer Weinigeld088e5f2008-07-07 18:12:42 +0100366 s3c24xx_udc_set_platdata(&n30_udc_cfg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
Ben Dooks027da012005-09-05 20:47:53 +0100368 /* Turn off suspend on both USB ports, and switch the
369 * selectable USB port to USB device mode. */
370
371 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
372 S3C2410_MISCCR_USBSUSPND0 |
373 S3C2410_MISCCR_USBSUSPND1, 0x0);
Ben Dooks57e51712007-04-20 11:19:16 +0100374
Christer Weinigel95790872008-07-07 18:12:45 +0100375 if (machine_is_n30()) {
376 /* Turn off suspend on both USB ports, and switch the
377 * selectable USB port to USB device mode. */
378 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
379 S3C2410_MISCCR_USBSUSPND0 |
380 S3C2410_MISCCR_USBSUSPND1, 0x0);
381
382 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
383 }
384
385 if (machine_is_n35()) {
386 /* Turn off suspend and switch the selectable USB port
387 * to USB device mode. Turn on suspend for the host
388 * port since it is not connected on the N35.
389 *
390 * Actually, the host port is available at some pads
391 * on the back of the device, so it would actually be
392 * possible to add a USB device inside the N35 if you
393 * are willing to do some hardware modifications. */
394 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
395 S3C2410_MISCCR_USBSUSPND0 |
396 S3C2410_MISCCR_USBSUSPND1,
397 S3C2410_MISCCR_USBSUSPND1);
398
399 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401}
402
403MACHINE_START(N30, "Acer-N30")
Ben Dooks027da012005-09-05 20:47:53 +0100404 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
405 Ben Dooks <ben-linux@fluff.org>
406 */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100407 .phys_io = S3C2410_PA_UART,
408 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
409 .boot_params = S3C2410_SDRAM_PA + 0x100,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 .timer = &s3c24xx_timer,
411 .init_machine = n30_init,
412 .init_irq = n30_init_irq,
413 .map_io = n30_map_io,
414MACHINE_END
Christer Weinigel95790872008-07-07 18:12:45 +0100415
416MACHINE_START(N35, "Acer-N35")
417 /* Maintainer: Christer Weinigel <christer@weinigel.se>
418 */
419 .phys_io = S3C2410_PA_UART,
420 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
421 .boot_params = S3C2410_SDRAM_PA + 0x100,
422 .timer = &s3c24xx_timer,
423 .init_machine = n30_init,
424 .init_irq = n30_init_irq,
425 .map_io = n30_map_io,
426MACHINE_END