public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/4] i2c: cdns: Read address from DT in ofdata_to_platdata
@ 2016-04-14 12:15 Michal Simek
  2016-04-14 12:15 ` [U-Boot] [PATCH 2/4] i2c: cdns: Moving speed setup from probe to set_bus_speed function Michal Simek
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Michal Simek @ 2016-04-14 12:15 UTC (permalink / raw)
  To: u-boot

Extract reading IP base address in function which is designed for it.
Also enable option to read more information from DT in this function.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/i2c/i2c-cdns.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index 909cea24182e..66bd580aad4b 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -125,10 +125,6 @@ static int cdns_i2c_probe(struct udevice *dev)
 {
 	struct i2c_cdns_bus *bus = dev_get_priv(dev);
 
-	bus->regs = (struct cdns_i2c_regs *)dev_get_addr(dev);
-	if (!bus->regs)
-		return -ENOMEM;
-
 	/* TODO: Calculate dividers based on CPU_CLK_1X */
 	/* 111MHz / ( (3 * 17) * 22 ) = ~100KHz */
 	writel((16 << CDNS_I2C_CONTROL_DIV_B_SHIFT) |
@@ -313,6 +309,17 @@ static int cdns_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
 	return 0;
 }
 
+static int cdns_i2c_ofdata_to_platdata(struct udevice *dev)
+{
+	struct i2c_cdns_bus *i2c_bus = dev_get_priv(dev);
+
+	i2c_bus->regs = (struct cdns_i2c_regs *)dev_get_addr(dev);
+	if (!i2c_bus->regs)
+		return -ENOMEM;
+
+	return 0;
+}
+
 static const struct dm_i2c_ops cdns_i2c_ops = {
 	.xfer = cdns_i2c_xfer,
 	.probe_chip = cdns_i2c_probe_chip,
@@ -330,6 +337,7 @@ U_BOOT_DRIVER(cdns_i2c) = {
 	.of_match = cdns_i2c_of_match,
 	.probe = cdns_i2c_probe,
 	.remove = cdns_i2c_remove,
+	.ofdata_to_platdata = cdns_i2c_ofdata_to_platdata,
 	.priv_auto_alloc_size = sizeof(struct i2c_cdns_bus),
 	.ops = &cdns_i2c_ops,
 };
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-04-25  8:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14 12:15 [U-Boot] [PATCH 1/4] i2c: cdns: Read address from DT in ofdata_to_platdata Michal Simek
2016-04-14 12:15 ` [U-Boot] [PATCH 2/4] i2c: cdns: Moving speed setup from probe to set_bus_speed function Michal Simek
2016-04-18  6:48   ` Heiko Schocher
2016-04-14 12:15 ` [U-Boot] [PATCH 3/4] i2c: cdns: Support different bus speeds Michal Simek
2016-04-18  7:08   ` Heiko Schocher
2016-04-18 11:09     ` Michal Simek
2016-04-14 12:15 ` [U-Boot] [PATCH 4/4] i2c: muxes: Add support for TI PCA954X mux Michal Simek
2016-04-18  7:27   ` Heiko Schocher
2016-04-20 14:41   ` Simon Glass
2016-04-25  8:36     ` Michal Simek
2016-04-18  6:47 ` [U-Boot] [PATCH 1/4] i2c: cdns: Read address from DT in ofdata_to_platdata Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox