Commit 36f78aaa authored by Chaithrika U S's avatar Chaithrika U S Committed by Kevin Hilman

i2c: davinci: misc. cleanups: remove MOD_REG_BIT and IO_ADDRESS usage

Cleanup the DaVinci I2C driver. Remove MOD_REG_BIT macro.
Also use ioremap instead of IO_ADDRESS macro.
Signed-off-by: default avatarChaithrika U S <chaithrika@ti.com>
Acked-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 869e6692
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <mach/i2c.h> #include <mach/i2c.h>
/* ----- global defines ----------------------------------------------- */ /* ----- global defines ----------------------------------------------- */
...@@ -72,37 +71,29 @@ ...@@ -72,37 +71,29 @@
#define DAVINCI_I2C_IVR_NACK 0x02 #define DAVINCI_I2C_IVR_NACK 0x02
#define DAVINCI_I2C_IVR_AL 0x01 #define DAVINCI_I2C_IVR_AL 0x01
#define DAVINCI_I2C_STR_BB (1 << 12) #define DAVINCI_I2C_STR_BB BIT(12)
#define DAVINCI_I2C_STR_RSFULL (1 << 11) #define DAVINCI_I2C_STR_RSFULL BIT(11)
#define DAVINCI_I2C_STR_SCD (1 << 5) #define DAVINCI_I2C_STR_SCD BIT(5)
#define DAVINCI_I2C_STR_ARDY (1 << 2) #define DAVINCI_I2C_STR_ARDY BIT(2)
#define DAVINCI_I2C_STR_NACK (1 << 1) #define DAVINCI_I2C_STR_NACK BIT(1)
#define DAVINCI_I2C_STR_AL (1 << 0) #define DAVINCI_I2C_STR_AL BIT(0)
#define DAVINCI_I2C_MDR_NACK (1 << 15) #define DAVINCI_I2C_MDR_NACK BIT(15)
#define DAVINCI_I2C_MDR_STT (1 << 13) #define DAVINCI_I2C_MDR_STT BIT(13)
#define DAVINCI_I2C_MDR_STP (1 << 11) #define DAVINCI_I2C_MDR_STP BIT(11)
#define DAVINCI_I2C_MDR_MST (1 << 10) #define DAVINCI_I2C_MDR_MST BIT(10)
#define DAVINCI_I2C_MDR_TRX (1 << 9) #define DAVINCI_I2C_MDR_TRX BIT(9)
#define DAVINCI_I2C_MDR_XA (1 << 8) #define DAVINCI_I2C_MDR_XA BIT(8)
#define DAVINCI_I2C_MDR_RM (1 << 7) #define DAVINCI_I2C_MDR_RM BIT(7)
#define DAVINCI_I2C_MDR_IRS (1 << 5) #define DAVINCI_I2C_MDR_IRS BIT(5)
#define DAVINCI_I2C_IMR_AAS (1 << 6) #define DAVINCI_I2C_IMR_AAS BIT(6)
#define DAVINCI_I2C_IMR_SCD (1 << 5) #define DAVINCI_I2C_IMR_SCD BIT(5)
#define DAVINCI_I2C_IMR_XRDY (1 << 4) #define DAVINCI_I2C_IMR_XRDY BIT(4)
#define DAVINCI_I2C_IMR_RRDY (1 << 3) #define DAVINCI_I2C_IMR_RRDY BIT(3)
#define DAVINCI_I2C_IMR_ARDY (1 << 2) #define DAVINCI_I2C_IMR_ARDY BIT(2)
#define DAVINCI_I2C_IMR_NACK (1 << 1) #define DAVINCI_I2C_IMR_NACK BIT(1)
#define DAVINCI_I2C_IMR_AL (1 << 0) #define DAVINCI_I2C_IMR_AL BIT(0)
#define MOD_REG_BIT(val, mask, set) do { \
if (set) { \
val |= mask; \
} else { \
val &= ~mask; \
} \
} while (0)
struct davinci_i2c_dev { struct davinci_i2c_dev {
struct device *dev; struct device *dev;
...@@ -156,7 +147,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev) ...@@ -156,7 +147,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
/* put I2C into reset */ /* put I2C into reset */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0); w &= ~DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w); davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
/* NOTE: I2C Clock divider programming info /* NOTE: I2C Clock divider programming info
...@@ -206,7 +197,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev) ...@@ -206,7 +197,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
/* Take the I2C module out of reset: */ /* Take the I2C module out of reset: */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1); w |= DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w); davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
/* Enable interrupts */ /* Enable interrupts */
...@@ -288,9 +279,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) ...@@ -288,9 +279,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
/* Enable receive or transmit interrupts */ /* Enable receive or transmit interrupts */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG); w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG);
if (msg->flags & I2C_M_RD) if (msg->flags & I2C_M_RD)
MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 1); w |= DAVINCI_I2C_IMR_RRDY;
else else
MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1); w |= DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w); davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w);
dev->terminate = 0; dev->terminate = 0;
...@@ -349,7 +340,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) ...@@ -349,7 +340,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
return msg->len; return msg->len;
if (stop) { if (stop) {
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
MOD_REG_BIT(w, DAVINCI_I2C_MDR_STP, 1); w |= DAVINCI_I2C_MDR_STP;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w); davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
} }
return -EREMOTEIO; return -EREMOTEIO;
...@@ -485,7 +476,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id) ...@@ -485,7 +476,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
w = davinci_i2c_read_reg(dev, w = davinci_i2c_read_reg(dev,
DAVINCI_I2C_IMR_REG); DAVINCI_I2C_IMR_REG);
MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 0); w &= ~DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev, davinci_i2c_write_reg(dev,
DAVINCI_I2C_IMR_REG, DAVINCI_I2C_IMR_REG,
w); w);
...@@ -564,7 +555,12 @@ static int davinci_i2c_probe(struct platform_device *pdev) ...@@ -564,7 +555,12 @@ static int davinci_i2c_probe(struct platform_device *pdev)
} }
clk_enable(dev->clk); clk_enable(dev->clk);
dev->base = (void __iomem *)IO_ADDRESS(mem->start); dev->base = ioremap(mem->start, resource_size(mem));
if (!dev->base) {
r = -EBUSY;
goto err_mem_ioremap;
}
i2c_davinci_init(dev); i2c_davinci_init(dev);
r = request_irq(dev->irq, i2c_davinci_isr, 0, pdev->name, dev); r = request_irq(dev->irq, i2c_davinci_isr, 0, pdev->name, dev);
...@@ -594,6 +590,8 @@ static int davinci_i2c_probe(struct platform_device *pdev) ...@@ -594,6 +590,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)
err_free_irq: err_free_irq:
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
err_unuse_clocks: err_unuse_clocks:
iounmap(dev->base);
err_mem_ioremap:
clk_disable(dev->clk); clk_disable(dev->clk);
clk_put(dev->clk); clk_put(dev->clk);
dev->clk = NULL; dev->clk = NULL;
...@@ -622,6 +620,7 @@ static int davinci_i2c_remove(struct platform_device *pdev) ...@@ -622,6 +620,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0); davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
free_irq(IRQ_I2C, dev); free_irq(IRQ_I2C, dev);
iounmap(dev->base);
kfree(dev); kfree(dev);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment