mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH v2 3/8] i2c: lpi2c: add PBL support
Date: Mon,  5 Feb 2024 08:45:48 +0100	[thread overview]
Message-ID: <20240205074553.2005284-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240205074553.2005284-1-s.hauer@pengutronix.de>

This adds PBL support to the lpi2c driver which can be used for early
I2C support on i.MX93.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/i2c/busses/Makefile        |  2 +-
 drivers/i2c/busses/i2c-imx-lpi2c.c | 34 ++++++++++++++++++++++++++++++
 include/pbl/i2c.h                  |  1 +
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 48f9b5be04..b4225995c0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -4,7 +4,7 @@ obj-$(CONFIG_I2C_BCM283X)	+= i2c-bcm283x.o
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX)		+= i2c-imx.o
 lwl-$(CONFIG_I2C_IMX_EARLY)	+= i2c-imx-early.o
-obj-$(CONFIG_I2C_IMX_LPI2C)	+= i2c-imx-lpi2c.o
+obj-pbl-$(CONFIG_I2C_IMX_LPI2C)	+= i2c-imx-lpi2c.o
 obj-$(CONFIG_I2C_MV64XXX)	+= i2c-mv64xxx.o
 obj-$(CONFIG_I2C_OMAP)		+= i2c-omap.o
 obj-$(CONFIG_I2C_TEGRA)		+= i2c-tegra.o
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 42f7b37143..a7d52fb1b1 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -19,6 +19,7 @@
 #include <pinctrl.h>
 #include <of_gpio.h>
 #include <of_device.h>
+#include <pbl/i2c.h>
 
 #include <io.h>
 #include <i2c/i2c.h>
@@ -93,6 +94,7 @@ enum lpi2c_imx_pincfg {
 
 struct lpi2c_imx_struct {
 	struct i2c_adapter	adapter;
+	struct pbl_i2c		pbl_i2c;
 	int			num_clks;
 	struct clk_bulk_data	*clks;
 	void __iomem		*base;
@@ -455,6 +457,36 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter,
 	return (result < 0) ? result : num;
 }
 
+#ifdef __PBL__
+
+static int lpi2c_pbl_imx_xfer(struct pbl_i2c *lpi2c, struct i2c_msg *msgs, int num)
+{
+	struct lpi2c_imx_struct *lpi2c_imx = container_of(lpi2c, struct lpi2c_imx_struct, pbl_i2c);
+
+	return lpi2c_imx_xfer(&lpi2c_imx->adapter, msgs, num);
+}
+
+struct pbl_i2c *imx93_i2c_early_init(void __iomem *regs)
+{
+	static struct lpi2c_imx_struct lpi2c;
+	u32 temp;
+
+	lpi2c.base = regs;
+
+	temp = readl(lpi2c.base + LPI2C_PARAM);
+	printf("%s: 0x%08x\n", __func__, temp);
+	lpi2c.txfifosize = 1 << (temp & 0x0f);
+	lpi2c.rxfifosize = 1 << ((temp >> 8) & 0x0f);
+	lpi2c.bitrate = 100000;
+	lpi2c.clk_rate = 24000000;
+
+	lpi2c.pbl_i2c.xfer = lpi2c_pbl_imx_xfer;
+
+	return &lpi2c.pbl_i2c;
+}
+
+#else
+
 static const struct of_device_id lpi2c_imx_of_match[] = {
 	{ .compatible = "fsl,imx7ulp-lpi2c" },
 	{ },
@@ -517,6 +549,8 @@ static struct driver lpi2c_imx_driver = {
 };
 coredevice_platform_driver(lpi2c_imx_driver);
 
+#endif
+
 MODULE_AUTHOR("Gao Pan <pandy.gao@nxp.com>");
 MODULE_DESCRIPTION("I2C adapter driver for LPI2C bus");
 MODULE_LICENSE("GPL");
diff --git a/include/pbl/i2c.h b/include/pbl/i2c.h
index ea2ae447a3..b31f72bee7 100644
--- a/include/pbl/i2c.h
+++ b/include/pbl/i2c.h
@@ -18,6 +18,7 @@ static inline int pbl_i2c_xfer(struct pbl_i2c *i2c,
 struct pbl_i2c *imx8m_i2c_early_init(void __iomem *regs);
 struct pbl_i2c *imx6_i2c_early_init(void __iomem *regs);
 struct pbl_i2c *ls1046_i2c_init(void __iomem *regs);
+struct pbl_i2c *imx93_i2c_early_init(void __iomem *regs);
 
 static inline int i2c_dev_probe(struct pbl_i2c *i2c, int addr, bool onebyte)
 {
-- 
2.39.2




  parent reply	other threads:[~2024-02-05  7:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05  7:45 [PATCH v2 0/8] ARM: i.MX93: TQMA93xx: Add LGA variant Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 1/8] i2c: lpi2c: determine clk rate during probe Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 2/8] i2c: lpi2c: use udelay for timeout loops Sascha Hauer
2024-02-05  7:45 ` Sascha Hauer [this message]
2024-02-05  7:45 ` [PATCH v2 4/8] pbl: eeprom: return error from eeprom_read() Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 5/8] common: add TQ EEPROM support Sascha Hauer
2024-02-05  8:11   ` Marco Felsch
2024-02-05  8:18     ` Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 6/8] ARM: i.MX9: add i2c base address defines Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 7/8] ARM: i.MX9: rename TQ i.MX93 board to TQMA93XX Sascha Hauer
2024-02-05  7:45 ` [PATCH v2 8/8] ARM: i.MX: tqma93xx: Add LGA board variant Sascha Hauer
2024-02-08  7:19 ` [PATCH v2 0/8] ARM: i.MX93: TQMA93xx: Add LGA variant Sascha Hauer

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=20240205074553.2005284-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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