All of lore.kernel.org
 help / color / mirror / Atom feed
From: andy.shevchenko@gmail.com
To: Esteban Blanc <eblanc@baylibre.com>
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
Date: Fri, 12 May 2023 20:07:59 +0300	[thread overview]
Message-ID: <ZF5yb4DbVDbfxVU4@surfacebook> (raw)
In-Reply-To: <20230512141755.1712358-3-eblanc@baylibre.com>

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 <linux/gpio/regmap.h>
> +#include <linux/gpio/driver.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/pinctrl/pinmux.h>

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



  reply	other threads:[~2023-05-12 17:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 14:17 [PATCH v4 0/3] TI TPS6594 PMIC support (RTC, pinctrl, regulators) Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC Esteban Blanc
2023-05-12 17:22   ` andy.shevchenko
2023-05-17 16:47     ` Esteban Blanc
2023-05-17 16:52       ` Andy Shevchenko
2023-05-22 11:49         ` Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs Esteban Blanc
2023-05-12 17:07   ` andy.shevchenko [this message]
2023-05-16 13:05     ` Esteban Blanc
2023-05-16 16:48       ` Andy Shevchenko
2023-05-17  9:58         ` Esteban Blanc
2023-05-17 13:51           ` Andy Shevchenko
2023-05-17 14:43             ` Esteban Blanc
2023-05-17 15:04               ` Andy Shevchenko
2023-05-22  8:45                 ` Esteban Blanc
2023-05-23  9:26                 ` Esteban Blanc
2023-05-23 11:03                   ` Andy Shevchenko
2023-05-23 11:32                     ` Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 3/3] regulator: tps6594-regulator: Add driver for TI TPS6594 regulators Esteban Blanc
2023-05-12 17:34   ` andy.shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZF5yb4DbVDbfxVU4@surfacebook \
    --to=andy.shevchenko@gmail.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=aseketeli@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=eblanc@baylibre.com \
    --cc=jneanne@baylibre.com \
    --cc=jpanis@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sterzik@ti.com \
    --cc=u-kumar1@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.