mach-rx1950.c 19 KB

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