Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751264AbdFAO5v (ORCPT ); Thu, 1 Jun 2017 10:57:51 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:41555 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbdFAO5t (ORCPT ); Thu, 1 Jun 2017 10:57:49 -0400 From: Gregory CLEMENT To: Richard Genoud Cc: Linus Walleij , Alexandre Courbot , Andrew Lunn , Jason Cooper , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, Mark Rutland , Ralph Sennhauser , Rob Herring , Russell King , Sebastian Hesselbarth , Thierry Reding Subject: Re: [PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used References: <20170601121826.14685-1-richard.genoud@gmail.com> <20170601121826.14685-3-richard.genoud@gmail.com> Date: Thu, 01 Jun 2017 16:57:47 +0200 In-Reply-To: <20170601121826.14685-3-richard.genoud@gmail.com> (Richard Genoud's message of "Thu, 1 Jun 2017 14:18:26 +0200") Message-ID: <87h8zzsql0.fsf@free-electrons.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1862 Lines: 59 Hi Richard, On jeu., juin 01 2017, Richard Genoud wrote: > 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 Reviewed-by: Gregory CLEMENT Thanks, Gregory > --- > 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); > -- Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com