mach-rx1950.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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/serial_s3c.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-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. #include <linux/platform_data/i2c-s3c2410.h>
  40. #include <linux/platform_data/mmc-s3cmci.h>
  41. #include <linux/platform_data/mtd-nand-s3c2410.h>
  42. #include <linux/platform_data/touchscreen-s3c2410.h>
  43. #include <linux/platform_data/usb-s3c2410_udc.h>
  44. #include <sound/uda1380.h>
  45. #include <mach/fb.h>
  46. #include <mach/regs-gpio.h>
  47. #include <mach/regs-lcd.h>
  48. #include <mach/gpio-samsung.h>
  49. #include <plat/cpu.h>
  50. #include <plat/devs.h>
  51. #include <plat/pm.h>
  52. #include <plat/samsung-time.h>
  53. #include <plat/gpio-cfg.h>
  54. #include "common.h"
  55. #include "h1940.h"
  56. #define LCD_PWM_PERIOD 192960
  57. #define LCD_PWM_DUTY 127353
  58. static struct map_desc rx1950_iodesc[] __initdata = {
  59. };
  60. static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
  61. [0] = {
  62. .hwport = 0,
  63. .flags = 0,
  64. .ucon = 0x3c5,
  65. .ulcon = 0x03,
  66. .ufcon = 0x51,
  67. .clk_sel = S3C2410_UCON_CLKSEL3,
  68. },
  69. [1] = {
  70. .hwport = 1,
  71. .flags = 0,
  72. .ucon = 0x3c5,
  73. .ulcon = 0x03,
  74. .ufcon = 0x51,
  75. .clk_sel = S3C2410_UCON_CLKSEL3,
  76. },
  77. /* IR port */
  78. [2] = {
  79. .hwport = 2,
  80. .flags = 0,
  81. .ucon = 0x3c5,
  82. .ulcon = 0x43,
  83. .ufcon = 0xf1,
  84. .clk_sel = S3C2410_UCON_CLKSEL3,
  85. },
  86. };
  87. static struct s3c2410fb_display rx1950_display = {
  88. .type = S3C2410_LCDCON1_TFT,
  89. .width = 240,
  90. .height = 320,
  91. .xres = 240,
  92. .yres = 320,
  93. .bpp = 16,
  94. .pixclock = 260000,
  95. .left_margin = 10,
  96. .right_margin = 20,
  97. .hsync_len = 10,
  98. .upper_margin = 2,
  99. .lower_margin = 2,
  100. .vsync_len = 2,
  101. .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  102. S3C2410_LCDCON5_INVVCLK |
  103. S3C2410_LCDCON5_INVVLINE |
  104. S3C2410_LCDCON5_INVVFRAME |
  105. S3C2410_LCDCON5_HWSWP |
  106. (0x02 << 13) |
  107. (0x02 << 15),
  108. };
  109. static int power_supply_init(struct device *dev)
  110. {
  111. return gpio_request(S3C2410_GPF(2), "cable plugged");
  112. }
  113. static int rx1950_is_ac_online(void)
  114. {
  115. return !gpio_get_value(S3C2410_GPF(2));
  116. }
  117. static void power_supply_exit(struct device *dev)
  118. {
  119. gpio_free(S3C2410_GPF(2));
  120. }
  121. static char *rx1950_supplicants[] = {
  122. "main-battery"
  123. };
  124. static struct pda_power_pdata power_supply_info = {
  125. .init = power_supply_init,
  126. .is_ac_online = rx1950_is_ac_online,
  127. .exit = power_supply_exit,
  128. .supplied_to = rx1950_supplicants,
  129. .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
  130. };
  131. static struct resource power_supply_resources[] = {
  132. [0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
  133. | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
  134. };
  135. static struct platform_device power_supply = {
  136. .name = "pda-power",
  137. .id = -1,
  138. .dev = {
  139. .platform_data =
  140. &power_supply_info,
  141. },
  142. .resource = power_supply_resources,
  143. .num_resources = ARRAY_SIZE(power_supply_resources),
  144. };
  145. static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
  146. { .volt = 4100, .cur = 156, .level = 100},
  147. { .volt = 4050, .cur = 156, .level = 95},
  148. { .volt = 4025, .cur = 141, .level = 90},
  149. { .volt = 3995, .cur = 144, .level = 85},
  150. { .volt = 3957, .cur = 162, .level = 80},
  151. { .volt = 3931, .cur = 147, .level = 75},
  152. { .volt = 3902, .cur = 147, .level = 70},
  153. { .volt = 3863, .cur = 153, .level = 65},
  154. { .volt = 3838, .cur = 150, .level = 60},
  155. { .volt = 3800, .cur = 153, .level = 55},
  156. { .volt = 3765, .cur = 153, .level = 50},
  157. { .volt = 3748, .cur = 172, .level = 45},
  158. { .volt = 3740, .cur = 153, .level = 40},
  159. { .volt = 3714, .cur = 175, .level = 35},
  160. { .volt = 3710, .cur = 156, .level = 30},
  161. { .volt = 3963, .cur = 156, .level = 25},
  162. { .volt = 3672, .cur = 178, .level = 20},
  163. { .volt = 3651, .cur = 178, .level = 15},
  164. { .volt = 3629, .cur = 178, .level = 10},
  165. { .volt = 3612, .cur = 162, .level = 5},
  166. { .volt = 3605, .cur = 162, .level = 0},
  167. };
  168. static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
  169. { .volt = 4200, .cur = 0, .level = 100},
  170. { .volt = 4190, .cur = 0, .level = 99},
  171. { .volt = 4178, .cur = 0, .level = 95},
  172. { .volt = 4110, .cur = 0, .level = 70},
  173. { .volt = 4076, .cur = 0, .level = 65},
  174. { .volt = 4046, .cur = 0, .level = 60},
  175. { .volt = 4021, .cur = 0, .level = 55},
  176. { .volt = 3999, .cur = 0, .level = 50},
  177. { .volt = 3982, .cur = 0, .level = 45},
  178. { .volt = 3965, .cur = 0, .level = 40},
  179. { .volt = 3957, .cur = 0, .level = 35},
  180. { .volt = 3948, .cur = 0, .level = 30},
  181. { .volt = 3936, .cur = 0, .level = 25},
  182. { .volt = 3927, .cur = 0, .level = 20},
  183. { .volt = 3906, .cur = 0, .level = 15},
  184. { .volt = 3880, .cur = 0, .level = 10},
  185. { .volt = 3829, .cur = 0, .level = 5},
  186. { .volt = 3820, .cur = 0, .level = 0},
  187. };
  188. static int rx1950_bat_init(void)
  189. {
  190. int ret;
  191. ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
  192. if (ret)
  193. goto err_gpio1;
  194. ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
  195. if (ret)
  196. goto err_gpio2;
  197. return 0;
  198. err_gpio2:
  199. gpio_free(S3C2410_GPJ(2));
  200. err_gpio1:
  201. return ret;
  202. }
  203. static void rx1950_bat_exit(void)
  204. {
  205. gpio_free(S3C2410_GPJ(2));
  206. gpio_free(S3C2410_GPJ(3));
  207. }
  208. static void rx1950_enable_charger(void)
  209. {
  210. gpio_direction_output(S3C2410_GPJ(2), 1);
  211. gpio_direction_output(S3C2410_GPJ(3), 1);
  212. }
  213. static void rx1950_disable_charger(void)
  214. {
  215. gpio_direction_output(S3C2410_GPJ(2), 0);
  216. gpio_direction_output(S3C2410_GPJ(3), 0);
  217. }
  218. static DEFINE_SPINLOCK(rx1950_blink_spin);
  219. static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
  220. unsigned long *delay_on, unsigned long *delay_off)
  221. {
  222. int gpio = desc_to_gpio(desc);
  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_lookup rx1950_pwm_lookup[] = {
  329. PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
  330. PWM_POLARITY_NORMAL),
  331. };
  332. static struct pwm_device *lcd_pwm;
  333. static void rx1950_lcd_power(int enable)
  334. {
  335. int i;
  336. static int enabled;
  337. if (enabled == enable)
  338. return;
  339. if (!enable) {
  340. /* GPC11-GPC15->OUTPUT */
  341. for (i = 11; i < 16; i++)
  342. gpio_direction_output(S3C2410_GPC(i), 1);
  343. /* Wait a bit here... */
  344. mdelay(100);
  345. /* GPD2-GPD7->OUTPUT */
  346. /* GPD11-GPD15->OUTPUT */
  347. /* GPD2-GPD7->1, GPD11-GPD15->1 */
  348. for (i = 2; i < 8; i++)
  349. gpio_direction_output(S3C2410_GPD(i), 1);
  350. for (i = 11; i < 16; i++)
  351. gpio_direction_output(S3C2410_GPD(i), 1);
  352. /* Wait a bit here...*/
  353. mdelay(100);
  354. /* GPB0->OUTPUT, GPB0->0 */
  355. gpio_direction_output(S3C2410_GPB(0), 0);
  356. /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
  357. for (i = 1; i < 5; i++)
  358. gpio_direction_output(S3C2410_GPC(i), 0);
  359. /* GPC15-GPC11->0 */
  360. for (i = 11; i < 16; i++)
  361. gpio_direction_output(S3C2410_GPC(i), 0);
  362. /* GPD15-GPD11->0, GPD2->GPD7->0 */
  363. for (i = 11; i < 16; i++)
  364. gpio_direction_output(S3C2410_GPD(i), 0);
  365. for (i = 2; i < 8; i++)
  366. gpio_direction_output(S3C2410_GPD(i), 0);
  367. /* GPC6->0, GPC7->0, GPC5->0 */
  368. gpio_direction_output(S3C2410_GPC(6), 0);
  369. gpio_direction_output(S3C2410_GPC(7), 0);
  370. gpio_direction_output(S3C2410_GPC(5), 0);
  371. /* GPB1->OUTPUT, GPB1->0 */
  372. gpio_direction_output(S3C2410_GPB(1), 0);
  373. pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
  374. pwm_disable(lcd_pwm);
  375. /* GPC0->0, GPC10->0 */
  376. gpio_direction_output(S3C2410_GPC(0), 0);
  377. gpio_direction_output(S3C2410_GPC(10), 0);
  378. } else {
  379. pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
  380. pwm_enable(lcd_pwm);
  381. gpio_direction_output(S3C2410_GPC(0), 1);
  382. gpio_direction_output(S3C2410_GPC(5), 1);
  383. s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
  384. gpio_direction_output(S3C2410_GPC(7), 1);
  385. for (i = 1; i < 5; i++)
  386. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  387. for (i = 11; i < 16; i++)
  388. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  389. for (i = 2; i < 8; i++)
  390. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  391. for (i = 11; i < 16; i++)
  392. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  393. gpio_direction_output(S3C2410_GPC(10), 1);
  394. gpio_direction_output(S3C2410_GPC(6), 1);
  395. }
  396. enabled = enable;
  397. }
  398. static void rx1950_bl_power(int enable)
  399. {
  400. static int enabled;
  401. if (enabled == enable)
  402. return;
  403. if (!enable) {
  404. gpio_direction_output(S3C2410_GPB(0), 0);
  405. } else {
  406. /* LED driver need a "push" to power on */
  407. gpio_direction_output(S3C2410_GPB(0), 1);
  408. /* Warm up backlight for one period of PWM.
  409. * Without this trick its almost impossible to
  410. * enable backlight with low brightness value
  411. */
  412. ndelay(48000);
  413. s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
  414. }
  415. enabled = enable;
  416. }
  417. static int rx1950_backlight_init(struct device *dev)
  418. {
  419. WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
  420. lcd_pwm = pwm_request(1, "RX1950 LCD");
  421. if (IS_ERR(lcd_pwm)) {
  422. dev_err(dev, "Unable to request PWM for LCD power!\n");
  423. return PTR_ERR(lcd_pwm);
  424. }
  425. /*
  426. * FIXME: pwm_apply_args() should be removed when switching to
  427. * the atomic PWM API.
  428. */
  429. pwm_apply_args(lcd_pwm);
  430. rx1950_lcd_power(1);
  431. rx1950_bl_power(1);
  432. return 0;
  433. }
  434. static void rx1950_backlight_exit(struct device *dev)
  435. {
  436. rx1950_bl_power(0);
  437. rx1950_lcd_power(0);
  438. pwm_free(lcd_pwm);
  439. gpio_free(S3C2410_GPB(0));
  440. }
  441. static int rx1950_backlight_notify(struct device *dev, int brightness)
  442. {
  443. if (!brightness) {
  444. rx1950_bl_power(0);
  445. rx1950_lcd_power(0);
  446. } else {
  447. rx1950_lcd_power(1);
  448. rx1950_bl_power(1);
  449. }
  450. return brightness;
  451. }
  452. static struct platform_pwm_backlight_data rx1950_backlight_data = {
  453. .max_brightness = 24,
  454. .dft_brightness = 4,
  455. .enable_gpio = -1,
  456. .init = rx1950_backlight_init,
  457. .notify = rx1950_backlight_notify,
  458. .exit = rx1950_backlight_exit,
  459. };
  460. static struct platform_device rx1950_backlight = {
  461. .name = "pwm-backlight",
  462. .dev = {
  463. .parent = &samsung_device_pwm.dev,
  464. .platform_data = &rx1950_backlight_data,
  465. },
  466. };
  467. static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
  468. {
  469. switch (power_mode) {
  470. case MMC_POWER_OFF:
  471. gpio_direction_output(S3C2410_GPJ(1), 0);
  472. break;
  473. case MMC_POWER_UP:
  474. case MMC_POWER_ON:
  475. gpio_direction_output(S3C2410_GPJ(1), 1);
  476. break;
  477. default:
  478. break;
  479. }
  480. }
  481. static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
  482. .gpio_detect = S3C2410_GPF(5),
  483. .gpio_wprotect = S3C2410_GPH(8),
  484. .set_power = rx1950_set_mmc_power,
  485. .ocr_avail = MMC_VDD_32_33,
  486. };
  487. static struct mtd_partition rx1950_nand_part[] = {
  488. [0] = {
  489. .name = "Boot0",
  490. .offset = 0,
  491. .size = 0x4000,
  492. .mask_flags = MTD_WRITEABLE,
  493. },
  494. [1] = {
  495. .name = "Boot1",
  496. .offset = MTDPART_OFS_APPEND,
  497. .size = 0x40000,
  498. .mask_flags = MTD_WRITEABLE,
  499. },
  500. [2] = {
  501. .name = "Kernel",
  502. .offset = MTDPART_OFS_APPEND,
  503. .size = 0x300000,
  504. .mask_flags = 0,
  505. },
  506. [3] = {
  507. .name = "Filesystem",
  508. .offset = MTDPART_OFS_APPEND,
  509. .size = MTDPART_SIZ_FULL,
  510. .mask_flags = 0,
  511. },
  512. };
  513. static struct s3c2410_nand_set rx1950_nand_sets[] = {
  514. [0] = {
  515. .name = "Internal",
  516. .nr_chips = 1,
  517. .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
  518. .partitions = rx1950_nand_part,
  519. },
  520. };
  521. static struct s3c2410_platform_nand rx1950_nand_info = {
  522. .tacls = 25,
  523. .twrph0 = 50,
  524. .twrph1 = 15,
  525. .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
  526. .sets = rx1950_nand_sets,
  527. };
  528. static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
  529. .vbus_pin = S3C2410_GPG(5),
  530. .vbus_pin_inverted = 1,
  531. .pullup_pin = S3C2410_GPJ(5),
  532. };
  533. static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
  534. .delay = 10000,
  535. .presc = 49,
  536. .oversampling_shift = 3,
  537. };
  538. static struct gpio_keys_button rx1950_gpio_keys_table[] = {
  539. {
  540. .code = KEY_POWER,
  541. .gpio = S3C2410_GPF(0),
  542. .active_low = 1,
  543. .desc = "Power button",
  544. .wakeup = 1,
  545. },
  546. {
  547. .code = KEY_F5,
  548. .gpio = S3C2410_GPF(7),
  549. .active_low = 1,
  550. .desc = "Record button",
  551. },
  552. {
  553. .code = KEY_F1,
  554. .gpio = S3C2410_GPG(0),
  555. .active_low = 1,
  556. .desc = "Calendar button",
  557. },
  558. {
  559. .code = KEY_F2,
  560. .gpio = S3C2410_GPG(2),
  561. .active_low = 1,
  562. .desc = "Contacts button",
  563. },
  564. {
  565. .code = KEY_F3,
  566. .gpio = S3C2410_GPG(3),
  567. .active_low = 1,
  568. .desc = "Mail button",
  569. },
  570. {
  571. .code = KEY_F4,
  572. .gpio = S3C2410_GPG(7),
  573. .active_low = 1,
  574. .desc = "WLAN button",
  575. },
  576. {
  577. .code = KEY_LEFT,
  578. .gpio = S3C2410_GPG(10),
  579. .active_low = 1,
  580. .desc = "Left button",
  581. },
  582. {
  583. .code = KEY_RIGHT,
  584. .gpio = S3C2410_GPG(11),
  585. .active_low = 1,
  586. .desc = "Right button",
  587. },
  588. {
  589. .code = KEY_UP,
  590. .gpio = S3C2410_GPG(4),
  591. .active_low = 1,
  592. .desc = "Up button",
  593. },
  594. {
  595. .code = KEY_DOWN,
  596. .gpio = S3C2410_GPG(6),
  597. .active_low = 1,
  598. .desc = "Down button",
  599. },
  600. {
  601. .code = KEY_ENTER,
  602. .gpio = S3C2410_GPG(9),
  603. .active_low = 1,
  604. .desc = "Ok button"
  605. },
  606. };
  607. static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
  608. .buttons = rx1950_gpio_keys_table,
  609. .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
  610. };
  611. static struct platform_device rx1950_device_gpiokeys = {
  612. .name = "gpio-keys",
  613. .dev.platform_data = &rx1950_gpio_keys_data,
  614. };
  615. static struct uda1380_platform_data uda1380_info = {
  616. .gpio_power = S3C2410_GPJ(0),
  617. .gpio_reset = S3C2410_GPD(0),
  618. .dac_clk = UDA1380_DAC_CLK_SYSCLK,
  619. };
  620. static struct i2c_board_info rx1950_i2c_devices[] = {
  621. {
  622. I2C_BOARD_INFO("uda1380", 0x1a),
  623. .platform_data = &uda1380_info,
  624. },
  625. };
  626. static struct platform_device *rx1950_devices[] __initdata = {
  627. &s3c2410_device_dclk,
  628. &s3c_device_lcd,
  629. &s3c_device_wdt,
  630. &s3c_device_i2c0,
  631. &s3c_device_iis,
  632. &s3c_device_usbgadget,
  633. &s3c_device_rtc,
  634. &s3c_device_nand,
  635. &s3c_device_sdi,
  636. &s3c_device_adc,
  637. &s3c_device_ts,
  638. &samsung_device_pwm,
  639. &rx1950_backlight,
  640. &rx1950_device_gpiokeys,
  641. &power_supply,
  642. &rx1950_battery,
  643. &rx1950_leds,
  644. };
  645. static void __init rx1950_map_io(void)
  646. {
  647. s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
  648. s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
  649. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  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_time(void)
  657. {
  658. s3c2442_init_clocks(16934000);
  659. samsung_timer_init();
  660. }
  661. static void __init rx1950_init_machine(void)
  662. {
  663. int i;
  664. s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
  665. s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
  666. s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
  667. s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
  668. s3c_i2c0_set_platdata(NULL);
  669. s3c_nand_set_platdata(&rx1950_nand_info);
  670. /* Turn off suspend on both USB ports, and switch the
  671. * selectable USB port to USB device mode. */
  672. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  673. S3C2410_MISCCR_USBSUSPND0 |
  674. S3C2410_MISCCR_USBSUSPND1, 0x0);
  675. /* mmc power is disabled by default */
  676. WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
  677. gpio_direction_output(S3C2410_GPJ(1), 0);
  678. for (i = 0; i < 8; i++)
  679. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  680. for (i = 10; i < 16; i++)
  681. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  682. for (i = 2; i < 8; i++)
  683. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  684. for (i = 11; i < 16; i++)
  685. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  686. WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
  687. WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
  688. WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
  689. WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
  690. gpio_direction_output(S3C2410_GPA(3), 0);
  691. gpio_direction_output(S3C2410_GPA(4), 0);
  692. gpio_direction_output(S3C2410_GPJ(6), 0);
  693. pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
  694. platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
  695. i2c_register_board_info(0, rx1950_i2c_devices,
  696. ARRAY_SIZE(rx1950_i2c_devices));
  697. }
  698. /* H1940 and RX3715 need to reserve this for suspend */
  699. static void __init rx1950_reserve(void)
  700. {
  701. memblock_reserve(0x30003000, 0x1000);
  702. memblock_reserve(0x30081000, 0x1000);
  703. }
  704. MACHINE_START(RX1950, "HP iPAQ RX1950")
  705. /* Maintainers: Vasily Khoruzhick */
  706. .atag_offset = 0x100,
  707. .map_io = rx1950_map_io,
  708. .reserve = rx1950_reserve,
  709. .init_irq = s3c2442_init_irq,
  710. .init_machine = rx1950_init_machine,
  711. .init_time = rx1950_init_time,
  712. MACHINE_END