1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/z2.c
5 * Support for the Zipit Z2 Handheld device.
7 * Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com>
9 * Based on research and code by: Ken McGuire
10 * Based on mainstone.c as modified for the Zipit Z2.
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/pwm.h>
17 #include <linux/pwm_backlight.h>
18 #include <linux/z2_battery.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/spi/spi.h>
21 #include <linux/spi/pxa2xx_spi.h>
22 #include <linux/spi/libertas_spi.h>
23 #include <linux/spi/lms283gf05.h>
24 #include <linux/power_supply.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/gpio.h>
27 #include <linux/gpio/machine.h>
28 #include <linux/gpio_keys.h>
29 #include <linux/delay.h>
30 #include <linux/regulator/machine.h>
31 #include <linux/platform_data/i2c-pxa.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
37 #include "mfp-pxa27x.h"
39 #include <linux/platform_data/video-pxafb.h>
40 #include <linux/platform_data/mmc-pxamci.h>
41 #include <linux/platform_data/keypad-pxa27x.h>
47 /******************************************************************************
49 ******************************************************************************/
50 static unsigned long z2_pin_config
[] = {
52 /* LCD - 16bpp Active TFT */
73 GPIO19_GPIO
, /* LCD reset */
74 GPIO88_GPIO
, /* LCD chipselect */
77 GPIO115_PWM1_OUT
, /* Keypad Backlight */
78 GPIO11_PWM2_OUT
, /* LCD Backlight */
87 GPIO96_GPIO
, /* SD detect */
115 GPIO23_SSP1_SCLK
, /* SSP1_SCK */
116 GPIO25_SSP1_TXD
, /* SSP1_TXD */
117 GPIO26_SSP1_RXD
, /* SSP1_RXD */
120 GPIO22_SSP2_SCLK
, /* SSP2_SCK */
121 GPIO13_SSP2_TXD
, /* SSP2_TXD */
122 GPIO40_SSP2_RXD
, /* SSP2_RXD */
125 GPIO10_GPIO
, /* WiFi LED */
126 GPIO83_GPIO
, /* Charging LED */
127 GPIO85_GPIO
, /* Charged LED */
130 GPIO28_I2S_BITCLK_OUT
,
132 GPIO30_I2S_SDATA_OUT
,
137 GPIO0_GPIO
, /* AC power detect */
138 GPIO1_GPIO
, /* Power button */
139 GPIO37_GPIO
, /* Headphone detect */
140 GPIO98_GPIO
, /* Lid switch */
141 GPIO14_GPIO
, /* WiFi Power */
142 GPIO24_GPIO
, /* WiFi CS */
143 GPIO36_GPIO
, /* WiFi IRQ */
144 GPIO88_GPIO
, /* LCD CS */
147 /******************************************************************************
149 ******************************************************************************/
150 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
151 static struct resource z2_flash_resource
= {
152 .start
= PXA_CS0_PHYS
,
153 .end
= PXA_CS0_PHYS
+ SZ_8M
- 1,
154 .flags
= IORESOURCE_MEM
,
157 static struct mtd_partition z2_flash_parts
[] = {
159 .name
= "U-Boot Bootloader",
163 .name
= "U-Boot Environment",
169 .size
= MTDPART_SIZ_FULL
,
173 static struct physmap_flash_data z2_flash_data
= {
175 .parts
= z2_flash_parts
,
176 .nr_parts
= ARRAY_SIZE(z2_flash_parts
),
179 static struct platform_device z2_flash
= {
180 .name
= "physmap-flash",
182 .resource
= &z2_flash_resource
,
185 .platform_data
= &z2_flash_data
,
189 static void __init
z2_nor_init(void)
191 platform_device_register(&z2_flash
);
194 static inline void z2_nor_init(void) {}
197 /******************************************************************************
199 ******************************************************************************/
200 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
201 static struct pwm_lookup z2_pwm_lookup
[] = {
202 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL
, 1260320,
203 PWM_POLARITY_NORMAL
),
204 PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL
, 1260320,
205 PWM_POLARITY_NORMAL
),
208 static struct platform_pwm_backlight_data z2_backlight_data
[] = {
210 /* Keypad Backlight */
211 .max_brightness
= 1023,
216 .max_brightness
= 1023,
217 .dft_brightness
= 512,
221 static struct platform_device z2_backlight_devices
[2] = {
223 .name
= "pwm-backlight",
226 .platform_data
= &z2_backlight_data
[1],
230 .name
= "pwm-backlight",
233 .platform_data
= &z2_backlight_data
[0],
237 static void __init
z2_pwm_init(void)
239 pwm_add_table(z2_pwm_lookup
, ARRAY_SIZE(z2_pwm_lookup
));
240 platform_device_register(&z2_backlight_devices
[0]);
241 platform_device_register(&z2_backlight_devices
[1]);
244 static inline void z2_pwm_init(void) {}
247 /******************************************************************************
249 ******************************************************************************/
250 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
251 static struct pxafb_mode_info z2_lcd_modes
[] = {
268 static struct pxafb_mach_info z2_lcd_screen
= {
269 .modes
= z2_lcd_modes
,
270 .num_modes
= ARRAY_SIZE(z2_lcd_modes
),
271 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_BIAS_ACTIVE_LOW
|
272 LCD_ALTERNATE_MAPPING
,
275 static void __init
z2_lcd_init(void)
277 pxa_set_fb_info(NULL
, &z2_lcd_screen
);
280 static inline void z2_lcd_init(void) {}
283 /******************************************************************************
284 * SD/MMC card controller
285 ******************************************************************************/
286 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
287 static struct pxamci_platform_data z2_mci_platform_data
= {
288 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
289 .detect_delay_ms
= 200,
292 static struct gpiod_lookup_table z2_mci_gpio_table
= {
293 .dev_id
= "pxa2xx-mci.0",
295 GPIO_LOOKUP("gpio-pxa", GPIO96_ZIPITZ2_SD_DETECT
,
296 "cd", GPIO_ACTIVE_LOW
),
301 static void __init
z2_mmc_init(void)
303 gpiod_add_lookup_table(&z2_mci_gpio_table
);
304 pxa_set_mci_info(&z2_mci_platform_data
);
307 static inline void z2_mmc_init(void) {}
310 /******************************************************************************
312 ******************************************************************************/
313 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
314 struct gpio_led z2_gpio_leds
[] = {
316 .name
= "z2:green:wifi",
317 .default_trigger
= "none",
318 .gpio
= GPIO10_ZIPITZ2_LED_WIFI
,
321 .name
= "z2:green:charged",
322 .default_trigger
= "mmc0",
323 .gpio
= GPIO85_ZIPITZ2_LED_CHARGED
,
326 .name
= "z2:amber:charging",
327 .default_trigger
= "Z2-charging-or-full",
328 .gpio
= GPIO83_ZIPITZ2_LED_CHARGING
,
333 static struct gpio_led_platform_data z2_gpio_led_info
= {
334 .leds
= z2_gpio_leds
,
335 .num_leds
= ARRAY_SIZE(z2_gpio_leds
),
338 static struct platform_device z2_leds
= {
342 .platform_data
= &z2_gpio_led_info
,
346 static void __init
z2_leds_init(void)
348 platform_device_register(&z2_leds
);
351 static inline void z2_leds_init(void) {}
354 /******************************************************************************
356 ******************************************************************************/
357 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
358 static const unsigned int z2_matrix_keys
[] = {
359 KEY(0, 0, KEY_OPTION
),
363 KEY(4, 0, KEY_RIGHT
),
365 KEY(6, 0, KEY_KPPLUS
),
372 KEY(5, 1, KEY_ENTER
),
373 KEY(6, 1, KEY_KPMINUS
),
375 KEY(0, 2, KEY_PAGEUP
),
380 KEY(5, 2, KEY_LEFTALT
),
382 KEY(0, 3, KEY_PAGEDOWN
),
387 KEY(5, 3, KEY_LEFTSHIFT
),
394 KEY(5, 4, KEY_LEFTCTRL
),
401 KEY(5, 5, KEY_SPACE
),
403 KEY(0, 6, KEY_STOPCD
),
406 KEY(3, 6, KEY_BACKSPACE
),
408 KEY(5, 6, KEY_COMMA
),
410 KEY(0, 7, KEY_PLAYCD
),
414 KEY(4, 7, KEY_SEMICOLON
),
418 static struct matrix_keymap_data z2_matrix_keymap_data
= {
419 .keymap
= z2_matrix_keys
,
420 .keymap_size
= ARRAY_SIZE(z2_matrix_keys
),
423 static struct pxa27x_keypad_platform_data z2_keypad_platform_data
= {
424 .matrix_key_rows
= 7,
425 .matrix_key_cols
= 8,
426 .matrix_keymap_data
= &z2_matrix_keymap_data
,
428 .debounce_interval
= 30,
431 static void __init
z2_mkp_init(void)
433 pxa_set_keypad_info(&z2_keypad_platform_data
);
436 static inline void z2_mkp_init(void) {}
439 /******************************************************************************
441 ******************************************************************************/
442 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
443 static struct gpio_keys_button z2_pxa_buttons
[] = {
446 .gpio
= GPIO1_ZIPITZ2_POWER_BUTTON
,
448 .desc
= "Power Button",
454 .gpio
= GPIO98_ZIPITZ2_LID_BUTTON
,
456 .desc
= "Lid Switch",
462 static struct gpio_keys_platform_data z2_pxa_keys_data
= {
463 .buttons
= z2_pxa_buttons
,
464 .nbuttons
= ARRAY_SIZE(z2_pxa_buttons
),
467 static struct platform_device z2_pxa_keys
= {
471 .platform_data
= &z2_pxa_keys_data
,
475 static void __init
z2_keys_init(void)
477 platform_device_register(&z2_pxa_keys
);
480 static inline void z2_keys_init(void) {}
483 /******************************************************************************
485 ******************************************************************************/
486 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
487 static struct z2_battery_info batt_chip_info
= {
489 .batt_I2C_addr
= 0x55,
491 .charge_gpio
= GPIO0_ZIPITZ2_AC_DETECT
,
492 .min_voltage
= 3475000,
493 .max_voltage
= 4190000,
495 .batt_mult
= 1000000,
496 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LION
,
500 static struct i2c_board_info __initdata z2_i2c_board_info
[] = {
502 I2C_BOARD_INFO("aer915", 0x55),
503 .platform_data
= &batt_chip_info
,
505 I2C_BOARD_INFO("wm8750", 0x1b),
510 static void __init
z2_i2c_init(void)
512 pxa_set_i2c_info(NULL
);
513 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info
));
516 static inline void z2_i2c_init(void) {}
519 /******************************************************************************
520 * SSP Devices - WiFi and LCD control
521 ******************************************************************************/
522 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
524 static int z2_lbs_spi_setup(struct spi_device
*spi
)
528 ret
= gpio_request(GPIO14_ZIPITZ2_WIFI_POWER
, "WiFi Power");
532 ret
= gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER
, 1);
536 /* Wait until card is powered on */
539 spi
->bits_per_word
= 16;
540 spi
->mode
= SPI_MODE_2
,
547 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
552 static int z2_lbs_spi_teardown(struct spi_device
*spi
)
554 gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER
, 0);
555 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
560 static struct pxa2xx_spi_chip z2_lbs_chip_info
= {
564 .gpio_cs
= GPIO24_ZIPITZ2_WIFI_CS
,
567 static struct libertas_spi_platform_data z2_lbs_pdata
= {
568 .use_dummy_writes
= 1,
569 .setup
= z2_lbs_spi_setup
,
570 .teardown
= z2_lbs_spi_teardown
,
574 static struct pxa2xx_spi_chip lms283_chip_info
= {
578 .gpio_cs
= GPIO88_ZIPITZ2_LCD_CS
,
581 static const struct lms283gf05_pdata lms283_pdata
= {
582 .reset_gpio
= GPIO19_ZIPITZ2_LCD_RESET
,
585 static struct spi_board_info spi_board_info
[] __initdata
= {
587 .modalias
= "libertas_spi",
588 .platform_data
= &z2_lbs_pdata
,
589 .controller_data
= &z2_lbs_chip_info
,
590 .irq
= PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ
),
591 .max_speed_hz
= 13000000,
596 .modalias
= "lms283gf05",
597 .controller_data
= &lms283_chip_info
,
598 .platform_data
= &lms283_pdata
,
599 .max_speed_hz
= 400000,
605 static struct pxa2xx_spi_controller pxa_ssp1_master_info
= {
610 static struct pxa2xx_spi_controller pxa_ssp2_master_info
= {
614 static void __init
z2_spi_init(void)
616 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info
);
617 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info
);
618 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
621 static inline void z2_spi_init(void) {}
624 /******************************************************************************
625 * Core power regulator
626 ******************************************************************************/
627 #if defined(CONFIG_REGULATOR_TPS65023) || \
628 defined(CONFIG_REGULATOR_TPS65023_MODULE)
629 static struct regulator_consumer_supply z2_tps65021_consumers
[] = {
630 REGULATOR_SUPPLY("vcc_core", NULL
),
633 static struct regulator_init_data z2_tps65021_info
[] = {
636 .name
= "vcc_core range",
640 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
642 .consumer_supplies
= z2_tps65021_consumers
,
643 .num_consumer_supplies
= ARRAY_SIZE(z2_tps65021_consumers
),
675 static struct i2c_board_info __initdata z2_pi2c_board_info
[] = {
677 I2C_BOARD_INFO("tps65021", 0x48),
678 .platform_data
= &z2_tps65021_info
,
682 static void __init
z2_pmic_init(void)
684 pxa27x_set_i2c_power_info(NULL
);
685 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info
));
688 static inline void z2_pmic_init(void) {}
692 static void z2_power_off(void)
694 /* We're using deep sleep as poweroff, so clear PSPR to ensure that
695 * bootloader will jump to its entry point in resume handler
699 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP
);
700 pxa27x_cpu_pm_enter(PM_SUSPEND_MEM
);
703 #define z2_power_off NULL
706 /******************************************************************************
708 ******************************************************************************/
709 static void __init
z2_init(void)
711 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config
));
713 pxa_set_ffuart_info(NULL
);
714 pxa_set_btuart_info(NULL
);
715 pxa_set_stuart_info(NULL
);
728 pm_power_off
= z2_power_off
;
731 MACHINE_START(ZIPIT2
, "Zipit Z2")
732 .atag_offset
= 0x100,
733 .map_io
= pxa27x_map_io
,
734 .nr_irqs
= PXA_NR_IRQS
,
735 .init_irq
= pxa27x_init_irq
,
736 .handle_irq
= pxa27x_handle_irq
,
737 .init_time
= pxa_timer_init
,
738 .init_machine
= z2_init
,
739 .restart
= pxa_restart
,