From patchwork Wed Oct 21 15:48:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 55140 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9LFwITo032259 for ; Wed, 21 Oct 2009 15:58:19 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9LFmYuK010944 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Oct 2009 10:48:35 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id n9LFmUjJ006438; Wed, 21 Oct 2009 10:48:34 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 516F48062B; Wed, 21 Oct 2009 10:48:30 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp31.itg.ti.com (dbdp31.itg.ti.com [172.24.170.98]) by linux.omap.com (Postfix) with ESMTP id 43F1F80628 for ; Wed, 21 Oct 2009 10:48:27 -0500 (CDT) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id n9LFmOcL027399; Wed, 21 Oct 2009 21:18:25 +0530 (IST) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by psplinux051.india.ti.com (8.13.1/8.13.1) with ESMTP id n9LFmOSU015701; Wed, 21 Oct 2009 21:18:24 +0530 Received: (from a0875516@localhost) by psplinux051.india.ti.com (8.13.1/8.13.1/Submit) id n9LFmOnd015698; Wed, 21 Oct 2009 21:18:24 +0530 From: Sekhar Nori To: davinci-linux-open-source@linux.davincidsp.com Date: Wed, 21 Oct 2009 21:18:20 +0530 Message-Id: <1256140104-15606-1-git-send-email-nsekhar@ti.com> X-Mailer: git-send-email 1.6.2.4 Cc: Subject: [PATCH v3 1/5] davinci: DA830/OMAP-L137 EVM: use runtime detection for UI card X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index be92240..1031262 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -100,21 +100,18 @@ config MACH_DAVINCI_DA830_EVM bool "TI DA830/OMAP-L137 Reference Platform" default ARCH_DAVINCI_DA830 depends on ARCH_DAVINCI_DA830 + select GPIO_PCF857X help Say Y here to select the TI DA830/OMAP-L137 Evaluation Module. -config DA830_UI - bool "DA830/OMAP-L137 UI (User Interface) board support" - depends on MACH_DAVINCI_DA830_EVM - help - Say Y here if you have the DA830/OMAP-L137 UI - (User Interface) board installed and you want to - enable the peripherals located on User Interface - board. - choice prompt "Select DA830/OMAP-L137 UI board peripheral" - depends on DA830_UI + depends on MACH_DAVINCI_DA830_EVM + help + The presence of UI card on the DA830/OMAP-L137 EVM is detected + automatically based on successful probe of the I2C based GPIO + expander on that board. This option selected in this menu has + an effect only in case of a successful UI card detection. config DA830_UI_LCD bool "LCD" diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index d2159e7..6de058f 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c @@ -36,58 +36,6 @@ #define DA830_EMIF25_ASYNC_DATA_CE3_BASE 0x62000000 #define DA830_EMIF25_CONTROL_BASE 0x68000000 -static struct at24_platform_data da830_evm_i2c_eeprom_info = { - .byte_len = SZ_256K / 8, - .page_size = 64, - .flags = AT24_FLAG_ADDR16, - .setup = davinci_get_mac_addr, - .context = (void *)0x7f00, -}; - -static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio, - unsigned ngpio, void *context) -{ - gpio_request(gpio + 6, "MUX_MODE"); -#ifdef CONFIG_DA830_UI_LCD - gpio_direction_output(gpio + 6, 0); -#else /* Must be NAND or NOR */ - gpio_direction_output(gpio + 6, 1); -#endif - return 0; -} - -static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio, - unsigned ngpio, void *context) -{ - gpio_free(gpio + 6); - return 0; -} - -static struct pcf857x_platform_data da830_evm_ui_expander_info = { - .gpio_base = DAVINCI_N_GPIO, - .setup = da830_evm_ui_expander_setup, - .teardown = da830_evm_ui_expander_teardown, -}; - -static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { - { - I2C_BOARD_INFO("24c256", 0x50), - .platform_data = &da830_evm_i2c_eeprom_info, - }, - { - I2C_BOARD_INFO("tlv320aic3x", 0x18), - }, - { - I2C_BOARD_INFO("pcf8574", 0x3f), - .platform_data = &da830_evm_ui_expander_info, - }, -}; - -static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = { - .bus_freq = 100, /* kHz */ - .bus_delay = 0, /* usec */ -}; - /* * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4]. */ @@ -396,7 +344,7 @@ static struct platform_device da830_evm_nand_device = { .resource = da830_evm_nand_resources, }; -static inline void da830_evm_init_nand(void) +static inline void da830_evm_init_nand(int mux_mode) { int ret; @@ -408,13 +356,15 @@ static inline void da830_evm_init_nand(void) ret = platform_device_register(&da830_evm_nand_device); if (ret) pr_warning("da830_evm_init: NAND device not registered.\n"); + + gpio_direction_output(mux_mode, 1); } #else -static inline void da830_evm_init_nand(void) { } +static inline void da830_evm_init_nand(int mux_mode) { } #endif #ifdef CONFIG_DA830_UI_LCD -static inline void da830_evm_init_lcdc(void) +static inline void da830_evm_init_lcdc(int mux_mode) { int ret; @@ -426,11 +376,65 @@ static inline void da830_evm_init_lcdc(void) ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata); if (ret) pr_warning("da830_evm_init: lcd setup failed: %d\n", ret); + + gpio_direction_output(mux_mode, 0); } #else -static inline void da830_evm_init_lcdc(void) { } +static inline void da830_evm_init_lcdc(int mux_mode) { } #endif +static struct at24_platform_data da830_evm_i2c_eeprom_info = { + .byte_len = SZ_256K / 8, + .page_size = 64, + .flags = AT24_FLAG_ADDR16, + .setup = davinci_get_mac_addr, + .context = (void *)0x7f00, +}; + +static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio, + unsigned ngpio, void *context) +{ + gpio_request(gpio + 6, "MUX_MODE"); + + da830_evm_init_lcdc(gpio + 6); + + da830_evm_init_nand(gpio + 6); + + return 0; +} + +static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio, + unsigned ngpio, void *context) +{ + gpio_free(gpio + 6); + return 0; +} + +static struct pcf857x_platform_data da830_evm_ui_expander_info = { + .gpio_base = DAVINCI_N_GPIO, + .setup = da830_evm_ui_expander_setup, + .teardown = da830_evm_ui_expander_teardown, +}; + +static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { + { + I2C_BOARD_INFO("24c256", 0x50), + .platform_data = &da830_evm_i2c_eeprom_info, + }, + { + I2C_BOARD_INFO("tlv320aic3x", 0x18), + }, + { + I2C_BOARD_INFO("pcf8574", 0x3f), + .platform_data = &da830_evm_ui_expander_info, + }, +}; + +static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = { + .bus_freq = 100, /* kHz */ + .bus_delay = 0, /* usec */ +}; + static __init void da830_evm_init(void) { struct davinci_soc_info *soc_info = &davinci_soc_info; @@ -485,10 +489,6 @@ static __init void da830_evm_init(void) da830_evm_init_mmc(); - da830_evm_init_lcdc(); - - da830_evm_init_nand(); - ret = da8xx_register_rtc(); if (ret) pr_warning("da830_evm_init: rtc setup failed: %d\n", ret);