public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode
@ 2013-12-26 21:48 Andrew Bresticker
  2013-12-26 21:48 ` [PATCH 2/2] regulator: as3722: set enable time for SD0/1/6 Andrew Bresticker
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Bresticker @ 2013-12-26 21:48 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Samuel Ortiz, Lee Jones, linux-kernel,
	Andrew Bresticker, Vince Hsu

SD0 may operate in low-voltage mode, with a minimum of 0.41V
and a maximum of 1.5V.  This is indicated by bit 4 of FUSE7.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Signed-off-by: Vince Hsu <vinceh@nvidia.com>
---
 drivers/regulator/as3722-regulator.c | 30 ++++++++++++++++++++++++++----
 include/linux/mfd/as3722.h           |  4 ++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index 27fe63c..1e91761 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -99,7 +99,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
 		.sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK,
 		.control_reg = AS3722_SD0_CONTROL_REG,
 		.mode_mask = AS3722_SD0_MODE_FAST,
-		.n_voltages = AS3722_SD0_VSEL_MAX + 1,
 	},
 	{
 		.regulator_id = AS3722_REGULATOR_ID_SD1,
@@ -112,7 +111,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
 		.sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK,
 		.control_reg = AS3722_SD1_CONTROL_REG,
 		.mode_mask = AS3722_SD1_MODE_FAST,
-		.n_voltages = AS3722_SD0_VSEL_MAX + 1,
 	},
 	{
 		.regulator_id = AS3722_REGULATOR_ID_SD2,
@@ -181,7 +179,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
 		.sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK,
 		.control_reg = AS3722_SD6_CONTROL_REG,
 		.mode_mask = AS3722_SD6_MODE_FAST,
-		.n_voltages = AS3722_SD0_VSEL_MAX + 1,
 	},
 	{
 		.regulator_id = AS3722_REGULATOR_ID_LDO0,
@@ -595,6 +592,22 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
 	return as3722_update_bits(as3722, reg, mask, val);
 }
 
+static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs)
+{
+	int err;
+	unsigned val;
+
+	err = as3722_read(as3722_regs->as3722, AS3722_FUSE7_REG, &val);
+	if (err < 0) {
+		dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
+			AS3722_FUSE7_REG, err);
+		return false;
+	}
+	if (val & AS3722_FUSE7_SD0_LOW_VOLTAGE)
+		return true;
+	return false;
+}
+
 static const struct regulator_linear_range as3722_sd2345_ranges[] = {
 	REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
 	REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
@@ -820,7 +833,16 @@ static int as3722_regulator_probe(struct platform_device *pdev)
 				ops = &as3722_sd016_extcntrl_ops;
 			else
 				ops = &as3722_sd016_ops;
-			as3722_regs->desc[id].min_uV = 610000;
+			if (id == AS3722_REGULATOR_ID_SD0 &&
+			    as3722_sd0_is_low_voltage(as3722_regs)) {
+				as3722_regs->desc[id].n_voltages =
+					AS3722_SD0_VSEL_LOW_VOL_MAX + 1;
+				as3722_regs->desc[id].min_uV = 410000;
+			} else {
+				as3722_regs->desc[id].n_voltages =
+					AS3722_SD0_VSEL_MAX + 1,
+				as3722_regs->desc[id].min_uV = 610000;
+			}
 			as3722_regs->desc[id].uV_step = 10000;
 			as3722_regs->desc[id].linear_min_sel = 1;
 			break;
diff --git a/include/linux/mfd/as3722.h b/include/linux/mfd/as3722.h
index 16bf8a0..bb9616d 100644
--- a/include/linux/mfd/as3722.h
+++ b/include/linux/mfd/as3722.h
@@ -151,6 +151,7 @@
 #define AS3722_ASIC_ID1_REG				0x90
 #define AS3722_ASIC_ID2_REG				0x91
 #define AS3722_LOCK_REG					0x9E
+#define AS3722_FUSE7_REG				0xA7
 #define AS3722_MAX_REGISTER				0xF4
 
 #define AS3722_SD0_EXT_ENABLE_MASK			0x03
@@ -224,6 +225,7 @@
 #define AS3722_SD_VSEL_MASK				0x7F
 #define AS3722_SD0_VSEL_MIN				0x01
 #define AS3722_SD0_VSEL_MAX				0x5A
+#define AS3722_SD0_VSEL_LOW_VOL_MAX			0x6E
 #define AS3722_SD2_VSEL_MIN				0x01
 #define AS3722_SD2_VSEL_MAX				0x7F
 
@@ -341,6 +343,8 @@
 #define AS3722_EXT_CONTROL_ENABLE2			0x2
 #define AS3722_EXT_CONTROL_ENABLE3			0x3
 
+#define AS3722_FUSE7_SD0_LOW_VOLTAGE			BIT(4)
+
 /* Interrupt IDs */
 enum as3722_irq {
 	AS3722_IRQ_LID,
-- 
1.8.5.1


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

* [PATCH 2/2] regulator: as3722: set enable time for SD0/1/6
  2013-12-26 21:48 [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Andrew Bresticker
@ 2013-12-26 21:48 ` Andrew Bresticker
  2014-01-06 11:45 ` [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Lee Jones
  2014-01-06 18:09 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Bresticker @ 2013-12-26 21:48 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Samuel Ortiz, Lee Jones, linux-kernel, Vince Hsu,
	Andrew Bresticker

From: Vince Hsu <vinceh@nvidia.com>

Add an enable time of 600us for SD0/1/6 to ensure that we have
enough setup time for the power rail.

Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/regulator/as3722-regulator.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index 1e91761..8b17d78 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -845,6 +845,7 @@ static int as3722_regulator_probe(struct platform_device *pdev)
 			}
 			as3722_regs->desc[id].uV_step = 10000;
 			as3722_regs->desc[id].linear_min_sel = 1;
+			as3722_regs->desc[id].enable_time = 600;
 			break;
 		case AS3722_REGULATOR_ID_SD2:
 		case AS3722_REGULATOR_ID_SD3:
-- 
1.8.5.1


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

* Re: [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode
  2013-12-26 21:48 [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Andrew Bresticker
  2013-12-26 21:48 ` [PATCH 2/2] regulator: as3722: set enable time for SD0/1/6 Andrew Bresticker
@ 2014-01-06 11:45 ` Lee Jones
  2014-01-06 18:09 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2014-01-06 11:45 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: Mark Brown, Liam Girdwood, Samuel Ortiz, linux-kernel, Vince Hsu

On Thu, 26 Dec 2013, Andrew Bresticker wrote:

> SD0 may operate in low-voltage mode, with a minimum of 0.41V
> and a maximum of 1.5V.  This is indicated by bit 4 of FUSE7.
> 
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> Signed-off-by: Vince Hsu <vinceh@nvidia.com>
> ---
>  drivers/regulator/as3722-regulator.c | 30 ++++++++++++++++++++++++++----
>  include/linux/mfd/as3722.h           |  4 ++++
>  2 files changed, 30 insertions(+), 4 deletions(-)

For the MFD part:
  Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode
  2013-12-26 21:48 [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Andrew Bresticker
  2013-12-26 21:48 ` [PATCH 2/2] regulator: as3722: set enable time for SD0/1/6 Andrew Bresticker
  2014-01-06 11:45 ` [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Lee Jones
@ 2014-01-06 18:09 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-01-06 18:09 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: Liam Girdwood, Samuel Ortiz, Lee Jones, linux-kernel, Vince Hsu

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

On Thu, Dec 26, 2013 at 01:48:46PM -0800, Andrew Bresticker wrote:
> SD0 may operate in low-voltage mode, with a minimum of 0.41V
> and a maximum of 1.5V.  This is indicated by bit 4 of FUSE7.

Applied both, thanks.

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

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

end of thread, other threads:[~2014-01-06 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-26 21:48 [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Andrew Bresticker
2013-12-26 21:48 ` [PATCH 2/2] regulator: as3722: set enable time for SD0/1/6 Andrew Bresticker
2014-01-06 11:45 ` [PATCH 1/2] regulator: as3722: detect SD0 low-voltage mode Lee Jones
2014-01-06 18:09 ` Mark Brown

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