Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1655079

[PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used

From Richard Genoud <richard.genoud@gmail.com>
Newsgroups linux.kernel
Subject [PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used
Date 2017-06-01 14:20 +0200
Message-ID <tNxf3-2qB-13@gated-at.bofh.it> (permalink)
References <tNxf3-2qB-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If more than one gpio bank has the "pwm" property, only one will be
registered successfully, all the others will fail with:
mvebu-gpio: probe of f1018140.gpio failed with error -17

That's because in alloc_pwms(), the chip->base (aka "int pwm"), was not
set (thus, ==0) ; and 0 is a meaningful start value in alloc_pwm().
What was intended is mvpwm->chip->base = -1.
Like that, the numbering will be done auto-magically

Moreover, as the region might be already occupied by another pwm, we
shouldn't force:
mvpwm->chip->base = 0
nor
mvpwm->chip->base = id * MVEBU_MAX_GPIO_PER_BANK;

Tested on clearfog-pro (Marvell 88F6828)

Fixes: 757642f9a584 ("gpio: mvebu: Add limited PWM support")
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/gpio/gpio-mvebu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index cdef2c78cb3b..5104b6398139 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -768,6 +768,13 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
 	mvpwm->chip.dev = dev;
 	mvpwm->chip.ops = &mvebu_pwm_ops;
 	mvpwm->chip.npwm = mvchip->chip.ngpio;
+	/*
+	 * There may already be some PWM allocated, so we can't force
+	 * mvpwm->chip.base to a fixed point like mvchip->chip.base.
+	 * So, we let pwmchip_add() do the numbering and take the next free
+	 * region.
+	 */
+	mvpwm->chip.base = -1;
 
 	spin_lock_init(&mvpwm->lock);
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv2 0/2] gpio: mvebu: fixes for PWM/blink Richard Genoud <richard.genoud@gmail.com> - 2017-06-01 14:20 +0200
  [PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used Richard Genoud <richard.genoud@gmail.com> - 2017-06-01 14:20 +0200
    Re: [PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used Gregory CLEMENT <gregory.clement@free-electrons.com> - 2017-06-01 17:00 +0200
  [PATCHv2 1/2] gpio: mvebu: fix blink counter register selection Richard Genoud <richard.genoud@gmail.com> - 2017-06-01 14:20 +0200

csiph-web