Skip to contentSkip to conversation

pwm: tegra: Set maximum pwm clock source per SoC tapeout

PATCH In review Laxman Dewangan 3 participants 6 messages May 2, 2017 – Jun 13, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pwm: tegra: Set maximum pwm clock source per SoC tapeout

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

	Before Tegra186, it is 38.4MHz.
	In Tegra186, it is 102MHz.

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.
- Set the maximum frequency unconditionally as per V1 review comment.

---
 drivers/pwm/pwm-tegra.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/pwm/pwm-tegra.c +17 -1
index 8c6ed55..e9b33f0 100644
@@ -41,6 +41,9 @@
 
 struct tegra_pwm_soc {
 	unsigned int num_channels;
+
+	/* Maximum IP frequency for given SoCs */
+	unsigned long max_frequency;
 };
 
 struct tegra_pwm_chip {
@@ -201,7 +204,18 @@ static int tegra_pwm_probe(struct platform_device *pdev)
 	if (IS_ERR(pwm->clk))
 		return PTR_ERR(pwm->clk);
 
-	/* Read PWM clock rate from source */
+	/* Set maximum frequency of the IP */
+	ret = clk_set_rate(pwm->clk, pwm->soc->max_frequency);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret);
+		return ret;
+	}
+
+	/*
+	 * The requested and configured frequency may differ due to
+	 * clock register resolutions. Get the configured frequency
+	 * so that PWM period can be calculated more accurately.
+	 */
 	pwm->clk_rate = clk_get_rate(pwm->clk);
 
 	pwm->rst = devm_reset_control_get(&pdev->dev, "pwm");
@@ -273,10 +287,12 @@ static int tegra_pwm_resume(struct device *dev)
 
 static const struct tegra_pwm_soc tegra20_pwm_soc = {
 	.num_channels = 4,
+	.max_frequency = 48000000UL,
 };
 
 static const struct tegra_pwm_soc tegra186_pwm_soc = {
 	.num_channels = 1,
+	.max_frequency = 102000000UL,
 };
 
 static const struct of_device_id tegra_pwm_of_match[] = {
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 7 lines · Laxman Dewangan

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

	Before Tegra186, it is 38.4MHz.
	In Tegra186, it is 102MHz.
Quoted 8 lines

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.

I think that your changelog needs to be updated, because it still says 38.4MHz and not 48MHz.

Cheers
Jon

Signature · 1 line
nvpublic
#2 lore raw
Quoted 11 lines · Jon Hunter
Quoted 10 lines · Laxman Dewangan

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

	Before Tegra186, it is 38.4MHz.
	In Tegra186, it is 102MHz.

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

Quoted 8 lines
Quoted 5 lines

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.

I think that your changelog needs to be updated, because it still says 38.4MHz and not 48MHz.

Oops, thanks for pointing.

Thierry,
Do I need to recycle the patch or can be corrected when applying?
If there is any further review comment in code then I will recycle and correct it.

maintainer Acked-by
#3 lore raw
Quoted 22 lines · Laxman Dewangan
Quoted 11 lines · Jon Hunter
Quoted 10 lines · Laxman Dewangan

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

    Before Tegra186, it is 38.4MHz.
    In Tegra186, it is 102MHz.

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

Quoted 8 lines
Quoted 5 lines

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.

I think that your changelog needs to be updated, because it still says 38.4MHz and not 48MHz.

Quoted 6 lines

Oops, thanks for pointing.

Thierry,
Do I need to recycle the patch or can be corrected when applying? If there is any further review comment in code then I will recycle and correct it.

Feel free to add my ...

Cheers
Jon

Signature · 1 line
nvpublic
#4 lore raw
In reply to Laxman Dewangan
Quoted 22 lines · Laxman Dewangan
Quoted 11 lines · Jon Hunter
Quoted 10 lines · Laxman Dewangan

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

    Before Tegra186, it is 38.4MHz.
    In Tegra186, it is 102MHz.

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

Quoted 8 lines
Quoted 5 lines

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.

I think that your changelog needs to be updated, because it still says 38.4MHz and not 48MHz.

Quoted 5 lines

Oops, thanks for pointing.

Thierry,
Do I need to recycle the patch or can be corrected when applying?
If there is any further review comment in code then I will recycle and correct it.

Thierry,
Can you please review?

#5 lore raw
In reply to Laxman Dewangan
Quoted 12 lines · Laxman Dewangan

The PWM hardware IP is taped-out with different maximum frequency on different SoCs.

From HW team:

	Before Tegra186, it is 38.4MHz.
	In Tegra186, it is 102MHz.

Add support to limit the clock source frequency to the maximum IP supported frequency. Provide these values via SoC chipdata.

Quoted 7 lines

---
Changes from V1:
- Set the 48MHz maximum frequency for Tegra210 and earlier.
- Set the maximum frequency unconditionally as per V1 review comment.

---
 drivers/pwm/pwm-tegra.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Applied with a fixed up commit message and Jon's Acked-by.

Thanks,
Thierry