z2.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*
  2. * linux/arch/arm/mach-pxa/z2.c
  3. *
  4. * Support for the Zipit Z2 Handheld device.
  5. *
  6. * Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com>
  7. *
  8. * Based on research and code by: Ken McGuire
  9. * Based on mainstone.c as modified for the Zipit Z2.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/platform_device.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/pwm.h>
  19. #include <linux/pwm_backlight.h>
  20. #include <linux/z2_battery.h>
  21. #include <linux/dma-mapping.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/pxa2xx_spi.h>
  24. #include <linux/spi/libertas_spi.h>
  25. #include <linux/spi/lms283gf05.h>
  26. #include <linux/power_supply.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <linux/gpio.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/delay.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/i2c/pxa-i2c.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include "pxa27x.h"
  36. #include "mfp-pxa27x.h"
  37. #include <mach/z2.h>
  38. #include <linux/platform_data/video-pxafb.h>
  39. #include <linux/platform_data/mmc-pxamci.h>
  40. #include <linux/platform_data/keypad-pxa27x.h>
  41. #include "pm.h"
  42. #include "generic.h"
  43. #include "devices.h"
  44. /******************************************************************************
  45. * Pin configuration
  46. ******************************************************************************/
  47. static unsigned long z2_pin_config[] = {
  48. /* LCD - 16bpp Active TFT */
  49. GPIO58_LCD_LDD_0,
  50. GPIO59_LCD_LDD_1,
  51. GPIO60_LCD_LDD_2,
  52. GPIO61_LCD_LDD_3,
  53. GPIO62_LCD_LDD_4,
  54. GPIO63_LCD_LDD_5,
  55. GPIO64_LCD_LDD_6,
  56. GPIO65_LCD_LDD_7,
  57. GPIO66_LCD_LDD_8,
  58. GPIO67_LCD_LDD_9,
  59. GPIO68_LCD_LDD_10,
  60. GPIO69_LCD_LDD_11,
  61. GPIO70_LCD_LDD_12,
  62. GPIO71_LCD_LDD_13,
  63. GPIO72_LCD_LDD_14,
  64. GPIO73_LCD_LDD_15,
  65. GPIO74_LCD_FCLK,
  66. GPIO75_LCD_LCLK,
  67. GPIO76_LCD_PCLK,
  68. GPIO77_LCD_BIAS,
  69. GPIO19_GPIO, /* LCD reset */
  70. GPIO88_GPIO, /* LCD chipselect */
  71. /* PWM */
  72. GPIO115_PWM1_OUT, /* Keypad Backlight */
  73. GPIO11_PWM2_OUT, /* LCD Backlight */
  74. /* MMC */
  75. GPIO32_MMC_CLK,
  76. GPIO112_MMC_CMD,
  77. GPIO92_MMC_DAT_0,
  78. GPIO109_MMC_DAT_1,
  79. GPIO110_MMC_DAT_2,
  80. GPIO111_MMC_DAT_3,
  81. GPIO96_GPIO, /* SD detect */
  82. /* STUART */
  83. GPIO46_STUART_RXD,
  84. GPIO47_STUART_TXD,
  85. /* Keypad */
  86. GPIO100_KP_MKIN_0,
  87. GPIO101_KP_MKIN_1,
  88. GPIO102_KP_MKIN_2,
  89. GPIO34_KP_MKIN_3,
  90. GPIO38_KP_MKIN_4,
  91. GPIO16_KP_MKIN_5,
  92. GPIO17_KP_MKIN_6,
  93. GPIO103_KP_MKOUT_0,
  94. GPIO104_KP_MKOUT_1,
  95. GPIO105_KP_MKOUT_2,
  96. GPIO106_KP_MKOUT_3,
  97. GPIO107_KP_MKOUT_4,
  98. GPIO108_KP_MKOUT_5,
  99. GPIO35_KP_MKOUT_6,
  100. GPIO41_KP_MKOUT_7,
  101. /* I2C */
  102. GPIO117_I2C_SCL,
  103. GPIO118_I2C_SDA,
  104. /* SSP1 */
  105. GPIO23_SSP1_SCLK, /* SSP1_SCK */
  106. GPIO25_SSP1_TXD, /* SSP1_TXD */
  107. GPIO26_SSP1_RXD, /* SSP1_RXD */
  108. /* SSP2 */
  109. GPIO22_SSP2_SCLK, /* SSP2_SCK */
  110. GPIO13_SSP2_TXD, /* SSP2_TXD */
  111. GPIO40_SSP2_RXD, /* SSP2_RXD */
  112. /* LEDs */
  113. GPIO10_GPIO, /* WiFi LED */
  114. GPIO83_GPIO, /* Charging LED */
  115. GPIO85_GPIO, /* Charged LED */
  116. /* I2S */
  117. GPIO28_I2S_BITCLK_OUT,
  118. GPIO29_I2S_SDATA_IN,
  119. GPIO30_I2S_SDATA_OUT,
  120. GPIO31_I2S_SYNC,
  121. GPIO113_I2S_SYSCLK,
  122. /* MISC */
  123. GPIO0_GPIO, /* AC power detect */
  124. GPIO1_GPIO, /* Power button */
  125. GPIO37_GPIO, /* Headphone detect */
  126. GPIO98_GPIO, /* Lid switch */
  127. GPIO14_GPIO, /* WiFi Power */
  128. GPIO24_GPIO, /* WiFi CS */
  129. GPIO36_GPIO, /* WiFi IRQ */
  130. GPIO88_GPIO, /* LCD CS */
  131. };
  132. /******************************************************************************
  133. * NOR Flash
  134. ******************************************************************************/
  135. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  136. static struct resource z2_flash_resource = {
  137. .start = PXA_CS0_PHYS,
  138. .end = PXA_CS0_PHYS + SZ_8M - 1,
  139. .flags = IORESOURCE_MEM,
  140. };
  141. static struct mtd_partition z2_flash_parts[] = {
  142. {
  143. .name = "U-Boot Bootloader",
  144. .offset = 0x0,
  145. .size = 0x40000,
  146. }, {
  147. .name = "U-Boot Environment",
  148. .offset = 0x40000,
  149. .size = 0x20000,
  150. }, {
  151. .name = "Flash",
  152. .offset = 0x60000,
  153. .size = MTDPART_SIZ_FULL,
  154. },
  155. };
  156. static struct physmap_flash_data z2_flash_data = {
  157. .width = 2,
  158. .parts = z2_flash_parts,
  159. .nr_parts = ARRAY_SIZE(z2_flash_parts),
  160. };
  161. static struct platform_device z2_flash = {
  162. .name = "physmap-flash",
  163. .id = -1,
  164. .resource = &z2_flash_resource,
  165. .num_resources = 1,
  166. .dev = {
  167. .platform_data = &z2_flash_data,
  168. },
  169. };
  170. static void __init z2_nor_init(void)
  171. {
  172. platform_device_register(&z2_flash);
  173. }
  174. #else
  175. static inline void z2_nor_init(void) {}
  176. #endif
  177. /******************************************************************************
  178. * Backlight
  179. ******************************************************************************/
  180. #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
  181. static struct pwm_lookup z2_pwm_lookup[] = {
  182. PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL, 1260320,
  183. PWM_POLARITY_NORMAL),
  184. PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL, 1260320,
  185. PWM_POLARITY_NORMAL),
  186. };
  187. static struct platform_pwm_backlight_data z2_backlight_data[] = {
  188. [0] = {
  189. /* Keypad Backlight */
  190. .max_brightness = 1023,
  191. .dft_brightness = 0,
  192. .enable_gpio = -1,
  193. },
  194. [1] = {
  195. /* LCD Backlight */
  196. .max_brightness = 1023,
  197. .dft_brightness = 512,
  198. .enable_gpio = -1,
  199. },
  200. };
  201. static struct platform_device z2_backlight_devices[2] = {
  202. {
  203. .name = "pwm-backlight",
  204. .id = 0,
  205. .dev = {
  206. .platform_data = &z2_backlight_data[1],
  207. },
  208. },
  209. {
  210. .name = "pwm-backlight",
  211. .id = 1,
  212. .dev = {
  213. .platform_data = &z2_backlight_data[0],
  214. },
  215. },
  216. };
  217. static void __init z2_pwm_init(void)
  218. {
  219. pwm_add_table(z2_pwm_lookup, ARRAY_SIZE(z2_pwm_lookup));
  220. platform_device_register(&z2_backlight_devices[0]);
  221. platform_device_register(&z2_backlight_devices[1]);
  222. }
  223. #else
  224. static inline void z2_pwm_init(void) {}
  225. #endif
  226. /******************************************************************************
  227. * Framebuffer
  228. ******************************************************************************/
  229. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  230. static struct pxafb_mode_info z2_lcd_modes[] = {
  231. {
  232. .pixclock = 192000,
  233. .xres = 240,
  234. .yres = 320,
  235. .bpp = 16,
  236. .left_margin = 4,
  237. .right_margin = 8,
  238. .upper_margin = 4,
  239. .lower_margin = 8,
  240. .hsync_len = 4,
  241. .vsync_len = 4,
  242. },
  243. };
  244. static struct pxafb_mach_info z2_lcd_screen = {
  245. .modes = z2_lcd_modes,
  246. .num_modes = ARRAY_SIZE(z2_lcd_modes),
  247. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW |
  248. LCD_ALTERNATE_MAPPING,
  249. };
  250. static void __init z2_lcd_init(void)
  251. {
  252. pxa_set_fb_info(NULL, &z2_lcd_screen);
  253. }
  254. #else
  255. static inline void z2_lcd_init(void) {}
  256. #endif
  257. /******************************************************************************
  258. * SD/MMC card controller
  259. ******************************************************************************/
  260. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  261. static struct pxamci_platform_data z2_mci_platform_data = {
  262. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  263. .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT,
  264. .gpio_power = -1,
  265. .gpio_card_ro = -1,
  266. .detect_delay_ms = 200,
  267. };
  268. static void __init z2_mmc_init(void)
  269. {
  270. pxa_set_mci_info(&z2_mci_platform_data);
  271. }
  272. #else
  273. static inline void z2_mmc_init(void) {}
  274. #endif
  275. /******************************************************************************
  276. * LEDs
  277. ******************************************************************************/
  278. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  279. struct gpio_led z2_gpio_leds[] = {
  280. {
  281. .name = "z2:green:wifi",
  282. .default_trigger = "none",
  283. .gpio = GPIO10_ZIPITZ2_LED_WIFI,
  284. .active_low = 1,
  285. }, {
  286. .name = "z2:green:charged",
  287. .default_trigger = "mmc0",
  288. .gpio = GPIO85_ZIPITZ2_LED_CHARGED,
  289. .active_low = 1,
  290. }, {
  291. .name = "z2:amber:charging",
  292. .default_trigger = "Z2-charging-or-full",
  293. .gpio = GPIO83_ZIPITZ2_LED_CHARGING,
  294. .active_low = 1,
  295. },
  296. };
  297. static struct gpio_led_platform_data z2_gpio_led_info = {
  298. .leds = z2_gpio_leds,
  299. .num_leds = ARRAY_SIZE(z2_gpio_leds),
  300. };
  301. static struct platform_device z2_leds = {
  302. .name = "leds-gpio",
  303. .id = -1,
  304. .dev = {
  305. .platform_data = &z2_gpio_led_info,
  306. }
  307. };
  308. static void __init z2_leds_init(void)
  309. {
  310. platform_device_register(&z2_leds);
  311. }
  312. #else
  313. static inline void z2_leds_init(void) {}
  314. #endif
  315. /******************************************************************************
  316. * GPIO keyboard
  317. ******************************************************************************/
  318. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  319. static const unsigned int z2_matrix_keys[] = {
  320. KEY(0, 0, KEY_OPTION),
  321. KEY(1, 0, KEY_UP),
  322. KEY(2, 0, KEY_DOWN),
  323. KEY(3, 0, KEY_LEFT),
  324. KEY(4, 0, KEY_RIGHT),
  325. KEY(5, 0, KEY_END),
  326. KEY(6, 0, KEY_KPPLUS),
  327. KEY(0, 1, KEY_HOME),
  328. KEY(1, 1, KEY_Q),
  329. KEY(2, 1, KEY_I),
  330. KEY(3, 1, KEY_G),
  331. KEY(4, 1, KEY_X),
  332. KEY(5, 1, KEY_ENTER),
  333. KEY(6, 1, KEY_KPMINUS),
  334. KEY(0, 2, KEY_PAGEUP),
  335. KEY(1, 2, KEY_W),
  336. KEY(2, 2, KEY_O),
  337. KEY(3, 2, KEY_H),
  338. KEY(4, 2, KEY_C),
  339. KEY(5, 2, KEY_LEFTALT),
  340. KEY(0, 3, KEY_PAGEDOWN),
  341. KEY(1, 3, KEY_E),
  342. KEY(2, 3, KEY_P),
  343. KEY(3, 3, KEY_J),
  344. KEY(4, 3, KEY_V),
  345. KEY(5, 3, KEY_LEFTSHIFT),
  346. KEY(0, 4, KEY_ESC),
  347. KEY(1, 4, KEY_R),
  348. KEY(2, 4, KEY_A),
  349. KEY(3, 4, KEY_K),
  350. KEY(4, 4, KEY_B),
  351. KEY(5, 4, KEY_LEFTCTRL),
  352. KEY(0, 5, KEY_TAB),
  353. KEY(1, 5, KEY_T),
  354. KEY(2, 5, KEY_S),
  355. KEY(3, 5, KEY_L),
  356. KEY(4, 5, KEY_N),
  357. KEY(5, 5, KEY_SPACE),
  358. KEY(0, 6, KEY_STOPCD),
  359. KEY(1, 6, KEY_Y),
  360. KEY(2, 6, KEY_D),
  361. KEY(3, 6, KEY_BACKSPACE),
  362. KEY(4, 6, KEY_M),
  363. KEY(5, 6, KEY_COMMA),
  364. KEY(0, 7, KEY_PLAYCD),
  365. KEY(1, 7, KEY_U),
  366. KEY(2, 7, KEY_F),
  367. KEY(3, 7, KEY_Z),
  368. KEY(4, 7, KEY_SEMICOLON),
  369. KEY(5, 7, KEY_DOT),
  370. };
  371. static struct matrix_keymap_data z2_matrix_keymap_data = {
  372. .keymap = z2_matrix_keys,
  373. .keymap_size = ARRAY_SIZE(z2_matrix_keys),
  374. };
  375. static struct pxa27x_keypad_platform_data z2_keypad_platform_data = {
  376. .matrix_key_rows = 7,
  377. .matrix_key_cols = 8,
  378. .matrix_keymap_data = &z2_matrix_keymap_data,
  379. .debounce_interval = 30,
  380. };
  381. static void __init z2_mkp_init(void)
  382. {
  383. pxa_set_keypad_info(&z2_keypad_platform_data);
  384. }
  385. #else
  386. static inline void z2_mkp_init(void) {}
  387. #endif
  388. /******************************************************************************
  389. * GPIO keys
  390. ******************************************************************************/
  391. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  392. static struct gpio_keys_button z2_pxa_buttons[] = {
  393. {
  394. .code = KEY_POWER,
  395. .gpio = GPIO1_ZIPITZ2_POWER_BUTTON,
  396. .active_low = 0,
  397. .desc = "Power Button",
  398. .wakeup = 1,
  399. .type = EV_KEY,
  400. },
  401. {
  402. .code = SW_LID,
  403. .gpio = GPIO98_ZIPITZ2_LID_BUTTON,
  404. .active_low = 1,
  405. .desc = "Lid Switch",
  406. .wakeup = 0,
  407. .type = EV_SW,
  408. },
  409. };
  410. static struct gpio_keys_platform_data z2_pxa_keys_data = {
  411. .buttons = z2_pxa_buttons,
  412. .nbuttons = ARRAY_SIZE(z2_pxa_buttons),
  413. };
  414. static struct platform_device z2_pxa_keys = {
  415. .name = "gpio-keys",
  416. .id = -1,
  417. .dev = {
  418. .platform_data = &z2_pxa_keys_data,
  419. },
  420. };
  421. static void __init z2_keys_init(void)
  422. {
  423. platform_device_register(&z2_pxa_keys);
  424. }
  425. #else
  426. static inline void z2_keys_init(void) {}
  427. #endif
  428. /******************************************************************************
  429. * Battery
  430. ******************************************************************************/
  431. #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
  432. static struct z2_battery_info batt_chip_info = {
  433. .batt_I2C_bus = 0,
  434. .batt_I2C_addr = 0x55,
  435. .batt_I2C_reg = 2,
  436. .charge_gpio = GPIO0_ZIPITZ2_AC_DETECT,
  437. .min_voltage = 3475000,
  438. .max_voltage = 4190000,
  439. .batt_div = 59,
  440. .batt_mult = 1000000,
  441. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION,
  442. .batt_name = "Z2",
  443. };
  444. static struct i2c_board_info __initdata z2_i2c_board_info[] = {
  445. {
  446. I2C_BOARD_INFO("aer915", 0x55),
  447. .platform_data = &batt_chip_info,
  448. }, {
  449. I2C_BOARD_INFO("wm8750", 0x1b),
  450. },
  451. };
  452. static void __init z2_i2c_init(void)
  453. {
  454. pxa_set_i2c_info(NULL);
  455. i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info));
  456. }
  457. #else
  458. static inline void z2_i2c_init(void) {}
  459. #endif
  460. /******************************************************************************
  461. * SSP Devices - WiFi and LCD control
  462. ******************************************************************************/
  463. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  464. /* WiFi */
  465. static int z2_lbs_spi_setup(struct spi_device *spi)
  466. {
  467. int ret = 0;
  468. ret = gpio_request(GPIO14_ZIPITZ2_WIFI_POWER, "WiFi Power");
  469. if (ret)
  470. goto err;
  471. ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER, 1);
  472. if (ret)
  473. goto err2;
  474. /* Wait until card is powered on */
  475. mdelay(180);
  476. spi->bits_per_word = 16;
  477. spi->mode = SPI_MODE_2,
  478. spi_setup(spi);
  479. return 0;
  480. err2:
  481. gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
  482. err:
  483. return ret;
  484. };
  485. static int z2_lbs_spi_teardown(struct spi_device *spi)
  486. {
  487. gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER, 0);
  488. gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
  489. return 0;
  490. };
  491. static struct pxa2xx_spi_chip z2_lbs_chip_info = {
  492. .rx_threshold = 8,
  493. .tx_threshold = 8,
  494. .timeout = 1000,
  495. .gpio_cs = GPIO24_ZIPITZ2_WIFI_CS,
  496. };
  497. static struct libertas_spi_platform_data z2_lbs_pdata = {
  498. .use_dummy_writes = 1,
  499. .setup = z2_lbs_spi_setup,
  500. .teardown = z2_lbs_spi_teardown,
  501. };
  502. /* LCD */
  503. static struct pxa2xx_spi_chip lms283_chip_info = {
  504. .rx_threshold = 1,
  505. .tx_threshold = 1,
  506. .timeout = 64,
  507. .gpio_cs = GPIO88_ZIPITZ2_LCD_CS,
  508. };
  509. static const struct lms283gf05_pdata lms283_pdata = {
  510. .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET,
  511. };
  512. static struct spi_board_info spi_board_info[] __initdata = {
  513. {
  514. .modalias = "libertas_spi",
  515. .platform_data = &z2_lbs_pdata,
  516. .controller_data = &z2_lbs_chip_info,
  517. .irq = PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ),
  518. .max_speed_hz = 13000000,
  519. .bus_num = 1,
  520. .chip_select = 0,
  521. },
  522. {
  523. .modalias = "lms283gf05",
  524. .controller_data = &lms283_chip_info,
  525. .platform_data = &lms283_pdata,
  526. .max_speed_hz = 400000,
  527. .bus_num = 2,
  528. .chip_select = 0,
  529. },
  530. };
  531. static struct pxa2xx_spi_master pxa_ssp1_master_info = {
  532. .num_chipselect = 1,
  533. .enable_dma = 1,
  534. };
  535. static struct pxa2xx_spi_master pxa_ssp2_master_info = {
  536. .num_chipselect = 1,
  537. };
  538. static void __init z2_spi_init(void)
  539. {
  540. pxa2xx_set_spi_info(1, &pxa_ssp1_master_info);
  541. pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
  542. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  543. }
  544. #else
  545. static inline void z2_spi_init(void) {}
  546. #endif
  547. /******************************************************************************
  548. * Core power regulator
  549. ******************************************************************************/
  550. #if defined(CONFIG_REGULATOR_TPS65023) || \
  551. defined(CONFIG_REGULATOR_TPS65023_MODULE)
  552. static struct regulator_consumer_supply z2_tps65021_consumers[] = {
  553. REGULATOR_SUPPLY("vcc_core", NULL),
  554. };
  555. static struct regulator_init_data z2_tps65021_info[] = {
  556. {
  557. .constraints = {
  558. .name = "vcc_core range",
  559. .min_uV = 800000,
  560. .max_uV = 1600000,
  561. .always_on = 1,
  562. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  563. },
  564. .consumer_supplies = z2_tps65021_consumers,
  565. .num_consumer_supplies = ARRAY_SIZE(z2_tps65021_consumers),
  566. }, {
  567. .constraints = {
  568. .name = "DCDC2",
  569. .min_uV = 3300000,
  570. .max_uV = 3300000,
  571. .always_on = 1,
  572. },
  573. }, {
  574. .constraints = {
  575. .name = "DCDC3",
  576. .min_uV = 1800000,
  577. .max_uV = 1800000,
  578. .always_on = 1,
  579. },
  580. }, {
  581. .constraints = {
  582. .name = "LDO1",
  583. .min_uV = 1000000,
  584. .max_uV = 3150000,
  585. .always_on = 1,
  586. },
  587. }, {
  588. .constraints = {
  589. .name = "LDO2",
  590. .min_uV = 1050000,
  591. .max_uV = 3300000,
  592. .always_on = 1,
  593. },
  594. }
  595. };
  596. static struct i2c_board_info __initdata z2_pi2c_board_info[] = {
  597. {
  598. I2C_BOARD_INFO("tps65021", 0x48),
  599. .platform_data = &z2_tps65021_info,
  600. },
  601. };
  602. static void __init z2_pmic_init(void)
  603. {
  604. pxa27x_set_i2c_power_info(NULL);
  605. i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info));
  606. }
  607. #else
  608. static inline void z2_pmic_init(void) {}
  609. #endif
  610. #ifdef CONFIG_PM
  611. static void z2_power_off(void)
  612. {
  613. /* We're using deep sleep as poweroff, so clear PSPR to ensure that
  614. * bootloader will jump to its entry point in resume handler
  615. */
  616. PSPR = 0x0;
  617. local_irq_disable();
  618. pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
  619. pxa27x_cpu_pm_enter(PM_SUSPEND_MEM);
  620. }
  621. #else
  622. #define z2_power_off NULL
  623. #endif
  624. /******************************************************************************
  625. * Machine init
  626. ******************************************************************************/
  627. static void __init z2_init(void)
  628. {
  629. pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config));
  630. pxa_set_ffuart_info(NULL);
  631. pxa_set_btuart_info(NULL);
  632. pxa_set_stuart_info(NULL);
  633. z2_lcd_init();
  634. z2_mmc_init();
  635. z2_mkp_init();
  636. z2_i2c_init();
  637. z2_spi_init();
  638. z2_nor_init();
  639. z2_pwm_init();
  640. z2_leds_init();
  641. z2_keys_init();
  642. z2_pmic_init();
  643. pm_power_off = z2_power_off;
  644. }
  645. MACHINE_START(ZIPIT2, "Zipit Z2")
  646. .atag_offset = 0x100,
  647. .map_io = pxa27x_map_io,
  648. .nr_irqs = PXA_NR_IRQS,
  649. .init_irq = pxa27x_init_irq,
  650. .handle_irq = pxa27x_handle_irq,
  651. .init_time = pxa_timer_init,
  652. .init_machine = z2_init,
  653. .restart = pxa_restart,
  654. MACHINE_END