Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Hardware definitions for PalmTX
0004  *
0005  * Author:     Marek Vasut <marek.vasut@gmail.com>
0006  *
0007  * Based on work of:
0008  *      Alex Osborne <ato@meshy.org>
0009  *      Cristiano P. <cristianop@users.sourceforge.net>
0010  *      Jan Herman <2hp@seznam.cz>
0011  *      Michal Hrusecky
0012  *
0013  * (find more info at www.hackndev.com)
0014  */
0015 
0016 #include <linux/platform_device.h>
0017 #include <linux/delay.h>
0018 #include <linux/irq.h>
0019 #include <linux/gpio_keys.h>
0020 #include <linux/input.h>
0021 #include <linux/pda_power.h>
0022 #include <linux/pwm_backlight.h>
0023 #include <linux/gpio.h>
0024 #include <linux/wm97xx.h>
0025 #include <linux/power_supply.h>
0026 #include <linux/mtd/platnand.h>
0027 #include <linux/mtd/mtd.h>
0028 #include <linux/mtd/physmap.h>
0029 
0030 #include <asm/mach-types.h>
0031 #include <asm/mach/arch.h>
0032 #include <asm/mach/map.h>
0033 
0034 #include "pxa27x.h"
0035 #include <linux/platform_data/asoc-pxa.h>
0036 #include "palmtx.h"
0037 #include <linux/platform_data/mmc-pxamci.h>
0038 #include <linux/platform_data/video-pxafb.h>
0039 #include <linux/platform_data/irda-pxaficp.h>
0040 #include <linux/platform_data/keypad-pxa27x.h>
0041 #include "udc.h"
0042 #include <linux/platform_data/asoc-palm27x.h>
0043 #include "palm27x.h"
0044 
0045 #include "generic.h"
0046 #include "devices.h"
0047 
0048 /******************************************************************************
0049  * Pin configuration
0050  ******************************************************************************/
0051 static unsigned long palmtx_pin_config[] __initdata = {
0052     /* MMC */
0053     GPIO32_MMC_CLK,
0054     GPIO92_MMC_DAT_0,
0055     GPIO109_MMC_DAT_1,
0056     GPIO110_MMC_DAT_2,
0057     GPIO111_MMC_DAT_3,
0058     GPIO112_MMC_CMD,
0059     GPIO14_GPIO,    /* SD detect */
0060     GPIO114_GPIO,   /* SD power */
0061     GPIO115_GPIO,   /* SD r/o switch */
0062 
0063     /* AC97 */
0064     GPIO28_AC97_BITCLK,
0065     GPIO29_AC97_SDATA_IN_0,
0066     GPIO30_AC97_SDATA_OUT,
0067     GPIO31_AC97_SYNC,
0068     GPIO89_AC97_SYSCLK,
0069     GPIO95_AC97_nRESET,
0070 
0071     /* IrDA */
0072     GPIO40_GPIO,    /* ir disable */
0073     GPIO46_FICP_RXD,
0074     GPIO47_FICP_TXD,
0075 
0076     /* PWM */
0077     GPIO16_PWM0_OUT,
0078 
0079     /* USB */
0080     GPIO13_GPIO,    /* usb detect */
0081     GPIO93_GPIO,    /* usb power */
0082 
0083     /* PCMCIA */
0084     GPIO48_nPOE,
0085     GPIO49_nPWE,
0086     GPIO50_nPIOR,
0087     GPIO51_nPIOW,
0088     GPIO85_nPCE_1,
0089     GPIO54_nPCE_2,
0090     GPIO79_PSKTSEL,
0091     GPIO55_nPREG,
0092     GPIO56_nPWAIT,
0093     GPIO57_nIOIS16,
0094     GPIO94_GPIO,    /* wifi power 1 */
0095     GPIO108_GPIO,   /* wifi power 2 */
0096     GPIO116_GPIO,   /* wifi ready */
0097 
0098     /* MATRIX KEYPAD */
0099     GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
0100     GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
0101     GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
0102     GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
0103     GPIO103_KP_MKOUT_0,
0104     GPIO104_KP_MKOUT_1,
0105     GPIO105_KP_MKOUT_2,
0106 
0107     /* LCD */
0108     GPIOxx_LCD_TFT_16BPP,
0109 
0110     /* FFUART */
0111     GPIO34_FFUART_RXD,
0112     GPIO39_FFUART_TXD,
0113 
0114     /* NAND */
0115     GPIO15_nCS_1,
0116     GPIO18_RDY,
0117 
0118     /* MISC. */
0119     GPIO10_GPIO,    /* hotsync button */
0120     GPIO12_GPIO,    /* power detect */
0121     GPIO107_GPIO,   /* earphone detect */
0122 };
0123 
0124 /******************************************************************************
0125  * NOR Flash
0126  ******************************************************************************/
0127 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
0128 static struct mtd_partition palmtx_partitions[] = {
0129     {
0130         .name       = "Flash",
0131         .offset     = 0x00000000,
0132         .size       = MTDPART_SIZ_FULL,
0133         .mask_flags = 0
0134     }
0135 };
0136 
0137 static struct physmap_flash_data palmtx_flash_data[] = {
0138     {
0139         .width      = 2,            /* bankwidth in bytes */
0140         .parts      = palmtx_partitions,
0141         .nr_parts   = ARRAY_SIZE(palmtx_partitions)
0142     }
0143 };
0144 
0145 static struct resource palmtx_flash_resource = {
0146     .start  = PXA_CS0_PHYS,
0147     .end    = PXA_CS0_PHYS + SZ_8M - 1,
0148     .flags  = IORESOURCE_MEM,
0149 };
0150 
0151 static struct platform_device palmtx_flash = {
0152     .name       = "physmap-flash",
0153     .id     = 0,
0154     .resource   = &palmtx_flash_resource,
0155     .num_resources  = 1,
0156     .dev        = {
0157         .platform_data = palmtx_flash_data,
0158     },
0159 };
0160 
0161 static void __init palmtx_nor_init(void)
0162 {
0163     platform_device_register(&palmtx_flash);
0164 }
0165 #else
0166 static inline void palmtx_nor_init(void) {}
0167 #endif
0168 
0169 /******************************************************************************
0170  * GPIO keyboard
0171  ******************************************************************************/
0172 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0173 static const unsigned int palmtx_matrix_keys[] = {
0174     KEY(0, 0, KEY_POWER),
0175     KEY(0, 1, KEY_F1),
0176     KEY(0, 2, KEY_ENTER),
0177 
0178     KEY(1, 0, KEY_F2),
0179     KEY(1, 1, KEY_F3),
0180     KEY(1, 2, KEY_F4),
0181 
0182     KEY(2, 0, KEY_UP),
0183     KEY(2, 2, KEY_DOWN),
0184 
0185     KEY(3, 0, KEY_RIGHT),
0186     KEY(3, 2, KEY_LEFT),
0187 };
0188 
0189 static struct matrix_keymap_data palmtx_matrix_keymap_data = {
0190     .keymap         = palmtx_matrix_keys,
0191     .keymap_size        = ARRAY_SIZE(palmtx_matrix_keys),
0192 };
0193 
0194 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
0195     .matrix_key_rows    = 4,
0196     .matrix_key_cols    = 3,
0197     .matrix_keymap_data = &palmtx_matrix_keymap_data,
0198 
0199     .debounce_interval  = 30,
0200 };
0201 
0202 static void __init palmtx_kpc_init(void)
0203 {
0204     pxa_set_keypad_info(&palmtx_keypad_platform_data);
0205 }
0206 #else
0207 static inline void palmtx_kpc_init(void) {}
0208 #endif
0209 
0210 /******************************************************************************
0211  * GPIO keys
0212  ******************************************************************************/
0213 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
0214 static struct gpio_keys_button palmtx_pxa_buttons[] = {
0215     {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
0216 };
0217 
0218 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
0219     .buttons    = palmtx_pxa_buttons,
0220     .nbuttons   = ARRAY_SIZE(palmtx_pxa_buttons),
0221 };
0222 
0223 static struct platform_device palmtx_pxa_keys = {
0224     .name   = "gpio-keys",
0225     .id = -1,
0226     .dev    = {
0227         .platform_data = &palmtx_pxa_keys_data,
0228     },
0229 };
0230 
0231 static void __init palmtx_keys_init(void)
0232 {
0233     platform_device_register(&palmtx_pxa_keys);
0234 }
0235 #else
0236 static inline void palmtx_keys_init(void) {}
0237 #endif
0238 
0239 /******************************************************************************
0240  * NAND Flash
0241  ******************************************************************************/
0242 #if defined(CONFIG_MTD_NAND_PLATFORM) || \
0243     defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
0244 static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
0245                 unsigned int ctrl)
0246 {
0247     char __iomem *nandaddr = this->legacy.IO_ADDR_W;
0248 
0249     if (cmd == NAND_CMD_NONE)
0250         return;
0251 
0252     if (ctrl & NAND_CLE)
0253         writeb(cmd, PALMTX_NAND_CLE_VIRT);
0254     else if (ctrl & NAND_ALE)
0255         writeb(cmd, PALMTX_NAND_ALE_VIRT);
0256     else
0257         writeb(cmd, nandaddr);
0258 }
0259 
0260 static struct mtd_partition palmtx_partition_info[] = {
0261     [0] = {
0262         .name   = "palmtx-0",
0263         .offset = 0,
0264         .size   = MTDPART_SIZ_FULL
0265     },
0266 };
0267 
0268 struct platform_nand_data palmtx_nand_platdata = {
0269     .chip   = {
0270         .nr_chips       = 1,
0271         .chip_offset        = 0,
0272         .nr_partitions      = ARRAY_SIZE(palmtx_partition_info),
0273         .partitions     = palmtx_partition_info,
0274         .chip_delay     = 20,
0275     },
0276     .ctrl   = {
0277         .cmd_ctrl   = palmtx_nand_cmd_ctl,
0278     },
0279 };
0280 
0281 static struct resource palmtx_nand_resource[] = {
0282     [0] = {
0283         .start  = PXA_CS1_PHYS,
0284         .end    = PXA_CS1_PHYS + SZ_1M - 1,
0285         .flags  = IORESOURCE_MEM,
0286     },
0287 };
0288 
0289 static struct platform_device palmtx_nand = {
0290     .name       = "gen_nand",
0291     .num_resources  = ARRAY_SIZE(palmtx_nand_resource),
0292     .resource   = palmtx_nand_resource,
0293     .id     = -1,
0294     .dev        = {
0295         .platform_data  = &palmtx_nand_platdata,
0296     }
0297 };
0298 
0299 static void __init palmtx_nand_init(void)
0300 {
0301     platform_device_register(&palmtx_nand);
0302 }
0303 #else
0304 static inline void palmtx_nand_init(void) {}
0305 #endif
0306 
0307 /******************************************************************************
0308  * Machine init
0309  ******************************************************************************/
0310 static struct map_desc palmtx_io_desc[] __initdata = {
0311 {
0312     .virtual    = (unsigned long)PALMTX_PCMCIA_VIRT,
0313     .pfn        = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
0314     .length     = PALMTX_PCMCIA_SIZE,
0315     .type       = MT_DEVICE,
0316 }, {
0317     .virtual    = (unsigned long)PALMTX_NAND_ALE_VIRT,
0318     .pfn        = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
0319     .length     = SZ_1M,
0320     .type       = MT_DEVICE,
0321 }, {
0322     .virtual    = (unsigned long)PALMTX_NAND_CLE_VIRT,
0323     .pfn        = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
0324     .length     = SZ_1M,
0325     .type       = MT_DEVICE,
0326 }
0327 };
0328 
0329 static void __init palmtx_map_io(void)
0330 {
0331     pxa27x_map_io();
0332     iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
0333 }
0334 
0335 static struct gpiod_lookup_table palmtx_mci_gpio_table = {
0336     .dev_id = "pxa2xx-mci.0",
0337     .table = {
0338         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N,
0339                 "cd", GPIO_ACTIVE_LOW),
0340         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY,
0341                 "wp", GPIO_ACTIVE_LOW),
0342         GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER,
0343                 "power", GPIO_ACTIVE_HIGH),
0344         { },
0345     },
0346 };
0347 
0348 static struct gpiod_lookup_table palmtx_wm97xx_touch_gpio_table = {
0349     .dev_id = "wm97xx-touch",
0350     .table = {
0351         GPIO_LOOKUP("gpio-pxa", 27, "touch", GPIO_ACTIVE_HIGH),
0352         { },
0353     },
0354 };
0355 
0356 static void __init palmtx_init(void)
0357 {
0358     pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
0359     pxa_set_ffuart_info(NULL);
0360     pxa_set_btuart_info(NULL);
0361     pxa_set_stuart_info(NULL);
0362 
0363     palm27x_mmc_init(&palmtx_mci_gpio_table);
0364     gpiod_add_lookup_table(&palmtx_wm97xx_touch_gpio_table);
0365     palm27x_pm_init(PALMTX_STR_BASE);
0366     palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
0367     palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
0368             GPIO_NR_PALMTX_USB_PULLUP, 1);
0369     palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
0370     palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
0371             GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
0372     palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
0373     palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
0374     palm27x_pmic_init();
0375     palmtx_kpc_init();
0376     palmtx_keys_init();
0377     palmtx_nor_init();
0378     palmtx_nand_init();
0379 }
0380 
0381 MACHINE_START(PALMTX, "Palm T|X")
0382     .atag_offset    = 0x100,
0383     .map_io     = palmtx_map_io,
0384     .nr_irqs    = PXA_NR_IRQS,
0385     .init_irq   = pxa27x_init_irq,
0386     .handle_irq = pxa27x_handle_irq,
0387     .init_time  = pxa_timer_init,
0388     .init_machine   = palmtx_init,
0389     .restart    = pxa_restart,
0390 MACHINE_END