diff options
-rw-r--r-- | arch/blackfin/cpu/cmd_gpio.c | 6 | ||||
-rw-r--r-- | arch/blackfin/cpu/jtag-console.c | 95 | ||||
-rw-r--r-- | include/configs/bf533-ezkit.h | 43 | ||||
-rw-r--r-- | include/configs/bf533-stamp.h | 43 | ||||
-rw-r--r-- | include/configs/bf561-ezkit.h | 42 | ||||
-rw-r--r-- | include/configs/bfin_adi_common.h | 1 | ||||
-rw-r--r-- | include/configs/blackstamp.h | 28 | ||||
-rw-r--r-- | include/configs/ibf-dsp561.h | 29 | ||||
-rwxr-xr-x | tools/jtagconsole | 4 |
9 files changed, 99 insertions, 192 deletions
diff --git a/arch/blackfin/cpu/cmd_gpio.c b/arch/blackfin/cpu/cmd_gpio.c index 9e505b6..4430c90 100644 --- a/arch/blackfin/cpu/cmd_gpio.c +++ b/arch/blackfin/cpu/cmd_gpio.c @@ -26,11 +26,9 @@ int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } - if (argc != 3) { + if (argc != 3) show_usage: - printf("Usage:\n%s\n", cmdtp->usage); - return 1; - } + return cmd_usage(cmdtp); /* parse the behavior */ ulong sub_cmd; diff --git a/arch/blackfin/cpu/jtag-console.c b/arch/blackfin/cpu/jtag-console.c index 1cd619f..e0f2975 100644 --- a/arch/blackfin/cpu/jtag-console.c +++ b/arch/blackfin/cpu/jtag-console.c @@ -1,49 +1,116 @@ /* * jtag-console.c - console driver over Blackfin JTAG * - * Copyright (c) 2008 Analog Devices Inc. + * Copyright (c) 2008-2010 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ #include <common.h> +#include <malloc.h> #include <stdio_dev.h> #include <asm/blackfin.h> +#ifdef DEBUG +# define dprintf(...) serial_printf(__VA_ARGS__) +#else +# define dprintf(...) do { if (0) printf(__VA_ARGS__); } while (0) +#endif + +static inline void dprintf_decode(const char *s, uint32_t len) +{ + uint32_t i; + for (i = 0; i < len; ++i) + if (s[i] < 0x20 || s[i] >= 0x7f) + dprintf("\\%o", s[i]); + else + dprintf("%c", s[i]); +} + +static inline uint32_t bfin_write_emudat(uint32_t emudat) +{ + __asm__ __volatile__("emudat = %0;" : : "d"(emudat)); + return emudat; +} + +static inline uint32_t bfin_read_emudat(void) +{ + uint32_t emudat; + __asm__ __volatile__("%0 = emudat;" : "=d"(emudat)); + return emudat; +} + #ifndef CONFIG_JTAG_CONSOLE_TIMEOUT # define CONFIG_JTAG_CONSOLE_TIMEOUT 500 #endif /* The Blackfin tends to be much much faster than the JTAG hardware. */ -static void jtag_write_emudat(uint32_t emudat) +static bool jtag_write_emudat(uint32_t emudat) { static bool overflowed = false; ulong timeout = get_timer(0) + CONFIG_JTAG_CONSOLE_TIMEOUT; while (bfin_read_DBGSTAT() & 0x1) { if (overflowed) - return; + return overflowed; if (timeout < get_timer(0)) overflowed = true; } overflowed = false; - __asm__ __volatile__("emudat = %0;" : : "d"(emudat)); + bfin_write_emudat(emudat); + return overflowed; } /* Transmit a buffer. The format is: * [32bit length][actual data] */ -static void jtag_send(const char *c, uint32_t len) +static void jtag_send(const char *raw_str, uint32_t len) { - uint32_t i; + const char *cooked_str; + uint32_t i, ex; if (len == 0) return; + /* Ugh, need to output \r after \n */ + ex = 0; + for (i = 0; i < len; ++i) + if (raw_str[i] == '\n') + ++ex; + if (ex) { + char *c = malloc(len + ex); + cooked_str = c; + for (i = 0; i < len; ++i) { + *c++ = raw_str[i]; + if (raw_str[i] == '\n') + *c++ = '\r'; + } + len += ex; + } else + cooked_str = raw_str; + + dprintf("%s(\"", __func__); + dprintf_decode(cooked_str, len); + dprintf("\", %i)\n", len); + /* First send the length */ - jtag_write_emudat(len); + if (jtag_write_emudat(len)) + goto done; /* Then send the data */ - for (i = 0; i < len; i += 4) - jtag_write_emudat((c[i] << 0) | (c[i+1] << 8) | (c[i+2] << 16) | (c[i+3] << 24)); + for (i = 0; i < len; i += 4) { + uint32_t emudat = + (cooked_str[i + 0] << 0) | + (cooked_str[i + 1] << 8) | + (cooked_str[i + 2] << 16) | + (cooked_str[i + 3] << 24); + if (jtag_write_emudat(emudat)) { + bfin_write_emudat(0); + goto done; + } + } + + done: + if (cooked_str != raw_str) + free((char *)cooked_str); } static void jtag_putc(const char c) { @@ -59,7 +126,10 @@ static size_t inbound_len, leftovers_len; /* Lower layers want to know when jtag has data */ static int jtag_tstc_dbg(void) { - return (bfin_read_DBGSTAT() & 0x2); + int ret = (bfin_read_DBGSTAT() & 0x2); + if (ret) + dprintf("%s: ret:%i\n", __func__, ret); + return ret; } /* Higher layers want to know when any data is available */ @@ -77,6 +147,9 @@ static int jtag_getc(void) int ret; uint32_t emudat; + dprintf("%s: inlen:%zu leftlen:%zu left:%x\n", __func__, + inbound_len, leftovers_len, leftovers); + /* see if any data is left over */ if (leftovers_len) { --leftovers_len; @@ -88,7 +161,7 @@ static int jtag_getc(void) /* wait for new data ! */ while (!jtag_tstc_dbg()) continue; - __asm__("%0 = emudat;" : "=d"(emudat)); + emudat = bfin_read_emudat(); if (inbound_len == 0) { /* grab the length */ diff --git a/include/configs/bf533-ezkit.h b/include/configs/bf533-ezkit.h index 37a7059..95d3afa 100644 --- a/include/configs/bf533-ezkit.h +++ b/include/configs/bf533-ezkit.h @@ -94,49 +94,10 @@ /* * I2C Settings - * By default PF1 is used as SDA and PF0 as SCL on the Stamp board */ #define CONFIG_SOFT_I2C -#ifdef CONFIG_SOFT_I2C -#define PF_SCL PF0 -#define PF_SDA PF1 -#define I2C_INIT \ - do { \ - *pFIO_DIR |= PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_ACTIVE \ - do { \ - *pFIO_DIR |= PF_SDA; \ - *pFIO_INEN &= ~PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_TRISTATE \ - do { \ - *pFIO_DIR &= ~PF_SDA; \ - *pFIO_INEN |= PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_READ ((*pFIO_FLAG_D & PF_SDA) != 0) -#define I2C_SDA(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SDA; \ - else \ - *pFIO_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SCL; \ - else \ - *pFIO_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1 /* diff --git a/include/configs/bf533-stamp.h b/include/configs/bf533-stamp.h index 02c8bc3..f39bfee 100644 --- a/include/configs/bf533-stamp.h +++ b/include/configs/bf533-stamp.h @@ -138,49 +138,10 @@ /* * I2C Settings - * By default PF2 is used as SDA and PF3 as SCL on the Stamp board */ #define CONFIG_SOFT_I2C -#ifdef CONFIG_SOFT_I2C -#define PF_SCL PF3 -#define PF_SDA PF2 -#define I2C_INIT \ - do { \ - *pFIO_DIR |= PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_ACTIVE \ - do { \ - *pFIO_DIR |= PF_SDA; \ - *pFIO_INEN &= ~PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_TRISTATE \ - do { \ - *pFIO_DIR &= ~PF_SDA; \ - *pFIO_INEN |= PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_READ ((*pFIO_FLAG_D & PF_SDA) != 0) -#define I2C_SDA(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SDA; \ - else \ - *pFIO_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SCL; \ - else \ - *pFIO_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF3 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF2 /* diff --git a/include/configs/bf561-ezkit.h b/include/configs/bf561-ezkit.h index 036bfe4..4e293b5 100644 --- a/include/configs/bf561-ezkit.h +++ b/include/configs/bf561-ezkit.h @@ -112,46 +112,8 @@ * I2C Settings */ #define CONFIG_SOFT_I2C -#ifdef CONFIG_SOFT_I2C -#define PF_SCL PF0 -#define PF_SDA PF1 -#define I2C_INIT \ - do { \ - *pFIO0_DIR |= PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_ACTIVE \ - do { \ - *pFIO0_DIR |= PF_SDA; \ - *pFIO0_INEN &= ~PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_TRISTATE \ - do { \ - *pFIO0_DIR &= ~PF_SDA; \ - *pFIO0_INEN |= PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_READ ((*pFIO0_FLAG_D & PF_SDA) != 0) -#define I2C_SDA(bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SDA; \ - else \ - *pFIO0_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL(bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SCL; \ - else \ - *pFIO0_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1 /* diff --git a/include/configs/bfin_adi_common.h b/include/configs/bfin_adi_common.h index 901a32f..4476268 100644 --- a/include/configs/bfin_adi_common.h +++ b/include/configs/bfin_adi_common.h @@ -68,6 +68,7 @@ # endif # if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) # define CONFIG_CMD_I2C +# define CONFIG_SOFT_I2C_READ_REPEATED_START # endif # ifdef CONFIG_SYS_NO_FLASH # undef CONFIG_CMD_FLASH diff --git a/include/configs/blackstamp.h b/include/configs/blackstamp.h index aa33933..85f08ea 100644 --- a/include/configs/blackstamp.h +++ b/include/configs/blackstamp.h @@ -206,32 +206,8 @@ * them yet. You can (and probably should) change these values! */ #ifdef CONFIG_SOFT_I2C - -#define PF_SCL PF9 -#define PF_SDA PF8 - -#define I2C_INIT do { *pFIO_DIR |= PF_SCL; SSYNC(); } while (0) -#define I2C_ACTIVE do { *pFIO_DIR |= PF_SDA; *pFIO_INEN &= ~PF_SDA; SSYNC(); } while (0) -#define I2C_TRISTATE do { *pFIO_DIR &= ~PF_SDA; *pFIO_INEN |= PF_SDA; SSYNC(); } while (0) -#define I2C_READ ((*pFIO_FLAG_D & PF_SDA) != 0) -#define I2C_SDA(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SDA; \ - else \ - *pFIO_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL(bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SCL; \ - else \ - *pFIO_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF9 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF8 #define CONFIG_SYS_I2C_SPEED 50000 #define CONFIG_SYS_I2C_SLAVE 0xFE #endif diff --git a/include/configs/ibf-dsp561.h b/include/configs/ibf-dsp561.h index 2c0a263..53b5197 100644 --- a/include/configs/ibf-dsp561.h +++ b/include/configs/ibf-dsp561.h @@ -112,33 +112,8 @@ * I2C Settings */ #define CONFIG_SOFT_I2C 1 -#define PF_SCL 0x1/*PF0*/ -#define PF_SDA 0x2/*PF1*/ - -#ifdef CONFIG_SOFT_I2C -#define I2C_INIT do { *pFIO0_DIR |= PF_SCL; SSYNC(); } while (0) -#define I2C_ACTIVE do { *pFIO0_DIR |= PF_SDA; *pFIO0_INEN &= ~PF_SDA; SSYNC(); } while (0) -#define I2C_TRISTATE do { *pFIO0_DIR &= ~PF_SDA; *pFIO0_INEN |= PF_SDA; SSYNC(); } while (0) -#define I2C_READ ((*pFIO0_FLAG_D & PF_SDA) != 0) -#define I2C_SDA(bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SDA; \ - else \ - *pFIO0_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL(bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SCL; \ - else \ - *pFIO0_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1 /* diff --git a/tools/jtagconsole b/tools/jtagconsole index 24198c8..d404fac 100755 --- a/tools/jtagconsole +++ b/tools/jtagconsole @@ -31,9 +31,9 @@ if [ -z "${ip}" ] || [ -n "$3" ] ; then usage "Invalid number of arguments" fi -trap "stty icanon echo intr ^C" 0 2 3 5 10 13 15 +trap "stty icanon echo opost intr ^C" 0 2 3 5 10 13 15 echo "NOTE: the interrupt signal (normally ^C) has been remapped to ^T" -stty -icanon -echo intr ^T +stty -icanon -echo -opost intr ^T nc ${ip} ${port} exit 0 |