From patchwork Thu Jun 7 10:06:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Longchamp X-Patchwork-Id: 163566 X-Patchwork-Delegate: prafulla@marvell.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 75928B6FC2 for ; Thu, 7 Jun 2012 20:07:33 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E60428248; Thu, 7 Jun 2012 12:07:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VctIKJ4JpJzl; Thu, 7 Jun 2012 12:07:28 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2DB1A281EB; Thu, 7 Jun 2012 12:07:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D74F281FE for ; Thu, 7 Jun 2012 12:07:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AWns+DFgQCIX for ; Thu, 7 Jun 2012 12:07:05 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.ch.keymile.com (mail.ch.keymile.com [193.17.201.103]) by theia.denx.de (Postfix) with SMTP id 34567281DA for ; Thu, 7 Jun 2012 12:07:02 +0200 (CEST) Received: from SRVCHBER1212.ch.keymile.net ([172.31.32.9]) by eSafe SMTP Relay 1334159602; Thu, 07 Jun 2012 12:07:02 +0200 Received: from chber1-10533x.ch.keymile.net ([172.31.40.3]) by SRVCHBER1212.ch.keymile.net with Microsoft SMTPSVC(6.0.3790.4675); Thu, 7 Jun 2012 12:07:01 +0200 From: Valentin Longchamp To: To: prafulla@mavell.com Date: Thu, 7 Jun 2012 12:06:42 +0200 Message-Id: <1339063620-8890-3-git-send-email-valentin.longchamp@keymile.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1339063620-8890-1-git-send-email-valentin.longchamp@keymile.com> References: <1339063620-8890-1-git-send-email-valentin.longchamp@keymile.com> X-OriginalArrivalTime: 07 Jun 2012 10:07:01.0804 (UTC) FILETIME=[48563EC0:01CD4495] X-ESAFE-STATUS: [srvchber1306.keymile.net] Mail allowed Cc: Valentin Longchamp , u-boot@lists.denx.de, holger.brunck@keymile.com, Gerlando Falauto , Prafulla@theia.denx.de Subject: [U-Boot] [PATCH 02/20] arm/km: use correct kw_gpio function for NAND/SPI switching X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This used to be done with registers direct access, which is not clear and optimal. Signed-off-by: Valentin Longchamp Signed-off-by: Holger Brunck cc: Gerlando Falauto cc: Prafulla Wadaskar --- board/keymile/km_arm/km_arm.c | 53 +++++++++++++++++++++------------------- include/configs/km/km_arm.h | 1 + 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c index ed12b5c..e4ae1fb 100644 --- a/board/keymile/km_arm/km_arm.c +++ b/board/keymile/km_arm/km_arm.c @@ -247,15 +247,12 @@ int board_early_init_f(void) kirkwood_mpp_conf(kwmpp_config, NULL); /* - * The FLASH_GPIO_PIN switches between using a + * The KM_FLASH_GPIO_PIN switches between using a * NAND or a SPI FLASH. Set this pin on start * to NAND mode. */ - tmp = readl(KW_GPIO0_BASE); - writel(tmp | FLASH_GPIO_PIN , KW_GPIO0_BASE); - tmp = readl(KW_GPIO0_BASE + 4); - writel(tmp & (~FLASH_GPIO_PIN) , KW_GPIO0_BASE + 4); - + kw_gpio_set_valid(KM_FLASH_GPIO_PIN, 1); + kw_gpio_direction_output(KM_FLASH_GPIO_PIN, 1); #if defined(CONFIG_SOFT_I2C) /* init the GPIO for I2C Bitbang driver */ kw_gpio_set_valid(KM_KIRKWOOD_SDA_PIN, 1); @@ -284,35 +281,41 @@ int board_init(void) return 0; } +int km_hw_spi_bus_claim(int on) +{ + int gpio_value = !on; + + if (on) { + kwmpp_config[0] = MPP0_SPI_SCn; + kwmpp_config[1] = MPP1_SPI_MOSI; + kwmpp_config[2] = MPP2_SPI_SCK; + kwmpp_config[3] = MPP3_SPI_MISO; + } else { + kwmpp_config[0] = MPP0_NF_IO2; + kwmpp_config[1] = MPP1_NF_IO3; + kwmpp_config[2] = MPP2_NF_IO4; + kwmpp_config[3] = MPP3_NF_IO5; + } + + /* Multi-Purpose Pins Functionality configuration */ + kirkwood_mpp_conf(kwmpp_config, NULL); + kw_gpio_set_value(KM_FLASH_GPIO_PIN, gpio_value); + + return 0; +} + #if defined(CONFIG_CMD_SF) int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - u32 tmp; if (argc < 2) return cmd_usage(cmdtp); if ((strcmp(argv[1], "off") == 0)) { printf("SPI FLASH disabled, NAND enabled\n"); - /* Multi-Purpose Pins Functionality configuration */ - kwmpp_config[0] = MPP0_NF_IO2; - kwmpp_config[1] = MPP1_NF_IO3; - kwmpp_config[2] = MPP2_NF_IO4; - kwmpp_config[3] = MPP3_NF_IO5; - - kirkwood_mpp_conf(kwmpp_config, NULL); - tmp = readl(KW_GPIO0_BASE); - writel(tmp | FLASH_GPIO_PIN , KW_GPIO0_BASE); + km_hw_spi_bus_claim(0); } else if ((strcmp(argv[1], "on") == 0)) { printf("SPI FLASH enabled, NAND disabled\n"); - /* Multi-Purpose Pins Functionality configuration */ - kwmpp_config[0] = MPP0_SPI_SCn; - kwmpp_config[1] = MPP1_SPI_MOSI; - kwmpp_config[2] = MPP2_SPI_SCK; - kwmpp_config[3] = MPP3_SPI_MISO; - - kirkwood_mpp_conf(kwmpp_config, NULL); - tmp = readl(KW_GPIO0_BASE); - writel(tmp & (~FLASH_GPIO_PIN) , KW_GPIO0_BASE); + km_hw_spi_bus_claim(1); } else { return cmd_usage(cmdtp); } diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 056bf53..28b5021 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -231,6 +231,7 @@ int get_scl(void); #define CONFIG_SYS_KW_SPI_MPP 0x0 #define FLASH_GPIO_PIN 0x00010000 +#define KM_FLASH_GPIO_PIN 16 #define MTDIDS_DEFAULT "nand0=orion_nand" /* test-only: partitioning needs some tuning, this is just for tests */