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