mach-rx1950.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  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/gpio/machine.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/serial_s3c.h>
  20. #include <linux/input.h>
  21. #include <linux/gpio_keys.h>
  22. #include <linux/device.h>
  23. #include <linux/pda_power.h>
  24. #include <linux/pwm_backlight.h>
  25. #include <linux/pwm.h>
  26. #include <linux/s3c_adc_battery.h>
  27. #include <linux/leds.h>
  28. #include <linux/i2c.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/partitions.h>
  31. #include <linux/mmc/host.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <linux/platform_data/i2c-s3c2410.h>
  36. #include <linux/platform_data/mmc-s3cmci.h>
  37. #include <linux/platform_data/mtd-nand-s3c2410.h>
  38. #include <linux/platform_data/touchscreen-s3c2410.h>
  39. #include <linux/platform_data/usb-s3c2410_udc.h>
  40. #include <linux/platform_data/fb-s3c2410.h>
  41. #include <sound/uda1380.h>
  42. #include "hardware-s3c24xx.h"
  43. #include "regs-gpio.h"
  44. #include "gpio-samsung.h"
  45. #include "cpu.h"
  46. #include "devs.h"
  47. #include "pm.h"
  48. #include "gpio-cfg.h"
  49. #include "s3c24xx.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 struct gpiod_lookup_table rx1950_bat_gpio_table = {
  184. .dev_id = "s3c-adc-battery",
  185. .table = {
  186. /* Charge status S3C2410_GPF(3) */
  187. GPIO_LOOKUP("GPIOF", 3, "charge-status", GPIO_ACTIVE_HIGH),
  188. { },
  189. },
  190. };
  191. static int rx1950_bat_init(void)
  192. {
  193. int ret;
  194. ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
  195. if (ret)
  196. goto err_gpio1;
  197. ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
  198. if (ret)
  199. goto err_gpio2;
  200. return 0;
  201. err_gpio2:
  202. gpio_free(S3C2410_GPJ(2));
  203. err_gpio1:
  204. return ret;
  205. }
  206. static void rx1950_bat_exit(void)
  207. {
  208. gpio_free(S3C2410_GPJ(2));
  209. gpio_free(S3C2410_GPJ(3));
  210. }
  211. static void rx1950_enable_charger(void)
  212. {
  213. gpio_direction_output(S3C2410_GPJ(2), 1);
  214. gpio_direction_output(S3C2410_GPJ(3), 1);
  215. }
  216. static void rx1950_disable_charger(void)
  217. {
  218. gpio_direction_output(S3C2410_GPJ(2), 0);
  219. gpio_direction_output(S3C2410_GPJ(3), 0);
  220. }
  221. static DEFINE_SPINLOCK(rx1950_blink_spin);
  222. static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
  223. unsigned long *delay_on, unsigned long *delay_off)
  224. {
  225. int gpio = desc_to_gpio(desc);
  226. int blink_gpio, check_gpio;
  227. switch (gpio) {
  228. case S3C2410_GPA(6):
  229. blink_gpio = S3C2410_GPA(4);
  230. check_gpio = S3C2410_GPA(3);
  231. break;
  232. case S3C2410_GPA(7):
  233. blink_gpio = S3C2410_GPA(3);
  234. check_gpio = S3C2410_GPA(4);
  235. break;
  236. default:
  237. return -EINVAL;
  238. }
  239. if (delay_on && delay_off && !*delay_on && !*delay_off)
  240. *delay_on = *delay_off = 500;
  241. spin_lock(&rx1950_blink_spin);
  242. switch (state) {
  243. case GPIO_LED_NO_BLINK_LOW:
  244. case GPIO_LED_NO_BLINK_HIGH:
  245. if (!gpio_get_value(check_gpio))
  246. gpio_set_value(S3C2410_GPJ(6), 0);
  247. gpio_set_value(blink_gpio, 0);
  248. gpio_set_value(gpio, state);
  249. break;
  250. case GPIO_LED_BLINK:
  251. gpio_set_value(gpio, 0);
  252. gpio_set_value(S3C2410_GPJ(6), 1);
  253. gpio_set_value(blink_gpio, 1);
  254. break;
  255. }
  256. spin_unlock(&rx1950_blink_spin);
  257. return 0;
  258. }
  259. static struct gpio_led rx1950_leds_desc[] = {
  260. {
  261. .name = "Green",
  262. .default_trigger = "main-battery-full",
  263. .gpio = S3C2410_GPA(6),
  264. .retain_state_suspended = 1,
  265. },
  266. {
  267. .name = "Red",
  268. .default_trigger
  269. = "main-battery-charging-blink-full-solid",
  270. .gpio = S3C2410_GPA(7),
  271. .retain_state_suspended = 1,
  272. },
  273. {
  274. .name = "Blue",
  275. .default_trigger = "rx1950-acx-mem",
  276. .gpio = S3C2410_GPA(11),
  277. .retain_state_suspended = 1,
  278. },
  279. };
  280. static struct gpio_led_platform_data rx1950_leds_pdata = {
  281. .num_leds = ARRAY_SIZE(rx1950_leds_desc),
  282. .leds = rx1950_leds_desc,
  283. .gpio_blink_set = rx1950_led_blink_set,
  284. };
  285. static struct platform_device rx1950_leds = {
  286. .name = "leds-gpio",
  287. .id = -1,
  288. .dev = {
  289. .platform_data = &rx1950_leds_pdata,
  290. },
  291. };
  292. static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
  293. .init = rx1950_bat_init,
  294. .exit = rx1950_bat_exit,
  295. .enable_charger = rx1950_enable_charger,
  296. .disable_charger = rx1950_disable_charger,
  297. .lut_noac = bat_lut_noac,
  298. .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
  299. .lut_acin = bat_lut_acin,
  300. .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
  301. .volt_channel = 0,
  302. .current_channel = 1,
  303. .volt_mult = 4235,
  304. .current_mult = 2900,
  305. .internal_impedance = 200,
  306. };
  307. static struct platform_device rx1950_battery = {
  308. .name = "s3c-adc-battery",
  309. .id = -1,
  310. .dev = {
  311. .parent = &s3c_device_adc.dev,
  312. .platform_data = &rx1950_bat_cfg,
  313. },
  314. };
  315. static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
  316. .displays = &rx1950_display,
  317. .num_displays = 1,
  318. .default_display = 0,
  319. .lpcsel = 0x02,
  320. .gpccon = 0xaa9556a9,
  321. .gpccon_mask = 0xffc003fc,
  322. .gpccon_reg = S3C2410_GPCCON,
  323. .gpcup = 0x0000ffff,
  324. .gpcup_mask = 0xffffffff,
  325. .gpcup_reg = S3C2410_GPCUP,
  326. .gpdcon = 0xaa90aaa1,
  327. .gpdcon_mask = 0xffc0fff0,
  328. .gpdcon_reg = S3C2410_GPDCON,
  329. .gpdup = 0x0000fcfd,
  330. .gpdup_mask = 0xffffffff,
  331. .gpdup_reg = S3C2410_GPDUP,
  332. };
  333. static struct pwm_lookup rx1950_pwm_lookup[] = {
  334. PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
  335. PWM_POLARITY_NORMAL),
  336. PWM_LOOKUP("samsung-pwm", 1, "pwm-backlight.0", "RX1950 LCD", LCD_PWM_PERIOD,
  337. PWM_POLARITY_NORMAL),
  338. };
  339. static struct pwm_device *lcd_pwm;
  340. static struct pwm_state lcd_pwm_state;
  341. static void rx1950_lcd_power(int enable)
  342. {
  343. int i;
  344. static int enabled;
  345. if (enabled == enable)
  346. return;
  347. if (!enable) {
  348. /* GPC11-GPC15->OUTPUT */
  349. for (i = 11; i < 16; i++)
  350. gpio_direction_output(S3C2410_GPC(i), 1);
  351. /* Wait a bit here... */
  352. mdelay(100);
  353. /* GPD2-GPD7->OUTPUT */
  354. /* GPD11-GPD15->OUTPUT */
  355. /* GPD2-GPD7->1, GPD11-GPD15->1 */
  356. for (i = 2; i < 8; i++)
  357. gpio_direction_output(S3C2410_GPD(i), 1);
  358. for (i = 11; i < 16; i++)
  359. gpio_direction_output(S3C2410_GPD(i), 1);
  360. /* Wait a bit here...*/
  361. mdelay(100);
  362. /* GPB0->OUTPUT, GPB0->0 */
  363. gpio_direction_output(S3C2410_GPB(0), 0);
  364. /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
  365. for (i = 1; i < 5; i++)
  366. gpio_direction_output(S3C2410_GPC(i), 0);
  367. /* GPC15-GPC11->0 */
  368. for (i = 11; i < 16; i++)
  369. gpio_direction_output(S3C2410_GPC(i), 0);
  370. /* GPD15-GPD11->0, GPD2->GPD7->0 */
  371. for (i = 11; i < 16; i++)
  372. gpio_direction_output(S3C2410_GPD(i), 0);
  373. for (i = 2; i < 8; i++)
  374. gpio_direction_output(S3C2410_GPD(i), 0);
  375. /* GPC6->0, GPC7->0, GPC5->0 */
  376. gpio_direction_output(S3C2410_GPC(6), 0);
  377. gpio_direction_output(S3C2410_GPC(7), 0);
  378. gpio_direction_output(S3C2410_GPC(5), 0);
  379. /* GPB1->OUTPUT, GPB1->0 */
  380. gpio_direction_output(S3C2410_GPB(1), 0);
  381. lcd_pwm_state.enabled = false;
  382. pwm_apply_state(lcd_pwm, &lcd_pwm_state);
  383. /* GPC0->0, GPC10->0 */
  384. gpio_direction_output(S3C2410_GPC(0), 0);
  385. gpio_direction_output(S3C2410_GPC(10), 0);
  386. } else {
  387. lcd_pwm_state.enabled = true;
  388. pwm_apply_state(lcd_pwm, &lcd_pwm_state);
  389. gpio_direction_output(S3C2410_GPC(0), 1);
  390. gpio_direction_output(S3C2410_GPC(5), 1);
  391. s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
  392. gpio_direction_output(S3C2410_GPC(7), 1);
  393. for (i = 1; i < 5; i++)
  394. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  395. for (i = 11; i < 16; i++)
  396. s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
  397. for (i = 2; i < 8; i++)
  398. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  399. for (i = 11; i < 16; i++)
  400. s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
  401. gpio_direction_output(S3C2410_GPC(10), 1);
  402. gpio_direction_output(S3C2410_GPC(6), 1);
  403. }
  404. enabled = enable;
  405. }
  406. static void rx1950_bl_power(int enable)
  407. {
  408. static int enabled;
  409. if (enabled == enable)
  410. return;
  411. if (!enable) {
  412. gpio_direction_output(S3C2410_GPB(0), 0);
  413. } else {
  414. /* LED driver need a "push" to power on */
  415. gpio_direction_output(S3C2410_GPB(0), 1);
  416. /* Warm up backlight for one period of PWM.
  417. * Without this trick its almost impossible to
  418. * enable backlight with low brightness value
  419. */
  420. ndelay(48000);
  421. s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
  422. }
  423. enabled = enable;
  424. }
  425. static int rx1950_backlight_init(struct device *dev)
  426. {
  427. WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
  428. lcd_pwm = pwm_get(dev, "RX1950 LCD");
  429. if (IS_ERR(lcd_pwm)) {
  430. dev_err(dev, "Unable to request PWM for LCD power!\n");
  431. return PTR_ERR(lcd_pwm);
  432. }
  433. /*
  434. * Call pwm_init_state to initialize .polarity and .period. The other
  435. * values are fixed in this driver.
  436. */
  437. pwm_init_state(lcd_pwm, &lcd_pwm_state);
  438. lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
  439. rx1950_lcd_power(1);
  440. rx1950_bl_power(1);
  441. return 0;
  442. }
  443. static void rx1950_backlight_exit(struct device *dev)
  444. {
  445. rx1950_bl_power(0);
  446. rx1950_lcd_power(0);
  447. pwm_put(lcd_pwm);
  448. gpio_free(S3C2410_GPB(0));
  449. }
  450. static int rx1950_backlight_notify(struct device *dev, int brightness)
  451. {
  452. if (!brightness) {
  453. rx1950_bl_power(0);
  454. rx1950_lcd_power(0);
  455. } else {
  456. rx1950_lcd_power(1);
  457. rx1950_bl_power(1);
  458. }
  459. return brightness;
  460. }
  461. static struct platform_pwm_backlight_data rx1950_backlight_data = {
  462. .max_brightness = 24,
  463. .dft_brightness = 4,
  464. .init = rx1950_backlight_init,
  465. .notify = rx1950_backlight_notify,
  466. .exit = rx1950_backlight_exit,
  467. };
  468. static struct platform_device rx1950_backlight = {
  469. .name = "pwm-backlight",
  470. .dev = {
  471. .parent = &samsung_device_pwm.dev,
  472. .platform_data = &rx1950_backlight_data,
  473. },
  474. };
  475. static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
  476. {
  477. s3c24xx_mci_def_set_power(power_mode, vdd);
  478. switch (power_mode) {
  479. case MMC_POWER_OFF:
  480. gpio_direction_output(S3C2410_GPJ(1), 0);
  481. break;
  482. case MMC_POWER_UP:
  483. case MMC_POWER_ON:
  484. gpio_direction_output(S3C2410_GPJ(1), 1);
  485. break;
  486. default:
  487. break;
  488. }
  489. }
  490. static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
  491. .set_power = rx1950_set_mmc_power,
  492. .ocr_avail = MMC_VDD_32_33,
  493. };
  494. static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
  495. .dev_id = "s3c2410-sdi",
  496. .table = {
  497. /* Card detect S3C2410_GPF(5) */
  498. GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
  499. /* Write protect S3C2410_GPH(8) */
  500. GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
  501. /* bus pins */
  502. GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
  503. GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
  504. GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
  505. GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
  506. GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
  507. GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
  508. { },
  509. },
  510. };
  511. static struct mtd_partition rx1950_nand_part[] = {
  512. [0] = {
  513. .name = "Boot0",
  514. .offset = 0,
  515. .size = 0x4000,
  516. .mask_flags = MTD_WRITEABLE,
  517. },
  518. [1] = {
  519. .name = "Boot1",
  520. .offset = MTDPART_OFS_APPEND,
  521. .size = 0x40000,
  522. .mask_flags = MTD_WRITEABLE,
  523. },
  524. [2] = {
  525. .name = "Kernel",
  526. .offset = MTDPART_OFS_APPEND,
  527. .size = 0x300000,
  528. .mask_flags = 0,
  529. },
  530. [3] = {
  531. .name = "Filesystem",
  532. .offset = MTDPART_OFS_APPEND,
  533. .size = MTDPART_SIZ_FULL,
  534. .mask_flags = 0,
  535. },
  536. };
  537. static struct s3c2410_nand_set rx1950_nand_sets[] = {
  538. [0] = {
  539. .name = "Internal",
  540. .nr_chips = 1,
  541. .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
  542. .partitions = rx1950_nand_part,
  543. },
  544. };
  545. static struct s3c2410_platform_nand rx1950_nand_info = {
  546. .tacls = 25,
  547. .twrph0 = 50,
  548. .twrph1 = 15,
  549. .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
  550. .sets = rx1950_nand_sets,
  551. .engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
  552. };
  553. static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
  554. };
  555. static struct gpiod_lookup_table rx1950_udc_gpio_table = {
  556. .dev_id = "s3c2410-usbgadget",
  557. .table = {
  558. GPIO_LOOKUP("GPIOG", 5, "vbus", GPIO_ACTIVE_LOW),
  559. GPIO_LOOKUP("GPIOJ", 5, "pullup", GPIO_ACTIVE_HIGH),
  560. { },
  561. },
  562. };
  563. static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
  564. .delay = 10000,
  565. .presc = 49,
  566. .oversampling_shift = 3,
  567. };
  568. static struct gpio_keys_button rx1950_gpio_keys_table[] = {
  569. {
  570. .code = KEY_POWER,
  571. .gpio = S3C2410_GPF(0),
  572. .active_low = 1,
  573. .desc = "Power button",
  574. .wakeup = 1,
  575. },
  576. {
  577. .code = KEY_F5,
  578. .gpio = S3C2410_GPF(7),
  579. .active_low = 1,
  580. .desc = "Record button",
  581. },
  582. {
  583. .code = KEY_F1,
  584. .gpio = S3C2410_GPG(0),
  585. .active_low = 1,
  586. .desc = "Calendar button",
  587. },
  588. {
  589. .code = KEY_F2,
  590. .gpio = S3C2410_GPG(2),
  591. .active_low = 1,
  592. .desc = "Contacts button",
  593. },
  594. {
  595. .code = KEY_F3,
  596. .gpio = S3C2410_GPG(3),
  597. .active_low = 1,
  598. .desc = "Mail button",
  599. },
  600. {
  601. .code = KEY_F4,
  602. .gpio = S3C2410_GPG(7),
  603. .active_low = 1,
  604. .desc = "WLAN button",
  605. },
  606. {
  607. .code = KEY_LEFT,
  608. .gpio = S3C2410_GPG(10),
  609. .active_low = 1,
  610. .desc = "Left button",
  611. },
  612. {
  613. .code = KEY_RIGHT,
  614. .gpio = S3C2410_GPG(11),
  615. .active_low = 1,
  616. .desc = "Right button",
  617. },
  618. {
  619. .code = KEY_UP,
  620. .gpio = S3C2410_GPG(4),
  621. .active_low = 1,
  622. .desc = "Up button",
  623. },
  624. {
  625. .code = KEY_DOWN,
  626. .gpio = S3C2410_GPG(6),
  627. .active_low = 1,
  628. .desc = "Down button",
  629. },
  630. {
  631. .code = KEY_ENTER,
  632. .gpio = S3C2410_GPG(9),
  633. .active_low = 1,
  634. .desc = "Ok button"
  635. },
  636. };
  637. static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
  638. .buttons = rx1950_gpio_keys_table,
  639. .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
  640. };
  641. static struct platform_device rx1950_device_gpiokeys = {
  642. .name = "gpio-keys",
  643. .dev.platform_data = &rx1950_gpio_keys_data,
  644. };
  645. static struct uda1380_platform_data uda1380_info = {
  646. .gpio_power = S3C2410_GPJ(0),
  647. .gpio_reset = S3C2410_GPD(0),
  648. .dac_clk = UDA1380_DAC_CLK_SYSCLK,
  649. };
  650. static struct i2c_board_info rx1950_i2c_devices[] = {
  651. {
  652. I2C_BOARD_INFO("uda1380", 0x1a),
  653. .platform_data = &uda1380_info,
  654. },
  655. };
  656. static struct gpiod_lookup_table rx1950_audio_gpio_table = {
  657. .dev_id = "rx1950-audio",
  658. .table = {
  659. GPIO_LOOKUP("GPIOG", 12, "hp-gpio", GPIO_ACTIVE_HIGH),
  660. GPIO_LOOKUP("GPIOA", 1, "speaker-power", GPIO_ACTIVE_HIGH),
  661. { },
  662. },
  663. };
  664. static struct platform_device rx1950_audio = {
  665. .name = "rx1950-audio",
  666. .id = -1,
  667. };
  668. static struct platform_device *rx1950_devices[] __initdata = {
  669. &s3c2410_device_dclk,
  670. &s3c_device_lcd,
  671. &s3c_device_wdt,
  672. &s3c_device_i2c0,
  673. &s3c_device_iis,
  674. &s3c_device_usbgadget,
  675. &s3c_device_rtc,
  676. &s3c_device_nand,
  677. &s3c_device_sdi,
  678. &s3c_device_adc,
  679. &s3c_device_ts,
  680. &samsung_device_pwm,
  681. &rx1950_backlight,
  682. &rx1950_device_gpiokeys,
  683. &power_supply,
  684. &rx1950_battery,
  685. &rx1950_leds,
  686. &rx1950_audio,
  687. };
  688. static void __init rx1950_map_io(void)
  689. {
  690. s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
  691. s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
  692. s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
  693. /* setup PM */
  694. #ifdef CONFIG_PM_H1940
  695. memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
  696. #endif
  697. s3c_pm_init();
  698. }
  699. static void __init rx1950_init_time(void)
  700. {
  701. s3c2442_init_clocks(16934000);
  702. s3c24xx_timer_init();
  703. }
  704. static void __init rx1950_init_machine(void)
  705. {
  706. int i;
  707. s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
  708. s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
  709. s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
  710. gpiod_add_lookup_table(&rx1950_mmc_gpio_table);
  711. s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
  712. s3c_i2c0_set_platdata(NULL);
  713. s3c_nand_set_platdata(&rx1950_nand_info);
  714. /* Turn off suspend on both USB ports, and switch the
  715. * selectable USB port to USB device mode. */
  716. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  717. S3C2410_MISCCR_USBSUSPND0 |
  718. S3C2410_MISCCR_USBSUSPND1, 0x0);
  719. /* mmc power is disabled by default */
  720. WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
  721. gpio_direction_output(S3C2410_GPJ(1), 0);
  722. for (i = 0; i < 8; i++)
  723. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  724. for (i = 10; i < 16; i++)
  725. WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
  726. for (i = 2; i < 8; i++)
  727. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  728. for (i = 11; i < 16; i++)
  729. WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
  730. WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
  731. WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
  732. WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
  733. WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
  734. gpio_direction_output(S3C2410_GPA(3), 0);
  735. gpio_direction_output(S3C2410_GPA(4), 0);
  736. gpio_direction_output(S3C2410_GPJ(6), 0);
  737. pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
  738. gpiod_add_lookup_table(&rx1950_udc_gpio_table);
  739. gpiod_add_lookup_table(&rx1950_audio_gpio_table);
  740. gpiod_add_lookup_table(&rx1950_bat_gpio_table);
  741. /* Configure the I2S pins (GPE0...GPE4) in correct mode */
  742. s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
  743. S3C_GPIO_PULL_NONE);
  744. platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
  745. i2c_register_board_info(0, rx1950_i2c_devices,
  746. ARRAY_SIZE(rx1950_i2c_devices));
  747. }
  748. /* H1940 and RX3715 need to reserve this for suspend */
  749. static void __init rx1950_reserve(void)
  750. {
  751. memblock_reserve(0x30003000, 0x1000);
  752. memblock_reserve(0x30081000, 0x1000);
  753. }
  754. MACHINE_START(RX1950, "HP iPAQ RX1950")
  755. /* Maintainers: Vasily Khoruzhick */
  756. .atag_offset = 0x100,
  757. .nr_irqs = NR_IRQS_S3C2442,
  758. .map_io = rx1950_map_io,
  759. .reserve = rx1950_reserve,
  760. .init_irq = s3c2442_init_irq,
  761. .init_machine = rx1950_init_machine,
  762. .init_time = rx1950_init_time,
  763. MACHINE_END