LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] pinctrl: support to save and restore GPIO conf.
@ 2021-08-31 5:28 Prathamesh Shete
2021-08-31 5:28 ` [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register Prathamesh Shete
2021-08-31 5:28 ` [PATCH 2/2] pinctrl: tegra: Implement pinmux register save and restore Prathamesh Shete
0 siblings, 2 replies; 5+ messages in thread
From: Prathamesh Shete @ 2021-08-31 5:28 UTC (permalink / raw)
To: linus.walleij, thierry.reding, jonathanh, ldewangan, linux-gpio,
linux-tegra, linux-kernel
Cc: smangipudi, pshete
From: pshete <pshete@nvidia.com>
This change adds support to save and restore GPIO configurations
Laxman Dewangan (2):
pinctrl: pimux: Add support to save and restore HW register
pinctrl: tegra: Implement pinmux register save and restore
drivers/pinctrl/pinmux.c | 24 ++++++++++
drivers/pinctrl/pinmux.h | 18 ++++++++
drivers/pinctrl/tegra/pinctrl-tegra.c | 66 +++++++++++++++++++++++++++
drivers/pinctrl/tegra/pinctrl-tegra.h | 1 +
include/linux/pinctrl/pinmux.h | 9 ++++
5 files changed, 118 insertions(+)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register
2021-08-31 5:28 [PATCH 0/2] pinctrl: support to save and restore GPIO conf Prathamesh Shete
@ 2021-08-31 5:28 ` Prathamesh Shete
2021-08-31 8:13 ` Mikko Perttunen
2021-08-31 14:28 ` kernel test robot
2021-08-31 5:28 ` [PATCH 2/2] pinctrl: tegra: Implement pinmux register save and restore Prathamesh Shete
1 sibling, 2 replies; 5+ messages in thread
From: Prathamesh Shete @ 2021-08-31 5:28 UTC (permalink / raw)
To: linus.walleij, thierry.reding, jonathanh, ldewangan, linux-gpio,
linux-tegra, linux-kernel
Cc: smangipudi, pshete
From: Laxman Dewangan <ldewangan@nvidia.com>
Add support to save and restore the pincontrol HW register
for GPIO mode configurations. This helps in changing the
pin configure only during suspend and restore in resume.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: pshete <pshete@nvidia.com>
---
drivers/pinctrl/pinmux.c | 24 ++++++++++++++++++++++++
drivers/pinctrl/pinmux.h | 18 ++++++++++++++++++
include/linux/pinctrl/pinmux.h | 9 +++++++++
3 files changed, 51 insertions(+)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 6cdbd9ccf2f0..66fc0ca22623 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -317,6 +317,30 @@ int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
return ret;
}
+int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin)
+{
+ const struct pinmux_ops *ops = pctldev->desc->pmxops;
+
+ if (ops->gpio_save_config)
+ return ops->gpio_save_config(pctldev, range, pin);
+
+ return 0;
+}
+
+int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin)
+{
+ const struct pinmux_ops *ops = pctldev->desc->pmxops;
+
+ if (ops->gpio_restore_config)
+ return ops->gpio_restore_config(pctldev, range, pin);
+
+ return 0;
+}
+
static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
const char *function)
{
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 78c3a31be882..425c31a0115b 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -31,6 +31,12 @@ int pinmux_map_to_setting(const struct pinctrl_map *map,
void pinmux_free_setting(const struct pinctrl_setting *setting);
int pinmux_enable_setting(const struct pinctrl_setting *setting);
void pinmux_disable_setting(const struct pinctrl_setting *setting);
+int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin);
+int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin);
#else
@@ -89,6 +95,18 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
{
}
+int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin)
+{
+ return 0;
+}
+int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned pin)
+{
+ return 0;
+}
#endif
#if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h
index 9a647fa5c8f1..cca87586d8c1 100644
--- a/include/linux/pinctrl/pinmux.h
+++ b/include/linux/pinctrl/pinmux.h
@@ -53,6 +53,8 @@ struct pinctrl_dev;
* depending on whether the GPIO is configured as input or output,
* a direction selector function may be implemented as a backing
* to the GPIO controllers that need pin muxing.
+ * @gpio_save_config: Save the GPIo configurations.
+ * @gpio_restore_config: Restore GPIO configurations.
* @strict: do not allow simultaneous use of the same pin for GPIO and another
* function. Check both gpio_owner and mux_owner strictly before approving
* the pin request.
@@ -79,6 +81,13 @@ struct pinmux_ops {
struct pinctrl_gpio_range *range,
unsigned offset,
bool input);
+ int (*gpio_save_config) (struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned offset);
+ int (*gpio_restore_config) (struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned offset);
+
bool strict;
};
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] pinctrl: tegra: Implement pinmux register save and restore
2021-08-31 5:28 [PATCH 0/2] pinctrl: support to save and restore GPIO conf Prathamesh Shete
2021-08-31 5:28 ` [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register Prathamesh Shete
@ 2021-08-31 5:28 ` Prathamesh Shete
1 sibling, 0 replies; 5+ messages in thread
From: Prathamesh Shete @ 2021-08-31 5:28 UTC (permalink / raw)
To: linus.walleij, thierry.reding, jonathanh, ldewangan, linux-gpio,
linux-tegra, linux-kernel
Cc: smangipudi, pshete
From: Laxman Dewangan <ldewangan@nvidia.com>
Implement the pinmux register save and restore for the GPIO
configuration of pins. This helps in changing the pins
configuration for suspend state only.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: pshete <pshete@nvidia.com>
---
drivers/pinctrl/tegra/pinctrl-tegra.c | 66 +++++++++++++++++++++++++++
drivers/pinctrl/tegra/pinctrl-tegra.h | 1 +
2 files changed, 67 insertions(+)
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index 195cfe557511..7f947c952e09 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -275,6 +275,66 @@ static int tegra_pinctrl_set_mux(struct pinctrl_dev *pctldev,
return 0;
}
+static int tegra_pinctrl_gpio_save_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned offset)
+{
+ struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
+ const struct tegra_pingroup *g;
+ unsigned group, num_pins;
+ const unsigned *pins;
+ int ret;
+
+ for (group = 0; group < pmx->soc->ngroups; ++group) {
+ ret = tegra_pinctrl_get_group_pins(pctldev, group, &pins, &num_pins);
+ if (ret < 0 || num_pins != 1)
+ continue;
+ if (offset == pins[0])
+ break;
+ }
+
+ if (group == pmx->soc->ngroups) {
+ dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset);
+ return -EINVAL;
+ }
+
+ g = &pmx->soc->groups[group];
+ if (g->mux_reg >= 0)
+ pmx->gpio_conf[offset] = pmx_readl(pmx, g->mux_bank, g->mux_reg);
+
+ return 0;
+}
+
+static int tegra_pinctrl_gpio_restore_config(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned offset)
+{
+ struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
+ const struct tegra_pingroup *g;
+ unsigned group, num_pins;
+ const unsigned *pins;
+ int ret;
+
+ for (group = 0; group < pmx->soc->ngroups; ++group) {
+ ret = tegra_pinctrl_get_group_pins(pctldev, group, &pins, &num_pins);
+ if (ret < 0 || num_pins != 1)
+ continue;
+ if (offset == pins[0])
+ break;
+ }
+
+ if (group == pmx->soc->ngroups) {
+ dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset);
+ return -EINVAL;
+ }
+
+ g = &pmx->soc->groups[group];
+ if (g->mux_reg >= 0)
+ pmx_writel(pmx, pmx->gpio_conf[offset], g->mux_bank, g->mux_reg);
+
+ return 0;
+}
+
static int tegra_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev,
struct pinctrl_gpio_range *range,
unsigned int offset)
@@ -326,6 +386,8 @@ static const struct pinmux_ops tegra_pinmux_ops = {
.set_mux = tegra_pinctrl_set_mux,
.gpio_request_enable = tegra_pinctrl_gpio_request_enable,
.gpio_disable_free = tegra_pinctrl_gpio_disable_free,
+ .gpio_save_config = tegra_pinctrl_gpio_save_config,
+ .gpio_restore_config = tegra_pinctrl_gpio_restore_config,
};
static int tegra_pinconf_reg(struct tegra_pmx *pmx,
@@ -826,6 +888,10 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
if (!pmx->backup_regs)
return -ENOMEM;
+ pmx->gpio_conf = devm_kzalloc(&pdev->dev, backup_regs_size, GFP_KERNEL);
+ if (!pmx->gpio_conf)
+ return -ENOMEM;
+
for (i = 0; i < pmx->nbanks; i++) {
pmx->regs[i] = devm_platform_ioremap_resource(pdev, i);
if (IS_ERR(pmx->regs[i]))
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.h b/drivers/pinctrl/tegra/pinctrl-tegra.h
index fcad7f74c5a2..c08c676bfa03 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.h
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.h
@@ -18,6 +18,7 @@ struct tegra_pmx {
int nbanks;
void __iomem **regs;
u32 *backup_regs;
+ u32 *gpio_conf;
};
enum tegra_pinconf_param {
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register
2021-08-31 5:28 ` [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register Prathamesh Shete
@ 2021-08-31 8:13 ` Mikko Perttunen
2021-08-31 14:28 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: Mikko Perttunen @ 2021-08-31 8:13 UTC (permalink / raw)
To: Prathamesh Shete, linus.walleij, thierry.reding, jonathanh,
ldewangan, linux-gpio, linux-tegra, linux-kernel
Cc: smangipudi
On 8/31/21 8:28 AM, Prathamesh Shete wrote:
> From: Laxman Dewangan <ldewangan@nvidia.com>
>
> Add support to save and restore the pincontrol HW register
> for GPIO mode configurations. This helps in changing the
> pin configure only during suspend and restore in resume.
Aren't we already saving all registers during suspend and restoring
during resume?
>
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> Signed-off-by: pshete <pshete@nvidia.com>
Needs full name. Also, there is a typo in the commit title, and it is
quite vague (what HW register?)
Cheers,
Mikko
> ---
> drivers/pinctrl/pinmux.c | 24 ++++++++++++++++++++++++
> drivers/pinctrl/pinmux.h | 18 ++++++++++++++++++
> include/linux/pinctrl/pinmux.h | 9 +++++++++
> 3 files changed, 51 insertions(+)
>
> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index 6cdbd9ccf2f0..66fc0ca22623 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -317,6 +317,30 @@ int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
> return ret;
> }
>
> +int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin)
> +{
> + const struct pinmux_ops *ops = pctldev->desc->pmxops;
> +
> + if (ops->gpio_save_config)
> + return ops->gpio_save_config(pctldev, range, pin);
> +
> + return 0;
> +}
> +
> +int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin)
> +{
> + const struct pinmux_ops *ops = pctldev->desc->pmxops;
> +
> + if (ops->gpio_restore_config)
> + return ops->gpio_restore_config(pctldev, range, pin);
> +
> + return 0;
> +}
> +
> static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
> const char *function)
> {
> diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
> index 78c3a31be882..425c31a0115b 100644
> --- a/drivers/pinctrl/pinmux.h
> +++ b/drivers/pinctrl/pinmux.h
> @@ -31,6 +31,12 @@ int pinmux_map_to_setting(const struct pinctrl_map *map,
> void pinmux_free_setting(const struct pinctrl_setting *setting);
> int pinmux_enable_setting(const struct pinctrl_setting *setting);
> void pinmux_disable_setting(const struct pinctrl_setting *setting);
> +int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin);
> +int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin);
>
> #else
>
> @@ -89,6 +95,18 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
> {
> }
>
> +int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin)
> +{
> + return 0;
> +}
> +int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned pin)
> +{
> + return 0;
> +}
> #endif
>
> #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
> diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h
> index 9a647fa5c8f1..cca87586d8c1 100644
> --- a/include/linux/pinctrl/pinmux.h
> +++ b/include/linux/pinctrl/pinmux.h
> @@ -53,6 +53,8 @@ struct pinctrl_dev;
> * depending on whether the GPIO is configured as input or output,
> * a direction selector function may be implemented as a backing
> * to the GPIO controllers that need pin muxing.
> + * @gpio_save_config: Save the GPIo configurations.
> + * @gpio_restore_config: Restore GPIO configurations.
> * @strict: do not allow simultaneous use of the same pin for GPIO and another
> * function. Check both gpio_owner and mux_owner strictly before approving
> * the pin request.
> @@ -79,6 +81,13 @@ struct pinmux_ops {
> struct pinctrl_gpio_range *range,
> unsigned offset,
> bool input);
> + int (*gpio_save_config) (struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned offset);
> + int (*gpio_restore_config) (struct pinctrl_dev *pctldev,
> + struct pinctrl_gpio_range *range,
> + unsigned offset);
> +
> bool strict;
> };
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register
2021-08-31 5:28 ` [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register Prathamesh Shete
2021-08-31 8:13 ` Mikko Perttunen
@ 2021-08-31 14:28 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-08-31 14:28 UTC (permalink / raw)
To: Prathamesh Shete, linus.walleij, thierry.reding, jonathanh,
ldewangan, linux-gpio, linux-tegra, linux-kernel
Cc: kbuild-all, smangipudi, pshete
[-- Attachment #1: Type: text/plain, Size: 2546 bytes --]
Hi Prathamesh,
I love your patch! Perhaps something to improve:
[auto build test WARNING on pinctrl/devel]
[also build test WARNING on tegra/for-next v5.14 next-20210831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Prathamesh-Shete/pinctrl-support-to-save-and-restore-GPIO-conf/20210831-133414
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/8c99cc4cd4b322e1a4dd6fb0e031a432ad768596
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Prathamesh-Shete/pinctrl-support-to-save-and-restore-GPIO-conf/20210831-133414
git checkout 8c99cc4cd4b322e1a4dd6fb0e031a432ad768596
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=s390
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from drivers/pinctrl/core.c:36:
>> drivers/pinctrl/pinmux.h:98:5: warning: no previous prototype for 'pinmux_gpio_save_config' [-Wmissing-prototypes]
98 | int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
| ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pinctrl/pinmux.h:104:5: warning: no previous prototype for 'pinmux_gpio_restore_config' [-Wmissing-prototypes]
104 | int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/pinmux_gpio_save_config +98 drivers/pinctrl/pinmux.h
97
> 98 int pinmux_gpio_save_config(struct pinctrl_dev *pctldev,
99 struct pinctrl_gpio_range *range,
100 unsigned pin)
101 {
102 return 0;
103 }
> 104 int pinmux_gpio_restore_config(struct pinctrl_dev *pctldev,
105 struct pinctrl_gpio_range *range,
106 unsigned pin)
107 {
108 return 0;
109 }
110 #endif
111
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28344 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-31 14:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 5:28 [PATCH 0/2] pinctrl: support to save and restore GPIO conf Prathamesh Shete
2021-08-31 5:28 ` [PATCH 1/2] pinctrl: pimux: Add support to save and restore HW register Prathamesh Shete
2021-08-31 8:13 ` Mikko Perttunen
2021-08-31 14:28 ` kernel test robot
2021-08-31 5:28 ` [PATCH 2/2] pinctrl: tegra: Implement pinmux register save and restore Prathamesh Shete
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).