From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 7/9] dm: mmc: sunxi: Add CLK and RESET support
Date: Mon, 21 Jan 2019 16:01:13 +0530 [thread overview]
Message-ID: <20190121103115.17794-8-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20190121103115.17794-1-jagan@amarulasolutions.com>
Now CLK and RESET driver for Allwinner SoC are available,
so add the relevant operations on mmc sunxi driver.
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Changes for v3:
- Grab changes for ML
drivers/mmc/sunxi_mmc.c | 52 +++++++++++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 0c443a732d..3c17958c95 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -8,10 +8,12 @@
*/
#include <common.h>
+#include <clk.h>
#include <dm.h>
#include <errno.h>
#include <malloc.h>
#include <mmc.h>
+#include <reset.h>
#include <asm/io.h>
#include <asm/arch/clock.h>
#include <asm/arch/cpu.h>
@@ -21,7 +23,6 @@
#ifdef CONFIG_DM_MMC
struct sunxi_mmc_variant {
- u16 gate_offset;
u16 mclk_offset;
};
#endif
@@ -41,6 +42,8 @@ struct sunxi_mmc_priv {
struct mmc_config cfg;
#ifdef CONFIG_DM_MMC
const struct sunxi_mmc_variant *variant;
+ struct clk clk_ahb;
+ struct reset_ctl reset;
#endif
};
@@ -602,6 +605,32 @@ static const struct dm_mmc_ops sunxi_mmc_ops = {
.get_cd = sunxi_mmc_getcd,
};
+static int sunxi_mmc_enable(struct udevice *dev)
+{
+ struct sunxi_mmc_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = clk_enable(&priv->clk_ahb);
+ if (ret) {
+ dev_err(dev, "failed to enable AHB clock\n");
+ return ret;
+ }
+
+ if (reset_valid(&priv->reset)) {
+ ret = reset_deassert(&priv->reset);
+ if (ret) {
+ dev_err(dev, "failed to deassert reset\n");
+ goto err_clk_ahb;
+ }
+ }
+
+ return 0;
+
+err_clk_ahb:
+ clk_disable(&priv->clk_ahb);
+ return ret;
+}
+
static int sunxi_mmc_probe(struct udevice *dev)
{
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
@@ -609,7 +638,7 @@ static int sunxi_mmc_probe(struct udevice *dev)
struct sunxi_mmc_priv *priv = dev_get_priv(dev);
struct mmc_config *cfg = &plat->cfg;
struct ofnode_phandle_args args;
- u32 *gate_reg, *ccu_reg;
+ u32 *ccu_reg;
int bus_width, ret;
cfg->name = dev->name;
@@ -641,8 +670,22 @@ static int sunxi_mmc_probe(struct udevice *dev)
priv->mmc_no = ((uintptr_t)priv->reg - SUNXI_MMC0_BASE) / 0x1000;
priv->mclkreg = (void *)ccu_reg +
(priv->variant->mclk_offset + (priv->mmc_no * 4));
- gate_reg = (void *)ccu_reg + priv->variant->gate_offset;
- setbits_le32(gate_reg, BIT(AHB_GATE_OFFSET_MMC(priv->mmc_no)));
+
+ ret = clk_get_by_name(dev, "ahb", &priv->clk_ahb);
+ if (ret) {
+ dev_err(dev, "failed to get AHB clock\n");
+ return ret;
+ }
+
+ ret = reset_get_by_name(dev, "ahb", &priv->reset);
+ if (ret && ret != -ENOENT) {
+ dev_err(dev, "failed to get reset\n");
+ return ret;
+ }
+
+ ret = sunxi_mmc_enable(dev);
+ if (ret)
+ return ret;
ret = mmc_set_mod_clk(priv, 24000000);
if (ret)
@@ -676,7 +719,6 @@ static int sunxi_mmc_bind(struct udevice *dev)
}
static const struct sunxi_mmc_variant sun4i_a10_variant = {
- .gate_offset = 0x60,
.mclk_offset = 0x88,
};
--
2.18.0.321.gffc6fa0e3
next prev parent reply other threads:[~2019-01-21 10:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 10:31 [U-Boot] [PATCH v3 0/9] mmc: sunxi: Enable DM_MMC Jagan Teki
2019-01-21 10:31 ` [U-Boot] [PATCH v3 1/9] sunxi: clk: add MMC gates/resets Jagan Teki
2019-01-23 1:08 ` André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 2/9] sunxi: clk: A80: add MMC clock support Jagan Teki
2019-01-21 10:31 ` [U-Boot] [PATCH v3 3/9] mmc: sunxi: Add A83T emmc compatible Jagan Teki
2019-01-23 1:37 ` André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 4/9] mmc: sunxi: Add mmc, emmc H5/A64 compatible Jagan Teki
2019-01-23 1:39 ` André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 5/9] mmc: sunxi: Add DM_MMC support for H6 Jagan Teki
2019-01-23 1:41 ` André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 6/9] mmc: sunxi: Add DM_MMC support for A80 Jagan Teki
2019-01-23 1:52 ` André Przywara
2019-01-21 10:31 ` Jagan Teki [this message]
2019-01-22 23:36 ` [U-Boot] [PATCH v3 7/9] dm: mmc: sunxi: Add CLK and RESET support André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 8/9] arm: sunxi: Enable DM_MMC Jagan Teki
2019-01-23 1:54 ` André Przywara
2019-01-21 10:31 ` [U-Boot] [PATCH v3 9/9] arm: dts: sunxi: Enumerate MMC2 as MMC1 Jagan Teki
2019-01-21 10:42 ` Chen-Yu Tsai
2019-01-21 11:07 ` Jagan Teki
2019-01-21 17:31 ` Chen-Yu Tsai
2019-01-21 15:38 ` Vasily Khoruzhick
2019-01-21 15:46 ` Jagan Teki
2019-01-22 4:24 ` Vasily Khoruzhick
2019-01-22 4:45 ` Vasily Khoruzhick
2019-01-21 17:05 ` Chen-Yu Tsai
2019-01-22 2:25 ` [U-Boot] [PATCH v3 0/9] mmc: sunxi: Enable DM_MMC Chen-Yu Tsai
2019-01-25 8:27 ` Jagan Teki
2019-01-25 8:34 ` Chen-Yu Tsai
2019-01-25 10:41 ` Jagan Teki
2019-01-25 11:01 ` [U-Boot] [linux-sunxi] " Chen-Yu Tsai
2019-01-25 11:36 ` Andre Przywara
2019-01-25 11:41 ` Jagan Teki
2019-01-25 11:42 ` Chen-Yu Tsai
2019-01-25 11:51 ` Andre Przywara
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=20190121103115.17794-8-jagan@amarulasolutions.com \
--to=jagan@amarulasolutions.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