2007-09-12 06:13:17 +04:00
/*
* linux / arch / arm / mach - pxa / zylonite_pxa300 . c
*
* PXA300 / PXA310 specific support code for the
* PXA3xx Development Platform ( aka Zylonite )
*
* Copyright ( C ) 2007 Marvell Internation Ltd .
2007-10-30 10:01:38 +03:00
* 2007 - 08 - 21 : eric miao < eric . miao @ marvell . com >
2007-09-12 06:13:17 +04:00
* initial version
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation .
*/
# include <linux/module.h>
# include <linux/kernel.h>
# include <linux/init.h>
2008-05-28 06:44:16 +04:00
# include <linux/i2c.h>
2011-02-23 14:38:16 +03:00
# include <linux/i2c/pxa-i2c.h>
2013-08-29 23:24:14 +04:00
# include <linux/platform_data/pca953x.h>
2009-01-02 18:17:22 +03:00
# include <linux/gpio.h>
2007-09-12 06:13:17 +04:00
2015-01-30 12:45:33 +03:00
# include "pxa300.h"
# include "zylonite.h"
2007-09-12 06:13:17 +04:00
2008-02-03 10:49:09 +03:00
# include "generic.h"
2007-09-12 06:13:17 +04:00
/* PXA300/PXA310 common configurations */
static mfp_cfg_t common_mfp_cfg [ ] __initdata = {
/* LCD */
GPIO54_LCD_LDD_0 ,
GPIO55_LCD_LDD_1 ,
GPIO56_LCD_LDD_2 ,
GPIO57_LCD_LDD_3 ,
GPIO58_LCD_LDD_4 ,
GPIO59_LCD_LDD_5 ,
GPIO60_LCD_LDD_6 ,
GPIO61_LCD_LDD_7 ,
GPIO62_LCD_LDD_8 ,
GPIO63_LCD_LDD_9 ,
GPIO64_LCD_LDD_10 ,
GPIO65_LCD_LDD_11 ,
GPIO66_LCD_LDD_12 ,
GPIO67_LCD_LDD_13 ,
GPIO68_LCD_LDD_14 ,
GPIO69_LCD_LDD_15 ,
GPIO70_LCD_LDD_16 ,
GPIO71_LCD_LDD_17 ,
GPIO72_LCD_FCLK ,
GPIO73_LCD_LCLK ,
GPIO74_LCD_PCLK ,
GPIO75_LCD_BIAS ,
GPIO76_LCD_VSYNC ,
GPIO127_LCD_CS_N ,
2008-04-14 00:46:34 +04:00
GPIO20_PWM3_OUT , /* backlight */
2007-09-12 06:13:17 +04:00
/* BTUART */
GPIO111_UART2_RTS ,
2008-01-08 18:25:01 +03:00
GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL ,
2007-09-12 06:13:17 +04:00
GPIO113_UART2_TXD ,
2008-01-08 18:25:01 +03:00
GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH ,
2007-09-12 06:13:17 +04:00
/* STUART */
GPIO109_UART3_TXD ,
2008-01-08 18:25:01 +03:00
GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL ,
2007-09-12 06:13:17 +04:00
/* AC97 */
GPIO23_AC97_nACRESET ,
GPIO24_AC97_SYSCLK ,
GPIO29_AC97_BITCLK ,
GPIO25_AC97_SDATA_IN_0 ,
GPIO27_AC97_SDATA_OUT ,
GPIO28_AC97_SYNC ,
2009-04-22 14:34:36 +04:00
GPIO17_GPIO , /* SDATA_IN_1 but unused - configure to GPIO */
2007-09-12 06:13:17 +04:00
2008-07-10 20:52:10 +04:00
/* SSP3 */
GPIO91_SSP3_SCLK ,
GPIO92_SSP3_FRM ,
GPIO93_SSP3_TXD ,
GPIO94_SSP3_RXD ,
2008-04-15 18:50:49 +04:00
/* WM9713 IRQ */
GPIO26_GPIO ,
2007-09-12 06:13:17 +04:00
/* Keypad */
2008-01-08 18:25:01 +03:00
GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH ,
GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH ,
GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH ,
GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH ,
GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH ,
GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH ,
GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH ,
GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH ,
GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH ,
GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH ,
2007-09-12 06:13:17 +04:00
GPIO121_KP_MKOUT_0 ,
GPIO122_KP_MKOUT_1 ,
GPIO123_KP_MKOUT_2 ,
GPIO124_KP_MKOUT_3 ,
GPIO125_KP_MKOUT_4 ,
GPIO4_2_KP_MKOUT_5 ,
GPIO5_2_KP_MKOUT_6 ,
GPIO6_2_KP_MKOUT_7 ,
2007-12-21 14:00:13 +03:00
/* MMC1 */
GPIO3_MMC1_DAT0 ,
2008-01-08 18:25:01 +03:00
GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH ,
2007-12-21 14:00:13 +03:00
GPIO5_MMC1_DAT2 ,
GPIO6_MMC1_DAT3 ,
GPIO7_MMC1_CLK ,
GPIO8_MMC1_CMD , /* CMD0 for slot 0 */
GPIO15_GPIO , /* CMD1 default as GPIO for slot 0 */
2007-12-21 14:15:36 +03:00
/* MMC2 */
GPIO9_MMC2_DAT0 ,
2008-01-08 18:25:01 +03:00
GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH ,
2007-12-21 14:15:36 +03:00
GPIO11_MMC2_DAT2 ,
GPIO12_MMC2_DAT3 ,
GPIO13_MMC2_CLK ,
GPIO14_MMC2_CMD ,
2008-05-28 06:44:16 +04:00
2008-09-27 14:05:49 +04:00
/* USB Host */
GPIO0_2_USBH_PEN ,
GPIO1_2_USBH_PWR ,
2008-05-28 06:44:16 +04:00
/* Standard I2C */
GPIO21_I2C_SCL ,
GPIO22_I2C_SDA ,
2009-04-22 14:38:40 +04:00
/* GPIO */
2009-12-22 15:29:40 +03:00
GPIO18_GPIO | MFP_PULL_HIGH , /* GPIO Expander #0 INT_N */
GPIO19_GPIO | MFP_PULL_HIGH , /* GPIO Expander #1 INT_N */
2007-09-12 06:13:17 +04:00
} ;
static mfp_cfg_t pxa300_mfp_cfg [ ] __initdata = {
/* FFUART */
2008-01-08 18:25:01 +03:00
GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL ,
2007-09-12 06:13:17 +04:00
GPIO31_UART1_TXD ,
GPIO32_UART1_CTS ,
GPIO37_UART1_RTS ,
GPIO33_UART1_DCD ,
2008-01-08 18:25:01 +03:00
GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL ,
2007-09-12 06:13:17 +04:00
GPIO35_UART1_RI ,
GPIO36_UART1_DTR ,
/* Ethernet */
GPIO2_nCS3 ,
GPIO99_GPIO ,
} ;
static mfp_cfg_t pxa310_mfp_cfg [ ] __initdata = {
/* FFUART */
2008-01-08 18:25:01 +03:00
GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL ,
2007-09-12 06:13:17 +04:00
GPIO100_UART1_TXD ,
GPIO101_UART1_CTS ,
GPIO106_UART1_RTS ,
/* Ethernet */
GPIO2_nCS3 ,
GPIO102_GPIO ,
2007-12-21 14:27:08 +03:00
/* MMC3 */
GPIO7_2_MMC3_DAT0 ,
2008-01-08 18:25:01 +03:00
GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH ,
2007-12-21 14:27:08 +03:00
GPIO9_2_MMC3_DAT2 ,
GPIO10_2_MMC3_DAT3 ,
GPIO103_MMC3_CLK ,
GPIO105_MMC3_CMD ,
2007-09-12 06:13:17 +04:00
} ;
# define NUM_LCD_DETECT_PINS 7
static int lcd_detect_pins [ ] __initdata = {
MFP_PIN_GPIO71 , /* LCD_LDD_17 - ORIENT */
MFP_PIN_GPIO70 , /* LCD_LDD_16 - LCDID[5] */
MFP_PIN_GPIO75 , /* LCD_BIAS - LCDID[4] */
MFP_PIN_GPIO73 , /* LCD_LCLK - LCDID[3] */
MFP_PIN_GPIO72 , /* LCD_FCLK - LCDID[2] */
MFP_PIN_GPIO127 , /* LCD_CS_N - LCDID[1] */
MFP_PIN_GPIO76 , /* LCD_VSYNC - LCDID[0] */
} ;
static void __init zylonite_detect_lcd_panel ( void )
{
unsigned long mfpr_save [ NUM_LCD_DETECT_PINS ] ;
int i , gpio , id = 0 ;
/* save the original MFP settings of these pins and configure
* them as GPIO Input , DS01X , Pull Neither , Edge Clear
*/
for ( i = 0 ; i < NUM_LCD_DETECT_PINS ; i + + ) {
mfpr_save [ i ] = pxa3xx_mfp_read ( lcd_detect_pins [ i ] ) ;
pxa3xx_mfp_write ( lcd_detect_pins [ i ] , 0x8440 ) ;
}
for ( i = 0 ; i < NUM_LCD_DETECT_PINS ; i + + ) {
id = id < < 1 ;
gpio = mfp_to_gpio ( lcd_detect_pins [ i ] ) ;
2009-07-15 15:47:24 +04:00
gpio_request ( gpio , " LCD_ID_PINS " ) ;
2007-09-12 06:13:17 +04:00
gpio_direction_input ( gpio ) ;
if ( gpio_get_value ( gpio ) )
id = id | 0x1 ;
2009-07-15 15:47:24 +04:00
gpio_free ( gpio ) ;
2007-09-12 06:13:17 +04:00
}
/* lcd id, flush out bit 1 */
lcd_id = id & 0x3d ;
/* lcd orientation, portrait or landscape */
lcd_orientation = ( id > > 6 ) & 0x1 ;
/* restore the original MFP settings */
for ( i = 0 ; i < NUM_LCD_DETECT_PINS ; i + + )
pxa3xx_mfp_write ( lcd_detect_pins [ i ] , mfpr_save [ i ] ) ;
}
2008-05-28 06:44:16 +04:00
# if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
static struct pca953x_platform_data gpio_exp [ ] = {
[ 0 ] = {
. gpio_base = 128 ,
} ,
[ 1 ] = {
. gpio_base = 144 ,
} ,
} ;
2008-08-26 13:58:54 +04:00
static struct i2c_board_info zylonite_i2c_board_info [ ] = {
2008-05-28 06:44:16 +04:00
{
. type = " pca9539 " ,
. addr = 0x74 ,
. platform_data = & gpio_exp [ 0 ] ,
2011-10-10 10:21:08 +04:00
. irq = PXA_GPIO_TO_IRQ ( 18 ) ,
2008-05-28 06:44:16 +04:00
} , {
. type = " pca9539 " ,
. addr = 0x75 ,
. platform_data = & gpio_exp [ 1 ] ,
2011-10-10 10:21:08 +04:00
. irq = PXA_GPIO_TO_IRQ ( 19 ) ,
2008-05-28 06:44:16 +04:00
} ,
} ;
static void __init zylonite_init_i2c ( void )
{
pxa_set_i2c_info ( NULL ) ;
i2c_register_board_info ( 0 , ARRAY_AND_SIZE ( zylonite_i2c_board_info ) ) ;
}
# else
static inline void zylonite_init_i2c ( void ) { }
# endif
2007-09-12 06:13:17 +04:00
void __init zylonite_pxa300_init ( void )
{
if ( cpu_is_pxa300 ( ) | | cpu_is_pxa310 ( ) ) {
/* initialize MFP */
pxa3xx_mfp_config ( ARRAY_AND_SIZE ( common_mfp_cfg ) ) ;
/* detect LCD panel */
zylonite_detect_lcd_panel ( ) ;
2008-04-15 18:50:49 +04:00
/* WM9713 IRQ */
wm9713_irq = mfp_to_gpio ( MFP_PIN_GPIO26 ) ;
2008-05-28 06:44:16 +04:00
zylonite_init_i2c ( ) ;
2007-09-12 06:13:17 +04:00
}
if ( cpu_is_pxa300 ( ) ) {
pxa3xx_mfp_config ( ARRAY_AND_SIZE ( pxa300_mfp_cfg ) ) ;
gpio_eth_irq = mfp_to_gpio ( MFP_PIN_GPIO99 ) ;
}
if ( cpu_is_pxa310 ( ) ) {
pxa3xx_mfp_config ( ARRAY_AND_SIZE ( pxa310_mfp_cfg ) ) ;
gpio_eth_irq = mfp_to_gpio ( MFP_PIN_GPIO102 ) ;
}
2008-06-17 15:03:54 +04:00
/* GPIOs for Debug LEDs */
gpio_debug_led1 = EXT_GPIO ( 25 ) ;
gpio_debug_led2 = EXT_GPIO ( 26 ) ;
2007-09-12 06:13:17 +04:00
}