Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10627134rwr; Fri, 12 May 2023 10:32:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UEDM7IdZ468WdVJIOV2TTSfrsWAhW3WnaLMfzDmJcypNxaxL0OtT4W+zrZGTOcaOIlc/6 X-Received: by 2002:a17:90b:8c5:b0:250:4618:f8e8 with SMTP id ds5-20020a17090b08c500b002504618f8e8mr22755354pjb.46.1683912737021; Fri, 12 May 2023 10:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683912737; cv=none; d=google.com; s=arc-20160816; b=YDYPpW59AM+XruL6j79WbP/2zDvmJI8K24BfXUjg8dz//ciSfHZ11gLnxk2nXQ0Qk0 y0uPHobCfUczZx82qhgiKLDRwQtz1XlT0yBcJAY/W5MSusiBt9BsWsWWo552yHlLRWaQ LVAmlfNRSplWiLkBQgHmOnD5zVaAHoeZ2sTvfYWkTB+gJM+XD7DZ9EzNRcVjBDYe6uMv 26g+nbOBSlzQEpYwVdaDz2tuBH5i4hmuCdGXs2FdirchH5SKkd8axy7v0+oSTUSzYo6A SEIBVnbXs7yzx7vHMSpK/2HOcStr2ihjrUTvd856VNR9wNnLV3fFOO4J+FbFPUI5NGXJ FClw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from; bh=Wv8Q3OryHY/nV+7XVw221+iaC7RZg3Jl4oULnvR0s84=; b=DPKro9n5woDcWAuOkiyA5Ucj84KnOdw4zyE1tOiZjVf7wYalCsw3tNZw8rE6PflMKC ik3oAxIOhB3LPJ/C/qe9P9zCPEnQyGs5rCrQQVSEa2W1sLQOd8Bmzib80hPSgdXkFHuc 75ym948zik4puPrL4Sp2SXdXUByZIQtXe6bvkv1wgrJfq7FKSVA8xhdy4X4MDth6+Aup a/cc40pR/YXz/96Bjxxa51pmWukRKPXY10kmPmHCQdL4BK93q4OGmJw5d7iFiedS5moF vihED2yfxj94qA28a4L8ZKHNpk2dzCaxBK+TdebHuvmpk9a3WhtUTM5PLj6UvRJzJrCw ckOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63f110000000b0051393805ccesi10237700pgi.418.2023.05.12.10.31.59; Fri, 12 May 2023 10:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237974AbjELRIO (ORCPT + 99 others); Fri, 12 May 2023 13:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237931AbjELRIK (ORCPT ); Fri, 12 May 2023 13:08:10 -0400 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8460FDDAB for ; Fri, 12 May 2023 10:08:03 -0700 (PDT) Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id 8bd276d0-f0e7-11ed-b972-005056bdfda7; Fri, 12 May 2023 20:08:00 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Fri, 12 May 2023 20:07:59 +0300 To: Esteban Blanc Cc: linus.walleij@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, a.zummo@towertech.it, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, jpanis@baylibre.com, jneanne@baylibre.com, aseketeli@baylibre.com, sterzik@ti.com, u-kumar1@ti.com Subject: Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs Message-ID: References: <20230512141755.1712358-1-eblanc@baylibre.com> <20230512141755.1712358-3-eblanc@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230512141755.1712358-3-eblanc@baylibre.com> X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti: > TI TPS6594 PMIC has 11 GPIOs which can be used > for different functions. > > This patch adds a pinctrl and GPIO drivers in > order to use those functions. ... > +config PINCTRL_THUNDERBAY Is it correct name? To me sounds not. The problem is that you use platform name for the non-platform-wide pin control, i.e. for PMIC exclusively. Did I miss anything? > + tristate "Generic pinctrl and GPIO driver for Intel Thunder Bay SoC" > + depends on ARCH_THUNDERBAY || (ARM64 && COMPILE_TEST) This doesn't look correct, but I remember some Kconfig options that are using this way of dependency. > + depends on HAS_IOMEM > + select PINMUX > + select PINCONF > + select GENERIC_PINCONF > + select GENERIC_PINCTRL_GROUPS > + select GENERIC_PINMUX_FUNCTIONS > + select GPIOLIB > + select GPIOLIB_IRQCHIP > + select GPIO_GENERIC > + help > + This selects pin control driver for the Intel Thunder Bay SoC. > + It provides pin config functions such as pull-up, pull-down, > + interrupt, drive strength, sec lock, Schmitt trigger, slew > + rate control and direction control. This module will be > + called as pinctrl-thunderbay. Ah, the above simply a mistake. right? Why is it in this patch? > +config PINCTRL_TPS6594 > + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC" > + depends on MFD_TPS6594 > + default MFD_TPS6594 > + select PINMUX > + select GPIOLIB > + select REGMAP > + select GPIO_REGMAP > + help > + This driver supports GPIOs and pinmuxing for the TPS6594 > + PMICs chip family. Module name? ... > +obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o Huh?! > +obj-$(CONFIG_PINCTRL_TPS6594) += pinctrl-tps6594.o ... > +#include > +#include > +#include > +#include > +#include Ordered? ... > +static const char *groups_name[TPS6594_PINCTRL_PINS_NB] = { > + "GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", > + "GPIO6", "GPIO7", "GPIO8", "GPIO9", "GPIO10" Leave trailing comma even for known size. > +}; ... > +struct tps6594_pinctrl_function { > + const char *name; > + u8 muxval; > + const char **groups; > + unsigned long ngroups; We have struct pinfunction. Use it here (as embedded). > +}; ... > +static const struct tps6594_pinctrl_function pinctrl_functions[] = { > + { "gpio", TPS6594_PINCTRL_GPIO_FUNCTION, groups_name, > + TPS6594_PINCTRL_PINS_NB }, Here and further use PINCTRL_PINFUNCTION() macro. > +}; ... > +static int tps6594_group_pins(struct pinctrl_dev *pctldev, > + unsigned int selector, const unsigned int **pins, > + unsigned int *num_pins) > +{ > + struct tps6594_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev); > + > + *pins = (unsigned int *)&pinctrl->pins[selector]; Why casting? > + *num_pins = 1; > + > + return 0; > +} ... > + pinctrl->pctl_dev = > + devm_pinctrl_register(&pdev->dev, pctrl_desc, pinctrl); One line? > + if (IS_ERR(pinctrl->pctl_dev)) { > + dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); > + return PTR_ERR(pinctrl->pctl_dev); return dev_err_probe(...); > + } ... > + pinctrl->gpio_regmap = devm_gpio_regmap_register(&pdev->dev, &config); > + if (IS_ERR(pinctrl->gpio_regmap)) { > + dev_err(&pdev->dev, "Couldn't register gpio_regmap driver\n"); > + return PTR_ERR(pinctrl->pctl_dev); Ditto. > + } > + > + return 0; > +} ... > -#define TPS6594_REG_GPIOX_CONF(gpio_inst) (0x31 + (gpio_inst)) > +#define TPS6594_REG_GPIO1_CONF 0x31 > +#define TPS6594_REG_GPIOX_CONF(gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst)) Why? The original code with parameter 0 will issue the same. -- With Best Regards, Andy Shevchenko