MFD: Palmas: Add TPS659038 PMIC to supported devices of Palmas
Subsystems (4)
cover MFD: Palmas: Add TPS659038 PMIC to supported devices of Palmas
The Patch series adds TPS659038 PMIC support in the palmas mfd/voltage driver. The TPS659038 has almost the same registers as of the earlier supported variants of PALMAS family such as the TWL6035.
The critical differences between TPS659038 and TWL6035 being:
1) TPS659038 has nothing related to battery charging and back up battery stuff.
2) TPS659038 does not have does not have SMPS10(Boost) step up convertor.
3) TPS659038 does not have Battery detection and anything related to battery.
4) SD card detection, Battery presence detection, Vibrator, USB OTG are missing when compared to TWL6035.
The patch series is based on the patch:
http://www.mail-archive.com/[email protected]/msg90598.html
J Keerthy (4):
MFD: Palmas: Add Interrupt feature
mfd: Palmas: Add TPS659038 PMIC support
MFD: Palmas: Add SMPS10_BOOST feature
regulator: Palmas: Add TPS659038 support
Documentation/devicetree/bindings/mfd/palmas.txt | 2 + .../devicetree/bindings/regulator/palmas-pmic.txt | 1 + drivers/mfd/palmas.c | 39 ++++++++++++++++---- drivers/regulator/palmas-regulator.c | 4 ++ include/linux/mfd/palmas.h | 18 +++++++++ 5 files changed, 57 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/4 MFD: Palmas: Add Interrupt feature
Palmas PMICs have an INT line. This line is one single Interrupt line to the application processor. The interrupt feature enables to selectively request irq for only those specific chips which have INT line connected to a valid IRQ line of the application processor.
--- drivers/mfd/palmas.c | 32 +++++++++++++++++++++++++------- include/linux/mfd/palmas.h | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-)
drivers/mfd/palmas.c +25 -7
@@ -231,6 +231,16 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,palmas_set_pdata_irq_flag (i2c, pdata); } +static unsigned int palmas_features =PALMAS_PMIC_FEATURE_INTERRUPT ; + +static const struct of_device_id of_palmas_match_tbl[] = { + { + .compatible ="ti,palmas" , + .data = &palmas_features, + }, + { }, +}; +static int palmas_i2c_probe (struct i2c_client *i2c,const struct i2c_device_id *id) {
@@ -238,8 +248,9 @@ static int palmas_i2c_probe(struct i2c_client *i2c,struct palmas_platform_data *pdata;struct device_node *node = i2c->dev.of_node;int ret =0 , i; -unsigned int reg, addr; +unsigned int reg, addr, *features;int slave; +const struct of_device_id *match; pdata =dev_get_platdata (&i2c->dev);
@@ -261,9 +272,17 @@ static int palmas_i2c_probe(struct i2c_client *i2c,i2c_set_clientdata (i2c, palmas); palmas->dev = &i2c->dev; - palmas->id = id->driver_data; palmas->irq = i2c->irq; + match =of_match_device (of_match_ptr (of_palmas_match_tbl), &i2c->dev); + +if (match) { + features = (unsigned int *)match->data; + palmas->features = *features; + }else { +return -ENODATA ; + } +for (i =0 ; i <PALMAS_NUM_CLIENTS ; i++) {if (i ==0 ) palmas->i2c_clients[i] = i2c;
@@ -290,6 +309,9 @@ static int palmas_i2c_probe(struct i2c_client *i2c, } } +if (!PALMAS_PMIC_HAS (palmas,INTERRUPT )) + goto no_int; +/* Change interrupt line output polarity */ if (pdata->irq_flags &IRQ_TYPE_LEVEL_HIGH ) reg =PALMAS_POLARITY_CTRL_INT_POLARITY ;
@@ -316,6 +338,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,if (ret <0 ) goto err; +no_int: slave =PALMAS_BASE_TO_SLAVE (PALMAS_PU_PD_OD_BASE ); addr =PALMAS_BASE_TO_REG (PALMAS_PU_PD_OD_BASE ,PALMAS_PRIMARY_SECONDARY_PAD1 );
@@ -427,11 +450,6 @@ static const struct i2c_device_id palmas_i2c_id[] = { };MODULE_DEVICE_TABLE (i2c, palmas_i2c_id); -static struct of_device_id of_palmas_match_tbl[] = { - { .compatible ="ti,palmas" , }, - {/* end */ } -}; -static struct i2c_driver palmas_i2c_driver = { .driver = { .name ="palmas" ,
include/linux/mfd/palmas.h +14 -0
@@ -32,6 +32,19 @@ ((a) == PALMAS_CHIP_ID))#define is_palmas_charger (a) ((a) == PALMAS_CHIP_CHARGER_ID) +/** +* DOC: Palmas PMIC feature types +* +* PALMAS_PMIC_FEATURE_INTERRUPT - used when the PMIC has Interrupt line going +* to an application processor. +* +* PALMAS_PMIC_HAS(b, f) - macro to check if a bandgap device is capable of a +* specific feature (above) or not. Return non-zero, if yes. +*/ +#define PALMAS_PMIC_FEATURE_INTERRUPT BIT(0) +#define PALMAS_PMIC_HAS (b, f) \ + ((b)->features & PALMAS_PMIC_FEATURE_ ## f) +struct palmas_pmic ;struct palmas_gpadc ;struct palmas_resource ;
@@ -46,6 +59,7 @@ struct palmas {/* Stored chip id */ int id; +unsigned int features;/* IRQ Data */ int irq;u32 irq_mask;
Signature · 1 line
1.7.5.4
Mark Brown
maintainerRe: [PATCH 1/4] MFD: Palmas: Add Interrupt feature
Quoted 5 lines · J Keerthy
Palmas PMICs have an INT line. This line is one single Interrupt line to the application processor. The interrupt feature enables to selectively request irq for only those specific chips which have INT line connected to a valid IRQ line of the application processor.
Does the support for the interrupt line need to be explicitly flagged like this or can the driver not simply support an interrupt line not being configured? That would also support cases where the hardware has an interrupt line but the system integrator has opeted not to connect it for some reason which seems generally more flexible than doing things on a chip ID basis.
Quoted 3 lines
+/**
+ * DOC: Palmas PMIC feature types
+ *
Is "DOC: " normal kerneldoc?
RE: [PATCH 1/4] MFD: Palmas: Add Interrupt feature
Hi Mark,
Thanks for the review.
Quoted 17 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Monday, June 17, 2013 9:46 PM
To: J, KEERTHY
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/4] MFD: Palmas: Add Interrupt featureQuoted 4 lines · J Keerthy
Palmas PMICs have an INT line. This line is one single Interrupt line to the application processor. The interrupt feature enables to selectively request irq for only those specific chips which have INT line connected to a valid IRQ line of the application processor.
Quoted 7 lines
Does the support for the interrupt line need to be explicitly flagged like this or can the driver not simply support an interrupt line not being configured? That would also support cases where the hardware has an interrupt line but the system integrator has opeted not to connect it for some reason which seems generally more flexible than doing things on a chip ID basis.
I understand your point. The IRQ is passed from device tree node. Say if the chip for some reason is not connected to any valid IRQ line the driver might end up requesting for a wrong IRQ line.
So should I be validating the irq entry populated from device tree?
Explicitly checking on chip ID helps to avoid wrongly populated Device tree data.
Quoted 5 lines
Quoted 3 lines
+/**
+ * DOC: Palmas PMIC feature types
+ *Is "DOC: " normal kerneldoc?
Normal kerneldoc I shall remove "DOC:"
Regards,
Keerthy
Mark Brown
maintainerRe: [PATCH 1/4] MFD: Palmas: Add Interrupt feature
Quoted 5 lines · KEERTHY
I understand your point. The IRQ is passed from device tree node. Say if the chip for some reason is not connected to any valid IRQ line the driver might end up requesting for a wrong IRQ line.
So should I be validating the irq entry populated from device tree?
Yes, you should be checking that there's actually an interrupt there - the number will be zero if there isn't.
Quoted 2 lines
Explicitly checking on chip ID helps to avoid wrongly populated Device tree data.
Right, but on the other hand it ought to be possible to handle chips that could but aren't configured to do interrupts and if the driver can do that then this becomes redundant.
RE: [PATCH 1/4] MFD: Palmas: Add Interrupt feature
Hi Mark,
Quoted 22 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Tuesday, June 18, 2013 2:28 PM
To: J, KEERTHY
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/4] MFD: Palmas: Add Interrupt featureQuoted 2 lines · KEERTHY
I understand your point. The IRQ is passed from device tree node. Say if the chip for some reason is not connected to any valid IRQ
line
Quoted 3 lines
the driver might end up requesting for a wrong IRQ line.
So should I be validating the irq entry populated from device tree?
Yes, you should be checking that there's actually an interrupt there - the number will be zero if there isn't.
Quoted 7 lines
Quoted 1 line
Explicitly checking on chip ID helps to avoid wrongly populated
Device
Quoted 1 line
tree data.
Right, but on the other hand it ought to be possible to handle chips that could but aren't configured to do interrupts and if the driver can do that then this becomes redundant.
I understood. I am now implementing this in the driver making use Of the of_parse_phandle and check if the interrupts property is Populated and only then request for irq else skip that. Hope this Approach is fine. I will send v2 in a while.
Regards,
Keerthy
PATCH 2/4 mfd: Palmas: Add TPS659038 PMIC support
In reply to J KeerthyThe Patch adds TPS659038 PMIC support in the palmas mfd driver. The TPS659038 has almost the same registers as of the earlier supported variants of PALMAS family such as the TWL6035.
The critical differences between TPS659038 and TWL6035 being:
1) TPS659038 has nothing related to battery charging and back up battery stuff.
2) TPS659038 does not have does not have SMPS10(Boost) step up convertor.
3) TPS659038 does not have Battery detection and anything related to battery.
4) SD card detection, Battery presence detection, Vibrator, USB OTG are missing when compared to TWL6035.
--- Documentation/devicetree/bindings/mfd/palmas.txt | 2 ++ drivers/mfd/palmas.c | 6 ++++++ 2 files changed, 8 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/palmas.txt +2 -0
@@ -5,6 +5,7 @@ twl6035 (palmas) twl6037 (palmas) tps65913 (palmas) tps65914 (palmas) +tps659038 Required properties: - compatible : Should be from the list
@@ -14,6 +15,7 @@ Required properties: ti,tps65913 ti,tps65914 ti,tps80036 + ti,tps659038 and also the generic series names ti,palmas - interrupt-controller : palmas has its own internal IRQs
drivers/mfd/palmas.c +6 -0
@@ -233,11 +233,17 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,static unsigned int palmas_features =PALMAS_PMIC_FEATURE_INTERRUPT ; +static unsigned int tps659038_features; +static const struct of_device_id of_palmas_match_tbl[] = { { .compatible ="ti,palmas" , .data = &palmas_features, }, + { + .compatible ="ti,tps659038" , + .data = &tps659038_features, + }, { }, };
Signature · 1 line
1.7.5.4
PATCH 3/4 MFD: Palmas: Add SMPS10_BOOST feature
In reply to J KeerthyThe SMPS10 regulator is not presesnt in all the variants of the PALMAS PMIC family. Hence adding a feature to distingush between them.
--- drivers/mfd/palmas.c | 3 ++- drivers/regulator/palmas-regulator.c | 3 +++ include/linux/mfd/palmas.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletions(-)
drivers/mfd/palmas.c +2 -1
@@ -231,7 +231,8 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,palmas_set_pdata_irq_flag (i2c, pdata); } -static unsigned int palmas_features =PALMAS_PMIC_FEATURE_INTERRUPT ; +static unsigned int palmas_features =PALMAS_PMIC_FEATURE_INTERRUPT | +PALMAS_PMIC_FEATURE_SMPS10_BOOST ;static unsigned int tps659038_features;
drivers/regulator/palmas-regulator.c +3 -0
@@ -838,6 +838,9 @@ static int palmas_regulators_probe(struct platform_device *pdev)continue ; ramp_delay_support = true;break ; +case PALMAS_REG_SMPS10 : +if (!PALMAS_PMIC_HAS (palmas,SMPS10_BOOST )) +continue ; }if ((id ==PALMAS_REG_SMPS6 ) || (id ==PALMAS_REG_SMPS8 ))
include/linux/mfd/palmas.h +4 -0
@@ -38,10 +38,14 @@* PALMAS_PMIC_FEATURE_INTERRUPT - used when the PMIC has Interrupt line going * to an application processor. * +* PALMAS_PMIC_FEATURE_SMPS10_BOOST - used when the PMIC provides SMPS10 boost +* voltage supply. +* * PALMAS_PMIC_HAS(b, f) - macro to check if a bandgap device is capable of a * specific feature (above) or not. Return non-zero, if yes. */ #define PALMAS_PMIC_FEATURE_INTERRUPT BIT(0) +#define PALMAS_PMIC_FEATURE_SMPS10_BOOST BIT(1)#define PALMAS_PMIC_HAS (b, f) \ ((b)->features & PALMAS_PMIC_FEATURE_ ## f)
Signature · 1 line
1.7.5.4
PATCH 4/4 regulator: Palmas: Add TPS659038 support
In reply to J Keerthy--- .../devicetree/bindings/regulator/palmas-pmic.txt | 1 + drivers/regulator/palmas-regulator.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/regulator/palmas-pmic.txt +1 -0
@@ -7,6 +7,7 @@ Required properties: ti,twl6037-pmic ti,tps65913-pmic ti,tps65914-pmic + ti,tps659038-pmic and also the generic series names ti,palmas-pmic - interrupt-parent : The parent interrupt controller which is palmas.
drivers/regulator/palmas-regulator.c +1 -0
@@ -1054,6 +1054,7 @@ static struct of_device_id of_palmas_match_tbl[] = { { .compatible = "ti,tps65913-pmic", }, { .compatible = "ti,tps65914-pmic", }, { .compatible = "ti,tps80036-pmic", }, + { .compatible = "ti,tps659038-pmic", }, { /* end */ } };
Signature · 1 line
1.7.5.4