aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-omap.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0037e31076ba..913abd7c172f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -49,24 +49,24 @@
49#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) 49#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
50 50
51#define OMAP_I2C_REV_REG 0x00 51#define OMAP_I2C_REV_REG 0x00
52#define OMAP_I2C_IE_REG 0x04 52#define OMAP_I2C_IE_REG 0x01
53#define OMAP_I2C_STAT_REG 0x08 53#define OMAP_I2C_STAT_REG 0x02
54#define OMAP_I2C_IV_REG 0x0c 54#define OMAP_I2C_IV_REG 0x03
55/* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ 55/* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
56#define OMAP_I2C_WE_REG 0x0c 56#define OMAP_I2C_WE_REG 0x03
57#define OMAP_I2C_SYSS_REG 0x10 57#define OMAP_I2C_SYSS_REG 0x04
58#define OMAP_I2C_BUF_REG 0x14 58#define OMAP_I2C_BUF_REG 0x05
59#define OMAP_I2C_CNT_REG 0x18 59#define OMAP_I2C_CNT_REG 0x06
60#define OMAP_I2C_DATA_REG 0x1c 60#define OMAP_I2C_DATA_REG 0x07
61#define OMAP_I2C_SYSC_REG 0x20 61#define OMAP_I2C_SYSC_REG 0x08
62#define OMAP_I2C_CON_REG 0x24 62#define OMAP_I2C_CON_REG 0x09
63#define OMAP_I2C_OA_REG 0x28 63#define OMAP_I2C_OA_REG 0x0a
64#define OMAP_I2C_SA_REG 0x2c 64#define OMAP_I2C_SA_REG 0x0b
65#define OMAP_I2C_PSC_REG 0x30 65#define OMAP_I2C_PSC_REG 0x0c
66#define OMAP_I2C_SCLL_REG 0x34 66#define OMAP_I2C_SCLL_REG 0x0d
67#define OMAP_I2C_SCLH_REG 0x38 67#define OMAP_I2C_SCLH_REG 0x0e
68#define OMAP_I2C_SYSTEST_REG 0x3c 68#define OMAP_I2C_SYSTEST_REG 0x0f
69#define OMAP_I2C_BUFSTAT_REG 0x40 69#define OMAP_I2C_BUFSTAT_REG 0x10
70 70
71/* I2C Interrupt Enable Register (OMAP_I2C_IE): */ 71/* I2C Interrupt Enable Register (OMAP_I2C_IE): */
72#define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ 72#define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */
@@ -161,6 +161,7 @@ struct omap_i2c_dev {
161 struct device *dev; 161 struct device *dev;
162 void __iomem *base; /* virtual */ 162 void __iomem *base; /* virtual */
163 int irq; 163 int irq;
164 int reg_shift; /* bit shift for I2C register addresses */
164 struct clk *iclk; /* Interface clock */ 165 struct clk *iclk; /* Interface clock */
165 struct clk *fclk; /* Functional clock */ 166 struct clk *fclk; /* Functional clock */
166 struct completion cmd_complete; 167 struct completion cmd_complete;
@@ -189,12 +190,12 @@ struct omap_i2c_dev {
189static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, 190static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
190 int reg, u16 val) 191 int reg, u16 val)
191{ 192{
192 __raw_writew(val, i2c_dev->base + reg); 193 __raw_writew(val, i2c_dev->base + (reg << i2c_dev->reg_shift));
193} 194}
194 195
195static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) 196static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
196{ 197{
197 return __raw_readw(i2c_dev->base + reg); 198 return __raw_readw(i2c_dev->base + (reg << i2c_dev->reg_shift));
198} 199}
199 200
200static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) 201static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev)
@@ -924,6 +925,11 @@ omap_i2c_probe(struct platform_device *pdev)
924 dev->b_hw = 1; /* Enable hardware fixes */ 925 dev->b_hw = 1; /* Enable hardware fixes */
925 } 926 }
926 927
928 if (cpu_is_omap7xx())
929 dev->reg_shift = 1;
930 else
931 dev->reg_shift = 2;
932
927 /* reset ASAP, clearing any IRQs */ 933 /* reset ASAP, clearing any IRQs */
928 omap_i2c_init(dev); 934 omap_i2c_init(dev);
929 935