diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-10-18 05:51:45 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-10-23 11:22:28 -0400 |
commit | e64c1eb47352d62f5bb06284bae72261d934faa8 (patch) | |
tree | ff3e5d2744fe0d783bb33d98a7c904fa44b14b7b | |
parent | b0e5992612a1079ddcc1810b786ab8ca438cddae (diff) |
mfd: tc3589x: Detect the precise version
Instead of detecting the "tc3589x" and hard-coding the number of
GPIO pins to 24, encode all the possible subtypes and set the
number of GPIO pins from the type.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/tc3589x.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 70f4909fee13..87ea51dc6234 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c | |||
@@ -16,6 +16,19 @@ | |||
16 | #include <linux/mfd/core.h> | 16 | #include <linux/mfd/core.h> |
17 | #include <linux/mfd/tc3589x.h> | 17 | #include <linux/mfd/tc3589x.h> |
18 | 18 | ||
19 | /** | ||
20 | * enum tc3589x_version - indicates the TC3589x version | ||
21 | */ | ||
22 | enum tc3589x_version { | ||
23 | TC3589X_TC35890, | ||
24 | TC3589X_TC35892, | ||
25 | TC3589X_TC35893, | ||
26 | TC3589X_TC35894, | ||
27 | TC3589X_TC35895, | ||
28 | TC3589X_TC35896, | ||
29 | TC3589X_UNKNOWN, | ||
30 | }; | ||
31 | |||
19 | #define TC3589x_CLKMODE_MODCTL_SLEEP 0x0 | 32 | #define TC3589x_CLKMODE_MODCTL_SLEEP 0x0 |
20 | #define TC3589x_CLKMODE_MODCTL_OPERATION (1 << 0) | 33 | #define TC3589x_CLKMODE_MODCTL_OPERATION (1 << 0) |
21 | 34 | ||
@@ -361,7 +374,21 @@ static int tc3589x_probe(struct i2c_client *i2c, | |||
361 | tc3589x->i2c = i2c; | 374 | tc3589x->i2c = i2c; |
362 | tc3589x->pdata = pdata; | 375 | tc3589x->pdata = pdata; |
363 | tc3589x->irq_base = pdata->irq_base; | 376 | tc3589x->irq_base = pdata->irq_base; |
364 | tc3589x->num_gpio = id->driver_data; | 377 | |
378 | switch (id->driver_data) { | ||
379 | case TC3589X_TC35893: | ||
380 | case TC3589X_TC35895: | ||
381 | case TC3589X_TC35896: | ||
382 | tc3589x->num_gpio = 20; | ||
383 | break; | ||
384 | case TC3589X_TC35890: | ||
385 | case TC3589X_TC35892: | ||
386 | case TC3589X_TC35894: | ||
387 | case TC3589X_UNKNOWN: | ||
388 | default: | ||
389 | tc3589x->num_gpio = 24; | ||
390 | break; | ||
391 | } | ||
365 | 392 | ||
366 | i2c_set_clientdata(i2c, tc3589x); | 393 | i2c_set_clientdata(i2c, tc3589x); |
367 | 394 | ||
@@ -432,7 +459,13 @@ static int tc3589x_resume(struct device *dev) | |||
432 | static SIMPLE_DEV_PM_OPS(tc3589x_dev_pm_ops, tc3589x_suspend, tc3589x_resume); | 459 | static SIMPLE_DEV_PM_OPS(tc3589x_dev_pm_ops, tc3589x_suspend, tc3589x_resume); |
433 | 460 | ||
434 | static const struct i2c_device_id tc3589x_id[] = { | 461 | static const struct i2c_device_id tc3589x_id[] = { |
435 | { "tc3589x", 24 }, | 462 | { "tc35890", TC3589X_TC35890 }, |
463 | { "tc35892", TC3589X_TC35892 }, | ||
464 | { "tc35893", TC3589X_TC35893 }, | ||
465 | { "tc35894", TC3589X_TC35894 }, | ||
466 | { "tc35895", TC3589X_TC35895 }, | ||
467 | { "tc35896", TC3589X_TC35896 }, | ||
468 | { "tc3589x", TC3589X_UNKNOWN }, | ||
436 | { } | 469 | { } |
437 | }; | 470 | }; |
438 | MODULE_DEVICE_TABLE(i2c, tc3589x_id); | 471 | MODULE_DEVICE_TABLE(i2c, tc3589x_id); |