Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-pxa/zylonite_pxa300.c
0004  *
0005  * PXA300/PXA310 specific support code for the
0006  * PXA3xx Development Platform (aka Zylonite)
0007  *
0008  * Copyright (C) 2007 Marvell Internation Ltd.
0009  * 2007-08-21: eric miao <eric.miao@marvell.com>
0010  *             initial version
0011  */
0012 
0013 #include <linux/module.h>
0014 #include <linux/kernel.h>
0015 #include <linux/init.h>
0016 #include <linux/i2c.h>
0017 #include <linux/platform_data/i2c-pxa.h>
0018 #include <linux/platform_data/pca953x.h>
0019 #include <linux/gpio.h>
0020 #include <linux/soc/pxa/cpu.h>
0021 
0022 #include "pxa300.h"
0023 #include "devices.h"
0024 #include "zylonite.h"
0025 
0026 #include "generic.h"
0027 
0028 /* PXA300/PXA310 common configurations */
0029 static mfp_cfg_t common_mfp_cfg[] __initdata = {
0030     /* LCD */
0031     GPIO54_LCD_LDD_0,
0032     GPIO55_LCD_LDD_1,
0033     GPIO56_LCD_LDD_2,
0034     GPIO57_LCD_LDD_3,
0035     GPIO58_LCD_LDD_4,
0036     GPIO59_LCD_LDD_5,
0037     GPIO60_LCD_LDD_6,
0038     GPIO61_LCD_LDD_7,
0039     GPIO62_LCD_LDD_8,
0040     GPIO63_LCD_LDD_9,
0041     GPIO64_LCD_LDD_10,
0042     GPIO65_LCD_LDD_11,
0043     GPIO66_LCD_LDD_12,
0044     GPIO67_LCD_LDD_13,
0045     GPIO68_LCD_LDD_14,
0046     GPIO69_LCD_LDD_15,
0047     GPIO70_LCD_LDD_16,
0048     GPIO71_LCD_LDD_17,
0049     GPIO72_LCD_FCLK,
0050     GPIO73_LCD_LCLK,
0051     GPIO74_LCD_PCLK,
0052     GPIO75_LCD_BIAS,
0053     GPIO76_LCD_VSYNC,
0054     GPIO127_LCD_CS_N,
0055     GPIO20_PWM3_OUT,    /* backlight */
0056 
0057     /* BTUART */
0058     GPIO111_UART2_RTS,
0059     GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
0060     GPIO113_UART2_TXD,
0061     GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
0062 
0063     /* STUART */
0064     GPIO109_UART3_TXD,
0065     GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
0066 
0067     /* AC97 */
0068     GPIO23_AC97_nACRESET,
0069     GPIO24_AC97_SYSCLK,
0070     GPIO29_AC97_BITCLK,
0071     GPIO25_AC97_SDATA_IN_0,
0072     GPIO27_AC97_SDATA_OUT,
0073     GPIO28_AC97_SYNC,
0074     GPIO17_GPIO,    /* SDATA_IN_1 but unused - configure to GPIO */
0075 
0076     /* SSP3 */
0077     GPIO91_SSP3_SCLK,
0078     GPIO92_SSP3_FRM,
0079     GPIO93_SSP3_TXD,
0080     GPIO94_SSP3_RXD,
0081 
0082     /* WM9713 IRQ */
0083     GPIO26_GPIO,
0084 
0085     /* Keypad */
0086     GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
0087     GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
0088     GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
0089     GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
0090     GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
0091     GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
0092     GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
0093     GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
0094     GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
0095     GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
0096     GPIO121_KP_MKOUT_0,
0097     GPIO122_KP_MKOUT_1,
0098     GPIO123_KP_MKOUT_2,
0099     GPIO124_KP_MKOUT_3,
0100     GPIO125_KP_MKOUT_4,
0101     GPIO4_2_KP_MKOUT_5,
0102     GPIO5_2_KP_MKOUT_6,
0103     GPIO6_2_KP_MKOUT_7,
0104 
0105     /* MMC1 */
0106     GPIO3_MMC1_DAT0,
0107     GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
0108     GPIO5_MMC1_DAT2,
0109     GPIO6_MMC1_DAT3,
0110     GPIO7_MMC1_CLK,
0111     GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
0112     GPIO15_GPIO,    /* CMD1 default as GPIO for slot 0 */
0113 
0114     /* MMC2 */
0115     GPIO9_MMC2_DAT0,
0116     GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
0117     GPIO11_MMC2_DAT2,
0118     GPIO12_MMC2_DAT3,
0119     GPIO13_MMC2_CLK,
0120     GPIO14_MMC2_CMD,
0121 
0122     /* USB Host */
0123     GPIO0_2_USBH_PEN,
0124     GPIO1_2_USBH_PWR,
0125 
0126     /* Standard I2C */
0127     GPIO21_I2C_SCL,
0128     GPIO22_I2C_SDA,
0129 
0130     /* GPIO */
0131     GPIO18_GPIO | MFP_PULL_HIGH,    /* GPIO Expander #0 INT_N */
0132     GPIO19_GPIO | MFP_PULL_HIGH,    /* GPIO Expander #1 INT_N */
0133 };
0134 
0135 static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
0136     /* FFUART */
0137     GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
0138     GPIO31_UART1_TXD,
0139     GPIO32_UART1_CTS,
0140     GPIO37_UART1_RTS,
0141     GPIO33_UART1_DCD,
0142     GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
0143     GPIO35_UART1_RI,
0144     GPIO36_UART1_DTR,
0145 
0146     /* Ethernet */
0147     GPIO2_nCS3,
0148     GPIO99_GPIO,
0149 };
0150 
0151 static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
0152     /* FFUART */
0153     GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
0154     GPIO100_UART1_TXD,
0155     GPIO101_UART1_CTS,
0156     GPIO106_UART1_RTS,
0157 
0158     /* Ethernet */
0159     GPIO2_nCS3,
0160     GPIO102_GPIO,
0161 
0162     /* MMC3 */
0163     GPIO7_2_MMC3_DAT0,
0164     GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
0165     GPIO9_2_MMC3_DAT2,
0166     GPIO10_2_MMC3_DAT3,
0167     GPIO103_MMC3_CLK,
0168     GPIO105_MMC3_CMD,
0169 };
0170 
0171 #define NUM_LCD_DETECT_PINS 7
0172 
0173 static int lcd_detect_pins[] __initdata = {
0174     MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
0175     MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
0176     MFP_PIN_GPIO75, /* LCD_BIAS   - LCDID[4] */
0177     MFP_PIN_GPIO73, /* LCD_LCLK   - LCDID[3] */
0178     MFP_PIN_GPIO72, /* LCD_FCLK   - LCDID[2] */
0179     MFP_PIN_GPIO127,/* LCD_CS_N   - LCDID[1] */
0180     MFP_PIN_GPIO76, /* LCD_VSYNC  - LCDID[0] */
0181 };
0182 
0183 static void __init zylonite_detect_lcd_panel(void)
0184 {
0185     unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
0186     int i, gpio, id = 0;
0187 
0188     /* save the original MFP settings of these pins and configure
0189      * them as GPIO Input, DS01X, Pull Neither, Edge Clear
0190      */
0191     for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
0192         mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
0193         pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
0194     }
0195 
0196     for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
0197         id = id << 1;
0198         gpio = mfp_to_gpio(lcd_detect_pins[i]);
0199         gpio_request(gpio, "LCD_ID_PINS");
0200         gpio_direction_input(gpio);
0201 
0202         if (gpio_get_value(gpio))
0203             id = id | 0x1;
0204         gpio_free(gpio);
0205     }
0206 
0207     /* lcd id, flush out bit 1 */
0208     lcd_id = id & 0x3d;
0209 
0210     /* lcd orientation, portrait or landscape */
0211     lcd_orientation = (id >> 6) & 0x1;
0212 
0213     /* restore the original MFP settings */
0214     for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
0215         pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
0216 }
0217 
0218 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
0219 static struct pca953x_platform_data gpio_exp[] = {
0220     [0] = {
0221         .gpio_base  = 128,
0222     },
0223     [1] = {
0224         .gpio_base  = 144,
0225     },
0226 };
0227 
0228 static struct i2c_board_info zylonite_i2c_board_info[] = {
0229     {
0230         .type       = "pca9539",
0231         .dev_name   = "pca9539-a",
0232         .addr       = 0x74,
0233         .platform_data  = &gpio_exp[0],
0234         .irq        = PXA_GPIO_TO_IRQ(18),
0235     }, {
0236         .type       = "pca9539",
0237         .dev_name   = "pca9539-b",
0238         .addr       = 0x75,
0239         .platform_data  = &gpio_exp[1],
0240         .irq        = PXA_GPIO_TO_IRQ(19),
0241     },
0242 };
0243 
0244 static void __init zylonite_init_i2c(void)
0245 {
0246     pxa_set_i2c_info(NULL);
0247     i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
0248 }
0249 #else
0250 static inline void zylonite_init_i2c(void) {}
0251 #endif
0252 
0253 void __init zylonite_pxa300_init(void)
0254 {
0255     if (cpu_is_pxa300() || cpu_is_pxa310()) {
0256         /* initialize MFP */
0257         pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
0258 
0259         /* detect LCD panel */
0260         zylonite_detect_lcd_panel();
0261 
0262         /* WM9713 IRQ */
0263         wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
0264 
0265         zylonite_init_i2c();
0266     }
0267 
0268     if (cpu_is_pxa300()) {
0269         pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
0270         gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
0271     }
0272 
0273     if (cpu_is_pxa310()) {
0274         pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
0275         gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
0276     }
0277 
0278     /* GPIOs for Debug LEDs */
0279     gpio_debug_led1 = EXT_GPIO(25);
0280     gpio_debug_led2 = EXT_GPIO(26);
0281 }