All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Cc: Shyam-sundar.S-k@amd.com, linus.walleij@linaro.org,
	linux-gpio@vger.kernel.org, mika.westerberg@linux.intel.com
Subject: Re: [PATCH v3 6/6] pinctrl: amd: Implement pinmux functionality
Date: Tue, 31 May 2022 13:32:28 +0300	[thread overview]
Message-ID: <YpXuvG04euX/rZr7@smile.fi.intel.com> (raw)
In-Reply-To: <20220531084322.1310250-7-Basavaraj.Natikar@amd.com>

On Tue, May 31, 2022 at 02:13:22PM +0530, Basavaraj Natikar wrote:
> Provide pinmux functionality by implementing pinmux_ops.

...

> +static int amd_set_mux(struct pinctrl_dev *pctrldev, unsigned int function, unsigned int group)
> +{
> +	struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctrldev);

Consider to use

	struct device *dev = ...;

and make code few lines shorter.

> +	struct pin_desc *pd;
> +	int ind, index;
> +
> +	if (!gpio_dev->iomux_base)
> +		return -EINVAL;
> +
> +	for (index = 0; index < NSELECTS; index++) {
> +		if (strcmp(gpio_dev->groups[group].name,  pmx_functions[function].groups[index]))
> +			continue;
> +
> +		if (readb(gpio_dev->iomux_base + pmx_functions[function].index) ==
> +				FUNCTION_INVALID) {
> +			dev_warn(&gpio_dev->pdev->dev,
> +				 "IOMUX_GPIO 0x%x not present or supported\n",
> +				 pmx_functions[function].index);
> +			return -EINVAL;
> +		}
> +
> +		writeb(index, gpio_dev->iomux_base + pmx_functions[function].index);
> +
> +		if (index != (readb(gpio_dev->iomux_base + pmx_functions[function].index) &
> +					FUNCTION_MASK)) {
> +			dev_warn(&gpio_dev->pdev->dev,
> +				 "IOMUX_GPIO 0x%x not present or supported\n",
> +				 pmx_functions[function].index);
> +			return -EINVAL;
> +		}
> +
> +		for (ind = 0; ind < gpio_dev->groups[group].npins; ind++) {
> +			if (strncmp(gpio_dev->groups[group].name, "IMX_F", strlen("IMX_F")))
> +				continue;
> +
> +			pd = pin_desc_get(gpio_dev->pctrl, gpio_dev->groups[group].pins[ind]);
> +			pd->mux_owner = gpio_dev->groups[group].name;
> +		}
> +		break;
> +	}
> +
> +	return 0;
> +}

...

> +#define AMD_PINCTRL_FUNC_GRP(_number, _func)						\
> +	[IMX_F##_func##_GPIO##_number] = PINCTRL_GRP("IMX_F"#_func "_GPIO"#_number,	\
> +						     AMD_PINS(_number), 1)

Slightly better:

#define AMD_PINCTRL_FUNC_GRP(_number, _func)					\
	[IMX_F##_func##_GPIO##_number] =					\
		PINCTRL_GRP("IMX_F"#_func "_GPIO"#_number, AMD_PINS(_number), 1)

...

> +#define AMD_PMUX_FUNC(_number) {						\
> +	.name = "iomux_gpio_"#_number,						\
> +	.groups = { "IMX_F0_GPIO"#_number, "IMX_F1_GPIO"#_number,		\
> +		    "IMX_F2_GPIO"#_number, "IMX_F3_GPIO"#_number },		\
> +	.index = _number,							\
> +	.ngroups = NSELECTS,							\
> +}

Slightly better (indentation, comma):

#define AMD_PMUX_FUNC(_number) {				\
	.name = "iomux_gpio_"#_number,				\
	.groups = {						\
		"IMX_F0_GPIO"#_number, "IMX_F1_GPIO"#_number,	\
		"IMX_F2_GPIO"#_number, "IMX_F3_GPIO"#_number,	\
	},							\
	.index = _number,					\
	.ngroups = NSELECTS,					\
}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2022-05-31 10:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31  8:43 [PATCH v3 0/6] Enhancements to AMD pinctrl and implementation of AMD pinmux Basavaraj Natikar
2022-05-31  8:43 ` [PATCH v3 1/6] pinctrl: Add pingroup and define PINCTRL_GRP Basavaraj Natikar
2022-05-31  9:19   ` Andy Shevchenko
2022-05-31 14:05     ` Basavaraj Natikar
2022-05-31 18:47       ` Andy Shevchenko
2022-05-31  8:43 ` [PATCH v3 2/6] pinctrl: amd: Remove amd_pingroup and use pingroup Basavaraj Natikar
2022-05-31 10:21   ` Andy Shevchenko
2022-05-31  8:43 ` [PATCH v3 3/6] pinctrl: amd: Use PINCTRL_GRP to manage pingroups Basavaraj Natikar
2022-05-31 10:22   ` Andy Shevchenko
2022-05-31  8:43 ` [PATCH v3 4/6] pinctrl: amd: Define and use AMD_PINS macro Basavaraj Natikar
2022-05-31 10:23   ` Andy Shevchenko
2022-05-31 13:58     ` Basavaraj Natikar
2022-05-31 15:47       ` Andy Shevchenko
2022-05-31  8:43 ` [PATCH v3 5/6] pinctrl: amd: Add amd_get_iomux_res function Basavaraj Natikar
2022-05-31 10:26   ` Andy Shevchenko
2022-05-31  8:43 ` [PATCH v3 6/6] pinctrl: amd: Implement pinmux functionality Basavaraj Natikar
2022-05-31 10:32   ` Andy Shevchenko [this message]

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=YpXuvG04euX/rZr7@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.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.