From patchwork Fri Oct 16 19:09:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 54385 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 n9GJJESW013074 for ; Fri, 16 Oct 2009 19:19:14 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9GJJDwa014699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 16 Oct 2009 14:19:14 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id n9GJJDKg023300 for ; Fri, 16 Oct 2009 14:19:13 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 25BB880A97 for ; Fri, 16 Oct 2009 14:17:27 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id F346680649 for ; Fri, 16 Oct 2009 14:13:39 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n9GJDd2F015172 for ; Fri, 16 Oct 2009 14:13:39 -0500 (CDT) Received: from mail113-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.113]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9GJDdb1028679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 16 Oct 2009 14:13:39 -0500 Received: from mail113-va3 (localhost.localdomain [127.0.0.1]) by mail113-va3-R.bigfish.com (Postfix) with ESMTP id ABD065C8779 for ; Fri, 16 Oct 2009 19:13:38 +0000 (UTC) X-SpamScore: 7 X-BigFish: vps7(zza4b1ozz1202hzzz2dh6bh61h) X-Spam-TCS-SCL: 0:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 209.85.219.220; Service: EHS Received: by mail113-va3 (MessageSwitch) id 1255720416427847_13584; Fri, 16 Oct 2009 19:13:36 +0000 (UCT) Received: from VA3EHSMHS015.bigfish.com (unknown [10.7.14.251]) by mail113-va3.bigfish.com (Postfix) with ESMTP id 65A8B6B8053 for ; Fri, 16 Oct 2009 19:13:36 +0000 (UTC) Received: from mail-ew0-f220.google.com (209.85.219.220) by VA3EHSMHS015.bigfish.com (10.7.99.25) with Microsoft SMTP Server id 14.0.482.32; Fri, 16 Oct 2009 19:13:35 +0000 Received: by mail-ew0-f220.google.com with SMTP id 20so2500484ewy.40 for ; Fri, 16 Oct 2009 12:13:34 -0700 (PDT) Received: by 10.216.90.79 with SMTP id d57mr686867wef.117.1255720414356; Fri, 16 Oct 2009 12:13:34 -0700 (PDT) Received: from localhost ([216.254.16.51]) by mx.google.com with ESMTPS id u14sm3123288gvf.18.2009.10.16.12.13.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Oct 2009 12:13:33 -0700 (PDT) From: Kevin Hilman To: linux-arm-kernel@lists.infradead.org Date: Fri, 16 Oct 2009 12:09:44 -0700 Message-ID: <1255720190-7452-42-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.4.3 In-Reply-To: <1255720190-7452-41-git-send-email-khilman@deeprootsystems.com> References: <1255720190-7452-1-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-2-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-3-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-4-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-5-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-6-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-7-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-8-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-9-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-10-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-11-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-12-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-13-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-14-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-15-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-16-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-17-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-18-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-19-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-20-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-21-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-22-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-23-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-24-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-25-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-26-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-27-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-28-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-29-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-30-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-31-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-32-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-33-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-34-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-35-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-36-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-37-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-38-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-39-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-40-git-send-email-khilman@deeprootsystems.com> <1255720190-7452-41-git-send-email-khilman@deeprootsystems.com> MIME-Version: 1.0 X-Reverse-DNS: mail-ew0-f220.google.com Cc: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 40/46] davinci: DA850/OMAP-L138 EVM expander setup and UI card detection 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+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index a34df64..05b2d87 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -145,10 +146,85 @@ static struct platform_device da850_evm_nandflash_device = { .resource = da850_evm_nandflash_resource, }; +static u32 ui_card_detected; +static void da850_evm_setup_nor_nand(void); + +static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, + unsigned ngpio, void *c) +{ + int sel_a, sel_b, sel_c, ret; + + sel_a = gpio + 7; + sel_b = gpio + 6; + sel_c = gpio + 5; + + ret = gpio_request(sel_a, "sel_a"); + if (ret) { + pr_warning("Cannot open UI expander pin %d\n", sel_a); + goto exp_setup_sela_fail; + } + + ret = gpio_request(sel_b, "sel_b"); + if (ret) { + pr_warning("Cannot open UI expander pin %d\n", sel_b); + goto exp_setup_selb_fail; + } + + ret = gpio_request(sel_c, "sel_c"); + if (ret) { + pr_warning("Cannot open UI expander pin %d\n", sel_c); + goto exp_setup_selc_fail; + } + + /* deselect all functionalities */ + gpio_direction_output(sel_a, 1); + gpio_direction_output(sel_b, 1); + gpio_direction_output(sel_c, 1); + + ui_card_detected = 1; + pr_info("DA850/OMAP-L138 EVM UI card detected\n"); + + da850_evm_setup_nor_nand(); + + return 0; + +exp_setup_selc_fail: + gpio_free(sel_b); +exp_setup_selb_fail: + gpio_free(sel_a); +exp_setup_sela_fail: + return ret; +} + +static int da850_evm_ui_expander_teardown(struct i2c_client *client, + unsigned gpio, unsigned ngpio, void *c) +{ + /* deselect all functionalities */ + gpio_set_value(gpio + 5, 1); + gpio_set_value(gpio + 6, 1); + gpio_set_value(gpio + 7, 1); + + gpio_free(gpio + 5); + gpio_free(gpio + 6); + gpio_free(gpio + 7); + + return 0; +} + +static struct pca953x_platform_data da850_evm_ui_expander_info = { + .gpio_base = DAVINCI_N_GPIO, + .setup = da850_evm_ui_expander_setup, + .teardown = da850_evm_ui_expander_teardown, +}; + static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { { I2C_BOARD_INFO("tlv320aic3x", 0x18), - } + }, + { + I2C_BOARD_INFO("tca6416", 0x20), + .platform_data = &da850_evm_ui_expander_info, + }, }; static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { @@ -399,13 +475,6 @@ static int __init pmic_tps65070_init(void) ARRAY_SIZE(da850evm_tps65070_info)); } -#if defined(CONFIG_MTD_PHYSMAP) || \ - defined(CONFIG_MTD_PHYSMAP_MODULE) -#define HAS_NOR 1 -#else -#define HAS_NOR 0 -#endif - #if defined(CONFIG_MMC_DAVINCI) || \ defined(CONFIG_MMC_DAVINCI_MODULE) #define HAS_MMC 1 @@ -413,6 +482,28 @@ static int __init pmic_tps65070_init(void) #define HAS_MMC 0 #endif +static void da850_evm_setup_nor_nand(void) +{ + int ret = 0; + + if (ui_card_detected & !HAS_MMC) { + ret = da8xx_pinmux_setup(da850_nand_pins); + if (ret) + pr_warning("da850_evm_init: nand mux setup failed: " + "%d\n", ret); + + ret = da8xx_pinmux_setup(da850_nor_pins); + if (ret) + pr_warning("da850_evm_init: nor mux setup failed: %d\n", + ret); + + da850_evm_init_nor(); + + platform_add_devices(da850_evm_devices, + ARRAY_SIZE(da850_evm_devices)); + } +} + static const short da850_evm_lcdc_pins[] = { DA850_GPIO2_8, DA850_GPIO2_15, -1 @@ -428,21 +519,6 @@ static __init void da850_evm_init(void) pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n", ret); - ret = da8xx_pinmux_setup(da850_nand_pins); - if (ret) - pr_warning("da850_evm_init: nand mux setup failed: %d\n", - ret); - - ret = da8xx_pinmux_setup(da850_nor_pins); - if (ret) - pr_warning("da850_evm_init: nor mux setup failed: %d\n", - ret); - - da850_evm_init_nor(); - - platform_add_devices(da850_evm_devices, - ARRAY_SIZE(da850_evm_devices)); - ret = da8xx_register_edma(); if (ret) pr_warning("da850_evm_init: edma registration failed: %d\n", @@ -478,11 +554,6 @@ static __init void da850_evm_init(void) ret); if (HAS_MMC) { - if (HAS_NOR) - pr_warning("WARNING: both NOR Flash and MMC/SD are " - "enabled, but they share AEMIF pins.\n" - "\tDisable one of them.\n"); - ret = da8xx_pinmux_setup(da850_mmcsd0_pins); if (ret) pr_warning("da850_evm_init: mmcsd0 mux setup failed:"