From patchwork Fri May 27 14:08:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 97688 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 B34F3B6F90 for ; Sat, 28 May 2011 00:09:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ACF8128102; Fri, 27 May 2011 16:09:12 +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 KYmhKXSY7rik; Fri, 27 May 2011 16:09:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8075628105; Fri, 27 May 2011 16:08:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21EA9280DD for ; Fri, 27 May 2011 16:08:43 +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 y2v48vF+ah9f for ; Fri, 27 May 2011 16:08:42 +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-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTP id 02C6C280B1 for ; Fri, 27 May 2011 16:08:35 +0200 (CEST) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id BB13E1824455; Fri, 27 May 2011 16:08:35 +0200 (CEST) X-Auth-Info: y8hf4//WLkmnkFzzVP3KlJcAKd2BwDiJXp4hhxt3VC4= Received: from localhost (p4FDE7632.dip.t-dialin.net [79.222.118.50]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA id 744201C00069; Fri, 27 May 2011 16:08:35 +0200 (CEST) From: Anatolij Gustschin To: u-boot@lists.denx.de Date: Fri, 27 May 2011 16:08:24 +0200 Message-Id: <1306505304-9593-6-git-send-email-agust@denx.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1306505304-9593-1-git-send-email-agust@denx.de> References: <1306505304-9593-1-git-send-email-agust@denx.de> Subject: [U-Boot] [PATCH 5/5] mpc5200: digsy_mtc: add support for writing 'appreg' value X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Up to now only reading 'appreg' value was implemented in the digsyMTC special 'mtc appreg' command. Extend the command to support writing appreg value, too. Signed-off-by: Werner Pfister Signed-off-by: Anatolij Gustschin Acked-by: Detlev Zundel --- board/digsy_mtc/cmd_mtc.c | 46 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 40 insertions(+), 6 deletions(-) diff --git a/board/digsy_mtc/cmd_mtc.c b/board/digsy_mtc/cmd_mtc.c index ba0c367..a12becf 100644 --- a/board/digsy_mtc/cmd_mtc.c +++ b/board/digsy_mtc/cmd_mtc.c @@ -31,6 +31,8 @@ DECLARE_GLOBAL_DATA_PTR; +static uchar user_out; + static const char *led_names[] = { "diag", "can1", @@ -112,6 +114,8 @@ static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else pcmd.cmd_val2 = 0; + pcmd.user_out = user_out; + mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -128,6 +132,7 @@ static int do_mtc_key(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) memset(&prx, 0, sizeof(prx)); pcmd.cmd = CMD_GET_VIM; + pcmd.user_out = user_out; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -160,6 +165,7 @@ static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv pcmd.cmd = CMD_GET_VIM; pcmd.user_out = channel_mask; + user_out = channel_mask; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -187,6 +193,7 @@ static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ memset(&prx, 0, sizeof(prx)); pcmd.cmd = CMD_GET_VIM; + pcmd.user_out = user_out; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -205,6 +212,7 @@ static int do_mtc_appreg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv rx_msp_cmd prx; int err; char buf[5]; + uchar appreg; /* read appreg */ memset(&pcmd, 0, sizeof(pcmd)); @@ -214,13 +222,34 @@ static int do_mtc_appreg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv pcmd.cmd_val0 = 5; /* max. Count */ pcmd.cmd_val1 = 5; /* max. Time */ pcmd.cmd_val2 = 0; /* =0 means read appreg */ + pcmd.user_out = user_out; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); + /* on success decide between read or write */ if (!err) { - sprintf(buf, "%d", prx.ack2); - setenv("appreg", buf); + if (argc == 2) { + appreg = simple_strtol(argv[1], NULL, 10); + if (appreg == 0) { + printf("mtc appreg: invalid parameter - " + "must be betwenn 1 and 255\n"); + return -1; + } + memset(&pcmd, 0, sizeof(pcmd)); + pcmd.cmd = CMD_WD_PARA; + pcmd.cmd_val0 = prx.ack3; /* max. Count */ + pcmd.cmd_val1 = prx.ack0; /* max. Time */ + pcmd.cmd_val2 = appreg; /* !=0 means write appreg */ + pcmd.user_out = user_out; + memset(&prx, 0, sizeof(prx)); + + mtc_calculate_checksum(&pcmd); + err = msp430_xfer(&pcmd, &prx); + } else { + sprintf(buf, "%d", prx.ack2); + setenv("appreg", buf); + } } return err; @@ -236,6 +265,7 @@ static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg memset(&prx, 0, sizeof(prx)); pcmd.cmd = CMD_FW_VERSION; + pcmd.user_out = user_out; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -259,6 +289,7 @@ static int do_mtc_state(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ pcmd.cmd = CMD_WD_WDSTATE; pcmd.cmd_val2 = 1; + pcmd.user_out = user_out; mtc_calculate_checksum(&pcmd); err = msp430_xfer(&pcmd, &prx); @@ -288,8 +319,10 @@ cmd_tbl_t cmd_mtc_sub[] = { "returns state of user key", ""), U_BOOT_CMD_MKENT(version, 0, 1, do_mtc_version, "returns firmware version of supervisor uC", ""), - U_BOOT_CMD_MKENT(appreg, 0, 1, do_mtc_appreg, - "reads appreg value and stores in environment variable 'appreg'", ""), + U_BOOT_CMD_MKENT(appreg, 1, 1, do_mtc_appreg, + "reads or writes appreg value and stores in environment " + "variable 'appreg'", + "[value] - value (1 - 255) to write to appreg"), U_BOOT_CMD_MKENT(digin, 1, 1, do_mtc_digin, "returns state of digital input", " - get state of digital input (1 or 2)\n"), @@ -342,8 +375,9 @@ U_BOOT_CMD(mtc, 5, 1, cmd_mtc, " [blink]: blink interval in 100ms steps (1 - 10; 0 = static)\n" "key - returns state of user key\n" "version - returns firmware version of supervisor uC\n" - "appreg - reads appreg value and stores in environment variable" - " 'appreg'\n" + "appreg [value] - reads (in environment variable 'appreg') or writes" + " appreg value\n" + " [value]: value (1 - 255) to write to appreg\n" "digin [channel] - returns state of digital input (1 or 2)\n" "digout - sets state of two digital outputs\n" "state - displays state\n"