All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 08/12] i2c: designware_i2c: Read device-tree properties
Date: Sat, 21 Dec 2019 09:15:21 -0700	[thread overview]
Message-ID: <20191221161525.27976-9-sjg@chromium.org> (raw)
In-Reply-To: <20191221161525.27976-1-sjg@chromium.org>

The i2c controller defines a few timing properties. Read these in and
store them for use by the driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/i2c/designware_i2c.c     |  8 ++++++--
 drivers/i2c/designware_i2c.h     | 15 +++++++++++++++
 drivers/i2c/designware_i2c_pci.c |  2 +-
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index 0a1df8015f..34b6816545 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -535,11 +535,15 @@ static int designware_i2c_probe_chip(struct udevice *bus, uint chip_addr,
 	return ret;
 }
 
-static int designware_i2c_ofdata_to_platdata(struct udevice *bus)
+int designware_i2c_ofdata_to_platdata(struct udevice *bus)
 {
 	struct dw_i2c *priv = dev_get_priv(bus);
 
-	priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
+	if (!priv->regs)
+		priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
+	dev_read_u32(bus, "i2c-scl-rising-time-ns", &priv->scl_rise_time_ns);
+	dev_read_u32(bus, "i2c-scl-falling-time-ns", &priv->scl_fall_time_ns);
+	dev_read_u32(bus, "i2c-sda-hold-time-ns", &priv->sda_hold_time_ns);
 
 	return 0;
 }
diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h
index 1f9940c2ba..55e440f0c0 100644
--- a/drivers/i2c/designware_i2c.h
+++ b/drivers/i2c/designware_i2c.h
@@ -166,10 +166,24 @@ struct dw_scl_sda_cfg {
 	u32 sda_hold;
 };
 
+/**
+ * struct dw_i2c - private information for the bus
+ *
+ * @regs: Registers pointer
+ * @scl_sda_cfg: Deprecated information for x86 (should move to device tree)
+ * @resets: Resets for the I2C controller
+ * @scl_rise_time_ns: Configured SCL rise time in nanoseconds
+ * @scl_fall_time_ns: Configured SCL fall time in nanoseconds
+ * @sda_hold_time_ns: Configured SDA hold time in nanoseconds
+ * @clk: Clock input to the I2C controller
+ */
 struct dw_i2c {
 	struct i2c_regs *regs;
 	struct dw_scl_sda_cfg *scl_sda_cfg;
 	struct reset_ctl_bulk resets;
+	u32 scl_rise_time_ns;
+	u32 scl_fall_time_ns;
+	u32 sda_hold_time_ns;
 #if CONFIG_IS_ENABLED(CLK)
 	struct clk clk;
 #endif
@@ -179,5 +193,6 @@ extern const struct dm_i2c_ops designware_i2c_ops;
 
 int designware_i2c_probe(struct udevice *bus);
 int designware_i2c_remove(struct udevice *dev);
+int designware_i2c_ofdata_to_platdata(struct udevice *bus);
 
 #endif /* __DW_I2C_H_ */
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index 7f0625df66..2b974a07c3 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -63,7 +63,7 @@ static int designware_i2c_pci_ofdata_to_platdata(struct udevice *dev)
 		/* Use BayTrail specific timing values */
 		priv->scl_sda_cfg = &byt_config;
 
-	return 0;
+	return designware_i2c_ofdata_to_platdata(dev);
 }
 
 static int designware_i2c_pci_probe(struct udevice *dev)
-- 
2.24.1.735.g03f4e72817-goog

  parent reply	other threads:[~2019-12-21 16:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21 16:15 [PATCH 00/12] i2c: designware_ic2: Improvements to timing Simon Glass
2019-12-21 16:15 ` [PATCH 01/12] i2c: designware_i2c: Add more registers Simon Glass
2019-12-23  8:15   ` Tan, Ley Foon
2019-12-25 10:20     ` pt
2019-12-21 16:15 ` [PATCH 02/12] i2c: designware_i2c: Don't allow changing IC_CLK Simon Glass
2019-12-21 16:15 ` [PATCH 03/12] i2c: designware_i2c: Include clk.h in the header file Simon Glass
2019-12-23  8:17   ` Tan, Ley Foon
2019-12-21 16:15 ` [PATCH 04/12] i2c: designware_i2c: Rename 'max' speed to 'high' speed Simon Glass
2019-12-21 16:15 ` [PATCH 05/12] i2c: designware_i2c: Use an enum for selected speed mode Simon Glass
2019-12-21 16:15 ` [PATCH 06/12] i2c: designware_i2c: Use an accurate bus clock instead of MHz Simon Glass
2019-12-21 16:15 ` [PATCH 07/12] i2c: designware_i2c: Bring in the binding file Simon Glass
2019-12-21 16:15 ` Simon Glass [this message]
2019-12-21 16:15 ` [PATCH 09/12] i2c: designware_i2c: Drop scl_sda_cfg parameter Simon Glass
2019-12-21 16:15 ` [PATCH 10/12] i2c: designware_i2c: Put hold config in a struct Simon Glass
2019-12-21 16:15 ` [PATCH 11/12] i2c: designware_i2c: Rewrite timing calculation Simon Glass
2019-12-21 16:15 ` [PATCH 12/12] i2c: designware_i2c: Add spike supression Simon Glass

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=20191221161525.27976-9-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.