mach-n30.c 15 KB

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