mach-rx1950.c 19 KB

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