blob: 4d475f6f4a777081d2e0c9c695ad7ceb26ab399f [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>
Wolfram Sang1e9d4212018-04-19 22:00:07 +020033#include <linux/platform_data/i2c-gpio.h>
Linus Walleijb2e63552017-09-10 01:30:46 +020034#include <linux/gpio/machine.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010035
36#include <asm/mach-types.h>
Russell King2c74a0c2011-06-22 17:41:48 +010037#include <asm/suspend.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010038#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010041#include "pxa27x.h"
Sergey Lapinc49e1e62008-08-29 15:47:52 +010042#include <mach/audio.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010043#include "palmz72.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020044#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>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010048#include "udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020049#include <linux/platform_data/asoc-palm27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010050#include "palm27x.h"
Marek Vasuteb73e622009-06-01 22:34:14 +020051
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010052#include "pm.h"
Mauro Carvalho Chehaba71daaa2015-11-17 07:11:13 -020053#include <linux/platform_data/media/camera-pxa.h>
Marek Vasut54a93b62011-01-13 11:45:30 +010054
55#include <media/soc_camera.h>
Sergey Lapinc49e1e62008-08-29 15:47:52 +010056
57#include "generic.h"
58#include "devices.h"
59
60/******************************************************************************
61 * Pin configuration
62 ******************************************************************************/
63static unsigned long palmz72_pin_config[] __initdata = {
64 /* MMC */
65 GPIO32_MMC_CLK,
66 GPIO92_MMC_DAT_0,
67 GPIO109_MMC_DAT_1,
68 GPIO110_MMC_DAT_2,
69 GPIO111_MMC_DAT_3,
70 GPIO112_MMC_CMD,
71 GPIO14_GPIO, /* SD detect */
72 GPIO115_GPIO, /* SD RO */
73 GPIO98_GPIO, /* SD power */
74
75 /* AC97 */
76 GPIO28_AC97_BITCLK,
77 GPIO29_AC97_SDATA_IN_0,
78 GPIO30_AC97_SDATA_OUT,
79 GPIO31_AC97_SYNC,
Marek Vasuteb73e622009-06-01 22:34:14 +020080 GPIO89_AC97_SYSCLK,
81 GPIO113_AC97_nRESET,
Sergey Lapinc49e1e62008-08-29 15:47:52 +010082
83 /* IrDA */
84 GPIO49_GPIO, /* ir disable */
85 GPIO46_FICP_RXD,
86 GPIO47_FICP_TXD,
87
88 /* PWM */
89 GPIO16_PWM0_OUT,
90
91 /* USB */
92 GPIO15_GPIO, /* usb detect */
Marek Vasuteb73e622009-06-01 22:34:14 +020093 GPIO95_GPIO, /* usb pullup */
Sergey Lapinc49e1e62008-08-29 15:47:52 +010094
95 /* Matrix keypad */
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,
100 GPIO103_KP_MKOUT_0,
101 GPIO104_KP_MKOUT_1,
102 GPIO105_KP_MKOUT_2,
103
104 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800105 GPIOxx_LCD_TFT_16BPP,
106
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100107 GPIO20_GPIO, /* bl power */
108 GPIO21_GPIO, /* LCD border switch */
109 GPIO22_GPIO, /* LCD border color */
110 GPIO96_GPIO, /* lcd power */
111
Marek Vasut54a93b62011-01-13 11:45:30 +0100112 /* PXA Camera */
113 GPIO81_CIF_DD_0,
114 GPIO48_CIF_DD_5,
115 GPIO50_CIF_DD_3,
116 GPIO51_CIF_DD_2,
117 GPIO52_CIF_DD_4,
118 GPIO53_CIF_MCLK,
119 GPIO54_CIF_PCLK,
120 GPIO55_CIF_DD_1,
121 GPIO84_CIF_FV,
122 GPIO85_CIF_LV,
123 GPIO93_CIF_DD_6,
124 GPIO108_CIF_DD_7,
125
126 GPIO56_GPIO, /* OV9640 Powerdown */
127 GPIO57_GPIO, /* OV9640 Reset */
128 GPIO91_GPIO, /* OV9640 Power */
129
130 /* I2C */
131 GPIO117_GPIO, /* I2C_SCL */
132 GPIO118_GPIO, /* I2C_SDA */
133
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100134 /* Misc. */
135 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
136 GPIO88_GPIO, /* green led */
137 GPIO27_GPIO, /* WM9712 IRQ */
138};
139
140/******************************************************************************
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100141 * GPIO keyboard
142 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200143#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700144static const unsigned int palmz72_matrix_keys[] = {
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100145 KEY(0, 0, KEY_POWER),
146 KEY(0, 1, KEY_F1),
147 KEY(0, 2, KEY_ENTER),
148
149 KEY(1, 0, KEY_F2),
150 KEY(1, 1, KEY_F3),
151 KEY(1, 2, KEY_F4),
152
153 KEY(2, 0, KEY_UP),
154 KEY(2, 2, KEY_DOWN),
155
156 KEY(3, 0, KEY_RIGHT),
157 KEY(3, 2, KEY_LEFT),
158};
159
Chao Xie0a085a92013-05-05 20:24:58 -0700160static struct matrix_keymap_data almz72_matrix_keymap_data = {
161 .keymap = palmz72_matrix_keys,
162 .keymap_size = ARRAY_SIZE(palmz72_matrix_keys),
163};
164
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100165static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
166 .matrix_key_rows = 4,
167 .matrix_key_cols = 3,
Chao Xie0a085a92013-05-05 20:24:58 -0700168 .matrix_keymap_data = &almz72_matrix_keymap_data,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100169
170 .debounce_interval = 30,
171};
172
Marek Vasut31620e22010-07-13 08:16:45 +0200173static void __init palmz72_kpc_init(void)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100174{
Marek Vasut31620e22010-07-13 08:16:45 +0200175 pxa_set_keypad_info(&palmz72_keypad_platform_data);
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100176}
Marek Vasut31620e22010-07-13 08:16:45 +0200177#else
178static inline void palmz72_kpc_init(void) {}
179#endif
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100180
181/******************************************************************************
182 * LEDs
183 ******************************************************************************/
Marek Vasut31620e22010-07-13 08:16:45 +0200184#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100185static struct gpio_led gpio_leds[] = {
186 {
187 .name = "palmz72:green:led",
188 .default_trigger = "none",
189 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
190 },
191};
192
193static struct gpio_led_platform_data gpio_led_info = {
194 .leds = gpio_leds,
195 .num_leds = ARRAY_SIZE(gpio_leds),
196};
197
198static struct platform_device palmz72_leds = {
199 .name = "leds-gpio",
200 .id = -1,
201 .dev = {
202 .platform_data = &gpio_led_info,
203 }
204};
205
Marek Vasut31620e22010-07-13 08:16:45 +0200206static void __init palmz72_leds_init(void)
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100207{
Marek Vasut31620e22010-07-13 08:16:45 +0200208 platform_device_register(&palmz72_leds);
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100209}
Marek Vasut31620e22010-07-13 08:16:45 +0200210#else
211static inline void palmz72_leds_init(void) {}
212#endif
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100213
Sergey Lapinfda50a12008-08-29 15:53:24 +0100214#ifdef CONFIG_PM
215
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 :)
224 */
225
226#define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
227
228static struct palmz72_resume_info palmz72_resume_info = {
229 .magic0 = 0xb4e6,
230 .magic1 = 1,
231
232 /* reset state, MMU off etc */
233 .arm_control = 0,
234 .aux_control = 0,
235 .ttb = 0,
236 .domain_access = 0,
237 .process_id = 0,
238};
239
240static unsigned long store_ptr;
241
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200242/* syscore_ops for Palm Zire 72 PM */
Sergey Lapinfda50a12008-08-29 15:53:24 +0100243
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200244static int palmz72_pm_suspend(void)
Sergey Lapinfda50a12008-08-29 15:53:24 +0100245{
246 /* setup the resume_info struct for the original bootloader */
Russell King4f5ad992011-02-06 17:41:26 +0000247 palmz72_resume_info.resume_addr = (u32) cpu_resume;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100248
249 /* Storing memory touched by ROM */
250 store_ptr = *PALMZ72_SAVE_DWORD;
251
252 /* Setting PSPR to a proper value */
Florian Fainelli64fc2a92017-01-15 03:59:29 +0100253 PSPR = __pa_symbol(&palmz72_resume_info);
Sergey Lapinfda50a12008-08-29 15:53:24 +0100254
255 return 0;
256}
257
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200258static void palmz72_pm_resume(void)
Sergey Lapinfda50a12008-08-29 15:53:24 +0100259{
260 *PALMZ72_SAVE_DWORD = store_ptr;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100261}
262
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200263static struct syscore_ops palmz72_pm_syscore_ops = {
Sergey Lapinfda50a12008-08-29 15:53:24 +0100264 .suspend = palmz72_pm_suspend,
265 .resume = palmz72_pm_resume,
266};
267
Sergey Lapinfda50a12008-08-29 15:53:24 +0100268static int __init palmz72_pm_init(void)
269{
Sergey Lapinfda50a12008-08-29 15:53:24 +0100270 if (machine_is_palmz72()) {
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200271 register_syscore_ops(&palmz72_pm_syscore_ops);
272 return 0;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100273 }
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200274 return -ENODEV;
Sergey Lapinfda50a12008-08-29 15:53:24 +0100275}
276
277device_initcall(palmz72_pm_init);
278#endif
279
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100280/******************************************************************************
Marek Vasut54a93b62011-01-13 11:45:30 +0100281 * SoC Camera
282 ******************************************************************************/
283#if defined(CONFIG_SOC_CAMERA_OV9640) || \
284 defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
285static 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,
288 .mclk_10khz = 2600,
289};
290
291/* Board I2C devices. */
292static struct i2c_board_info palmz72_i2c_device[] = {
293 {
294 I2C_BOARD_INFO("ov9640", 0x30),
295 }
296};
297
298static int palmz72_camera_power(struct device *dev, int power)
299{
300 gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN, !power);
301 mdelay(50);
302 return 0;
303}
304
305static int palmz72_camera_reset(struct device *dev)
306{
307 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 1);
308 mdelay(50);
309 gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 0);
310 mdelay(50);
311 return 0;
312}
313
314static 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],
317 .i2c_adapter_id = 0,
318 .module_name = "ov96xx",
319 .power = &palmz72_camera_power,
320 .reset = &palmz72_camera_reset,
321 .flags = SOCAM_DATAWIDTH_8,
322};
323
Linus Walleijb2e63552017-09-10 01:30:46 +0200324static struct gpiod_lookup_table palmz72_i2c_gpiod_table = {
Linus Walleijf59c3032018-05-26 18:37:34 +0200325 .dev_id = "i2c-gpio.0",
Linus Walleijb2e63552017-09-10 01:30:46 +0200326 .table = {
Linus Walleij4d0ce622017-09-10 23:03:32 +0200327 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),
Linus Walleijb2e63552017-09-10 01:30:46 +0200331 },
332};
333
Marek Vasut54a93b62011-01-13 11:45:30 +0100334static struct i2c_gpio_platform_data palmz72_i2c_bus_data = {
Marek Vasut54a93b62011-01-13 11:45:30 +0100335 .udelay = 10,
336 .timeout = 100,
337};
338
339static struct platform_device palmz72_i2c_bus_device = {
340 .name = "i2c-gpio",
341 .id = 0, /* we use this as a replacement for i2c-pxa */
342 .dev = {
343 .platform_data = &palmz72_i2c_bus_data,
344 }
345};
346
347static struct platform_device palmz72_camera = {
348 .name = "soc-camera-pdrv",
349 .id = -1,
350 .dev = {
351 .platform_data = &palmz72_iclink,
352 },
353};
354
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. */
358static 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" },
362};
363
364static inline void __init palmz72_cam_gpio_init(void)
365{
366 int ret;
367
368 ret = gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
369 if (!ret)
370 gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
371 else
372 printk(KERN_ERR "Camera GPIO init failed!\n");
373
374 return;
375}
376
377static void __init palmz72_camera_init(void)
378{
379 palmz72_cam_gpio_init();
380 pxa_set_camera_info(&palmz72_pxacamera_platform_data);
Linus Walleijb2e63552017-09-10 01:30:46 +0200381 gpiod_add_lookup_table(&palmz72_i2c_gpiod_table);
Marek Vasut54a93b62011-01-13 11:45:30 +0100382 platform_device_register(&palmz72_i2c_bus_device);
383 platform_device_register(&palmz72_camera);
384}
385#else
386static inline void palmz72_camera_init(void) {}
387#endif
388
389/******************************************************************************
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100390 * Machine init
391 ******************************************************************************/
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100392static void __init palmz72_init(void)
393{
394 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800395 pxa_set_ffuart_info(NULL);
396 pxa_set_btuart_info(NULL);
397 pxa_set_stuart_info(NULL);
398
Marek Vasut31620e22010-07-13 08:16:45 +0200399 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,
406 -1, 113);
407 palm27x_pwm_init(-1, -1);
408 palm27x_power_init(-1, -1);
409 palm27x_pmic_init();
410 palmz72_kpc_init();
411 palmz72_leds_init();
Marek Vasut54a93b62011-01-13 11:45:30 +0100412 palmz72_camera_init();
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100413}
414
415MACHINE_START(PALMZ72, "Palm Zire72")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400416 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200417 .map_io = pxa27x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600418 .nr_irqs = PXA_NR_IRQS,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100419 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800420 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700421 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000422 .init_machine = palmz72_init,
423 .restart = pxa_restart,
Sergey Lapinc49e1e62008-08-29 15:47:52 +0100424MACHINE_END