mach-n30.c 14 KB

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