diff options
author | Ganesan Ramalingam <ganesanr@broadcom.com> | 2012-07-13 09:44:23 -0400 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-07-14 07:30:24 -0400 |
commit | 8bb986a816148d6e8fbaae23be0fee33d6a1ae3f (patch) | |
tree | 1b1bee995a60cc6be9d87ce9bbe711b26746cedf /drivers | |
parent | 9ae97a8996a6d6f66e2fbc221906e2406d6c261f (diff) |
i2c: i2c-ocores: Use reg-shift property
Deprecate 'regstep' property and use the standard 'reg-shift' property
for register offset shifts. 'regstep' will still be supported as an
optional property, but will give a warning when used.
Signed-off-by: Ganesan Ramalingam <ganesanr@broadcom.com>
Signed-off-by: Jayachandran C <jayachandranc@netlogicmicro.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/i2c-ocores.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index f6e7ad9f60e9..9e0709d5fb36 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -25,10 +25,11 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/of_i2c.h> | 27 | #include <linux/of_i2c.h> |
28 | #include <linux/log2.h> | ||
28 | 29 | ||
29 | struct ocores_i2c { | 30 | struct ocores_i2c { |
30 | void __iomem *base; | 31 | void __iomem *base; |
31 | int regstep; | 32 | u32 reg_shift; |
32 | wait_queue_head_t wait; | 33 | wait_queue_head_t wait; |
33 | struct i2c_adapter adap; | 34 | struct i2c_adapter adap; |
34 | struct i2c_msg *msg; | 35 | struct i2c_msg *msg; |
@@ -71,12 +72,12 @@ struct ocores_i2c { | |||
71 | 72 | ||
72 | static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) | 73 | static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) |
73 | { | 74 | { |
74 | iowrite8(value, i2c->base + reg * i2c->regstep); | 75 | iowrite8(value, i2c->base + (reg << i2c->reg_shift)); |
75 | } | 76 | } |
76 | 77 | ||
77 | static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) | 78 | static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) |
78 | { | 79 | { |
79 | return ioread8(i2c->base + reg * i2c->regstep); | 80 | return ioread8(i2c->base + (reg << i2c->reg_shift)); |
80 | } | 81 | } |
81 | 82 | ||
82 | static void ocores_process(struct ocores_i2c *i2c) | 83 | static void ocores_process(struct ocores_i2c *i2c) |
@@ -219,22 +220,29 @@ static struct i2c_adapter ocores_adapter = { | |||
219 | static int ocores_i2c_of_probe(struct platform_device *pdev, | 220 | static int ocores_i2c_of_probe(struct platform_device *pdev, |
220 | struct ocores_i2c *i2c) | 221 | struct ocores_i2c *i2c) |
221 | { | 222 | { |
222 | const __be32* val; | 223 | struct device_node *np = pdev->dev.of_node; |
223 | 224 | u32 val; | |
224 | val = of_get_property(pdev->dev.of_node, "regstep", NULL); | 225 | |
225 | if (!val) { | 226 | if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) { |
226 | dev_err(&pdev->dev, "Missing required parameter 'regstep'\n"); | 227 | /* no 'reg-shift', check for deprecated 'regstep' */ |
227 | return -ENODEV; | 228 | if (!of_property_read_u32(np, "regstep", &val)) { |
229 | if (!is_power_of_2(val)) { | ||
230 | dev_err(&pdev->dev, "invalid regstep %d\n", | ||
231 | val); | ||
232 | return -EINVAL; | ||
233 | } | ||
234 | i2c->reg_shift = ilog2(val); | ||
235 | dev_warn(&pdev->dev, | ||
236 | "regstep property deprecated, use reg-shift\n"); | ||
237 | } | ||
228 | } | 238 | } |
229 | i2c->regstep = be32_to_cpup(val); | ||
230 | 239 | ||
231 | val = of_get_property(pdev->dev.of_node, "clock-frequency", NULL); | 240 | if (of_property_read_u32(np, "clock-frequency", &val)) { |
232 | if (!val) { | ||
233 | dev_err(&pdev->dev, | 241 | dev_err(&pdev->dev, |
234 | "Missing required parameter 'clock-frequency'\n"); | 242 | "Missing required parameter 'clock-frequency'\n"); |
235 | return -ENODEV; | 243 | return -ENODEV; |
236 | } | 244 | } |
237 | i2c->clock_khz = be32_to_cpup(val) / 1000; | 245 | i2c->clock_khz = val / 1000; |
238 | 246 | ||
239 | return 0; | 247 | return 0; |
240 | } | 248 | } |
@@ -277,7 +285,7 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev) | |||
277 | 285 | ||
278 | pdata = pdev->dev.platform_data; | 286 | pdata = pdev->dev.platform_data; |
279 | if (pdata) { | 287 | if (pdata) { |
280 | i2c->regstep = pdata->regstep; | 288 | i2c->reg_shift = pdata->reg_shift; |
281 | i2c->clock_khz = pdata->clock_khz; | 289 | i2c->clock_khz = pdata->clock_khz; |
282 | } else { | 290 | } else { |
283 | ret = ocores_i2c_of_probe(pdev, i2c); | 291 | ret = ocores_i2c_of_probe(pdev, i2c); |