aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-i2c.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-02-20 15:42:10 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-03-06 12:46:42 -0500
commit0f620837595145cd42be1c9dc6b619146fbeaf88 (patch)
treec8baef44fa4b407ef897ccd234b91f8d83ac85e3 /drivers/mfd/ab8500-i2c.c
parent6d95b7fdd0bd2e28ef651da6863d75edca4c2aca (diff)
mfd: Add ab8500 version detection and enforcing
There are currently four different versions of the AB8500 around: AB8500, AB8505, AB9540 and AB8540. Unfortunately: - Some of the chips (AB8500, AB8505, AB9540) cannot read the AB8500_REV_REG register but return errors - Some of them have the same ID value in the hardware register AB8500_REV_REV, for example the first versions of AB8505 and AB9540 have 0xFF in this register - just like the AB8500. So we need to be able to enforce a certain version from the platform. We do this by using the id of the platform device that provides the read/write functions. Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Maxime Coquelin <maxime.coquelin@stericsson.com> Signed-off-by: Alex Macro <alex.macro@stericsson.com> Signed-off-by: Michel Jaouen <michel.jaouen@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/ab8500-i2c.c')
-rw-r--r--drivers/mfd/ab8500-i2c.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/mfd/ab8500-i2c.c b/drivers/mfd/ab8500-i2c.c
index 087fecd71ce0..70a16ae856a2 100644
--- a/drivers/mfd/ab8500-i2c.c
+++ b/drivers/mfd/ab8500-i2c.c
@@ -38,6 +38,7 @@ static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr)
38 38
39static int __devinit ab8500_i2c_probe(struct platform_device *plf) 39static int __devinit ab8500_i2c_probe(struct platform_device *plf)
40{ 40{
41 const struct platform_device_id *platid = platform_get_device_id(plf);
41 struct ab8500 *ab8500; 42 struct ab8500 *ab8500;
42 struct resource *resource; 43 struct resource *resource;
43 int ret; 44 int ret;
@@ -61,10 +62,11 @@ static int __devinit ab8500_i2c_probe(struct platform_device *plf)
61 62
62 platform_set_drvdata(plf, ab8500); 63 platform_set_drvdata(plf, ab8500);
63 64
64 ret = ab8500_init(ab8500); 65 ret = ab8500_init(ab8500, platid->driver_data);
65 if (ret) 66 if (ret)
66 kfree(ab8500); 67 kfree(ab8500);
67 68
69
68 return ret; 70 return ret;
69} 71}
70 72
@@ -78,13 +80,22 @@ static int __devexit ab8500_i2c_remove(struct platform_device *plf)
78 return 0; 80 return 0;
79} 81}
80 82
83static const struct platform_device_id ab8500_id[] = {
84 { "ab8500-i2c", AB8500_VERSION_AB8500 },
85 { "ab8505-i2c", AB8500_VERSION_AB8505 },
86 { "ab9540-i2c", AB8500_VERSION_AB9540 },
87 { "ab8540-i2c", AB8500_VERSION_AB8540 },
88 { }
89};
90
81static struct platform_driver ab8500_i2c_driver = { 91static struct platform_driver ab8500_i2c_driver = {
82 .driver = { 92 .driver = {
83 .name = "ab8500-i2c", 93 .name = "ab8500-i2c",
84 .owner = THIS_MODULE, 94 .owner = THIS_MODULE,
85 }, 95 },
86 .probe = ab8500_i2c_probe, 96 .probe = ab8500_i2c_probe,
87 .remove = __devexit_p(ab8500_i2c_remove) 97 .remove = __devexit_p(ab8500_i2c_remove),
98 .id_table = ab8500_id,
88}; 99};
89 100
90static int __init ab8500_i2c_init(void) 101static int __init ab8500_i2c_init(void)