Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 1 | /* |
| 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> |
| 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> |
Marek Vasut | 241cf47 | 2010-06-04 03:07:33 +0200 | [diff] [blame] | 30 | #include <linux/wm97xx.h> |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 31 | #include <linux/power_supply.h> |
Marek Vasut | eb73e62 | 2009-06-01 22:34:14 +0200 | [diff] [blame] | 32 | #include <linux/usb/gpio_vbus.h> |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 33 | |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/map.h> |
| 37 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 38 | #include <mach/pxa27x.h> |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 39 | #include <mach/audio.h> |
| 40 | #include <mach/palmz72.h> |
| 41 | #include <mach/mmc.h> |
| 42 | #include <mach/pxafb.h> |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 43 | #include <mach/irda.h> |
Mark F. Brown | 4a2490e | 2010-09-03 18:28:06 -0400 | [diff] [blame] | 44 | #include <plat/pxa27x_keypad.h> |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 45 | #include <mach/udc.h> |
Marek Vasut | eb73e62 | 2009-06-01 22:34:14 +0200 | [diff] [blame] | 46 | #include <mach/palmasoc.h> |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 47 | #include <mach/palm27x.h> |
Marek Vasut | eb73e62 | 2009-06-01 22:34:14 +0200 | [diff] [blame] | 48 | |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 49 | #include <mach/pm.h> |
| 50 | |
| 51 | #include "generic.h" |
| 52 | #include "devices.h" |
| 53 | |
| 54 | /****************************************************************************** |
| 55 | * Pin configuration |
| 56 | ******************************************************************************/ |
| 57 | static unsigned long palmz72_pin_config[] __initdata = { |
| 58 | /* MMC */ |
| 59 | GPIO32_MMC_CLK, |
| 60 | GPIO92_MMC_DAT_0, |
| 61 | GPIO109_MMC_DAT_1, |
| 62 | GPIO110_MMC_DAT_2, |
| 63 | GPIO111_MMC_DAT_3, |
| 64 | GPIO112_MMC_CMD, |
| 65 | GPIO14_GPIO, /* SD detect */ |
| 66 | GPIO115_GPIO, /* SD RO */ |
| 67 | GPIO98_GPIO, /* SD power */ |
| 68 | |
| 69 | /* AC97 */ |
| 70 | GPIO28_AC97_BITCLK, |
| 71 | GPIO29_AC97_SDATA_IN_0, |
| 72 | GPIO30_AC97_SDATA_OUT, |
| 73 | GPIO31_AC97_SYNC, |
Marek Vasut | eb73e62 | 2009-06-01 22:34:14 +0200 | [diff] [blame] | 74 | GPIO89_AC97_SYSCLK, |
| 75 | GPIO113_AC97_nRESET, |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 76 | |
| 77 | /* IrDA */ |
| 78 | GPIO49_GPIO, /* ir disable */ |
| 79 | GPIO46_FICP_RXD, |
| 80 | GPIO47_FICP_TXD, |
| 81 | |
| 82 | /* PWM */ |
| 83 | GPIO16_PWM0_OUT, |
| 84 | |
| 85 | /* USB */ |
| 86 | GPIO15_GPIO, /* usb detect */ |
Marek Vasut | eb73e62 | 2009-06-01 22:34:14 +0200 | [diff] [blame] | 87 | GPIO95_GPIO, /* usb pullup */ |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 88 | |
| 89 | /* Matrix keypad */ |
| 90 | GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH, |
| 91 | GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH, |
| 92 | GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH, |
| 93 | GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH, |
| 94 | GPIO103_KP_MKOUT_0, |
| 95 | GPIO104_KP_MKOUT_1, |
| 96 | GPIO105_KP_MKOUT_2, |
| 97 | |
| 98 | /* LCD */ |
Eric Miao | bedbda9 | 2010-01-04 11:37:14 +0800 | [diff] [blame] | 99 | GPIOxx_LCD_TFT_16BPP, |
| 100 | |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 101 | GPIO20_GPIO, /* bl power */ |
| 102 | GPIO21_GPIO, /* LCD border switch */ |
| 103 | GPIO22_GPIO, /* LCD border color */ |
| 104 | GPIO96_GPIO, /* lcd power */ |
| 105 | |
| 106 | /* Misc. */ |
| 107 | GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */ |
| 108 | GPIO88_GPIO, /* green led */ |
| 109 | GPIO27_GPIO, /* WM9712 IRQ */ |
| 110 | }; |
| 111 | |
| 112 | /****************************************************************************** |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 113 | * GPIO keyboard |
| 114 | ******************************************************************************/ |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 115 | #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 116 | static unsigned int palmz72_matrix_keys[] = { |
| 117 | KEY(0, 0, KEY_POWER), |
| 118 | KEY(0, 1, KEY_F1), |
| 119 | KEY(0, 2, KEY_ENTER), |
| 120 | |
| 121 | KEY(1, 0, KEY_F2), |
| 122 | KEY(1, 1, KEY_F3), |
| 123 | KEY(1, 2, KEY_F4), |
| 124 | |
| 125 | KEY(2, 0, KEY_UP), |
| 126 | KEY(2, 2, KEY_DOWN), |
| 127 | |
| 128 | KEY(3, 0, KEY_RIGHT), |
| 129 | KEY(3, 2, KEY_LEFT), |
| 130 | }; |
| 131 | |
| 132 | static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = { |
| 133 | .matrix_key_rows = 4, |
| 134 | .matrix_key_cols = 3, |
| 135 | .matrix_key_map = palmz72_matrix_keys, |
| 136 | .matrix_key_map_size = ARRAY_SIZE(palmz72_matrix_keys), |
| 137 | |
| 138 | .debounce_interval = 30, |
| 139 | }; |
| 140 | |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 141 | static void __init palmz72_kpc_init(void) |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 142 | { |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 143 | pxa_set_keypad_info(&palmz72_keypad_platform_data); |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 144 | } |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 145 | #else |
| 146 | static inline void palmz72_kpc_init(void) {} |
| 147 | #endif |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 148 | |
| 149 | /****************************************************************************** |
| 150 | * LEDs |
| 151 | ******************************************************************************/ |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 152 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 153 | static struct gpio_led gpio_leds[] = { |
| 154 | { |
| 155 | .name = "palmz72:green:led", |
| 156 | .default_trigger = "none", |
| 157 | .gpio = GPIO_NR_PALMZ72_LED_GREEN, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | static struct gpio_led_platform_data gpio_led_info = { |
| 162 | .leds = gpio_leds, |
| 163 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 164 | }; |
| 165 | |
| 166 | static struct platform_device palmz72_leds = { |
| 167 | .name = "leds-gpio", |
| 168 | .id = -1, |
| 169 | .dev = { |
| 170 | .platform_data = &gpio_led_info, |
| 171 | } |
| 172 | }; |
| 173 | |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 174 | static void __init palmz72_leds_init(void) |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 175 | { |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 176 | platform_device_register(&palmz72_leds); |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 177 | } |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 178 | #else |
| 179 | static inline void palmz72_leds_init(void) {} |
| 180 | #endif |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 181 | |
Sergey Lapin | fda50a1 | 2008-08-29 15:53:24 +0100 | [diff] [blame] | 182 | #ifdef CONFIG_PM |
| 183 | |
| 184 | /* We have some black magic here |
| 185 | * PalmOS ROM on recover expects special struct physical address |
| 186 | * to be transferred via PSPR. Using this struct PalmOS restores |
| 187 | * its state after sleep. As for Linux, we need to setup it the |
| 188 | * same way. More than that, PalmOS ROM changes some values in memory. |
| 189 | * For now only one location is found, which needs special treatment. |
| 190 | * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people |
| 191 | * for reading backtraces for me :) |
| 192 | */ |
| 193 | |
| 194 | #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050) |
| 195 | |
| 196 | static struct palmz72_resume_info palmz72_resume_info = { |
| 197 | .magic0 = 0xb4e6, |
| 198 | .magic1 = 1, |
| 199 | |
| 200 | /* reset state, MMU off etc */ |
| 201 | .arm_control = 0, |
| 202 | .aux_control = 0, |
| 203 | .ttb = 0, |
| 204 | .domain_access = 0, |
| 205 | .process_id = 0, |
| 206 | }; |
| 207 | |
| 208 | static unsigned long store_ptr; |
| 209 | |
| 210 | /* sys_device for Palm Zire 72 PM */ |
| 211 | |
| 212 | static int palmz72_pm_suspend(struct sys_device *dev, pm_message_t msg) |
| 213 | { |
| 214 | /* setup the resume_info struct for the original bootloader */ |
Russell King | 4f5ad99 | 2011-02-06 17:41:26 +0000 | [diff] [blame^] | 215 | palmz72_resume_info.resume_addr = (u32) cpu_resume; |
Sergey Lapin | fda50a1 | 2008-08-29 15:53:24 +0100 | [diff] [blame] | 216 | |
| 217 | /* Storing memory touched by ROM */ |
| 218 | store_ptr = *PALMZ72_SAVE_DWORD; |
| 219 | |
| 220 | /* Setting PSPR to a proper value */ |
| 221 | PSPR = virt_to_phys(&palmz72_resume_info); |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | static int palmz72_pm_resume(struct sys_device *dev) |
| 227 | { |
| 228 | *PALMZ72_SAVE_DWORD = store_ptr; |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | static struct sysdev_class palmz72_pm_sysclass = { |
| 233 | .name = "palmz72_pm", |
| 234 | .suspend = palmz72_pm_suspend, |
| 235 | .resume = palmz72_pm_resume, |
| 236 | }; |
| 237 | |
| 238 | static struct sys_device palmz72_pm_device = { |
| 239 | .cls = &palmz72_pm_sysclass, |
| 240 | }; |
| 241 | |
| 242 | static int __init palmz72_pm_init(void) |
| 243 | { |
| 244 | int ret = -ENODEV; |
| 245 | if (machine_is_palmz72()) { |
| 246 | ret = sysdev_class_register(&palmz72_pm_sysclass); |
| 247 | if (ret == 0) |
| 248 | ret = sysdev_register(&palmz72_pm_device); |
| 249 | } |
| 250 | return ret; |
| 251 | } |
| 252 | |
| 253 | device_initcall(palmz72_pm_init); |
| 254 | #endif |
| 255 | |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 256 | /****************************************************************************** |
| 257 | * Machine init |
| 258 | ******************************************************************************/ |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 259 | static void __init palmz72_init(void) |
| 260 | { |
| 261 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config)); |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 262 | pxa_set_ffuart_info(NULL); |
| 263 | pxa_set_btuart_info(NULL); |
| 264 | pxa_set_stuart_info(NULL); |
| 265 | |
Marek Vasut | 31620e2 | 2010-07-13 08:16:45 +0200 | [diff] [blame] | 266 | palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO, |
| 267 | GPIO_NR_PALMZ72_SD_POWER_N, 1); |
| 268 | palm27x_lcd_init(-1, &palm_320x320_lcd_mode); |
| 269 | palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N, |
| 270 | GPIO_NR_PALMZ72_USB_PULLUP, 0); |
| 271 | palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE); |
| 272 | palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE, |
| 273 | -1, 113); |
| 274 | palm27x_pwm_init(-1, -1); |
| 275 | palm27x_power_init(-1, -1); |
| 276 | palm27x_pmic_init(); |
| 277 | palmz72_kpc_init(); |
| 278 | palmz72_leds_init(); |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | MACHINE_START(PALMZ72, "Palm Zire72") |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 282 | .boot_params = 0xa0000100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 283 | .map_io = pxa27x_map_io, |
Sergey Lapin | c49e1e6 | 2008-08-29 15:47:52 +0100 | [diff] [blame] | 284 | .init_irq = pxa27x_init_irq, |
| 285 | .timer = &pxa_timer, |
| 286 | .init_machine = palmz72_init |
| 287 | MACHINE_END |