mach-n30.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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/delay.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/init.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 <asm/plat-s3c/iic.h>
  38. #include <asm/plat-s3c/regs-serial.h>
  39. #include <asm/plat-s3c24xx/clock.h>
  40. #include <asm/plat-s3c24xx/cpu.h>
  41. #include <asm/plat-s3c24xx/devs.h>
  42. #include <asm/plat-s3c24xx/s3c2410.h>
  43. #include <asm/plat-s3c24xx/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_GPB3, 1);
  80. break;
  81. case S3C2410_UDC_P_DISABLE :
  82. s3c2410_gpio_setpin(S3C2410_GPB3, 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_GPG1,
  93. .vbus_pin_inverted = 0,
  94. };
  95. static struct gpio_keys_button n30_buttons[] = {
  96. {
  97. .gpio = S3C2410_GPF0,
  98. .code = KEY_POWER,
  99. .desc = "Power",
  100. .active_low = 0,
  101. },
  102. {
  103. .gpio = S3C2410_GPG9,
  104. .code = KEY_UP,
  105. .desc = "Thumbwheel Up",
  106. .active_low = 0,
  107. },
  108. {
  109. .gpio = S3C2410_GPG8,
  110. .code = KEY_DOWN,
  111. .desc = "Thumbwheel Down",
  112. .active_low = 0,
  113. },
  114. {
  115. .gpio = S3C2410_GPG7,
  116. .code = KEY_ENTER,
  117. .desc = "Thumbwheel Press",
  118. .active_low = 0,
  119. },
  120. {
  121. .gpio = S3C2410_GPF7,
  122. .code = KEY_HOMEPAGE,
  123. .desc = "Home",
  124. .active_low = 0,
  125. },
  126. {
  127. .gpio = S3C2410_GPF6,
  128. .code = KEY_CALENDAR,
  129. .desc = "Calendar",
  130. .active_low = 0,
  131. },
  132. {
  133. .gpio = S3C2410_GPF5,
  134. .code = KEY_ADDRESSBOOK,
  135. .desc = "Contacts",
  136. .active_low = 0,
  137. },
  138. {
  139. .gpio = S3C2410_GPF4,
  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_GPF0,
  159. .code = KEY_POWER,
  160. .desc = "Power",
  161. .active_low = 0,
  162. },
  163. {
  164. .gpio = S3C2410_GPG9,
  165. .code = KEY_UP,
  166. .desc = "Joystick Up",
  167. .active_low = 0,
  168. },
  169. {
  170. .gpio = S3C2410_GPG8,
  171. .code = KEY_DOWN,
  172. .desc = "Joystick Down",
  173. .active_low = 0,
  174. },
  175. {
  176. .gpio = S3C2410_GPG6,
  177. .code = KEY_DOWN,
  178. .desc = "Joystick Left",
  179. .active_low = 0,
  180. },
  181. {
  182. .gpio = S3C2410_GPG5,
  183. .code = KEY_DOWN,
  184. .desc = "Joystick Right",
  185. .active_low = 0,
  186. },
  187. {
  188. .gpio = S3C2410_GPG7,
  189. .code = KEY_ENTER,
  190. .desc = "Joystick Press",
  191. .active_low = 0,
  192. },
  193. {
  194. .gpio = S3C2410_GPF7,
  195. .code = KEY_HOMEPAGE,
  196. .desc = "Home",
  197. .active_low = 0,
  198. },
  199. {
  200. .gpio = S3C2410_GPF6,
  201. .code = KEY_CALENDAR,
  202. .desc = "Calendar",
  203. .active_low = 0,
  204. },
  205. {
  206. .gpio = S3C2410_GPF5,
  207. .code = KEY_ADDRESSBOOK,
  208. .desc = "Contacts",
  209. .active_low = 0,
  210. },
  211. {
  212. .gpio = S3C2410_GPF4,
  213. .code = KEY_MAIL,
  214. .desc = "Mail",
  215. .active_low = 0,
  216. },
  217. {
  218. .gpio = S3C2410_GPF3,
  219. .code = SW_RADIO,
  220. .desc = "GPS Antenna",
  221. .active_low = 0,
  222. },
  223. {
  224. .gpio = S3C2410_GPG2,
  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_GPG6,
  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_GPD9,
  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_i2c,
  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_i2c,
  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. .bus_freq = 10*1000,
  317. .max_freq = 10*1000,
  318. };
  319. /* Lots of hardcoded stuff, but it sets up the hardware in a useful
  320. * state so that we can boot Linux directly from flash. */
  321. static void __init n30_hwinit(void)
  322. {
  323. /* GPA0-11 special functions -- unknown what they do
  324. * GPA12 N30 special function -- unknown what it does
  325. * N35/PiN output -- unknown what it does
  326. *
  327. * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
  328. * don't think it does anything useful on the N30, so I ought
  329. * to make it an output there too since it always driven to 0
  330. * as far as I can tell. */
  331. if (machine_is_n30())
  332. __raw_writel(0x007fffff, S3C2410_GPACON);
  333. if (machine_is_n35())
  334. __raw_writel(0x007fefff, S3C2410_GPACON);
  335. __raw_writel(0x00000000, S3C2410_GPADAT);
  336. /* GPB0 TOUT0 backlight level
  337. * GPB1 output 1=backlight on
  338. * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
  339. * GPB3 output USB D+ pull up 0=disabled, 1=enabled
  340. * GPB4 N30 output -- unknown function
  341. * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
  342. * GPB5 output -- unknown function
  343. * GPB6 input -- unknown function
  344. * GPB7 output -- unknown function
  345. * GPB8 output -- probably LCD driver enable
  346. * GPB9 output -- probably LCD VSYNC driver enable
  347. * GPB10 output -- probably LCD HSYNC driver enable
  348. */
  349. __raw_writel(0x00154556, S3C2410_GPBCON);
  350. __raw_writel(0x00000750, S3C2410_GPBDAT);
  351. __raw_writel(0x00000073, S3C2410_GPBUP);
  352. /* GPC0 input RS232 DCD/DSR/RI
  353. * GPC1 LCD
  354. * GPC2 output RS232 DTR?
  355. * GPC3 input RS232 DCD/DSR/RI
  356. * GPC4 LCD
  357. * GPC5 output 0=NAND write enabled, 1=NAND write protect
  358. * GPC6 input -- unknown function
  359. * GPC7 input charger status 0=charger connected
  360. * this input can be triggered by power on the USB device
  361. * port too, but will go back to disconnected soon after.
  362. * GPC8 N30/N35 output -- unknown function, always driven to 1
  363. * PiN input -- unknown function, always read as 1
  364. * Make it an input with a pull up for all models.
  365. * GPC9-15 LCD
  366. */
  367. __raw_writel(0xaaa80618, S3C2410_GPCCON);
  368. __raw_writel(0x0000014c, S3C2410_GPCDAT);
  369. __raw_writel(0x0000fef2, S3C2410_GPCUP);
  370. /* GPD0 input -- unknown function
  371. * GPD1-D7 LCD
  372. * GPD8 N30 output -- unknown function
  373. * N35/PiN output 1=GPS LED on
  374. * GPD9 output 0=power led blinks red, 1=normal power led function
  375. * GPD10 output -- unknown function
  376. * GPD11-15 LCD drivers
  377. */
  378. __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
  379. __raw_writel(0x00000601, S3C2410_GPDDAT);
  380. __raw_writel(0x0000fbfe, S3C2410_GPDUP);
  381. /* GPE0-4 I2S audio bus
  382. * GPE5-10 SD/MMC bus
  383. * E11-13 outputs -- unknown function, probably power management
  384. * E14-15 I2C bus connected to the battery controller
  385. */
  386. __raw_writel(0xa56aaaaa, S3C2410_GPECON);
  387. __raw_writel(0x0000efc5, S3C2410_GPEDAT);
  388. __raw_writel(0x0000f81f, S3C2410_GPEUP);
  389. /* GPF0 input 0=power button pressed
  390. * GPF1 input SD/MMC switch 0=card present
  391. * GPF2 N30 1=reset button pressed (inverted compared to the rest)
  392. * N35/PiN 0=reset button pressed
  393. * GPF3 N30/PiN input -- unknown function
  394. * N35 input GPS antenna position, 0=antenna closed, 1=open
  395. * GPF4 input 0=button 4 pressed
  396. * GPF5 input 0=button 3 pressed
  397. * GPF6 input 0=button 2 pressed
  398. * GPF7 input 0=button 1 pressed
  399. */
  400. __raw_writel(0x0000aaaa, S3C2410_GPFCON);
  401. __raw_writel(0x00000000, S3C2410_GPFDAT);
  402. __raw_writel(0x000000ff, S3C2410_GPFUP);
  403. /* GPG0 input RS232 DCD/DSR/RI
  404. * GPG1 input 1=USB gadget port has power from a host
  405. * GPG2 N30 input -- unknown function
  406. * N35/PiN input 0=headphones plugged in, 1=not plugged in
  407. * GPG3 N30 output -- unknown function
  408. * N35/PiN input with unknown function
  409. * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
  410. * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
  411. * N35/PiN input joystick right
  412. * GPG6 N30 output 0=blue led on, 1=off
  413. * N35/PiN input joystick left
  414. * GPG7 input 0=thumbwheel pressed
  415. * GPG8 input 0=thumbwheel down
  416. * GPG9 input 0=thumbwheel up
  417. * GPG10 input SD/MMC write protect switch
  418. * GPG11 N30 input -- unknown function
  419. * N35 output 0=GPS antenna powered, 1=not powered
  420. * PiN output -- unknown function
  421. * GPG12-15 touch screen functions
  422. *
  423. * The pullups differ between the models, so enable all
  424. * pullups that are enabled on any of the models.
  425. */
  426. if (machine_is_n30())
  427. __raw_writel(0xff0a956a, S3C2410_GPGCON);
  428. if (machine_is_n35())
  429. __raw_writel(0xff4aa92a, S3C2410_GPGCON);
  430. __raw_writel(0x0000e800, S3C2410_GPGDAT);
  431. __raw_writel(0x0000f86f, S3C2410_GPGUP);
  432. /* GPH0/1/2/3 RS232 serial port
  433. * GPH4/5 IrDA serial port
  434. * GPH6/7 N30 BlueTooth serial port
  435. * N35/PiN GPS receiver
  436. * GPH8 input -- unknown function
  437. * GPH9 CLKOUT0 HCLK -- unknown use
  438. * GPH10 CLKOUT1 FCLK -- unknown use
  439. *
  440. * The pull ups for H6/H7 are enabled on N30 but not on the
  441. * N35/PiN. I suppose is useful for a budget model of the N30
  442. * with no bluetooh. It doesn't hurt to have the pull ups
  443. * enabled on the N35, so leave them enabled for all models.
  444. */
  445. __raw_writel(0x0028aaaa, S3C2410_GPHCON);
  446. __raw_writel(0x000005ef, S3C2410_GPHDAT);
  447. __raw_writel(0x0000063f, S3C2410_GPHUP);
  448. }
  449. static void __init n30_map_io(void)
  450. {
  451. s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
  452. n30_hwinit();
  453. s3c24xx_init_clocks(0);
  454. s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
  455. }
  456. static void __init n30_init_irq(void)
  457. {
  458. s3c24xx_init_irq();
  459. }
  460. /* GPB3 is the line that controls the pull-up for the USB D+ line */
  461. static void __init n30_init(void)
  462. {
  463. s3c24xx_fb_set_platdata(&n30_fb_info);
  464. s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
  465. s3c24xx_udc_set_platdata(&n30_udc_cfg);
  466. /* Turn off suspend on both USB ports, and switch the
  467. * selectable USB port to USB device mode. */
  468. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  469. S3C2410_MISCCR_USBSUSPND0 |
  470. S3C2410_MISCCR_USBSUSPND1, 0x0);
  471. if (machine_is_n30()) {
  472. /* Turn off suspend on both USB ports, and switch the
  473. * selectable USB port to USB device mode. */
  474. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  475. S3C2410_MISCCR_USBSUSPND0 |
  476. S3C2410_MISCCR_USBSUSPND1, 0x0);
  477. platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
  478. }
  479. if (machine_is_n35()) {
  480. /* Turn off suspend and switch the selectable USB port
  481. * to USB device mode. Turn on suspend for the host
  482. * port since it is not connected on the N35.
  483. *
  484. * Actually, the host port is available at some pads
  485. * on the back of the device, so it would actually be
  486. * possible to add a USB device inside the N35 if you
  487. * are willing to do some hardware modifications. */
  488. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  489. S3C2410_MISCCR_USBSUSPND0 |
  490. S3C2410_MISCCR_USBSUSPND1,
  491. S3C2410_MISCCR_USBSUSPND1);
  492. platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
  493. }
  494. }
  495. MACHINE_START(N30, "Acer-N30")
  496. /* Maintainer: Christer Weinigel <christer@weinigel.se>,
  497. Ben Dooks <ben-linux@fluff.org>
  498. */
  499. .phys_io = S3C2410_PA_UART,
  500. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  501. .boot_params = S3C2410_SDRAM_PA + 0x100,
  502. .timer = &s3c24xx_timer,
  503. .init_machine = n30_init,
  504. .init_irq = n30_init_irq,
  505. .map_io = n30_map_io,
  506. MACHINE_END
  507. MACHINE_START(N35, "Acer-N35")
  508. /* Maintainer: Christer Weinigel <christer@weinigel.se>
  509. */
  510. .phys_io = S3C2410_PA_UART,
  511. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  512. .boot_params = S3C2410_SDRAM_PA + 0x100,
  513. .timer = &s3c24xx_timer,
  514. .init_machine = n30_init,
  515. .init_irq = n30_init_irq,
  516. .map_io = n30_map_io,
  517. MACHINE_END