regulator: palmas fix SMPS no voltages
PATCH 1/2 regulator: palmas fix SMPS no voltages
From: Graeme Gregory <[email protected]>
Number of voltages for SMPS regulators was off by one.
--- drivers/regulator/palmas-regulator.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/regulator/palmas-regulator.c +2 -1
@@ -4,6 +4,7 @@* Copyright 2011-2012 Texas Instruments Inc. * * Author: Graeme Gregory <[email protected]> +* Author: Ian Lartey <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the
@@ -156,7 +157,7 @@ static const struct regs_info palmas_regs_info[] = {* * So they are basically (maxV-minV)/stepV */ -#define PALMAS_SMPS_NUM_VOLTAGES 116 +#define PALMAS_SMPS_NUM_VOLTAGES 117#define PALMAS_SMPS10_NUM_VOLTAGES 2#define PALMAS_LDO_NUM_VOLTAGES 50
Signature · 1 line
1.7.0.4
PATCH 2/2 mfd: palmas add variant and OTP detection
From: Graeme Gregory <[email protected]>
Read the chip varient and the OTP information from the chip and display this on probe to aid in debugging of issues.
Older palmas chips do not have the USB_ID programmed and will therefore return 0x0000 for this field.
--- drivers/mfd/palmas.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-)
drivers/mfd/palmas.c +49 -0
@@ -4,6 +4,7 @@* Copyright 2011-2012 Texas Instruments Inc. * * Author: Graeme Gregory <[email protected]> +* Author: Ian Lartey <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the
@@ -344,6 +345,54 @@ static int palmas_i2c_probe(struct i2c_client *i2c, } } +/* Read varient info from the device */ + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_LSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } + + palmas->id = reg; + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_MSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } + + palmas->id |= reg <<8 ; + +dev_info (palmas->dev,"Product ID %x\n" , palmas->id); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_DESIGNREV_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_DESIGNREV_BASE ,PALMAS_DESIGNREV ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read DESIGNREV err: %d\n" , ret); + goto err; + } + + palmas->designrev = reg &PALMAS_DESIGNREV_DESIGNREV_MASK ; + +dev_info (palmas->dev,"Product Design Rev %x\n" , palmas->designrev); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_PMU_CONTROL_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_PMU_CONTROL_BASE ,PALMAS_SW_REVISION ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read SW_REVISION err: %d\n" , + ret); + goto err; + } + + palmas->sw_revision = reg; + +dev_info (palmas->dev,"Product SW Rev %x\n" , palmas->sw_revision); +/* Change IRQ into clear on read mode for efficiency */ slave =PALMAS_BASE_TO_SLAVE (PALMAS_INTERRUPT_BASE ); addr =PALMAS_BASE_TO_REG (PALMAS_INTERRUPT_BASE ,PALMAS_INT_CTRL );
include/linux/mfd/palmas.h +38 -0
@@ -4,6 +4,7 @@* Copyright 2011 Texas Instruments Inc. * * Author: Graeme Gregory <[email protected]> +* Author: Ian Lartey <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the
@@ -22,6 +23,10 @@#define PALMAS_NUM_CLIENTS 3 +/* The ID_REVISION NUMBERS */ +#define PALMAS_CHIP_OLD_ID 0x0000 +#define PALMAS_CHIP_ID 0xC035 +struct palmas_pmic ;struct palmas_gpadc ;struct palmas_resource ;
@@ -35,6 +40,8 @@ struct palmas {/* Stored chip id */ int id; +int designrev; +int sw_revision;/* IRQ Data */ int irq;
@@ -427,11 +434,13 @@ enum usb_irq_events {#define PALMAS_PU_PD_OD_BASE 0x1F4#define PALMAS_LED_BASE 0x200#define PALMAS_INTERRUPT_BASE 0x210 +#define PALMAS_ID_BASE 0x24F#define PALMAS_USB_OTG_BASE 0x250#define PALMAS_VIBRATOR_BASE 0x270#define PALMAS_GPIO_BASE 0x280#define PALMAS_USB_BASE 0x290#define PALMAS_GPADC_BASE 0x2C0 +#define PALMAS_DESIGNREV_BASE 0x357#define PALMAS_TRIM_GPADC_BASE 0x3CD/* Registers for function RTC */
@@ -2149,6 +2158,28 @@ enum usb_irq_events {#define PALMAS_INT_CTRL_INT_CLEAR 0x01#define PALMAS_INT_CTRL_INT_CLEAR_SHIFT 0 +/* Registers for function ID */ +#define PALMAS_VENDOR_ID_LSB 0x0 +#define PALMAS_VENDOR_ID_MSB 0x1 +#define PALMAS_PRODUCT_ID_LSB 0x2 +#define PALMAS_PRODUCT_ID_MSB 0x3 + +/* Bit definitions for VENDOR_ID_LSB */ +#define PALMAS_VENDOR_ID_LSB_VENDOR_ID_MASK 0xff +#define PALMAS_VENDOR_ID_LSB_VENDOR_ID_SHIFT 0 + +/* Bit definitions for VENDOR_ID_MSB */ +#define PALMAS_VENDOR_ID_MSB_VENDOR_ID_MASK 0xff +#define PALMAS_VENDOR_ID_MSB_VENDOR_ID_SHIFT 0 + +/* Bit definitions for PRODUCT_ID_LSB */ +#define PALMAS_PRODUCT_ID_LSB_PRODUCT_ID_MASK 0xff +#define PALMAS_PRODUCT_ID_LSB_PRODUCT_ID_SHIFT 0 + +/* Bit definitions for PRODUCT_ID_MSB */ +#define PALMAS_PRODUCT_ID_MSB_PRODUCT_ID_MASK 0xff +#define PALMAS_PRODUCT_ID_MSB_PRODUCT_ID_SHIFT 0 +/* Registers for function USB_OTG */ #define PALMAS_USB_WAKEUP 0x3#define PALMAS_USB_VBUS_CTRL_SET 0x4
@@ -2771,6 +2802,13 @@ enum usb_irq_events {#define PALMAS_GPADC_SMPS_VSEL_MONITORING_SMPS_VSEL_MONITORING_MASK 0x7f#define PALMAS_GPADC_SMPS_VSEL_MONITORING_SMPS_VSEL_MONITORING_SHIFT 0 +/* Registers for function DESIGNREV */ +#define PALMAS_DESIGNREV 0x0 + +/* Bit definitions for DESIGNREV */ +#define PALMAS_DESIGNREV_DESIGNREV_MASK 0x0f +#define PALMAS_DESIGNREV_DESIGNREV_SHIFT 0 +/* Registers for function GPADC */ #define PALMAS_GPADC_TRIM1 0x0#define PALMAS_GPADC_TRIM2 0x1
Signature · 1 line
1.7.0.4
Re: [PATCH 2/2] mfd: palmas add variant and OTP detection
Quoted 7 lines · Ian Lartey
From: Graeme Gregory <[email protected]>
Read the chip varient and the OTP information from the chip and display this on probe to aid in debugging of issues.
drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 356
Quoted 9 lines
drivers/mfd/palmas.c +9
-0+/* Read varient info from the device */ + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_LSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } +
Can you please use the api palmas_* for reading register which I added recently. This will reduce the calc of slave and addr and done in single call? Same of following code also.
Also can we move all these new code to one function where we read id and diaplay. To keep probe() smaller.
drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 367
Quoted 11 lines
drivers/mfd/palmas.c +11
-0+ palmas->id = reg; + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_MSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } + + palmas->id |= reg <<8 ;
Is it possible to change variable name id to product_id and then update to have more meaningful name? We can add for vendor_id also if require.
Quoted 18 lines
drivers/mfd/palmas.c +18
-0+ +dev_info (palmas->dev,"Product ID %x\n" , palmas->id); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_DESIGNREV_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_DESIGNREV_BASE ,PALMAS_DESIGNREV ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read DESIGNREV err: %d\n" , ret); + goto err; + } + + palmas->designrev = reg &PALMAS_DESIGNREV_DESIGNREV_MASK ; + +dev_info (palmas->dev,"Product Design Rev %x\n" , palmas->designrev); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_PMU_CONTROL_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_PMU_CONTROL_BASE ,PALMAS_SW_REVISION ); + ret =regmap_read (palmas->regmap[slave], addr, ®);
drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 395
Quoted 10 lines
drivers/mfd/palmas.c +10
-0+if (ret <0 ) { +dev_err (palmas->dev,"Unable to read SW_REVISION err: %d\n" , + ret); + goto err; + } + + palmas->sw_revision = reg; + +dev_info (palmas->dev,"Product SW Rev %x\n" , palmas->sw_revision); +
Here designrev also says the ES version and sw revision says the OTP SW revision.
TI has make the design revision as ES1.0, ES2.0, ES2.1, ES2.2 like this and other technical names are 0xA0, 0xB0, 0xB1, 0xB2 etc.
Probably I will add this in follow on patch becasue we have some errata which we need to implement based on the version number.
Re: [PATCH 2/2] mfd: palmas add variant and OTP detection
Quoted 17 lines · Laxman Dewangan
Quoted 6 lines · Ian Lartey
From: Graeme Gregory <[email protected]>
Read the chip varient and the OTP information from the chip and display this on probe to aid in debugging of issues.
drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 356
Quoted 9 lines
drivers/mfd/palmas.c +9
-0+/* Read varient info from the device */ + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_LSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } +
Quoted 4 lines
Can you please use the api palmas_* for reading register which I added recently. This will reduce the calc of slave and addr and done in single call?
Same of following code also.
Will do.
Quoted 4 lines
Also can we move all these new code to one function where we read id and diaplay. To keep
probe()smaller.
Yes, I'll do that too.
Quoted 17 lines
drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 367
Quoted 13 lines
drivers/mfd/palmas.c +11
-0+ palmas->id = reg; + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_ID_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_ID_BASE ,PALMAS_PRODUCT_ID_MSB ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read ID err: %d\n" , ret); + goto err; + } + + palmas->id |= reg <<8 ;Is it possible to change variable name id to
product_idand then update to have more meaningful name?
We can add forvendor_idalso if require.
The rename of id to product_id is fine, if this what you mean by
"update to have a more meaningful name" then I agree.
Though if you wish for a additional change, I am not sure what the additional change is.
Quoted 37 lines
Quoted 20 lines
drivers/mfd/palmas.c +17
-0+ +dev_info (palmas->dev,"Product ID %x\n" , palmas->id); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_DESIGNREV_BASE ); + addr =PALMAS_BASE_TO_REG (PALMAS_DESIGNREV_BASE ,PALMAS_DESIGNREV ); + ret =regmap_read (palmas->regmap[slave], addr, ®); +if (ret <0 ) { +dev_err (palmas->dev,"Unable to read DESIGNREV err: %d\n" , ret); + goto err; + } + + palmas->designrev = reg &PALMAS_DESIGNREV_DESIGNREV_MASK ; + +dev_info (palmas->dev,"Product Design Rev %x\n" , palmas->designrev); + + slave =PALMAS_BASE_TO_SLAVE (PALMAS_PMU_CONTROL_BASE ); + addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE,
PALMAS_SW_REVISION);drivers/mfd/palmas.c +1
-0+ ret =regmap_read (palmas->regmap[slave], addr, ®);drivers/mfd/palmas.c static int palmas_i2c_probe(struct i2c_client *i2c, · line 395
Quoted 10 lines
drivers/mfd/palmas.c +10
-0+if (ret <0 ) { +dev_err (palmas->dev,"Unable to read SW_REVISION err: %d\n" , + ret); + goto err; + } + + palmas->sw_revision = reg; + +dev_info (palmas->dev,"Product SW Rev %x\n" , palmas->sw_revision); +Here designrev also says the ES version and sw revision says the OTP SW revision.
TI has make the design revision as ES1.0, ES2.0, ES2.1, ES2.2 like this and other technical names are0xA0,0xB0,0xB1,0xB2etc.
Quoted 2 lines
Probably I will add this in follow on patch becasue we have some errata which we need to implement based on the version number.
OK, I'll not make this change in favour of your later patch.
Quoted 9 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 23 lines · Ian Lartey
From: Graeme Gregory <[email protected]>
Number of voltages for SMPS regulators was off by one.
Signed-off-by Graeme Gregory <[email protected]>Signed-off-by Ian Lartey <[email protected]>--- drivers/regulator/palmas-regulator.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/regulator/palmas-regulator.c +1
-0@@ -4,6 +4,7 @@* Copyright 2011-2012 Texas Instruments Inc. * * Author: Graeme Gregory <[email protected]> +* Author: Ian Lartey <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the
drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = { · line 160
Quoted 5 lines
drivers/regulator/palmas-regulator.c +1
-1@@ -156,7 +157,7 @@ static const struct regs_info palmas_regs_info[] = {* * So they are basically (maxV-minV)/stepV */ -#define PALMAS_SMPS_NUM_VOLTAGES 116 +#define PALMAS_SMPS_NUM_VOLTAGES 117
Yes, if we keep one for 0.5V and one for 1.65 the it becomes 117 including off.