mach-n30.c 15 KB

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