mach-h1940.c 19 KB

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