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