Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  linux/arch/arm/mach-pxa/z2.c
0004  *
0005  *  Support for the Zipit Z2 Handheld device.
0006  *
0007  *  Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com>
0008  *
0009  *  Based on research and code by: Ken McGuire
0010  *  Based on mainstone.c as modified for the Zipit Z2.
0011  */
0012 
0013 #include <linux/platform_device.h>
0014 #include <linux/mtd/mtd.h>
0015 #include <linux/mtd/partitions.h>
0016 #include <linux/pwm.h>
0017 #include <linux/pwm_backlight.h>
0018 #include <linux/z2_battery.h>
0019 #include <linux/dma-mapping.h>
0020 #include <linux/spi/spi.h>
0021 #include <linux/spi/pxa2xx_spi.h>
0022 #include <linux/spi/libertas_spi.h>
0023 #include <linux/power_supply.h>
0024 #include <linux/mtd/physmap.h>
0025 #include <linux/gpio.h>
0026 #include <linux/gpio/machine.h>
0027 #include <linux/gpio_keys.h>
0028 #include <linux/delay.h>
0029 #include <linux/regulator/machine.h>
0030 #include <linux/platform_data/i2c-pxa.h>
0031 
0032 #include <asm/mach-types.h>
0033 #include <asm/mach/arch.h>
0034 
0035 #include "pxa27x.h"
0036 #include "mfp-pxa27x.h"
0037 #include "z2.h"
0038 #include <linux/platform_data/video-pxafb.h>
0039 #include <linux/platform_data/mmc-pxamci.h>
0040 #include <linux/platform_data/keypad-pxa27x.h>
0041 #include "pm.h"
0042 
0043 #include "generic.h"
0044 #include "devices.h"
0045 
0046 /******************************************************************************
0047  * Pin configuration
0048  ******************************************************************************/
0049 static unsigned long z2_pin_config[] = {
0050 
0051     /* LCD - 16bpp Active TFT */
0052     GPIO58_LCD_LDD_0,
0053     GPIO59_LCD_LDD_1,
0054     GPIO60_LCD_LDD_2,
0055     GPIO61_LCD_LDD_3,
0056     GPIO62_LCD_LDD_4,
0057     GPIO63_LCD_LDD_5,
0058     GPIO64_LCD_LDD_6,
0059     GPIO65_LCD_LDD_7,
0060     GPIO66_LCD_LDD_8,
0061     GPIO67_LCD_LDD_9,
0062     GPIO68_LCD_LDD_10,
0063     GPIO69_LCD_LDD_11,
0064     GPIO70_LCD_LDD_12,
0065     GPIO71_LCD_LDD_13,
0066     GPIO72_LCD_LDD_14,
0067     GPIO73_LCD_LDD_15,
0068     GPIO74_LCD_FCLK,
0069     GPIO75_LCD_LCLK,
0070     GPIO76_LCD_PCLK,
0071     GPIO77_LCD_BIAS,
0072     GPIO19_GPIO,        /* LCD reset */
0073     GPIO88_GPIO,        /* LCD chipselect */
0074 
0075     /* PWM */
0076     GPIO115_PWM1_OUT,   /* Keypad Backlight */
0077     GPIO11_PWM2_OUT,    /* LCD Backlight */
0078 
0079     /* MMC */
0080     GPIO32_MMC_CLK,
0081     GPIO112_MMC_CMD,
0082     GPIO92_MMC_DAT_0,
0083     GPIO109_MMC_DAT_1,
0084     GPIO110_MMC_DAT_2,
0085     GPIO111_MMC_DAT_3,
0086     GPIO96_GPIO,        /* SD detect */
0087 
0088     /* STUART */
0089     GPIO46_STUART_RXD,
0090     GPIO47_STUART_TXD,
0091 
0092     /* Keypad */
0093     GPIO100_KP_MKIN_0,
0094     GPIO101_KP_MKIN_1,
0095     GPIO102_KP_MKIN_2,
0096     GPIO34_KP_MKIN_3,
0097     GPIO38_KP_MKIN_4,
0098     GPIO16_KP_MKIN_5,
0099     GPIO17_KP_MKIN_6,
0100     GPIO103_KP_MKOUT_0,
0101     GPIO104_KP_MKOUT_1,
0102     GPIO105_KP_MKOUT_2,
0103     GPIO106_KP_MKOUT_3,
0104     GPIO107_KP_MKOUT_4,
0105     GPIO108_KP_MKOUT_5,
0106     GPIO35_KP_MKOUT_6,
0107     GPIO41_KP_MKOUT_7,
0108 
0109     /* I2C */
0110     GPIO117_I2C_SCL,
0111     GPIO118_I2C_SDA,
0112 
0113     /* SSP1 */
0114     GPIO23_SSP1_SCLK,   /* SSP1_SCK */
0115     GPIO25_SSP1_TXD,    /* SSP1_TXD */
0116     GPIO26_SSP1_RXD,    /* SSP1_RXD */
0117 
0118     /* SSP2 */
0119     GPIO22_SSP2_SCLK,   /* SSP2_SCK */
0120     GPIO13_SSP2_TXD,    /* SSP2_TXD */
0121     GPIO40_SSP2_RXD,    /* SSP2_RXD */
0122 
0123     /* LEDs */
0124     GPIO10_GPIO,        /* WiFi LED */
0125     GPIO83_GPIO,        /* Charging LED */
0126     GPIO85_GPIO,        /* Charged LED */
0127 
0128     /* I2S */
0129     GPIO28_I2S_BITCLK_OUT,
0130     GPIO29_I2S_SDATA_IN,
0131     GPIO30_I2S_SDATA_OUT,
0132     GPIO31_I2S_SYNC,
0133     GPIO113_I2S_SYSCLK,
0134 
0135     /* MISC */
0136     GPIO0_GPIO,     /* AC power detect */
0137     GPIO1_GPIO,     /* Power button */
0138     GPIO37_GPIO,        /* Headphone detect */
0139     GPIO98_GPIO,        /* Lid switch */
0140     GPIO14_GPIO,        /* WiFi Power */
0141     GPIO24_GPIO,        /* WiFi CS */
0142     GPIO36_GPIO,        /* WiFi IRQ */
0143     GPIO88_GPIO,        /* LCD CS */
0144 };
0145 
0146 /******************************************************************************
0147  * NOR Flash
0148  ******************************************************************************/
0149 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
0150 static struct resource z2_flash_resource = {
0151     .start  = PXA_CS0_PHYS,
0152     .end    = PXA_CS0_PHYS + SZ_8M - 1,
0153     .flags  = IORESOURCE_MEM,
0154 };
0155 
0156 static struct mtd_partition z2_flash_parts[] = {
0157     {
0158         .name   = "U-Boot Bootloader",
0159         .offset = 0x0,
0160         .size   = 0x40000,
0161     }, {
0162         .name   = "U-Boot Environment",
0163         .offset = 0x40000,
0164         .size   = 0x20000,
0165     }, {
0166         .name   = "Flash",
0167         .offset = 0x60000,
0168         .size   = MTDPART_SIZ_FULL,
0169     },
0170 };
0171 
0172 static struct physmap_flash_data z2_flash_data = {
0173     .width      = 2,
0174     .parts      = z2_flash_parts,
0175     .nr_parts   = ARRAY_SIZE(z2_flash_parts),
0176 };
0177 
0178 static struct platform_device z2_flash = {
0179     .name       = "physmap-flash",
0180     .id     = -1,
0181     .resource   = &z2_flash_resource,
0182     .num_resources  = 1,
0183     .dev = {
0184         .platform_data  = &z2_flash_data,
0185     },
0186 };
0187 
0188 static void __init z2_nor_init(void)
0189 {
0190     platform_device_register(&z2_flash);
0191 }
0192 #else
0193 static inline void z2_nor_init(void) {}
0194 #endif
0195 
0196 /******************************************************************************
0197  * Backlight
0198  ******************************************************************************/
0199 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
0200 static struct pwm_lookup z2_pwm_lookup[] = {
0201     PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL, 1260320,
0202            PWM_POLARITY_NORMAL),
0203     PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL, 1260320,
0204            PWM_POLARITY_NORMAL),
0205 };
0206 
0207 static struct platform_pwm_backlight_data z2_backlight_data[] = {
0208     [0] = {
0209         /* Keypad Backlight */
0210         .max_brightness = 1023,
0211         .dft_brightness = 0,
0212     },
0213     [1] = {
0214         /* LCD Backlight */
0215         .max_brightness = 1023,
0216         .dft_brightness = 512,
0217     },
0218 };
0219 
0220 static struct platform_device z2_backlight_devices[2] = {
0221     {
0222         .name   = "pwm-backlight",
0223         .id = 0,
0224         .dev    = {
0225             .platform_data  = &z2_backlight_data[1],
0226         },
0227     },
0228     {
0229         .name   = "pwm-backlight",
0230         .id = 1,
0231         .dev    = {
0232             .platform_data  = &z2_backlight_data[0],
0233         },
0234     },
0235 };
0236 static void __init z2_pwm_init(void)
0237 {
0238     pwm_add_table(z2_pwm_lookup, ARRAY_SIZE(z2_pwm_lookup));
0239     platform_device_register(&z2_backlight_devices[0]);
0240     platform_device_register(&z2_backlight_devices[1]);
0241 }
0242 #else
0243 static inline void z2_pwm_init(void) {}
0244 #endif
0245 
0246 /******************************************************************************
0247  * Framebuffer
0248  ******************************************************************************/
0249 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
0250 static struct pxafb_mode_info z2_lcd_modes[] = {
0251 {
0252     .pixclock   = 192000,
0253     .xres       = 240,
0254     .yres       = 320,
0255     .bpp        = 16,
0256 
0257     .left_margin    = 4,
0258     .right_margin   = 8,
0259     .upper_margin   = 4,
0260     .lower_margin   = 8,
0261 
0262     .hsync_len  = 4,
0263     .vsync_len  = 4,
0264 },
0265 };
0266 
0267 static struct pxafb_mach_info z2_lcd_screen = {
0268     .modes      = z2_lcd_modes,
0269     .num_modes      = ARRAY_SIZE(z2_lcd_modes),
0270     .lcd_conn   = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW |
0271               LCD_ALTERNATE_MAPPING,
0272 };
0273 
0274 static void __init z2_lcd_init(void)
0275 {
0276     pxa_set_fb_info(NULL, &z2_lcd_screen);
0277 }
0278 #else
0279 static inline void z2_lcd_init(void) {}
0280 #endif
0281 
0282 /******************************************************************************
0283  * SD/MMC card controller
0284  ******************************************************************************/
0285 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
0286 static struct pxamci_platform_data z2_mci_platform_data = {
0287     .ocr_mask       = MMC_VDD_32_33 | MMC_VDD_33_34,
0288     .detect_delay_ms    = 200,
0289 };
0290 
0291 static struct gpiod_lookup_table z2_mci_gpio_table = {
0292     .dev_id = "pxa2xx-mci.0",
0293     .table = {
0294         GPIO_LOOKUP("gpio-pxa", GPIO96_ZIPITZ2_SD_DETECT,
0295                 "cd", GPIO_ACTIVE_LOW),
0296         { },
0297     },
0298 };
0299 
0300 static void __init z2_mmc_init(void)
0301 {
0302     gpiod_add_lookup_table(&z2_mci_gpio_table);
0303     pxa_set_mci_info(&z2_mci_platform_data);
0304 }
0305 #else
0306 static inline void z2_mmc_init(void) {}
0307 #endif
0308 
0309 /******************************************************************************
0310  * LEDs
0311  ******************************************************************************/
0312 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
0313 struct gpio_led z2_gpio_leds[] = {
0314 {
0315     .name           = "z2:green:wifi",
0316     .default_trigger    = "none",
0317     .gpio           = GPIO10_ZIPITZ2_LED_WIFI,
0318     .active_low     = 1,
0319 }, {
0320     .name           = "z2:green:charged",
0321     .default_trigger    = "mmc0",
0322     .gpio           = GPIO85_ZIPITZ2_LED_CHARGED,
0323     .active_low     = 1,
0324 }, {
0325     .name           = "z2:amber:charging",
0326     .default_trigger    = "Z2-charging-or-full",
0327     .gpio           = GPIO83_ZIPITZ2_LED_CHARGING,
0328     .active_low     = 1,
0329 },
0330 };
0331 
0332 static struct gpio_led_platform_data z2_gpio_led_info = {
0333     .leds       = z2_gpio_leds,
0334     .num_leds   = ARRAY_SIZE(z2_gpio_leds),
0335 };
0336 
0337 static struct platform_device z2_leds = {
0338     .name   = "leds-gpio",
0339     .id = -1,
0340     .dev    = {
0341         .platform_data  = &z2_gpio_led_info,
0342     }
0343 };
0344 
0345 static void __init z2_leds_init(void)
0346 {
0347     platform_device_register(&z2_leds);
0348 }
0349 #else
0350 static inline void z2_leds_init(void) {}
0351 #endif
0352 
0353 /******************************************************************************
0354  * GPIO keyboard
0355  ******************************************************************************/
0356 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0357 static const unsigned int z2_matrix_keys[] = {
0358     KEY(0, 0, KEY_OPTION),
0359     KEY(1, 0, KEY_UP),
0360     KEY(2, 0, KEY_DOWN),
0361     KEY(3, 0, KEY_LEFT),
0362     KEY(4, 0, KEY_RIGHT),
0363     KEY(5, 0, KEY_END),
0364     KEY(6, 0, KEY_KPPLUS),
0365 
0366     KEY(0, 1, KEY_HOME),
0367     KEY(1, 1, KEY_Q),
0368     KEY(2, 1, KEY_I),
0369     KEY(3, 1, KEY_G),
0370     KEY(4, 1, KEY_X),
0371     KEY(5, 1, KEY_ENTER),
0372     KEY(6, 1, KEY_KPMINUS),
0373 
0374     KEY(0, 2, KEY_PAGEUP),
0375     KEY(1, 2, KEY_W),
0376     KEY(2, 2, KEY_O),
0377     KEY(3, 2, KEY_H),
0378     KEY(4, 2, KEY_C),
0379     KEY(5, 2, KEY_LEFTALT),
0380 
0381     KEY(0, 3, KEY_PAGEDOWN),
0382     KEY(1, 3, KEY_E),
0383     KEY(2, 3, KEY_P),
0384     KEY(3, 3, KEY_J),
0385     KEY(4, 3, KEY_V),
0386     KEY(5, 3, KEY_LEFTSHIFT),
0387 
0388     KEY(0, 4, KEY_ESC),
0389     KEY(1, 4, KEY_R),
0390     KEY(2, 4, KEY_A),
0391     KEY(3, 4, KEY_K),
0392     KEY(4, 4, KEY_B),
0393     KEY(5, 4, KEY_LEFTCTRL),
0394 
0395     KEY(0, 5, KEY_TAB),
0396     KEY(1, 5, KEY_T),
0397     KEY(2, 5, KEY_S),
0398     KEY(3, 5, KEY_L),
0399     KEY(4, 5, KEY_N),
0400     KEY(5, 5, KEY_SPACE),
0401 
0402     KEY(0, 6, KEY_STOPCD),
0403     KEY(1, 6, KEY_Y),
0404     KEY(2, 6, KEY_D),
0405     KEY(3, 6, KEY_BACKSPACE),
0406     KEY(4, 6, KEY_M),
0407     KEY(5, 6, KEY_COMMA),
0408 
0409     KEY(0, 7, KEY_PLAYCD),
0410     KEY(1, 7, KEY_U),
0411     KEY(2, 7, KEY_F),
0412     KEY(3, 7, KEY_Z),
0413     KEY(4, 7, KEY_SEMICOLON),
0414     KEY(5, 7, KEY_DOT),
0415 };
0416 
0417 static struct matrix_keymap_data z2_matrix_keymap_data = {
0418     .keymap         = z2_matrix_keys,
0419     .keymap_size        = ARRAY_SIZE(z2_matrix_keys),
0420 };
0421 
0422 static struct pxa27x_keypad_platform_data z2_keypad_platform_data = {
0423     .matrix_key_rows    = 7,
0424     .matrix_key_cols    = 8,
0425     .matrix_keymap_data = &z2_matrix_keymap_data,
0426 
0427     .debounce_interval  = 30,
0428 };
0429 
0430 static void __init z2_mkp_init(void)
0431 {
0432     pxa_set_keypad_info(&z2_keypad_platform_data);
0433 }
0434 #else
0435 static inline void z2_mkp_init(void) {}
0436 #endif
0437 
0438 /******************************************************************************
0439  * GPIO keys
0440  ******************************************************************************/
0441 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
0442 static struct gpio_keys_button z2_pxa_buttons[] = {
0443     {
0444         .code       = KEY_POWER,
0445         .gpio       = GPIO1_ZIPITZ2_POWER_BUTTON,
0446         .active_low = 0,
0447         .desc       = "Power Button",
0448         .wakeup     = 1,
0449         .type       = EV_KEY,
0450     },
0451     {
0452         .code       = SW_LID,
0453         .gpio       = GPIO98_ZIPITZ2_LID_BUTTON,
0454         .active_low = 1,
0455         .desc       = "Lid Switch",
0456         .wakeup     = 0,
0457         .type       = EV_SW,
0458     },
0459 };
0460 
0461 static struct gpio_keys_platform_data z2_pxa_keys_data = {
0462     .buttons    = z2_pxa_buttons,
0463     .nbuttons   = ARRAY_SIZE(z2_pxa_buttons),
0464 };
0465 
0466 static struct platform_device z2_pxa_keys = {
0467     .name   = "gpio-keys",
0468     .id = -1,
0469     .dev    = {
0470         .platform_data = &z2_pxa_keys_data,
0471     },
0472 };
0473 
0474 static void __init z2_keys_init(void)
0475 {
0476     platform_device_register(&z2_pxa_keys);
0477 }
0478 #else
0479 static inline void z2_keys_init(void) {}
0480 #endif
0481 
0482 /******************************************************************************
0483  * Battery
0484  ******************************************************************************/
0485 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
0486 static struct z2_battery_info batt_chip_info = {
0487     .batt_I2C_bus   = 0,
0488     .batt_I2C_addr  = 0x55,
0489     .batt_I2C_reg   = 2,
0490     .min_voltage    = 3475000,
0491     .max_voltage    = 4190000,
0492     .batt_div   = 59,
0493     .batt_mult  = 1000000,
0494     .batt_tech  = POWER_SUPPLY_TECHNOLOGY_LION,
0495     .batt_name  = "Z2",
0496 };
0497 
0498 static struct gpiod_lookup_table z2_battery_gpio_table = {
0499     .dev_id = "aer915",
0500     .table = {
0501         GPIO_LOOKUP("gpio-pxa", GPIO0_ZIPITZ2_AC_DETECT,
0502                 NULL, GPIO_ACTIVE_HIGH),
0503         { },
0504     },
0505 };
0506 
0507 static struct i2c_board_info __initdata z2_i2c_board_info[] = {
0508     {
0509         I2C_BOARD_INFO("aer915", 0x55),
0510         .dev_name = "aer915",
0511         .platform_data  = &batt_chip_info,
0512     }, {
0513         I2C_BOARD_INFO("wm8750", 0x1b),
0514     },
0515 
0516 };
0517 
0518 static void __init z2_i2c_init(void)
0519 {
0520     pxa_set_i2c_info(NULL);
0521     gpiod_add_lookup_table(&z2_battery_gpio_table);
0522     i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info));
0523 }
0524 #else
0525 static inline void z2_i2c_init(void) {}
0526 #endif
0527 
0528 /******************************************************************************
0529  * SSP Devices - WiFi and LCD control
0530  ******************************************************************************/
0531 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
0532 /* WiFi */
0533 static int z2_lbs_spi_setup(struct spi_device *spi)
0534 {
0535     int ret = 0;
0536 
0537     ret = gpio_request(GPIO14_ZIPITZ2_WIFI_POWER, "WiFi Power");
0538     if (ret)
0539         goto err;
0540 
0541     ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER, 1);
0542     if (ret)
0543         goto err2;
0544 
0545     /* Wait until card is powered on */
0546     mdelay(180);
0547 
0548     spi->bits_per_word = 16;
0549     spi->mode = SPI_MODE_2,
0550 
0551     spi_setup(spi);
0552 
0553     return 0;
0554 
0555 err2:
0556     gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
0557 err:
0558     return ret;
0559 };
0560 
0561 static int z2_lbs_spi_teardown(struct spi_device *spi)
0562 {
0563     gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER, 0);
0564     gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
0565 
0566     return 0;
0567 };
0568 
0569 static struct pxa2xx_spi_chip z2_lbs_chip_info = {
0570     .rx_threshold   = 8,
0571     .tx_threshold   = 8,
0572     .timeout    = 1000,
0573 };
0574 
0575 static struct libertas_spi_platform_data z2_lbs_pdata = {
0576     .use_dummy_writes   = 1,
0577     .setup          = z2_lbs_spi_setup,
0578     .teardown       = z2_lbs_spi_teardown,
0579 };
0580 
0581 /* LCD */
0582 static struct pxa2xx_spi_chip lms283_chip_info = {
0583     .rx_threshold   = 1,
0584     .tx_threshold   = 1,
0585     .timeout    = 64,
0586 };
0587 
0588 static struct gpiod_lookup_table lms283_gpio_table = {
0589     .dev_id = "spi2.0", /* SPI bus 2 chip select 0 */
0590     .table = {
0591         GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET,
0592                 "reset", GPIO_ACTIVE_LOW),
0593         { },
0594     },
0595 };
0596 
0597 static struct spi_board_info spi_board_info[] __initdata = {
0598 {
0599     .modalias       = "libertas_spi",
0600     .platform_data      = &z2_lbs_pdata,
0601     .controller_data    = &z2_lbs_chip_info,
0602     .irq            = PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ),
0603     .max_speed_hz       = 13000000,
0604     .bus_num        = 1,
0605     .chip_select        = 0,
0606 },
0607 {
0608     .modalias       = "lms283gf05",
0609     .controller_data    = &lms283_chip_info,
0610     .max_speed_hz       = 400000,
0611     .bus_num        = 2,
0612     .chip_select        = 0,
0613 },
0614 };
0615 
0616 static struct pxa2xx_spi_controller pxa_ssp1_master_info = {
0617     .num_chipselect = 1,
0618     .enable_dma = 1,
0619 };
0620 
0621 static struct pxa2xx_spi_controller pxa_ssp2_master_info = {
0622     .num_chipselect = 1,
0623 };
0624 
0625 static struct gpiod_lookup_table pxa_ssp1_gpio_table = {
0626     .dev_id = "spi1",
0627     .table = {
0628         GPIO_LOOKUP_IDX("gpio-pxa", GPIO24_ZIPITZ2_WIFI_CS, "cs", 0, GPIO_ACTIVE_LOW),
0629         { },
0630     },
0631 };
0632 
0633 static struct gpiod_lookup_table pxa_ssp2_gpio_table = {
0634     .dev_id = "spi2",
0635     .table = {
0636         GPIO_LOOKUP_IDX("gpio-pxa", GPIO88_ZIPITZ2_LCD_CS, "cs", 0, GPIO_ACTIVE_LOW),
0637         { },
0638     },
0639 };
0640 
0641 static void __init z2_spi_init(void)
0642 {
0643     gpiod_add_lookup_table(&pxa_ssp1_gpio_table);
0644     gpiod_add_lookup_table(&pxa_ssp2_gpio_table);
0645     pxa2xx_set_spi_info(1, &pxa_ssp1_master_info);
0646     pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
0647     gpiod_add_lookup_table(&lms283_gpio_table);
0648     spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
0649 }
0650 #else
0651 static inline void z2_spi_init(void) {}
0652 #endif
0653 
0654 static struct gpiod_lookup_table z2_audio_gpio_table = {
0655     .dev_id = "soc-audio",
0656     .table = {
0657         GPIO_LOOKUP("gpio-pxa", GPIO37_ZIPITZ2_HEADSET_DETECT,
0658                 "hsdet-gpio", GPIO_ACTIVE_HIGH),
0659         { },
0660     },
0661 };
0662 
0663 /******************************************************************************
0664  * Core power regulator
0665  ******************************************************************************/
0666 #if defined(CONFIG_REGULATOR_TPS65023) || \
0667     defined(CONFIG_REGULATOR_TPS65023_MODULE)
0668 static struct regulator_consumer_supply z2_tps65021_consumers[] = {
0669     REGULATOR_SUPPLY("vcc_core", NULL),
0670 };
0671 
0672 static struct regulator_init_data z2_tps65021_info[] = {
0673     {
0674         .constraints = {
0675             .name       = "vcc_core range",
0676             .min_uV     = 800000,
0677             .max_uV     = 1600000,
0678             .always_on  = 1,
0679             .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
0680         },
0681         .consumer_supplies  = z2_tps65021_consumers,
0682         .num_consumer_supplies  = ARRAY_SIZE(z2_tps65021_consumers),
0683     }, {
0684         .constraints = {
0685             .name       = "DCDC2",
0686             .min_uV     = 3300000,
0687             .max_uV     = 3300000,
0688             .always_on  = 1,
0689         },
0690     }, {
0691         .constraints = {
0692             .name       = "DCDC3",
0693             .min_uV     = 1800000,
0694             .max_uV     = 1800000,
0695             .always_on  = 1,
0696         },
0697     }, {
0698         .constraints = {
0699             .name       = "LDO1",
0700             .min_uV     = 1000000,
0701             .max_uV     = 3150000,
0702             .always_on  = 1,
0703         },
0704     }, {
0705         .constraints = {
0706             .name       = "LDO2",
0707             .min_uV     = 1050000,
0708             .max_uV     = 3300000,
0709             .always_on  = 1,
0710         },
0711     }
0712 };
0713 
0714 static struct i2c_board_info __initdata z2_pi2c_board_info[] = {
0715     {
0716         I2C_BOARD_INFO("tps65021", 0x48),
0717         .platform_data  = &z2_tps65021_info,
0718     },
0719 };
0720 
0721 static void __init z2_pmic_init(void)
0722 {
0723     pxa27x_set_i2c_power_info(NULL);
0724     i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info));
0725 }
0726 #else
0727 static inline void z2_pmic_init(void) {}
0728 #endif
0729 
0730 #ifdef CONFIG_PM
0731 static void z2_power_off(void)
0732 {
0733     /* We're using deep sleep as poweroff, so clear PSPR to ensure that
0734      * bootloader will jump to its entry point in resume handler
0735      */
0736     PSPR = 0x0;
0737     local_irq_disable();
0738     pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
0739     pxa27x_cpu_pm_enter(PM_SUSPEND_MEM);
0740 }
0741 #else
0742 #define z2_power_off   NULL
0743 #endif
0744 
0745 /******************************************************************************
0746  * Machine init
0747  ******************************************************************************/
0748 static void __init z2_init(void)
0749 {
0750     pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config));
0751 
0752     pxa_set_ffuart_info(NULL);
0753     pxa_set_btuart_info(NULL);
0754     pxa_set_stuart_info(NULL);
0755 
0756     z2_lcd_init();
0757     z2_mmc_init();
0758     z2_mkp_init();
0759     z2_i2c_init();
0760     z2_spi_init();
0761     z2_nor_init();
0762     z2_pwm_init();
0763     z2_leds_init();
0764     z2_keys_init();
0765     z2_pmic_init();
0766 
0767     gpiod_add_lookup_table(&z2_audio_gpio_table);
0768 
0769     pm_power_off = z2_power_off;
0770 }
0771 
0772 MACHINE_START(ZIPIT2, "Zipit Z2")
0773     .atag_offset    = 0x100,
0774     .map_io     = pxa27x_map_io,
0775     .nr_irqs    = PXA_NR_IRQS,
0776     .init_irq   = pxa27x_init_irq,
0777     .handle_irq = pxa27x_handle_irq,
0778     .init_time  = pxa_timer_init,
0779     .init_machine   = z2_init,
0780     .restart    = pxa_restart,
0781 MACHINE_END