Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drivers/gpio/gpio-pca953x.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <linux/of_platform.h>
#endif

#define CONFIG_OF_GPIO 1
#define CONFIG_GPIO_PCA953X_IRQ 1
#define CONFIG_ARM 1

#define PCA953X_INPUT 0
#define PCA953X_OUTPUT 1
#define PCA953X_INVERT 2
Expand Down
44 changes: 30 additions & 14 deletions drivers/pwm/pwm-tiehrpwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions drivers/pwm/pwm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down