[U-Boot] [PATCH 0/4] Series of bugfixes for the digsy_mtc platform

Well actually there is one commit adding a (mostly trivial) subcommand to our own private command, but I still hope that the complete series can be applied.
Anatolij Gustschin (1): digsy_mtc: minor fixes for mtc command help
Detlev Zundel (2): digsy_mtc: Add delay in SPI transfers to the companion controller. digsy_mtc: Update default environment
Grzegorz Bernacki (1): digsy_mtc: Add mtc state command.
board/digsy_mtc/cmd_mtc.c | 80 +++++++++++++++++++++-------- board/digsy_mtc/cmd_mtc.h | 1 + include/configs/digsy_mtc.h | 120 +++++++++++++++++++++++++++++++++++------- 3 files changed, 160 insertions(+), 41 deletions(-)

From: Grzegorz Bernacki gjb@semihalf.com
Signed-off-by: Grzegorz Bernacki gjb@semihalf.com --- board/digsy_mtc/cmd_mtc.c | 30 ++++++++++++++++++++++++++++++ board/digsy_mtc/cmd_mtc.h | 1 + 2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/board/digsy_mtc/cmd_mtc.c b/board/digsy_mtc/cmd_mtc.c index 2ecb4f8..dc16771 100644 --- a/board/digsy_mtc/cmd_mtc.c +++ b/board/digsy_mtc/cmd_mtc.c @@ -246,6 +246,34 @@ static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return err; }
+static int do_mtc_state(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_WD_WDSTATE; + pcmd.cmd_val2 = 1; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + if (!err) { + printf("State %02Xh\n", prx.state); + printf("Input %02Xh\n", prx.input); + printf("UserWD %02Xh\n", prx.ack2); + printf("Sys WD %02Xh\n", prx.ack3); + printf("WD Timout %02Xh\n", prx.ack0); + printf("eSysState %02Xh\n", prx.ack1); + } + + return err; +} + static int do_mtc_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
cmd_tbl_t cmd_mtc_sub[] = { @@ -267,6 +295,8 @@ cmd_tbl_t cmd_mtc_sub[] = { U_BOOT_CMD_MKENT(digout, 2, 1, do_mtc_digout, "sets digital outputs", "<on|off> <on|off>- set state of digital output 1 and 2\n"), + U_BOOT_CMD_MKENT(state, 0, 1, do_mtc_state, + "displays state\n", ""), U_BOOT_CMD_MKENT(help, 4, 1, do_mtc_help, "get help", "[command] - get help for command\n"), }; diff --git a/board/digsy_mtc/cmd_mtc.h b/board/digsy_mtc/cmd_mtc.h index db3aeed..81714e3 100644 --- a/board/digsy_mtc/cmd_mtc.h +++ b/board/digsy_mtc/cmd_mtc.h @@ -27,6 +27,7 @@ #define CMD_MTC_H
#define CMD_WD_PARA 0x02 +#define CMD_WD_WDSTATE 0x04 #define CMD_FW_VERSION 0x10 #define CMD_GET_VIM 0x30 #define CMD_SET_LED 0x40

From: Anatolij Gustschin agust@denx.de
Add mtc state subcommand description to the help of mtc command.
Remove some newlines in description of commands for proper help formating.
Signed-off-by: Anatolij Gustschin agust@denx.de --- board/digsy_mtc/cmd_mtc.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/board/digsy_mtc/cmd_mtc.c b/board/digsy_mtc/cmd_mtc.c index dc16771..c9faa01 100644 --- a/board/digsy_mtc/cmd_mtc.c +++ b/board/digsy_mtc/cmd_mtc.c @@ -284,11 +284,11 @@ cmd_tbl_t cmd_mtc_sub[] = { " - state: off red green orange\n" " - blink: blink interval in 100ms steps (1 - 10; 0 = static)\n"), U_BOOT_CMD_MKENT(key, 0, 1, do_mtc_key, - "returns state of user key\n", ""), + "returns state of user key", ""), U_BOOT_CMD_MKENT(version, 0, 1, do_mtc_version, - "returns firmware version of supervisor uC\n", ""), + "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'\n", ""), + "reads appreg value and stores in environment variable 'appreg'", ""), U_BOOT_CMD_MKENT(digin, 1, 1, do_mtc_digin, "returns state of digital input", "<channel_num> - get state of digital input (1 or 2)\n"), @@ -296,7 +296,7 @@ cmd_tbl_t cmd_mtc_sub[] = { "sets digital outputs", "<on|off> <on|off>- set state of digital output 1 and 2\n"), U_BOOT_CMD_MKENT(state, 0, 1, do_mtc_state, - "displays state\n", ""), + "displays state", ""), U_BOOT_CMD_MKENT(help, 4, 1, do_mtc_help, "get help", "[command] - get help for command\n"), }; @@ -363,7 +363,7 @@ int cmd_mtc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }
U_BOOT_CMD(mtc, 5, 1, cmd_mtc, - "mtc - special commands for digsyMTC\n", + "special commands for digsyMTC", "[subcommand] [args...]\n" "Subcommands list:\n" "led [ledname] [state] [blink] - set state of leds\n" @@ -376,5 +376,6 @@ U_BOOT_CMD(mtc, 5, 1, cmd_mtc, " 'appreg'\n" "digin [channel] - returns state of digital input (1 or 2)\n" "digout <on|off> <on|off> - sets state of two digital outputs\n" + "state - displays state\n" "help [subcommand] - get help for subcommand\n" );

While at it, remove initialization of variables which will be set before usage in all cases.
Signed-off-by: Detlev Zundel dzu@denx.de --- board/digsy_mtc/cmd_mtc.c | 47 +++++++++++++++++++++++++------------------- 1 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/board/digsy_mtc/cmd_mtc.c b/board/digsy_mtc/cmd_mtc.c index c9faa01..aa39611 100644 --- a/board/digsy_mtc/cmd_mtc.c +++ b/board/digsy_mtc/cmd_mtc.c @@ -44,6 +44,19 @@ static const char *led_names[] = { "" };
+static int msp430_xfer(const void *dout, void *din) +{ + int err; + + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, dout, din, + SPI_XFER_BEGIN | SPI_XFER_END); + + /* The MSP chip needs time to ready itself for the next command */ + udelay(1000); + + return err; +} + static void mtc_calculate_checksum(tx_msp_cmd *packet) { int i; @@ -59,7 +72,7 @@ static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err; int i;
if (argc < 2) { @@ -102,8 +115,7 @@ static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd_val2 = 0;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
return err; } @@ -112,7 +124,7 @@ static int do_mtc_key(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err;
memset(&pcmd, 0, sizeof(pcmd)); memset(&prx, 0, sizeof(prx)); @@ -120,8 +132,7 @@ static int do_mtc_key(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd = CMD_GET_VIM;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
if (!err) { /* function returns '0' if key is pressed */ @@ -135,7 +146,7 @@ static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err; uchar channel_mask = 0;
if (argc < 3) { @@ -155,8 +166,7 @@ static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.user_out = channel_mask;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
return err; } @@ -165,7 +175,7 @@ static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err; uchar channel_num = 0;
if (argc < 2) { @@ -185,8 +195,7 @@ static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd = CMD_GET_VIM;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
if (!err) { /* function returns '0' when digin is on */ @@ -213,8 +222,8 @@ static int do_mtc_appreg(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd_val2 = 0; /* =0 means read appreg */
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx); + if (!err) { sprintf(buf, "%d", prx.ack2); setenv("appreg", buf); @@ -227,7 +236,7 @@ static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err;
memset(&pcmd, 0, sizeof(pcmd)); memset(&prx, 0, sizeof(prx)); @@ -235,8 +244,7 @@ static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd = CMD_FW_VERSION;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
if (!err) { printf("FW V%d.%d.%d / HW %d\n", @@ -250,7 +258,7 @@ static int do_mtc_state(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { tx_msp_cmd pcmd; rx_msp_cmd prx; - int err = 0; + int err;
memset(&pcmd, 0, sizeof(pcmd)); memset(&prx, 0, sizeof(prx)); @@ -259,8 +267,7 @@ static int do_mtc_state(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pcmd.cmd_val2 = 1;
mtc_calculate_checksum(&pcmd); - err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, - SPI_XFER_BEGIN | SPI_XFER_END); + err = msp430_xfer(&pcmd, &prx);
if (!err) { printf("State %02Xh\n", prx.state);

Signed-off-by: Detlev Zundel dzu@denx.de --- include/configs/digsy_mtc.h | 120 +++++++++++++++++++++++++++++++++++------- 1 files changed, 100 insertions(+), 20 deletions(-)
diff --git a/include/configs/digsy_mtc.h b/include/configs/digsy_mtc.h index 6ccebfa..2bdaaac 100644 --- a/include/configs/digsy_mtc.h +++ b/include/configs/digsy_mtc.h @@ -114,29 +114,109 @@
#undef CONFIG_BOOTARGS
-#define CONFIG_EXTRA_ENV_SETTINGS \ - "netdev=eth0\0" \ - "console=ttyPSC0\0" \ - "kernel_addr_r=400000\0" \ - "fdt_addr_r=600000\0" \ - "nfsargs=setenv bootargs root=/dev/nfs rw " \ - "nfsroot=${serverip}:${rootpath}\0" \ - "addip=setenv bootargs ${bootargs} " \ - "ip=${ipaddr}:${serverip}:${gatewayip}:"\ - "${netmask}:${hostname}:${netdev}:off panic=1\0" \ +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fw_image=digsyMPC.img\0" \ + "mtcb_start=mtc led diag orange; run mtcb_1\0" \ + "mtcb_clearled=for x in user1 user2 usbpwr usbbusy; " \ + "do mtc led $x; done\0" \ + "mtcb_1=if mtc key; then run mtcb_clearled mtcb_update; " \ + "else run mtcb_fw; fi\0" \ + "mtcb_fw=if bootm ff000000; then echo FIRMWARE OK!; " \ + "else echo BAD FIRMWARE CRC!; mtc led diag red; fi\0" \ + "mtcb_update=mtc led user1 orange;" \ + "while mtc key; do ; done; run mtcb_2;\0" \ + "mtcb_2=mtc led user1 green 2; usb reset; run mtcb_usb1;\0" \ + "mtcb_usb1=if fatload usb 0 400000 script.img; " \ + "then run mtcb_doscript; else run mtcb_usb2; fi\0" \ + "mtcb_usb2=if fatload usb 0 400000 $fw_image; " \ + "then run mtcb_dousb; else run mtcb_ide; fi\0" \ + "mtcb_doscript=run mtcb_usbleds; mtc led user2 orange 2; " \ + "run mtcb_wait_flickr mtcb_ds_1;\0" \ + "mtcb_ds_1=if imi 400000; then mtc led usbbusy; " \ + "source 400000; else run mtcb_error; fi\0" \ + "mtcb_dousb=run mtcb_usbleds mtcb_wait_flickr mtcb_du_1;\0" \ + "mtcb_du_1=if imi 400000; then run mtcb_du_2; " \ + "else run mtcb_error; fi\0" \ + "mtcb_du_2=run mtcb_clear mtcb_prog; mtc led usbbusy; " \ + "run mtcb_checkfw\0" \ + "mtcb_checkfw=if imi ff000000; then run mtcb_success; " \ + "else run mtcb_error; fi\0" \ + "mtcb_waitkey=mtc key; until test $? -eq 0; do mtc key; done\0" \ + "mtcb_wait_flickr=run mtcb_waitkey mtcb_uledflckr\0" \ + "mtcb_usbleds=mtc led usbpwr green; mtc led usbbusy orange 1;\0"\ + "mtcb_uledflckr=mtc led user1 orange 11\0" \ + "mtcb_error=mtc led user1 red\0" \ + "mtcb_clear=erase ff000000 ff0fffff\0" \ + "mtcb_prog=cp.b 400000 ff000000 ${filesize}\0" \ + "mtcb_success=mtc led user1 green\0" \ + "mtcb_ide=if fatload ide 0 400000 $fw_image;" \ + "then run mtcb_doide; else run mtcb_error; fi\0" \ + "mtcb_doide=mtc led user2 green 1;" \ + "run mtcb_wait_flickr mtcb_di_1;\0" \ + "mtcb_di_1=if imi 400000; then run mtcb_di_2;" \ + "else run mtcb_error; fi\0" \ + "mtcb_di_2=run mtcb_clear; run mtcb_prog mtcb_checkfw\0" \ + "ramdisk_num_sector=16\0" \ + "flash_base=ff000000\0" \ + "flashdisk_size=e00000\0" \ + "env_sector=fff60000\0" \ + "flashdisk_start=ff100000\0" \ + "load_cmd=tftp 400000 digsyMPC.img\0" \ + "clear_cmd=erase ff000000 ff0fffff\0" \ + "flash_cmd=cp.b 400000 ff000000 ${filesize}\0" \ + "update_cmd=run load_cmd; " \ + "iminfo 400000; " \ + "run clear_cmd flash_cmd; " \ + "iminfo ff000000\0" \ + "spi_driver=yes\0" \ + "spi_watchdog=no\0" \ + "ftps_start=yes\0" \ + "ftps_user1=admin\0" \ + "ftps_pass1=admin\0" \ + "ftps_base1=/\0" \ + "ftps_home1=/\0" \ + "plc_sio_srv=no\0" \ + "plc_sio_baud=57600\0" \ + "plc_sio_parity=no\0" \ + "plc_sio_stop=1\0" \ + "plc_sio_com=2\0" \ + "plc_eth_srv=yes\0" \ + "plc_eth_port=1200\0" \ + "plc_root=/ide/\0" \ + "diag_level=0\0" \ + "webvisu=no\0" \ + "plc_can1_routing=no\0" \ + "plc_can1_baudrate=250\0" \ + "plc_can2_routing=no\0" \ + "plc_can2_baudrate=250\0" \ + "plc_can3_routing=no\0" \ + "plc_can3_baudrate=250\0" \ + "plc_can4_routing=no\0" \ + "plc_can4_baudrate=250\0" \ + "netdev=eth0\0" \ + "console=ttyPSC0\0" \ + "kernel_addr_r=400000\0" \ + "fdt_addr_r=600000\0" \ + "nfsargs=setenv bootargs root=/dev/nfs rw " \ + "nfsroot=${serverip}:${rootpath}\0" \ + "addip=setenv bootargs ${bootargs} " \ + "ip=${ipaddr}:${serverip}:${gatewayip}:" \ + "${netmask}:${hostname}:${netdev}:off panic=1\0" \ "addcons=setenv bootargs ${bootargs} console=${console},${baudrate}\0"\ - "rootpath=/opt/eldk/ppc_6xx\0" \ - "net_nfs=tftp ${kernel_addr_r} ${bootfile};" \ - "tftp ${fdt_addr_r} ${fdt_file};" \ - "run nfsargs addip addcons;" \ - "bootm ${kernel_addr_r} - ${fdt_addr_r}\0" \ - "load=tftp 200000 ${u-boot}\0" \ - "update=protect off FFF00000 +${filesize};" \ - "erase FFF00000 +${filesize};" \ - "cp.b 200000 FFF00000 ${filesize};" \ - "protect on FFF00000 +${filesize}\0" \ + "rootpath=/opt/eldk/ppc_6xx\0" \ + "net_nfs=tftp ${kernel_addr_r} ${bootfile};" \ + "tftp ${fdt_addr_r} ${fdt_file};" \ + "run nfsargs addip addcons;" \ + "bootm ${kernel_addr_r} - ${fdt_addr_r}\0" \ + "load=tftp 200000 ${u-boot}\0" \ + "update=protect off FFF00000 +${filesize};" \ + "erase FFF00000 +${filesize};" \ + "cp.b 200000 FFF00000 ${filesize};" \ + "protect on FFF00000 +${filesize}\0" \ ""
+#define CONFIG_BOOTCOMMAND "run mtcb_start" + /* * SPI configuration */

Dear Detlev Zundel,
In message 1249490265-13448-5-git-send-email-dzu@denx.de you wrote:
Signed-off-by: Detlev Zundel dzu@denx.de
include/configs/digsy_mtc.h | 120 +++++++++++++++++++++++++++++++++++------- 1 files changed, 100 insertions(+), 20 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Detlev Zundel,
In message 1249490265-13448-4-git-send-email-dzu@denx.de you wrote:
While at it, remove initialization of variables which will be set before usage in all cases.
Signed-off-by: Detlev Zundel dzu@denx.de
board/digsy_mtc/cmd_mtc.c | 47 +++++++++++++++++++++++++------------------- 1 files changed, 27 insertions(+), 20 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Detlev Zundel,
In message 1249490265-13448-3-git-send-email-dzu@denx.de you wrote:
From: Anatolij Gustschin agust@denx.de
Add mtc state subcommand description to the help of mtc command.
Remove some newlines in description of commands for proper help formating.
Signed-off-by: Anatolij Gustschin agust@denx.de
board/digsy_mtc/cmd_mtc.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Detlev Zundel,
In message 1249490265-13448-2-git-send-email-dzu@denx.de you wrote:
From: Grzegorz Bernacki gjb@semihalf.com
Signed-off-by: Grzegorz Bernacki gjb@semihalf.com
board/digsy_mtc/cmd_mtc.c | 30 ++++++++++++++++++++++++++++++ board/digsy_mtc/cmd_mtc.h | 1 + 2 files changed, 31 insertions(+), 0 deletions(-)
Appied, thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Detlev Zundel
-
Wolfgang Denk