mach-h1940.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /* linux/arch/arm/mach-s3c2410/mach-h1940.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.handhelds.org/projects/h1940.html
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/memblock.h>
  18. #include <linux/timer.h>
  19. #include <linux/init.h>
  20. #include <linux/sysdev.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio.h>
  25. #include <linux/input.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/pwm_backlight.h>
  28. #include <linux/i2c.h>
  29. #include <linux/leds.h>
  30. #include <linux/pda_power.h>
  31. #include <linux/s3c_adc_battery.h>
  32. #include <linux/delay.h>
  33. #include <video/platform_lcd.h>
  34. #include <linux/mmc/host.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/irq.h>
  38. #include <mach/hardware.h>
  39. #include <asm/irq.h>
  40. #include <asm/mach-types.h>
  41. #include <plat/regs-serial.h>
  42. #include <mach/regs-lcd.h>
  43. #include <mach/regs-clock.h>
  44. #include <mach/regs-gpio.h>
  45. #include <mach/gpio-fns.h>
  46. #include <mach/gpio-nrs.h>
  47. #include <mach/h1940.h>
  48. #include <mach/h1940-latch.h>
  49. #include <mach/fb.h>
  50. #include <plat/udc.h>
  51. #include <plat/iic.h>
  52. #include <plat/gpio-cfg.h>
  53. #include <plat/clock.h>
  54. #include <plat/devs.h>
  55. #include <plat/cpu.h>
  56. #include <plat/pll.h>
  57. #include <plat/pm.h>
  58. #include <plat/mci.h>
  59. #include <plat/ts.h>
  60. #include <sound/uda1380.h>
  61. #define H1940_LATCH ((void __force __iomem *)0xF8000000)
  62. #define H1940_PA_LATCH S3C2410_CS2
  63. #define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END))
  64. static struct map_desc h1940_iodesc[] __initdata = {
  65. [0] = {
  66. .virtual = (unsigned long)H1940_LATCH,
  67. .pfn = __phys_to_pfn(H1940_PA_LATCH),
  68. .length = SZ_16K,
  69. .type = MT_DEVICE
  70. },
  71. };
  72. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  73. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  74. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  75. static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
  76. [0] = {
  77. .hwport = 0,
  78. .flags = 0,
  79. .ucon = 0x3c5,
  80. .ulcon = 0x03,
  81. .ufcon = 0x51,
  82. },
  83. [1] = {
  84. .hwport = 1,
  85. .flags = 0,
  86. .ucon = 0x245,
  87. .ulcon = 0x03,
  88. .ufcon = 0x00,
  89. },
  90. /* IR port */
  91. [2] = {
  92. .hwport = 2,
  93. .flags = 0,
  94. .uart_flags = UPF_CONS_FLOW,
  95. .ucon = 0x3c5,
  96. .ulcon = 0x43,
  97. .ufcon = 0x51,
  98. }
  99. };
  100. /* Board control latch control */
  101. static unsigned int latch_state;
  102. static void h1940_latch_control(unsigned int clear, unsigned int set)
  103. {
  104. unsigned long flags;
  105. local_irq_save(flags);
  106. latch_state &= ~clear;
  107. latch_state |= set;
  108. __raw_writel(latch_state, H1940_LATCH);
  109. local_irq_restore(flags);
  110. }
  111. static inline int h1940_gpiolib_to_latch(int offset)
  112. {
  113. return 1 << (offset + 16);
  114. }
  115. static void h1940_gpiolib_latch_set(struct gpio_chip *chip,
  116. unsigned offset, int value)
  117. {
  118. int latch_bit = h1940_gpiolib_to_latch(offset);
  119. h1940_latch_control(value ? 0 : latch_bit,
  120. value ? latch_bit : 0);
  121. }
  122. static int h1940_gpiolib_latch_output(struct gpio_chip *chip,
  123. unsigned offset, int value)
  124. {
  125. h1940_gpiolib_latch_set(chip, offset, value);
  126. return 0;
  127. }
  128. static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
  129. unsigned offset)
  130. {
  131. return (latch_state >> (offset + 16)) & 1;
  132. }
  133. struct gpio_chip h1940_latch_gpiochip = {
  134. .base = H1940_LATCH_GPIO(0),
  135. .owner = THIS_MODULE,
  136. .label = "H1940_LATCH",
  137. .ngpio = 16,
  138. .direction_output = h1940_gpiolib_latch_output,
  139. .set = h1940_gpiolib_latch_set,
  140. .get = h1940_gpiolib_latch_get,
  141. };
  142. static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
  143. .vbus_pin = S3C2410_GPG(5),
  144. .vbus_pin_inverted = 1,
  145. .pullup_pin = H1940_LATCH_USB_DP,
  146. };
  147. static struct s3c2410_ts_mach_info h1940_ts_cfg __initdata = {
  148. .delay = 10000,
  149. .presc = 49,
  150. .oversampling_shift = 2,
  151. .cfg_gpio = s3c24xx_ts_cfg_gpio,
  152. };
  153. /**
  154. * Set lcd on or off
  155. **/
  156. static struct s3c2410fb_display h1940_lcd __initdata = {
  157. .lcdcon5= S3C2410_LCDCON5_FRM565 | \
  158. S3C2410_LCDCON5_INVVLINE | \
  159. S3C2410_LCDCON5_HWSWP,
  160. .type = S3C2410_LCDCON1_TFT,
  161. .width = 240,
  162. .height = 320,
  163. .pixclock = 260000,
  164. .xres = 240,
  165. .yres = 320,
  166. .bpp = 16,
  167. .left_margin = 8,
  168. .right_margin = 20,
  169. .hsync_len = 4,
  170. .upper_margin = 8,
  171. .lower_margin = 7,
  172. .vsync_len = 1,
  173. };
  174. static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
  175. .displays = &h1940_lcd,
  176. .num_displays = 1,
  177. .default_display = 0,
  178. .lpcsel = 0x02,
  179. .gpccon = 0xaa940659,
  180. .gpccon_mask = 0xffffc0f0,
  181. .gpcup = 0x0000ffff,
  182. .gpcup_mask = 0xffffffff,
  183. .gpdcon = 0xaa84aaa0,
  184. .gpdcon_mask = 0xffffffff,
  185. .gpdup = 0x0000faff,
  186. .gpdup_mask = 0xffffffff,
  187. };
  188. static int power_supply_init(struct device *dev)
  189. {
  190. return gpio_request(S3C2410_GPF(2), "cable plugged");
  191. }
  192. static int h1940_is_ac_online(void)
  193. {
  194. return !gpio_get_value(S3C2410_GPF(2));
  195. }
  196. static void power_supply_exit(struct device *dev)
  197. {
  198. gpio_free(S3C2410_GPF(2));
  199. }
  200. static char *h1940_supplicants[] = {
  201. "main-battery",
  202. "backup-battery",
  203. };
  204. static struct pda_power_pdata power_supply_info = {
  205. .init = power_supply_init,
  206. .is_ac_online = h1940_is_ac_online,
  207. .exit = power_supply_exit,
  208. .supplied_to = h1940_supplicants,
  209. .num_supplicants = ARRAY_SIZE(h1940_supplicants),
  210. };
  211. static struct resource power_supply_resources[] = {
  212. [0] = {
  213. .name = "ac",
  214. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
  215. IORESOURCE_IRQ_HIGHEDGE,
  216. .start = IRQ_EINT2,
  217. .end = IRQ_EINT2,
  218. },
  219. };
  220. static struct platform_device power_supply = {
  221. .name = "pda-power",
  222. .id = -1,
  223. .dev = {
  224. .platform_data =
  225. &power_supply_info,
  226. },
  227. .resource = power_supply_resources,
  228. .num_resources = ARRAY_SIZE(power_supply_resources),
  229. };
  230. static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
  231. { .volt = 4070, .cur = 162, .level = 100},
  232. { .volt = 4040, .cur = 165, .level = 95},
  233. { .volt = 4016, .cur = 164, .level = 90},
  234. { .volt = 3996, .cur = 166, .level = 85},
  235. { .volt = 3971, .cur = 168, .level = 80},
  236. { .volt = 3951, .cur = 168, .level = 75},
  237. { .volt = 3931, .cur = 170, .level = 70},
  238. { .volt = 3903, .cur = 172, .level = 65},
  239. { .volt = 3886, .cur = 172, .level = 60},
  240. { .volt = 3858, .cur = 176, .level = 55},
  241. { .volt = 3842, .cur = 176, .level = 50},
  242. { .volt = 3818, .cur = 176, .level = 45},
  243. { .volt = 3789, .cur = 180, .level = 40},
  244. { .volt = 3769, .cur = 180, .level = 35},
  245. { .volt = 3749, .cur = 184, .level = 30},
  246. { .volt = 3732, .cur = 184, .level = 25},
  247. { .volt = 3716, .cur = 184, .level = 20},
  248. { .volt = 3708, .cur = 184, .level = 15},
  249. { .volt = 3716, .cur = 96, .level = 10},
  250. { .volt = 3700, .cur = 96, .level = 5},
  251. { .volt = 3684, .cur = 96, .level = 0},
  252. };
  253. static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
  254. { .volt = 4130, .cur = 0, .level = 100},
  255. { .volt = 3982, .cur = 0, .level = 50},
  256. { .volt = 3854, .cur = 0, .level = 10},
  257. { .volt = 3841, .cur = 0, .level = 0},
  258. };
  259. int h1940_bat_init(void)
  260. {
  261. int ret;
  262. ret = gpio_request(H1940_LATCH_SM803_ENABLE, "h1940-charger-enable");
  263. if (ret)
  264. return ret;
  265. gpio_direction_output(H1940_LATCH_SM803_ENABLE, 0);
  266. return 0;
  267. }
  268. void h1940_bat_exit(void)
  269. {
  270. gpio_free(H1940_LATCH_SM803_ENABLE);
  271. }
  272. void h1940_enable_charger(void)
  273. {
  274. gpio_set_value(H1940_LATCH_SM803_ENABLE, 1);
  275. }
  276. void h1940_disable_charger(void)
  277. {
  278. gpio_set_value(H1940_LATCH_SM803_ENABLE, 0);
  279. }
  280. static struct s3c_adc_bat_pdata h1940_bat_cfg = {
  281. .init = h1940_bat_init,
  282. .exit = h1940_bat_exit,
  283. .enable_charger = h1940_enable_charger,
  284. .disable_charger = h1940_disable_charger,
  285. .gpio_charge_finished = S3C2410_GPF(3),
  286. .gpio_inverted = 1,
  287. .lut_noac = bat_lut_noac,
  288. .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
  289. .lut_acin = bat_lut_acin,
  290. .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
  291. .volt_channel = 0,
  292. .current_channel = 1,
  293. .volt_mult = 4056,
  294. .current_mult = 1893,
  295. .internal_impedance = 200,
  296. .backup_volt_channel = 3,
  297. /* TODO Check backup volt multiplier */
  298. .backup_volt_mult = 4056,
  299. .backup_volt_min = 0,
  300. .backup_volt_max = 4149288
  301. };
  302. static struct platform_device h1940_battery = {
  303. .name = "s3c-adc-battery",
  304. .id = -1,
  305. .dev = {
  306. .parent = &s3c_device_adc.dev,
  307. .platform_data = &h1940_bat_cfg,
  308. },
  309. };
  310. DEFINE_SPINLOCK(h1940_blink_spin);
  311. int h1940_led_blink_set(unsigned gpio, int state,
  312. unsigned long *delay_on, unsigned long *delay_off)
  313. {
  314. int blink_gpio, check_gpio1, check_gpio2;
  315. switch (gpio) {
  316. case H1940_LATCH_LED_GREEN:
  317. blink_gpio = S3C2410_GPA(7);
  318. check_gpio1 = S3C2410_GPA(1);
  319. check_gpio2 = S3C2410_GPA(3);
  320. break;
  321. case H1940_LATCH_LED_RED:
  322. blink_gpio = S3C2410_GPA(1);
  323. check_gpio1 = S3C2410_GPA(7);
  324. check_gpio2 = S3C2410_GPA(3);
  325. break;
  326. default:
  327. blink_gpio = S3C2410_GPA(3);
  328. check_gpio1 = S3C2410_GPA(1);
  329. check_gpio1 = S3C2410_GPA(7);
  330. break;
  331. }
  332. if (delay_on && delay_off && !*delay_on && !*delay_off)
  333. *delay_on = *delay_off = 500;
  334. spin_lock(&h1940_blink_spin);
  335. switch (state) {
  336. case GPIO_LED_NO_BLINK_LOW:
  337. case GPIO_LED_NO_BLINK_HIGH:
  338. if (!gpio_get_value(check_gpio1) &&
  339. !gpio_get_value(check_gpio2))
  340. gpio_set_value(H1940_LATCH_LED_FLASH, 0);
  341. gpio_set_value(blink_gpio, 0);
  342. if (gpio_is_valid(gpio))
  343. gpio_set_value(gpio, state);
  344. break;
  345. case GPIO_LED_BLINK:
  346. if (gpio_is_valid(gpio))
  347. gpio_set_value(gpio, 0);
  348. gpio_set_value(H1940_LATCH_LED_FLASH, 1);
  349. gpio_set_value(blink_gpio, 1);
  350. break;
  351. }
  352. spin_unlock(&h1940_blink_spin);
  353. return 0;
  354. }
  355. EXPORT_SYMBOL(h1940_led_blink_set);
  356. static struct gpio_led h1940_leds_desc[] = {
  357. {
  358. .name = "Green",
  359. .default_trigger = "main-battery-charging-or-full",
  360. .gpio = H1940_LATCH_LED_GREEN,
  361. .retain_state_suspended = 1,
  362. },
  363. {
  364. .name = "Red",
  365. .default_trigger = "main-battery-full",
  366. .gpio = H1940_LATCH_LED_RED,
  367. .retain_state_suspended = 1,
  368. },
  369. };
  370. static struct gpio_led_platform_data h1940_leds_pdata = {
  371. .num_leds = ARRAY_SIZE(h1940_leds_desc),
  372. .leds = h1940_leds_desc,
  373. .gpio_blink_set = h1940_led_blink_set,
  374. };
  375. static struct platform_device h1940_device_leds = {
  376. .name = "leds-gpio",
  377. .id = -1,
  378. .dev = {
  379. .platform_data = &h1940_leds_pdata,
  380. },
  381. };
  382. static struct platform_device h1940_device_bluetooth = {
  383. .name = "h1940-bt",
  384. .id = -1,
  385. };
  386. static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
  387. {
  388. switch (power_mode) {
  389. case MMC_POWER_OFF:
  390. gpio_set_value(H1940_LATCH_SD_POWER, 0);
  391. break;
  392. case MMC_POWER_UP:
  393. case MMC_POWER_ON:
  394. gpio_set_value(H1940_LATCH_SD_POWER, 1);
  395. break;
  396. default:
  397. break;
  398. };
  399. }
  400. static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
  401. .gpio_detect = S3C2410_GPF(5),
  402. .gpio_wprotect = S3C2410_GPH(8),
  403. .set_power = h1940_set_mmc_power,
  404. .ocr_avail = MMC_VDD_32_33,
  405. };
  406. static int h1940_backlight_init(struct device *dev)
  407. {
  408. gpio_request(S3C2410_GPB(0), "Backlight");
  409. gpio_direction_output(S3C2410_GPB(0), 0);
  410. s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
  411. s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
  412. gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
  413. return 0;
  414. }
  415. static int h1940_backlight_notify(struct device *dev, int brightness)
  416. {
  417. if (!brightness) {
  418. gpio_direction_output(S3C2410_GPB(0), 1);
  419. gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
  420. } else {
  421. gpio_direction_output(S3C2410_GPB(0), 0);
  422. s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
  423. s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
  424. gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
  425. }
  426. return brightness;
  427. }
  428. static void h1940_backlight_exit(struct device *dev)
  429. {
  430. gpio_direction_output(S3C2410_GPB(0), 1);
  431. gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
  432. }
  433. static struct platform_pwm_backlight_data backlight_data = {
  434. .pwm_id = 0,
  435. .max_brightness = 100,
  436. .dft_brightness = 50,
  437. /* tcnt = 0x31 */
  438. .pwm_period_ns = 36296,
  439. .init = h1940_backlight_init,
  440. .notify = h1940_backlight_notify,
  441. .exit = h1940_backlight_exit,
  442. };
  443. static struct platform_device h1940_backlight = {
  444. .name = "pwm-backlight",
  445. .dev = {
  446. .parent = &s3c_device_timer[0].dev,
  447. .platform_data = &backlight_data,
  448. },
  449. .id = -1,
  450. };
  451. static void h1940_lcd_power_set(struct plat_lcd_data *pd,
  452. unsigned int power)
  453. {
  454. int value, retries = 100;
  455. if (!power) {
  456. gpio_set_value(S3C2410_GPC(0), 0);
  457. /* wait for 3ac */
  458. do {
  459. value = gpio_get_value(S3C2410_GPC(6));
  460. } while (value && retries--);
  461. gpio_set_value(H1940_LATCH_LCD_P2, 0);
  462. gpio_set_value(H1940_LATCH_LCD_P3, 0);
  463. gpio_set_value(H1940_LATCH_LCD_P4, 0);
  464. gpio_direction_output(S3C2410_GPC(1), 0);
  465. gpio_direction_output(S3C2410_GPC(4), 0);
  466. gpio_set_value(H1940_LATCH_LCD_P1, 0);
  467. gpio_set_value(H1940_LATCH_LCD_P0, 0);
  468. gpio_set_value(S3C2410_GPC(5), 0);
  469. } else {
  470. gpio_set_value(H1940_LATCH_LCD_P0, 1);
  471. gpio_set_value(H1940_LATCH_LCD_P1, 1);
  472. gpio_direction_input(S3C2410_GPC(1));
  473. gpio_direction_input(S3C2410_GPC(4));
  474. mdelay(10);
  475. s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
  476. s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));
  477. gpio_set_value(S3C2410_GPC(5), 1);
  478. gpio_set_value(S3C2410_GPC(0), 1);
  479. gpio_set_value(H1940_LATCH_LCD_P3, 1);
  480. gpio_set_value(H1940_LATCH_LCD_P2, 1);
  481. gpio_set_value(H1940_LATCH_LCD_P4, 1);
  482. }
  483. }
  484. static struct plat_lcd_data h1940_lcd_power_data = {
  485. .set_power = h1940_lcd_power_set,
  486. };
  487. static struct platform_device h1940_lcd_powerdev = {
  488. .name = "platform-lcd",
  489. .dev.parent = &s3c_device_lcd.dev,
  490. .dev.platform_data = &h1940_lcd_power_data,
  491. };
  492. static struct uda1380_platform_data uda1380_info = {
  493. .gpio_power = H1940_LATCH_UDA_POWER,
  494. .gpio_reset = S3C2410_GPA(12),
  495. .dac_clk = UDA1380_DAC_CLK_SYSCLK,
  496. };
  497. static struct i2c_board_info h1940_i2c_devices[] = {
  498. {
  499. I2C_BOARD_INFO("uda1380", 0x1a),
  500. .platform_data = &uda1380_info,
  501. },
  502. };
  503. #define DECLARE_BUTTON(p, k, n, w) \
  504. { \
  505. .gpio = p, \
  506. .code = k, \
  507. .desc = n, \
  508. .wakeup = w, \
  509. .active_low = 1, \
  510. }
  511. static struct gpio_keys_button h1940_buttons[] = {
  512. DECLARE_BUTTON(S3C2410_GPF(0), KEY_POWER, "Power", 1),
  513. DECLARE_BUTTON(S3C2410_GPF(6), KEY_ENTER, "Select", 1),
  514. DECLARE_BUTTON(S3C2410_GPF(7), KEY_RECORD, "Record", 0),
  515. DECLARE_BUTTON(S3C2410_GPG(0), KEY_F11, "Calendar", 0),
  516. DECLARE_BUTTON(S3C2410_GPG(2), KEY_F12, "Contacts", 0),
  517. DECLARE_BUTTON(S3C2410_GPG(3), KEY_MAIL, "Mail", 0),
  518. DECLARE_BUTTON(S3C2410_GPG(6), KEY_LEFT, "Left_arrow", 0),
  519. DECLARE_BUTTON(S3C2410_GPG(7), KEY_HOMEPAGE, "Home", 0),
  520. DECLARE_BUTTON(S3C2410_GPG(8), KEY_RIGHT, "Right_arrow", 0),
  521. DECLARE_BUTTON(S3C2410_GPG(9), KEY_UP, "Up_arrow", 0),
  522. DECLARE_BUTTON(S3C2410_GPG(10), KEY_DOWN, "Down_arrow", 0),
  523. };
  524. static struct gpio_keys_platform_data h1940_buttons_data = {
  525. .buttons = h1940_buttons,
  526. .nbuttons = ARRAY_SIZE(h1940_buttons),
  527. };
  528. static struct platform_device h1940_dev_buttons = {
  529. .name = "gpio-keys",
  530. .id = -1,
  531. .dev = {
  532. .platform_data = &h1940_buttons_data,
  533. }
  534. };
  535. static struct platform_device *h1940_devices[] __initdata = {
  536. &h1940_dev_buttons,
  537. &s3c_device_ohci,
  538. &s3c_device_lcd,
  539. &s3c_device_wdt,
  540. &s3c_device_i2c0,
  541. &s3c_device_iis,
  542. &samsung_asoc_dma,
  543. &s3c_device_usbgadget,
  544. &h1940_device_leds,
  545. &h1940_device_bluetooth,
  546. &s3c_device_sdi,
  547. &s3c_device_rtc,
  548. &s3c_device_timer[0],
  549. &h1940_backlight,
  550. &h1940_lcd_powerdev,
  551. &s3c_device_adc,
  552. &s3c_device_ts,
  553. &power_supply,
  554. &h1940_battery,
  555. };
  556. static void __init h1940_map_io(void)
  557. {
  558. s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
  559. s3c24xx_init_clocks(0);
  560. s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
  561. /* setup PM */
  562. #ifdef CONFIG_PM_H1940
  563. memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
  564. #endif
  565. s3c_pm_init();
  566. /* Add latch gpio chip, set latch initial value */
  567. h1940_latch_control(0, 0);
  568. WARN_ON(gpiochip_add(&h1940_latch_gpiochip));
  569. }
  570. /* H1940 and RX3715 need to reserve this for suspend */
  571. static void __init h1940_reserve(void)
  572. {
  573. memblock_reserve(0x30003000, 0x1000);
  574. memblock_reserve(0x30081000, 0x1000);
  575. }
  576. static void __init h1940_init_irq(void)
  577. {
  578. s3c24xx_init_irq();
  579. }
  580. static void __init h1940_init(void)
  581. {
  582. u32 tmp;
  583. s3c24xx_fb_set_platdata(&h1940_fb_info);
  584. s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
  585. s3c24xx_udc_set_platdata(&h1940_udc_cfg);
  586. s3c24xx_ts_set_platdata(&h1940_ts_cfg);
  587. s3c_i2c0_set_platdata(NULL);
  588. /* Turn off suspend on both USB ports, and switch the
  589. * selectable USB port to USB device mode. */
  590. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  591. S3C2410_MISCCR_USBSUSPND0 |
  592. S3C2410_MISCCR_USBSUSPND1, 0x0);
  593. tmp = (0x78 << S3C24XX_PLLCON_MDIVSHIFT)
  594. | (0x02 << S3C24XX_PLLCON_PDIVSHIFT)
  595. | (0x03 << S3C24XX_PLLCON_SDIVSHIFT);
  596. writel(tmp, S3C2410_UPLLCON);
  597. gpio_request(S3C2410_GPC(0), "LCD power");
  598. gpio_request(S3C2410_GPC(1), "LCD power");
  599. gpio_request(S3C2410_GPC(4), "LCD power");
  600. gpio_request(S3C2410_GPC(5), "LCD power");
  601. gpio_request(S3C2410_GPC(6), "LCD power");
  602. gpio_request(H1940_LATCH_LCD_P0, "LCD power");
  603. gpio_request(H1940_LATCH_LCD_P1, "LCD power");
  604. gpio_request(H1940_LATCH_LCD_P2, "LCD power");
  605. gpio_request(H1940_LATCH_LCD_P3, "LCD power");
  606. gpio_request(H1940_LATCH_LCD_P4, "LCD power");
  607. gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
  608. gpio_direction_output(S3C2410_GPC(0), 0);
  609. gpio_direction_output(S3C2410_GPC(1), 0);
  610. gpio_direction_output(S3C2410_GPC(4), 0);
  611. gpio_direction_output(S3C2410_GPC(5), 0);
  612. gpio_direction_input(S3C2410_GPC(6));
  613. gpio_direction_output(H1940_LATCH_LCD_P0, 0);
  614. gpio_direction_output(H1940_LATCH_LCD_P1, 0);
  615. gpio_direction_output(H1940_LATCH_LCD_P2, 0);
  616. gpio_direction_output(H1940_LATCH_LCD_P3, 0);
  617. gpio_direction_output(H1940_LATCH_LCD_P4, 0);
  618. gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
  619. gpio_request(H1940_LATCH_SD_POWER, "SD power");
  620. gpio_direction_output(H1940_LATCH_SD_POWER, 0);
  621. platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
  622. gpio_request(S3C2410_GPA(1), "Red LED blink");
  623. gpio_request(S3C2410_GPA(3), "Blue LED blink");
  624. gpio_request(S3C2410_GPA(7), "Green LED blink");
  625. gpio_request(H1940_LATCH_LED_FLASH, "LED blink");
  626. gpio_direction_output(S3C2410_GPA(1), 0);
  627. gpio_direction_output(S3C2410_GPA(3), 0);
  628. gpio_direction_output(S3C2410_GPA(7), 0);
  629. gpio_direction_output(H1940_LATCH_LED_FLASH, 0);
  630. i2c_register_board_info(0, h1940_i2c_devices,
  631. ARRAY_SIZE(h1940_i2c_devices));
  632. }
  633. MACHINE_START(H1940, "IPAQ-H1940")
  634. /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
  635. .boot_params = S3C2410_SDRAM_PA + 0x100,
  636. .map_io = h1940_map_io,
  637. .reserve = h1940_reserve,
  638. .init_irq = h1940_init_irq,
  639. .init_machine = h1940_init,
  640. .timer = &s3c24xx_timer,
  641. MACHINE_END