]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: arm: bcmstb: Enable driver model MMC support
authorThomas Fitzsimmons <fitzsim@fitzsim.org>
Fri, 17 May 2019 12:17:07 +0000 (08:17 -0400)
committerTom Rini <trini@konsulko.com>
Tue, 28 May 2019 17:58:06 +0000 (13:58 -0400)
For bcm7445 and bcm7260, this patch enables CONFIG_DM_MMC and updates
the bcmstb SDHCI driver to use the new driver model.  This allows
removal of SDHCI configuration handling from bcmstb.c, and eliminates
a board removal compile warning.

Signed-off-by: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Reviewed-by: Stefan Roese <sr@denx.de>
board/broadcom/bcmstb/bcmstb.c
configs/bcm7260_defconfig
configs/bcm7445_defconfig
drivers/mmc/bcmstb_sdhci.c
include/configs/bcm7260.h
include/configs/bcm7445.h

index 56328463aecb705ed499046ac7dc5a8a5a41b7b6..7f8e0f951d47b15426005bcecffcb3ccb061a378 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2018  Cisco Systems, Inc.
+ * (C) Copyright 2019  Synamedia
  *
  * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
  */
@@ -9,7 +10,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/bootm.h>
-#include <mach/sdhci.h>
 #include <mach/timer.h>
 #include <mmc.h>
 #include <fdtdec.h>
@@ -80,69 +80,6 @@ void enable_caches(void)
         */
 }
 
-static const phys_addr_t bcmstb_sdhci_address(u32 alias_index)
-{
-       int node = 0;
-       int ret = 0;
-       char sdhci[16] = { 0 };
-       const void *fdt = gd->fdt_blob;
-       const char *path = NULL;
-       struct fdt_resource resource = { 0 };
-
-       if (!fdt) {
-               printf("%s: Invalid gd->fdt_blob\n", __func__);
-               return 0;
-       }
-
-       node = fdt_path_offset(fdt, "/aliases");
-       if (node < 0) {
-               printf("%s: Failed to find /aliases node\n", __func__);
-               return 0;
-       }
-
-       sprintf(sdhci, "sdhci%d", alias_index);
-       path = fdt_getprop(fdt, node, sdhci, NULL);
-       if (!path) {
-               printf("%s: Failed to find alias for %s\n", __func__, sdhci);
-               return 0;
-       }
-
-       node = fdt_path_offset(fdt, path);
-       if (node < 0) {
-               printf("%s: Failed to resolve BCMSTB SDHCI alias\n", __func__);
-               return 0;
-       }
-
-       ret = fdt_get_named_resource(fdt, node, "reg", "reg-names",
-                                    "host", &resource);
-       if (ret) {
-               printf("%s: Failed to read BCMSTB SDHCI host resource\n",
-                      __func__);
-               return 0;
-       }
-
-       return resource.start;
-}
-
-int board_mmc_init(bd_t *bis)
-{
-       phys_addr_t sdhci_base_address = 0;
-
-       sdhci_base_address = bcmstb_sdhci_address(CONFIG_BCMSTB_SDHCI_INDEX);
-
-       if (!sdhci_base_address) {
-               sdhci_base_address = BCMSTB_SDHCI_BASE;
-               printf("%s: Assuming BCMSTB SDHCI address: 0x%p\n",
-                      __func__, (void *)sdhci_base_address);
-       }
-
-       debug("BCMSTB SDHCI base address: 0x%p\n", (void *)sdhci_base_address);
-
-       bcmstb_sdhci_init(sdhci_base_address);
-
-       return 0;
-}
-
 int timer_init(void)
 {
        gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
index 263694c58fac561999cec99b1ef8d2f85a4a0c21..6e0266be4594037f8451c8824ad2fa34df04310c 100644 (file)
@@ -11,6 +11,7 @@ CONFIG_SYS_PROMPT="U-Boot>"
 CONFIG_EFI_PARTITION=y
 CONFIG_OF_PRIOR_STAGE=y
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 # CONFIG_EFI_LOADER is not set
index 97098bf7e2e1f5dd8b4b0558cd5990bc5f247846..f22b06e9ce817da89d4fe3013e3a9ad5af6df3a0 100644 (file)
@@ -13,6 +13,7 @@ CONFIG_CMD_SF_TEST=y
 CONFIG_CMD_SPI=y
 CONFIG_OF_PRIOR_STAGE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 CONFIG_DM_SPI_FLASH=y
index 443ae8d481757d17cd4ac697fde05336bde5d76e..eef46f3af15b3141ae8bd53654da25a0c90765ba 100644 (file)
@@ -1,11 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2018  Cisco Systems, Inc.
+ * (C) Copyright 2019  Synamedia
  *
  * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
  */
 
 #include <common.h>
+#include <dm.h>
 #include <mach/sdhci.h>
 #include <malloc.h>
 #include <sdhci.h>
  */
 #define BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY   400000
 
-static char *BCMSTB_SDHCI_NAME = "bcmstb-sdhci";
-
 /*
  * This driver has only been tested with eMMC devices; SD devices may
  * not work.
  */
-int bcmstb_sdhci_init(phys_addr_t regbase)
+struct sdhci_bcmstb_plat {
+       struct mmc_config cfg;
+       struct mmc mmc;
+};
+
+static int sdhci_bcmstb_bind(struct udevice *dev)
 {
-       struct sdhci_host *host = NULL;
+       struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev);
 
-       host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
-       if (!host) {
-               printf("%s: Failed to allocate memory\n", __func__);
-               return 1;
-       }
-       memset(host, 0, sizeof(*host));
+       return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static int sdhci_bcmstb_probe(struct udevice *dev)
+{
+       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+       struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev);
+       struct sdhci_host *host = dev_get_priv(dev);
+       fdt_addr_t base;
+       int ret;
 
-       host->name = BCMSTB_SDHCI_NAME;
-       host->ioaddr = (void *)regbase;
-       host->quirks = 0;
+       base = devfdt_get_addr(dev);
+       if (base == FDT_ADDR_T_NONE)
+               return -EINVAL;
 
-       host->cfg.part_type = PART_TYPE_DOS;
+       host->name = dev->name;
+       host->ioaddr = (void *)base;
 
-       host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
+       ret = mmc_of_parse(dev, &plat->cfg);
+       if (ret)
+               return ret;
 
-       return add_sdhci(host,
-                        BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY,
-                        BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY);
+       ret = sdhci_setup_cfg(&plat->cfg, host,
+                             BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY,
+                             BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY);
+       if (ret)
+               return ret;
+
+       upriv->mmc = &plat->mmc;
+       host->mmc = &plat->mmc;
+       host->mmc->priv = host;
+
+       return sdhci_probe(dev);
 }
+
+static const struct udevice_id sdhci_bcmstb_match[] = {
+       { .compatible = "brcm,bcm7425-sdhci" },
+       { .compatible = "brcm,sdhci-brcmstb" },
+       { }
+};
+
+U_BOOT_DRIVER(sdhci_bcmstb) = {
+       .name = "sdhci-bcmstb",
+       .id = UCLASS_MMC,
+       .of_match = sdhci_bcmstb_match,
+       .ops = &sdhci_ops,
+       .bind = sdhci_bcmstb_bind,
+       .probe = sdhci_bcmstb_probe,
+       .priv_auto_alloc_size = sizeof(struct sdhci_host),
+       .platdata_auto_alloc_size = sizeof(struct sdhci_bcmstb_plat),
+};
index a2d7f614ce1b07dab4e79071f38d50df5b0b49f2..967bde54c86688b330b71107983e2e7d54927147 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "bcmstb.h"
 
-#define BCMSTB_SDHCI_BASE      0xf0200300
 #define BCMSTB_TIMER_LOW       0xf0412008
 #define BCMSTB_TIMER_HIGH      0xf041200c
 #define BCMSTB_TIMER_FREQUENCY 0xf0412020
index 6984edde18f107b0c01e5a93260699e455485b75..3ff4677f0af10dc7291f6599424296f2465a60d3 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "bcmstb.h"
 
-#define BCMSTB_SDHCI_BASE      0xf03e0200
 #define BCMSTB_TIMER_LOW       0xf0412008
 #define BCMSTB_TIMER_HIGH      0xf041200c
 #define BCMSTB_TIMER_FREQUENCY 0xf0412020