U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 24/25] mmc: k3_arasan: Add sdhci driver support for K3 family SoCs
Date: Tue, 21 Aug 2018 20:02:02 +0530	[thread overview]
Message-ID: <20180821143203.29142-25-lokeshvutla@ti.com> (raw)
In-Reply-To: <20180821143203.29142-1-lokeshvutla@ti.com>

AM654 has an arasan sdhci controller and a mmc phy attached to it.
Add basic support for K3 specific arasan sdhci controller.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/mmc/Kconfig          |   9 +++
 drivers/mmc/Makefile         |   1 +
 drivers/mmc/k3_arsan_sdhci.c | 109 +++++++++++++++++++++++++++++++++++
 3 files changed, 119 insertions(+)
 create mode 100644 drivers/mmc/k3_arsan_sdhci.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 377b1c4b3b..27dfccb9b2 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -402,6 +402,15 @@ config MMC_SDHCI_CADENCE
 
 	  If unsure, say N.
 
+config MMC_SDHCI_K3_ARASAN
+	bool "Arasan SDHCI controller for TI's K3 based SoCs"
+	depends on ARCH_K3
+	depends on MMC_SDHCI
+	depends on DM_MMC && OF_CONTROL && BLK
+	help
+	  Support for Arasan SDHCI host controller on Texas Instruments'
+	  K3 family based SoC platforms
+
 config MMC_SDHCI_KONA
 	bool "SDHCI support on Broadcom KONA platform"
 	depends on MMC_SDHCI
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index f6191862d6..23c5b0daef 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_MMC_SDHCI_ATMEL)		+= atmel_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_BCM2835)		+= bcm2835_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_BCMSTB)		+= bcmstb_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_CADENCE)		+= sdhci-cadence.o
+obj-$(CONFIG_MMC_SDHCI_K3_ARASAN)	+= k3_arsan_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_KONA)		+= kona_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MSM)		+= msm_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_MV)		+= mv_sdhci.o
diff --git a/drivers/mmc/k3_arsan_sdhci.c b/drivers/mmc/k3_arsan_sdhci.c
new file mode 100644
index 0000000000..1da25dc55d
--- /dev/null
+++ b/drivers/mmc/k3_arsan_sdhci.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier:	GPL-2.0+
+/*
+ * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Texas Instruments' K3 SD Host Controller Interface
+ */
+
+#include <clk.h>
+#include <common.h>
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain.h>
+#include <sdhci.h>
+
+#define K3_ARASAN_SDHCI_MIN_FREQ	0
+
+struct k3_arasan_sdhci_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+	unsigned int f_max;
+};
+
+static int k3_arasan_sdhci_probe(struct udevice *dev)
+{
+	struct k3_arasan_sdhci_plat *plat = dev_get_platdata(dev);
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct sdhci_host *host = dev_get_priv(dev);
+	struct power_domain sdhci_pwrdmn;
+	struct clk clk;
+	unsigned long clock;
+	int ret;
+
+	ret = power_domain_get_by_index(dev, &sdhci_pwrdmn, 0);
+	if (ret) {
+		dev_err(dev, "failed to get power domain\n");
+		return ret;
+	}
+
+	ret = power_domain_on(&sdhci_pwrdmn);
+	if (ret) {
+		dev_err(dev, "Power domain on failed\n");
+		return ret;
+	}
+
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret) {
+		dev_err(dev, "failed to get clock\n");
+		return ret;
+	}
+
+	clock = clk_get_rate(&clk);
+	if (IS_ERR_VALUE(clock)) {
+		dev_err(dev, "failed to get rate\n");
+		return clock;
+	}
+
+	host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
+		       SDHCI_QUIRK_BROKEN_R1B;
+
+	host->max_clk = clock;
+
+	ret = sdhci_setup_cfg(&plat->cfg, host, plat->f_max,
+			      K3_ARASAN_SDHCI_MIN_FREQ);
+	host->mmc = &plat->mmc;
+	if (ret)
+		return ret;
+	host->mmc->priv = host;
+	host->mmc->dev = dev;
+	upriv->mmc = host->mmc;
+
+	return sdhci_probe(dev);
+}
+
+static int k3_arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
+{
+	struct k3_arasan_sdhci_plat *plat = dev_get_platdata(dev);
+	struct sdhci_host *host = dev_get_priv(dev);
+
+	host->name = dev->name;
+	host->ioaddr = (void *)dev_read_addr(dev);
+	host->bus_width = dev_read_u32_default(dev, "bus-width", 4);
+	plat->f_max = dev_read_u32_default(dev, "max-frequency", 0);
+
+	return 0;
+}
+
+static int k3_arasan_sdhci_bind(struct udevice *dev)
+{
+	struct k3_arasan_sdhci_plat *plat = dev_get_platdata(dev);
+
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id k3_arasan_sdhci_ids[] = {
+	{ .compatible = "arasan,sdhci-5.1" },
+	{ }
+};
+
+U_BOOT_DRIVER(k3_arasan_sdhci_drv) = {
+	.name		= "k3_arasan_sdhci",
+	.id		= UCLASS_MMC,
+	.of_match	= k3_arasan_sdhci_ids,
+	.ofdata_to_platdata = k3_arasan_sdhci_ofdata_to_platdata,
+	.ops		= &sdhci_ops,
+	.bind		= k3_arasan_sdhci_bind,
+	.probe		= k3_arasan_sdhci_probe,
+	.priv_auto_alloc_size = sizeof(struct sdhci_host),
+	.platdata_auto_alloc_size = sizeof(struct k3_arasan_sdhci_plat),
+};
-- 
2.18.0

  parent reply	other threads:[~2018-08-21 14:32 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 14:31 [U-Boot] [PATCH 00/25] [2/3] Initial support Texas Instrument's AM654 Platform Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 01/25] firmware: Add basic support for TI System Control Interface (TI SCI) protocol Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-24 15:00     ` Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 02/25] firmware: ti_sci: Add support for board configuration Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 03/25] firmware: ti_sci: Add support for device control Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 04/25] firmware: ti_sci: Add support for clock control Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 05/25] firmware: ti_sci: Add support for reboot core service Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 06/25] firmware: ti_sci: Add support for processor control services Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 07/25] dm: firmware: Automatically bind child devices Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 08/25] dm: reset: Update uclass to allow querying reset status Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 09/25] reset: Extend reset control with an optional data field Lokesh Vutla
2018-08-24 14:11   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 10/25] reset: Introduce TI System Control Interface (TI SCI) reset driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 11/25] clk: Allow clock defaults to be set also during re-reloc state Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-24 14:42     ` Dr. Philipp Tomsich
2018-08-24 15:54       ` Andreas Dannenberg
2018-08-24 16:00         ` Dr. Philipp Tomsich
2018-08-24 16:28           ` Andreas Dannenberg
2018-08-27  3:26           ` Kever Yang
2018-08-27 16:06             ` Andreas Dannenberg
2018-08-28  9:12               ` Lokesh Vutla
2018-08-27  6:02       ` Lokesh Vutla
2018-08-21 14:31 ` [U-Boot] [PATCH 12/25] clk: Extend clock control with an optional data field Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 13/25] clk: Introduce TI System Control Interface (TI SCI) clock driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 14/25] power domain: Add support for multiple powerdomains per device Lokesh Vutla
2018-08-22  9:21   ` Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 15/25] power domain: Introduce TI System Control Interface (TI SCI) power domain driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 16/25] sysreset: Add TI System Control Interface (TI SCI) sysreset driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 17/25] mailbox: Allow attaching private data for mbox_chan Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 18/25] mailbox: Introduce K3 Secure Proxy Driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 19/25] spl: Allow mailbox drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 20/25] remoteproc: Allow for individual remoteproc initialization Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:31 ` [U-Boot] [PATCH 21/25] remoteproc: Introduce K3 system controller Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-24 15:02     ` Lokesh Vutla
2018-08-21 14:32 ` [U-Boot] [PATCH 22/25] remoteproc: Introduce K3 remoteproc driver Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 23/25] spl: Allow remoteproc drivers to be used within SPL Lokesh Vutla
2018-08-24 14:12   ` Tom Rini
2018-08-21 14:32 ` Lokesh Vutla [this message]
2018-08-24 14:12   ` [U-Boot] [PATCH 24/25] mmc: k3_arasan: Add sdhci driver support for K3 family SoCs Tom Rini
2018-08-21 14:32 ` [U-Boot] [PATCH 25/25] gpio: do not include <asm/arch/gpio.h> for ARCH_K3 Lokesh Vutla
2018-08-24 14:13   ` Tom Rini

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=20180821143203.29142-25-lokeshvutla@ti.com \
    --to=lokeshvutla@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox