-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Robert Nelson <[email protected]>
- Loading branch information
1 parent
667e11d
commit 2543b5f
Showing
4 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
From e38d5cc4de7ed43d0964fa5eeb617874749e3137 Mon Sep 17 00:00:00 2001 | ||
From: efargas <[email protected]> | ||
Date: Tue, 15 Sep 2015 21:01:17 +0200 | ||
Subject: [PATCH 11/12] PWM period control | ||
|
||
Applied patch from https://github.com/avterekhov/bb-pwm/, tested and working on 3.8.13 branch | ||
--- | ||
drivers/pwm/pwm-tiehrpwm.c | 44 ++++++++++++++++++++++++++++++-------------- | ||
1 file changed, 30 insertions(+), 14 deletions(-) | ||
|
||
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c | ||
index af6f162..836592d 100644 | ||
--- a/drivers/pwm/pwm-tiehrpwm.c | ||
+++ b/drivers/pwm/pwm-tiehrpwm.c | ||
@@ -225,6 +225,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | ||
unsigned long period_cycles, duty_cycles; | ||
unsigned short ps_divval, tb_divval; | ||
int i, cmp_reg; | ||
+ struct pwm_device *pwm_alter; /* In case period changes */ | ||
|
||
if (period_ns > NSEC_PER_SEC) | ||
return -ERANGE; | ||
@@ -244,26 +245,41 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | ||
duty_cycles = (unsigned long)c; | ||
} | ||
|
||
+ | ||
/* | ||
* Period values should be same for multiple PWM channels as IP uses | ||
- * same period register for multiple channels. | ||
+ * same period register for multiple channels. Check if there is any with | ||
+ * a different period. | ||
*/ | ||
- for (i = 0; i < NUM_PWM_CHANNEL; i++) { | ||
- if (pc->period_cycles[i] && | ||
- (pc->period_cycles[i] != period_cycles)) { | ||
- /* | ||
- * Allow channel to reconfigure period if no other | ||
- * channels being configured. | ||
- */ | ||
- if (i == pwm->hwpwm) | ||
+ if (pc->period_cycles[pwm->hwpwm] != period_cycles) { | ||
+ for (i = 0; i < NUM_PWM_CHANNEL; i++) { | ||
+ if (pc->period_cycles[i]) { | ||
+ pwm_alter = &chip->pwms[i]; | ||
+ if (pwm_alter->duty > period_ns) { | ||
+ dev_err(chip->dev, "Duty is larger than period"); | ||
+ return -EINVAL; | ||
+ } | ||
+ } | ||
+ } | ||
+ if (!pc->period_cycles[pwm->hwpwm]) | ||
+ pc->period_cycles[pwm->hwpwm] = period_cycles; | ||
+ for (i = 0; i < NUM_PWM_CHANNEL; i++) { | ||
+ if (pc->period_cycles[i]) | ||
+ pc->period_cycles[i] = period_cycles; | ||
+ } | ||
+ for (i = 0; i < NUM_PWM_CHANNEL; i++) { | ||
+ if (i == pwm->hwpwm) /* No need to run for itself */ | ||
continue; | ||
- | ||
- dev_err(chip->dev, "Period value conflicts with channel %d\n", | ||
- i); | ||
- return -EINVAL; | ||
+ if (pc->period_cycles[i]) { | ||
+ pwm_alter = &chip->pwms[i]; | ||
+ if (ehrpwm_pwm_config(chip, pwm_alter, pwm_alter->duty, period_ns)) { | ||
+ dev_err(chip->dev, "Something went seriously wrong"); | ||
+ return -EINVAL; | ||
+ } | ||
+ pwm_alter->period = period_ns; | ||
+ } | ||
} | ||
} | ||
- | ||
pc->period_cycles[pwm->hwpwm] = period_cycles; | ||
|
||
/* Configure clock prescaler to support Low frequency PWM wave */ | ||
-- | ||
2.5.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From a0ed312190125d6d0594443ba028ae131e545481 Mon Sep 17 00:00:00 2001 | ||
From: efargas <[email protected]> | ||
Date: Tue, 15 Sep 2015 21:04:42 +0200 | ||
Subject: [PATCH 12/12] PWM period control | ||
|
||
Applied patch from https://github.com/avterekhov/bb-pwm/ testes and workin on 3.8.13 branch | ||
--- | ||
drivers/pwm/pwm_test.c | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/drivers/pwm/pwm_test.c b/drivers/pwm/pwm_test.c | ||
index 9c07880..7b50052 100644 | ||
--- a/drivers/pwm/pwm_test.c | ||
+++ b/drivers/pwm/pwm_test.c | ||
@@ -41,7 +41,7 @@ static ssize_t pwm_test_show_duty(struct device *dev, | ||
struct device_attribute *attr, char *buf) | ||
{ | ||
struct pwm_test *pwm_test = dev_get_drvdata(dev); | ||
- | ||
+ pwm_test->duty = pwm_test->pwm->duty; | ||
return sprintf(buf, "%d\n", pwm_test->duty); | ||
} | ||
|
||
@@ -65,7 +65,7 @@ static ssize_t pwm_test_store_duty(struct device *dev, | ||
return rc; | ||
} | ||
|
||
- pwm_test->duty = duty; | ||
+ pwm_test->duty = pwm_test->pwm->duty; | ||
|
||
return count; | ||
} | ||
@@ -74,7 +74,7 @@ static ssize_t pwm_test_show_period(struct device *dev, | ||
struct device_attribute *attr, char *buf) | ||
{ | ||
struct pwm_test *pwm_test = dev_get_drvdata(dev); | ||
- | ||
+ pwm_test->period = pwm_test->pwm->period; | ||
return sprintf(buf, "%d\n", pwm_test->period); | ||
} | ||
|
||
@@ -102,7 +102,7 @@ static ssize_t pwm_test_store_period(struct device *dev, | ||
return rc; | ||
} | ||
|
||
- pwm_test->period = period; | ||
+ pwm_test->period = pwm_test->pwm->period; | ||
|
||
return count; | ||
} | ||
-- | ||
2.5.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters