aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/tps6586x.c50
-rw-r--r--include/linux/mfd/tps6586x.h7
2 files changed, 49 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;
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h
index 87994542573b..cbecec2e353a 100644
--- a/include/linux/mfd/tps6586x.h
+++ b/include/linux/mfd/tps6586x.h
@@ -13,6 +13,12 @@
13#define TPS6586X_SLEW_RATE_SET 0x08 13#define TPS6586X_SLEW_RATE_SET 0x08
14#define TPS6586X_SLEW_RATE_MASK 0x07 14#define TPS6586X_SLEW_RATE_MASK 0x07
15 15
16/* VERSION CRC */
17#define TPS658621A 0x15
18#define TPS658621CD 0x2c
19#define TPS658623 0x1b
20#define TPS658643 0x03
21
16enum { 22enum {
17 TPS6586X_ID_SYS, 23 TPS6586X_ID_SYS,
18 TPS6586X_ID_SM_0, 24 TPS6586X_ID_SM_0,
@@ -97,5 +103,6 @@ extern int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
97extern int tps6586x_update(struct device *dev, int reg, uint8_t val, 103extern int tps6586x_update(struct device *dev, int reg, uint8_t val,
98 uint8_t mask); 104 uint8_t mask);
99extern int tps6586x_irq_get_virq(struct device *dev, int irq); 105extern int tps6586x_irq_get_virq(struct device *dev, int irq);
106extern int tps6586x_get_version(struct device *dev);
100 107
101#endif /*__LINUX_MFD_TPS6586X_H */ 108#endif /*__LINUX_MFD_TPS6586X_H */