Message ID | 20231229130758.84214-1-emil.renner.berthing@canonical.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2555462dyb; Fri, 29 Dec 2023 05:08:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7ymBqCNvnLz58nkTDtt1yuTtw4sMxgN+EvdS5VuG2AOD5cmvgGFByPhpnLVRUYjRWa6hR X-Received: by 2002:a05:6871:14c:b0:1fb:29af:c8b2 with SMTP id z12-20020a056871014c00b001fb29afc8b2mr13308823oab.7.1703855310723; Fri, 29 Dec 2023 05:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703855310; cv=none; d=google.com; s=arc-20160816; b=jnSRrQb7alszc9HQQIPWniMVL+MOY8gMf6sKUl8v2+rdFOEtqRmGoPK4oLwqFbgHZt IKisa4580pP9YopiDmi7MZHbsBqlKQSXoBdl6aSHPY3jy2lLrSMYbmcDsvAarcYX585u 6eDPgffepZTo45Tp7jnIuqDaRSnyhZ0d5djO17aah8TXOVpJremaztVpFVtX3kK1rGxI Iem3k8RjvC0zBtkAsI9aZsM5mTgxnEgnlFWPD1/q62zOifVyxp6qL3QYOm4eWzGc0u3Y rhVwSYaspB1aqgA28s7cq3rTBkuW55ShFrrwaSGqJIk21nc+bA1WkPl6Uc0c9SMmt55B bRPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; fh=7+VlPjlvMh5BcTbJ3sN70/UW1WHuO1uZHVdSiAivbi0=; b=Vjj1Y6jb1V9MIBOIVOulvW7noK5UIdG+CN2CHxK92Sahb7VpdD24nu/uSKni3XLWvi GwGafMReHRhcPhtvYchAt4dBWgsGIgDRqLqyNSxErB0yuFR4qnRWV8szMhmv+KQk3uX+ fer9BlVMq5WHMHG4Y7inkZ6rTCwqZbquX4HydFnfrVofmaAdEU2O/2BvEHg72rUyVUk0 cVE95KzttIStq6LMUZZoQFOkyuJnCLxkpPsdHdqNaIX3+dG0W9nU9elNOEgPXRV3KA1w n97SAI5/uieDKAQGASaSWAZLzwIykrZpkybZzZUe1zOFXNtznkbYmJydoUNaVIyHRtCj sFtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=eK9NUZ75; spf=pass (google.com: domain of linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j1-20020a63e741000000b005cd811e2ffesi14776905pgk.18.2023.12.29.05.08.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 05:08:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=eK9NUZ75; spf=pass (google.com: domain of linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 74BCA282B91 for <ouuuleilei@gmail.com>; Fri, 29 Dec 2023 13:08:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36FD811716; Fri, 29 Dec 2023 13:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="eK9NUZ75" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21393111B5 for <linux-kernel@vger.kernel.org>; Fri, 29 Dec 2023 13:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 562D53F15B for <linux-kernel@vger.kernel.org>; Fri, 29 Dec 2023 13:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1703855290; bh=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eK9NUZ751EG8XuCqHJjBkaq+ncUXr6PzlYT+zrbvp2ACMCzKJpSx4DvkmFeKL5Q99 boW7ZeongFkRMzciT9OS9UVesrn+sn9vWQnNqoqVxpZrkXfiuPBZwd1Obr1yaMLyRt l9q0yqHBFXfz6fX95Tqa8yghJqsqxhTkfjWzizuQu25jyxrcQ1FEwxkvI6Yf4vIwgI oZQ0i+fW9PjPrZ1IKwLBgyaNGiQb/KhnUFAjqgOROalCparTY7u4BpRoxxNxtmOZMY XlBONN9+8eFY1gs8NFvzc5JTZIFxV4iv3n/APR4+1eVB6+HBGFT9KLfvVW3WQcLUbt PEXMMpXwW/ekw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5552470977aso1698378a12.0 for <linux-kernel@vger.kernel.org>; Fri, 29 Dec 2023 05:08:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703855290; x=1704460090; 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=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; b=Znb+TRjziAMqOqLw/SSz+yegYrMco5Xb1RgLwEWIh1dIk41GSzcM9yS5a06ju6qy93 BvZ60t3vIQxJMFUmb/IOWSdiXGGGsczhN+pBsm56az88Wjri7WmRg2rRKcsDJABleQAB 3ZSRWustN3RFkx19eW6h7sPT26slrDtqS+Drg0tkGAoZn2F4+TFLzFCGqPB75/LMkUsv yuIvw/Ky4ZclosK9sDSIIdmEP1liXQEeWut3KK/tHo5daJBfu57FhBgGyuL78hCACYcY cG9PZijxvgX5MwizVWm4xd8NbNx+bep17/KebtnAeIm/p7AI6e/fFhOH+INY9gOQqk7a vg7g== X-Gm-Message-State: AOJu0YzvVK9NGvJZZYw5DQEfsZrthrWdY1izK6jE/QaPrN8712Voylqr ZnR0E725m+4fEbm0RPLOTMsORthnpS8I392VFyj+wwOOuf8hXqZsZU90PV5n+jsu0/huZ+u4adC Xbh1P8oxrufpDHWRljxVrY6dpqEfJYoRV91JMunFbubLeh6iP X-Received: by 2002:a17:907:1047:b0:a1f:7298:aa25 with SMTP id oy7-20020a170907104700b00a1f7298aa25mr5908865ejb.45.1703855290046; Fri, 29 Dec 2023 05:08:10 -0800 (PST) X-Received: by 2002:a17:907:1047:b0:a1f:7298:aa25 with SMTP id oy7-20020a170907104700b00a1f7298aa25mr5908860ejb.45.1703855289728; Fri, 29 Dec 2023 05:08:09 -0800 (PST) Received: from stitch.. ([2001:67c:20a1:1909:b62b:6d4a:f569:ad01]) by smtp.gmail.com with ESMTPSA id ex1-20020a170907954100b00a26f22dca5asm4359327ejc.0.2023.12.29.05.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 05:08:09 -0800 (PST) From: Emil Renner Berthing <emil.renner.berthing@canonical.com> To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hoan Tran <hoan@os.amperecomputing.com>, Serge Semin <fancer.lancer@gmail.com>, Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <brgl@bgdev.pl>, Andy Shevchenko <andy@kernel.org>, Jisheng Zhang <jszhang@kernel.org>, Drew Fustini <dfustini@baylibre.com> Subject: [PATCH v1] gpio: dwapb: Use generic request, free and set_config Date: Fri, 29 Dec 2023 14:07:51 +0100 Message-ID: <20231229130758.84214-1-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786621786026564082 X-GMAIL-MSGID: 1786621786026564082 |
Series |
[v1] gpio: dwapb: Use generic request, free and set_config
|
|
Commit Message
Emil Renner Berthing
Dec. 29, 2023, 1:07 p.m. UTC
This way GPIO will be denied on pins already claimed by other devices
and basic pin configuration (pull-up, pull-down etc.) can be done
through the userspace GPIO API.
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
---
drivers/gpio/gpio-dwapb.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
Comments
On Fri, Dec 29, 2023 at 2:08 PM Emil Renner Berthing <emil.renner.berthing@canonical.com> wrote: > This way GPIO will be denied on pins already claimed by other devices > and basic pin configuration (pull-up, pull-down etc.) can be done > through the userspace GPIO API. > > Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> This looks like a nice case of a pure pin control back-end for the generic DW front-end GPIO. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
On Fri, Dec 29, 2023 at 02:07:51PM +0100, Emil Renner Berthing wrote: > This way GPIO will be denied on pins already claimed by other devices > and basic pin configuration (pull-up, pull-down etc.) can be done > through the userspace GPIO API. > > Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> LGTM. Thanks! Acked-by: Serge Semin <fancer.lancer@gmail.com> -Serge(y) > --- > drivers/gpio/gpio-dwapb.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c > index 8c59332429c2..798235791f70 100644 > --- a/drivers/gpio/gpio-dwapb.c > +++ b/drivers/gpio/gpio-dwapb.c > @@ -416,11 +416,12 @@ static int dwapb_gpio_set_config(struct gpio_chip *gc, unsigned offset, > { > u32 debounce; > > - if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) > - return -ENOTSUPP; > + if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) { > + debounce = pinconf_to_config_argument(config); > + return dwapb_gpio_set_debounce(gc, offset, debounce); > + } > > - debounce = pinconf_to_config_argument(config); > - return dwapb_gpio_set_debounce(gc, offset, debounce); > + return gpiochip_generic_config(gc, offset, config); > } > > static int dwapb_convert_irqs(struct dwapb_gpio_port_irqchip *pirq, > @@ -530,10 +531,14 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, > port->gc.fwnode = pp->fwnode; > port->gc.ngpio = pp->ngpio; > port->gc.base = pp->gpio_base; > + port->gc.request = gpiochip_generic_request; > + port->gc.free = gpiochip_generic_free; > > /* Only port A support debounce */ > if (pp->idx == 0) > port->gc.set_config = dwapb_gpio_set_config; > + else > + port->gc.set_config = gpiochip_generic_config; > > /* Only port A can provide interrupts in all configurations of the IP */ > if (pp->idx == 0) > -- > 2.43.0 >
On Fri, Dec 29, 2023 at 2:08 PM Emil Renner Berthing <emil.renner.berthing@canonical.com> wrote: > > This way GPIO will be denied on pins already claimed by other devices > and basic pin configuration (pull-up, pull-down etc.) can be done > through the userspace GPIO API. > > Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> > --- Applied, thanks! Bart
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 8c59332429c2..798235791f70 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -416,11 +416,12 @@ static int dwapb_gpio_set_config(struct gpio_chip *gc, unsigned offset, { u32 debounce; - if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) - return -ENOTSUPP; + if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) { + debounce = pinconf_to_config_argument(config); + return dwapb_gpio_set_debounce(gc, offset, debounce); + } - debounce = pinconf_to_config_argument(config); - return dwapb_gpio_set_debounce(gc, offset, debounce); + return gpiochip_generic_config(gc, offset, config); } static int dwapb_convert_irqs(struct dwapb_gpio_port_irqchip *pirq, @@ -530,10 +531,14 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, port->gc.fwnode = pp->fwnode; port->gc.ngpio = pp->ngpio; port->gc.base = pp->gpio_base; + port->gc.request = gpiochip_generic_request; + port->gc.free = gpiochip_generic_free; /* Only port A support debounce */ if (pp->idx == 0) port->gc.set_config = dwapb_gpio_set_config; + else + port->gc.set_config = gpiochip_generic_config; /* Only port A can provide interrupts in all configurations of the IP */ if (pp->idx == 0)