mach-n30.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /* Machine specific code for the Acer n30, Acer N35, Navman PiN 570,
  2. * Yakumo AlphaX and Airis NC05 PDAs.
  3. *
  4. * Copyright (c) 2003-2005 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se>
  8. *
  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.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/init.h>
  20. #include <linux/gpio.h>
  21. #include <linux/input.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/serial_core.h>
  25. #include <linux/timer.h>
  26. #include <linux/io.h>
  27. #include <mach/hardware.h>
  28. #include <asm/irq.h>
  29. #include <asm/mach-types.h>
  30. #include <mach/fb.h>
  31. #include <mach/leds-gpio.h>
  32. #include <mach/regs-gpio.h>
  33. #include <mach/regs-lcd.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/irq.h>
  36. #include <asm/mach/map.h>
  37. #include <plat/iic.h>
  38. #include <plat/regs-serial.h>
  39. #include <plat/clock.h>
  40. #include <plat/cpu.h>
  41. #include <plat/devs.h>
  42. #include <plat/s3c2410.h>
  43. #include <plat/udc.h>
  44. static struct map_desc n30_iodesc[] __initdata = {
  45. /* nothing here yet */
  46. };
  47. static struct s3c2410_uartcfg n30_uartcfgs[] = {
  48. /* Normal serial port */
  49. [0] = {
  50. .hwport = 0,
  51. .flags = 0,
  52. .ucon = 0x2c5,
  53. .ulcon = 0x03,
  54. .ufcon = 0x51,
  55. },
  56. /* IR port */
  57. [1] = {
  58. .hwport = 1,
  59. .flags = 0,
  60. .uart_flags = UPF_CONS_FLOW,
  61. .ucon = 0x2c5,
  62. .ulcon = 0x43,
  63. .ufcon = 0x51,
  64. },
  65. /* On the N30 the bluetooth controller is connected here.
  66. * On the N35 and variants the GPS receiver is connected here. */
  67. [2] = {
  68. .hwport = 2,
  69. .flags = 0,
  70. .ucon = 0x2c5,
  71. .ulcon = 0x03,
  72. .ufcon = 0x51,
  73. },
  74. };
  75. static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd)
  76. {
  77. switch (cmd) {
  78. case S3C2410_UDC_P_ENABLE :
  79. s3c2410_gpio_setpin(S3C2410_GPB(3), 1);
  80. break;
  81. case S3C2410_UDC_P_DISABLE :
  82. s3c2410_gpio_setpin(S3C2410_GPB(3), 0);
  83. break;
  84. case S3C2410_UDC_P_RESET :
  85. break;
  86. default:
  87. break;
  88. }
  89. }
  90. static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
  91. .udc_command = n30_udc_pullup,
  92. .vbus_pin = S3C2410_GPG(1),
  93. .vbus_pin_inverted = 0,
  94. };
  95. static struct gpio_keys_button n30_buttons[] = {
  96. {
  97. .gpio = S3C2410_GPF(0),
  98. .code = KEY_POWER,
  99. .desc = "Power",
  100. .active_low = 0,
  101. },
  102. {
  103. .gpio = S3C2410_GPG(9),
  104. .code = KEY_UP,
  105. .desc = "Thumbwheel Up",
  106. .active_low = 0,
  107. },
  108. {
  109. .gpio = S3C2410_GPG(8),
  110. .code = KEY_DOWN,
  111. .desc = "Thumbwheel Down",
  112. .active_low = 0,
  113. },
  114. {
  115. .gpio = S3C2410_GPG(7),
  116. .code = KEY_ENTER,
  117. .desc = "Thumbwheel Press",
  118. .active_low = 0,
  119. },
  120. {
  121. .gpio = S3C2410_GPF(7),
  122. .code = KEY_HOMEPAGE,
  123. .desc = "Home",
  124. .active_low = 0,
  125. },
  126. {
  127. .gpio = S3C2410_GPF(6),
  128. .code = KEY_CALENDAR,
  129. .desc = "Calendar",
  130. .active_low = 0,
  131. },
  132. {
  133. .gpio = S3C2410_GPF(5),
  134. .code = KEY_ADDRESSBOOK,
  135. .desc = "Contacts",
  136. .active_low = 0,
  137. },
  138. {
  139. .gpio = S3C2410_GPF(4),
  140. .code = KEY_MAIL,
  141. .desc = "Mail",
  142. .active_low = 0,
  143. },
  144. };
  145. static struct gpio_keys_platform_data n30_button_data = {
  146. .buttons = n30_buttons,
  147. .nbuttons = ARRAY_SIZE(n30_buttons),
  148. };
  149. static struct platform_device n30_button_device = {
  150. .name = "gpio-keys",
  151. .id = -1,
  152. .dev = {
  153. .platform_data = &n30_button_data,
  154. }
  155. };
  156. static struct gpio_keys_button n35_buttons[] = {
  157. {
  158. .gpio = S3C2410_GPF(0),
  159. .code = KEY_POWER,
  160. .desc = "Power",
  161. .active_low = 0,
  162. },
  163. {
  164. .gpio = S3C2410_GPG(9),
  165. .code = KEY_UP,
  166. .desc = "Joystick Up",
  167. .active_low = 0,
  168. },
  169. {
  170. .gpio = S3C2410_GPG(8),
  171. .code = KEY_DOWN,
  172. .desc = "Joystick Down",
  173. .active_low = 0,
  174. },
  175. {
  176. .gpio = S3C2410_GPG(6),
  177. .code = KEY_DOWN,
  178. .desc = "Joystick Left",
  179. .active_low = 0,
  180. },
  181. {
  182. .gpio = S3C2410_GPG(5),
  183. .code = KEY_DOWN,
  184. .desc = "Joystick Right",
  185. .active_low = 0,
  186. },
  187. {
  188. .gpio = S3C2410_GPG(7),
  189. .code = KEY_ENTER,
  190. .desc = "Joystick Press",
  191. .active_low = 0,
  192. },
  193. {
  194. .gpio = S3C2410_GPF(7),
  195. .code = KEY_HOMEPAGE,
  196. .desc = "Home",
  197. .active_low = 0,
  198. },
  199. {
  200. .gpio = S3C2410_GPF(6),
  201. .code = KEY_CALENDAR,
  202. .desc = "Calendar",
  203. .active_low = 0,
  204. },
  205. {
  206. .gpio = S3C2410_GPF(5),
  207. .code = KEY_ADDRESSBOOK,
  208. .desc = "Contacts",
  209. .active_low = 0,
  210. },
  211. {
  212. .gpio = S3C2410_GPF(4),
  213. .code = KEY_MAIL,
  214. .desc = "Mail",
  215. .active_low = 0,
  216. },
  217. {
  218. .gpio = S3C2410_GPF(3),
  219. .code = SW_RADIO,
  220. .desc = "GPS Antenna",
  221. .active_low = 0,
  222. },
  223. {
  224. .gpio = S3C2410_GPG(2),
  225. .code = SW_HEADPHONE_INSERT,
  226. .desc = "Headphone",
  227. .active_low = 0,
  228. },
  229. };
  230. static struct gpio_keys_platform_data n35_button_data = {
  231. .buttons = n35_buttons,
  232. .nbuttons = ARRAY_SIZE(n35_buttons),
  233. };
  234. static struct platform_device n35_button_device = {
  235. .name = "gpio-keys",
  236. .id = -1,
  237. .num_resources = 0,
  238. .dev = {
  239. .platform_data = &n35_button_data,
  240. }
  241. };
  242. /* This is the bluetooth LED on the device. */
  243. static struct s3c24xx_led_platdata n30_blue_led_pdata = {
  244. .name = "blue_led",
  245. .gpio = S3C2410_GPG(6),
  246. .def_trigger = "",
  247. };
  248. /* This LED is driven by the battery microcontroller, and is blinking
  249. * red, blinking green or solid green when the battery is low,
  250. * charging or full respectively. By driving GPD9 low, it's possible
  251. * to force the LED to blink red, so call that warning LED. */
  252. static struct s3c24xx_led_platdata n30_warning_led_pdata = {
  253. .name = "warning_led",
  254. .flags = S3C24XX_LEDF_ACTLOW,
  255. .gpio = S3C2410_GPD(9),
  256. .def_trigger = "",
  257. };
  258. static struct platform_device n30_blue_led = {
  259. .name = "s3c24xx_led",
  260. .id = 1,
  261. .dev = {
  262. .platform_data = &n30_blue_led_pdata,
  263. },
  264. };
  265. static struct platform_device n30_warning_led = {
  266. .name = "s3c24xx_led",
  267. .id = 2,
  268. .dev = {
  269. .platform_data = &n30_warning_led_pdata,
  270. },
  271. };
  272. static struct s3c2410fb_display n30_display __initdata = {
  273. .type = S3C2410_LCDCON1_TFT,
  274. .width = 240,
  275. .height = 320,
  276. .pixclock = 170000,
  277. .xres = 240,
  278. .yres = 320,
  279. .bpp = 16,
  280. .left_margin = 3,
  281. .right_margin = 40,
  282. .hsync_len = 40,
  283. .upper_margin = 2,
  284. .lower_margin = 3,
  285. .vsync_len = 2,
  286. .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
  287. };
  288. static struct s3c2410fb_mach_info n30_fb_info __initdata = {
  289. .displays = &n30_display,
  290. .num_displays = 1,
  291. .default_display = 0,
  292. .lpcsel = 0x06,
  293. };
  294. static struct platform_device *n30_devices[] __initdata = {
  295. &s3c_device_lcd,
  296. &s3c_device_wdt,
  297. &s3c_device_i2c0,
  298. &s3c_device_iis,
  299. &s3c_device_usb,
  300. &s3c_device_usbgadget,
  301. &n30_button_device,
  302. &n30_blue_led,
  303. &n30_warning_led,
  304. };
  305. static struct platform_device *n35_devices[] __initdata = {
  306. &s3c_device_lcd,
  307. &s3c_device_wdt,
  308. &s3c_device_i2c0,
  309. &s3c_device_iis,
  310. &s3c_device_usbgadget,
  311. &n35_button_device,
  312. };
  313. static struct s3c2410_platform_i2c n30_i2ccfg = {
  314. .flags = 0,
  315. .slave_addr = 0x10,
  316. .frequency = 10*1000,
  317. };
  318. /* Lots of hardcoded stuff, but it sets up the hardware in a useful
  319. * state so that we can boot Linux directly from flash. */
  320. static void __init n30_hwinit(void)
  321. {
  322. /* GPA0-11 special functions -- unknown what they do
  323. * GPA12 N30 special function -- unknown what it does
  324. * N35/PiN output -- unknown what it does
  325. *
  326. * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
  327. * don't think it does anything useful on the N30, so I ought
  328. * to make it an output there too since it always driven to 0
  329. * as far as I can tell. */
  330. if (machine_is_n30())
  331. __raw_writel(0x007fffff, S3C2410_GPACON);
  332. if (machine_is_n35())
  333. __raw_writel(0x007fefff, S3C2410_GPACON);
  334. __raw_writel(0x00000000, S3C2410_GPADAT);
  335. /* GPB0 TOUT0 backlight level
  336. * GPB1 output 1=backlight on
  337. * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
  338. * GPB3 output USB D+ pull up 0=disabled, 1=enabled
  339. * GPB4 N30 output -- unknown function
  340. * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
  341. * GPB5 output -- unknown function
  342. * GPB6 input -- unknown function
  343. * GPB7 output -- unknown function
  344. * GPB8 output -- probably LCD driver enable
  345. * GPB9 output -- probably LCD VSYNC driver enable
  346. * GPB10 output -- probably LCD HSYNC driver enable
  347. */
  348. __raw_writel(0x00154556, S3C2410_GPBCON);
  349. __raw_writel(0x00000750, S3C2410_GPBDAT);
  350. __raw_writel(0x00000073, S3C2410_GPBUP);
  351. /* GPC0 input RS232 DCD/DSR/RI
  352. * GPC1 LCD
  353. * GPC2 output RS232 DTR?
  354. * GPC3 input RS232 DCD/DSR/RI
  355. * GPC4 LCD
  356. * GPC5 output 0=NAND write enabled, 1=NAND write protect
  357. * GPC6 input -- unknown function
  358. * GPC7 input charger status 0=charger connected
  359. * this input can be triggered by power on the USB device
  360. * port too, but will go back to disconnected soon after.
  361. * GPC8 N30/N35 output -- unknown function, always driven to 1
  362. * PiN input -- unknown function, always read as 1
  363. * Make it an input with a pull up for all models.
  364. * GPC9-15 LCD
  365. */
  366. __raw_writel(0xaaa80618, S3C2410_GPCCON);
  367. __raw_writel(0x0000014c, S3C2410_GPCDAT);
  368. __raw_writel(0x0000fef2, S3C2410_GPCUP);
  369. /* GPD0 input -- unknown function
  370. * GPD1-D7 LCD
  371. * GPD8 N30 output -- unknown function
  372. * N35/PiN output 1=GPS LED on
  373. * GPD9 output 0=power led blinks red, 1=normal power led function
  374. * GPD10 output -- unknown function
  375. * GPD11-15 LCD drivers
  376. */
  377. __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
  378. __raw_writel(0x00000601, S3C2410_GPDDAT);
  379. __raw_writel(0x0000fbfe, S3C2410_GPDUP);
  380. /* GPE0-4 I2S audio bus
  381. * GPE5-10 SD/MMC bus
  382. * E11-13 outputs -- unknown function, probably power management
  383. * E14-15 I2C bus connected to the battery controller
  384. */
  385. __raw_writel(0xa56aaaaa, S3C2410_GPECON);
  386. __raw_writel(0x0000efc5, S3C2410_GPEDAT);
  387. __raw_writel(0x0000f81f, S3C2410_GPEUP);
  388. /* GPF0 input 0=power button pressed
  389. * GPF1 input SD/MMC switch 0=card present
  390. * GPF2 N30 1=reset button pressed (inverted compared to the rest)
  391. * N35/PiN 0=reset button pressed
  392. * GPF3 N30/PiN input -- unknown function
  393. * N35 input GPS antenna position, 0=antenna closed, 1=open
  394. * GPF4 input 0=button 4 pressed
  395. * GPF5 input 0=button 3 pressed
  396. * GPF6 input 0=button 2 pressed
  397. * GPF7 input 0=button 1 pressed
  398. */
  399. __raw_writel(0x0000aaaa, S3C2410_GPFCON);
  400. __raw_writel(0x00000000, S3C2410_GPFDAT);
  401. __raw_writel(0x000000ff, S3C2410_GPFUP);
  402. /* GPG0 input RS232 DCD/DSR/RI
  403. * GPG1 input 1=USB gadget port has power from a host
  404. * GPG2 N30 input -- unknown function
  405. * N35/PiN input 0=headphones plugged in, 1=not plugged in
  406. * GPG3 N30 output -- unknown function
  407. * N35/PiN input with unknown function
  408. * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
  409. * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
  410. * N35/PiN input joystick right
  411. * GPG6 N30 output 0=blue led on, 1=off
  412. * N35/PiN input joystick left
  413. * GPG7 input 0=thumbwheel pressed
  414. * GPG8 input 0=thumbwheel down
  415. * GPG9 input 0=thumbwheel up
  416. * GPG10 input SD/MMC write protect switch
  417. * GPG11 N30 input -- unknown function
  418. * N35 output 0=GPS antenna powered, 1=not powered
  419. * PiN output -- unknown function
  420. * GPG12-15 touch screen functions
  421. *
  422. * The pullups differ between the models, so enable all
  423. * pullups that are enabled on any of the models.
  424. */
  425. if (machine_is_n30())
  426. __raw_writel(0xff0a956a, S3C2410_GPGCON);
  427. if (machine_is_n35())
  428. __raw_writel(0xff4aa92a, S3C2410_GPGCON);
  429. __raw_writel(0x0000e800, S3C2410_GPGDAT);
  430. __raw_writel(0x0000f86f, S3C2410_GPGUP);
  431. /* GPH0/1/2/3 RS232 serial port
  432. * GPH4/5 IrDA serial port
  433. * GPH6/7 N30 BlueTooth serial port
  434. * N35/PiN GPS receiver
  435. * GPH8 input -- unknown function
  436. * GPH9 CLKOUT0 HCLK -- unknown use
  437. * GPH10 CLKOUT1 FCLK -- unknown use
  438. *
  439. * The pull ups for H6/H7 are enabled on N30 but not on the
  440. * N35/PiN. I suppose is useful for a budget model of the N30
  441. * with no bluetooh. It doesn't hurt to have the pull ups
  442. * enabled on the N35, so leave them enabled for all models.
  443. */
  444. __raw_writel(0x0028aaaa, S3C2410_GPHCON);
  445. __raw_writel(0x000005ef, S3C2410_GPHDAT);
  446. __raw_writel(0x0000063f, S3C2410_GPHUP);
  447. }
  448. static void __init n30_map_io(void)
  449. {
  450. s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
  451. n30_hwinit();
  452. s3c24xx_init_clocks(0);
  453. s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
  454. }
  455. static void __init n30_init_irq(void)
  456. {
  457. s3c24xx_init_irq();
  458. }
  459. /* GPB3 is the line that controls the pull-up for the USB D+ line */
  460. static void __init n30_init(void)
  461. {
  462. s3c24xx_fb_set_platdata(&n30_fb_info);
  463. s3c_device_i2c0.dev.platform_data = &n30_i2ccfg;
  464. s3c24xx_udc_set_platdata(&n30_udc_cfg);
  465. /* Turn off suspend on both USB ports, and switch the
  466. * selectable USB port to USB device mode. */
  467. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  468. S3C2410_MISCCR_USBSUSPND0 |
  469. S3C2410_MISCCR_USBSUSPND1, 0x0);
  470. if (machine_is_n30()) {
  471. /* Turn off suspend on both USB ports, and switch the
  472. * selectable USB port to USB device mode. */
  473. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  474. S3C2410_MISCCR_USBSUSPND0 |
  475. S3C2410_MISCCR_USBSUSPND1, 0x0);
  476. platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
  477. }
  478. if (machine_is_n35()) {
  479. /* Turn off suspend and switch the selectable USB port
  480. * to USB device mode. Turn on suspend for the host
  481. * port since it is not connected on the N35.
  482. *
  483. * Actually, the host port is available at some pads
  484. * on the back of the device, so it would actually be
  485. * possible to add a USB device inside the N35 if you
  486. * are willing to do some hardware modifications. */
  487. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  488. S3C2410_MISCCR_USBSUSPND0 |
  489. S3C2410_MISCCR_USBSUSPND1,
  490. S3C2410_MISCCR_USBSUSPND1);
  491. platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
  492. }
  493. }
  494. MACHINE_START(N30, "Acer-N30")
  495. /* Maintainer: Christer Weinigel <christer@weinigel.se>,
  496. Ben Dooks <ben-linux@fluff.org>
  497. */
  498. .phys_io = S3C2410_PA_UART,
  499. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  500. .boot_params = S3C2410_SDRAM_PA + 0x100,
  501. .timer = &s3c24xx_timer,
  502. .init_machine = n30_init,
  503. .init_irq = n30_init_irq,
  504. .map_io = n30_map_io,
  505. MACHINE_END
  506. MACHINE_START(N35, "Acer-N35")
  507. /* Maintainer: Christer Weinigel <christer@weinigel.se>
  508. */
  509. .phys_io = S3C2410_PA_UART,
  510. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  511. .boot_params = S3C2410_SDRAM_PA + 0x100,
  512. .timer = &s3c24xx_timer,
  513. .init_machine = n30_init,
  514. .init_irq = n30_init_irq,
  515. .map_io = n30_map_io,
  516. MACHINE_END