linux/arch/arm/mach-pxa/palmz72.c
<<
>>
Prefs
   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>
  30#include <linux/wm97xx.h>
  31#include <linux/power_supply.h>
  32#include <linux/usb/gpio_vbus.h>
  33
  34#include <asm/mach-types.h>
  35#include <asm/mach/arch.h>
  36#include <asm/mach/map.h>
  37
  38#include <mach/pxa27x.h>
  39#include <mach/audio.h>
  40#include <mach/palmz72.h>
  41#include <mach/mmc.h>
  42#include <mach/pxafb.h>
  43#include <mach/irda.h>
  44#include <plat/pxa27x_keypad.h>
  45#include <mach/udc.h>
  46#include <mach/palmasoc.h>
  47#include <mach/palm27x.h>
  48
  49#include <mach/pm.h>
  50
  51#include "generic.h"
  52#include "devices.h"
  53
  54/******************************************************************************
  55 * Pin configuration
  56 ******************************************************************************/
  57static 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,
  74        GPIO89_AC97_SYSCLK,
  75        GPIO113_AC97_nRESET,
  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 */
  87        GPIO95_GPIO,    /* usb pullup */
  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 */
  99        GPIOxx_LCD_TFT_16BPP,
 100
 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/******************************************************************************
 113 * GPIO keyboard
 114 ******************************************************************************/
 115#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
 116static 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
 132static 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
 141static void __init palmz72_kpc_init(void)
 142{
 143        pxa_set_keypad_info(&palmz72_keypad_platform_data);
 144}
 145#else
 146static inline void palmz72_kpc_init(void) {}
 147#endif
 148
 149/******************************************************************************
 150 * LEDs
 151 ******************************************************************************/
 152#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
 153static 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
 161static struct gpio_led_platform_data gpio_led_info = {
 162        .leds           = gpio_leds,
 163        .num_leds       = ARRAY_SIZE(gpio_leds),
 164};
 165
 166static struct platform_device palmz72_leds = {
 167        .name   = "leds-gpio",
 168        .id     = -1,
 169        .dev    = {
 170                .platform_data  = &gpio_led_info,
 171        }
 172};
 173
 174static void __init palmz72_leds_init(void)
 175{
 176        platform_device_register(&palmz72_leds);
 177}
 178#else
 179static inline void palmz72_leds_init(void) {}
 180#endif
 181
 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
 196static 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
 208static unsigned long store_ptr;
 209
 210/* sys_device for Palm Zire 72 PM */
 211
 212static int palmz72_pm_suspend(struct sys_device *dev, pm_message_t msg)
 213{
 214        /* setup the resume_info struct for the original bootloader */
 215        palmz72_resume_info.resume_addr = (u32) pxa_cpu_resume;
 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
 226static int palmz72_pm_resume(struct sys_device *dev)
 227{
 228        *PALMZ72_SAVE_DWORD = store_ptr;
 229        return 0;
 230}
 231
 232static struct sysdev_class palmz72_pm_sysclass = {
 233        .name = "palmz72_pm",
 234        .suspend = palmz72_pm_suspend,
 235        .resume = palmz72_pm_resume,
 236};
 237
 238static struct sys_device palmz72_pm_device = {
 239        .cls = &palmz72_pm_sysclass,
 240};
 241
 242static 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
 253device_initcall(palmz72_pm_init);
 254#endif
 255
 256/******************************************************************************
 257 * Machine init
 258 ******************************************************************************/
 259static void __init palmz72_init(void)
 260{
 261        pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
 262        pxa_set_ffuart_info(NULL);
 263        pxa_set_btuart_info(NULL);
 264        pxa_set_stuart_info(NULL);
 265
 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();
 279}
 280
 281MACHINE_START(PALMZ72, "Palm Zire72")
 282        .boot_params    = 0xa0000100,
 283        .map_io         = pxa27x_map_io,
 284        .init_irq       = pxa27x_init_irq,
 285        .timer          = &pxa_timer,
 286        .init_machine   = palmz72_init
 287MACHINE_END
 288