]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: mediatek: add support for optional arb and pmic clock
authorChristian Marangi <ansuelsmth@gmail.com>
Mon, 24 Jun 2024 21:03:31 +0000 (23:03 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 8 Jul 2024 17:45:50 +0000 (11:45 -0600)
Add support for optional arb and pmic clock for i2c provided in upstream
linux DTSI.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
drivers/i2c/mtk_i2c.c

index 5592fe9181718b5076bbed5ccd6eb992aa6626dc..3450177741aa31645a2e04bd9bf2532b28b98a85 100644 (file)
@@ -221,6 +221,8 @@ struct mtk_i2c_priv {
        void __iomem *pdmabase;         /* dma base address*/
        struct clk clk_main;            /* main clock for i2c bus */
        struct clk clk_dma;             /* DMA clock for i2c via DMA */
+       struct clk clk_arb;             /* DMA clock for i2c ARB */
+       struct clk clk_pmic;            /* DMA clock for i2c PMIC */
        const struct mtk_i2c_soc_data *soc_data; /* Compatible data for different IC */
        int op;                         /* operation mode */
        bool zero_len;                  /* Only transfer slave address, no data */
@@ -255,6 +257,18 @@ static int mtk_i2c_clk_enable(struct mtk_i2c_priv *priv)
        if (ret)
                return log_msg_ret("enable clk_dma", ret);
 
+       if (priv->clk_arb.dev) {
+               ret = clk_enable(&priv->clk_arb);
+               if (ret)
+                       return log_msg_ret("enable clk_arb", ret);
+       }
+
+       if (priv->clk_pmic.dev) {
+               ret = clk_enable(&priv->clk_pmic);
+               if (ret)
+                       return log_msg_ret("enable clk_pmic", ret);
+       }
+
        return 0;
 }
 
@@ -262,6 +276,18 @@ static int mtk_i2c_clk_disable(struct mtk_i2c_priv *priv)
 {
        int ret;
 
+       if (priv->clk_pmic.dev) {
+               ret = clk_disable(&priv->clk_pmic);
+               if (ret)
+                       return log_msg_ret("disable clk_pmic", ret);
+       }
+
+       if (priv->clk_arb.dev) {
+               ret = clk_disable(&priv->clk_arb);
+               if (ret)
+                       return log_msg_ret("disable clk_arb", ret);
+       }
+
        ret = clk_disable(&priv->clk_dma);
        if (ret)
                return log_msg_ret("disable clk_dma", ret);
@@ -748,6 +774,10 @@ static int mtk_i2c_of_to_plat(struct udevice *dev)
 
        ret = clk_get_by_index(dev, 1, &priv->clk_dma);
 
+       /* optional i2c clock */
+       clk_get_by_name(dev, "arb", &priv->clk_arb);
+       clk_get_by_name(dev, "pmic", &priv->clk_pmic);
+
        return ret;
 }