blob: b2dff9d415ebf69eedba22393913e74075bb75ac [file] [log] [blame]
Sergey Lapinc49e1e62008-08-29 15:47:52 +01001/*
2 * Hardware definitions for Palm Zire72
3 *
4 * Authors:
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>
9 *
10 * Rewrite for mainline:
11 * Marek Vasut <marek.vasut@gmail.com>
12 *
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.
16 *
17 * (find more info at www.hackndev.com)
18 *
19 */
20
21#include <linux/platform_device.h>
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +020022#include <linux/syscore_ops.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010023#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>
Marek Vasut241cf472010-06-04 03:07:33 +020030#include <linux/wm97xx.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010031#include <linux/power_supply.h>
Marek Vasuteb73e622009-06-01 22:34:14 +020032#include <linux/usb/gpio_vbus.h>
Marek Vasut54a93b62011-01-13 11:45:30 +010033#include <linux/i2c-gpio.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010034
35#include <asm/mach-types.h>
Russell King2c74a0c2011-06-22 17:41:48 +010036#include <asm/suspend.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010037#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
Eric Miao51c62982009-01-02 23:17:22 +080040#include <mach/pxa27x.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010041#include <mach/audio.h>
42#include <mach/palmz72.h>
43#include <mach/mmc.h>
44#include <mach/pxafb.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010045#include <mach/irda.h>
Mark F. Brown4a2490e2010-09-03 18:28:06 -040046#include <plat/pxa27x_keypad.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010047#include <mach/udc.h>
Marek Vasuteb73e622009-06-01 22:34:14 +020048#include <mach/palmasoc.h>
Marek Vasut31620e22010-07-13 08:16:45 +020049#include <mach/palm27x.h>
Marek Vasuteb73e622009-06-01 22:34:14 +020050
Sergey Lapinc49e1e62008-08-29 15:47:52 +010051#include <mach/pm.h>
Marek Vasut54a93b62011-01-13 11:45:30 +010052#include <mach/camera.h>
53
54#include <media/soc_camera.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010055
56#include "generic.h"
57#include "devices.h"
58
59/******************************************************************************
60 * Pin configuration
61 ******************************************************************************/
62static unsigned long palmz72_pin_config[] __initdata = {
63 /* MMC */
64 GPIO32_MMC_CLK,
65 GPIO92_MMC_DAT_0,
66 GPIO109_MMC_DAT_1,
67 GPIO110_MMC_DAT_2,
68 GPIO111_MMC_DAT_3,
69 GPIO112_MMC_CMD,
70 GPIO14_GPIO, /* SD detect */
71 GPIO115_GPIO, /* SD RO */
72 GPIO98_GPIO, /* SD power */
73
74 /* AC97 */
75 GPIO28_AC97_BITCLK,
76 GPIO29_AC97_SDATA_IN_0,
77 GPIO30_AC97_SDATA_OUT,
78 GPIO31_AC97_SYNC,
Marek Vasuteb73e622009-06-01 22:34:14 +020079 GPIO89_AC97_SYSCLK,
80 GPIO113_AC97_nRESET,
Sergey Lapinc49e1e62008-08-29 15:47:52 +010081
82 /* IrDA */
83 GPIO49_GPIO, /* ir disable */
84 GPIO46_FICP_RXD,
85 GPIO47_FICP_TXD,
86
87 /* PWM */
88 GPIO16_PWM0_OUT,
89
90 /* USB */
91 GPIO15_GPIO, /* usb detect */
Marek Vasuteb73e622009-06-01 22:34:14 +020092 GPIO95_GPIO, /* usb pullup */
Sergey Lapinc49e1e62008-08-29 15:47:52 +010093
94 /* Matrix keypad */
95 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
96 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
97 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
98 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
99 GPIO103_KP_MKOUT_0,
100 GPIO104_KP_MKOUT_1,
101 GPIO105_KP_MKOUT_2,
102
103 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800104 GPIOxx_LCD_TFT_16BPP,
105
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100106 GPIO20_GPIO, /* bl power */
107 GPIO21_GPIO, /* LCD border switch */
108 GPIO22_GPIO, /* LCD border color */
109 GPIO96_GPIO, /* lcd power */
110
Marek Vasut54a93b62011-01-13 11:45:30 +0100111 /* PXA Camera */
112 GPIO81_CIF_DD_0,
113 GPIO48_CIF_DD_5,
114 GPIO50_CIF_DD_3,
115 GPIO51_CIF_DD_2,
116 GPIO52_CIF_DD_4,
117 GPIO53_CIF_MCLK,
118 GPIO54_CIF_PCLK,
119 GPIO55_CIF_DD_1,
120 GPIO84_CIF_FV,
121 GPIO85_CIF_LV,
122 GPIO93_CIF_DD_6,
123 GPIO108_CIF_DD_7,
124
125 GPIO56_GPIO, /* OV9640 Powerdown */
126 GPIO57_GPIO, /* OV9640 Reset */
127 GPIO91_GPIO, /* OV9640 Power */
128
129 /* I2C */
130 GPIO117_GPIO, /* I2C_SCL */
131 GPIO118_GPIO, /* I2C_SDA */
132
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100133 /* Misc. */
134 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
135 GPIO88_GPIO, /* green led */
136 GPIO27_GPIO, /* WM9712 IRQ */
137};
138
139/******************************************************************************
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100140 * GPIO keyboard
141 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200142#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100143static unsigned int palmz72_matrix_keys[] = {
144 KEY(0, 0, KEY_POWER),
145 KEY(0, 1, KEY_F1),
146 KEY(0, 2, KEY_ENTER),
147
148 KEY(1, 0, KEY_F2),
149 KEY(1, 1, KEY_F3),
150 KEY(1, 2, KEY_F4),
151
152 KEY(2, 0, KEY_UP),
153 KEY(2, 2, KEY_DOWN),
154
155 KEY(3, 0, KEY_RIGHT),
156 KEY(3, 2, KEY_LEFT),
157};
158
159static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
160 .matrix_key_rows = 4,
161 .matrix_key_cols = 3,
162 .matrix_key_map = palmz72_matrix_keys,
163 .matrix_key_map_size = ARRAY_SIZE(palmz72_matrix_keys),
164
165 .debounce_interval = 30,
166};
167
Marek Vasut31620e22010-07-13 08:16:45 +0200168static void __init palmz72_kpc_init(void)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100169{
Marek Vasut31620e22010-07-13 08:16:45 +0200170 pxa_set_keypad_info(&palmz72_keypad_platform_data);
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100171}
Marek Vasut31620e22010-07-13 08:16:45 +0200172#else
173static inline void palmz72_kpc_init(void) {}
174#endif
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100175
176/******************************************************************************
177 * LEDs
178 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200179#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100180static struct gpio_led gpio_leds[] = {
181 {
182 .name = "palmz72:green:led",
183 .default_trigger = "none",
184 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
185 },
186};
187
188static struct gpio_led_platform_data gpio_led_info = {
189 .leds = gpio_leds,
190 .num_leds = ARRAY_SIZE(gpio_leds),
191};
192
193static struct platform_device palmz72_leds = {
194 .name = "leds-gpio",
195 .id = -1,
196 .dev = {
197 .platform_data = &gpio_led_info,
198 }
199};
200
Marek Vasut31620e22010-07-13 08:16:45 +0200201static void __init palmz72_leds_init(void)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100202{
Marek Vasut31620e22010-07-13 08:16:45 +0200203 platform_device_register(&palmz72_leds);
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100204}
Marek Vasut31620e22010-07-13 08:16:45 +0200205#else
206static inline void palmz72_leds_init(void) {}
207#endif
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100208
Sergey Lapinfda50a12008-08-29 15:53:24 +0100209#ifdef CONFIG_PM
210
211/* We have some black magic here
212 * PalmOS ROM on recover expects special struct physical address
213 * to be transferred via PSPR. Using this struct PalmOS restores
214 * its state after sleep. As for Linux, we need to setup it the
215 * same way. More than that, PalmOS ROM changes some values in memory.
216 * For now only one location is found, which needs special treatment.
217 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
218 * for reading backtraces for me :)
219 */
220
221#define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
222
223static struct palmz72_resume_info palmz72_resume_info = {
224 .magic0 = 0xb4e6,
225 .magic1 = 1,
226
227 /* reset state, MMU off etc */
228 .arm_control = 0,
229 .aux_control = 0,
230 .ttb = 0,
231 .domain_access = 0,
232 .process_id = 0,
233};
234
235static unsigned long store_ptr;
236
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200237/* syscore_ops for Palm Zire 72 PM */
Sergey Lapinfda50a12008-08-29 15:53:24 +0100238
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200239static int palmz72_pm_suspend(void)
Sergey Lapinfda50a12008-08-29 15:53:24 +0100240{
241 /* setup the resume_info struct for the original bootloader */
Russell King4f5ad992011-02-06 17:41:26 +0000242 palmz72_resume_info.resume_addr = (u32) cpu_resume;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100243
244 /* Storing memory touched by ROM */
245 store_ptr = *PALMZ72_SAVE_DWORD;
246
247 /* Setting PSPR to a proper value */
248 PSPR = virt_to_phys(&palmz72_resume_info);
249
250 return 0;
251}
252
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200253static void palmz72_pm_resume(void)
Sergey Lapinfda50a12008-08-29 15:53:24 +0100254{
255 *PALMZ72_SAVE_DWORD = store_ptr;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100256}
257
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200258static struct syscore_ops palmz72_pm_syscore_ops = {
Sergey Lapinfda50a12008-08-29 15:53:24 +0100259 .suspend = palmz72_pm_suspend,
260 .resume = palmz72_pm_resume,
261};
262
Sergey Lapinfda50a12008-08-29 15:53:24 +0100263static int __init palmz72_pm_init(void)
264{
Sergey Lapinfda50a12008-08-29 15:53:24 +0100265 if (machine_is_palmz72()) {
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200266 register_syscore_ops(&palmz72_pm_syscore_ops);
267 return 0;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100268 }
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200269 return -ENODEV;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100270}
271
272device_initcall(palmz72_pm_init);
273#endif
274
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100275/******************************************************************************
Marek Vasut54a93b62011-01-13 11:45:30 +0100276 * SoC Camera
277 ******************************************************************************/
278#if defined(CONFIG_SOC_CAMERA_OV9640) || \
279 defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
280static struct pxacamera_platform_data palmz72_pxacamera_platform_data = {
281 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
282 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
283 .mclk_10khz = 2600,
284};
285
286/* Board I2C devices. */
287static struct i2c_board_info palmz72_i2c_device[] = {
288 {
289 I2C_BOARD_INFO("ov9640", 0x30),
290 }
291};
292
293static int palmz72_camera_power(struct device *dev, int power)
294{
295 gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN, !power);
296 mdelay(50);
297 return 0;
298}
299
300static int palmz72_camera_reset(struct device *dev)
301{
302 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 1);
303 mdelay(50);
304 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 0);
305 mdelay(50);
306 return 0;
307}
308
309static struct soc_camera_link palmz72_iclink = {
310 .bus_id = 0, /* Match id in pxa27x_device_camera in device.c */
311 .board_info = &palmz72_i2c_device[0],
312 .i2c_adapter_id = 0,
313 .module_name = "ov96xx",
314 .power = &palmz72_camera_power,
315 .reset = &palmz72_camera_reset,
316 .flags = SOCAM_DATAWIDTH_8,
317};
318
319static struct i2c_gpio_platform_data palmz72_i2c_bus_data = {
320 .sda_pin = 118,
321 .scl_pin = 117,
322 .udelay = 10,
323 .timeout = 100,
324};
325
326static struct platform_device palmz72_i2c_bus_device = {
327 .name = "i2c-gpio",
328 .id = 0, /* we use this as a replacement for i2c-pxa */
329 .dev = {
330 .platform_data = &palmz72_i2c_bus_data,
331 }
332};
333
334static struct platform_device palmz72_camera = {
335 .name = "soc-camera-pdrv",
336 .id = -1,
337 .dev = {
338 .platform_data = &palmz72_iclink,
339 },
340};
341
342/* Here we request the camera GPIOs and configure them. We power up the camera
343 * module, deassert the reset pin, but put it into powerdown (low to no power
344 * consumption) mode. This allows us to later bring the module up fast. */
345static struct gpio palmz72_camera_gpios[] = {
346 { GPIO_NR_PALMZ72_CAM_POWER, GPIOF_INIT_HIGH,"Camera DVDD" },
347 { GPIO_NR_PALMZ72_CAM_RESET, GPIOF_INIT_LOW, "Camera RESET" },
348 { GPIO_NR_PALMZ72_CAM_PWDN, GPIOF_INIT_LOW, "Camera PWDN" },
349};
350
351static inline void __init palmz72_cam_gpio_init(void)
352{
353 int ret;
354
355 ret = gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
356 if (!ret)
357 gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
358 else
359 printk(KERN_ERR "Camera GPIO init failed!\n");
360
361 return;
362}
363
364static void __init palmz72_camera_init(void)
365{
366 palmz72_cam_gpio_init();
367 pxa_set_camera_info(&palmz72_pxacamera_platform_data);
368 platform_device_register(&palmz72_i2c_bus_device);
369 platform_device_register(&palmz72_camera);
370}
371#else
372static inline void palmz72_camera_init(void) {}
373#endif
374
375/******************************************************************************
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100376 * Machine init
377 ******************************************************************************/
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100378static void __init palmz72_init(void)
379{
380 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800381 pxa_set_ffuart_info(NULL);
382 pxa_set_btuart_info(NULL);
383 pxa_set_stuart_info(NULL);
384
Marek Vasut31620e22010-07-13 08:16:45 +0200385 palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO,
386 GPIO_NR_PALMZ72_SD_POWER_N, 1);
387 palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
388 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
389 GPIO_NR_PALMZ72_USB_PULLUP, 0);
390 palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
391 palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
392 -1, 113);
393 palm27x_pwm_init(-1, -1);
394 palm27x_power_init(-1, -1);
395 palm27x_pmic_init();
396 palmz72_kpc_init();
397 palmz72_leds_init();
Marek Vasut54a93b62011-01-13 11:45:30 +0100398 palmz72_camera_init();
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100399}
400
401MACHINE_START(PALMZ72, "Palm Zire72")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400402 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200403 .map_io = pxa27x_map_io,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100404 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800405 .handle_irq = pxa27x_handle_irq,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100406 .timer = &pxa_timer,
Russell King271a74f2011-11-04 14:15:53 +0000407 .init_machine = palmz72_init,
408 .restart = pxa_restart,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100409MACHINE_END