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/sysdev.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>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
39 #include <mach/pxa27x.h>
40 #include <mach/audio.h>
41 #include <mach/palmz72.h>
43 #include <mach/pxafb.h>
44 #include <mach/irda.h>
45 #include <plat/pxa27x_keypad.h>
47 #include <mach/palmasoc.h>
48 #include <mach/palm27x.h>
51 #include <mach/camera.h>
53 #include <media/soc_camera.h>
58 /******************************************************************************
60 ******************************************************************************/
61 static unsigned long palmz72_pin_config[] __initdata = {
69 GPIO14_GPIO, /* SD detect */
70 GPIO115_GPIO, /* SD RO */
71 GPIO98_GPIO, /* SD power */
75 GPIO29_AC97_SDATA_IN_0,
76 GPIO30_AC97_SDATA_OUT,
82 GPIO49_GPIO, /* ir disable */
90 GPIO15_GPIO, /* usb detect */
91 GPIO95_GPIO, /* usb pullup */
94 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
95 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
96 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
97 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
103 GPIOxx_LCD_TFT_16BPP,
105 GPIO20_GPIO, /* bl power */
106 GPIO21_GPIO, /* LCD border switch */
107 GPIO22_GPIO, /* LCD border color */
108 GPIO96_GPIO, /* lcd power */
124 GPIO56_GPIO, /* OV9640 Powerdown */
125 GPIO57_GPIO, /* OV9640 Reset */
126 GPIO91_GPIO, /* OV9640 Power */
129 GPIO117_GPIO, /* I2C_SCL */
130 GPIO118_GPIO, /* I2C_SDA */
133 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
134 GPIO88_GPIO, /* green led */
135 GPIO27_GPIO, /* WM9712 IRQ */
138 /******************************************************************************
140 ******************************************************************************/
141 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
142 static unsigned int palmz72_matrix_keys[] = {
143 KEY(0, 0, KEY_POWER),
145 KEY(0, 2, KEY_ENTER),
154 KEY(3, 0, KEY_RIGHT),
158 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
159 .matrix_key_rows = 4,
160 .matrix_key_cols = 3,
161 .matrix_key_map = palmz72_matrix_keys,
162 .matrix_key_map_size = ARRAY_SIZE(palmz72_matrix_keys),
164 .debounce_interval = 30,
167 static void __init palmz72_kpc_init(void)
169 pxa_set_keypad_info(&palmz72_keypad_platform_data);
172 static inline void palmz72_kpc_init(void) {}
175 /******************************************************************************
177 ******************************************************************************/
178 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
179 static struct gpio_led gpio_leds[] = {
181 .name = "palmz72:green:led",
182 .default_trigger = "none",
183 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
187 static struct gpio_led_platform_data gpio_led_info = {
189 .num_leds = ARRAY_SIZE(gpio_leds),
192 static struct platform_device palmz72_leds = {
196 .platform_data = &gpio_led_info,
200 static void __init palmz72_leds_init(void)
202 platform_device_register(&palmz72_leds);
205 static inline void palmz72_leds_init(void) {}
210 /* We have some black magic here
211 * PalmOS ROM on recover expects special struct physical address
212 * to be transferred via PSPR. Using this struct PalmOS restores
213 * its state after sleep. As for Linux, we need to setup it the
214 * same way. More than that, PalmOS ROM changes some values in memory.
215 * For now only one location is found, which needs special treatment.
216 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
217 * for reading backtraces for me :)
220 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
222 static struct palmz72_resume_info palmz72_resume_info = {
226 /* reset state, MMU off etc */
234 static unsigned long store_ptr;
236 /* sys_device for Palm Zire 72 PM */
238 static int palmz72_pm_suspend(struct sys_device *dev, pm_message_t msg)
240 /* setup the resume_info struct for the original bootloader */
241 palmz72_resume_info.resume_addr = (u32) cpu_resume;
243 /* Storing memory touched by ROM */
244 store_ptr = *PALMZ72_SAVE_DWORD;
246 /* Setting PSPR to a proper value */
247 PSPR = virt_to_phys(&palmz72_resume_info);
252 static int palmz72_pm_resume(struct sys_device *dev)
254 *PALMZ72_SAVE_DWORD = store_ptr;
258 static struct sysdev_class palmz72_pm_sysclass = {
259 .name = "palmz72_pm",
260 .suspend = palmz72_pm_suspend,
261 .resume = palmz72_pm_resume,
264 static struct sys_device palmz72_pm_device = {
265 .cls = &palmz72_pm_sysclass,
268 static int __init palmz72_pm_init(void)
271 if (machine_is_palmz72()) {
272 ret = sysdev_class_register(&palmz72_pm_sysclass);
274 ret = sysdev_register(&palmz72_pm_device);
279 device_initcall(palmz72_pm_init);
282 /******************************************************************************
284 ******************************************************************************/
285 #if defined(CONFIG_SOC_CAMERA_OV9640) || \
286 defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
287 static struct pxacamera_platform_data palmz72_pxacamera_platform_data = {
288 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
289 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
293 /* Board I2C devices. */
294 static struct i2c_board_info palmz72_i2c_device[] = {
296 I2C_BOARD_INFO("ov9640", 0x30),
300 static int palmz72_camera_power(struct device *dev, int power)
302 gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN, !power);
307 static int palmz72_camera_reset(struct device *dev)
309 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 1);
311 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 0);
316 static struct soc_camera_link palmz72_iclink = {
317 .bus_id = 0, /* Match id in pxa27x_device_camera in device.c */
318 .board_info = &palmz72_i2c_device[0],
320 .module_name = "ov96xx",
321 .power = &palmz72_camera_power,
322 .reset = &palmz72_camera_reset,
323 .flags = SOCAM_DATAWIDTH_8,
326 static struct i2c_gpio_platform_data palmz72_i2c_bus_data = {
333 static struct platform_device palmz72_i2c_bus_device = {
335 .id = 0, /* we use this as a replacement for i2c-pxa */
337 .platform_data = &palmz72_i2c_bus_data,
341 static struct platform_device palmz72_camera = {
342 .name = "soc-camera-pdrv",
345 .platform_data = &palmz72_iclink,
349 /* Here we request the camera GPIOs and configure them. We power up the camera
350 * module, deassert the reset pin, but put it into powerdown (low to no power
351 * consumption) mode. This allows us to later bring the module up fast. */
352 static struct gpio palmz72_camera_gpios[] = {
353 { GPIO_NR_PALMZ72_CAM_POWER, GPIOF_INIT_HIGH,"Camera DVDD" },
354 { GPIO_NR_PALMZ72_CAM_RESET, GPIOF_INIT_LOW, "Camera RESET" },
355 { GPIO_NR_PALMZ72_CAM_PWDN, GPIOF_INIT_LOW, "Camera PWDN" },
358 static inline void __init palmz72_cam_gpio_init(void)
362 ret = gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
364 gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
366 printk(KERN_ERR "Camera GPIO init failed!\n");
371 static void __init palmz72_camera_init(void)
373 palmz72_cam_gpio_init();
374 pxa_set_camera_info(&palmz72_pxacamera_platform_data);
375 platform_device_register(&palmz72_i2c_bus_device);
376 platform_device_register(&palmz72_camera);
379 static inline void palmz72_camera_init(void) {}
382 /******************************************************************************
384 ******************************************************************************/
385 static void __init palmz72_init(void)
387 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
388 pxa_set_ffuart_info(NULL);
389 pxa_set_btuart_info(NULL);
390 pxa_set_stuart_info(NULL);
392 palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO,
393 GPIO_NR_PALMZ72_SD_POWER_N, 1);
394 palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
395 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
396 GPIO_NR_PALMZ72_USB_PULLUP, 0);
397 palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
398 palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
400 palm27x_pwm_init(-1, -1);
401 palm27x_power_init(-1, -1);
405 palmz72_camera_init();
408 MACHINE_START(PALMZ72, "Palm Zire72")
409 .boot_params = 0xa0000100,
410 .map_io = pxa27x_map_io,
411 .init_irq = pxa27x_init_irq,
413 .init_machine = palmz72_init