From patchwork Thu Jun 1 12:18:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9759499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 488D760375 for ; Thu, 1 Jun 2017 12:19:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F5A726E98 for ; Thu, 1 Jun 2017 12:19:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23F8727FA6; Thu, 1 Jun 2017 12:19:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A93D626E98 for ; Thu, 1 Jun 2017 12:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wdvdY2bJzDyyi49yRMzOj5WlqXxcLbBk4kEN5T+FhFs=; b=rmjV9nlOlFABmTKnJLdUeGeTw9 kxwi4TuyUq6cNmjtFM9oZ/uIW/YSBI+iQ9gMJnqWqZtovYzbOp06xgBqdeiHPHevmy/5f4DR++bK/ o8FYyoAGJwqxBk+qQ/UcArDCRygu7pxEWGeJbrSB0VtFaUw7/73Sx+3QbgQwxuciL0Y4jFheveil+ RMrMIT65dvJ+NQk3dEMZasu1N6nUxLV2dT1TrMvsGjigxXxP8CmBGVAoQf8+j7OXmP5zLtidGkXzF JHF/ADFMwlmbE07DuaNRidlr+OjSSiMYlVQGd0ajhJ/x5SiN6esy6uVjLQhMk70JZ6kqcOObJd+Uj eZVtgXKA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dGP4g-00025n-UK; Thu, 01 Jun 2017 12:19:34 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGP4R-0001aD-BW for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2017 12:19:22 +0000 Received: by mail-wm0-x242.google.com with SMTP id k15so10886126wmh.3 for ; Thu, 01 Jun 2017 05:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=726gJKC4/dP2V5RikrqWGqGVXCbP/S03MlJLQSujf0U=; b=fp0Z3oy/N5Z/t3BFwnXbkbqvUujgkrvkpPJ9K9WGBjUrVA5XOKt5ZGOxxVAZ1XjAxB c4ZCjpptNCbPCOem4E6t0+2KpMoc0WhMQ4K8kvf0SI4+oFjSkbPT85jWilGSsjJ0eLmA xtuUG58DZCA95XVi7M/1XbJfZ/w7f1SglRT3APWwadMOPFKfZwVc/coMkWxpm1id77GY +DnQOXoysptBMwLRsEPgZMexoPc3VW/xer3355PGhEKV8fdTiuxF1ICFZJUkPhu/BZXV 6wUFzVs9Dh3Nx/a/TjHWm7bLZapqMxcsGsXN6dTO90gPqgFgdnCowHtYGaUMXktlUqpL UzsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=726gJKC4/dP2V5RikrqWGqGVXCbP/S03MlJLQSujf0U=; b=EXMdrLTUwsABbTwBEBTVoJVIY9gg71l9trvZictm80fUl6uWvnnmCIPOm/LHQA+qVg 5iVdie2wrvptZ6z5fjsl6J7E2Z2bS3UP3S2YInQfkC95JtT7vm1c23NIapsVDpaP50Jo 4t5f5H3UmPFQRZfHM2X9RE7wurLKbIMClbjokfnKRSWCAgHCPyZOChGzSHiCRRY4b5R7 z3LU/T8NfamY5fXjun1cOFwQ8v+QexWfwRufVy1emvR2j0etENyxDxbVtwkgfW/QnelZ 3k5frZ9rU9ix8aow3hs4ZzxO4qOw1BA4MWmbYw+wd0Jaq3YYVbIjYv5i4IcthGTEQCLi 9mcw== X-Gm-Message-State: AODbwcB9/53/QmgGzPJKVfAHEs3WG4BIFzu4RfSPWhKhSS5Jf7Z0Onaq orxvXWuBicQhdg== X-Received: by 10.28.156.197 with SMTP id f188mr1559152wme.76.1496319537304; Thu, 01 Jun 2017 05:18:57 -0700 (PDT) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id k7sm24109518wrk.45.2017.06.01.05.18.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 05:18:56 -0700 (PDT) From: Richard Genoud To: Linus Walleij Subject: [PATCHv2 2/2] gpio: mvebu: fix gpio bank registration when pwm is used Date: Thu, 1 Jun 2017 14:18:26 +0200 Message-Id: <20170601121826.14685-3-richard.genoud@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170601121826.14685-1-richard.genoud@gmail.com> References: <20170601121826.14685-1-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170601_051919_962366_866D5F33 X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Alexandre Courbot , Jason Cooper , Andrew Lunn , Richard Genoud , linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, Russell King , linux-gpio@vger.kernel.org, Rob Herring , Thierry Reding , Gregory Clement , Ralph Sennhauser , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);