mach-rx1950.c 19 KB

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