mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 09/19] i2c i.MX: convert to struct resource
Date: Tue, 19 Jul 2011 10:39:53 +0200	[thread overview]
Message-ID: <1311064803-6305-10-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1311064803-6305-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/i2c/busses/i2c-imx.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 93e978e..aaed8c4 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -102,6 +102,7 @@ static u16 i2c_clk_div[50][2] = {
 };
 
 struct imx_i2c_struct {
+	void __iomem		*base;
 	struct i2c_adapter	adapter;
 	unsigned int 		disable_delay;
 	int			stopped;
@@ -140,7 +141,8 @@ static inline void i2c_imx_dump_reg(struct i2c_adapter *adapter)
 
 static int i2c_imx_bus_busy(struct i2c_adapter *adapter, int for_busy)
 {
-	unsigned long base = adapter->dev->map_base;
+	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
+	void __iomem *base = i2c_imx->base;
 	uint64_t start;
 	unsigned int temp;
 
@@ -164,7 +166,8 @@ static int i2c_imx_bus_busy(struct i2c_adapter *adapter, int for_busy)
 
 static int i2c_imx_trx_complete(struct i2c_adapter *adapter)
 {
-	unsigned long base = adapter->dev->map_base;
+	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
+	void __iomem *base = i2c_imx->base;
 	uint64_t start;
 
 	start = get_time_ns();
@@ -185,7 +188,8 @@ static int i2c_imx_trx_complete(struct i2c_adapter *adapter)
 
 static int i2c_imx_acked(struct i2c_adapter *adapter)
 {
-	unsigned long base = adapter->dev->map_base;
+	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
+	void __iomem *base = i2c_imx->base;
 	uint64_t start;
 
 	start = get_time_ns();
@@ -206,7 +210,7 @@ static int i2c_imx_acked(struct i2c_adapter *adapter)
 static int i2c_imx_start(struct i2c_adapter *adapter)
 {
 	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
-	unsigned long base = adapter->dev->map_base;
+	void __iomem *base = i2c_imx->base;
 	unsigned int temp = 0;
 	int result;
 
@@ -238,7 +242,7 @@ static int i2c_imx_start(struct i2c_adapter *adapter)
 static void i2c_imx_stop(struct i2c_adapter *adapter)
 {
 	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
-	unsigned long base = adapter->dev->map_base;
+	void __iomem *base = i2c_imx->base;
 	unsigned int temp = 0;
 
 	if (!i2c_imx->stopped) {
@@ -306,7 +310,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
 
 static int i2c_imx_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 {
-	unsigned long base = adapter->dev->map_base;
+	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
+	void __iomem *base = i2c_imx->base;
 	int i, result;
 
 	dev_dbg(adapter->dev,
@@ -343,7 +348,7 @@ static int i2c_imx_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 static int i2c_imx_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 {
 	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
-	unsigned long base = adapter->dev->map_base;
+	void __iomem *base = i2c_imx->base;
 	int i, result;
 	unsigned int temp;
 
@@ -411,7 +416,8 @@ static int i2c_imx_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 static int i2c_imx_xfer(struct i2c_adapter *adapter,
 			struct i2c_msg *msgs, int num)
 {
-	unsigned long base = adapter->dev->map_base;
+	struct imx_i2c_struct *i2c_imx = to_imx_i2c_struct(adapter);
+	void __iomem *base = i2c_imx->base;
 	unsigned int i, temp;
 	int result;
 
@@ -453,7 +459,6 @@ static int __init i2c_imx_probe(struct device_d *pdev)
 {
 	struct imx_i2c_struct *i2c_imx;
 	struct i2c_platform_data *pdata;
-	unsigned long base = pdev->map_base;
 	int ret;
 
 	pdata = pdev->platform_data;
@@ -464,6 +469,7 @@ static int __init i2c_imx_probe(struct device_d *pdev)
 	i2c_imx->adapter.master_xfer = i2c_imx_xfer;
 	i2c_imx->adapter.nr = pdev->id;
 	i2c_imx->adapter.dev = pdev;
+	i2c_imx->base = dev_request_mem_region(pdev, 0);
 
 	/* Set up clock divider */
 	if (pdata && pdata->bitrate)
@@ -472,8 +478,8 @@ static int __init i2c_imx_probe(struct device_d *pdev)
 		i2c_imx_set_clk(i2c_imx, IMX_I2C_BIT_RATE);
 
 	/* Set up chip registers to defaults */
-	writeb(0, base + IMX_I2C_I2CR);
-	writeb(0, base + IMX_I2C_I2SR);
+	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
+	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
 
 	/* Add I2C adapter */
 	ret = i2c_add_numbered_adapter(&i2c_imx->adapter);
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-07-19  8:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-19  8:39 [PATCH] resources work Sascha Hauer
2011-07-19  8:39 ` [PATCH 01/19] register_device: Add IORESOURCE_MEM flag Sascha Hauer
2011-07-19  8:39 ` [PATCH 02/19] device: Add a dev_request_mem_region function Sascha Hauer
2011-07-19 10:11   ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 10:58     ` Sascha Hauer
2011-07-19  8:39 ` [PATCH 03/19] add a add_mem_device function Sascha Hauer
2011-07-19 10:13   ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 11:00     ` Sascha Hauer
2011-07-19 13:06       ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-19  8:39 ` [PATCH 04/19] generic memmap: use resources Sascha Hauer
2011-07-19  8:39 ` [PATCH 05/19] mem_read/write: " Sascha Hauer
2011-07-19 10:14   ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-19  8:39 ` [PATCH 06/19] nand i.MX: convert to struct resource Sascha Hauer
2011-07-19  8:39 ` [PATCH 07/19] video " Sascha Hauer
2011-07-19  8:39 ` [PATCH 08/19] serial " Sascha Hauer
2011-07-19  8:39 ` Sascha Hauer [this message]
2011-07-19  8:39 ` [PATCH 10/19] mci " Sascha Hauer
2011-07-19  8:39 ` [PATCH 11/19] net i.MX fec: " Sascha Hauer
2011-07-19  8:39 ` [PATCH 12/19] mci i.MX esdhc: " Sascha Hauer
2011-07-19  8:39 ` [PATCH 13/19] spi i.MX: " Sascha Hauer
2011-07-19  8:39 ` [PATCH 14/19] video i.MX ipu: " Sascha Hauer
2011-07-19  8:39 ` [PATCH 15/19] i.MX devices: " Sascha Hauer
2011-07-19  8:40 ` [PATCH 16/19] cfi: " Sascha Hauer
2011-07-19  8:40 ` [PATCH 17/19] ARM pcm038: use add_mem_device helper Sascha Hauer
2011-07-19  8:40 ` [PATCH 18/19] ARM pcm037: " Sascha Hauer
2011-07-19  8:40 ` [PATCH 19/19] ARM i.MX51 babbage: " 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=1311064803-6305-10-git-send-email-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