From: "Esteban Blanc" <eblanc@baylibre.com>
To: "Bhargav Raviprakash" <bhargav.r@ltts.com>,
<linux-kernel@vger.kernel.org>
Cc: <m.nirmaladevi@ltts.com>, <lee@kernel.org>, <robh+dt@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
<jpanis@baylibre.com>, <devicetree@vger.kernel.org>,
<arnd@arndb.de>, <gregkh@linuxfoundation.org>,
<lgirdwood@gmail.com>, <broonie@kernel.org>,
<linus.walleij@linaro.org>, <linux-gpio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <nm@ti.com>,
<vigneshr@ti.com>, <kristo@kernel.org>
Subject: Re: [PATCH v2 13/14] pinctrl: pinctrl-tps6594: Add TPS65224 PMIC pinctrl and GPIO
Date: Thu, 29 Feb 2024 14:56:41 +0100 [thread overview]
Message-ID: <CZHM5FYHS6G0.295L6AYUNZCT@baylibre.com> (raw)
In-Reply-To: <20240223093701.66034-14-bhargav.r@ltts.com>
On Fri Feb 23, 2024 at 10:37 AM CET, Bhargav Raviprakash wrote:
> From: Nirmala Devi Mal Nadar <m.nirmaladevi@ltts.com>
>
> Add support for TPS65224 pinctrl and GPIOs to TPS6594 driver as they
> have significant functional overlap.
> TPS65224 PMIC has 6 GPIOS which can be configured as GPIO or other
> dedicated device functions.
>
> Signed-off-by: Nirmala Devi Mal Nadar <m.nirmaladevi@ltts.com>
> Signed-off-by: Bhargav Raviprakash <bhargav.r@ltts.com>
> ---
> drivers/pinctrl/pinctrl-tps6594.c | 287 +++++++++++++++++++++++++-----
> 1 file changed, 246 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-tps6594.c b/drivers/pinctrl/pinctrl-tps6594.c
> index 66985e54b..5da21aa14 100644
> --- a/drivers/pinctrl/pinctrl-tps6594.c
> +++ b/drivers/pinctrl/pinctrl-tps6594.c
> @@ -201,7 +319,21 @@ static int tps6594_gpio_regmap_xlate(struct gpio_regmap *gpio,
>
> static int tps6594_pmx_func_cnt(struct pinctrl_dev *pctldev)
> {
> - return ARRAY_SIZE(pinctrl_functions);
> + struct tps6594_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev);
> + int func_cnt = 0;
> +
> + switch (pinctrl->tps->chip_id) {
See below.
> @@ -229,10 +361,26 @@ static int tps6594_pmx_set(struct tps6594_pinctrl *pinctrl, unsigned int pin,
> u8 muxval)
> {
> u8 mux_sel_val = muxval << TPS6594_OFFSET_GPIO_SEL;
> + u8 mux_sel_mask = 0;
> +
> + switch (pinctrl->tps->chip_id) {
See below.
> @@ -240,16 +388,28 @@ static int tps6594_pmx_set_mux(struct pinctrl_dev *pctldev,
> {
> struct tps6594_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev);
> u8 muxval = pinctrl->funcs[function].muxval;
> + unsigned int remap_cnt = 0;
> + struct muxval_remap *remap;
>
> /* Some pins don't have the same muxval for the same function... */
> - if (group == 8) {
> - if (muxval == TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION)
> - muxval = TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION_GPIO8;
> - else if (muxval == TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION)
> - muxval = TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION_GPIO8;
> - } else if (group == 9) {
> - if (muxval == TPS6594_PINCTRL_CLK32KOUT_FUNCTION)
> - muxval = TPS6594_PINCTRL_CLK32KOUT_FUNCTION_GPIO9;
> + switch (pinctrl->tps->chip_id) {
See below.
> @@ -276,7 +436,21 @@ static const struct pinmux_ops tps6594_pmx_ops = {
>
> static int tps6594_groups_cnt(struct pinctrl_dev *pctldev)
> {
> - return ARRAY_SIZE(tps6594_pins);
> + struct tps6594_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev);
> + int num_pins = 0;
> +
> + switch (pinctrl->tps->chip_id) {
See below.
> @@ -320,8 +494,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)
> return -ENOMEM;
> pctrl_desc->name = dev_name(dev);
> pctrl_desc->owner = THIS_MODULE;
> - pctrl_desc->pins = tps6594_pins;
> - pctrl_desc->npins = ARRAY_SIZE(tps6594_pins);
> + switch (tps->chip_id) {
See below.
> @@ -329,8 +513,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)
> if (!pinctrl)
> return -ENOMEM;
> pinctrl->tps = dev_get_drvdata(dev->parent);
> - pinctrl->funcs = pinctrl_functions;
> - pinctrl->pins = tps6594_pins;
> + switch (pinctrl->tps->chip_id) {
See below.
> @@ -338,8 +532,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)
>
> config.parent = tps->dev;
> config.regmap = tps->regmap;
> - config.ngpio = TPS6594_PINCTRL_PINS_NB;
> - config.ngpio_per_reg = 8;
> + switch (pinctrl->tps->chip_id) {
Regarding all the switch case, I think you should try and put all the
differences inside the `struct tps6594_pinctrl`. This way most of the
functions (if not all of them) could be writen without the switch case,
making them more readable and straight forward to understand.
You already have some switch case in the probe, why not fill the `struct
tps6594_pintcl` there and use these new fileds in the different
function.
It's not pretty today, imagine if in the future there is more supported
chip, it would be quite unreadable IMAO.
Other than that the changes looks fine to me. I will have to boot a
board with TPS6594 to check that whole series did not break anything.
Please add me to your Cc for the next round.
Best regards,
--
Esteban "Skallwar" Blanc
BayLibre
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-02-29 13:57 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 9:36 [PATCH v2 00/14] Add support for TI TPS65224 PMIC Bhargav Raviprakash
2024-02-23 9:36 ` [PATCH v2 01/14] mfd: tps6594: Add register definitions " Bhargav Raviprakash
2024-02-26 11:07 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 02/14] mfd: tps6594: use volatile_table instead of volatile_reg Bhargav Raviprakash
2024-02-26 11:15 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 03/14] mfd: tps6594: add regmap config in match data Bhargav Raviprakash
2024-02-26 11:35 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 04/14] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC Bhargav Raviprakash
2024-02-23 18:37 ` Conor Dooley
2024-02-23 9:36 ` [PATCH v2 05/14] mfd: tps6594-i2c: Add TI TPS65224 PMIC I2C Bhargav Raviprakash
2024-02-26 11:40 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 06/14] mfd: tps6594-spi: Add TI TPS65224 PMIC SPI Bhargav Raviprakash
2024-02-26 11:52 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 07/14] mfd: tps6594-core: Add TI TPS65224 PMIC core Bhargav Raviprakash
2024-02-26 12:17 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 08/14] misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM Bhargav Raviprakash
2024-02-26 12:43 ` Julien Panis
2024-03-07 9:13 ` Bhargav Raviprakash
2024-02-23 9:36 ` [PATCH v2 09/14] misc: tps6594-esm: reversion check limited to TPS6594 family Bhargav Raviprakash
2024-02-26 12:56 ` Julien Panis
2024-02-23 9:36 ` [PATCH v2 10/14] misc: tps6594-esm: use regmap_field Bhargav Raviprakash
2024-02-23 9:36 ` [PATCH v2 11/14] misc: tps6594-esm: Add TI TPS65224 PMIC ESM Bhargav Raviprakash
2024-02-23 9:36 ` [PATCH v2 12/14] regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators Bhargav Raviprakash
2024-02-29 13:58 ` Mark Brown
2024-03-07 9:15 ` Bhargav Raviprakash
2024-02-29 14:42 ` Esteban Blanc
2024-02-29 14:49 ` Mark Brown
2024-03-07 9:18 ` Bhargav Raviprakash
2024-03-07 9:17 ` Bhargav Raviprakash
2024-02-23 9:37 ` [PATCH v2 13/14] pinctrl: pinctrl-tps6594: Add TPS65224 PMIC pinctrl and GPIO Bhargav Raviprakash
2024-02-29 13:24 ` Linus Walleij
2024-03-07 9:19 ` Bhargav Raviprakash
2024-03-07 9:36 ` Julien Panis
2024-02-29 13:56 ` Esteban Blanc [this message]
2024-02-23 9:37 ` [PATCH v2 14/14] arch: arm64: dts: ti: k3-am62p5-sk: Add TPS65224 PMIC support in AM62P dts Bhargav Raviprakash
2024-02-29 17:49 ` [PATCH v2 00/14] Add support for TI TPS65224 PMIC Lee Jones
2024-03-07 9:47 ` Bhargav Raviprakash
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=CZHM5FYHS6G0.295L6AYUNZCT@baylibre.com \
--to=eblanc@baylibre.com \
--cc=arnd@arndb.de \
--cc=bhargav.r@ltts.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jpanis@baylibre.com \
--cc=kristo@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.nirmaladevi@ltts.com \
--cc=nm@ti.com \
--cc=robh+dt@kernel.org \
--cc=vigneshr@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).