Skip to contentSkip to conversation

mfd: arizona: Factor out SYSCLK enable from wm5102 hardware patch

PATCH Superseded Charles Keepax 3 participants 12 messages Mar 17, 2015 – Mar 23, 2015

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 mfd: arizona: Factor out SYSCLK enable from wm5102 hardware patch

wm5102 applies a custom hardware boot sequence, for this the SYSCLK needs to be enabled. This patch factors out the code that enables SYSCLK for this sequence such that it can be used for other boot time operations that require SYSCLK.

---

Changes since v1:
- Added some comments in patch 4 to explain the exact regulator voltage ranges
- Removed the reset patch, whilst I work on the suggestions by Mark, the rest of the series is useful in its own right and doesn't need to be blocked by that

Thanks,
Charles

 drivers/mfd/arizona-core.c |   48 ++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 17 deletions(-)
drivers/mfd/arizona-core.c +31 -17
index 6ca6dfa..ef1f8aa 100644
@@ -250,7 +250,8 @@ static int arizona_wait_for_boot(struct arizona *arizona)
 	return ret;
 }
 
-static int arizona_apply_hardware_patch(struct arizona* arizona)
+static int arizona_exec_with_sysclk(struct arizona *arizona,
+				    int (*exec)(struct arizona *))
 {
 	unsigned int fll, sysclk;
 	int ret, err;
@@ -292,23 +293,8 @@ static int arizona_apply_hardware_patch(struct arizona* arizona)
 		goto err_fll;
 	}
 
-	/* Start the write sequencer and wait for it to finish */
-	ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
-			ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160);
-	if (ret != 0) {
-		dev_err(arizona->dev, "Failed to start write sequencer: %d\n",
-			ret);
-		goto err_sysclk;
-	}
-	ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1,
-			       ARIZONA_WSEQ_BUSY, 0);
-	if (ret != 0) {
-		regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
-				ARIZONA_WSEQ_ABORT);
-		ret = -ETIMEDOUT;
-	}
+	ret = exec(arizona);
 
-err_sysclk:
 	err = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, sysclk);
 	if (err != 0) {
 		dev_err(arizona->dev,
@@ -330,6 +316,34 @@ err_fll:
 		return err;
 }
 
+static int arizona_hardware_patch_wseq(struct arizona *arizona)
+{
+	int ret;
+
+	/* Start the write sequencer and wait for it to finish */
+	ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
+			ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160);
+	if (ret != 0) {
+		dev_err(arizona->dev, "Failed to start write sequencer: %d\n",
+			ret);
+		return ret;
+	}
+	ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1,
+			       ARIZONA_WSEQ_BUSY, 0);
+	if (ret != 0) {
+		regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
+				ARIZONA_WSEQ_ABORT);
+		ret = -ETIMEDOUT;
+	}
+
+	return ret;
+}
+
+static inline int arizona_apply_hardware_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);
+}
+
 #ifdef CONFIG_PM
 static int arizona_runtime_resume(struct device *dev)
 {
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH v2 2/4 mfd: wm5110: Add register patch required for low power sleep

Some register settings must be applied before the first time low power sleep mode is entered on the wm5110 to ensure optimium performance. These settings require SYSCLK to be enabled whilst they are being applied. This patch applies the settings using the recently factored out boot time SYSCLK functionality.

---
 drivers/mfd/arizona-core.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +29 -0
index ef1f8aa..8f61ccf 100644
@@ -344,6 +344,25 @@ static inline int arizona_apply_hardware_patch(struct arizona *arizona)
 	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);
 }
 
+static const struct reg_default wm5110_sleep_patch[] = {
+	{ 0x337A, 0xC100 },
+	{ 0x337B, 0x0041 },
+	{ 0x3300, 0xA210 },
+	{ 0x3301, 0x050C },
+};
+
+static inline int wm5110_sleep_patch_wseq(struct arizona *arizona)
+{
+	return regmap_multi_reg_write_bypassed(arizona->regmap,
+					       wm5110_sleep_patch,
+					       ARRAY_SIZE(wm5110_sleep_patch));
+}
+
+static inline int wm5110_apply_sleep_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, wm5110_sleep_patch_wseq);
+}
+
 #ifdef CONFIG_PM
 static int arizona_runtime_resume(struct device *dev)
 {
@@ -913,6 +932,16 @@ int arizona_dev_init(struct arizona *arizona)
 				goto err_reset;
 			}
 			break;
+		case WM5110:
+		case WM8280:
+			ret = wm5110_apply_sleep_patch(arizona);
+			if (ret != 0) {
+				dev_err(arizona->dev,
+					"Failed to apply sleep patch: %d\n",
+					ret);
+				goto err_reset;
+			}
+			break;
 		default:
 			break;
 		}
Signature · 1 line
1.7.2.5
#2 lore raw

Re: [PATCH v2 2/4] mfd: wm5110: Add register patch required for low power sleep

Quoted 16 lines · Charles Keepax

Some register settings must be applied before the first time low power sleep mode is entered on the wm5110 to ensure optimium performance. These settings require SYSCLK to be enabled whilst they are being applied. This patch applies the settings using the recently factored out boot time SYSCLK functionality.

---
 drivers/mfd/arizona-core.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +0 -0
index ef1f8aa..8f61ccf 100644

drivers/mfd/arizona-core.c static inline int arizona_apply_hardware_patch(struct arizona *arizona) · line 352

Quoted 9 lines
drivers/mfd/arizona-core.c +6 -0
@@ -344,6 +344,25 @@ static inline int arizona_apply_hardware_patch(struct arizona *arizona)
 	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);
 }
 
+static const struct reg_default wm5110_sleep_patch[] = {
+	{ 0x337A, 0xC100 },
+	{ 0x337B, 0x0041 },
+	{ 0x3300, 0xA210 },
+	{ 0x3301, 0x050C },
+};

Really not keen on all these magic numbers.

Would you be kind enough to define them please?

drivers/mfd/arizona-core.c static inline int arizona_apply_hardware_patch(struct arizona *arizona) · line 354

Quoted 1 line
drivers/mfd/arizona-core.c +1 -0
+static inline int wm5110_sleep_patch_wseq(struct arizona *arizona)

What is 'wseq'?

I suggest if I'm having to ask that it's not a very good name.

Quoted 15 lines
drivers/mfd/arizona-core.c +11 -0
+{
+	return regmap_multi_reg_write_bypassed(arizona->regmap,
+					       wm5110_sleep_patch,
+					       ARRAY_SIZE(wm5110_sleep_patch));
+}
+
+static inline int wm5110_apply_sleep_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, wm5110_sleep_patch_wseq);
+}
+
 #ifdef CONFIG_PM
 static int arizona_runtime_resume(struct device *dev)
 {

drivers/mfd/arizona-core.c int arizona_dev_init(struct arizona *arizona) · line 938

Quoted 7 lines
drivers/mfd/arizona-core.c +4 -0
@@ -913,6 +932,16 @@ int arizona_dev_init(struct arizona *arizona)
 				goto err_reset;
 			}
 			break;
+		case WM5110:
+		case WM8280:
+			ret = wm5110_apply_sleep_patch(arizona);
+			if (ret != 0) {

if (ret) {

Quoted 9 lines
drivers/mfd/arizona-core.c +6 -0
+				dev_err(arizona->dev,
+					"Failed to apply sleep patch: %d\n",
+					ret);
+				goto err_reset;
+			}
+			break;
 		default:
 			break;
 		}
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

Re: [PATCH v2 2/4] mfd: wm5110: Add register patch required for low power sleep

Quoted 30 lines · Lee Jones
Quoted 16 lines · Charles Keepax

Some register settings must be applied before the first time low power sleep mode is entered on the wm5110 to ensure optimium performance. These settings require SYSCLK to be enabled whilst they are being applied. This patch applies the settings using the recently factored out boot time SYSCLK functionality.

---
 drivers/mfd/arizona-core.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +0 -0
index ef1f8aa..8f61ccf 100644

drivers/mfd/arizona-core.c static inline int arizona_apply_hardware_patch(struct arizona *arizona) · line 352

Quoted 9 lines
drivers/mfd/arizona-core.c +6 -0
@@ -344,6 +344,25 @@ static inline int arizona_apply_hardware_patch(struct arizona *arizona)
 	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);
 }
 
+static const struct reg_default wm5110_sleep_patch[] = {
+	{ 0x337A, 0xC100 },
+	{ 0x337B, 0x0041 },
+	{ 0x3300, 0xA210 },
+	{ 0x3301, 0x050C },
+};

Really not keen on all these magic numbers.

Quoted 1 line

Would you be kind enough to define them please?

This is basically just a register patch, its only not included in the normal patch due to the constraint on SYSCLK being enabled. Its not very normal to add defines for register patch entries and often not really practical in terms of IP. I would prefer to leave this as is if possible, I am not sure the sort of naming I am going to put on it in terms of defines is likely to add much more clarity to the situation.

Quoted 6 lines

drivers/mfd/arizona-core.c static inline int arizona_apply_hardware_patch(struct arizona *arizona) · line 354

Quoted 2 lines
drivers/mfd/arizona-core.c +1 -0
+static inline int wm5110_sleep_patch_wseq(struct arizona *arizona)

What is 'wseq'?

I suggest if I'm having to ask that it's not a very good name.

Yeah good point I will update the name here.

Thanks,
Charles

#4 lore raw

Re: [PATCH v2 2/4] mfd: wm5110: Add register patch required for low power sleep

Quoted 33 lines · Charles Keepax
Quoted 30 lines · Lee Jones
Quoted 16 lines · Charles Keepax

Some register settings must be applied before the first time low power sleep mode is entered on the wm5110 to ensure optimium performance. These settings require SYSCLK to be enabled whilst they are being applied. This patch applies the settings using the recently factored out boot time SYSCLK functionality.

---
 drivers/mfd/arizona-core.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +0 -0
index ef1f8aa..8f61ccf 100644

drivers/mfd/arizona-core.c static inline int arizona_apply_hardware_patch(struct arizona *arizona) · line 352

Quoted 9 lines
drivers/mfd/arizona-core.c +6 -0
@@ -344,6 +344,25 @@ static inline int arizona_apply_hardware_patch(struct arizona *arizona)
 	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);
 }
 
+static const struct reg_default wm5110_sleep_patch[] = {
+	{ 0x337A, 0xC100 },
+	{ 0x337B, 0x0041 },
+	{ 0x3300, 0xA210 },
+	{ 0x3301, 0x050C },
+};

Really not keen on all these magic numbers.

Quoted 1 line

Would you be kind enough to define them please?

Quoted 7 lines

This is basically just a register patch, its only not included in the normal patch due to the constraint on SYSCLK being enabled. Its not very normal to add defines for register patch entries and often not really practical in terms of IP. I would prefer to leave this as is if possible, I am not sure the sort of naming I am going to put on it in terms of defines is likely to add much more clarity to the situation.

At least supply a nice descriptive comment then please.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

PATCH v2 3/4 regulator: arizona-ldo1: Add additional supported voltage

In reply to Charles Keepax

This patch adds support for the 1.175V mode on the LDO1 regulator on the wm5110. This is need as part of the low power sleep mode operation.

---
 drivers/regulator/arizona-ldo1.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/regulator/arizona-ldo1.c +15 -0
index 8169165..c9f6302 100644
@@ -178,6 +178,16 @@ static const struct regulator_init_data arizona_ldo1_default = {
 	.num_consumer_supplies = 1,
 };
 
+static const struct regulator_init_data arizona_ldo1_wm5110 = {
+	.constraints = {
+		.min_uV = 1175000,
+		.max_uV = 1200000,
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS |
+				  REGULATOR_CHANGE_VOLTAGE,
+	},
+	.num_consumer_supplies = 1,
+};
+
 static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
 				     struct regulator_config *config,
 				     const struct regulator_desc *desc)
@@ -243,6 +253,11 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 		desc = &arizona_ldo1_hc;
 		ldo1->init_data = arizona_ldo1_dvfs;
 		break;
+	case WM5110:
+	case WM8280:
+		desc = &arizona_ldo1;
+		ldo1->init_data = arizona_ldo1_wm5110;
+		break;
 	default:
 		desc = &arizona_ldo1;
 		ldo1->init_data = arizona_ldo1_default;
Signature · 1 line
1.7.2.5
#6 lore raw

PATCH v2 4/4 mfd: wm5110: Set DCVDD voltage to 1.175V before entering sleep mode

In reply to Charles Keepax

The low power sleep mode on wm5110 requires that the LDO1 regulator be set to 1.175V prior to entering sleep, then returned to 1.2V after exiting sleep mode. This patch apply these regulator settings.

---
 drivers/mfd/arizona-core.c |   52 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +52 -0
index 8f61ccf..d208c20 100644
@@ -407,6 +407,37 @@ static int arizona_runtime_resume(struct device *dev)
 			goto err;
 		}
 		break;
+	case WM5110:
+	case WM8280:
+		ret = arizona_wait_for_boot(arizona);
+		if (ret != 0)
+			goto err;
+
+		if (arizona->external_dcvdd) {
+			ret = regmap_update_bits(arizona->regmap,
+						 ARIZONA_ISOLATION_CONTROL,
+						 ARIZONA_ISOLATE_DCVDD1, 0);
+			if (ret != 0) {
+				dev_err(arizona->dev,
+					"Failed to connect DCVDD: %d\n", ret);
+				goto err;
+			}
+		} else {
+			/*
+			 * As this is only called for the internal regulator
+			 * (where we know voltage ranges available) it is ok
+			 * to request an exact range.
+			 */
+			ret = regulator_set_voltage(arizona->dcvdd,
+						    1200000, 1200000);
+			if (ret < 0) {
+				dev_err(arizona->dev,
+					"Failed to set resume voltage: %d\n",
+					ret);
+				goto err;
+			}
+		}
+		break;
 	default:
 		ret = arizona_wait_for_boot(arizona);
 		if (ret != 0) {
@@ -457,6 +488,27 @@ static int arizona_runtime_suspend(struct device *dev)
 				ret);
 			return ret;
 		}
+	} else {
+		switch (arizona->type) {
+		case WM5110:
+		case WM8280:
+			/*
+			 * As this is only called for the internal regulator
+			 * (where we know voltage ranges available) it is ok
+			 * to request an exact range.
+			 */
+			ret = regulator_set_voltage(arizona->dcvdd,
+						    1175000, 1175000);
+			if (ret < 0) {
+				dev_err(arizona->dev,
+					"Failed to set suspend voltage: %d\n",
+					ret);
+				return ret;
+			}
+			break;
+		default:
+			break;
+		}
 	}
 
 	regcache_cache_only(arizona->regmap, true);
Signature · 1 line
1.7.2.5
maintainer Acked-by on v2 4/4
#7 lore raw

Re: [PATCH v2 4/4] mfd: wm5110: Set DCVDD voltage to 1.175V before entering sleep mode

Quoted 3 lines · Charles Keepax

The low power sleep mode on wm5110 requires that the LDO1 regulator be set to 1.175V prior to entering sleep, then returned to 1.2V after exiting sleep mode. This patch apply these regulator settings.

#8 lore raw

Re: [PATCH v2 4/4] mfd: wm5110: Set DCVDD voltage to 1.175V before entering sleep mode

In reply to Charles Keepax
Quoted 14 lines · Charles Keepax

The low power sleep mode on wm5110 requires that the LDO1 regulator be set to 1.175V prior to entering sleep, then returned to 1.2V after exiting sleep mode. This patch apply these regulator settings.

---
 drivers/mfd/arizona-core.c |   52 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
drivers/mfd/arizona-core.c +0 -0
index 8f61ccf..d208c20 100644

drivers/mfd/arizona-core.c static int arizona_runtime_resume(struct device *dev) · line 413

Quoted 7 lines
drivers/mfd/arizona-core.c +4 -0
@@ -407,6 +407,37 @@ static int arizona_runtime_resume(struct device *dev)
 			goto err;
 		}
 		break;
+	case WM5110:
+	case WM8280:
+		ret = arizona_wait_for_boot(arizona);
+		if (ret != 0)

Nit: if (ret)

drivers/mfd/arizona-core.c static int arizona_runtime_resume(struct device *dev) · line 420

Quoted 7 lines
drivers/mfd/arizona-core.c +7 -0
+			goto err;
+
+		if (arizona->external_dcvdd) {
+			ret = regmap_update_bits(arizona->regmap,
+						 ARIZONA_ISOLATION_CONTROL,
+						 ARIZONA_ISOLATE_DCVDD1, 0);
+			if (ret != 0) {

Nit: And so on ...

Quoted 51 lines
drivers/mfd/arizona-core.c +41 -0
+				dev_err(arizona->dev,
+					"Failed to connect DCVDD: %d\n", ret);
+				goto err;
+			}
+		} else {
+			/*
+			 * As this is only called for the internal regulator
+			 * (where we know voltage ranges available) it is ok
+			 * to request an exact range.
+			 */
+			ret = regulator_set_voltage(arizona->dcvdd,
+						    1200000, 1200000);
+			if (ret < 0) {
+				dev_err(arizona->dev,
+					"Failed to set resume voltage: %d\n",
+					ret);
+				goto err;
+			}
+		}
+		break;
 	default:
 		ret = arizona_wait_for_boot(arizona);
 		if (ret != 0) {
@@ -457,6 +488,27 @@ static int arizona_runtime_suspend(struct device *dev)
 				ret);
 			return ret;
 		}
+	} else {
+		switch (arizona->type) {
+		case WM5110:
+		case WM8280:
+			/*
+			 * As this is only called for the internal regulator
+			 * (where we know voltage ranges available) it is ok
+			 * to request an exact range.
+			 */
+			ret = regulator_set_voltage(arizona->dcvdd,
+						    1175000, 1175000);
+			if (ret < 0) {
+				dev_err(arizona->dev,
+					"Failed to set suspend voltage: %d\n",
+					ret);
+				return ret;
+			}
+			break;
+		default:
+			break;
+		}
 	}
 
 	regcache_cache_only(arizona->regmap, true);
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw
In reply to Charles Keepax
Quoted 80 lines · Charles Keepax

wm5102 applies a custom hardware boot sequence, for this the SYSCLK needs to be enabled. This patch factors out the code that enables SYSCLK for this sequence such that it can be used for other boot time operations that require SYSCLK.

---

Changes since v1:
- Added some comments in patch 4 to explain the exact regulator voltage ranges
- Removed the reset patch, whilst I work on the suggestions by Mark, the rest of the series is useful in its own right and doesn't need to be blocked by that

Thanks,
Charles

 drivers/mfd/arizona-core.c |   48 ++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 17 deletions(-)
drivers/mfd/arizona-core.c +19 -17
index 6ca6dfa..ef1f8aa 100644
@@ -250,7 +250,8 @@ static int arizona_wait_for_boot(struct arizona *arizona)
 	return ret;
 }
 
-static int arizona_apply_hardware_patch(struct arizona* arizona)
+static int arizona_exec_with_sysclk(struct arizona *arizona,
+				    int (*exec)(struct arizona *))
 {
 	unsigned int fll, sysclk;
 	int ret, err;
@@ -292,23 +293,8 @@ static int arizona_apply_hardware_patch(struct arizona* arizona)
 		goto err_fll;
 	}
 
-	/* Start the write sequencer and wait for it to finish */
-	ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
-			ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160);
-	if (ret != 0) {
-		dev_err(arizona->dev, "Failed to start write sequencer: %d\n",
-			ret);
-		goto err_sysclk;
-	}
-	ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1,
-			       ARIZONA_WSEQ_BUSY, 0);
-	if (ret != 0) {
-		regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
-				ARIZONA_WSEQ_ABORT);
-		ret = -ETIMEDOUT;
-	}
+	ret = exec(arizona);
 
-err_sysclk:
 	err = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, sysclk);
 	if (err != 0) {
 		dev_err(arizona->dev,
@@ -330,6 +316,34 @@ err_fll:
 		return err;
 }
 
+static int arizona_hardware_patch_wseq(struct arizona *arizona)
+{
+	int ret;
+
+	/* Start the write sequencer and wait for it to finish */
+	ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
+			ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160);
+	if (ret != 0) {
+		dev_err(arizona->dev, "Failed to start write sequencer: %d\n",
+			ret);
+		return ret;
+	}
+	ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1,
+			       ARIZONA_WSEQ_BUSY, 0);
+	if (ret != 0) {
+		regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,

drivers/mfd/arizona-core.c err_fll: · line 344

Quoted 10 lines
drivers/mfd/arizona-core.c +10 -0
+				ARIZONA_WSEQ_ABORT);
+		ret = -ETIMEDOUT;
+	}
+
+	return ret;
+}
+
+static inline int arizona_apply_hardware_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);

Not sure I like this much.

What's the reason for over-complicating this? Can you just:

arizona_exec_with_sysclk(arizona);
arizona_hardware_patch_wseq(arizona);

... or if you need that call to be in the middle, split the calls up further.

Quoted 5 lines
drivers/mfd/arizona-core.c +2 -0
+}
+
 #ifdef CONFIG_PM
 static int arizona_runtime_resume(struct device *dev)
 {
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#10 lore raw
Quoted 9 lines · Lee Jones
Quoted 7 lines · Charles Keepax

wm5102 applies a custom hardware boot sequence, for this the SYSCLK needs to be enabled. This patch factors out the code that enables SYSCLK for this sequence such that it can be used for other boot time operations that require SYSCLK.

---

<snip>

Quoted 7 lines

drivers/mfd/arizona-core.c err_fll: · line 344

Quoted 4 lines
drivers/mfd/arizona-core.c +4 -0
+
+static inline int arizona_apply_hardware_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);

Not sure I like this much.

Quoted 8 lines

What's the reason for over-complicating this? Can you just:

arizona_exec_with_sysclk(arizona);
arizona_hardware_patch_wseq(arizona);

... or if you need that call to be in the middle, split the calls up further.

Yeah, it was just a handy way to store the state and keep the amount of code down. But I don't really have any problem with explicitly storing the state if you prefer that.

So would probably look something like:

struct sysclk_state;
int ret;

ret = arizona_force_sysclk(arizona, &sysclk_state);

if (ret) {
	//Handle error
}
ret = arizona_hardware_patch_wseq(arizona);
if (ret) {
	//Handle error
}
ret = arizona_restore_sysclk(arizona, &sysclk_state);
if (ret) {
	//Handle error
}

I will assume you want it updated to look like this so let me know if not.

Thanks,
Charles

#11 lore raw
Quoted 49 lines · Charles Keepax
Quoted 9 lines · Lee Jones
Quoted 7 lines · Charles Keepax

wm5102 applies a custom hardware boot sequence, for this the SYSCLK needs to be enabled. This patch factors out the code that enables SYSCLK for this sequence such that it can be used for other boot time operations that require SYSCLK.

---

<snip>

Quoted 7 lines

drivers/mfd/arizona-core.c err_fll: · line 344

Quoted 4 lines
drivers/mfd/arizona-core.c +4 -0
+
+static inline int arizona_apply_hardware_patch(struct arizona *arizona)
+{
+	return arizona_exec_with_sysclk(arizona, arizona_hardware_patch_wseq);

Not sure I like this much.

Quoted 8 lines

What's the reason for over-complicating this? Can you just:

arizona_exec_with_sysclk(arizona);
arizona_hardware_patch_wseq(arizona);

... or if you need that call to be in the middle, split the calls up further.

Yeah, it was just a handy way to store the state and keep the amount of code down. But I don't really have any problem with explicitly storing the state if you prefer that.

So would probably look something like:

struct sysclk_state;
int ret;

ret = arizona_force_sysclk(arizona, &sysclk_state);

if (ret) {
	//Handle error
}
ret = arizona_hardware_patch_wseq(arizona);
if (ret) {
	//Handle error
}
ret = arizona_restore_sysclk(arizona, &sysclk_state);
if (ret) {
	//Handle error
}
Quoted 2 lines

I will assume you want it updated to look like this so let me know if not.

Looks much cleaner/less hacky.

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