mach-rx1950.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. /*
  2. * Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
  3. * Copyright (c) 2007-2010 Vasily Khoruzhick
  4. *
  5. * based on smdk2440 written by Ben Dooks
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/memblock.h>
  17. #include <linux/delay.h>
  18. #include <linux/timer.h>
  19. #include <linux/init.h>
  20. #include <linux/gpio.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/input.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/device.h>
  26. #include <linux/pda_power.h>
  27. #include <linux/pwm_backlight.h>
  28. #include <linux/pwm.h>
  29. #include <linux/s3c_adc_battery.h>
  30. #include <linux/leds.h>
  31. #include <linux/i2c.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/mmc/host.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <linux/platform_data/i2c-s3c2410.h>
  39. #include <linux/platform_data/mmc-s3cmci.h>
  40. #include <linux/platform_data/mtd-nand-s3c2410.h>
  41. #include <linux/platform_data/touchscreen-s3c2410.h>
  42. #include <linux/platform_data/usb-s3c2410_udc.h>
  43. #include <sound/uda1380.h>
  44. #include <mach/fb.h>
  45. #include <mach/regs-gpio.h>
  46. #include <mach/regs-lcd.h>
  47. #include <plat/clock.h>
  48. #include <plat/cpu.h>
  49. #include <plat/devs.h>
  50. #include <plat/pm.h>
  51. #include <plat/regs-iic.h>
  52. #include <plat/regs-serial.h>
  53. #include "common.h"
  54. #include "h1940.h"
  55. #define LCD_PWM_PERIOD 192960
  56. #define LCD_PWM_DUTY 127353
  57. static struct map_desc rx1950_iodesc[] __initdata = {
  58. };
  59. static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
  60. [0] = {
  61. .hwport = 0,
  62. .flags = 0,
  63. .ucon = 0x3c5,
  64. .ulcon = 0x03,
  65. .ufcon = 0x51,
  66. .clk_sel = S3C2410_UCON_CLKSEL3,
  67. },
  68. [1] = {
  69. .hwport = 1,
  70. .flags = 0,
  71. .ucon = 0x3c5,
  72. .ulcon = 0x03,
  73. .ufcon = 0x51,
  74. .clk_sel = S3C2410_UCON_CLKSEL3,
  75. },
  76. /* IR port */
  77. [2] = {
  78. .hwport = 2,
  79. .flags = 0,
  80. .ucon = 0x3c5,
  81. .ulcon = 0x43,
  82. .ufcon = 0xf1,
  83. .clk_sel = S3C2410_UCON_CLKSEL3,
  84. },
  85. };
  86. static struct s3c2410fb_display rx1950_display = {
  87. .type = S3C2410_LCDCON1_TFT,
  88. .width = 240,
  89. .height = 320,
  90. .xres = 240,
  91. .yres = 320,
  92. .bpp = 16,
  93. .pixclock = 260000,
  94. .left_margin = 10,
  95. .right_margin = 20,
  96. .hsync_len = 10,
  97. .upper_margin = 2,
  98. .lower_margin = 2,
  99. .vsync_len = 2,
  100. .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  101. S3C2410_LCDCON5_INVVCLK |
  102. S3C2410_LCDCON5_INVVLINE |
  103. S3C2410_LCDCON5_INVVFRAME |
  104. S3C2410_LCDCON5_HWSWP |
  105. (0x02 << 13) |
  106. (0x02 << 15),
  107. };
  108. static int power_supply_init(struct device *dev)
  109. {
  110. return gpio_request(S3C2410_GPF(2), "cable plugged");
  111. }
  112. static int rx1950_is_ac_online(void)
  113. {
  114. return !gpio_get_value(S3C2410_GPF(2));
  115. }
  116. static void power_supply_exit(struct device *dev)
  117. {
  118. gpio_free(S3C2410_GPF(2));
  119. }
  120. static char *rx1950_supplicants[] = {
  121. "main-battery"
  122. };
  123. static struct pda_power_pdata power_supply_info = {
  124. .init = power_supply_init,
  125. .is_ac_online = rx1950_is_ac_online,
  126. .exit = power_supply_exit,
  127. .supplied_to = rx1950_supplicants,
  128. .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
  129. };
  130. static struct resource power_supply_resources[] = {
  131. [0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
  132. | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
  133. };
  134. static struct platform_device power_supply = {
  135. .name = "pda-power",
  136. .id = -1,
  137. .dev = {
  138. .platform_data =
  139. &power_supply_info,
  140. },
  141. .resource = power_supply_resources,
  142. .num_resources = ARRAY_SIZE(power_supply_resources),
  143. };
  144. static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
  145. { .volt = 4100, .cur = 156, .level = 100},
  146. { .volt = 4050, .cur = 156, .level = 95},
  147. { .volt = 4025, .cur = 141, .level = 90},
  148. { .volt = 3995, .cur = 144, .level = 85},
  149. { .volt = 3957, .cur = 162, .level = 80},
  150. { .volt = 3931, .cur = 147, .level = 75},
  151. { .volt = 3902, .cur = 147, .level = 70},
  152. { .volt = 3863, .cur = 153, .level = 65},
  153. { .volt = 3838, .cur = 150, .level = 60},
  154. { .volt = 3800, .cur = 153, .level = 55},
  155. { .volt = 3765, .cur = 153, .level = 50},
  156. { .volt = 3748, .cur = 172, .level = 45},
  157. { .volt = 3740, .cur = 153, .level = 40},
  158. { .volt = 3714, .cur = 175, .level = 35},
  159. { .volt = 3710, .cur = 156, .level = 30},
  160. { .volt = 3963, .cur = 156, .level = 25},
  161. { .volt = 3672, .cur = 178, .level = 20},
  162. { .volt = 3651, .cur = 178, .level = 15},
  163. { .volt = 3629, .cur = 178, .level = 10},
  164. { .volt = 3612, .cur = 162, .level = 5},
  165. { .volt = 3605, .cur = 162, .level = 0},
  166. };
  167. static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
  168. { .volt = 4200, .cur = 0, .level = 100},
  169. { .volt = 4190, .cur = 0, .level = 99},
  170. { .volt = 4178, .cur = 0, .level = 95},
  171. { .volt = 4110, .cur = 0, .level = 70},
  172. { .volt = 4076, .cur = 0, .level = 65},
  173. { .volt = 4046, .cur = 0, .level = 60},
  174. { .volt = 4021, .cur = 0, .level = 55},
  175. { .volt = 3999, .cur = 0, .level = 50},
  176. { .volt = 3982, .cur = 0, .level = 45},
  177. { .volt = 3965, .cur = 0, .level = 40},
  178. { .volt = 3957, .cur = 0, .level = 35},
  179. { .volt = 3948, .cur = 0, .level = 30},
  180. { .volt = 3936, .cur = 0, .level = 25},
  181. { .volt = 3927, .cur = 0, .level = 20},
  182. { .volt = 3906, .cur = 0, .level = 15},
  183. { .volt = 3880, .cur = 0, .level = 10},
  184. { .volt = 3829, .cur = 0, .level = 5},
  185. { .volt = 3820, .cur = 0, .level = 0},
  186. };
  187. static int rx1950_bat_init(void)
  188. {
  189. int ret;
  190. ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
  191. if (ret)
  192. goto err_gpio1;
  193. ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
  194. if (ret)
  195. goto err_gpio2;
  196. return 0;
  197. err_gpio2:
  198. gpio_free(S3C2410_GPJ(2));
  199. err_gpio1:
  200. return ret;
  201. }
  202. static void rx1950_bat_exit(void)
  203. {
  204. gpio_free(S3C2410_GPJ(2));
  205. gpio_free(S3C2410_GPJ(3));
  206. }
  207. static void rx1950_enable_charger(void)
  208. {
  209. gpio_direction_output(S3C2410_GPJ(2), 1);
  210. gpio_direction_output(S3C2410_GPJ(3), 1);
  211. }
  212. static void rx1950_disable_charger(void)
  213. {
  214. gpio_direction_output(S3C2410_GPJ(2), 0);
  215. gpio_direction_output(S3C2410_GPJ(3), 0);
  216. }
  217. static DEFINE_SPINLOCK(rx1950_blink_spin);
  218. static int rx1950_led_blink_set(unsigned gpio, int state,
  219. unsigned long *delay_on, unsigned long *delay_off)
  220. {
  221. int blink_gpio, check_gpio;
  222. switch (gpio) {
  223. case S3C2410_GPA(6):
  224. blink_gpio = S3C2410_GPA(4);
  225. check_gpio = S3C2410_GPA(3);
  226. break;
  227. case S3C2410_GPA(7):
  228. blink_gpio = S3C2410_GPA(3);
  229. check_gpio = S3C2410_GPA(4);
  230. break;
  231. default:
  232. return -EINVAL;
  233. break;
  234. }
  235. if (delay_on && delay_off && !*delay_on && !*delay_off)
  236. *delay_on = *delay_off = 500;
  237. spin_lock(&rx1950_blink_spin);
  238. switch (state) {
  239. case GPIO_LED_NO_BLINK_LOW:
  240. case GPIO_LED_NO_BLINK_HIGH:
  241. if (!gpio_get_value(check_gpio))
  242. gpio_set_value(S3C2410_GPJ(6), 0);
  243. gpio_set_value(blink_gpio, 0);
  244. gpio_set_value(gpio, state);
  245. break;
  246. case GPIO_LED_BLINK:
  247. gpio_set_value(gpio, 0);
  248. gpio_set_value(S3C2410_GPJ(6), 1);
  249. gpio_set_value(blink_gpio, 1);
  250. break;
  251. }
  252. spin_unlock(&rx1950_blink_spin);
  253. return 0;
  254. }
  255. static struct gpio_led rx1950_leds_desc[] = {
  256. {
  257. .name = "Green",
  258. .default_trigger = "main-battery-full",
  259. .gpio = S3C2410_GPA(6),
  260. .retain_state_suspended = 1,
  261. },
  262. {
  263. .name = "Red",
  264. .default_trigger
  265. = "main-battery-charging-blink-full-solid",
  266. .gpio = S3C2410_GPA(7),
  267. .retain_state_suspended = 1,
  268. },
  269. {
  270. .name = "Blue",
  271. .default_trigger = "rx1950-acx-mem",
  272. .gpio = S3C2410_GPA(11),
  273. .retain_state_suspended = 1,
  274. },
  275. };
  276. static struct gpio_led_platform_data rx1950_leds_pdata = {
  277. .num_leds = ARRAY_SIZE(rx1950_leds_desc),
  278. .leds = rx1950_leds_desc,
  279. .gpio_blink_set = rx1950_led_blink_set,
  280. };
  281. static struct platform_device rx1950_leds = {
  282. .name = "leds-gpio",
  283. .id = -1,
  284. .dev = {
  285. .platform_data = &rx1950_leds_pdata,
  286. },
  287. };
  288. static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
  289. .init = rx1950_bat_init,
  290. .exit = rx1950_bat_exit,
  291. .enable_charger = rx1950_enable_charger,
  292. .disable_charger = rx1950_disable_charger,
  293. .gpio_charge_finished = S3C2410_GPF(3),
  294. .lut_noac = bat_lut_noac,
  295. .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
  296. .lut_acin = bat_lut_acin,
  297. .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
  298. .volt_channel = 0,
  299. .current_channel = 1,
  300. .volt_mult = 4235,
  301. .current_mult = 2900,
  302. .internal_impedance = 200,
  303. };
  304. static struct platform_device rx1950_battery = {
  305. .name = "s3c-adc-battery",
  306. .id = -1,
  307. .dev = {
  308. .parent = &s3c_device_adc.dev,
  309. .platform_data = &rx1950_bat_cfg,
  310. },
  311. };
  312. static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
  313. .displays = &rx1950_display,
  314. .num_displays = 1,
  315. .default_display = 0,
  316. .lpcsel = 0x02,
  317. .gpccon = 0xaa9556a9,
  318. .gpccon_mask = 0xffc003fc,
  319. .gpcup = 0x0000ffff,
  320. .gpcup_mask = 0xffffffff,
  321. .gpdcon = 0xaa90aaa1,
  322. .gpdcon_mask = 0xffc0fff0,
  323. .gpdup = 0x0000fcfd,
  324. .gpdup_mask = 0xffffffff,
  325. };
  326. static struct pwm_device *lcd_pwm;
  327. static void rx1950_lcd_power(int enable)
  328. {
  329. int i;
  330. static int enabled;
  331. if (enabled == enable)
  332. return;
  333. if (!enable) {
  334. /* GPC11-GPC15->OUTPUT */
  335. for (i = 11; i < 16; i++)
  336. gpio_direction_output(S3C2410_GPC(i), 1);
  337. /* Wait a bit here... */
  338. mdelay(100);
  339. /* GPD2-GPD7->OUTPUT */
  340. /* GPD11-GPD15->OUTPUT */
  341. /* GPD2-GPD7->1, GPD11-GPD15->1 */
  342. for (i = 2; i < 8; i++)
  343. gpio_direction_output(S3C2410_GPD(i), 1);
  344. for (i = 11; i < 16; i++)
  345. gpio_direction_output(S3C2410_GPD(i), 1);
  346. /* Wait a bit here...*/
  347. mdelay(100);
  348. /* GPB0->OUTPUT, GPB0->0 */
  349. gpio_direction_output(S3C2410_GPB(0), 0);
  350. /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
  351. for (i = 1; i < 5; i++)
  352. gpio_direction_output(S3C2410_GPC(i), 0);
  353. /* GPC15-GPC11->0 */
  354. for (i = 11; i < 16; i++)
  355. gpio_direction_output(S3C2410_GPC(i), 0);
  356. /* GPD15-GPD11->0, GPD2->GPD7->0 */
  357. for (i = 11; i < 16; i++)
  358. gpio_direction_output(S3C2410_GPD(i), 0);
  359. for (i = 2; i < 8; i++)
  360. gpio_direction_output(S3C2410_GPD(i), 0);
  361. /* GPC6->0, GPC7->0, GPC5->0 */
  362. gpio_direction_output(S3C2410_GPC(6), 0);
  363. gpio_direction_output(S3C2410_GPC(7), 0);
  364. gpio_direction_output(S3C2410_GPC(5), 0);
  365. /* GPB1->OUTPUT, GPB1->0 */
  366. gpio_direction_output(S3C2410_GPB(1), 0);
  367. pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
  368. pwm_disable(lcd_pwm);
  369. /* GPC0->0, GPC10->0 */
  370. gpio_direction_output(S3C2410_GPC(0), 0);
  371. gpio_direction_output(S3C2410_GPC(10), 0);
  372. } else {
  373. pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
  374. pwm_enable(lcd_pwm);
  375. gpio_direction_output(S3C2410_GPC(0), 1);
  376. gpio_direction_output(S3C2410_GPC(5), 1);
  377. s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
  378. gpio_direction_output(S3C2410_GPC(7), 1);
  379. for (i = 1; i < 5; i++)
  380. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  381. for (i = 11; i < 16; i++)
  382. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  383. for (i = 2; i < 8; i++)
  384. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  385. for (i = 11; i < 16; i++)
  386. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  387. gpio_direction_output(S3C2410_GPC(10), 1);
  388. gpio_direction_output(S3C2410_GPC(6), 1);
  389. }
  390. enabled = enable;
  391. }
  392. static void rx1950_bl_power(int enable)
  393. {
  394. static int enabled;
  395. if (enabled == enable)
  396. return;
  397. if (!enable) {
  398. gpio_direction_output(S3C2410_GPB(0), 0);
  399. } else {
  400. /* LED driver need a "push" to power on */
  401. gpio_direction_output(S3C2410_GPB(0), 1);
  402. /* Warm up backlight for one period of PWM.
  403. * Without this trick its almost impossible to
  404. * enable backlight with low brightness value
  405. */
  406. ndelay(48000);
  407. s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
  408. }
  409. enabled = enable;
  410. }
  411. static int rx1950_backlight_init(struct device *dev)
  412. {
  413. WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
  414. lcd_pwm = pwm_request(1, "RX1950 LCD");
  415. if (IS_ERR(lcd_pwm)) {
  416. dev_err(dev, "Unable to request PWM for LCD power!\n");
  417. return PTR_ERR(lcd_pwm);
  418. }
  419. rx1950_lcd_power(1);
  420. rx1950_bl_power(1);
  421. return 0;
  422. }
  423. static void rx1950_backlight_exit(struct device *dev)
  424. {
  425. rx1950_bl_power(0);
  426. rx1950_lcd_power(0);
  427. pwm_free(lcd_pwm);
  428. gpio_free(S3C2410_GPB(0));
  429. }
  430. static int rx1950_backlight_notify(struct device *dev, int brightness)
  431. {
  432. if (!brightness) {
  433. rx1950_bl_power(0);
  434. rx1950_lcd_power(0);
  435. } else {
  436. rx1950_lcd_power(1);
  437. rx1950_bl_power(1);
  438. }
  439. return brightness;
  440. }
  441. static struct platform_pwm_backlight_data rx1950_backlight_data = {
  442. .pwm_id = 0,
  443. .max_brightness = 24,
  444. .dft_brightness = 4,
  445. .pwm_period_ns = 48000,
  446. .init = rx1950_backlight_init,
  447. .notify = rx1950_backlight_notify,
  448. .exit = rx1950_backlight_exit,
  449. };
  450. static struct platform_device rx1950_backlight = {
  451. .name = "pwm-backlight",
  452. .dev = {
  453. .parent = &s3c_device_timer[0].dev,
  454. .platform_data = &rx1950_backlight_data,
  455. },
  456. };
  457. static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
  458. {
  459. switch (power_mode) {
  460. case MMC_POWER_OFF:
  461. gpio_direction_output(S3C2410_GPJ(1), 0);
  462. break;
  463. case MMC_POWER_UP:
  464. case MMC_POWER_ON:
  465. gpio_direction_output(S3C2410_GPJ(1), 1);
  466. break;
  467. default:
  468. break;
  469. }
  470. }
  471. static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
  472. .gpio_detect = S3C2410_GPF(5),
  473. .gpio_wprotect = S3C2410_GPH(8),
  474. .set_power = rx1950_set_mmc_power,
  475. .ocr_avail = MMC_VDD_32_33,
  476. };
  477. static struct mtd_partition rx1950_nand_part[] = {
  478. [0] = {
  479. .name = "Boot0",
  480. .offset = 0,
  481. .size = 0x4000,
  482. .mask_flags = MTD_WRITEABLE,
  483. },
  484. [1] = {
  485. .name = "Boot1",
  486. .offset = MTDPART_OFS_APPEND,
  487. .size = 0x40000,
  488. .mask_flags = MTD_WRITEABLE,
  489. },
  490. [2] = {
  491. .name = "Kernel",
  492. .offset = MTDPART_OFS_APPEND,
  493. .size = 0x300000,
  494. .mask_flags = 0,
  495. },
  496. [3] = {
  497. .name = "Filesystem",
  498. .offset = MTDPART_OFS_APPEND,
  499. .size = MTDPART_SIZ_FULL,
  500. .mask_flags = 0,
  501. },
  502. };
  503. static struct s3c2410_nand_set rx1950_nand_sets[] = {
  504. [0] = {
  505. .name = "Internal",
  506. .nr_chips = 1,
  507. .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
  508. .partitions = rx1950_nand_part,
  509. },
  510. };
  511. static struct s3c2410_platform_nand rx1950_nand_info = {
  512. .tacls = 25,
  513. .twrph0 = 50,
  514. .twrph1 = 15,
  515. .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
  516. .sets = rx1950_nand_sets,
  517. };
  518. static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
  519. .vbus_pin = S3C2410_GPG(5),
  520. .vbus_pin_inverted = 1,
  521. .pullup_pin = S3C2410_GPJ(5),
  522. };
  523. static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
  524. .delay = 10000,
  525. .presc = 49,
  526. .oversampling_shift = 3,
  527. };
  528. static struct gpio_keys_button rx1950_gpio_keys_table[] = {
  529. {
  530. .code = KEY_POWER,
  531. .gpio = S3C2410_GPF(0),
  532. .active_low = 1,
  533. .desc = "Power button",
  534. .wakeup = 1,
  535. },
  536. {
  537. .code = KEY_F5,
  538. .gpio = S3C2410_GPF(7),
  539. .active_low = 1,
  540. .desc = "Record button",
  541. },
  542. {
  543. .code = KEY_F1,
  544. .gpio = S3C2410_GPG(0),
  545. .active_low = 1,
  546. .desc = "Calendar button",
  547. },
  548. {
  549. .code = KEY_F2,
  550. .gpio = S3C2410_GPG(2),
  551. .active_low = 1,
  552. .desc = "Contacts button",
  553. },
  554. {
  555. .code = KEY_F3,
  556. .gpio = S3C2410_GPG(3),
  557. .active_low = 1,
  558. .desc = "Mail button",
  559. },
  560. {
  561. .code = KEY_F4,
  562. .gpio = S3C2410_GPG(7),
  563. .active_low = 1,
  564. .desc = "WLAN button",
  565. },
  566. {
  567. .code = KEY_LEFT,
  568. .gpio = S3C2410_GPG(10),
  569. .active_low = 1,
  570. .desc = "Left button",
  571. },
  572. {
  573. .code = KEY_RIGHT,
  574. .gpio = S3C2410_GPG(11),
  575. .active_low = 1,
  576. .desc = "Right button",
  577. },
  578. {
  579. .code = KEY_UP,
  580. .gpio = S3C2410_GPG(4),
  581. .active_low = 1,
  582. .desc = "Up button",
  583. },
  584. {
  585. .code = KEY_DOWN,
  586. .gpio = S3C2410_GPG(6),
  587. .active_low = 1,
  588. .desc = "Down button",
  589. },
  590. {
  591. .code = KEY_ENTER,
  592. .gpio = S3C2410_GPG(9),
  593. .active_low = 1,
  594. .desc = "Ok button"
  595. },
  596. };
  597. static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
  598. .buttons = rx1950_gpio_keys_table,
  599. .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
  600. };
  601. static struct platform_device rx1950_device_gpiokeys = {
  602. .name = "gpio-keys",
  603. .dev.platform_data = &rx1950_gpio_keys_data,
  604. };
  605. static struct uda1380_platform_data uda1380_info = {
  606. .gpio_power = S3C2410_GPJ(0),
  607. .gpio_reset = S3C2410_GPD(0),
  608. .dac_clk = UDA1380_DAC_CLK_SYSCLK,
  609. };
  610. static struct i2c_board_info rx1950_i2c_devices[] = {
  611. {
  612. I2C_BOARD_INFO("uda1380", 0x1a),
  613. .platform_data = &uda1380_info,
  614. },
  615. };
  616. static struct platform_device *rx1950_devices[] __initdata = {
  617. &s3c_device_lcd,
  618. &s3c_device_wdt,
  619. &s3c_device_i2c0,
  620. &s3c_device_iis,
  621. &s3c_device_usbgadget,
  622. &s3c_device_rtc,
  623. &s3c_device_nand,
  624. &s3c_device_sdi,
  625. &s3c_device_adc,
  626. &s3c_device_ts,
  627. &s3c_device_timer[0],
  628. &s3c_device_timer[1],
  629. &rx1950_backlight,
  630. &rx1950_device_gpiokeys,
  631. &power_supply,
  632. &rx1950_battery,
  633. &rx1950_leds,
  634. };
  635. static struct clk *rx1950_clocks[] __initdata = {
  636. &s3c24xx_clkout0,
  637. &s3c24xx_clkout1,
  638. };
  639. static void __init rx1950_map_io(void)
  640. {
  641. s3c24xx_clkout0.parent = &clk_h;
  642. s3c24xx_clkout1.parent = &clk_f;
  643. s3c24xx_register_clocks(rx1950_clocks, ARRAY_SIZE(rx1950_clocks));
  644. s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
  645. s3c24xx_init_clocks(16934000);
  646. s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
  647. /* setup PM */
  648. #ifdef CONFIG_PM_H1940
  649. memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
  650. #endif
  651. s3c_pm_init();
  652. }
  653. static void __init rx1950_init_machine(void)
  654. {
  655. int i;
  656. s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
  657. s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
  658. s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
  659. s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
  660. s3c_i2c0_set_platdata(NULL);
  661. s3c_nand_set_platdata(&rx1950_nand_info);
  662. /* Turn off suspend on both USB ports, and switch the
  663. * selectable USB port to USB device mode. */
  664. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  665. S3C2410_MISCCR_USBSUSPND0 |
  666. S3C2410_MISCCR_USBSUSPND1, 0x0);
  667. /* mmc power is disabled by default */
  668. WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
  669. gpio_direction_output(S3C2410_GPJ(1), 0);
  670. for (i = 0; i < 8; i++)
  671. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  672. for (i = 10; i < 16; i++)
  673. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  674. for (i = 2; i < 8; i++)
  675. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  676. for (i = 11; i < 16; i++)
  677. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  678. WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
  679. WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
  680. WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
  681. WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
  682. gpio_direction_output(S3C2410_GPA(3), 0);
  683. gpio_direction_output(S3C2410_GPA(4), 0);
  684. gpio_direction_output(S3C2410_GPJ(6), 0);
  685. platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
  686. i2c_register_board_info(0, rx1950_i2c_devices,
  687. ARRAY_SIZE(rx1950_i2c_devices));
  688. }
  689. /* H1940 and RX3715 need to reserve this for suspend */
  690. static void __init rx1950_reserve(void)
  691. {
  692. memblock_reserve(0x30003000, 0x1000);
  693. memblock_reserve(0x30081000, 0x1000);
  694. }
  695. MACHINE_START(RX1950, "HP iPAQ RX1950")
  696. /* Maintainers: Vasily Khoruzhick */
  697. .atag_offset = 0x100,
  698. .map_io = rx1950_map_io,
  699. .reserve = rx1950_reserve,
  700. .init_irq = s3c24xx_init_irq,
  701. .init_machine = rx1950_init_machine,
  702. .init_time = s3c24xx_timer_init,
  703. .restart = s3c244x_restart,
  704. MACHINE_END