Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp905994ybs; Mon, 25 May 2020 02:08:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr1r9MSB+g0U7ELsStXAp74oaNjHCwkIvoDzzdpMsKdDbZq/C3h392l6ZN57uq7DBnr0EN X-Received: by 2002:a17:906:2b96:: with SMTP id m22mr18755463ejg.330.1590397737155; Mon, 25 May 2020 02:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590397737; cv=none; d=google.com; s=arc-20160816; b=QDmlAjRaJnyv+12k8NeoKVT+IEiU4+8tb8jjkS21jO/D+Q1gg7RzHzUWQwjsn6cA6X Z+z/crvet8F9bJqlGh8pA8qSLjCoKictJBm85l1QwKqrXiO/nY+GI82hXUji4SobRNH/ Nlczoyxl3aZJjTp11cjbRMei3060sUuh82KzIRtosdhZgCHf8fRQQoQN15097MkijeKQ oFH+tpCv5eabVLwbq7MfZG0y/LVAUzSjEtEiyYwxYcxk79MHjjjyW1NdTCJRlvowuCR1 VhUKNK3ttaCPhWwJ9RkGtpgcGPA/dve77TQV8+Icv+YNCbOXnQ5FmuLG2lDpqPRS5gdM TUuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dPuZPyJHL9y310jCMBab1+wUqEyxBpL9sxzRpIMUcDw=; b=KqXcCNj7tXlS8CDCs7obt+LYUI3ZTd7nClpVjlSDHJr7BmsMk2RsZaBJa8wlAwGffn reaIvdb2ZZfxqczS6QQb8LQ26LOf485naOs2d++HMajG9aXIvXWTZqpmNS1eBp8fOUDw /Tqo1h8aLAxL8y7D3yL3VYu8Lf5eIOY9XZ434ykdJlbg+mhFMkqtJMQCdqUH5E6v2fPe H2gVKyKA25+XrSZyAOX7f6eA4tUYIDMk33tUDsOjFp/xEaGEc8riYd+Fqn63LhODi0tZ IrEmTBb/Mn/y0roTxZvpcwyQV7GaEXnJ4qHzi5k1O3x6Rx9fVc1ZUwyeObuzi/VBcFFC S79g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=nO2zcmFB; 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 e4si9132422edm.144.2020.05.25.02.08.32; Mon, 25 May 2020 02:08:57 -0700 (PDT) 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=nO2zcmFB; 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 S2389064AbgEYJGE (ORCPT + 99 others); Mon, 25 May 2020 05:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388660AbgEYJGE (ORCPT ); Mon, 25 May 2020 05:06:04 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0746C05BD43 for ; Mon, 25 May 2020 02:06:03 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id n141so4500036qke.2 for ; Mon, 25 May 2020 02:06:03 -0700 (PDT) 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:content-transfer-encoding; bh=dPuZPyJHL9y310jCMBab1+wUqEyxBpL9sxzRpIMUcDw=; b=nO2zcmFBdCWzlGqLw1pR2ThUuz31GiwsX9FmLMPWXkIRbISIRdArAGzOKpkV7Qzv10 5VetiQSFGmqqkEyKB7+SGACaU0qLz2m+9iyUgPiDy2IDRCPxhwFx8/5DMtWUHYRsjtlL 0atWQF/ahgFhsYQYAzdXXs0aRQhob0wySOVyDYs2DXpouokBCqB6slqb/TvDM+I33ev8 yk0brFmDMsprGHiwBPRLvyh/NVcy/OCFMiVYdFYc4bQaZFP6VvDRpzKRyp0zTf5FOVWN aSAJO9abuoljXUYQUaIMlrcVwRxlonf00RVbuDaEI1E+vkonNYosmqgXcWB0HgzUmBS7 NMpg== 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:content-transfer-encoding; bh=dPuZPyJHL9y310jCMBab1+wUqEyxBpL9sxzRpIMUcDw=; b=QlPPOjlZY5++W48Uo6Yqci/xwxLYav3yJDjlPTttWZIqfU3geSzn1QlVIg6yjeTqkD HPX/V9P4yptWpDfuX/BP78kJsmbDSHpDEQz97jS4fZMIthCQl34CWAPBnxt6gIEMBXyC Sioa81n0Vc7F6hREvz7goTBin2gjhQN1+zP+ytJIUuy59A7OnHId+P8Qx8Ud7OGPc5hT BgAmVY0GYCTvDLqLfuHZPw95oh+KOpET+T33qcHw6TZNtRfFZk99AdswBg3ekspFbyXt je7CbQ6pTq3MR/l6aX0EUdrX/xJztyp4eyvLW6FNBU4YLCJKbd/TdHod7KZpqQPVsgh4 fwDA== X-Gm-Message-State: AOAM532lrqw4FvJSGNC5nVwevtCtT/Fz/p2CHJhhvXtaHTGysvREyct0 6JLNxzAM72U6VG4yFIN0P1lDdTP+QZV6WgCxh2TQAg== X-Received: by 2002:a37:5b47:: with SMTP id p68mr26336785qkb.120.1590397562647; Mon, 25 May 2020 02:06:02 -0700 (PDT) MIME-Version: 1.0 References: <20200423174543.17161-1-michael@walle.cc> <20200423174543.17161-11-michael@walle.cc> <75bff2917be1badd36af9f980cf59d2c@walle.cc> In-Reply-To: <75bff2917be1badd36af9f980cf59d2c@walle.cc> From: Bartosz Golaszewski Date: Mon, 25 May 2020 11:05:51 +0200 Message-ID: Subject: Re: [PATCH v3 10/16] gpio: add a reusable generic gpio_chip using regmap To: Michael Walle Cc: Andy Shevchenko , linux-gpio , linux-devicetree , LKML , linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org, LINUXWATCHDOG , arm-soc , Linus Walleij , Rob Herring , Jean Delvare , Guenter Roeck , Lee Jones , Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Wim Van Sebroeck , Shawn Guo , Li Yang , Thomas Gleixner , Jason Cooper , Marc Zyngier , Mark Brown , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 12 maj 2020 o 16:41 Michael Walle napisa=C5=82(a): > > >> + > >> +MODULE_AUTHOR("Michael Walle "); > >> +MODULE_DESCRIPTION("GPIO generic regmap driver core"); > >> +MODULE_LICENSE("GPL"); > >> diff --git a/include/linux/gpio-regmap.h b/include/linux/gpio-regmap.h > >> new file mode 100644 > >> index 000000000000..a868cbcde6e9 > >> --- /dev/null > >> +++ b/include/linux/gpio-regmap.h > >> @@ -0,0 +1,69 @@ > >> +/* SPDX-License-Identifier: GPL-2.0-only */ > >> + > >> +#ifndef _LINUX_GPIO_REGMAP_H > >> +#define _LINUX_GPIO_REGMAP_H > >> + > >> +struct gpio_regmap; > >> + > >> +#define GPIO_REGMAP_ADDR_ZERO ((unsigned long)(-1)) > >> +#define GPIO_REGMAP_ADDR(addr) ((addr) ? : GPIO_REGMAP_ADDR_ZERO) > >> + > > > > What if the addr is actually 0? > > Then the driver has to set GPIO_REGMAP_ADDR_ZERO or use the convenience > macro GPIO_REGMAP_ADDR. > > So you can have > > struct gpio_regmap_config config =3D { 0 }; > config.reg_dat_base =3D 0x10; > config.reg_dir_out_base =3D 0x20; > > or > > config.reg_dat_base =3D GPIO_REGMAP_ADDR_ZERO; > > or if you can't be sure if the RHS value might be zero: > > config.reg_dat_base =3D GPIO_REGMAP_ADDR(reg); > > > > Maybe drop GPIO_REGMAP_ADDR and require users to set unused registers > > to GPIO_REGMAP_ADDR_ZERO? > > Thats bad because: > * you'd have to set plenty of unused base registers for a simple driver > * if there will be additional properties in the future, you have to > touch > all other drivers, because they are initialized as 0 (ie. valid reg > 0). > > >> +/** > >> + * struct gpio_regmap_config - Description of a generic regmap > >> gpio_chip. > >> + * > >> + * @parent: The parent device > >> + * @regmap: The regmap used to access the registers > >> + * given, the name of the device is used > >> + * @label: (Optional) Descriptive name for GPIO > >> controller. > >> + * If not given, the name of the device is used. > >> + * @ngpio: Number of GPIOs > >> + * @reg_dat_base: (Optional) (in) register base address > >> + * @reg_set_base: (Optional) set register base address > >> + * @reg_clr_base: (Optional) clear register base address > >> + * @reg_dir_in_base: (Optional) out setting register base address > >> + * @reg_dir_out_base: (Optional) in setting register base address > > > > The two above are inverted I think? > good catch. > > > Also: why the limitation of only supporting one at a time? > > they should be exclusive, either you have a register where you set the > output bits to one, or the input bits. Maybe this need a bit more > context > above. in gpio-mmio.c you can set both and both are used in > set_direction(), but only one is read in get_direction(). > > That being said, I have no strong opinion wether they should be > exclusive > or not, besides the symmetry of set_/get_direction(). > > -michael > Sorry for the late response, your comments make sense to me. Are you going to submit a v4 before the v5.8 merge window? Bart