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/platform_data/i2c-gpio.h>
29 #include <linux/gpio/machine.h>
31 #include <asm/mach-types.h>
32 #include <asm/suspend.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
37 #include <mach/audio.h>
39 #include <linux/platform_data/mmc-pxamci.h>
40 #include <linux/platform_data/video-pxafb.h>
41 #include <linux/platform_data/irda-pxaficp.h>
42 #include <linux/platform_data/keypad-pxa27x.h>
44 #include <linux/platform_data/asoc-palm27x.h>
48 #include <linux/platform_data/media/camera-pxa.h>
53 /******************************************************************************
55 ******************************************************************************/
56 static unsigned long palmz72_pin_config[] __initdata = {
64 GPIO14_GPIO, /* SD detect */
65 GPIO115_GPIO, /* SD RO */
66 GPIO98_GPIO, /* SD power */
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
77 GPIO49_GPIO, /* ir disable */
85 GPIO15_GPIO, /* usb detect */
86 GPIO95_GPIO, /* usb pullup */
89 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
90 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
91 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
92 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
100 GPIO20_GPIO, /* bl power */
101 GPIO21_GPIO, /* LCD border switch */
102 GPIO22_GPIO, /* LCD border color */
103 GPIO96_GPIO, /* lcd power */
119 GPIO56_GPIO, /* OV9640 Powerdown */
120 GPIO57_GPIO, /* OV9640 Reset */
121 GPIO91_GPIO, /* OV9640 Power */
124 GPIO117_GPIO, /* I2C_SCL */
125 GPIO118_GPIO, /* I2C_SDA */
128 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
129 GPIO88_GPIO, /* green led */
130 GPIO27_GPIO, /* WM9712 IRQ */
133 /******************************************************************************
135 ******************************************************************************/
136 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
137 static const unsigned int palmz72_matrix_keys[] = {
138 KEY(0, 0, KEY_POWER),
140 KEY(0, 2, KEY_ENTER),
149 KEY(3, 0, KEY_RIGHT),
153 static struct matrix_keymap_data almz72_matrix_keymap_data = {
154 .keymap = palmz72_matrix_keys,
155 .keymap_size = ARRAY_SIZE(palmz72_matrix_keys),
158 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
159 .matrix_key_rows = 4,
160 .matrix_key_cols = 3,
161 .matrix_keymap_data = &almz72_matrix_keymap_data,
163 .debounce_interval = 30,
166 static void __init palmz72_kpc_init(void)
168 pxa_set_keypad_info(&palmz72_keypad_platform_data);
171 static inline void palmz72_kpc_init(void) {}
174 /******************************************************************************
176 ******************************************************************************/
177 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
178 static struct gpio_led gpio_leds[] = {
180 .name = "palmz72:green:led",
181 .default_trigger = "none",
182 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
186 static struct gpio_led_platform_data gpio_led_info = {
188 .num_leds = ARRAY_SIZE(gpio_leds),
191 static struct platform_device palmz72_leds = {
195 .platform_data = &gpio_led_info,
199 static void __init palmz72_leds_init(void)
201 platform_device_register(&palmz72_leds);
204 static inline void palmz72_leds_init(void) {}
209 /* We have some black magic here
210 * PalmOS ROM on recover expects special struct physical address
211 * to be transferred via PSPR. Using this struct PalmOS restores
212 * its state after sleep. As for Linux, we need to setup it the
213 * same way. More than that, PalmOS ROM changes some values in memory.
214 * For now only one location is found, which needs special treatment.
215 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
216 * for reading backtraces for me :)
219 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
221 static struct palmz72_resume_info palmz72_resume_info = {
225 /* reset state, MMU off etc */
233 static unsigned long store_ptr;
235 /* syscore_ops for Palm Zire 72 PM */
237 static int palmz72_pm_suspend(void)
239 /* setup the resume_info struct for the original bootloader */
240 palmz72_resume_info.resume_addr = (u32) cpu_resume;
242 /* Storing memory touched by ROM */
243 store_ptr = *PALMZ72_SAVE_DWORD;
245 /* Setting PSPR to a proper value */
246 PSPR = __pa_symbol(&palmz72_resume_info);
251 static void palmz72_pm_resume(void)
253 *PALMZ72_SAVE_DWORD = store_ptr;
256 static struct syscore_ops palmz72_pm_syscore_ops = {
257 .suspend = palmz72_pm_suspend,
258 .resume = palmz72_pm_resume,
261 static int __init palmz72_pm_init(void)
263 if (machine_is_palmz72()) {
264 register_syscore_ops(&palmz72_pm_syscore_ops);
270 device_initcall(palmz72_pm_init);
273 static struct gpiod_lookup_table palmz72_mci_gpio_table = {
274 .dev_id = "pxa2xx-mci.0",
276 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N,
277 "cd", GPIO_ACTIVE_LOW),
278 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO,
279 "wp", GPIO_ACTIVE_LOW),
280 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N,
281 "power", GPIO_ACTIVE_LOW),
286 /******************************************************************************
288 ******************************************************************************/
289 static void __init palmz72_init(void)
291 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
292 pxa_set_ffuart_info(NULL);
293 pxa_set_btuart_info(NULL);
294 pxa_set_stuart_info(NULL);
296 palm27x_mmc_init(&palmz72_mci_gpio_table);
297 palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
298 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
299 GPIO_NR_PALMZ72_USB_PULLUP, 0);
300 palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
301 palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
303 palm27x_pwm_init(-1, -1);
304 palm27x_power_init(-1, -1);
310 MACHINE_START(PALMZ72, "Palm Zire72")
311 .atag_offset = 0x100,
312 .map_io = pxa27x_map_io,
313 .nr_irqs = PXA_NR_IRQS,
314 .init_irq = pxa27x_init_irq,
315 .handle_irq = pxa27x_handle_irq,
316 .init_time = pxa_timer_init,
317 .init_machine = palmz72_init,
318 .restart = pxa_restart,