From patchwork Mon May 13 08:00:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sonic Zhang X-Patchwork-Id: 243320 X-Patchwork-Delegate: sonic.adi@gmail.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 4CE4F2C00A7 for ; Mon, 13 May 2013 18:05:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1506C4A027; Mon, 13 May 2013 10:05:08 +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 fsSpxxm01Q7f; Mon, 13 May 2013 10:05:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A2EF4A026; Mon, 13 May 2013 10:05:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CD4824A02D for ; Mon, 13 May 2013 10:04:58 +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 fR9iU1hRVBMk for ; Mon, 13 May 2013 10:04:54 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=ERR(-1.5) (only DNSBL check requested) Received: from db8outboundpool.messaging.microsoft.com (mail-db8lp0184.outbound.messaging.microsoft.com [213.199.154.184]) by theia.denx.de (Postfix) with ESMTPS id 1FF9B4A023 for ; Mon, 13 May 2013 10:04:44 +0200 (CEST) Received: from mail199-db8-R.bigfish.com (10.174.8.254) by DB8EHSOBE011.bigfish.com (10.174.4.74) with Microsoft SMTP Server id 14.1.225.23; Mon, 13 May 2013 08:04:43 +0000 Received: from mail199-db8 (localhost [127.0.0.1]) by mail199-db8-R.bigfish.com (Postfix) with ESMTP id C4D88700351; Mon, 13 May 2013 08:04:43 +0000 (UTC) X-Forefront-Antispam-Report: CIP:137.71.25.57; KIP:(null); UIP:(null); IPV:NLI; H:nwd2mta2.analog.com; RD:nwd2mail11.analog.com; EFVD:NLI X-SpamScore: 7 X-BigFish: VS7(zzzz1f42h1ee6h1ce5h1fdah1202h1fd0h1e76h1d1ah1cabh1d2ah1fc6hzz8275bhz2ei87h2a8h668h839hd24he5bh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h13eah1441h14ddh1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fhff4m129fi1155h) Received-SPF: neutral (mail199-db8: 137.71.25.57 is neither permitted nor denied by domain of gmail.com) client-ip=137.71.25.57; envelope-from=sonic.adi@gmail.com; helo=nwd2mta2.analog.com ; 2.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail199-db8 (localhost.localdomain [127.0.0.1]) by mail199-db8 (MessageSwitch) id 1368432281177294_11276; Mon, 13 May 2013 08:04:41 +0000 (UTC) Received: from DB8EHSMHS026.bigfish.com (unknown [10.174.8.237]) by mail199-db8.bigfish.com (Postfix) with ESMTP id 27483A00051; Mon, 13 May 2013 08:04:41 +0000 (UTC) Received: from nwd2mta2.analog.com (137.71.25.57) by DB8EHSMHS026.bigfish.com (10.174.4.36) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 13 May 2013 08:04:39 +0000 Received: from NWD2HUBCAS6.ad.analog.com (nwd2hubcas6.ad.analog.com [10.64.72.159]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id r4D9X2Xs007680 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 13 May 2013 05:33:02 -0400 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS6.ad.analog.com (10.64.72.159) with Microsoft SMTP Server id 14.3.123.3; Mon, 13 May 2013 04:03:28 -0400 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.6/8.14.6) with ESMTP id r4D83Rxw031370; Mon, 13 May 2013 04:03:28 -0400 Received: from nine.analog.com (unknown [10.99.22.72]) by linux.site (Postfix) with ESMTP id E86434270FB8; Sun, 12 May 2013 18:37:02 -0600 (MDT) From: Sonic Zhang To: Date: Mon, 13 May 2013 16:00:56 +0800 Message-ID: <1368432056-10167-2-git-send-email-sonic.adi@gmail.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1368432056-10167-1-git-send-email-sonic.adi@gmail.com> References: <1368432056-10167-1-git-send-email-sonic.adi@gmail.com> MIME-Version: 1.0 Cc: u-boot-devel@blackfin.uclinux.org, Bob Liu , Sonic Zhang Subject: [U-Boot] [PATCH v2 2/2] blackfin: bf609: add softswitch config command 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Bob Liu Add softswitch_output command for bf609-ezkit to enable softswitches. Signed-off-by: Bob Liu Signed-off-by: Sonic Zhang Signed-off-by: Sonic Zhang --- Changes in v2: - Add documentation for CONFIG_CMD_SOFTSWITCH to top-level README. README | 1 + arch/blackfin/include/asm/soft_switch.h | 18 +++++++++++++++ board/bf609-ezkit/soft_switch.c | 11 +-------- board/bf609-ezkit/soft_switch.h | 25 +++++++++++++------- common/Makefile | 1 + common/cmd_softswitch.c | 41 +++++++++++++++++++++++++++++++++ include/configs/bf609-ezkit.h | 1 + 7 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 arch/blackfin/include/asm/soft_switch.h create mode 100644 common/cmd_softswitch.c diff --git a/README b/README index 0d37d56..defdedb 100644 --- a/README +++ b/README @@ -898,6 +898,7 @@ The following options need to be configured: CONFIG_CMD_SF * Read/write/erase SPI NOR flash CONFIG_CMD_SHA1SUM print sha1 memory digest (requires CONFIG_CMD_MEMORY) + CONFIG_CMD_SOFTSWITCH * Soft switch setting command for BF60x CONFIG_CMD_SOURCE "source" command Support CONFIG_CMD_SPI * SPI serial bus support CONFIG_CMD_TFTPSRV * TFTP transfer in server mode diff --git a/arch/blackfin/include/asm/soft_switch.h b/arch/blackfin/include/asm/soft_switch.h new file mode 100644 index 0000000..ff8e44d --- /dev/null +++ b/arch/blackfin/include/asm/soft_switch.h @@ -0,0 +1,18 @@ +/* + * U-boot - main board file + * + * Copyright (c) 2008-2012 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __SOFT_SWITCH_H__ +#define __SOFT_SWITCH_H__ + +#define IO_PORT_A 0 +#define IO_PORT_B 1 +#define IO_PORT_INPUT 0 +#define IO_PORT_OUTPUT 1 + +int config_switch_bit(int num, int port, int bit, int dir, uchar value); +#endif diff --git a/board/bf609-ezkit/soft_switch.c b/board/bf609-ezkit/soft_switch.c index 2e1404f..e0c8d93 100644 --- a/board/bf609-ezkit/soft_switch.c +++ b/board/bf609-ezkit/soft_switch.c @@ -12,14 +12,6 @@ #include #include "soft_switch.h" -#define SWITCH_ADDR 0x21 - -#define NUM_SWITCH 3 -#define IODIRA 0x0 -#define IODIRB 0x1 -#define OLATA 0x14 -#define OLATB 0x15 - struct switch_config { uchar dir0; /* IODIRA */ uchar dir1; /* IODIRB */ @@ -126,9 +118,8 @@ static int setup_soft_switch(int addr, struct switch_config *config) return i2c_write(addr, IODIRB, 1, &config->dir1, 1); } -int config_switch_bit(int num, int port, int bit, int dir, uchar value) +int config_switch_bit(int addr, int port, int bit, int dir, uchar value) { - int addr = SWITCH_ADDR + num; int ret, data_reg, dir_reg; uchar tmp; diff --git a/board/bf609-ezkit/soft_switch.h b/board/bf609-ezkit/soft_switch.h index 8da0e44..d147fe1 100644 --- a/board/bf609-ezkit/soft_switch.h +++ b/board/bf609-ezkit/soft_switch.h @@ -6,8 +6,10 @@ * Licensed under the GPL-2 or later. */ -#ifndef __SOFT_SWITCH_H__ -#define __SOFT_SWITCH_H__ +#ifndef __BOARD_SOFT_SWITCH_H__ +#define __BOARD_SOFT_SWITCH_H__ + +#include /* switch 0 port A */ #define CAN_EN 0x1 @@ -61,11 +63,18 @@ #define PD3_SPI0MOSI_EN 0x1 #define PD4_SPI0CK_EN 0x2 -#define IO_PORT_A 0 -#define IO_PORT_B 1 -#define IO_PORT_INPUT 0 -#define IO_PORT_OUTPUT 1 +#ifdef CONFIG_BFIN_BOARD_VERSION_1_0 +#define SWITCH_ADDR 0x21 +#else +#define SWITCH_ADDR 0x20 +#endif + +#define NUM_SWITCH 3 +#define IODIRA 0x0 +#define IODIRB 0x1 +#define OLATA 0x14 +#define OLATB 0x15 -int config_switch_bit(int num, int port, int bit, int dir, uchar value); int setup_board_switches(void); -#endif + +#endif /* __BOARD_SOFT_SWITCH_H__ */ diff --git a/common/Makefile b/common/Makefile index 0e0fff1..0429a3c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -164,6 +164,7 @@ COBJS-$(CONFIG_CMD_SF) += cmd_sf.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o COBJS-$(CONFIG_CMD_SHA1SUM) += cmd_sha1sum.o COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o +COBJS-$(CONFIG_CMD_SOFTSWITCH) += cmd_softswitch.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o diff --git a/common/cmd_softswitch.c b/common/cmd_softswitch.c new file mode 100644 index 0000000..f75d926 --- /dev/null +++ b/common/cmd_softswitch.c @@ -0,0 +1,41 @@ +/* + * cmd_softswitch.c - set the softswitch for bf60x + * + * Copyright (c) 2012 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include +#include +#include +#include + +int do_softswitch(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int switchaddr, value, pin, port; + + if (argc != 5) + return CMD_RET_USAGE; + + if (strcmp(argv[2], "GPA") == 0) + port = IO_PORT_A; + else if (strcmp(argv[2], "GPB") == 0) + port = IO_PORT_B; + else + return CMD_RET_USAGE; + + switchaddr = simple_strtoul(argv[1], NULL, 16); + pin = simple_strtoul(argv[3], NULL, 16); + value = simple_strtoul(argv[4], NULL, 16); + + config_switch_bit(switchaddr, port, (1 << pin), IO_PORT_OUTPUT, value); + + return 0; +} + +U_BOOT_CMD( + softswitch_output, 5, 1, do_softswitch, + "switchaddr GPA/GPB pin_offset value", + "" +); diff --git a/include/configs/bf609-ezkit.h b/include/configs/bf609-ezkit.h index 8b90129..f0ac86b 100644 --- a/include/configs/bf609-ezkit.h +++ b/include/configs/bf609-ezkit.h @@ -144,6 +144,7 @@ #define CONFIG_UART_CONSOLE 0 #define CONFIG_CMD_MEMORY +#define CONFIG_CMD_SOFTSWITCH #define CONFIG_SYS_MEMTEST_END (CONFIG_STACKBASE - 20*1024*1024 + 4) #define CONFIG_BFIN_SOFT_SWITCH