linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Qianggui Song <qianggui.song@amlogic.com>
To: Jerome Brunet <jbrunet@baylibre.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	<linux-gpio@vger.kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Hanjie Lin <hanjie.lin@amlogic.com>,
	Jianxin Pan <jianxin.pan@amlogic.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Kevin Hilman <khilman@baylibre.com>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Carlo Caione <carlo@caione.org>,
	linux-amlogic@lists.infradead.org,
	Xingyu Chen <xingyu.chen@amlogic.com>
Subject: Re: [PATCH v4 2/4] pinctrl: meson: add a new callback for SoCs fixup
Date: Tue, 5 Nov 2019 10:39:04 +0800	[thread overview]
Message-ID: <25885aef-1ea6-600e-c022-6f0385d78559@amlogic.com> (raw)
In-Reply-To: <1jeeyo3wdg.fsf@starbuckisacylon.baylibre.com>



On 2019/11/4 15:59, Jerome Brunet wrote:
> 
> On Fri 25 Oct 2019 at 13:49, Qianggui Song <qianggui.song@amlogic.com> wrote:
> 
>> In meson_pinctrl_parse_dt, it contains two parts: reg parsing and
>> SoC relative fixup for AO. Several fixups in the same code make it hard
>> to maintain, so move all fixups to each SoC's callback and make
>> meson_pinctrl_parse_dt just do the reg parsing, separate these two
>> parts.Overview of all current Meson SoCs fixup is as below:
>>
>> +------+--------------------------------------+--------------------------+
>> |      |                                      |                          |
>> | SoC  |                EE domain             |        AO domain         |
>> +------+--------------------------------------+--------------------------+
>> |m8    | parse regs:                          | parse regs:              |
>> |m8b   |   gpio,mux,pull,pull-enable(skip ds) |    gpio,mux,pull(skip ds)|
>> |gxl   | fixup:                               | fixup:                   |
>> |gxbb  |   no                                 |     pull-enable = pull   |
>> |axg   |                                      |                          |
>> +------+--------------------------------------+--------------------------+
>> |g12a  | parse regs:                          | parse regs:              |
>> |sm1   |   gpio,mux,pull,pull-enable,ds       |   gpio,mux,ds            |
>> |      | fixup:                               | fixup:                   |
>> |      |   no                                 |   pull = gpio            |
>> |      |                                      |   pull-enable = gpio     |
>> +------+--------------------------------------+--------------------------+
>> |a1 or | parse regs:                                                     |
>> |later |  gpio/mux (without ao domain)                                   |
>> |SoCs  | fixup:                                                          |
>> |      |  pull=gpio; pull-enable=gpio; ds=gpio                           |
>> +------+-----------------------------------------------------------------+
>>
>> Signed-off-by: Qianggui Song <qianggui.song@amlogic.com>
>> ---
>>  drivers/pinctrl/meson/pinctrl-meson-axg.c  | 11 +++++++++++
>>  drivers/pinctrl/meson/pinctrl-meson-g12a.c |  9 +++++++++
>>  drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 11 +++++++++++
>>  drivers/pinctrl/meson/pinctrl-meson-gxl.c  | 11 +++++++++++
>>  drivers/pinctrl/meson/pinctrl-meson.c      |  9 +++++----
>>  drivers/pinctrl/meson/pinctrl-meson.h      |  3 +++
>>  drivers/pinctrl/meson/pinctrl-meson8.c     | 11 +++++++++++
>>  drivers/pinctrl/meson/pinctrl-meson8b.c    | 11 +++++++++++
>>  8 files changed, 72 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson-axg.c b/drivers/pinctrl/meson/pinctrl-meson-axg.c
>> index ad502eda4afa..9c07f4423c37 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson-axg.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson-axg.c
>> @@ -1040,6 +1040,16 @@
>>  	.num_pmx_banks = ARRAY_SIZE(meson_axg_aobus_pmx_banks),
>>  };
>>  
>> +static int meson_axg_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	if (!pc->reg_pull)
>> +		return -EINVAL;
>> +
>> +	pc->reg_pullen = pc->reg_pull;
>> +
>> +	return 0;
>> +}
>> +
>>  static struct meson_pinctrl_data meson_axg_periphs_pinctrl_data = {
>>  	.name		= "periphs-banks",
>>  	.pins		= meson_axg_periphs_pins,
>> @@ -1066,6 +1076,7 @@
>>  	.num_banks	= ARRAY_SIZE(meson_axg_aobus_banks),
>>  	.pmx_ops	= &meson_axg_pmx_ops,
>>  	.pmx_data	= &meson_axg_aobus_pmx_banks_data,
>> +	.parse_dt	= meson_axg_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson_axg_pinctrl_dt_match[] = {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c
>> index 582665fd362a..41850e3c0091 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c
>> @@ -1362,6 +1362,14 @@
>>  	.num_pmx_banks	= ARRAY_SIZE(meson_g12a_aobus_pmx_banks),
>>  };
>>  
>> +static int meson_g12a_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	pc->reg_pull = pc->reg_gpio;
>> +	pc->reg_pullen = pc->reg_gpio;
>> +
>> +	return 0;
>> +}
>> +
>>  static struct meson_pinctrl_data meson_g12a_periphs_pinctrl_data = {
>>  	.name		= "periphs-banks",
>>  	.pins		= meson_g12a_periphs_pins,
>> @@ -1388,6 +1396,7 @@
>>  	.num_banks	= ARRAY_SIZE(meson_g12a_aobus_banks),
>>  	.pmx_ops	= &meson_axg_pmx_ops,
>>  	.pmx_data	= &meson_g12a_aobus_pmx_banks_data,
>> +	.parse_dt	= meson_g12a_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson_g12a_pinctrl_dt_match[] = {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
>> index 5bfa56f3847e..f5494a948200 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
>> @@ -827,6 +827,16 @@
>>  	BANK("AO",   GPIOAO_0,  GPIOAO_13, 0, 13, 0,  16, 0, 0,   0,  0,  0, 16,  1,  0),
>>  };
>>  
>> +static int meson_gxbb_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	if (!pc->reg_pull)
>> +		return -EINVAL;
>> +
>> +	pc->reg_pullen = pc->reg_pull;
>> +
>> +	return 0;
>> +}
> 
> Can you share the definition of this function instead of repeating it ?
> 
Seems like this common function can only be placed in pinctrl-meson.c, I
will try to write a meson_aobus_parse_dt_extra in pinctrl-meson.c and
assign it to each SoCs  driver before g12a.
>> +
>>  static struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data = {
>>  	.name		= "periphs-banks",
>>  	.pins		= meson_gxbb_periphs_pins,
>> @@ -851,6 +861,7 @@
>>  	.num_funcs	= ARRAY_SIZE(meson_gxbb_aobus_functions),
>>  	.num_banks	= ARRAY_SIZE(meson_gxbb_aobus_banks),
>>  	.pmx_ops	= &meson8_pmx_ops,
>> +	.parse_dt	= meson_gxbb_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson_gxbb_pinctrl_dt_match[] = {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
>> index 72c5373c8dc1..943fb27dab08 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
>> @@ -796,6 +796,16 @@
>>  	BANK("AO",   GPIOAO_0,  GPIOAO_9, 0, 9, 0,  16, 0, 0,   0,  0,  0, 16,  1,  0),
>>  };
>>  
>> +static int meson_gxl_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	if (!pc->reg_pull)
>> +		return -EINVAL;
>> +
>> +	pc->reg_pullen = pc->reg_pull;
>> +
>> +	return 0;
>> +}
> 
> Same
will do it for above and below other platform.
> 
>> +
>>  static struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data = {
>>  	.name		= "periphs-banks",
>>  	.pins		= meson_gxl_periphs_pins,
>> @@ -820,6 +830,7 @@
>>  	.num_funcs	= ARRAY_SIZE(meson_gxl_aobus_functions),
>>  	.num_banks	= ARRAY_SIZE(meson_gxl_aobus_banks),
>>  	.pmx_ops	= &meson8_pmx_ops,
>> +	.parse_dt 	= meson_gxl_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson_gxl_pinctrl_dt_match[] = {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
>> index 8bba9d053d9f..e182583422a4 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
>> @@ -677,14 +677,12 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc,
>>  	}
>>  
>>  	pc->reg_pull = meson_map_resource(pc, gpio_np, "pull");
>> -	/* Use gpio region if pull one is not present */
>>  	if (IS_ERR(pc->reg_pull))
>> -		pc->reg_pull = pc->reg_gpio;
>> +		pc->reg_pull = NULL;
> 
> Instead of doing this fixup, could modifhy meson_map_ressourse() to
> return NULL instead of -ENOENT ?
> 
> Then you should IS_ERR_OR_NULL() for "mux" and "gpio" and just IS_ERR()
> for the rest
> 
Ok, will modify this in the next patch set
>>  
>>  	pc->reg_pullen = meson_map_resource(pc, gpio_np, "pull-enable");
>> -	/* Use pull region if pull-enable one is not present */
>>  	if (IS_ERR(pc->reg_pullen))
>> -		pc->reg_pullen = pc->reg_pull;
>> +		pc->reg_pullen = NULL;
>>  
>>  	pc->reg_ds = meson_map_resource(pc, gpio_np, "ds");
>>  	if (IS_ERR(pc->reg_ds)) {
>> @@ -692,6 +690,9 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc,
>>  		pc->reg_ds = NULL;
>>  	}
>>  
>> +	if (pc->data->parse_dt)
>> +		return pc->data->parse_dt(pc);
>> +
>>  	return 0;
>>  }
>>  
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
>> index c696f3241a36..d570f7c53045 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson.h
>> +++ b/drivers/pinctrl/meson/pinctrl-meson.h
>> @@ -11,6 +11,8 @@
>>  #include <linux/regmap.h>
>>  #include <linux/types.h>
>>  
>> +struct meson_pinctrl;
>> +
>>  /**
>>   * struct meson_pmx_group - a pinmux group
>>   *
>> @@ -114,6 +116,7 @@ struct meson_pinctrl_data {
>>  	unsigned int num_banks;
>>  	const struct pinmux_ops *pmx_ops;
>>  	void *pmx_data;
>> +	int (*parse_dt)(struct meson_pinctrl *pc);
>>  };
>>  
>>  struct meson_pinctrl {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson8.c b/drivers/pinctrl/meson/pinctrl-meson8.c
>> index 0b97befa6335..65c70c9b7070 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson8.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson8.c
>> @@ -1079,6 +1079,16 @@
>>  	BANK("AO",   GPIOAO_0, GPIO_TEST_N, 0, 13, 0, 16,  0,  0,  0,  0,  0, 16,  1,  0),
>>  };
>>  
>> +static int meson8_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	if (!pc->reg_pull)
>> +		return -EINVAL;
>> +
>> +	pc->reg_pullen = pc->reg_pull;
>> +
>> +	return 0;
>> +}
>> +
>>  static struct meson_pinctrl_data meson8_cbus_pinctrl_data = {
>>  	.name		= "cbus-banks",
>>  	.pins		= meson8_cbus_pins,
>> @@ -1103,6 +1113,7 @@
>>  	.num_funcs	= ARRAY_SIZE(meson8_aobus_functions),
>>  	.num_banks	= ARRAY_SIZE(meson8_aobus_banks),
>>  	.pmx_ops	= &meson8_pmx_ops,
>> +	.parse_dt	= &meson8_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson8_pinctrl_dt_match[] = {
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c
>> index a7de388388e6..85dc12e0c839 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson8b.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson8b.c
>> @@ -938,6 +938,16 @@
>>  	BANK("AO",   GPIOAO_0, GPIO_TEST_N, 0, 13, 0,  16, 0, 0,  0,  0,  0, 16,  1,  0),
>>  };
>>  
>> +static int meson8b_aobus_parse_dt_extra(struct meson_pinctrl *pc)
>> +{
>> +	if (!pc->reg_pull)
>> +		return -EINVAL;
>> +
>> +	pc->reg_pullen = pc->reg_pull;
>> +
>> +	return 0;
>> +}
>> +
>>  static struct meson_pinctrl_data meson8b_cbus_pinctrl_data = {
>>  	.name		= "cbus-banks",
>>  	.pins		= meson8b_cbus_pins,
>> @@ -962,6 +972,7 @@
>>  	.num_funcs	= ARRAY_SIZE(meson8b_aobus_functions),
>>  	.num_banks	= ARRAY_SIZE(meson8b_aobus_banks),
>>  	.pmx_ops	= &meson8_pmx_ops,
>> +	.parse_dt	= &meson8b_aobus_parse_dt_extra,
>>  };
>>  
>>  static const struct of_device_id meson8b_pinctrl_dt_match[] = {
> 
> .
> 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2019-11-05  2:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 11:49 [PATCH v4 0/4] pinctrl: meson-a1: add pinctrl driver Qianggui Song
2019-10-25 11:49 ` [PATCH v4 1/4] pinctrl: add compatible for Amlogic Meson A1 pin controller Qianggui Song
2019-11-04 15:31   ` Linus Walleij
2019-11-04 15:33     ` Linus Walleij
2019-10-25 11:49 ` [PATCH v4 2/4] pinctrl: meson: add a new callback for SoCs fixup Qianggui Song
2019-11-04  7:59   ` Jerome Brunet
2019-11-05  2:39     ` Qianggui Song [this message]
2019-10-25 11:49 ` [PATCH v4 3/4] pinctrl: meson: add pinctrl driver support for Meson-A1 SoC Qianggui Song
2019-10-25 11:49 ` [PATCH v4 4/4] arm64: dts: meson: a1: add pinctrl controller support Qianggui Song

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=25885aef-1ea6-600e-c022-6f0385d78559@amlogic.com \
    --to=qianggui.song@amlogic.com \
    --cc=carlo@caione.org \
    --cc=hanjie.lin@amlogic.com \
    --cc=jbrunet@baylibre.com \
    --cc=jianxin.pan@amlogic.com \
    --cc=khilman@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=xingyu.chen@amlogic.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).