dm: Rename dev_addr..() functions

These support the flat device tree. We want to use the dev_read_..()
prefix for functions that support both flat tree and live tree. So rename
the existing functions to avoid confusion.

In the end we will have:

   1. dev_read_addr...()    - works on devices, supports flat/live tree
   2. devfdt_get_addr...()  - current functions, flat tree only
   3. of_get_address() etc. - new functions, live tree only

All drivers will be written to use 1. That function will in turn call
either 2 or 3 depending on whether the flat or live tree is in use.

Note this involves changing some dead code - the imx_lpi2c.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index c58bc1e..8ac1cc6 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -134,7 +134,6 @@
 
 config SYS_I2C_IMX_LPI2C
 	bool "NXP i.MX LPI2C driver"
-	depends on ARCH_MX7ULP
 	help
 	  Add support for the NXP i.MX LPI2C driver.
 
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 16dfb57..7ed0c10 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -92,7 +92,7 @@
 	struct ast_i2c_priv *priv = dev_get_priv(dev);
 	int ret;
 
-	priv->regs = dev_get_addr_ptr(dev);
+	priv->regs = devfdt_get_addr_ptr(dev);
 	if (IS_ERR(priv->regs))
 		return PTR_ERR(priv->regs);
 
diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index 5a63669..b7298cf 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -244,7 +244,7 @@
 	struct at91_i2c_bus *bus = dev_get_priv(dev);
 	int node = dev_of_offset(dev);
 
-	bus->regs = (struct at91_i2c_regs *)dev_get_addr(dev);
+	bus->regs = (struct at91_i2c_regs *)devfdt_get_addr(dev);
 	bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);
 	bus->clock_frequency = fdtdec_get_int(blob, node,
 					      "clock-frequency", 100000);
diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index 4471193..2df07bb 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -470,7 +470,7 @@
 	struct i2c_bus *i2c_bus = dev_get_priv(dev);
 
 	i2c_bus->id = dev->seq;
-	i2c_bus->regs = (struct i2c_regs *)dev_get_addr(dev);
+	i2c_bus->regs = (struct i2c_regs *)devfdt_get_addr(dev);
 
 	i2c_bus->speed = 100000;
 	 _davinci_i2c_init(i2c_bus->regs, i2c_bus->speed, 0);
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index c68ff64..d4df35a 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -545,7 +545,7 @@
 #endif
 #endif
 	} else {
-		priv->regs = (struct i2c_regs *)dev_get_addr_ptr(bus);
+		priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
 	}
 
 	__dw_i2c_init(priv->regs, 0, 0);
diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c
index 2dd75fd..9f4ac2f 100644
--- a/drivers/i2c/exynos_hs_i2c.c
+++ b/drivers/i2c/exynos_hs_i2c.c
@@ -524,7 +524,7 @@
 
 	node = dev_of_offset(dev);
 
-	i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);
+	i2c_bus->hsregs = (struct exynos5_hsi2c *)devfdt_get_addr(dev);
 
 	i2c_bus->id = pinmux_decode_periph_id(blob, node);
 
diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index db37444..8265ce3 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -419,7 +419,7 @@
 	struct cdns_i2c_platform_data *pdata =
 		(struct cdns_i2c_platform_data *)dev_get_driver_data(dev);
 
-	i2c_bus->regs = (struct cdns_i2c_regs *)dev_get_addr(dev);
+	i2c_bus->regs = (struct cdns_i2c_regs *)devfdt_get_addr(dev);
 	if (!i2c_bus->regs)
 		return -ENOMEM;
 
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index be9fc8a..e51537b 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -104,7 +104,7 @@
 	struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
 	int ret;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 75d1c4c..3412e2a 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -49,7 +49,7 @@
 	fdt_addr_t addr;
 	struct uniphier_i2c_dev *priv = dev_get_priv(dev);
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index f792d44..aa97196 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -25,9 +25,8 @@
 	return 0;
 }
 
-static int imx_lpci2c_check_busy_bus(struct udevice *bus)
+static int imx_lpci2c_check_busy_bus(const struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 status;
 
@@ -39,9 +38,8 @@
 	return result;
 }
 
-static int imx_lpci2c_check_clear_error(struct udevice *bus)
+static int imx_lpci2c_check_clear_error(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val, status;
 
@@ -71,9 +69,8 @@
 	return result;
 }
 
-static int bus_i2c_wait_for_tx_ready(struct udevice *bus)
+static int bus_i2c_wait_for_tx_ready(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 txcount = 0;
 	ulong start_time = get_timer(0);
@@ -81,7 +78,7 @@
 	do {
 		txcount = LPI2C_MFSR_TXCOUNT(readl(&regs->mfsr));
 		txcount = LPI2C_FIFO_SIZE - txcount;
-		result = imx_lpci2c_check_clear_error(bus);
+		result = imx_lpci2c_check_clear_error(regs);
 		if (result) {
 			debug("i2c: wait for tx ready: result 0x%x\n", result);
 			return result;
@@ -95,9 +92,8 @@
 	return result;
 }
 
-static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len)
+static int bus_i2c_send(struct imx_lpi2c_reg *regs, u8 *txbuf, int len)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 
 	/* empty tx */
@@ -105,7 +101,7 @@
 		return result;
 
 	while (len--) {
-		result = bus_i2c_wait_for_tx_ready(bus);
+		result = bus_i2c_wait_for_tx_ready(regs);
 		if (result) {
 			debug("i2c: send wait fot tx ready: %d\n", result);
 			return result;
@@ -116,9 +112,8 @@
 	return result;
 }
 
-static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
+static int bus_i2c_receive(struct imx_lpi2c_reg *regs, u8 *rxbuf, int len)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val;
 	ulong start_time = get_timer(0);
@@ -127,7 +122,7 @@
 	if (!len)
 		return result;
 
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: receive wait fot tx ready: %d\n", result);
 		return result;
@@ -141,9 +136,10 @@
 
 	while (len--) {
 		do {
-			result = imx_lpci2c_check_clear_error(bus);
+			result = imx_lpci2c_check_clear_error(regs);
 			if (result) {
-				debug("i2c: receive check clear error: %d\n", result);
+				debug("i2c: receive check clear error: %d\n",
+				      result);
 				return result;
 			}
 			if (get_timer(start_time) > LPI2C_TIMEOUT_MS) {
@@ -158,13 +154,12 @@
 	return result;
 }
 
-static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
+static int bus_i2c_start(struct imx_lpi2c_reg *regs, u8 addr, u8 dir)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val;
 
-	result = imx_lpci2c_check_busy_bus(bus);
+	result = imx_lpci2c_check_busy_bus(regs);
 	if (result) {
 		debug("i2c: start check busy bus: 0x%x\n", result);
 		return result;
@@ -175,7 +170,7 @@
 	val = readl(&regs->mcfgr1) & ~LPI2C_MCFGR1_AUTOSTOP_MASK;
 	writel(val, &regs->mcfgr1);
 	/* wait tx fifo ready */
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: start wait for tx ready: 0x%x\n", result);
 		return result;
@@ -186,13 +181,13 @@
 
 	return result;
 }
-static int bus_i2c_stop(struct udevice *bus)
+
+static int bus_i2c_stop(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 status;
 
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: stop wait for tx ready: 0x%x\n", result);
 		return result;
@@ -203,7 +198,7 @@
 
 	while (result == LPI2C_SUCESS) {
 		status = readl(&regs->msr);
-		result = imx_lpci2c_check_clear_error(bus);
+		result = imx_lpci2c_check_clear_error(regs);
 		/* stop detect flag */
 		if (status & LPI2C_MSR_SDF_MASK) {
 			/* clear stop flag */
@@ -216,34 +211,34 @@
 	return result;
 }
 
-static int bus_i2c_read(struct udevice *bus, u32 chip, u8 *buf, int len)
+static int bus_i2c_read(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len)
 {
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 1);
+	result = bus_i2c_start(regs, chip, 1);
 	if (result)
 		return result;
-	result = bus_i2c_receive(bus, buf, len);
+	result = bus_i2c_receive(regs, buf, len);
 	if (result)
 		return result;
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result)
 		return result;
 
 	return result;
 }
 
-static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len)
+static int bus_i2c_write(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len)
 {
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 0);
+	result = bus_i2c_start(regs, chip, 0);
 	if (result)
 		return result;
-	result = bus_i2c_send(bus, buf, len);
+	result = bus_i2c_send(regs, buf, len);
 	if (result)
 		return result;
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result)
 		return result;
 
@@ -253,7 +248,7 @@
 
 static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
+	struct imx_lpi2c_reg *regs;
 	u32 val;
 	u32 preescale = 0, best_pre = 0, clkhi = 0;
 	u32 best_clkhi = 0, abs_error = 0, rate;
@@ -262,6 +257,7 @@
 	bool mode;
 	int i;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	clock_rate = imx_get_i2cclk(bus->seq + 4);
 	if (!clock_rate)
 		return -EPERM;
@@ -320,10 +316,11 @@
 
 static int bus_i2c_init(struct udevice *bus, int speed)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
+	struct imx_lpi2c_reg *regs;
 	u32 val;
 	int ret;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	/* reset peripheral */
 	writel(LPI2C_MCR_RST_MASK, &regs->mcr);
 	writel(0x0, &regs->mcr);
@@ -356,16 +353,18 @@
 static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
 				u32 chip_flags)
 {
+	struct imx_lpi2c_reg *regs;
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 0);
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
+	result = bus_i2c_start(regs, chip, 0);
 	if (result) {
-		bus_i2c_stop(bus);
+		bus_i2c_stop(regs);
 		bus_i2c_init(bus, 100000);
 		return result;
 	}
 
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result) {
 		bus_i2c_init(bus, 100000);
 		return -result;
@@ -376,15 +375,16 @@
 
 static int imx_lpi2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
 {
+	struct imx_lpi2c_reg *regs;
 	int ret = 0;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	for (; nmsgs > 0; nmsgs--, msg++) {
 		debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
 		if (msg->flags & I2C_M_RD)
-			ret = bus_i2c_read(bus, msg->addr, msg->buf,
-					   msg->len);
+			ret = bus_i2c_read(regs, msg->addr, msg->buf, msg->len);
 		else {
-			ret = bus_i2c_write(bus, msg->addr, msg->buf,
+			ret = bus_i2c_write(regs, msg->addr, msg->buf,
 					    msg->len);
 			if (ret)
 				break;
@@ -410,7 +410,7 @@
 
 	i2c_bus->driver_data = dev_get_driver_data(bus);
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index c780272..913721b 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -579,7 +579,7 @@
 {
 	struct mv_i2c_priv *priv = dev_get_priv(bus);
 
-	priv->base = (void *)dev_get_addr_ptr(bus);
+	priv->base = (void *)devfdt_get_addr_ptr(bus);
 
 	return 0;
 }
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 3703519..dfbc4e0 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -778,7 +778,7 @@
 {
 	struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
 
-	dev->base = dev_get_addr_ptr(bus);
+	dev->base = devfdt_get_addr_ptr(bus);
 
 	if (!dev->base)
 		return -ENOMEM;
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index b68e827..3258ae7 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -752,7 +752,7 @@
 
 	i2c_bus->driver_data = dev_get_driver_data(bus);
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index 4b8397a..f71e0a5 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -896,7 +896,7 @@
 {
 	struct omap_i2c *priv = dev_get_priv(bus);
 
-	priv->regs = map_physmem(dev_get_addr(bus), sizeof(void *),
+	priv->regs = map_physmem(devfdt_get_addr(bus), sizeof(void *),
 				 MAP_NOCACHE);
 	priv->speed = CONFIG_SYS_OMAP24_I2C_SPEED;
 
diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 76f41f7..8bc045a 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -369,7 +369,7 @@
 {
 	struct rk_i2c *priv = dev_get_priv(bus);
 
-	priv->regs = (void *)dev_get_addr(bus);
+	priv->regs = (void *)devfdt_get_addr(bus);
 
 	return 0;
 }
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 3c69dbf..06fe0a5 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -314,7 +314,7 @@
 
 	node = dev_of_offset(dev);
 
-	i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);
+	i2c_bus->regs = (struct s3c24x0_i2c *)devfdt_get_addr(dev);
 
 	i2c_bus->id = pinmux_decode_periph_id(blob, node);
 
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 898f12a..055f481 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -365,7 +365,7 @@
 
 	i2c_bus->id = dev->seq;
 	i2c_bus->type = dev_get_driver_data(dev);
-	i2c_bus->regs = (struct i2c_ctlr *)dev_get_addr(dev);
+	i2c_bus->regs = (struct i2c_ctlr *)devfdt_get_addr(dev);
 
 	ret = reset_get_by_name(dev, "i2c", &i2c_bus->reset_ctl);
 	if (ret) {