History

Merge tag 'for-3.6-rc6' of git://gitorious.org/linux-pwm/linux-pwm

Pull pwm fixes from Thierry Reding: "While this comes a bit later than I had wished, both patches are rather minor and touch only new drivers so I think these are still safe for merging." * tag 'for-3.6-rc6' of git://gitorious.org/linux-pwm/linux-pwm: pwm: pwm-tiehrpwm: Fix conflicting channel period setting pwm: pwm-tiecap: Disable APWM mode after configure

Linus Torvalds committed 14 years ago

Commit c500ce32 parents 76e77da 01b2d452 files · +36 −0Browse files

Unified · Split

2 files
  1. drivers/pwm/pwm-tiecap.c +7 −0
  2. drivers/pwm/pwm-tiehrpwm.c +29 −0
drivers/pwm/pwm-tiecap.c+7−0
@@ -100,6 +100,13 @@ static int ecap_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 99 unmodified lines
100100 writel(period_cycles, pc->mmio_base + CAP3);
101101 }
102102
103+ if (!test_bit(PWMF_ENABLED, &pwm->flags)) {
104+ reg_val = readw(pc->mmio_base + ECCTL2);
105+ /* Disable APWM mode to put APWM output Low */
106+ reg_val &= ~ECCTL2_APWM_MODE;
107+ writew(reg_val, pc->mmio_base + ECCTL2);
108+ }
109+
103110 pm_runtime_put_sync(pc->chip.dev);
104111 return 0;
105112 }
drivers/pwm/pwm-tiehrpwm.c+29−0
@@ -104,6 +104,7 @@ struct ehrpwm_pwm_chip { · 103 unmodified lines
104104 struct pwm_chip chip;
105105 unsigned int clk_rate;
106106 void __iomem *mmio_base;
107+ unsigned long period_cycles[NUM_PWM_CHANNEL];
107108 };
108109
109110 static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
@@ -210,6 +211,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 100 unmodified lines
210211 unsigned long long c;
211212 unsigned long period_cycles, duty_cycles;
212213 unsigned short ps_divval, tb_divval;
214+ int i;
213215
214216 if (period_ns < 0 || duty_ns < 0 || period_ns > NSEC_PER_SEC)
215217 return -ERANGE;
@@ -229,6 +231,28 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, · 13 unmodified lines
229231 duty_cycles = (unsigned long)c;
230232 }
231233
234+ /*
235+ * Period values should be same for multiple PWM channels as IP uses
236+ * same period register for multiple channels.
237+ */
238+ for (i = 0; i < NUM_PWM_CHANNEL; i++) {
239+ if (pc->period_cycles[i] &&
240+ (pc->period_cycles[i] != period_cycles)) {
241+ /*
242+ * Allow channel to reconfigure period if no other
243+ * channels being configured.
244+ */
245+ if (i == pwm->hwpwm)
246+ continue;
247+
248+ dev_err(chip->dev, "Period value conflicts with channel %d\n",
249+ i);
250+ return -EINVAL;
251+ }
252+ }
253+
254+ pc->period_cycles[pwm->hwpwm] = period_cycles;
255+
232256 /* Configure clock prescaler to support Low frequency PWM wave */
233257 if (set_prescale_div(period_cycles/PERIOD_MAX, &ps_divval,
234258 &tb_divval)) {
@@ -320,10 +344,15 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) · 85 unmodified lines
320344
321345 static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
322346 {
347+ struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
348+
323349 if (test_bit(PWMF_ENABLED, &pwm->flags)) {
324350 dev_warn(chip->dev, "Removing PWM device without disabling\n");
325351 pm_runtime_put_sync(chip->dev);
326352 }
353+
354+ /* set period value to zero on free */
355+ pc->period_cycles[pwm->hwpwm] = 0;
327356 }
328357
329358 static const struct pwm_ops ehrpwm_pwm_ops = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t