magician.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. /*
  2. * Support for HTC Magician PDA phones:
  3. * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
  4. * and T-Mobile MDA Compact.
  5. *
  6. * Copyright (c) 2006-2007 Philipp Zabel
  7. *
  8. * Based on hx4700.c, spitz.c and others.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/delay.h>
  19. #include <linux/gpio.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/mfd/htc-egpio.h>
  23. #include <linux/mfd/htc-pasic3.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/pda_power.h>
  26. #include <linux/pwm_backlight.h>
  27. #include <linux/regulator/bq24022.h>
  28. #include <linux/regulator/machine.h>
  29. #include <linux/usb/gpio_vbus.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <mach/pxa27x.h>
  34. #include <mach/magician.h>
  35. #include <mach/pxafb.h>
  36. #include <plat/i2c.h>
  37. #include <mach/mmc.h>
  38. #include <mach/irda.h>
  39. #include <mach/ohci.h>
  40. #include "devices.h"
  41. #include "generic.h"
  42. static unsigned long magician_pin_config[] __initdata = {
  43. /* SDRAM and Static Memory I/O Signals */
  44. GPIO20_nSDCS_2,
  45. GPIO21_nSDCS_3,
  46. GPIO15_nCS_1,
  47. GPIO78_nCS_2, /* PASIC3 */
  48. GPIO79_nCS_3, /* EGPIO CPLD */
  49. GPIO80_nCS_4,
  50. GPIO33_nCS_5,
  51. /* I2C */
  52. GPIO117_I2C_SCL,
  53. GPIO118_I2C_SDA,
  54. /* PWM 0 */
  55. GPIO16_PWM0_OUT,
  56. /* I2S */
  57. GPIO28_I2S_BITCLK_OUT,
  58. GPIO29_I2S_SDATA_IN,
  59. GPIO31_I2S_SYNC,
  60. GPIO113_I2S_SYSCLK,
  61. /* SSP 1 */
  62. GPIO23_SSP1_SCLK,
  63. GPIO24_SSP1_SFRM,
  64. GPIO25_SSP1_TXD,
  65. /* SSP 2 */
  66. GPIO19_SSP2_SCLK,
  67. GPIO14_SSP2_SFRM,
  68. GPIO89_SSP2_TXD,
  69. GPIO88_SSP2_RXD,
  70. /* MMC */
  71. GPIO32_MMC_CLK,
  72. GPIO92_MMC_DAT_0,
  73. GPIO109_MMC_DAT_1,
  74. GPIO110_MMC_DAT_2,
  75. GPIO111_MMC_DAT_3,
  76. GPIO112_MMC_CMD,
  77. /* LCD */
  78. GPIO58_LCD_LDD_0,
  79. GPIO59_LCD_LDD_1,
  80. GPIO60_LCD_LDD_2,
  81. GPIO61_LCD_LDD_3,
  82. GPIO62_LCD_LDD_4,
  83. GPIO63_LCD_LDD_5,
  84. GPIO64_LCD_LDD_6,
  85. GPIO65_LCD_LDD_7,
  86. GPIO66_LCD_LDD_8,
  87. GPIO67_LCD_LDD_9,
  88. GPIO68_LCD_LDD_10,
  89. GPIO69_LCD_LDD_11,
  90. GPIO70_LCD_LDD_12,
  91. GPIO71_LCD_LDD_13,
  92. GPIO72_LCD_LDD_14,
  93. GPIO73_LCD_LDD_15,
  94. GPIO74_LCD_FCLK,
  95. GPIO75_LCD_LCLK,
  96. GPIO76_LCD_PCLK,
  97. GPIO77_LCD_BIAS,
  98. /* QCI */
  99. GPIO12_CIF_DD_7,
  100. GPIO17_CIF_DD_6,
  101. GPIO50_CIF_DD_3,
  102. GPIO51_CIF_DD_2,
  103. GPIO52_CIF_DD_4,
  104. GPIO53_CIF_MCLK,
  105. GPIO54_CIF_PCLK,
  106. GPIO55_CIF_DD_1,
  107. GPIO81_CIF_DD_0,
  108. GPIO82_CIF_DD_5,
  109. GPIO84_CIF_FV,
  110. GPIO85_CIF_LV,
  111. /* Magician specific input GPIOs */
  112. GPIO9_GPIO, /* unknown */
  113. GPIO10_GPIO, /* GSM_IRQ */
  114. GPIO13_GPIO, /* CPLD_IRQ */
  115. GPIO107_GPIO, /* DS1WM_IRQ */
  116. GPIO108_GPIO, /* GSM_READY */
  117. GPIO115_GPIO, /* nPEN_IRQ */
  118. /* I2C */
  119. GPIO117_I2C_SCL,
  120. GPIO118_I2C_SDA,
  121. };
  122. /*
  123. * IRDA
  124. */
  125. static struct pxaficp_platform_data magician_ficp_info = {
  126. .gpio_pwdown = GPIO83_MAGICIAN_nIR_EN,
  127. .transceiver_cap = IR_SIRMODE | IR_OFF,
  128. };
  129. /*
  130. * GPIO Keys
  131. */
  132. #define INIT_KEY(_code, _gpio, _desc) \
  133. { \
  134. .code = KEY_##_code, \
  135. .gpio = _gpio, \
  136. .desc = _desc, \
  137. .type = EV_KEY, \
  138. .wakeup = 1, \
  139. }
  140. static struct gpio_keys_button magician_button_table[] = {
  141. INIT_KEY(POWER, GPIO0_MAGICIAN_KEY_POWER, "Power button"),
  142. INIT_KEY(ESC, GPIO37_MAGICIAN_KEY_HANGUP, "Hangup button"),
  143. INIT_KEY(F10, GPIO38_MAGICIAN_KEY_CONTACTS, "Contacts button"),
  144. INIT_KEY(CALENDAR, GPIO90_MAGICIAN_KEY_CALENDAR, "Calendar button"),
  145. INIT_KEY(CAMERA, GPIO91_MAGICIAN_KEY_CAMERA, "Camera button"),
  146. INIT_KEY(UP, GPIO93_MAGICIAN_KEY_UP, "Up button"),
  147. INIT_KEY(DOWN, GPIO94_MAGICIAN_KEY_DOWN, "Down button"),
  148. INIT_KEY(LEFT, GPIO95_MAGICIAN_KEY_LEFT, "Left button"),
  149. INIT_KEY(RIGHT, GPIO96_MAGICIAN_KEY_RIGHT, "Right button"),
  150. INIT_KEY(KPENTER, GPIO97_MAGICIAN_KEY_ENTER, "Action button"),
  151. INIT_KEY(RECORD, GPIO98_MAGICIAN_KEY_RECORD, "Record button"),
  152. INIT_KEY(VOLUMEUP, GPIO100_MAGICIAN_KEY_VOL_UP, "Volume up"),
  153. INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"),
  154. INIT_KEY(PHONE, GPIO102_MAGICIAN_KEY_PHONE, "Phone button"),
  155. INIT_KEY(PLAY, GPIO99_MAGICIAN_HEADPHONE_IN, "Headset button"),
  156. };
  157. static struct gpio_keys_platform_data gpio_keys_data = {
  158. .buttons = magician_button_table,
  159. .nbuttons = ARRAY_SIZE(magician_button_table),
  160. };
  161. static struct platform_device gpio_keys = {
  162. .name = "gpio-keys",
  163. .dev = {
  164. .platform_data = &gpio_keys_data,
  165. },
  166. .id = -1,
  167. };
  168. /*
  169. * EGPIO (Xilinx CPLD)
  170. *
  171. * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input
  172. */
  173. static struct resource egpio_resources[] = {
  174. [0] = {
  175. .start = PXA_CS3_PHYS,
  176. .end = PXA_CS3_PHYS + 0x20 - 1,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
  181. .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ),
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. };
  185. static struct htc_egpio_chip egpio_chips[] = {
  186. [0] = {
  187. .reg_start = 0,
  188. .gpio_base = MAGICIAN_EGPIO(0, 0),
  189. .num_gpios = 24,
  190. .direction = HTC_EGPIO_OUTPUT,
  191. .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
  192. },
  193. [1] = {
  194. .reg_start = 4,
  195. .gpio_base = MAGICIAN_EGPIO(4, 0),
  196. .num_gpios = 24,
  197. .direction = HTC_EGPIO_INPUT,
  198. },
  199. };
  200. static struct htc_egpio_platform_data egpio_info = {
  201. .reg_width = 8,
  202. .bus_width = 32,
  203. .irq_base = IRQ_BOARD_START,
  204. .num_irqs = 4,
  205. .ack_register = 3,
  206. .chip = egpio_chips,
  207. .num_chips = ARRAY_SIZE(egpio_chips),
  208. };
  209. static struct platform_device egpio = {
  210. .name = "htc-egpio",
  211. .id = -1,
  212. .resource = egpio_resources,
  213. .num_resources = ARRAY_SIZE(egpio_resources),
  214. .dev = {
  215. .platform_data = &egpio_info,
  216. },
  217. };
  218. /*
  219. * LCD - Toppoly TD028STEB1 or Samsung LTP280QV
  220. */
  221. static struct pxafb_mode_info toppoly_modes[] = {
  222. {
  223. .pixclock = 96153,
  224. .bpp = 16,
  225. .xres = 240,
  226. .yres = 320,
  227. .hsync_len = 11,
  228. .vsync_len = 3,
  229. .left_margin = 19,
  230. .upper_margin = 2,
  231. .right_margin = 10,
  232. .lower_margin = 2,
  233. .sync = 0,
  234. },
  235. };
  236. static struct pxafb_mode_info samsung_modes[] = {
  237. {
  238. .pixclock = 96153,
  239. .bpp = 16,
  240. .xres = 240,
  241. .yres = 320,
  242. .hsync_len = 8,
  243. .vsync_len = 4,
  244. .left_margin = 9,
  245. .upper_margin = 4,
  246. .right_margin = 9,
  247. .lower_margin = 4,
  248. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  249. },
  250. };
  251. static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si)
  252. {
  253. pr_debug("Toppoly LCD power\n");
  254. if (on) {
  255. pr_debug("on\n");
  256. gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1);
  257. gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1);
  258. udelay(2000);
  259. gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
  260. udelay(2000);
  261. /* FIXME: enable LCDC here */
  262. udelay(2000);
  263. gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1);
  264. udelay(2000);
  265. gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1);
  266. } else {
  267. pr_debug("off\n");
  268. msleep(15);
  269. gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0);
  270. udelay(500);
  271. gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0);
  272. udelay(1000);
  273. gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0);
  274. gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
  275. }
  276. }
  277. static void samsung_lcd_power(int on, struct fb_var_screeninfo *si)
  278. {
  279. pr_debug("Samsung LCD power\n");
  280. if (on) {
  281. pr_debug("on\n");
  282. if (system_rev < 3)
  283. gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1);
  284. else
  285. gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
  286. mdelay(10);
  287. gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1);
  288. mdelay(10);
  289. gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1);
  290. mdelay(30);
  291. gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1);
  292. mdelay(10);
  293. } else {
  294. pr_debug("off\n");
  295. mdelay(10);
  296. gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0);
  297. mdelay(30);
  298. gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0);
  299. mdelay(10);
  300. gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0);
  301. mdelay(10);
  302. if (system_rev < 3)
  303. gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
  304. else
  305. gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
  306. }
  307. }
  308. static struct pxafb_mach_info toppoly_info = {
  309. .modes = toppoly_modes,
  310. .num_modes = 1,
  311. .fixed_modes = 1,
  312. .lcd_conn = LCD_COLOR_TFT_16BPP,
  313. .pxafb_lcd_power = toppoly_lcd_power,
  314. };
  315. static struct pxafb_mach_info samsung_info = {
  316. .modes = samsung_modes,
  317. .num_modes = 1,
  318. .fixed_modes = 1,
  319. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |\
  320. LCD_ALTERNATE_MAPPING,
  321. .pxafb_lcd_power = samsung_lcd_power,
  322. };
  323. /*
  324. * Backlight
  325. */
  326. static int magician_backlight_init(struct device *dev)
  327. {
  328. int ret;
  329. ret = gpio_request(EGPIO_MAGICIAN_BL_POWER, "BL_POWER");
  330. if (ret)
  331. goto err;
  332. ret = gpio_request(EGPIO_MAGICIAN_BL_POWER2, "BL_POWER2");
  333. if (ret)
  334. goto err2;
  335. return 0;
  336. err2:
  337. gpio_free(EGPIO_MAGICIAN_BL_POWER);
  338. err:
  339. return ret;
  340. }
  341. static int magician_backlight_notify(int brightness)
  342. {
  343. gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
  344. if (brightness >= 200) {
  345. gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
  346. return brightness - 72;
  347. } else {
  348. gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
  349. return brightness;
  350. }
  351. }
  352. static void magician_backlight_exit(struct device *dev)
  353. {
  354. gpio_free(EGPIO_MAGICIAN_BL_POWER);
  355. gpio_free(EGPIO_MAGICIAN_BL_POWER2);
  356. }
  357. static struct platform_pwm_backlight_data backlight_data = {
  358. .pwm_id = 0,
  359. .max_brightness = 272,
  360. .dft_brightness = 100,
  361. .pwm_period_ns = 30923,
  362. .init = magician_backlight_init,
  363. .notify = magician_backlight_notify,
  364. .exit = magician_backlight_exit,
  365. };
  366. static struct platform_device backlight = {
  367. .name = "pwm-backlight",
  368. .id = -1,
  369. .dev = {
  370. .parent = &pxa27x_device_pwm0.dev,
  371. .platform_data = &backlight_data,
  372. },
  373. };
  374. /*
  375. * LEDs
  376. */
  377. static struct gpio_led gpio_leds[] = {
  378. {
  379. .name = "magician::vibra",
  380. .default_trigger = "none",
  381. .gpio = GPIO22_MAGICIAN_VIBRA_EN,
  382. },
  383. {
  384. .name = "magician::phone_bl",
  385. .default_trigger = "backlight",
  386. .gpio = GPIO103_MAGICIAN_LED_KP,
  387. },
  388. };
  389. static struct gpio_led_platform_data gpio_led_info = {
  390. .leds = gpio_leds,
  391. .num_leds = ARRAY_SIZE(gpio_leds),
  392. };
  393. static struct platform_device leds_gpio = {
  394. .name = "leds-gpio",
  395. .id = -1,
  396. .dev = {
  397. .platform_data = &gpio_led_info,
  398. },
  399. };
  400. static struct pasic3_led pasic3_leds[] = {
  401. {
  402. .led = {
  403. .name = "magician:red",
  404. .default_trigger = "ds2760-battery.0-charging",
  405. },
  406. .hw_num = 0,
  407. .bit2 = PASIC3_BIT2_LED0,
  408. .mask = PASIC3_MASK_LED0,
  409. },
  410. {
  411. .led = {
  412. .name = "magician:green",
  413. .default_trigger = "ds2760-battery.0-charging-or-full",
  414. },
  415. .hw_num = 1,
  416. .bit2 = PASIC3_BIT2_LED1,
  417. .mask = PASIC3_MASK_LED1,
  418. },
  419. {
  420. .led = {
  421. .name = "magician:blue",
  422. .default_trigger = "bluetooth",
  423. },
  424. .hw_num = 2,
  425. .bit2 = PASIC3_BIT2_LED2,
  426. .mask = PASIC3_MASK_LED2,
  427. },
  428. };
  429. static struct pasic3_leds_machinfo pasic3_leds_info = {
  430. .num_leds = ARRAY_SIZE(pasic3_leds),
  431. .power_gpio = EGPIO_MAGICIAN_LED_POWER,
  432. .leds = pasic3_leds,
  433. };
  434. /*
  435. * PASIC3 with DS1WM
  436. */
  437. static struct resource pasic3_resources[] = {
  438. [0] = {
  439. .start = PXA_CS2_PHYS,
  440. .end = PXA_CS2_PHYS + 0x1b,
  441. .flags = IORESOURCE_MEM,
  442. },
  443. /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
  444. [1] = {
  445. .start = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
  446. .end = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
  447. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  448. }
  449. };
  450. static struct pasic3_platform_data pasic3_platform_data = {
  451. .led_pdata = &pasic3_leds_info,
  452. .clock_rate = 4000000,
  453. };
  454. static struct platform_device pasic3 = {
  455. .name = "pasic3",
  456. .id = -1,
  457. .num_resources = ARRAY_SIZE(pasic3_resources),
  458. .resource = pasic3_resources,
  459. .dev = {
  460. .platform_data = &pasic3_platform_data,
  461. },
  462. };
  463. /*
  464. * USB "Transceiver"
  465. */
  466. static struct resource gpio_vbus_resource = {
  467. .flags = IORESOURCE_IRQ,
  468. .start = IRQ_MAGICIAN_VBUS,
  469. .end = IRQ_MAGICIAN_VBUS,
  470. };
  471. static struct gpio_vbus_mach_info gpio_vbus_info = {
  472. .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN,
  473. .gpio_vbus = EGPIO_MAGICIAN_CABLE_STATE_USB,
  474. };
  475. static struct platform_device gpio_vbus = {
  476. .name = "gpio-vbus",
  477. .id = -1,
  478. .num_resources = 1,
  479. .resource = &gpio_vbus_resource,
  480. .dev = {
  481. .platform_data = &gpio_vbus_info,
  482. },
  483. };
  484. /*
  485. * External power
  486. */
  487. static int power_supply_init(struct device *dev)
  488. {
  489. return gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC");
  490. }
  491. static int magician_is_ac_online(void)
  492. {
  493. return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC);
  494. }
  495. static void power_supply_exit(struct device *dev)
  496. {
  497. gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
  498. }
  499. static char *magician_supplicants[] = {
  500. "ds2760-battery.0", "backup-battery"
  501. };
  502. static struct pda_power_pdata power_supply_info = {
  503. .init = power_supply_init,
  504. .is_ac_online = magician_is_ac_online,
  505. .exit = power_supply_exit,
  506. .supplied_to = magician_supplicants,
  507. .num_supplicants = ARRAY_SIZE(magician_supplicants),
  508. };
  509. static struct resource power_supply_resources[] = {
  510. [0] = {
  511. .name = "ac",
  512. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  513. IORESOURCE_IRQ_LOWEDGE,
  514. .start = IRQ_MAGICIAN_VBUS,
  515. .end = IRQ_MAGICIAN_VBUS,
  516. },
  517. [1] = {
  518. .name = "usb",
  519. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  520. IORESOURCE_IRQ_LOWEDGE,
  521. .start = IRQ_MAGICIAN_VBUS,
  522. .end = IRQ_MAGICIAN_VBUS,
  523. },
  524. };
  525. static struct platform_device power_supply = {
  526. .name = "pda-power",
  527. .id = -1,
  528. .dev = {
  529. .platform_data = &power_supply_info,
  530. },
  531. .resource = power_supply_resources,
  532. .num_resources = ARRAY_SIZE(power_supply_resources),
  533. };
  534. /*
  535. * Battery charger
  536. */
  537. static struct regulator_consumer_supply bq24022_consumers[] = {
  538. {
  539. .dev = &gpio_vbus.dev,
  540. .supply = "vbus_draw",
  541. },
  542. {
  543. .dev = &power_supply.dev,
  544. .supply = "ac_draw",
  545. },
  546. };
  547. static struct regulator_init_data bq24022_init_data = {
  548. .constraints = {
  549. .max_uA = 500000,
  550. .valid_ops_mask = REGULATOR_CHANGE_CURRENT,
  551. },
  552. .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
  553. .consumer_supplies = bq24022_consumers,
  554. };
  555. static struct bq24022_mach_info bq24022_info = {
  556. .gpio_nce = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
  557. .gpio_iset2 = EGPIO_MAGICIAN_BQ24022_ISET2,
  558. .init_data = &bq24022_init_data,
  559. };
  560. static struct platform_device bq24022 = {
  561. .name = "bq24022",
  562. .id = -1,
  563. .dev = {
  564. .platform_data = &bq24022_info,
  565. },
  566. };
  567. /*
  568. * MMC/SD
  569. */
  570. static int magician_mci_init(struct device *dev,
  571. irq_handler_t detect_irq, void *data)
  572. {
  573. return request_irq(IRQ_MAGICIAN_SD, detect_irq,
  574. IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
  575. "mmc card detect", data);
  576. }
  577. static void magician_mci_exit(struct device *dev, void *data)
  578. {
  579. free_irq(IRQ_MAGICIAN_SD, data);
  580. }
  581. static struct pxamci_platform_data magician_mci_info = {
  582. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  583. .init = magician_mci_init,
  584. .exit = magician_mci_exit,
  585. .gpio_card_detect = -1,
  586. .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY,
  587. .gpio_card_ro_invert = 1,
  588. .gpio_power = EGPIO_MAGICIAN_SD_POWER,
  589. };
  590. /*
  591. * USB OHCI
  592. */
  593. static struct pxaohci_platform_data magician_ohci_info = {
  594. .port_mode = PMM_PERPORT_MODE,
  595. .flags = ENABLE_PORT1 | ENABLE_PORT3 | POWER_CONTROL_LOW,
  596. .power_budget = 0,
  597. };
  598. /*
  599. * StrataFlash
  600. */
  601. static void magician_set_vpp(struct map_info *map, int vpp)
  602. {
  603. gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
  604. }
  605. static struct resource strataflash_resource = {
  606. .start = PXA_CS0_PHYS,
  607. .end = PXA_CS0_PHYS + SZ_64M - 1,
  608. .flags = IORESOURCE_MEM,
  609. };
  610. static struct physmap_flash_data strataflash_data = {
  611. .width = 4,
  612. .set_vpp = magician_set_vpp,
  613. };
  614. static struct platform_device strataflash = {
  615. .name = "physmap-flash",
  616. .id = -1,
  617. .resource = &strataflash_resource,
  618. .num_resources = 1,
  619. .dev = {
  620. .platform_data = &strataflash_data,
  621. },
  622. };
  623. /*
  624. * I2C
  625. */
  626. static struct i2c_pxa_platform_data i2c_info = {
  627. .fast_mode = 1,
  628. };
  629. /*
  630. * Platform devices
  631. */
  632. static struct platform_device *devices[] __initdata = {
  633. &gpio_keys,
  634. &egpio,
  635. &backlight,
  636. &pasic3,
  637. &bq24022,
  638. &gpio_vbus,
  639. &power_supply,
  640. &strataflash,
  641. &leds_gpio,
  642. };
  643. static void __init magician_init(void)
  644. {
  645. void __iomem *cpld;
  646. int lcd_select;
  647. int err;
  648. gpio_request(GPIO13_MAGICIAN_CPLD_IRQ, "CPLD_IRQ");
  649. gpio_request(GPIO107_MAGICIAN_DS1WM_IRQ, "DS1WM_IRQ");
  650. pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
  651. platform_add_devices(ARRAY_AND_SIZE(devices));
  652. err = gpio_request(GPIO83_MAGICIAN_nIR_EN, "nIR_EN");
  653. if (!err) {
  654. gpio_direction_output(GPIO83_MAGICIAN_nIR_EN, 1);
  655. pxa_set_ficp_info(&magician_ficp_info);
  656. }
  657. pxa27x_set_i2c_power_info(NULL);
  658. pxa_set_i2c_info(&i2c_info);
  659. pxa_set_mci_info(&magician_mci_info);
  660. pxa_set_ohci_info(&magician_ohci_info);
  661. /* Check LCD type we have */
  662. cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000);
  663. if (cpld) {
  664. u8 board_id = __raw_readb(cpld+0x14);
  665. iounmap(cpld);
  666. system_rev = board_id & 0x7;
  667. lcd_select = board_id & 0x8;
  668. pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly");
  669. if (lcd_select && (system_rev < 3)) {
  670. gpio_request(GPIO75_MAGICIAN_SAMSUNG_POWER, "SAMSUNG_POWER");
  671. gpio_direction_output(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
  672. }
  673. gpio_request(GPIO104_MAGICIAN_LCD_POWER_1, "LCD_POWER_1");
  674. gpio_request(GPIO105_MAGICIAN_LCD_POWER_2, "LCD_POWER_2");
  675. gpio_request(GPIO106_MAGICIAN_LCD_POWER_3, "LCD_POWER_3");
  676. gpio_direction_output(GPIO104_MAGICIAN_LCD_POWER_1, 0);
  677. gpio_direction_output(GPIO105_MAGICIAN_LCD_POWER_2, 0);
  678. gpio_direction_output(GPIO106_MAGICIAN_LCD_POWER_3, 0);
  679. set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info);
  680. } else
  681. pr_err("LCD detection: CPLD mapping failed\n");
  682. }
  683. MACHINE_START(MAGICIAN, "HTC Magician")
  684. .phys_io = 0x40000000,
  685. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  686. .boot_params = 0xa0000100,
  687. .map_io = pxa_map_io,
  688. .init_irq = pxa27x_init_irq,
  689. .init_machine = magician_init,
  690. .timer = &pxa_timer,
  691. MACHINE_END