gpio: fxl6408: add optional reset and suspend/resume
cover gpio: fxl6408: add optional reset and suspend/resume
Two improvements to the fxl6408 gpio driver:
Add opitonal reset gpio control.
Add suspend/resume support.
Jisheng Zhang (2):
gpio: fxl6408: Add optional reset gpio control
gpio: fxl6408: Add suspend/resume support
drivers/gpio/gpio-fxl6408.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
Signature · 1 line
2.51.0
PATCH 1/2 gpio: fxl6408: Add optional reset gpio control
Add optional active low reset-gpios pin control. If present, de-assert the specified reset gpio pin to bring the chip out of reset.
--- drivers/gpio/gpio-fxl6408.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpio/gpio-fxl6408.c +5 -0
@@ -104,6 +104,7 @@ static int fxl6408_identify(struct device *dev, struct regmap *regmap)static int fxl6408_probe (struct i2c_client *client) {struct device *dev = &client->dev; +struct gpio_desc *reset_gpio;int ret;struct gpio_regmap_config gpio_config = { .parent = dev,
@@ -114,6 +115,10 @@ static int fxl6408_probe(struct i2c_client *client) .ngpio_per_reg = FXL6408_NGPIO, }; + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW ); +if (IS_ERR (reset_gpio)) +return dev_err_probe (dev,PTR_ERR (reset_gpio),"Failed to get reset gpio\n" ); + gpio_config.regmap =devm_regmap_init_i2c (client, ®map);if (IS_ERR (gpio_config.regmap)) return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
Signature · 1 line
2.51.0
kernel test robot
build botRe: [PATCH 1/2] gpio: fxl6408: Add optional reset gpio control
kernel test robot noticed the following build errors:
Hi Jisheng,
kernel test robot noticed the following build errors:
[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linus/master v6.18-rc4 next-20251031] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jisheng-Zhang/gpio-fxl6408-Add-optional-reset-gpio-control/20251102-182544 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20251102100515.9506-2-jszhang%40kernel.org patch subject: [PATCH 1/2] gpio: fxl6408: Add optional reset gpio control config: nios2-randconfig-r073-20251103 (https://download.01.org/0day-ci/archive/20251103/[email protected]/config) compiler: nios2-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251103/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/gpio/gpio-fxl6408.c: In function 'fxl6408_probe':
>> drivers/gpio/gpio-fxl6408.c:118:15: error: implicit declaration of function 'devm_gpiod_get_optional'; did you mean 'devm_regulator_get_optional'? [-Werror=implicit-function-declaration]
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
^~~~~~~~~~~~~~~~~~~~~~~
devm_regulator_get_optional
>> drivers/gpio/gpio-fxl6408.c:118:53: error: 'GPIOD_OUT_LOW' undeclared (first use in this function)
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
^~~~~~~~~~~~~ drivers/gpio/gpio-fxl6408.c:118:53: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
vim +118 drivers/gpio/gpio-fxl6408.c
103
104 static int fxl6408_probe(struct i2c_client *client)
105 {
106 struct device *dev = &client->dev;
107 struct gpio_desc *reset_gpio;
108 int ret;
109 struct gpio_regmap_config gpio_config = {
110 .parent = dev,
111 .ngpio = FXL6408_NGPIO,
112 .reg_dat_base = GPIO_REGMAP_ADDR(FXL6408_REG_INPUT_STATUS),
113 .reg_set_base = GPIO_REGMAP_ADDR(FXL6408_REG_OUTPUT),
114 .reg_dir_out_base = GPIO_REGMAP_ADDR(FXL6408_REG_IO_DIR),
115 .ngpio_per_reg = FXL6408_NGPIO,
116 };
117
> 118 reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
119 if (IS_ERR(reset_gpio))
120 return dev_err_probe(dev, PTR_ERR(reset_gpio), "Failed to get reset gpio\n");
121
122 gpio_config.regmap = devm_regmap_init_i2c(client, ®map);
123 if (IS_ERR(gpio_config.regmap))
124 return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
125 "failed to allocate register map\n");
126
127 ret = fxl6408_identify(dev, gpio_config.regmap);
128 if (ret)
129 return ret;
130
131 /* Disable High-Z of outputs, so that our OUTPUT updates actually take effect. */
132 ret = regmap_write(gpio_config.regmap, FXL6408_REG_OUTPUT_HIGH_Z, 0);
133 if (ret)
134 return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n");
135
136 return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
137 }
138
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 1/2] gpio: fxl6408: Add optional reset gpio control
In reply to Jisheng Zhangkernel test robot noticed the following build errors:
Hi Jisheng,
kernel test robot noticed the following build errors:
[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linus/master v6.18-rc4 next-20251031] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jisheng-Zhang/gpio-fxl6408-Add-optional-reset-gpio-control/20251102-182544 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20251102100515.9506-2-jszhang%40kernel.org patch subject: [PATCH 1/2] gpio: fxl6408: Add optional reset gpio control config: arm-randconfig-001-20251103 (https://download.01.org/0day-ci/archive/20251103/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project d2625a438020ad35330cda29c3def102c1687b1b) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251103/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/gpio/gpio-fxl6408.c:118:15: error: call to undeclared function 'devm_gpiod_get_optional'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
118 | reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
| ^
drivers/gpio/gpio-fxl6408.c:118:15: note: did you mean 'devm_regulator_get_optional'?
include/linux/regulator/consumer.h:163:32: note: 'devm_regulator_get_optional' declared here
163 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
| ^
>> drivers/gpio/gpio-fxl6408.c:118:53: error: use of undeclared identifier 'GPIOD_OUT_LOW'
118 | reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
| ^~~~~~~~~~~~~2 errors generated.
vim +/devm_gpiod_get_optional +118 drivers/gpio/gpio-fxl6408.c
103
104 static int fxl6408_probe(struct i2c_client *client)
105 {
106 struct device *dev = &client->dev;
107 struct gpio_desc *reset_gpio;
108 int ret;
109 struct gpio_regmap_config gpio_config = {
110 .parent = dev,
111 .ngpio = FXL6408_NGPIO,
112 .reg_dat_base = GPIO_REGMAP_ADDR(FXL6408_REG_INPUT_STATUS),
113 .reg_set_base = GPIO_REGMAP_ADDR(FXL6408_REG_OUTPUT),
114 .reg_dir_out_base = GPIO_REGMAP_ADDR(FXL6408_REG_IO_DIR),
115 .ngpio_per_reg = FXL6408_NGPIO,
116 };
117
> 118 reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
119 if (IS_ERR(reset_gpio))
120 return dev_err_probe(dev, PTR_ERR(reset_gpio), "Failed to get reset gpio\n");
121
122 gpio_config.regmap = devm_regmap_init_i2c(client, ®map);
123 if (IS_ERR(gpio_config.regmap))
124 return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
125 "failed to allocate register map\n");
126
127 ret = fxl6408_identify(dev, gpio_config.regmap);
128 if (ret)
129 return ret;
130
131 /* Disable High-Z of outputs, so that our OUTPUT updates actually take effect. */
132 ret = regmap_write(gpio_config.regmap, FXL6408_REG_OUTPUT_HIGH_Z, 0);
133 if (ret)
134 return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n");
135
136 return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
137 }
138
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 2/2 gpio: fxl6408: Add suspend/resume support
In reply to Jisheng ZhangCurrently, during suspend, do nothing; during resume, just sync the regmap cache to hw regs.
--- drivers/gpio/gpio-fxl6408.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpio/gpio-fxl6408.c +23 -0
@@ -43,6 +43,10 @@#define FXL6408_NGPIO 8 +struct fxl6408_chip { +struct regmap *regmap; +}; +static const struct regmap_range rd_range[] = { {FXL6408_REG_DEVICE_ID ,FXL6408_REG_DEVICE_ID }, {FXL6408_REG_IO_DIR ,FXL6408_REG_OUTPUT },
@@ -105,6 +109,7 @@ static int fxl6408_probe(struct i2c_client *client) {struct device *dev = &client->dev;struct gpio_desc *reset_gpio; +struct fxl6408_chip *chip;int ret;struct gpio_regmap_config gpio_config = { .parent = dev,
@@ -115,6 +120,10 @@ static int fxl6408_probe(struct i2c_client *client) .ngpio_per_reg = FXL6408_NGPIO, }; + chip =devm_kzalloc (dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW );if (IS_ERR (reset_gpio))return dev_err_probe (dev,PTR_ERR (reset_gpio),"Failed to get reset gpio\n" );
@@ -128,6 +137,9 @@ static int fxl6408_probe(struct i2c_client *client)if (ret)return ret; + chip->regmap = gpio_config.regmap; +i2c_set_clientdata (client, chip); +/* Disable High-Z of outputs, so that our OUTPUT updates actually take effect. */ ret =regmap_write (gpio_config.regmap,FXL6408_REG_OUTPUT_HIGH_Z ,0 );if (ret)
@@ -136,6 +148,16 @@ static int fxl6408_probe(struct i2c_client *client)return PTR_ERR_OR_ZERO (devm_gpio_regmap_register (dev, &gpio_config)); } +static int fxl6408_resume (struct device *dev) +{ +struct fxl6408_chip *chip =dev_get_drvdata (dev); + +regcache_mark_dirty (chip->regmap); +return regcache_sync (chip->regmap); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(fxl6408_pm_ops, NULL, fxl6408_resume); +static const __maybe_unused struct of_device_id fxl6408_dt_ids[] = { { .compatible ="fcs,fxl6408" }, { }
@@ -151,6 +173,7 @@ MODULE_DEVICE_TABLE(i2c, fxl6408_id);static struct i2c_driver fxl6408_driver = { .driver = { .name ="fxl6408" , + .pm =pm_sleep_ptr (&fxl6408_pm_ops), .of_match_table = fxl6408_dt_ids, }, .probe = fxl6408_probe,
Signature · 1 line
2.51.0