From b40dd46a861738be1086b8037544e2648a9ed488 Mon Sep 17 00:00:00 2001 From: Avinash A Date: Fri, 9 Sep 2011 18:56:20 +0530 Subject: mach-ux500: dynamic detection of uibs Detect the uibs dynamically and resolve the conflict between the pins used for SPI with the cypress touchscreen and the keypad pins on other boards ref commit-id: I3bb7672cebe4e9696c7df6846d6031841f87ea58 Signed-off-by: Avinash A Change-Id: I661a0939e1b10dc4e1e8f21ff07f3070a7dc6963 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/30589 Reviewed-by: Avinash A Tested-by: Avinash A --- arch/arm/mach-ux500/board-mop500-pins.c | 9 +++++++ arch/arm/mach-ux500/board-mop500-uib.c | 41 ++++++++++++++++++++--------- arch/arm/mach-ux500/board-mop500.c | 5 ---- arch/arm/mach-ux500/board-mop500.h | 2 ++ arch/arm/mach-ux500/include/mach/hardware.h | 13 +++++++++ 5 files changed, 53 insertions(+), 17 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index 32f3a014d6c..44bf0d17549 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -394,6 +394,14 @@ static UX500_PINS(mop500_pins_usb, GPIO267_USB_DAT0, ); +/* SPI2 */ +static UX500_PINS(mop500_pins_spi2, + GPIO216_GPIO | PIN_OUTPUT_HIGH, + GPIO218_SPI2_RXD | PIN_INPUT_PULLDOWN, + GPIO215_SPI2_TXD | PIN_OUTPUT_LOW, + GPIO217_SPI2_CLK | PIN_OUTPUT_LOW, +); + static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("mcde-dpi", &mop500_pins_mcde_dpi), PIN_LOOKUP("mcde-tvout", &mop500_pins_mcde_tvout), @@ -408,6 +416,7 @@ static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("sdi2", &mop500_pins_sdi2), PIN_LOOKUP("sdi4", &mop500_pins_sdi4), PIN_LOOKUP("ab8500-usb.0", &mop500_pins_usb), + PIN_LOOKUP("spi2", &mop500_pins_spi2), }; /* diff --git a/arch/arm/mach-ux500/board-mop500-uib.c b/arch/arm/mach-ux500/board-mop500-uib.c index f4dfd52541c..2a5d50aa286 100644 --- a/arch/arm/mach-ux500/board-mop500-uib.c +++ b/arch/arm/mach-ux500/board-mop500-uib.c @@ -17,6 +17,7 @@ enum mop500_uib { STUIB, U8500UIB, + U8500UIB_R3, }; struct uib { @@ -36,6 +37,11 @@ static struct uib __initdata mop500_uibs[] = { .option = "u8500uib", .init = mop500_u8500uib_init, }, + [U8500UIB_R3] = { + .name = "U8500-UIBR3", + .option = "u8500uibr3", + .init = mop500_u8500uib_r3_init, + }, }; static struct uib __initdata *mop500_uib; @@ -98,18 +104,14 @@ static void __init __mop500_uib_init(struct uib *uib, const char *why) */ static int __init mop500_uib_init(void) { - struct uib *uib = mop500_uib; + struct uib *uib = mop500_uibs; struct i2c_adapter *i2c0; + struct i2c_adapter *i2c3; int ret; if (!cpu_is_u8500()) return -ENODEV; - if (uib) { - __mop500_uib_init(uib, "from uib= boot argument"); - return 0; - } - i2c0 = i2c_get_adapter(0); if (!i2c0) { __mop500_uib_init(&mop500_uibs[STUIB], @@ -121,12 +123,27 @@ static int __init mop500_uib_init(void) ret = i2c_smbus_xfer(i2c0, 0x44, 0, I2C_SMBUS_WRITE, 0, I2C_SMBUS_QUICK, NULL); i2c_put_adapter(i2c0); - - if (ret == 0) - uib = &mop500_uibs[U8500UIB]; - else - uib = &mop500_uibs[STUIB]; - + i2c3 = i2c_get_adapter(3); + if (ret == 0) { + if (!i2c3) { + __mop500_uib_init(&mop500_uibs[STUIB], + "fallback, could not get i2c3"); + return -ENODEV; + } + ret = i2c_smbus_xfer(i2c3, 0x4B, 0, I2C_SMBUS_WRITE, 0, + I2C_SMBUS_QUICK, NULL); + if (ret == 0) + uib = &mop500_uibs[U8500UIB]; + else + uib = &mop500_uibs[U8500UIB_R3]; + } + else { + ret = i2c_smbus_xfer(i2c3, 0x5C, 0, I2C_SMBUS_WRITE, 0, + I2C_SMBUS_QUICK, NULL); + i2c_put_adapter(i2c3); + if (ret == 0) + uib = &mop500_uibs[STUIB]; + } __mop500_uib_init(uib, "detected"); return 0; diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 414b3e10d5a..c485c9f4312 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -39,7 +39,6 @@ #include #include -#include #include #include @@ -926,10 +925,6 @@ static struct pl022_ssp_controller ssp0_plat = { */ .num_chipselect = NUM_SSP_CLIENTS, }; -static struct pl022_ssp_controller mop500_spi2_data = { - .bus_id = SPI023_2_CONTROLLER, - .num_chipselect = NUM_SSP_CLIENTS, -}; static void __init mop500_spi_init(struct device *parent) { diff --git a/arch/arm/mach-ux500/board-mop500.h b/arch/arm/mach-ux500/board-mop500.h index 3eb8641c1f6..863ebe05f2c 100644 --- a/arch/arm/mach-ux500/board-mop500.h +++ b/arch/arm/mach-ux500/board-mop500.h @@ -88,6 +88,8 @@ void __init mop500_msp_init(void); void __init mop500_pins_init(void); void __init hrefv60_pins_init(void); void __init snowball_pins_init(void); +void mop500_cyttsp_init(void); +void __init mop500_u8500uib_r3_init(void); void mop500_uib_i2c_add(int busnum, struct i2c_board_info const *info, unsigned n); diff --git a/arch/arm/mach-ux500/include/mach/hardware.h b/arch/arm/mach-ux500/include/mach/hardware.h index 273f84781ff..87e54c415df 100644 --- a/arch/arm/mach-ux500/include/mach/hardware.h +++ b/arch/arm/mach-ux500/include/mach/hardware.h @@ -41,6 +41,19 @@ #define CRYP1_RX_REG_OFFSET 0x10 #define CRYP1_TX_REG_OFFSET 0x8 +#define MSP_0_CONTROLLER 1 +#define MSP_1_CONTROLLER 2 +#define MSP_2_CONTROLLER 3 +#define MSP_3_CONTROLLER 4 + +#define SSP_0_CONTROLLER 4 +#define SSP_1_CONTROLLER 5 + +#define SPI023_0_CONTROLLER 6 +#define SPI023_1_CONTROLLER 7 +#define SPI023_2_CONTROLLER 8 +#define SPI023_3_CONTROLLER 9 + #ifndef __ASSEMBLY__ #include -- cgit v1.2.3