
From: Bharat Gooty bharat.gooty@broadcom.com
Following netXtreme commands are supported: probe, remove.
Signed-off-by: Bharat Gooty bharat.gooty@broadcom.com
Signed-off-by: Roman Bacik roman.bacik@broadcom.com ---
Changes in v3: - remove commands set/get mac/speed - add doc/bnxt.rst
cmd/Kconfig | 2 + cmd/broadcom/Kconfig | 10 +++++ cmd/broadcom/Makefile | 3 +- cmd/broadcom/bnxt.c | 97 +++++++++++++++++++++++++++++++++++++++++++ doc/usage/bnxt.rst | 35 ++++++++++++++++ doc/usage/index.rst | 1 + 6 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 cmd/broadcom/Kconfig create mode 100644 cmd/broadcom/bnxt.c create mode 100644 doc/usage/bnxt.rst
diff --git a/cmd/Kconfig b/cmd/Kconfig index 5b30b13e438f..e054292dbcd0 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1953,6 +1953,8 @@ endmenu
source "cmd/ti/Kconfig"
+source "cmd/broadcom/Kconfig" + config CMD_BOOTSTAGE bool "Enable the 'bootstage' command" depends on BOOTSTAGE diff --git a/cmd/broadcom/Kconfig b/cmd/broadcom/Kconfig new file mode 100644 index 000000000000..6f16b09d1425 --- /dev/null +++ b/cmd/broadcom/Kconfig @@ -0,0 +1,10 @@ +menu "Broadcom specific command line interface" + +config BNXT_ETH_CMD + bool "BNXT commands" + depends on BNXT_ETH + help + Broadcom NXS ethernet controller commands. Commands supported are:- + Driver probe, Driver remove, Supported speeds, get/set MAC address and get/set Link speeds. + +endmenu diff --git a/cmd/broadcom/Makefile b/cmd/broadcom/Makefile index 62268d98d0dd..0027c1c15e5a 100644 --- a/cmd/broadcom/Makefile +++ b/cmd/broadcom/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ -# Copyright 2020 Broadcom +# Copyright 2020-2021 Broadcom
obj-y += chimp_boot.o obj-y += nitro_image_load.o obj-y += chimp_handshake.o +obj-$(CONFIG_BNXT_ETH_CMD) += bnxt.o diff --git a/cmd/broadcom/bnxt.c b/cmd/broadcom/bnxt.c new file mode 100644 index 000000000000..ddc2ceb98863 --- /dev/null +++ b/cmd/broadcom/bnxt.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 Broadcom + */ + +#include <common.h> +#include <command.h> + +#include <asm/io.h> +#include <pci.h> +#include <broadcom/bnxt.h> +#include <broadcom/bnxt_ver.h> +#include <broadcom/bnxt_hsi.h> +#include <dm.h> +#include <env_flags.h> +#include <env_internal.h> +#include <errno.h> +#include <linux/if_ether.h> +#include <net.h> +#include <dm/device-internal.h> +#include <linux/ctype.h> +#include <linux/delay.h> +#include <linux/types.h> + +static int print_drv(u8 flag) +{ + printf("bnxt - Device "); + if (flag) + printf("already"); + else + printf("not"); + + printf(" initialized\n"); + + return CMD_RET_SUCCESS; +} + +static int bnxt_parse_input(int argc, char *const argv[]) +{ + if (!strcmp(argv[2], "probe")) + return CMD_PROBE; + else if (!strcmp(argv[2], "remove")) + return CMD_REMOVE; + + return CMD_UNKNOWN; +} + +static int do_bnxt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct udevice *dev; + struct bnxt *bp; + char name[30]; + int ret = CMD_RET_USAGE; + int cardnum; + int op; + + printf("\n"); + if (argc < 2) + return ret; + + cardnum = simple_strtoul(argv[1], NULL, 10); + sprintf(name, "bnxt_eth%u", cardnum); + ret = uclass_get_device_by_name(UCLASS_ETH, name, &dev); + if (ret) + return CMD_RET_USAGE; + + bp = dev_get_priv(dev); + op = bnxt_parse_input(argc, argv); + ret = CMD_RET_USAGE; + switch (op) { + case CMD_PROBE: + if (!bp->drv_load) + ret = bnxt_drv_probe(dev); + else + ret = print_drv(1); + break; + case CMD_REMOVE: + ret = bnxt_drv_remove(dev); + break; + default: + if (op && !bp->drv_load) + ret = print_drv(0); + } + + printf("\n"); + + return ret; +} + +U_BOOT_CMD + (bnxt, 5, 1, do_bnxt, + "Broadcom NetXtreme-C/E Management", + /* */"<bnxt_eth#> probe\n" + " - Load Driver Instance.\n" + "bnxt <bnxt_eth#> remove\n" + " - Unload Driver Instance.\n" +); diff --git a/doc/usage/bnxt.rst b/doc/usage/bnxt.rst new file mode 100644 index 000000000000..4b0b7b22411a --- /dev/null +++ b/doc/usage/bnxt.rst @@ -0,0 +1,35 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +bnxt command +============ + +Synopsis +-------- + +:: + + bnxt bnxt_eth# probe + bnxt bnxt_eth# remove + +Description +----------- + +The bnxt commands are used to load and unload the bnxt driver. The probe loads and remove unloads the driver. + +Example +------- + +:: + + => bnxt 0 probe + => bnxt 0 remove + +Configuration +------------- + +The bnxt commands are only available if CONFIG_CMD_BNXT=y. + +Return value +------------ + +The return value $? is 0 if successful and nonzero error code if the command fails. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 356f2a56181b..834e8d274646 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -20,6 +20,7 @@ Shell commands addrmap askenv base + bnxt bootefi booti bootmenu