Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-pxa/zylonite_pxa320.c
0004  *
0005  * PXA320 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/gpio.h>
0017 #include <linux/soc/pxa/cpu.h>
0018 
0019 #include "pxa320.h"
0020 #include "zylonite.h"
0021 
0022 #include "generic.h"
0023 
0024 static mfp_cfg_t mfp_cfg[] __initdata = {
0025     /* LCD */
0026     GPIO6_2_LCD_LDD_0,
0027     GPIO7_2_LCD_LDD_1,
0028     GPIO8_2_LCD_LDD_2,
0029     GPIO9_2_LCD_LDD_3,
0030     GPIO10_2_LCD_LDD_4,
0031     GPIO11_2_LCD_LDD_5,
0032     GPIO12_2_LCD_LDD_6,
0033     GPIO13_2_LCD_LDD_7,
0034     GPIO63_LCD_LDD_8,
0035     GPIO64_LCD_LDD_9,
0036     GPIO65_LCD_LDD_10,
0037     GPIO66_LCD_LDD_11,
0038     GPIO67_LCD_LDD_12,
0039     GPIO68_LCD_LDD_13,
0040     GPIO69_LCD_LDD_14,
0041     GPIO70_LCD_LDD_15,
0042     GPIO71_LCD_LDD_16,
0043     GPIO72_LCD_LDD_17,
0044     GPIO73_LCD_CS_N,
0045     GPIO74_LCD_VSYNC,
0046     GPIO14_2_LCD_FCLK,
0047     GPIO15_2_LCD_LCLK,
0048     GPIO16_2_LCD_PCLK,
0049     GPIO17_2_LCD_BIAS,
0050     GPIO14_PWM3_OUT,    /* backlight */
0051 
0052     /* FFUART */
0053     GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL,
0054     GPIO42_UART1_TXD,
0055     GPIO43_UART1_CTS,
0056     GPIO44_UART1_DCD,
0057     GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL,
0058     GPIO46_UART1_RI,
0059     GPIO47_UART1_DTR,
0060     GPIO48_UART1_RTS,
0061 
0062     /* AC97 */
0063     GPIO34_AC97_SYSCLK,
0064     GPIO35_AC97_SDATA_IN_0,
0065     GPIO37_AC97_SDATA_OUT,
0066     GPIO38_AC97_SYNC,
0067     GPIO39_AC97_BITCLK,
0068     GPIO40_AC97_nACRESET,
0069     GPIO36_GPIO,    /* SDATA_IN_1 but unused - configure to GPIO */
0070 
0071     /* SSP3 */
0072     GPIO89_SSP3_SCLK,
0073     GPIO90_SSP3_FRM,
0074     GPIO91_SSP3_TXD,
0075     GPIO92_SSP3_RXD,
0076 
0077     /* WM9713 IRQ */
0078     GPIO15_GPIO,
0079 
0080     /* I2C */
0081     GPIO32_I2C_SCL,
0082     GPIO33_I2C_SDA,
0083 
0084     /* Keypad */
0085     GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
0086     GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
0087     GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
0088     GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
0089     GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
0090     GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
0091     GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
0092     GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
0093     GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
0094     GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
0095     GPIO121_KP_MKOUT_0,
0096     GPIO122_KP_MKOUT_1,
0097     GPIO123_KP_MKOUT_2,
0098     GPIO124_KP_MKOUT_3,
0099     GPIO125_KP_MKOUT_4,
0100     GPIO126_KP_MKOUT_5,
0101     GPIO127_KP_MKOUT_6,
0102     GPIO5_2_KP_MKOUT_7,
0103 
0104     /* Ethernet */
0105     GPIO4_nCS3,
0106     GPIO90_GPIO,
0107 
0108     /* MMC1 */
0109     GPIO18_MMC1_DAT0,
0110     GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
0111     GPIO20_MMC1_DAT2,
0112     GPIO21_MMC1_DAT3,
0113     GPIO22_MMC1_CLK,
0114     GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
0115     GPIO31_GPIO,    /* CMD1 default as GPIO for slot 0 */
0116 
0117     /* MMC2 */
0118     GPIO24_MMC2_DAT0,
0119     GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
0120     GPIO26_MMC2_DAT2,
0121     GPIO27_MMC2_DAT3,
0122     GPIO28_MMC2_CLK,
0123     GPIO29_MMC2_CMD,
0124 
0125     /* USB Host */
0126     GPIO2_2_USBH_PEN,
0127     GPIO3_2_USBH_PWR,
0128 
0129     /* Debug LEDs */
0130     GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
0131     GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
0132 };
0133 
0134 #define NUM_LCD_DETECT_PINS 7
0135 
0136 static int lcd_detect_pins[] __initdata = {
0137     MFP_PIN_GPIO72,   /* LCD_LDD_17 - ORIENT */
0138     MFP_PIN_GPIO71,   /* LCD_LDD_16 - LCDID[5] */
0139     MFP_PIN_GPIO17_2, /* LCD_BIAS   - LCDID[4] */
0140     MFP_PIN_GPIO15_2, /* LCD_LCLK   - LCDID[3] */
0141     MFP_PIN_GPIO14_2, /* LCD_FCLK   - LCDID[2] */
0142     MFP_PIN_GPIO73,   /* LCD_CS_N   - LCDID[1] */
0143     MFP_PIN_GPIO74,   /* LCD_VSYNC  - LCDID[0] */
0144     /*
0145      * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
0146      * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
0147      */
0148     MFP_PIN_GPIO14,
0149     MFP_PIN_GPIO15,
0150     MFP_PIN_GPIO17,
0151 };
0152 
0153 static int lcd_detect_mfpr[] __initdata = {
0154     /* AF0, DS 1X, Pull Neither, Edge Clear */
0155     0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
0156     0xc442, /* Backlight, Pull-Up, AF2 */
0157     0x8445, /* AF5 */
0158     0x8445, /* AF5 */
0159 };
0160 
0161 static void __init zylonite_detect_lcd_panel(void)
0162 {
0163     unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
0164     int i, gpio, id = 0;
0165 
0166     /* save the original MFP settings of these pins and configure them
0167      * as GPIO Input, DS01X, Pull Neither, Edge Clear
0168      */
0169     for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
0170         mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
0171         pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
0172     }
0173 
0174     for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
0175         id = id << 1;
0176         gpio = mfp_to_gpio(lcd_detect_pins[i]);
0177         gpio_request(gpio, "LCD_ID_PINS");
0178         gpio_direction_input(gpio);
0179 
0180         if (gpio_get_value(gpio))
0181             id = id | 0x1;
0182         gpio_free(gpio);
0183     }
0184 
0185     /* lcd id, flush out bit 1 */
0186     lcd_id = id & 0x3d;
0187 
0188     /* lcd orientation, portrait or landscape */
0189     lcd_orientation = (id >> 6) & 0x1;
0190 
0191     /* restore the original MFP settings */
0192     for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
0193         pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
0194 }
0195 
0196 void __init zylonite_pxa320_init(void)
0197 {
0198     if (cpu_is_pxa320()) {
0199         /* initialize MFP */
0200         pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
0201 
0202         /* detect LCD panel */
0203         zylonite_detect_lcd_panel();
0204 
0205         /* GPIO pin assignment */
0206         gpio_eth_irq    = mfp_to_gpio(MFP_PIN_GPIO9);
0207         gpio_debug_led1 = mfp_to_gpio(MFP_PIN_GPIO1_2);
0208         gpio_debug_led2 = mfp_to_gpio(MFP_PIN_GPIO4_2);
0209 
0210         /* WM9713 IRQ */
0211         wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15);
0212     }
0213 }