Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Hardware definitions for Palm Zire72
0004  *
0005  * Authors:
0006  *  Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
0007  *  Sergey Lapin <slapin@ossfans.org>
0008  *  Alex Osborne <bobofdoom@gmail.com>
0009  *  Jan Herman <2hp@seznam.cz>
0010  *
0011  * Rewrite for mainline:
0012  *  Marek Vasut <marek.vasut@gmail.com>
0013  *
0014  * (find more info at www.hackndev.com)
0015  */
0016 
0017 #include <linux/platform_device.h>
0018 #include <linux/syscore_ops.h>
0019 #include <linux/delay.h>
0020 #include <linux/irq.h>
0021 #include <linux/gpio_keys.h>
0022 #include <linux/input.h>
0023 #include <linux/pda_power.h>
0024 #include <linux/pwm_backlight.h>
0025 #include <linux/gpio.h>
0026 #include <linux/wm97xx.h>
0027 #include <linux/power_supply.h>
0028 #include <linux/platform_data/i2c-gpio.h>
0029 #include <linux/gpio/machine.h>
0030 
0031 #include <asm/mach-types.h>
0032 #include <asm/suspend.h>
0033 #include <asm/mach/arch.h>
0034 #include <asm/mach/map.h>
0035 
0036 #include "pxa27x.h"
0037 #include <linux/platform_data/asoc-pxa.h>
0038 #include "palmz72.h"
0039 #include <linux/platform_data/mmc-pxamci.h>
0040 #include <linux/platform_data/video-pxafb.h>
0041 #include <linux/platform_data/irda-pxaficp.h>
0042 #include <linux/platform_data/keypad-pxa27x.h>
0043 #include "udc.h"
0044 #include <linux/platform_data/asoc-palm27x.h>
0045 #include "palm27x.h"
0046 
0047 #include "pm.h"
0048 #include <linux/platform_data/media/camera-pxa.h>
0049 
0050 #include "generic.h"
0051 #include "devices.h"
0052 
0053 /******************************************************************************
0054  * Pin configuration
0055  ******************************************************************************/
0056 static unsigned long palmz72_pin_config[] __initdata = {
0057     /* MMC */
0058     GPIO32_MMC_CLK,
0059     GPIO92_MMC_DAT_0,
0060     GPIO109_MMC_DAT_1,
0061     GPIO110_MMC_DAT_2,
0062     GPIO111_MMC_DAT_3,
0063     GPIO112_MMC_CMD,
0064     GPIO14_GPIO,    /* SD detect */
0065     GPIO115_GPIO,   /* SD RO */
0066     GPIO98_GPIO,    /* SD power */
0067 
0068     /* AC97 */
0069     GPIO28_AC97_BITCLK,
0070     GPIO29_AC97_SDATA_IN_0,
0071     GPIO30_AC97_SDATA_OUT,
0072     GPIO31_AC97_SYNC,
0073     GPIO89_AC97_SYSCLK,
0074     GPIO113_AC97_nRESET,
0075 
0076     /* IrDA */
0077     GPIO49_GPIO,    /* ir disable */
0078     GPIO46_FICP_RXD,
0079     GPIO47_FICP_TXD,
0080 
0081     /* PWM */
0082     GPIO16_PWM0_OUT,
0083 
0084     /* USB */
0085     GPIO15_GPIO,    /* usb detect */
0086     GPIO95_GPIO,    /* usb pullup */
0087 
0088     /* Matrix keypad */
0089     GPIO100_KP_MKIN_0   | WAKEUP_ON_LEVEL_HIGH,
0090     GPIO101_KP_MKIN_1   | WAKEUP_ON_LEVEL_HIGH,
0091     GPIO102_KP_MKIN_2   | WAKEUP_ON_LEVEL_HIGH,
0092     GPIO97_KP_MKIN_3    | WAKEUP_ON_LEVEL_HIGH,
0093     GPIO103_KP_MKOUT_0,
0094     GPIO104_KP_MKOUT_1,
0095     GPIO105_KP_MKOUT_2,
0096 
0097     /* LCD */
0098     GPIOxx_LCD_TFT_16BPP,
0099 
0100     GPIO20_GPIO,    /* bl power */
0101     GPIO21_GPIO,    /* LCD border switch */
0102     GPIO22_GPIO,    /* LCD border color */
0103     GPIO96_GPIO,    /* lcd power */
0104 
0105     /* PXA Camera */
0106     GPIO81_CIF_DD_0,
0107     GPIO48_CIF_DD_5,
0108     GPIO50_CIF_DD_3,
0109     GPIO51_CIF_DD_2,
0110     GPIO52_CIF_DD_4,
0111     GPIO53_CIF_MCLK,
0112     GPIO54_CIF_PCLK,
0113     GPIO55_CIF_DD_1,
0114     GPIO84_CIF_FV,
0115     GPIO85_CIF_LV,
0116     GPIO93_CIF_DD_6,
0117     GPIO108_CIF_DD_7,
0118 
0119     GPIO56_GPIO,    /* OV9640 Powerdown */
0120     GPIO57_GPIO,    /* OV9640 Reset */
0121     GPIO91_GPIO,    /* OV9640 Power */
0122 
0123     /* I2C */
0124     GPIO117_GPIO,   /* I2C_SCL */
0125     GPIO118_GPIO,   /* I2C_SDA */
0126 
0127     /* Misc. */
0128     GPIO0_GPIO  | WAKEUP_ON_LEVEL_HIGH, /* power detect */
0129     GPIO88_GPIO,                /* green led */
0130     GPIO27_GPIO,                /* WM9712 IRQ */
0131 };
0132 
0133 /******************************************************************************
0134  * GPIO keyboard
0135  ******************************************************************************/
0136 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0137 static const unsigned int palmz72_matrix_keys[] = {
0138     KEY(0, 0, KEY_POWER),
0139     KEY(0, 1, KEY_F1),
0140     KEY(0, 2, KEY_ENTER),
0141 
0142     KEY(1, 0, KEY_F2),
0143     KEY(1, 1, KEY_F3),
0144     KEY(1, 2, KEY_F4),
0145 
0146     KEY(2, 0, KEY_UP),
0147     KEY(2, 2, KEY_DOWN),
0148 
0149     KEY(3, 0, KEY_RIGHT),
0150     KEY(3, 2, KEY_LEFT),
0151 };
0152 
0153 static struct matrix_keymap_data almz72_matrix_keymap_data = {
0154     .keymap         = palmz72_matrix_keys,
0155     .keymap_size        = ARRAY_SIZE(palmz72_matrix_keys),
0156 };
0157 
0158 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
0159     .matrix_key_rows    = 4,
0160     .matrix_key_cols    = 3,
0161     .matrix_keymap_data = &almz72_matrix_keymap_data,
0162 
0163     .debounce_interval  = 30,
0164 };
0165 
0166 static void __init palmz72_kpc_init(void)
0167 {
0168     pxa_set_keypad_info(&palmz72_keypad_platform_data);
0169 }
0170 #else
0171 static inline void palmz72_kpc_init(void) {}
0172 #endif
0173 
0174 /******************************************************************************
0175  * LEDs
0176  ******************************************************************************/
0177 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
0178 static struct gpio_led gpio_leds[] = {
0179     {
0180         .name           = "palmz72:green:led",
0181         .default_trigger    = "none",
0182         .gpio           = GPIO_NR_PALMZ72_LED_GREEN,
0183     },
0184 };
0185 
0186 static struct gpio_led_platform_data gpio_led_info = {
0187     .leds       = gpio_leds,
0188     .num_leds   = ARRAY_SIZE(gpio_leds),
0189 };
0190 
0191 static struct platform_device palmz72_leds = {
0192     .name   = "leds-gpio",
0193     .id = -1,
0194     .dev    = {
0195         .platform_data  = &gpio_led_info,
0196     }
0197 };
0198 
0199 static void __init palmz72_leds_init(void)
0200 {
0201     platform_device_register(&palmz72_leds);
0202 }
0203 #else
0204 static inline void palmz72_leds_init(void) {}
0205 #endif
0206 
0207 #ifdef CONFIG_PM
0208 
0209 /* We have some black magic here
0210  * PalmOS ROM on recover expects special struct physical address
0211  * to be transferred via PSPR. Using this struct PalmOS restores
0212  * its state after sleep. As for Linux, we need to setup it the
0213  * same way. More than that, PalmOS ROM changes some values in memory.
0214  * For now only one location is found, which needs special treatment.
0215  * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
0216  * for reading backtraces for me :)
0217  */
0218 
0219 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
0220 
0221 static struct palmz72_resume_info palmz72_resume_info = {
0222     .magic0 = 0xb4e6,
0223     .magic1 = 1,
0224 
0225     /* reset state, MMU off etc */
0226     .arm_control = 0,
0227     .aux_control = 0,
0228     .ttb = 0,
0229     .domain_access = 0,
0230     .process_id = 0,
0231 };
0232 
0233 static unsigned long store_ptr;
0234 
0235 /* syscore_ops for Palm Zire 72 PM */
0236 
0237 static int palmz72_pm_suspend(void)
0238 {
0239     /* setup the resume_info struct for the original bootloader */
0240     palmz72_resume_info.resume_addr = (u32) cpu_resume;
0241 
0242     /* Storing memory touched by ROM */
0243     store_ptr = *PALMZ72_SAVE_DWORD;
0244 
0245     /* Setting PSPR to a proper value */
0246     PSPR = __pa_symbol(&palmz72_resume_info);
0247 
0248     return 0;
0249 }
0250 
0251 static void palmz72_pm_resume(void)
0252 {
0253     *PALMZ72_SAVE_DWORD = store_ptr;
0254 }
0255 
0256 static struct syscore_ops palmz72_pm_syscore_ops = {
0257     .suspend = palmz72_pm_suspend,
0258     .resume = palmz72_pm_resume,
0259 };
0260 
0261 static int __init palmz72_pm_init(void)
0262 {
0263     if (machine_is_palmz72()) {
0264         register_syscore_ops(&palmz72_pm_syscore_ops);
0265         return 0;
0266     }
0267     return -ENODEV;
0268 }
0269 
0270 device_initcall(palmz72_pm_init);
0271 #endif
0272 
0273 static struct gpiod_lookup_table palmz72_mci_gpio_table = {
0274     .dev_id = "pxa2xx-mci.0",
0275     .table = {
0276         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N,
0277                 "cd", GPIO_ACTIVE_LOW),
0278         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO,
0279                 "wp", GPIO_ACTIVE_LOW),
0280         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N,
0281                 "power", GPIO_ACTIVE_LOW),
0282         { },
0283     },
0284 };
0285 
0286 /******************************************************************************
0287  * Machine init
0288  ******************************************************************************/
0289 static void __init palmz72_init(void)
0290 {
0291     pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
0292     pxa_set_ffuart_info(NULL);
0293     pxa_set_btuart_info(NULL);
0294     pxa_set_stuart_info(NULL);
0295 
0296     palm27x_mmc_init(&palmz72_mci_gpio_table);
0297     palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
0298     palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
0299             GPIO_NR_PALMZ72_USB_PULLUP, 0);
0300     palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
0301     palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
0302             -1, 113);
0303     palm27x_pwm_init(-1, -1);
0304     palm27x_power_init(-1, -1);
0305     palm27x_pmic_init();
0306     palmz72_kpc_init();
0307     palmz72_leds_init();
0308 }
0309 
0310 MACHINE_START(PALMZ72, "Palm Zire72")
0311     .atag_offset    = 0x100,
0312     .map_io     = pxa27x_map_io,
0313     .nr_irqs    = PXA_NR_IRQS,
0314     .init_irq   = pxa27x_init_irq,
0315     .handle_irq = pxa27x_handle_irq,
0316     .init_time  = pxa_timer_init,
0317     .init_machine   = palmz72_init,
0318     .restart    = pxa_restart,
0319 MACHINE_END