[PATCH 04/10] ARM: socfpga: add Enclustra storage switch
Marek Vasut
marex at denx.de
Mon Oct 14 19:51:32 CEST 2024
On 10/13/24 4:32 PM, Lothar Rubusch wrote:
[...]
> diff --git a/board/enclustra/mercury_aa1/aa1_set_storage_cmd.c b/board/enclustra/mercury_aa1/aa1_set_storage_cmd.c
> new file mode 100644
> index 0000000000..95438c5487
> --- /dev/null
> +++ b/board/enclustra/mercury_aa1/aa1_set_storage_cmd.c
> @@ -0,0 +1,190 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2024 Enclustra GmbH
> + * <info at enclustra.com>
> + */
> +
> +#include <command.h>
> +#include <env.h>
> +#include <init.h>
> +#include <dm.h>
> +#include <dm/uclass.h>
> +#include <asm-generic/gpio.h>
> +#include <asm/io.h>
> +
> +/* Pin muxing */
> +#define ALTERA_NONE 0
> +#define ALTERA_MMC 1
> +#define ALTERA_QSPI 2
> +#define ALTERA_EMMC 3
> +#define MMC_CLK_DIV 0x9
> +#define QSPI_CLK_DIV 0x384
> +#define ALTERA_PINMUX_OFFS 0xffd07200
> +#define ALTERA_CLKMGR_MAINPLL_CNTR6CLK_BASE 0xFFD04078
> +
> +static int altera_current_storage = ALTERA_NONE;
> +
> +static const struct udevice_id altera_set_storage_match[] = {
> + { .compatible = "encl,altera_set_storage" },
DT bindings indicate the prefix is incorrect:
Documentation/devicetree/bindings/vendor-prefixes.yaml: "^enclustra,.*":
Documentation/devicetree/bindings/vendor-prefixes.yaml: description:
Enclustra GmbH
> + { }
> +};
> +
> +U_BOOT_DRIVER(altera_set_storage) = {
> + .name = "altera_set_storage",
> + .id = UCLASS_MISC,
> + .of_match = altera_set_storage_match,
> +};
> +
> +static void enclustra_mercury_aa1_write(const u32 *pinmux_arr, int len)
> +{
> + u32 i, offset, value;
> +
> + for (i = 0; i < len; i += 2) {
> + offset = pinmux_arr[i];
> + value = pinmux_arr[i + 1];
> + writel(value, ALTERA_PINMUX_OFFS + offset);
> + }
> +}
> +
> +static void enclustra_mercury_aa1_set_mux_mmc(void)
> +{
> + static const u32 pinmux_arr[] = {0x0c, 0x8, // IO4 connected to SDMMC
> + 0x10, 0x8, // IO5
> + 0x14, 0x8, // IO6
> + 0x18, 0x8, // IO7
> + 0x1c, 0x8, // IO8
> + 0x20, 0x8, // IO9
> + 0x24, 0xf, // IO10 connected to GPIO
> + 0x28, 0xf, // IO11
> + 0x2c, 0xf, // IO12
> + 0x30, 0xf, // IO13
> + 0x34, 0xf, // IO14
> + 0x38, 0xf}; // IO15
> + enclustra_mercury_aa1_write(pinmux_arr, sizeof(pinmux_arr) / sizeof(u32));
Try ARRAY_SIZE()
[...]
> +static int altera_set_storage_cmd(struct cmd_tbl *cmdtp, int flag,
> + int argc, char * const argv[])
> +{
> + struct udevice *dev;
> + int ret;
> +
> + ret = uclass_get_device_by_driver(UCLASS_MISC,
> + DM_DRIVER_GET(altera_set_storage), &dev);
> + if (ret)
> + return ret;
> +
> + if (argc != 2)
> + return CMD_RET_USAGE;
> +
> + if (!strcmp(argv[1], "MMC") || !strcmp(argv[1], "mmc"))
> + return altera_set_storage(dev, ALTERA_MMC);
> + else if (!strcmp(argv[1], "QSPI") || !strcmp(argv[1], "qspi"))
> + return altera_set_storage(dev, ALTERA_QSPI);
> + else if (!strcmp(argv[1], "EMMC") || !strcmp(argv[1], "emmc"))
Try strcasecmp()
More information about the U-Boot
mailing list