From: Christian Marangi <ansuelsmth@gmail.com>
To: "Tom Rini" <trini@konsulko.com>,
"Lukasz Majewski" <lukma@denx.de>,
"Sean Anderson" <seanga2@gmail.com>,
"Ryder Lee" <ryder.lee@mediatek.com>,
"Weijie Gao" <weijie.gao@mediatek.com>,
"Chunfeng Yun" <chunfeng.yun@mediatek.com>,
GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
"Heiko Schocher" <hs@denx.de>, "Peng Fan" <peng.fan@nxp.com>,
"Jaehoon Chung" <jh80.chung@samsung.com>,
"Joe Hershberger" <joe.hershberger@ni.com>,
"Ramon Fried" <rfried.dev@gmail.com>,
"Jagan Teki" <jagan@amarulasolutions.com>,
"Christian Marangi" <ansuelsmth@gmail.com>,
"Sam Shih" <sam.shih@mediatek.com>,
"Francois Berder" <fberder@outlook.fr>,
"Simon Glass" <sjg@chromium.org>,
"Julien Masson" <jmasson@baylibre.com>,
"Peter Robinson" <pbrobinson@gmail.com>,
"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
"Bo-Cun Chen" <bc-bocun.chen@mediatek.com>,
"This contributor prefers not to receive mails"
<noreply@example.com>, "Michal Simek" <michal.simek@amd.com>,
"John Crispin" <john@phrozen.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Mason Huo" <mason.huo@starfivetech.com>,
"Stefan Roese" <sr@denx.de>, "Sumit Garg" <sumit.garg@linaro.org>,
"Mark Kettenis" <kettenis@openbsd.org>,
"Sergei Antonov" <saproj@gmail.com>,
"Mayuresh Chitale" <mchitale@ventanamicro.com>,
"SkyLake.Huang" <skylake.huang@mediatek.com>,
"Nicolò Veronese" <nicveronese@gmail.com>,
u-boot@lists.denx.de
Subject: [PATCH 08/11] mmc: mediatek: add support for upstream linux clock and property
Date: Wed, 5 Jun 2024 21:02:15 +0200 [thread overview]
Message-ID: <20240605190220.17616-9-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240605190220.17616-1-ansuelsmth@gmail.com>
Add support for upstream linux clock and map U-Boot property to the one
use in upstream linux where supported.
Also add handling for the use_internal_cd that on upstream is hardcoded
enabled on mt7620.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/mmc/mtk-sd.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index 296aaee7331..93878900dec 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -336,6 +336,7 @@ struct msdc_compatible {
bool enhance_rx;
bool builtin_pad_ctrl;
bool default_pad_dly;
+ bool use_internal_cd;
};
struct msdc_delay_phase {
@@ -366,6 +367,10 @@ struct msdc_host {
struct clk src_clk_cg; /* optional, MSDC source clock control gate */
struct clk h_clk; /* MSDC core clock */
+ /* upstream linux clock */
+ struct clk axi_cg_clk; /* optional, AXI clock */
+ struct clk ahb_cg_clk; /* optional, AHB clock */
+
u32 src_clk_freq; /* source clock */
u32 mclk; /* mmc framework required bus clock */
u32 sclk; /* actual calculated bus clock */
@@ -1638,6 +1643,11 @@ static void msdc_ungate_clock(struct msdc_host *host)
clk_enable(&host->h_clk);
if (host->src_clk_cg.dev)
clk_enable(&host->src_clk_cg);
+
+ if (host->axi_cg_clk.dev)
+ clk_enable(&host->axi_cg_clk);
+ if (host->ahb_cg_clk.dev)
+ clk_enable(&host->ahb_cg_clk);
}
static int msdc_drv_probe(struct udevice *dev)
@@ -1716,19 +1726,33 @@ static int msdc_of_to_plat(struct udevice *dev)
clk_get_by_name(dev, "source_cg", &host->src_clk_cg); /* optional */
+ /* upstream linux clock */
+ clk_get_by_name(dev, "axi_cg", &host->axi_cg_clk); /* optional */
+ clk_get_by_name(dev, "ahb_cg", &host->ahb_cg_clk); /* optional */
+
#if CONFIG_IS_ENABLED(DM_GPIO)
gpio_request_by_name(dev, "wp-gpios", 0, &host->gpio_wp, GPIOD_IS_IN);
gpio_request_by_name(dev, "cd-gpios", 0, &host->gpio_cd, GPIOD_IS_IN);
#endif
host->hs400_ds_delay = dev_read_u32_default(dev, "hs400-ds-delay", 0);
- host->hs200_cmd_int_delay =
- dev_read_u32_default(dev, "cmd_int_delay", 0);
+ if (dev_read_u32(dev, "mediatek,hs200-cmd-int-delay",
+ &host->hs200_cmd_int_delay))
+ host->hs200_cmd_int_delay =
+ dev_read_u32_default(dev, "cmd_int_delay", 0);
+
host->hs200_write_int_delay =
dev_read_u32_default(dev, "write_int_delay", 0);
- host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0);
+
+ if (dev_read_u32(dev, "mediatek,latch-ck", &host->latch_ck))
+ host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0);
+
host->r_smpl = dev_read_u32_default(dev, "r_smpl", 0);
- host->builtin_cd = dev_read_u32_default(dev, "builtin-cd", 0);
+ if (dev_read_bool(dev, "mediatek,hs400-cmd-resp-sel-rising"))
+ host->r_smpl = 1;
+
+ host->builtin_cd = dev_read_u32_default(dev, "builtin-cd", 0) ||
+ host->dev_comp->use_internal_cd;
host->cd_active_high = dev_read_bool(dev, "cd-active-high");
return 0;
@@ -1776,6 +1800,7 @@ static const struct msdc_compatible mt7620_compat = {
.enhance_rx = false,
.builtin_pad_ctrl = true,
.default_pad_dly = true,
+ .use_internal_cd = true,
};
static const struct msdc_compatible mt7621_compat = {
--
2.43.0
next prev parent reply other threads:[~2024-06-05 19:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 19:02 [PATCH 00/11] mediatek: cumulative trivial fix for OF_UPSTREAM support Christian Marangi
2024-06-05 19:02 ` [PATCH 01/11] phy: phy-mtk-tphy: add support for phy type switch Christian Marangi
2024-06-05 19:02 ` [PATCH 02/11] pci: mediatek: add PCIe controller support for filogic silicon Christian Marangi
2024-06-05 19:02 ` [PATCH 03/11] spi: mtk_spim: add support for upstream mediatek, spi-ipm compatible Christian Marangi
2024-06-05 19:02 ` [PATCH 04/11] net: mediatek: handle alternative name for pn_swap property Christian Marangi
2024-06-05 19:02 ` [PATCH 05/11] i2c: mediatek: add support for optional arb and pmic clock Christian Marangi
2024-06-06 4:27 ` Heiko Schocher
2024-06-05 19:02 ` [PATCH 06/11] serial: mediatek: add support for bus clock and enable it Christian Marangi
2024-06-05 19:02 ` [PATCH 07/11] serial: mediatek: add special handling for highspeed and linux compat Christian Marangi
2024-06-05 19:02 ` Christian Marangi [this message]
2024-06-05 19:02 ` [PATCH 09/11] clk: mediatek: mt7981: support alternative compatible for fixed-plls Christian Marangi
2024-06-05 19:02 ` [PATCH 10/11] pinctrl: mediatek: add support for gpio-controller property in root node Christian Marangi
2024-06-05 19:02 ` [PATCH 11/11] pinctrl: mediatek: mt7981: init device before relocation Christian Marangi
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=20240605190220.17616-9-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=GSS_MTK_Uboot_upstream@mediatek.com \
--cc=bc-bocun.chen@mediatek.com \
--cc=chunfeng.yun@mediatek.com \
--cc=fberder@outlook.fr \
--cc=hs@denx.de \
--cc=jagan@amarulasolutions.com \
--cc=jh80.chung@samsung.com \
--cc=jmasson@baylibre.com \
--cc=joe.hershberger@ni.com \
--cc=john@phrozen.org \
--cc=kettenis@openbsd.org \
--cc=lukma@denx.de \
--cc=marek.vasut+renesas@mailbox.org \
--cc=mason.huo@starfivetech.com \
--cc=mchitale@ventanamicro.com \
--cc=michal.simek@amd.com \
--cc=nicveronese@gmail.com \
--cc=noreply@example.com \
--cc=pbrobinson@gmail.com \
--cc=peng.fan@nxp.com \
--cc=rfried.dev@gmail.com \
--cc=ryder.lee@mediatek.com \
--cc=sam.shih@mediatek.com \
--cc=saproj@gmail.com \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=skylake.huang@mediatek.com \
--cc=sr@denx.de \
--cc=sumit.garg@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=weijie.gao@mediatek.com \
--cc=xypron.glpk@gmx.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