Linux Audio

Check our new training course

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