public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] regulator: palmas fix SMPS no voltages
@ 2013-02-23 16:35 Ian Lartey
  2013-02-23 16:35 ` [PATCH v2 2/2] mfd: palmas add variant and OTP detection Ian Lartey
  2013-03-01  7:42 ` [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Ian Lartey @ 2013-02-23 16:35 UTC (permalink / raw)
  To: linux-kernel, broonie, sameo
  Cc: ldewangan, lgirdwood, Graeme Gregory, Ian Lartey

From: Graeme Gregory <gg@slimlogic.co.uk>

Number of voltages for SMPS regulators was off by one.

Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Ian Lartey <ian@slimlogic.co.uk>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/regulator/palmas-regulator.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index cde13bb..39cf146 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -4,6 +4,7 @@
  * Copyright 2011-2012 Texas Instruments Inc.
  *
  * Author: Graeme Gregory <gg@slimlogic.co.uk>
+ * Author: Ian Lartey <ian@slimlogic.co.uk>
  *
  *  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
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] mfd: palmas add variant and OTP detection
  2013-02-23 16:35 [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Ian Lartey
@ 2013-02-23 16:35 ` Ian Lartey
  2013-02-26 13:53   ` Laxman Dewangan
  2013-03-01  7:42 ` [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Ian Lartey @ 2013-02-23 16:35 UTC (permalink / raw)
  To: linux-kernel, broonie, sameo
  Cc: ldewangan, lgirdwood, Graeme Gregory, Ian Lartey

From: Graeme Gregory <gg@slimlogic.co.uk>

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.

palmas register read/write/update API is now used

palmas_read_product_id_and_revs used by palmas_i2c_probe to get
the device id, design and software revisions

id field of pamas struct renamed to device_id

Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Ian Lartey <ian@slimlogic.co.uk>
---
 drivers/mfd/palmas.c       |   88 ++++++++++++++++++++++++++++++++++---------
 include/linux/mfd/palmas.h |   40 +++++++++++++++++++-
 2 files changed, 108 insertions(+), 20 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index bbdbc50..1a435f3 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -4,6 +4,7 @@
  * Copyright 2011-2012 Texas Instruments Inc.
  *
  * Author: Graeme Gregory <gg@slimlogic.co.uk>
+ * Author: Ian Lartey <ian@slimlogic.co.uk>
  *
  *  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
@@ -257,6 +258,56 @@ static struct regmap_irq_chip palmas_irq_chip = {
 			PALMAS_INT1_MASK),
 };
 
+static int palmas_read_product_id_and_revs(struct palmas *palmas)
+{
+	int ret;
+	unsigned int reg;
+
+	/* Read variant info from the device */
+	ret = palmas_read(palmas, PALMAS_ID_BASE, PALMAS_PRODUCT_ID_LSB, &reg);
+	if (ret < 0) {
+		dev_err(palmas->dev, "Unable to read ID err: %d\n", ret);
+		return ret;
+	}
+
+	palmas->product_id = reg;
+
+	ret = palmas_read(palmas, PALMAS_ID_BASE, PALMAS_PRODUCT_ID_MSB, &reg);
+	if (ret < 0) {
+		dev_err(palmas->dev, "Unable to read ID err: %d\n", ret);
+		return ret;
+	}
+
+	palmas->product_id |= reg << 8;
+
+	dev_info(palmas->dev, "Product ID %x\n", palmas->product_id);
+
+	ret = palmas_read(palmas, PALMAS_DESIGNREV_BASE,
+				PALMAS_DESIGNREV, &reg);
+	if (ret < 0) {
+		dev_err(palmas->dev, "Unable to read DESIGNREV err: %d\n", ret);
+		return ret;
+	}
+
+	palmas->designrev = reg & PALMAS_DESIGNREV_DESIGNREV_MASK;
+
+	dev_info(palmas->dev, "Product Design Rev %x\n", palmas->designrev);
+
+	ret = palmas_read(palmas, PALMAS_PMU_CONTROL_BASE, PALMAS_SW_REVISION,
+			&reg);
+	if (ret < 0) {
+		dev_err(palmas->dev, "Unable to read SW_REVISION err: %d\n",
+				ret);
+		return ret;
+	}
+
+	palmas->sw_revision = reg;
+
+	dev_info(palmas->dev, "Product SW Rev %x\n", palmas->sw_revision);
+
+	return 0;
+}
+
 static void palmas_dt_to_pdata(struct device_node *node,
 		struct palmas_platform_data *pdata)
 {
@@ -292,7 +343,7 @@ 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;
 	int slave;
 	struct mfd_cell *children;
 
@@ -316,7 +367,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, palmas);
 	palmas->dev = &i2c->dev;
-	palmas->id = id->driver_data;
+	palmas->product_id = id->driver_data;
 	palmas->irq = i2c->irq;
 
 	for (i = 0; i < PALMAS_NUM_CLIENTS; i++) {
@@ -344,12 +395,16 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 		}
 	}
 
+	/* Read variant info from the device */
+	ret = palmas_read_product_id_and_revs(palmas);
+	if (ret < 0)
+		goto err;
+
 	/* 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);
 	reg = PALMAS_INT_CTRL_INT_CLEAR;
 
-	regmap_write(palmas->regmap[slave], addr, reg);
+	ret = palmas_write(palmas, PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL, reg);
 
 	ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
 			IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip,
@@ -357,17 +412,15 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 	if (ret < 0)
 		goto err;
 
-	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
-	addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
-			PALMAS_PRIMARY_SECONDARY_PAD1);
-
 	if (pdata->mux_from_pdata) {
 		reg = pdata->pad1;
-		ret = regmap_write(palmas->regmap[slave], addr, reg);
+		ret = palmas_write(palmas, PALMAS_PU_PD_OD_BASE,
+				PALMAS_PRIMARY_SECONDARY_PAD1, reg);
 		if (ret)
 			goto err_irq;
 	} else {
-		ret = regmap_read(palmas->regmap[slave], addr, &reg);
+		ret = palmas_read(palmas, PALMAS_PU_PD_OD_BASE,
+				PALMAS_PRIMARY_SECONDARY_PAD1, &reg);
 		if (ret)
 			goto err_irq;
 	}
@@ -393,16 +446,15 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_3))
 		palmas->gpio_muxed |= PALMAS_GPIO_3_MUXED;
 
-	addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
-			PALMAS_PRIMARY_SECONDARY_PAD2);
-
 	if (pdata->mux_from_pdata) {
 		reg = pdata->pad2;
-		ret = regmap_write(palmas->regmap[slave], addr, reg);
+		ret = palmas_write(palmas, PALMAS_PU_PD_OD_BASE,
+				PALMAS_PRIMARY_SECONDARY_PAD2, reg);
 		if (ret)
 			goto err_irq;
 	} else {
-		ret = regmap_read(palmas->regmap[slave], addr, &reg);
+		ret = palmas_read(palmas, PALMAS_PU_PD_OD_BASE,
+				PALMAS_PRIMARY_SECONDARY_PAD2, &reg);
 		if (ret)
 			goto err_irq;
 	}
@@ -422,10 +474,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 
 	reg = pdata->power_ctrl;
 
-	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
-	addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_POWER_CTRL);
-
-	ret = regmap_write(palmas->regmap[slave], addr, reg);
+	ret = palmas_write(palmas, PALMAS_PU_PD_OD_BASE,
+			PALMAS_PRIMARY_SECONDARY_PAD2, reg);
 	if (ret)
 		goto err_irq;
 
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index a4d13d7..3129f9a 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -4,6 +4,7 @@
  * Copyright 2011 Texas Instruments Inc.
  *
  * Author: Graeme Gregory <gg@slimlogic.co.uk>
+ * Author: Ian Lartey <ian@slimlogic.co.uk>
  *
  *  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;
@@ -34,7 +39,9 @@ struct palmas {
 	struct regmap *regmap[PALMAS_NUM_CLIENTS];
 
 	/* Stored chip id */
-	int id;
+	int product_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
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] mfd: palmas add variant and OTP detection
  2013-02-23 16:35 ` [PATCH v2 2/2] mfd: palmas add variant and OTP detection Ian Lartey
@ 2013-02-26 13:53   ` Laxman Dewangan
  2013-03-01 23:42     ` Ian Lartey
  0 siblings, 1 reply; 5+ messages in thread
From: Laxman Dewangan @ 2013-02-26 13:53 UTC (permalink / raw)
  To: Ian Lartey
  Cc: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com,
	sameo@linux.intel.com, lgirdwood@gmail.com, Graeme Gregory

On Saturday 23 February 2013 10:05 PM, Ian Lartey wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> 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.

> +
>   	/* 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);
>   	reg = PALMAS_INT_CTRL_INT_CLEAR;
>   
> -	regmap_write(palmas->regmap[slave], addr, reg);
> +	ret = palmas_write(palmas, PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL, reg);
>   

I think this is unrelated change and can be on another patch.

>   	
> -	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
> -	addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
> -			PALMAS_PRIMARY_SECONDARY_PAD1);
> -
>   	if (pdata->mux_from_pdata) {
>   		reg = pdata->pad1;
> -		ret = regmap_write(palmas->regmap[slave], addr, reg);
> +		ret = palmas_write(palmas, PALMAS_PU_PD_OD_BASE,
> +				PALMAS_PRIMARY_SECONDARY_PAD1, reg);

Same, in another patch and elsewhere which was part of cleanups.


otherwise it looks good.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] regulator: palmas fix SMPS no voltages
  2013-02-23 16:35 [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Ian Lartey
  2013-02-23 16:35 ` [PATCH v2 2/2] mfd: palmas add variant and OTP detection Ian Lartey
@ 2013-03-01  7:42 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-03-01  7:42 UTC (permalink / raw)
  To: Ian Lartey; +Cc: linux-kernel, sameo, ldewangan, lgirdwood, Graeme Gregory

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

On Sat, Feb 23, 2013 at 04:35:40PM +0000, Ian Lartey wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
> 
> Number of voltages for SMPS regulators was off by one.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] mfd: palmas add variant and OTP detection
  2013-02-26 13:53   ` Laxman Dewangan
@ 2013-03-01 23:42     ` Ian Lartey
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lartey @ 2013-03-01 23:42 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com,
	sameo@linux.intel.com, lgirdwood@gmail.com, Graeme Gregory

On 26/02/13 13:53, Laxman Dewangan wrote:
> On Saturday 23 February 2013 10:05 PM, Ian Lartey wrote:
>> From: Graeme Gregory <gg@slimlogic.co.uk>
>>
>> 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.
>
>> +
>>       /* 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);
>>       reg = PALMAS_INT_CTRL_INT_CLEAR;
>> -    regmap_write(palmas->regmap[slave], addr, reg);
>> +    ret = palmas_write(palmas, PALMAS_INTERRUPT_BASE,
>> PALMAS_INT_CTRL, reg);
>
> I think this is unrelated change and can be on another patch.

This is the change  which you requested earlier "Can you please use the 
api palmas_* for reading register which I added recently."

>
>>
>> -    slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
>> -    addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
>> -            PALMAS_PRIMARY_SECONDARY_PAD1);
>> -
>>       if (pdata->mux_from_pdata) {
>>           reg = pdata->pad1;
>> -        ret = regmap_write(palmas->regmap[slave], addr, reg);
>> +        ret = palmas_write(palmas, PALMAS_PU_PD_OD_BASE,
>> +                PALMAS_PRIMARY_SECONDARY_PAD1, reg);
>
> Same, in another patch and elsewhere which was part of cleanups.

ditto.

>
>
> otherwise it looks good.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-01 23:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-23 16:35 [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Ian Lartey
2013-02-23 16:35 ` [PATCH v2 2/2] mfd: palmas add variant and OTP detection Ian Lartey
2013-02-26 13:53   ` Laxman Dewangan
2013-03-01 23:42     ` Ian Lartey
2013-03-01  7:42 ` [PATCH v2 1/2] regulator: palmas fix SMPS no voltages Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox