drivers/bcm2835gpio: fix usage messages
[openocd.git] / src / jtag / drivers / bcm2835gpio.c
index 1d84cbe4054a5ef4e1cbfab97c8a4cbf74bbe583..926bd89d338fb8e6e7dac6a21147eea769f78e89 100644 (file)
@@ -16,9 +16,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -51,9 +49,9 @@ uint32_t bcm2835_peri_base = 0x20000000;
 static int dev_mem_fd;
 static volatile uint32_t *pio_base;
 
-static int bcm2835gpio_read(void);
-static void bcm2835gpio_write(int tck, int tms, int tdi);
-static void bcm2835gpio_reset(int trst, int srst);
+static bb_value_t bcm2835gpio_read(void);
+static int bcm2835gpio_write(int tck, int tms, int tdi);
+static int bcm2835gpio_reset(int trst, int srst);
 
 static int bcm2835_swdio_read(void);
 static void bcm2835_swdio_drive(bool is_output);
@@ -93,12 +91,12 @@ static int speed_coeff = 113714;
 static int speed_offset = 28;
 static unsigned int jtag_delay;
 
-static int bcm2835gpio_read(void)
+static bb_value_t bcm2835gpio_read(void)
 {
-       return !!(GPIO_LEV & 1<<tdo_gpio);
+       return (GPIO_LEV & 1<<tdo_gpio) ? BB_HIGH : BB_LOW;
 }
 
-static void bcm2835gpio_write(int tck, int tms, int tdi)
+static int bcm2835gpio_write(int tck, int tms, int tdi)
 {
        uint32_t set = tck<<tck_gpio | tms<<tms_gpio | tdi<<tdi_gpio;
        uint32_t clear = !tck<<tck_gpio | !tms<<tms_gpio | !tdi<<tdi_gpio;
@@ -108,9 +106,11 @@ static void bcm2835gpio_write(int tck, int tms, int tdi)
 
        for (unsigned int i = 0; i < jtag_delay; i++)
                asm volatile ("");
+
+       return ERROR_OK;
 }
 
-static void bcm2835gpio_swd_write(int tck, int tms, int tdi)
+static int bcm2835gpio_swd_write(int tck, int tms, int tdi)
 {
        uint32_t set = tck<<swclk_gpio | tdi<<swdio_gpio;
        uint32_t clear = !tck<<swclk_gpio | !tdi<<swdio_gpio;
@@ -120,10 +120,12 @@ static void bcm2835gpio_swd_write(int tck, int tms, int tdi)
 
        for (unsigned int i = 0; i < jtag_delay; i++)
                asm volatile ("");
+
+       return ERROR_OK;
 }
 
 /* (1) assert or (0) deassert reset lines */
-static void bcm2835gpio_reset(int trst, int srst)
+static int bcm2835gpio_reset(int trst, int srst)
 {
        uint32_t set = 0;
        uint32_t clear = 0;
@@ -140,6 +142,8 @@ static void bcm2835gpio_reset(int trst, int srst)
 
        GPIO_SET = set;
        GPIO_CLR = clear;
+
+       return ERROR_OK;
 }
 
 static void bcm2835_swdio_drive(bool is_output)
@@ -196,7 +200,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionums)
        }
 
        command_print(CMD_CTX,
-                       "BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdi = %d",
+                       "BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
                        tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
 
        return ERROR_OK;
@@ -296,6 +300,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_speed_coeffs)
                COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], speed_coeff);
                COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], speed_offset);
        }
+
+       command_print(CMD_CTX, "BCM2835 GPIO: speed_coeffs = %d, speed_offset = %d",
+                                 speed_coeff, speed_offset);
        return ERROR_OK;
 }
 
@@ -303,6 +310,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_peripheral_base)
 {
        if (CMD_ARGC == 1)
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bcm2835_peri_base);
+
+       command_print(CMD_CTX, "BCM2835 GPIO: peripheral_base = 0x%08x",
+                                 bcm2835_peri_base);
        return ERROR_OK;
 }
 
@@ -312,74 +322,84 @@ static const struct command_registration bcm2835gpio_command_handlers[] = {
                .handler = &bcm2835gpio_handle_jtag_gpionums,
                .mode = COMMAND_CONFIG,
                .help = "gpio numbers for tck, tms, tdi, tdo. (in that order)",
-               .usage = "(tck tms tdi tdo)* ",
+               .usage = "[tck tms tdi tdo]",
        },
        {
                .name = "bcm2835gpio_tck_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_tck,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for tck.",
+               .usage = "[tck]",
        },
        {
                .name = "bcm2835gpio_tms_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_tms,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for tms.",
+               .usage = "[tms]",
        },
        {
                .name = "bcm2835gpio_tdo_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_tdo,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for tdo.",
+               .usage = "[tdo]",
        },
        {
                .name = "bcm2835gpio_tdi_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_tdi,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for tdi.",
+               .usage = "[tdi]",
        },
        {
                .name = "bcm2835gpio_swd_nums",
                .handler = &bcm2835gpio_handle_swd_gpionums,
                .mode = COMMAND_CONFIG,
                .help = "gpio numbers for swclk, swdio. (in that order)",
-               .usage = "(swclk swdio)* ",
+               .usage = "[swclk swdio]",
        },
        {
                .name = "bcm2835gpio_swclk_num",
                .handler = &bcm2835gpio_handle_swd_gpionum_swclk,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for swclk.",
+               .usage = "[swclk]",
        },
        {
                .name = "bcm2835gpio_swdio_num",
                .handler = &bcm2835gpio_handle_swd_gpionum_swdio,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for swdio.",
+               .usage = "[swdio]",
        },
        {
                .name = "bcm2835gpio_srst_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_srst,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for srst.",
+               .usage = "[srst]",
        },
        {
                .name = "bcm2835gpio_trst_num",
                .handler = &bcm2835gpio_handle_jtag_gpionum_trst,
                .mode = COMMAND_CONFIG,
                .help = "gpio number for trst.",
+               .usage = "[trst]",
        },
        {
                .name = "bcm2835gpio_speed_coeffs",
                .handler = &bcm2835gpio_handle_speed_coeffs,
                .mode = COMMAND_CONFIG,
                .help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
+               .usage = "[SPEED_COEFF SPEED_OFFSET]",
        },
        {
                .name = "bcm2835gpio_peripheral_base",
                .handler = &bcm2835gpio_handle_peripheral_base,
                .mode = COMMAND_CONFIG,
                .help = "peripheral base to access GPIOs (RPi1 0x20000000, RPi2 0x3F000000).",
+               .usage = "[base]",
        },
 
        COMMAND_REGISTRATION_DONE
@@ -434,10 +454,6 @@ static int bcm2835gpio_init(void)
                        LOG_INFO("JTAG and SWD modes enabled");
                else
                        LOG_INFO("JTAG only mode enabled (specify swclk and swdio gpio to add SWD mode)");
-               if (!is_gpio_valid(trst_gpio) && !is_gpio_valid(srst_gpio)) {
-                       LOG_ERROR("Require at least one of trst or srst gpios to be specified");
-                       return ERROR_JTAG_INIT_FAILED;
-               }
        } else if (bcm2835gpio_swd_mode_possible()) {
                LOG_INFO("SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)");
        } else {
@@ -470,8 +486,8 @@ static int bcm2835gpio_init(void)
                return ERROR_JTAG_INIT_FAILED;
        }
 
-       /* set 16mA drive strength */
-       pads_base[BCM2835_PADS_GPIO_0_27_OFFSET] = 0x5a000018 + 7;
+       /* set 4mA drive strength, slew rate limited, hysteresis on */
+       pads_base[BCM2835_PADS_GPIO_0_27_OFFSET] = 0x5a000008 + 1;
 
        tdo_gpio_mode = MODE_GPIO(tdo_gpio);
        tdi_gpio_mode = MODE_GPIO(tdi_gpio);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)