From patchwork Tue Apr 23 17:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13640504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36143C4345F for ; Tue, 23 Apr 2024 17:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Djj13ewuQPKFQcMofdsqwXy3E3lHs6P4Zl0PSXtaul4=; b=QDVQV0DRXqXEQO t0HsmTa9/0SoxdAMc8RsiA2KSbfZ3Z89RaGeVjieDeZxVJ69jOtdlpVQ4llFymuuL2mnHHWTI3rFK 8iHg5+EO/FQqooqFEc2eQrkwvL3TvKacS9YE+Ejil37QettIHTaNN5r2Ity1WlOYh/2T5D/f5eGUf kZ2trCgloFOxx1aFJ3yVpsjgXhUR5ujl3/ttSyyKtXqBErs0jJ8ZN4dgEyeDu4SLZunqS2W9flLMI /0SOR6e6LYgoiXSlYef3hM/xorSNWDPslOEIi3ontk0CiK5xTQRqg2olTrjTOxG2UXk1+RAcW1zLM Ahn7RD2ZMVKZs7CuNrSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzKIU-000000012AX-3u8I; Tue, 23 Apr 2024 17:51:14 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzKIR-0000000129X-2xlA for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 17:51:13 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6a071595d22so11885476d6.3 for ; Tue, 23 Apr 2024 10:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713894660; x=1714499460; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mq3/dOubMwzkxAEhuwZmQ8xTgTsTEEG+7iq9Q2Hjw3A=; b=O1TTCbwaMPDmbOumdQ/c4+0dQOAuc6b1BANDpQglEPhFrE0k+8TBhj/tVplx8B8Y8o Gi3a5P5iaRNCEEHDC8041fPQpiSyIrJUBmxlB1i5EJ1WqjcvvuZkdkNJ5+4Dt64PDvOU 2iyRqnbYU+RXDsPozOxt4dgjfEdBOOSmUqaLRuRaZ2CDqPPavq+yGWh5/Kygvb1GYKSS Px22VyvkJorW7te5CErRZeK8NY8xl3SqZyM/YGN/GAX2bTf2bQVZ5WX97ruIXzCU0NYT FH3RJA5enVLxCtmGbeZCPhW9X8VPAvhq/DwikrQLzdiZad8aHyLhj5UopON/qjUdvIPj //gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713894660; x=1714499460; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mq3/dOubMwzkxAEhuwZmQ8xTgTsTEEG+7iq9Q2Hjw3A=; b=pM1mkfp02XmBPu3VtBhe/pMGn5mnH1qOTj2iRkQ5zaIg44xYm0ZY3T2jLZnXGciPSJ msinzFpjPFdlckLyhZq6Zldf2ZgJJ0dnhyXPoaEJrcMzve+jblmLPBly3H9M/Z7pKJxj ahpO7L8dWJZt8igT2EZ33FZEpLFv+mbUyk/mk7TOGTkLaAw5osx03kb9GVGKKsDvdpj7 mdZ0QGeNqpXdteHMgNol2JBvxUyAQfezBWxeBYQcrzpDHKJ2Nkhn7Ey9P1fFmwhOwcHi fffFUmItf2e+imsMCiQaDIxp1F0f8RdzyRPD7rpETf6PruVdVX5PdzS8guQxvlfYEvpK XW4Q== X-Forwarded-Encrypted: i=1; AJvYcCX4qlok5Bt0PhcqZOC0d8XC3vvc7jbBhWQrW5msLJtXgYhB2S5zVcbEU4AlddRzBolRKDy8naa6KYFFHXs1DqXLo9uuXRaDxd5Bux6qXLbv76tnBNU= X-Gm-Message-State: AOJu0YyIwHLqBzwCG8dsb6ZNGAH8dJ3/kcT8YnbVW55jsdnUTG5Sq+kc mgP45HH62ZczRdOBL7BMTzfD9V8xElrs8iVQyYLrdbbGM/oow0T2ZLo3lg== X-Google-Smtp-Source: AGHT+IFRYtQrNtQjtshOLSGV5N3sax3zO2noXWjyyB+SGvQ46sxMyNLuuDPmIbzrQiIw9G51RFuuSg== X-Received: by 2002:a05:6214:328c:b0:691:8b3a:5acb with SMTP id mu12-20020a056214328c00b006918b3a5acbmr174177qvb.13.1713894660340; Tue, 23 Apr 2024 10:51:00 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id js7-20020a05622a808700b0043936ed09bfsm3859808qtb.27.2024.04.23.10.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 10:50:59 -0700 (PDT) From: Doug Berger To: Linus Walleij , Bartosz Golaszewski , Florian Fainelli Cc: bcm-kernel-feedback-list@broadcom.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger , Phil Elwell Subject: [PATCH] gpio: brcmstb: Use dynamic GPIO base numbers Date: Tue, 23 Apr 2024 10:50:25 -0700 Message-Id: <20240423175025.1490171-1-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_105111_778001_8D5E56E2 X-CRM114-Status: GOOD ( 17.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Forcing a gpiochip to have a fixed base number now leads to a warning message. Remove the need to do so by using the offset value of the gpiochip. Signed-off-by: Phil Elwell Signed-off-by: Doug Berger Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli --- drivers/gpio/gpio-brcmstb.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index a789af4a5c85..a9d5697349d3 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -50,7 +50,6 @@ struct brcmstb_gpio_priv { struct irq_domain *irq_domain; struct irq_chip irq_chip; int parent_irq; - int gpio_base; int num_gpios; int parent_wake_irq; }; @@ -92,7 +91,7 @@ brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank) static int brcmstb_gpio_hwirq_to_offset(irq_hw_number_t hwirq, struct brcmstb_gpio_bank *bank) { - return hwirq - (bank->gc.base - bank->parent_priv->gpio_base); + return hwirq - bank->gc.offset; } static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank, @@ -118,7 +117,7 @@ static int brcmstb_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { struct brcmstb_gpio_priv *priv = brcmstb_gpio_gc_to_priv(gc); /* gc_offset is relative to this gpio_chip; want real offset */ - int hwirq = offset + (gc->base - priv->gpio_base); + int hwirq = offset + gc->offset; if (hwirq >= priv->num_gpios) return -ENXIO; @@ -263,7 +262,7 @@ static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank) { struct brcmstb_gpio_priv *priv = bank->parent_priv; struct irq_domain *domain = priv->irq_domain; - int hwbase = bank->gc.base - priv->gpio_base; + int hwbase = bank->gc.offset; unsigned long status; while ((status = brcmstb_gpio_get_active_irqs(bank))) { @@ -412,7 +411,7 @@ static int brcmstb_gpio_of_xlate(struct gpio_chip *gc, if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) return -EINVAL; - offset = gpiospec->args[0] - (gc->base - priv->gpio_base); + offset = gpiospec->args[0] - bank->gc.offset; if (offset >= gc->ngpio || offset < 0) return -EINVAL; @@ -596,8 +595,8 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) const __be32 *p; u32 bank_width; int num_banks = 0; + int num_gpios = 0; int err; - static int gpio_base; unsigned long flags = 0; bool need_wakeup_event = false; @@ -611,7 +610,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) if (IS_ERR(reg_base)) return PTR_ERR(reg_base); - priv->gpio_base = gpio_base; priv->reg_base = reg_base; priv->pdev = pdev; @@ -651,7 +649,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) dev_dbg(dev, "Width 0 found: Empty bank @ %d\n", num_banks); num_banks++; - gpio_base += MAX_GPIO_PER_BANK; + num_gpios += MAX_GPIO_PER_BANK; continue; } @@ -691,7 +689,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) err = -ENOMEM; goto fail; } - gc->base = gpio_base; + gc->base = -1; gc->of_gpio_n_cells = 2; gc->of_xlate = brcmstb_gpio_of_xlate; /* not all ngpio lines are valid, will use bank width later */ @@ -713,7 +711,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) bank->id); goto fail; } - gpio_base += gc->ngpio; + num_gpios += gc->ngpio; dev_dbg(dev, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank->id, gc->base, gc->ngpio, bank->width); @@ -724,7 +722,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) num_banks++; } - priv->num_gpios = gpio_base - priv->gpio_base; + priv->num_gpios = num_gpios; if (priv->parent_irq > 0) { err = brcmstb_gpio_irq_setup(pdev, priv); if (err)