All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 05/12] mmc: uniphier-sd: migrate to CONFIG_BLK
Date: Wed, 14 Sep 2016 01:06:03 +0900	[thread overview]
Message-ID: <1473782770-20130-6-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1473782770-20130-1-git-send-email-yamada.masahiro@socionext.com>

This is the state-of-the-art MMC driver implementation.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/Kconfig          |  1 +
 drivers/mmc/Kconfig       |  1 +
 drivers/mmc/uniphier-sd.c | 50 +++++++++++++++++++++++------------------------
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 512e326..498658d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -855,6 +855,7 @@ config TARGET_COLIBRI_PXA270
 
 config ARCH_UNIPHIER
 	bool "Socionext UniPhier SoCs"
+	select BLK
 	select CLK_UNIPHIER
 	select DM
 	select DM_GPIO
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index a71afa5..ba9a723 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -80,6 +80,7 @@ config ROCKCHIP_SDHCI
 config MMC_UNIPHIER
 	bool "UniPhier SD/MMC Host Controller support"
 	depends on ARCH_UNIPHIER
+	depends on BLK
 	select DM_MMC_OPS
 	help
 	  This selects support for the SD/MMC Host Controller on UniPhier SoCs.
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 701b26f..4af7fdb 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -119,9 +119,12 @@ DECLARE_GLOBAL_DATA_PTR;
 /* alignment required by the DMA engine of this controller */
 #define UNIPHIER_SD_DMA_MINALIGN	0x10
 
-struct uniphier_sd_priv {
+struct uniphier_sd_plat {
 	struct mmc_config cfg;
-	struct mmc *mmc;
+	struct mmc mmc;
+};
+
+struct uniphier_sd_priv {
 	void __iomem *regbase;
 	unsigned long mclk;
 	unsigned int version;
@@ -654,8 +657,16 @@ static void uniphier_sd_host_init(struct uniphier_sd_priv *priv)
 	}
 }
 
+static int uniphier_sd_bind(struct udevice *dev)
+{
+	struct uniphier_sd_plat *plat = dev_get_platdata(dev);
+
+	return mmc_bind(dev, &plat->mmc, &plat->cfg);
+}
+
 static int uniphier_sd_probe(struct udevice *dev)
 {
+	struct uniphier_sd_plat *plat = dev_get_platdata(dev);
 	struct uniphier_sd_priv *priv = dev_get_priv(dev);
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	fdt_addr_t base;
@@ -691,15 +702,15 @@ static int uniphier_sd_probe(struct udevice *dev)
 		return ret;
 	}
 
-	priv->cfg.name = dev->name;
-	priv->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
+	plat->cfg.name = dev->name;
+	plat->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 	switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) {
 	case 8:
-		priv->cfg.host_caps |= MMC_MODE_8BIT;
+		plat->cfg.host_caps |= MMC_MODE_8BIT;
 		break;
 	case 4:
-		priv->cfg.host_caps |= MMC_MODE_4BIT;
+		plat->cfg.host_caps |= MMC_MODE_4BIT;
 		break;
 	case 1:
 		break;
@@ -722,27 +733,13 @@ static int uniphier_sd_probe(struct udevice *dev)
 
 	uniphier_sd_host_init(priv);
 
-	priv->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34;
-	priv->cfg.f_min = priv->mclk /
+	plat->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34;
+	plat->cfg.f_min = priv->mclk /
 			(priv->caps & UNIPHIER_SD_CAP_DIV1024 ? 1024 : 512);
-	priv->cfg.f_max = priv->mclk;
-	priv->cfg.b_max = U32_MAX; /* max value of UNIPHIER_SD_SECCNT */
-
-	priv->mmc = mmc_create(&priv->cfg, priv);
-	if (!priv->mmc)
-		return -EIO;
-
-	upriv->mmc = priv->mmc;
-	priv->mmc->dev = dev;
-
-	return 0;
-}
-
-static int uniphier_sd_remove(struct udevice *dev)
-{
-	struct uniphier_sd_priv *priv = dev_get_priv(dev);
+	plat->cfg.f_max = priv->mclk;
+	plat->cfg.b_max = U32_MAX; /* max value of UNIPHIER_SD_SECCNT */
 
-	mmc_destroy(priv->mmc);
+	upriv->mmc = &plat->mmc;
 
 	return 0;
 }
@@ -756,8 +753,9 @@ U_BOOT_DRIVER(uniphier_mmc) = {
 	.name = "uniphier-mmc",
 	.id = UCLASS_MMC,
 	.of_match = uniphier_sd_match,
+	.bind = uniphier_sd_bind,
 	.probe = uniphier_sd_probe,
-	.remove = uniphier_sd_remove,
 	.priv_auto_alloc_size = sizeof(struct uniphier_sd_priv),
+	.platdata_auto_alloc_size = sizeof(struct uniphier_sd_plat),
 	.ops = &uniphier_sd_ops,
 };
-- 
1.9.1

  parent reply	other threads:[~2016-09-13 16:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 16:05 [U-Boot] [PATCH 00/12] ARM: uniphier: UniPhier SoC updates for v2016.11-rc1 Masahiro Yamada
2016-09-13 16:05 ` [U-Boot] [PATCH 01/12] ARM: uniphier: sort select:s alphabetically Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 02/12] usb: uniphier: remove UniPhier xHCI driver and select DM_USB Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 03/12] ARM: uniphier: delete unnecessary xHCI pin-mux settings Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 04/12] ARM: uniphier: enable Generic EHCI driver for Pro4 SoC Masahiro Yamada
2016-09-13 16:06 ` Masahiro Yamada [this message]
2016-09-13 16:06 ` [U-Boot] [PATCH 06/12] pinctrl: uniphier: add System Bus pin-mux settings Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 07/12] pinctrl: uniphier: move register base macros from header to .c file Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 08/12] ARM: uniphier: remove IECTRL setup code of LD4 SoC Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 09/12] ARM: uniphier: use checkboard() instead of misc_init_f() Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 10/12] ARM: uniphier: merge board init functions into board_init() Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 11/12] ARM: uniphier: fix DRAM size of LD21 SoC package Masahiro Yamada
2016-09-13 16:06 ` [U-Boot] [PATCH 12/12] ARM: uniphier: introduce flags to adjust DRAM timing for LD20/LD21 Masahiro Yamada
2016-09-14 14:04 ` [U-Boot] [PATCH 00/12] ARM: uniphier: UniPhier SoC updates for v2016.11-rc1 Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473782770-20130-6-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.