1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hardware definitions for Palm Zire72
6 * Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
7 * Sergey Lapin <slapin@ossfans.org>
8 * Alex Osborne <bobofdoom@gmail.com>
9 * Jan Herman <2hp@seznam.cz>
11 * Rewrite for mainline:
12 * Marek Vasut <marek.vasut@gmail.com>
14 * (find more info at www.hackndev.com)
17 #include <linux/platform_device.h>
18 #include <linux/syscore_ops.h>
19 #include <linux/delay.h>
20 #include <linux/irq.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/pda_power.h>
24 #include <linux/pwm_backlight.h>
25 #include <linux/gpio.h>
26 #include <linux/wm97xx.h>
27 #include <linux/power_supply.h>
28 #include <linux/usb/gpio_vbus.h>
29 #include <linux/platform_data/i2c-gpio.h>
30 #include <linux/gpio/machine.h>
32 #include <asm/mach-types.h>
33 #include <asm/suspend.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
38 #include <mach/audio.h>
40 #include <linux/platform_data/mmc-pxamci.h>
41 #include <linux/platform_data/video-pxafb.h>
42 #include <linux/platform_data/irda-pxaficp.h>
43 #include <linux/platform_data/keypad-pxa27x.h>
45 #include <linux/platform_data/asoc-palm27x.h>
49 #include <linux/platform_data/media/camera-pxa.h>
51 #include <media/soc_camera.h>
56 /******************************************************************************
58 ******************************************************************************/
59 static unsigned long palmz72_pin_config[] __initdata = {
67 GPIO14_GPIO, /* SD detect */
68 GPIO115_GPIO, /* SD RO */
69 GPIO98_GPIO, /* SD power */
73 GPIO29_AC97_SDATA_IN_0,
74 GPIO30_AC97_SDATA_OUT,
80 GPIO49_GPIO, /* ir disable */
88 GPIO15_GPIO, /* usb detect */
89 GPIO95_GPIO, /* usb pullup */
92 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
93 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
94 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
95 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
101 GPIOxx_LCD_TFT_16BPP,
103 GPIO20_GPIO, /* bl power */
104 GPIO21_GPIO, /* LCD border switch */
105 GPIO22_GPIO, /* LCD border color */
106 GPIO96_GPIO, /* lcd power */
122 GPIO56_GPIO, /* OV9640 Powerdown */
123 GPIO57_GPIO, /* OV9640 Reset */
124 GPIO91_GPIO, /* OV9640 Power */
127 GPIO117_GPIO, /* I2C_SCL */
128 GPIO118_GPIO, /* I2C_SDA */
131 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
132 GPIO88_GPIO, /* green led */
133 GPIO27_GPIO, /* WM9712 IRQ */
136 /******************************************************************************
138 ******************************************************************************/
139 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
140 static const unsigned int palmz72_matrix_keys[] = {
141 KEY(0, 0, KEY_POWER),
143 KEY(0, 2, KEY_ENTER),
152 KEY(3, 0, KEY_RIGHT),
156 static struct matrix_keymap_data almz72_matrix_keymap_data = {
157 .keymap = palmz72_matrix_keys,
158 .keymap_size = ARRAY_SIZE(palmz72_matrix_keys),
161 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
162 .matrix_key_rows = 4,
163 .matrix_key_cols = 3,
164 .matrix_keymap_data = &almz72_matrix_keymap_data,
166 .debounce_interval = 30,
169 static void __init palmz72_kpc_init(void)
171 pxa_set_keypad_info(&palmz72_keypad_platform_data);
174 static inline void palmz72_kpc_init(void) {}
177 /******************************************************************************
179 ******************************************************************************/
180 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
181 static struct gpio_led gpio_leds[] = {
183 .name = "palmz72:green:led",
184 .default_trigger = "none",
185 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
189 static struct gpio_led_platform_data gpio_led_info = {
191 .num_leds = ARRAY_SIZE(gpio_leds),
194 static struct platform_device palmz72_leds = {
198 .platform_data = &gpio_led_info,
202 static void __init palmz72_leds_init(void)
204 platform_device_register(&palmz72_leds);
207 static inline void palmz72_leds_init(void) {}
212 /* We have some black magic here
213 * PalmOS ROM on recover expects special struct physical address
214 * to be transferred via PSPR. Using this struct PalmOS restores
215 * its state after sleep. As for Linux, we need to setup it the
216 * same way. More than that, PalmOS ROM changes some values in memory.
217 * For now only one location is found, which needs special treatment.
218 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
219 * for reading backtraces for me :)
222 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
224 static struct palmz72_resume_info palmz72_resume_info = {
228 /* reset state, MMU off etc */
236 static unsigned long store_ptr;
238 /* syscore_ops for Palm Zire 72 PM */
240 static int palmz72_pm_suspend(void)
242 /* setup the resume_info struct for the original bootloader */
243 palmz72_resume_info.resume_addr = (u32) cpu_resume;
245 /* Storing memory touched by ROM */
246 store_ptr = *PALMZ72_SAVE_DWORD;
248 /* Setting PSPR to a proper value */
249 PSPR = __pa_symbol(&palmz72_resume_info);
254 static void palmz72_pm_resume(void)
256 *PALMZ72_SAVE_DWORD = store_ptr;
259 static struct syscore_ops palmz72_pm_syscore_ops = {
260 .suspend = palmz72_pm_suspend,
261 .resume = palmz72_pm_resume,
264 static int __init palmz72_pm_init(void)
266 if (machine_is_palmz72()) {
267 register_syscore_ops(&palmz72_pm_syscore_ops);
273 device_initcall(palmz72_pm_init);
276 /******************************************************************************
278 ******************************************************************************/
279 #if defined(CONFIG_SOC_CAMERA_OV9640) || \
280 defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
281 static struct pxacamera_platform_data palmz72_pxacamera_platform_data = {
282 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
283 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
287 /* Board I2C devices. */
288 static struct i2c_board_info palmz72_i2c_device[] = {
290 I2C_BOARD_INFO("ov9640", 0x30),
294 static int palmz72_camera_power(struct device *dev, int power)
296 gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN, !power);
301 static int palmz72_camera_reset(struct device *dev)
303 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 1);
305 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 0);
310 static struct soc_camera_link palmz72_iclink = {
311 .bus_id = 0, /* Match id in pxa27x_device_camera in device.c */
312 .board_info = &palmz72_i2c_device[0],
314 .module_name = "ov96xx",
315 .power = &palmz72_camera_power,
316 .reset = &palmz72_camera_reset,
317 .flags = SOCAM_DATAWIDTH_8,
320 static struct gpiod_lookup_table palmz72_i2c_gpiod_table = {
321 .dev_id = "i2c-gpio.0",
323 GPIO_LOOKUP_IDX("gpio-pxa", 118, NULL, 0,
324 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
325 GPIO_LOOKUP_IDX("gpio-pxa", 117, NULL, 1,
326 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
330 static struct i2c_gpio_platform_data palmz72_i2c_bus_data = {
335 static struct platform_device palmz72_i2c_bus_device = {
337 .id = 0, /* we use this as a replacement for i2c-pxa */
339 .platform_data = &palmz72_i2c_bus_data,
343 static struct platform_device palmz72_camera = {
344 .name = "soc-camera-pdrv",
347 .platform_data = &palmz72_iclink,
351 /* Here we request the camera GPIOs and configure them. We power up the camera
352 * module, deassert the reset pin, but put it into powerdown (low to no power
353 * consumption) mode. This allows us to later bring the module up fast. */
354 static struct gpio palmz72_camera_gpios[] = {
355 { GPIO_NR_PALMZ72_CAM_POWER, GPIOF_INIT_HIGH,"Camera DVDD" },
356 { GPIO_NR_PALMZ72_CAM_RESET, GPIOF_INIT_LOW, "Camera RESET" },
357 { GPIO_NR_PALMZ72_CAM_PWDN, GPIOF_INIT_LOW, "Camera PWDN" },
360 static inline void __init palmz72_cam_gpio_init(void)
364 ret = gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
366 gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
368 printk(KERN_ERR "Camera GPIO init failed!\n");
373 static void __init palmz72_camera_init(void)
375 palmz72_cam_gpio_init();
376 pxa_set_camera_info(&palmz72_pxacamera_platform_data);
377 gpiod_add_lookup_table(&palmz72_i2c_gpiod_table);
378 platform_device_register(&palmz72_i2c_bus_device);
379 platform_device_register(&palmz72_camera);
382 static inline void palmz72_camera_init(void) {}
385 static struct gpiod_lookup_table palmz72_mci_gpio_table = {
386 .dev_id = "pxa2xx-mci.0",
388 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N,
389 "cd", GPIO_ACTIVE_LOW),
390 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO,
391 "wp", GPIO_ACTIVE_LOW),
392 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N,
393 "power", GPIO_ACTIVE_LOW),
398 /******************************************************************************
400 ******************************************************************************/
401 static void __init palmz72_init(void)
403 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
404 pxa_set_ffuart_info(NULL);
405 pxa_set_btuart_info(NULL);
406 pxa_set_stuart_info(NULL);
408 palm27x_mmc_init(&palmz72_mci_gpio_table);
409 palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
410 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
411 GPIO_NR_PALMZ72_USB_PULLUP, 0);
412 palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
413 palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
415 palm27x_pwm_init(-1, -1);
416 palm27x_power_init(-1, -1);
420 palmz72_camera_init();
423 MACHINE_START(PALMZ72, "Palm Zire72")
424 .atag_offset = 0x100,
425 .map_io = pxa27x_map_io,
426 .nr_irqs = PXA_NR_IRQS,
427 .init_irq = pxa27x_init_irq,
428 .handle_irq = pxa27x_handle_irq,
429 .init_time = pxa_timer_init,
430 .init_machine = palmz72_init,
431 .restart = pxa_restart,