Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Nelson <[email protected]>
  • Loading branch information
RobertCNelson committed Sep 15, 2015
1 parent 667e11d commit 2543b5f
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 2 deletions.
4 changes: 3 additions & 1 deletion patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -943,9 +943,11 @@ am33x_after () {
${git} "${DIR}/patches/fixes/0008-deb-pkg-sync-with-v3.14.patch"
${git} "${DIR}/patches/fixes/0009-Fix-for-a-part-of-video-got-flipped-from-bottom-to-t.patch"
${git} "${DIR}/patches/fixes/0010-modified-drivers-tty-serial-omap-serial.c-the-change.patch"
${git} "${DIR}/patches/fixes/0011-PWM-period-control.patch"
${git} "${DIR}/patches/fixes/0012-PWM-period-control.patch"

if [ "x${regenerate}" = "xenable" ] ; then
number=10
number=12
cleanup
fi

Expand Down
81 changes: 81 additions & 0 deletions patches/fixes/0011-PWM-period-control.patch
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

53 changes: 53 additions & 0 deletions patches/fixes/0012-PWM-period-control.patch
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

2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ toolchain="gcc_linaro_gnueabihf_4_7"
#Kernel/Build
KERNEL_REL=3.8
KERNEL_TAG=${KERNEL_REL}.13
BUILD=bone74
BUILD=bone74.1

#v3.X-rcX + upto SHA
#prev_KERNEL_SHA=""
Expand Down

0 comments on commit 2543b5f

Please sign in to comment.