mach-n30.c 15 KB

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