Skip to content

Commit c014673

Browse files
systec-awelag-linaro
authored andcommitted
mfd: tps65086: Read DEVICE ID register 1 from device
This commit prepares a following commit for the regulator part of the MFD. The driver should support different device chips that differ in their register definitions, for instance to control LDOA1 and SWB2. So it is necessary to use a dedicated regulator description for a specific device variant. Thus, the content from DEVICEID Register 1 is used to choose a dedicated configuration between the different device variants. Signed-off-by: Andre Werner <andre.werner@systec-electronic.com> Link: https://lore.kernel.org/r/20230818083721.29790-2-andre.werner@systec-electronic.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 06c2afb commit c014673

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

drivers/mfd/tps65086.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,23 @@ static int tps65086_probe(struct i2c_client *client)
8181
return PTR_ERR(tps->regmap);
8282
}
8383

84-
ret = regmap_read(tps->regmap, TPS65086_DEVICEID, &version);
84+
/* Store device ID to load regulator configuration that fit to IC variant */
85+
ret = regmap_read(tps->regmap, TPS65086_DEVICEID1, &tps->chip_id);
8586
if (ret) {
86-
dev_err(tps->dev, "Failed to read revision register\n");
87+
dev_err(tps->dev, "Failed to read revision register 1\n");
88+
return ret;
89+
}
90+
91+
ret = regmap_read(tps->regmap, TPS65086_DEVICEID2, &version);
92+
if (ret) {
93+
dev_err(tps->dev, "Failed to read revision register 2\n");
8794
return ret;
8895
}
8996

9097
dev_info(tps->dev, "Device: TPS65086%01lX, OTP: %c, Rev: %ld\n",
91-
(version & TPS65086_DEVICEID_PART_MASK),
92-
(char)((version & TPS65086_DEVICEID_OTP_MASK) >> 4) + 'A',
93-
(version & TPS65086_DEVICEID_REV_MASK) >> 6);
98+
(version & TPS65086_DEVICEID2_PART_MASK),
99+
(char)((version & TPS65086_DEVICEID2_OTP_MASK) >> 4) + 'A',
100+
(version & TPS65086_DEVICEID2_REV_MASK) >> 6);
94101

95102
if (tps->irq > 0) {
96103
ret = regmap_add_irq_chip(tps->regmap, tps->irq, IRQF_ONESHOT, 0,

include/linux/mfd/tps65086.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <linux/regmap.h>
1414

1515
/* List of registers for TPS65086 */
16-
#define TPS65086_DEVICEID 0x01
17-
#define TPS65086_IRQ 0x02
16+
#define TPS65086_DEVICEID1 0x00
17+
#define TPS65086_DEVICEID2 0x01
18+
#define TPS65086_IRQ 0x02
1819
#define TPS65086_IRQ_MASK 0x03
1920
#define TPS65086_PMICSTAT 0x04
2021
#define TPS65086_SHUTDNSRC 0x05
@@ -75,10 +76,16 @@
7576
#define TPS65086_IRQ_SHUTDN_MASK BIT(3)
7677
#define TPS65086_IRQ_FAULT_MASK BIT(7)
7778

78-
/* DEVICEID Register field definitions */
79-
#define TPS65086_DEVICEID_PART_MASK GENMASK(3, 0)
80-
#define TPS65086_DEVICEID_OTP_MASK GENMASK(5, 4)
81-
#define TPS65086_DEVICEID_REV_MASK GENMASK(7, 6)
79+
/* DEVICEID1 Register field definitions */
80+
#define TPS6508640_ID 0x00
81+
#define TPS65086401_ID 0x01
82+
#define TPS6508641_ID 0x10
83+
#define TPS65086470_ID 0x70
84+
85+
/* DEVICEID2 Register field definitions */
86+
#define TPS65086_DEVICEID2_PART_MASK GENMASK(3, 0)
87+
#define TPS65086_DEVICEID2_OTP_MASK GENMASK(5, 4)
88+
#define TPS65086_DEVICEID2_REV_MASK GENMASK(7, 6)
8289

8390
/* VID Masks */
8491
#define BUCK_VID_MASK GENMASK(7, 1)
@@ -100,6 +107,7 @@ enum tps65086_irqs {
100107
struct tps65086 {
101108
struct device *dev;
102109
struct regmap *regmap;
110+
unsigned int chip_id;
103111

104112
/* IRQ Data */
105113
int irq;

0 commit comments

Comments
 (0)