aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStefan Agner <stefan@agner.ch>2013-12-06 07:51:45 -0500
committerLee Jones <lee.jones@linaro.org>2014-01-21 03:28:01 -0500
commite0a3da80c65dc427c30829eb3e361507f843778f (patch)
tree433fe00ea3f9f7f7ad0887ba13067bc92620b052 /drivers
parentaf66b3c0934e350059646651958306565313e145 (diff)
mfd: tps6586x: Add version detection
Use the VERSIONCRC to determine the exact device version. According to the datasheet this register can be used as device identifier. The identification is needed since some tps6586x regulators use a different voltage table. Signed-off-by: Stefan Agner <stefan@agner.ch> Reviewed-by: Thierry Reding <treding@nvidia.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/tps6586x.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index d0e57934370f..bbd54414a75d 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -124,6 +124,7 @@ struct tps6586x {
124 struct device *dev; 124 struct device *dev;
125 struct i2c_client *client; 125 struct i2c_client *client;
126 struct regmap *regmap; 126 struct regmap *regmap;
127 int version;
127 128
128 int irq; 129 int irq;
129 struct irq_chip irq_chip; 130 struct irq_chip irq_chip;
@@ -208,6 +209,14 @@ int tps6586x_irq_get_virq(struct device *dev, int irq)
208} 209}
209EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq); 210EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq);
210 211
212int tps6586x_get_version(struct device *dev)
213{
214 struct tps6586x *tps6586x = dev_get_drvdata(dev);
215
216 return tps6586x->version;
217}
218EXPORT_SYMBOL_GPL(tps6586x_get_version);
219
211static int __remove_subdev(struct device *dev, void *unused) 220static int __remove_subdev(struct device *dev, void *unused)
212{ 221{
213 platform_device_unregister(to_platform_device(dev)); 222 platform_device_unregister(to_platform_device(dev));
@@ -472,12 +481,38 @@ static void tps6586x_power_off(void)
472 tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); 481 tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
473} 482}
474 483
484static void tps6586x_print_version(struct i2c_client *client, int version)
485{
486 const char *name;
487
488 switch (version) {
489 case TPS658621A:
490 name = "TPS658621A";
491 break;
492 case TPS658621CD:
493 name = "TPS658621C/D";
494 break;
495 case TPS658623:
496 name = "TPS658623";
497 break;
498 case TPS658643:
499 name = "TPS658643";
500 break;
501 default:
502 name = "TPS6586X";
503 break;
504 }
505
506 dev_info(&client->dev, "Found %s, VERSIONCRC is %02x\n", name, version);
507}
508
475static int tps6586x_i2c_probe(struct i2c_client *client, 509static int tps6586x_i2c_probe(struct i2c_client *client,
476 const struct i2c_device_id *id) 510 const struct i2c_device_id *id)
477{ 511{
478 struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev); 512 struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev);
479 struct tps6586x *tps6586x; 513 struct tps6586x *tps6586x;
480 int ret; 514 int ret;
515 int version;
481 516
482 if (!pdata && client->dev.of_node) 517 if (!pdata && client->dev.of_node)
483 pdata = tps6586x_parse_dt(client); 518 pdata = tps6586x_parse_dt(client);
@@ -487,19 +522,18 @@ static int tps6586x_i2c_probe(struct i2c_client *client,
487 return -ENOTSUPP; 522 return -ENOTSUPP;
488 } 523 }
489 524
490 ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); 525 version = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC);
491 if (ret < 0) { 526 if (version < 0) {
492 dev_err(&client->dev, "Chip ID read failed: %d\n", ret); 527 dev_err(&client->dev, "Chip ID read failed: %d\n", version);
493 return -EIO; 528 return -EIO;
494 } 529 }
495 530
496 dev_info(&client->dev, "VERSIONCRC is %02x\n", ret);
497
498 tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL); 531 tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
499 if (tps6586x == NULL) { 532 if (!tps6586x)
500 dev_err(&client->dev, "memory for tps6586x alloc failed\n");
501 return -ENOMEM; 533 return -ENOMEM;
502 } 534
535 tps6586x->version = version;
536 tps6586x_print_version(client, tps6586x->version);
503 537
504 tps6586x->client = client; 538 tps6586x->client = client;
505 tps6586x->dev = &client->dev; 539 tps6586x->dev = &client->dev;