2 * Hardware definitions for Palm Zire72
5 * Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
6 * Sergey Lapin <slapin@ossfans.org>
7 * Alex Osborne <bobofdoom@gmail.com>
8 * Jan Herman <2hp@seznam.cz>
10 * Rewrite for mainline:
11 * Marek Vasut <marek.vasut@gmail.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * (find more info at www.hackndev.com)
21 #include <linux/platform_device.h>
22 #include <linux/syscore_ops.h>
23 #include <linux/delay.h>
24 #include <linux/irq.h>
25 #include <linux/gpio_keys.h>
26 #include <linux/input.h>
27 #include <linux/pda_power.h>
28 #include <linux/pwm_backlight.h>
29 #include <linux/gpio.h>
30 #include <linux/wm97xx.h>
31 #include <linux/power_supply.h>
32 #include <linux/usb/gpio_vbus.h>
33 #include <linux/i2c-gpio.h>
34 #include <linux/gpio/machine.h>
36 #include <asm/mach-types.h>
37 #include <asm/suspend.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
42 #include <mach/audio.h>
44 #include <linux/platform_data/mmc-pxamci.h>
45 #include <linux/platform_data/video-pxafb.h>
46 #include <linux/platform_data/irda-pxaficp.h>
47 #include <linux/platform_data/keypad-pxa27x.h>
49 #include <linux/platform_data/asoc-palm27x.h>
53 #include <linux/platform_data/media/camera-pxa.h>
55 #include <media/soc_camera.h>
60 /******************************************************************************
62 ******************************************************************************/
63 static unsigned long palmz72_pin_config
[] __initdata
= {
71 GPIO14_GPIO
, /* SD detect */
72 GPIO115_GPIO
, /* SD RO */
73 GPIO98_GPIO
, /* SD power */
77 GPIO29_AC97_SDATA_IN_0
,
78 GPIO30_AC97_SDATA_OUT
,
84 GPIO49_GPIO
, /* ir disable */
92 GPIO15_GPIO
, /* usb detect */
93 GPIO95_GPIO
, /* usb pullup */
96 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
97 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
98 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
99 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
105 GPIOxx_LCD_TFT_16BPP
,
107 GPIO20_GPIO
, /* bl power */
108 GPIO21_GPIO
, /* LCD border switch */
109 GPIO22_GPIO
, /* LCD border color */
110 GPIO96_GPIO
, /* lcd power */
126 GPIO56_GPIO
, /* OV9640 Powerdown */
127 GPIO57_GPIO
, /* OV9640 Reset */
128 GPIO91_GPIO
, /* OV9640 Power */
131 GPIO117_GPIO
, /* I2C_SCL */
132 GPIO118_GPIO
, /* I2C_SDA */
135 GPIO0_GPIO
| WAKEUP_ON_LEVEL_HIGH
, /* power detect */
136 GPIO88_GPIO
, /* green led */
137 GPIO27_GPIO
, /* WM9712 IRQ */
140 /******************************************************************************
142 ******************************************************************************/
143 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
144 static const unsigned int palmz72_matrix_keys
[] = {
145 KEY(0, 0, KEY_POWER
),
147 KEY(0, 2, KEY_ENTER
),
156 KEY(3, 0, KEY_RIGHT
),
160 static struct matrix_keymap_data almz72_matrix_keymap_data
= {
161 .keymap
= palmz72_matrix_keys
,
162 .keymap_size
= ARRAY_SIZE(palmz72_matrix_keys
),
165 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data
= {
166 .matrix_key_rows
= 4,
167 .matrix_key_cols
= 3,
168 .matrix_keymap_data
= &almz72_matrix_keymap_data
,
170 .debounce_interval
= 30,
173 static void __init
palmz72_kpc_init(void)
175 pxa_set_keypad_info(&palmz72_keypad_platform_data
);
178 static inline void palmz72_kpc_init(void) {}
181 /******************************************************************************
183 ******************************************************************************/
184 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
185 static struct gpio_led gpio_leds
[] = {
187 .name
= "palmz72:green:led",
188 .default_trigger
= "none",
189 .gpio
= GPIO_NR_PALMZ72_LED_GREEN
,
193 static struct gpio_led_platform_data gpio_led_info
= {
195 .num_leds
= ARRAY_SIZE(gpio_leds
),
198 static struct platform_device palmz72_leds
= {
202 .platform_data
= &gpio_led_info
,
206 static void __init
palmz72_leds_init(void)
208 platform_device_register(&palmz72_leds
);
211 static inline void palmz72_leds_init(void) {}
216 /* We have some black magic here
217 * PalmOS ROM on recover expects special struct physical address
218 * to be transferred via PSPR. Using this struct PalmOS restores
219 * its state after sleep. As for Linux, we need to setup it the
220 * same way. More than that, PalmOS ROM changes some values in memory.
221 * For now only one location is found, which needs special treatment.
222 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
223 * for reading backtraces for me :)
226 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
228 static struct palmz72_resume_info palmz72_resume_info
= {
232 /* reset state, MMU off etc */
240 static unsigned long store_ptr
;
242 /* syscore_ops for Palm Zire 72 PM */
244 static int palmz72_pm_suspend(void)
246 /* setup the resume_info struct for the original bootloader */
247 palmz72_resume_info
.resume_addr
= (u32
) cpu_resume
;
249 /* Storing memory touched by ROM */
250 store_ptr
= *PALMZ72_SAVE_DWORD
;
252 /* Setting PSPR to a proper value */
253 PSPR
= __pa_symbol(&palmz72_resume_info
);
258 static void palmz72_pm_resume(void)
260 *PALMZ72_SAVE_DWORD
= store_ptr
;
263 static struct syscore_ops palmz72_pm_syscore_ops
= {
264 .suspend
= palmz72_pm_suspend
,
265 .resume
= palmz72_pm_resume
,
268 static int __init
palmz72_pm_init(void)
270 if (machine_is_palmz72()) {
271 register_syscore_ops(&palmz72_pm_syscore_ops
);
277 device_initcall(palmz72_pm_init
);
280 /******************************************************************************
282 ******************************************************************************/
283 #if defined(CONFIG_SOC_CAMERA_OV9640) || \
284 defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
285 static struct pxacamera_platform_data palmz72_pxacamera_platform_data
= {
286 .flags
= PXA_CAMERA_MASTER
| PXA_CAMERA_DATAWIDTH_8
|
287 PXA_CAMERA_PCLK_EN
| PXA_CAMERA_MCLK_EN
,
291 /* Board I2C devices. */
292 static struct i2c_board_info palmz72_i2c_device
[] = {
294 I2C_BOARD_INFO("ov9640", 0x30),
298 static int palmz72_camera_power(struct device
*dev
, int power
)
300 gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN
, !power
);
305 static int palmz72_camera_reset(struct device
*dev
)
307 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET
, 1);
309 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET
, 0);
314 static struct soc_camera_link palmz72_iclink
= {
315 .bus_id
= 0, /* Match id in pxa27x_device_camera in device.c */
316 .board_info
= &palmz72_i2c_device
[0],
318 .module_name
= "ov96xx",
319 .power
= &palmz72_camera_power
,
320 .reset
= &palmz72_camera_reset
,
321 .flags
= SOCAM_DATAWIDTH_8
,
324 static struct gpiod_lookup_table palmz72_i2c_gpiod_table
= {
325 .dev_id
= "i2c-gpio",
327 GPIO_LOOKUP_IDX("gpio-pxa", 118, NULL
, 0,
328 GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
329 GPIO_LOOKUP_IDX("gpio-pxa", 117, NULL
, 1,
330 GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
334 static struct i2c_gpio_platform_data palmz72_i2c_bus_data
= {
339 static struct platform_device palmz72_i2c_bus_device
= {
341 .id
= 0, /* we use this as a replacement for i2c-pxa */
343 .platform_data
= &palmz72_i2c_bus_data
,
347 static struct platform_device palmz72_camera
= {
348 .name
= "soc-camera-pdrv",
351 .platform_data
= &palmz72_iclink
,
355 /* Here we request the camera GPIOs and configure them. We power up the camera
356 * module, deassert the reset pin, but put it into powerdown (low to no power
357 * consumption) mode. This allows us to later bring the module up fast. */
358 static struct gpio palmz72_camera_gpios
[] = {
359 { GPIO_NR_PALMZ72_CAM_POWER
, GPIOF_INIT_HIGH
,"Camera DVDD" },
360 { GPIO_NR_PALMZ72_CAM_RESET
, GPIOF_INIT_LOW
, "Camera RESET" },
361 { GPIO_NR_PALMZ72_CAM_PWDN
, GPIOF_INIT_LOW
, "Camera PWDN" },
364 static inline void __init
palmz72_cam_gpio_init(void)
368 ret
= gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios
));
370 gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios
));
372 printk(KERN_ERR
"Camera GPIO init failed!\n");
377 static void __init
palmz72_camera_init(void)
379 palmz72_cam_gpio_init();
380 pxa_set_camera_info(&palmz72_pxacamera_platform_data
);
381 gpiod_add_lookup_table(&palmz72_i2c_gpiod_table
);
382 platform_device_register(&palmz72_i2c_bus_device
);
383 platform_device_register(&palmz72_camera
);
386 static inline void palmz72_camera_init(void) {}
389 /******************************************************************************
391 ******************************************************************************/
392 static void __init
palmz72_init(void)
394 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config
));
395 pxa_set_ffuart_info(NULL
);
396 pxa_set_btuart_info(NULL
);
397 pxa_set_stuart_info(NULL
);
399 palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N
, GPIO_NR_PALMZ72_SD_RO
,
400 GPIO_NR_PALMZ72_SD_POWER_N
, 1);
401 palm27x_lcd_init(-1, &palm_320x320_lcd_mode
);
402 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N
,
403 GPIO_NR_PALMZ72_USB_PULLUP
, 0);
404 palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE
);
405 palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE
, PALMZ72_BAT_MAX_VOLTAGE
,
407 palm27x_pwm_init(-1, -1);
408 palm27x_power_init(-1, -1);
412 palmz72_camera_init();
415 MACHINE_START(PALMZ72
, "Palm Zire72")
416 .atag_offset
= 0x100,
417 .map_io
= pxa27x_map_io
,
418 .nr_irqs
= PXA_NR_IRQS
,
419 .init_irq
= pxa27x_init_irq
,
420 .handle_irq
= pxa27x_handle_irq
,
421 .init_time
= pxa_timer_init
,
422 .init_machine
= palmz72_init
,
423 .restart
= pxa_restart
,