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 03/11] spi: mtk_spim: add support for upstream mediatek, spi-ipm compatible
Date: Wed, 5 Jun 2024 21:02:10 +0200 [thread overview]
Message-ID: <20240605190220.17616-4-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240605190220.17616-1-ansuelsmth@gmail.com>
Upstream kernel linux use a different compatible mediatek,spi-ipm.
Add support for this compatible and add handling for the additional
clock similar to how it's done by the upstream driver and handling for
all the property enabled by default.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/spi/mtk_spim.c | 45 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/mtk_spim.c b/drivers/spi/mtk_spim.c
index 90f4c3cecb9..b360eca2b91 100644
--- a/drivers/spi/mtk_spim.c
+++ b/drivers/spi/mtk_spim.c
@@ -137,6 +137,8 @@ struct mtk_spim_capability {
* @state: Controller state
* @sel_clk: Pad clock
* @spi_clk: Core clock
+ * @parent_clk: Parent clock (needed for mediatek,spi-ipm, upstream DTSI)
+ * @hclk: HCLK clock (needed for mediatek,spi-ipm, upstream DTSI)
* @pll_clk_rate: Controller's PLL source clock rate, which is different
* from SPI bus clock rate
* @xfer_len: Current length of data for transfer
@@ -151,6 +153,7 @@ struct mtk_spim_priv {
void __iomem *base;
u32 state;
struct clk sel_clk, spi_clk;
+ struct clk parent_clk, hclk;
u32 pll_clk_rate;
u32 xfer_len;
struct mtk_spim_capability hw_cap;
@@ -650,7 +653,21 @@ static int mtk_spim_probe(struct udevice *dev)
if (!priv->base)
return -EINVAL;
- mtk_spim_get_attr(priv, dev);
+ /*
+ * Upstream linux driver for ipm design enable all the modes
+ * and setup the calibrarion values directly in the driver with
+ * standard values.
+ */
+ if (device_is_compatible(dev, "mediatek,spi-ipm")) {
+ priv->hw_cap.enhance_timing = true;
+ priv->hw_cap.dma_ext = true;
+ priv->hw_cap.ipm_design = true;
+ priv->hw_cap.support_quad = true;
+ priv->sample_sel = 0;
+ priv->tick_dly = 2;
+ } else {
+ mtk_spim_get_attr(priv, dev);
+ }
ret = clk_get_by_name(dev, "sel-clk", &priv->sel_clk);
if (ret < 0) {
@@ -664,8 +681,31 @@ static int mtk_spim_probe(struct udevice *dev)
return ret;
}
- clk_enable(&priv->sel_clk);
+ /*
+ * Upstream DTSI use a different compatible that provide additional
+ * clock instead of the assigned-clock implementation.
+ */
+ if (device_is_compatible(dev, "mediatek,spi-ipm")) {
+ ret = clk_get_by_name(dev, "parent-clk", &priv->parent_clk);
+ if (ret < 0) {
+ dev_err(dev, "failed to get parent-clk\n");
+ return ret;
+ }
+
+ ret = clk_get_by_name(dev, "hclk", &priv->hclk);
+ if (ret < 0) {
+ dev_err(dev, "failed to get hclk\n");
+ return ret;
+ }
+
+ clk_enable(&priv->parent_clk);
+ clk_set_parent(&priv->sel_clk, &priv->parent_clk);
+
+ clk_enable(&priv->hclk);
+ }
+
clk_enable(&priv->spi_clk);
+ clk_enable(&priv->sel_clk);
priv->pll_clk_rate = clk_get_rate(&priv->spi_clk);
if (priv->pll_clk_rate == 0)
@@ -698,6 +738,7 @@ static const struct dm_spi_ops mtk_spim_ops = {
static const struct udevice_id mtk_spim_ids[] = {
{ .compatible = "mediatek,ipm-spi" },
+ { .compatible = "mediatek,spi-ipm", },
{}
};
--
2.43.0
next prev parent reply other threads:[~2024-06-05 19:38 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 ` Christian Marangi [this message]
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 ` [PATCH 08/11] mmc: mediatek: add support for upstream linux clock and property Christian Marangi
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-4-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