summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2016-08-16 10:35:06 +0100
committerThierry Reding <thierry.reding@gmail.com>2016-09-08 10:55:11 +0200
commit85a834c42a491deed9ac5bca549b93b7a5455d84 (patch)
tree284fe84bd46ad1f5035d6f63862fb8c09af7f2ba /drivers/pwm
parentc97267ae831da2711e9592398d490dbd1f4d5ddd (diff)
downloadlinux-85a834c42a491deed9ac5bca549b93b7a5455d84.tar.gz
linux-85a834c42a491deed9ac5bca549b93b7a5455d84.tar.bz2
linux-85a834c42a491deed9ac5bca549b93b7a5455d84.zip
pwm: sti: It's now valid for number of PWM channels to be zero
Setting up the STI PWM IP as capture only, with zero PWM output devices is a perfectly valid configuration. It is no longer okay to assume that there must be at least 1 PWM output device. In this patch we make the default number of PWM output devices zero and only configure channels explicitly requested. Reported-by: Peter Griffin <peter.griffin@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-sti.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c
index 95014f57a9c6..9a1ca1986c30 100644
--- a/drivers/pwm/pwm-sti.c
+++ b/drivers/pwm/pwm-sti.c
@@ -483,6 +483,11 @@ static int sti_pwm_probe_dt(struct sti_pwm_chip *pc)
if (!ret)
cdata->cpt_num_devs = num_devs;
+ if (!cdata->pwm_num_devs && !cdata->cpt_num_devs) {
+ dev_err(dev, "No channels configured\n");
+ return -EINVAL;
+ }
+
reg_fields = cdata->reg_fields;
pc->prescale_low = devm_regmap_field_alloc(dev, pc->regmap,
@@ -573,7 +578,7 @@ static int sti_pwm_probe(struct platform_device *pdev)
cdata->reg_fields = &sti_pwm_regfields[0];
cdata->max_prescale = 0xff;
cdata->max_pwm_cnt = 255;
- cdata->pwm_num_devs = 1;
+ cdata->pwm_num_devs = 0;
cdata->cpt_num_devs = 0;
pc->cdata = cdata;
@@ -585,6 +590,9 @@ static int sti_pwm_probe(struct platform_device *pdev)
if (ret)
return ret;
+ if (!cdata->pwm_num_devs)
+ goto skip_pwm;
+
pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
if (IS_ERR(pc->pwm_clk)) {
dev_err(dev, "failed to get PWM clock\n");
@@ -597,6 +605,10 @@ static int sti_pwm_probe(struct platform_device *pdev)
return ret;
}
+skip_pwm:
+ if (!cdata->cpt_num_devs)
+ goto skip_cpt;
+
pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
if (IS_ERR(pc->cpt_clk)) {
dev_err(dev, "failed to get PWM capture clock\n");
@@ -609,6 +621,7 @@ static int sti_pwm_probe(struct platform_device *pdev)
return ret;
}
+skip_cpt:
pc->chip.dev = dev;
pc->chip.ops = &sti_pwm_ops;
pc->chip.base = -1;