magician.c 17 KB

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