z2.c 18 KB

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