From patchwork Fri May 17 12:17:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Fitzsimmons X-Patchwork-Id: 1101066 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fitzsim.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fitzsim-org.20150623.gappssmtp.com header.i=@fitzsim-org.20150623.gappssmtp.com header.b="H3tSmZ6P"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45586m2NCGz9s9N for ; Fri, 17 May 2019 23:20:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C0216C21DDC; Fri, 17 May 2019 13:18:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2C5BEC21E02; Fri, 17 May 2019 13:18:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 77B43C21C3F; Fri, 17 May 2019 12:17:31 +0000 (UTC) Received: from mail-it1-f195.google.com (mail-it1-f195.google.com [209.85.166.195]) by lists.denx.de (Postfix) with ESMTPS id DFDD0C21C29 for ; Fri, 17 May 2019 12:17:30 +0000 (UTC) Received: by mail-it1-f195.google.com with SMTP id u16so10812577itc.0 for ; Fri, 17 May 2019 05:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fitzsim-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZXvhl6TGe0AHXEOhFH/prxyHG1/880+y7v/KJnELGKw=; b=H3tSmZ6PXMkMqDEcj0gSp2tyC9N3+g+rbDr5GrsbIsyQ6Ofl4liQt2GSsn59JSQ2hc FSFNunv8bM/QdL3NQTT83vr5DrTZ5PWnWOPnXnlSgwWb9NesRrRZBpsbSanSjr+JJCEj knghBBBQ4T9JbAu0ngQSOUuoY5RJt+8KtW1HVhEg23JLSs0YVuNIQxONqnQ3A0xiXjTI XJ57JXIq14fv8Bw7sToeJKItxnsKPvPZcIruEzqyqWLW37YxQiq/o6M6N/5HoIAKkE53 ZQX1E6JlHN3o22WiK+tsnjALx4D3RApCYv3Ml+eqwwTGTplxDx/9GpiU8tJJ0Izb0zKW 4mpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZXvhl6TGe0AHXEOhFH/prxyHG1/880+y7v/KJnELGKw=; b=umdnMgrf13MGb3nEqOB0lCq4DFjfikZuuyWCL253eF+5iIi0lS9qKWnqreaCTR3/nm M98wsDJ0mop5Z4WlrAeDzuqfItO1c+f2Xqn0oC86od1mWqX+XCby1gjUNsFUutxClji/ XHUs5ymSKzbdQciAT9wDJNGf3rdEjwMof03h1g3os5RoSbt8+AQA9rpg02/7tTAKa0Yp /z0QYmZJ/s0+7RZSXKCQLTrglGhGa0332eP4t5t1ENQh+/amYOka0ez2k+woaShDMZqV bBp3SyYhJxdEFidqEgpVHOMEH7oOcNpATQKwL+EYP8b012/HMUUH7by2iuFpg+PVN6M0 imTQ== X-Gm-Message-State: APjAAAWyauuAwO/sby9IVYfkPnke70b7kOiWKqV7TCA6AP1Z/pA60UEk GWmVOlk6KsOv9OqRP5xGpJpyJAQjnWs= X-Google-Smtp-Source: APXvYqwQi/AcoZtVq+kQxCI9Ok8nLBQ5MYcAdWnAGIqvjE9F6kRdZClElmdcFF1wyDno+PdyELKVQg== X-Received: by 2002:a24:9906:: with SMTP id a6mr16203082ite.52.1558095449316; Fri, 17 May 2019 05:17:29 -0700 (PDT) Received: from localhost.localdomain (69-165-165-189.dsl.teksavvy.com. [69.165.165.189]) by smtp.gmail.com with ESMTPSA id m30sm110978iti.41.2019.05.17.05.17.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 05:17:28 -0700 (PDT) From: Thomas Fitzsimmons To: u-boot@lists.denx.de Date: Fri, 17 May 2019 08:17:07 -0400 Message-Id: <20190517121707.41249-1-fitzsim@fitzsim.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 17 May 2019 13:18:06 +0000 Subject: [U-Boot] [PATCH] dm: arm: bcmstb: Enable driver model MMC support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Stefan Roese --- board/broadcom/bcmstb/bcmstb.c | 65 +----------------------------- configs/bcm7260_defconfig | 1 + configs/bcm7445_defconfig | 1 + drivers/mmc/bcmstb_sdhci.c | 73 +++++++++++++++++++++++++--------- include/configs/bcm7260.h | 1 - include/configs/bcm7445.h | 1 - 6 files changed, 58 insertions(+), 84 deletions(-) diff --git a/board/broadcom/bcmstb/bcmstb.c b/board/broadcom/bcmstb/bcmstb.c index 56328463ae..7f8e0f951d 100644 --- a/board/broadcom/bcmstb/bcmstb.c +++ b/board/broadcom/bcmstb/bcmstb.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2018 Cisco Systems, Inc. + * (C) Copyright 2019 Synamedia * * Author: Thomas Fitzsimmons */ @@ -9,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -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); diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig index 263694c58f..6e0266be45 100644 --- a/configs/bcm7260_defconfig +++ b/configs/bcm7260_defconfig @@ -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 diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig index 97098bf7e2..f22b06e9ce 100644 --- a/configs/bcm7445_defconfig +++ b/configs/bcm7445_defconfig @@ -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 diff --git a/drivers/mmc/bcmstb_sdhci.c b/drivers/mmc/bcmstb_sdhci.c index 443ae8d481..eef46f3af1 100644 --- a/drivers/mmc/bcmstb_sdhci.c +++ b/drivers/mmc/bcmstb_sdhci.c @@ -1,11 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2018 Cisco Systems, Inc. + * (C) Copyright 2019 Synamedia * * Author: Thomas Fitzsimmons */ #include +#include #include #include #include @@ -36,32 +38,67 @@ */ #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_bcmstb_plat *plat = dev_get_platdata(dev); + + return sdhci_bind(dev, &plat->mmc, &plat->cfg); +} + +static int sdhci_bcmstb_probe(struct udevice *dev) { - struct sdhci_host *host = NULL; + 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; + + base = devfdt_get_addr(dev); + if (base == FDT_ADDR_T_NONE) + return -EINVAL; - 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)); + host->name = dev->name; + host->ioaddr = (void *)base; - host->name = BCMSTB_SDHCI_NAME; - host->ioaddr = (void *)regbase; - host->quirks = 0; + ret = mmc_of_parse(dev, &plat->cfg); + if (ret) + return ret; - host->cfg.part_type = PART_TYPE_DOS; + ret = sdhci_setup_cfg(&plat->cfg, host, + BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY, + BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY); + if (ret) + return ret; - host->version = sdhci_readw(host, SDHCI_HOST_VERSION); + upriv->mmc = &plat->mmc; + host->mmc = &plat->mmc; + host->mmc->priv = host; - return add_sdhci(host, - BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY, - BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY); + 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), +}; diff --git a/include/configs/bcm7260.h b/include/configs/bcm7260.h index a2d7f614ce..967bde54c8 100644 --- a/include/configs/bcm7260.h +++ b/include/configs/bcm7260.h @@ -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 diff --git a/include/configs/bcm7445.h b/include/configs/bcm7445.h index 6984edde18..3ff4677f0a 100644 --- a/include/configs/bcm7445.h +++ b/include/configs/bcm7445.h @@ -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