From patchwork Wed Feb 27 08:37: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: 223551 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 26BC42C007E for ; Wed, 27 Feb 2013 19:35:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF3D74A028; Wed, 27 Feb 2013 09:35:27 +0100 (CET) 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 rB0lsHt8C5Wx; Wed, 27 Feb 2013 09:35:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0113F4A02A; Wed, 27 Feb 2013 09:35:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5562E4A023 for ; Wed, 27 Feb 2013 09:35:15 +0100 (CET) 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 UeUJJscxkY4Q for ; Wed, 27 Feb 2013 09:35:12 +0100 (CET) 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 ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) by theia.denx.de (Postfix) with ESMTPS id 1D3594A021 for ; Wed, 27 Feb 2013 09:35:10 +0100 (CET) Received: from mail119-ch1-R.bigfish.com (10.43.68.234) by CH1EHSOBE015.bigfish.com (10.43.70.65) with Microsoft SMTP Server id 14.1.225.23; Wed, 27 Feb 2013 08:35:08 +0000 Received: from mail119-ch1 (localhost [127.0.0.1]) by mail119-ch1-R.bigfish.com (Postfix) with ESMTP id AB927A0157; Wed, 27 Feb 2013 08:35:08 +0000 (UTC) X-Forefront-Antispam-Report: CIP:137.71.25.55; KIP:(null); UIP:(null); IPV:NLI; H:nwd2mta1.analog.com; RD:nwd2mail10.analog.com; EFVD:NLI X-SpamScore: 12 X-BigFish: VS12(zzzz1f42h1ee6h1ce5h1202h1e76h1d1ah1cabh1d2ahzz8275bhz2ei87h2a8h668h839hd24he5bh1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h13eah1441h1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5hff4m1355m129fi1155h) Received-SPF: neutral (mail119-ch1: 137.71.25.55 is neither permitted nor denied by domain of gmail.com) client-ip=137.71.25.55; envelope-from=sonic.adi@gmail.com; helo=nwd2mta1.analog.com ; 1.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail119-ch1 (localhost.localdomain [127.0.0.1]) by mail119-ch1 (MessageSwitch) id 1361954106736136_18670; Wed, 27 Feb 2013 08:35:06 +0000 (UTC) Received: from CH1EHSMHS023.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.254]) by mail119-ch1.bigfish.com (Postfix) with ESMTP id B0C1D34004E; Wed, 27 Feb 2013 08:35:06 +0000 (UTC) Received: from nwd2mta1.analog.com (137.71.25.55) by CH1EHSMHS023.bigfish.com (10.43.70.23) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 27 Feb 2013 08:35:06 +0000 Received: from NWD2HUBCAS5.ad.analog.com (nwd2hubcas5.ad.analog.com [10.64.72.161]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id r1R8Z6Uq024232 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 27 Feb 2013 00:35:06 -0800 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS5.ad.analog.com (10.64.72.161) with Microsoft SMTP Server id 14.2.328.9; Wed, 27 Feb 2013 03:35:05 -0500 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.5/8.14.5) with ESMTP id r1R8Z4WV001407; Wed, 27 Feb 2013 03:35:04 -0500 Received: from localhost.localdomain (unknown [10.99.22.81]) by linux.site (Postfix) with ESMTP id 338E542CE1B8; Tue, 26 Feb 2013 18:06:45 -0700 (MST) From: Sonic Zhang To: Wolfgang Denk , Date: Wed, 27 Feb 2013 16:37:56 +0800 Message-ID: <1361954276-9657-2-git-send-email-sonic.adi@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1361954276-9657-1-git-send-email-sonic.adi@gmail.com> References: <1361954276-9657-1-git-send-email-sonic.adi@gmail.com> MIME-Version: 1.0 Cc: u-boot-devel@blackfin.uclinux.org, Sonic Zhang Subject: [U-Boot] [PATCH v1 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 --- 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 + 6 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 arch/blackfin/include/asm/soft_switch.h create mode 100644 common/cmd_softswitch.c 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 54fcc81..80fee78 100644 --- a/common/Makefile +++ b/common/Makefile @@ -157,6 +157,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