Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp154541pxb; Wed, 18 Nov 2020 00:31:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQhinCNuxVwJUp2dHIyUDNJEg9LY8PdgnRMWUu+lHwPaXQjlAhZJyho7KGVKJD3pfbQHEj X-Received: by 2002:a05:6402:1a58:: with SMTP id bf24mr23923568edb.191.1605688292478; Wed, 18 Nov 2020 00:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605688292; cv=none; d=google.com; s=arc-20160816; b=jRQOPUt5MJzjsa991OHciRv2ARINn/V5G1tZwgEbb1MHDKBCTe9P4x4xvXByxKlWgw yOipxj7Hrer+BCZxpweyrnES+ig3bwqYw3BtWLq69PU2UYp0W962uIjCHzM/TIWRh3SO BQrr8wmef811gYcB7vUq+Q4my2MVadFXTE7fULCh9M8jaS02rT5tWrQChZ3xw/vysWT/ O18+ny6WAI2+i+ntntw1Tz/G1ujF9C2eGglEZ1KVV32Y6eHiQDDFQy9bW2nxSHo+3U8Q zg7lZdah99ca4NuOU5zFXY7ZMobuU4QCUxzr8DSUR4TO9qAdJd8lWs16D/Pxi7MtqTv9 IO0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=e7/0oySTdCBUS5K5VKhLrqKbbTWozDIFYehy2a24oc4=; b=X3FMix7IZci0UJAKWxA2Vv1pyI3itEW6BHucEx8pj8NcprVLDcPY0sYzMEUVdS1lz9 4k8TXNyHoCUm43ynGqG+N31f6/Qf7IusKnNOxs0dBrgBlvJ9mlmH9RcuwT7Y44pNEMR9 7uM26qQz23Xj8VjqesKtVgy29LIX8Dj8YneyTusaB/+2d4aqoAcrM69mt2WR30QJQF/U QSQit1dCxYu8txq5cPSEvNUEy3RQDLcjO0kCwKlpUAMmSuLmmv5soasWuyOHdU5g6qiA KmTcOBWNOGiNl22YmtCoQgd5WdOuv/KXwHyQ6tUFeYobZBXov9Zy9Tun7kDFWWCGgI16 PpPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=x6eY0PCR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si14834906eju.633.2020.11.18.00.31.09; Wed, 18 Nov 2020 00:31:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=x6eY0PCR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgKRI3T (ORCPT + 99 others); Wed, 18 Nov 2020 03:29:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbgKRI3S (ORCPT ); Wed, 18 Nov 2020 03:29:18 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6805CC0613D4 for ; Wed, 18 Nov 2020 00:29:18 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id 7so1572241ejm.0 for ; Wed, 18 Nov 2020 00:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e7/0oySTdCBUS5K5VKhLrqKbbTWozDIFYehy2a24oc4=; b=x6eY0PCRQQMpbRy1Q6I+uu2YRoF0r80KxAZAQf9JYuY7YfySWIG/IDmCzLYv7CaBsZ 7SrK4geFajx4WBuJSxw3oLdNfgW0ovgegiQHt/m9n7a5Utp8dDQlE6JCWoyW6R+lOpiT FbHpL2YR+nhQfigvVD3YVHC5Vc24MOU5GQlUSjGPtemOT/Z5V0IJEueviYI+TWfNxaMa JoqLlIzxPBgZ5/upGEV7DiBW9qID+MvjIB1WTzavkjzQuKhh+pftwAib3wjvLlUWrBWk 6lPZj68GyYlz9r5ntU4DpfTriBwHExi1ODjUuostjEtrslX9QGrQ+IcWHX124w/4nQKd pMHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e7/0oySTdCBUS5K5VKhLrqKbbTWozDIFYehy2a24oc4=; b=NzdQIulevA7ohrZ1ds0C9qR9nMymST942wGEVX7gmicmmPQLv6wKs2r/Lj2I1iOKOD 9Ff0m9LlkmUqwY64p9LwqFvUXhgw658T/fDYIg6WLwCUwivnMuAYrhwKYvp/jkiZu+RS EDMFuktbbmP0c+mCbBmL5V8Machikv9Duoi382AUI888dPkMUrTH8n/O6JjPydG2WyNd EHWxM27V9i+yJtmT/esrezerioMuoXkNsH1Ve9qzjc1a+OZGDJJNdVW12bQXWEkwD2y6 GUeaM+DyJZVVTGQ8e2NzL2+a1eas0CVw6VZtEPCRlNP6SPIhhEBscejNyZMHlKaLWF8p BTmA== X-Gm-Message-State: AOAM533LN+BZsltOwdDQ7IigiUOrVpyb2Gh4LFJrccDlnB1GNMl47VWb UJ1JIZ3/teoMHatqmlNHfrQJaLRqEuoZuwXoFTVrIs4MNLg= X-Received: by 2002:a17:906:15cc:: with SMTP id l12mr21905044ejd.363.1605688157047; Wed, 18 Nov 2020 00:29:17 -0800 (PST) MIME-Version: 1.0 References: <20201113023355.43406-1-greentime.hu@sifive.com> In-Reply-To: <20201113023355.43406-1-greentime.hu@sifive.com> From: Bartosz Golaszewski Date: Wed, 18 Nov 2020 09:29:06 +0100 Message-ID: Subject: Re: [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data To: Greentime Hu Cc: LKML , Linus Walleij , linux-gpio , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Andy Shevchenko , Yash Shah Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 13, 2020 at 3:34 AM Greentime Hu wrote: > > We can get hwirq number of the gpio by its irq_data->hwirq so that we don't > need to add more macros for different platforms. This patch is tested in > SiFive Unleashed board and SiFive Unmatched board. > > Signed-off-by: Greentime Hu > --- > drivers/gpio/gpio-sifive.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c > index c54dd08f2cbf..630bddec48e5 100644 > --- a/drivers/gpio/gpio-sifive.c > +++ b/drivers/gpio/gpio-sifive.c > @@ -29,7 +29,6 @@ > #define SIFIVE_GPIO_OUTPUT_XOR 0x40 > > #define SIFIVE_GPIO_MAX 32 > -#define SIFIVE_GPIO_IRQ_OFFSET 7 > > struct sifive_gpio { > void __iomem *base; > @@ -37,7 +36,7 @@ struct sifive_gpio { > struct regmap *regs; > unsigned long irq_state; > unsigned int trigger[SIFIVE_GPIO_MAX]; > - unsigned int irq_parent[SIFIVE_GPIO_MAX]; > + unsigned int irq_number[SIFIVE_GPIO_MAX]; > }; > > static void sifive_gpio_set_ie(struct sifive_gpio *chip, unsigned int offset) > @@ -144,8 +143,12 @@ static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc, > unsigned int *parent, > unsigned int *parent_type) > { > + struct sifive_gpio *chip = gpiochip_get_data(gc); > + struct irq_data *d = irq_get_irq_data(chip->irq_number[child]); > + > *parent_type = IRQ_TYPE_NONE; > - *parent = child + SIFIVE_GPIO_IRQ_OFFSET; > + *parent = irqd_to_hwirq(d); > + > return 0; > } > > @@ -165,7 +168,7 @@ static int sifive_gpio_probe(struct platform_device *pdev) > struct irq_domain *parent; > struct gpio_irq_chip *girq; > struct sifive_gpio *chip; > - int ret, ngpio; > + int ret, ngpio, i; > > chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); > if (!chip) > @@ -200,6 +203,9 @@ static int sifive_gpio_probe(struct platform_device *pdev) > return -ENODEV; > } > > + for (i = 0; i < ngpio; i++) > + chip->irq_number[i] = platform_get_irq(pdev, i); > + > ret = bgpio_init(&chip->gc, dev, 4, > chip->base + SIFIVE_GPIO_INPUT_VAL, > chip->base + SIFIVE_GPIO_OUTPUT_VAL, > -- > 2.29.2 > Applied, thanks! Bart