linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] feat(kernel/pca963x): implement power management
@ 2023-12-10 11:46 Amitesh Singh
  2023-12-10 22:37 ` kernel test robot
  2023-12-13 11:47 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Amitesh Singh @ 2023-12-10 11:46 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Lee Jones, linux-leds, linux-kernel

 From a22dbd7390ce875e81d67f14f05f593d7f03d5c1 Mon Sep 17 00:00:00 2001
From: Amitesh Singh <singh.amitesh@gmail.com>
Date: Fri, 8 Dec 2023 15:08:33 +0530
Subject: [PATCH] feat(kernel/pca963x): implement power management

This implements power management in upstream driver
for pca9633 which enables device sleep and resume
on system-wide sleep/hibernation

Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
---
  drivers/leds/leds-pca963x.c | 41 +++++++++++++++++++++++++++++++++++++
  1 file changed, 41 insertions(+)

diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 47223c850e4b..462f917dc986 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -39,6 +39,7 @@
  #define PCA963X_LED_PWM		0x2	/* Controlled through PWM */
  #define PCA963X_LED_GRP_PWM	0x3	/* Controlled through PWM/GRPPWM */

+#define PCA963X_MODE1_SLEEP     0x04    /* Normal mode or Low Power 
mode, oscillator off */
  #define PCA963X_MODE2_OUTDRV	0x04	/* Open-drain or totem pole */
  #define PCA963X_MODE2_INVRT	0x10	/* Normal or inverted direction */
  #define PCA963X_MODE2_DMBLNK	0x20	/* Enable blinking */
@@ -380,6 +381,45 @@ static int pca963x_register_leds(struct i2c_client 
*client,
  	return ret;
  }

+#ifdef CONFIG_PM
+static int pca963x_suspend(struct device *dev)
+{
+	struct pca963x *chip;
+	u8 reg;
+
+	chip = dev_get_drvdata(dev);
+
+	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+	reg = reg | (1 << PCA963X_MODE1_SLEEP);
+	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+	return 0;
+}
+
+static int pca963x_resume(struct device *dev)
+{
+	struct pca963x *chip;
+	u8 reg;
+
+	chip = dev_get_drvdata(dev);
+
+	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
+	reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
+	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
+
+	return 0;
+}
+
+static const struct dev_pm_ops pca963x_pmops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume)
+};
+
+#define PCA963X_SMBUS_PMOPS (&pca963x_pmops)
+
+#else
+#define PCA963X_SMBUS_PMOPS NULL
+#endif
+
  static const struct of_device_id of_pca963x_match[] = {
  	{ .compatible = "nxp,pca9632", },
  	{ .compatible = "nxp,pca9633", },
@@ -430,6 +470,7 @@ static struct i2c_driver pca963x_driver = {
  	.driver = {
  		.name	= "leds-pca963x",
  		.of_match_table = of_pca963x_match,
+		.pm = PCA963X_SMBUS_PMOPS
  	},
  	.probe = pca963x_probe,
  	.id_table = pca963x_id,
-- 
2.43.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] feat(kernel/pca963x): implement power management
  2023-12-10 11:46 [PATCH] feat(kernel/pca963x): implement power management Amitesh Singh
@ 2023-12-10 22:37 ` kernel test robot
  2023-12-13 11:47 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-12-10 22:37 UTC (permalink / raw)
  To: Amitesh Singh, Pavel Machek
  Cc: oe-kbuild-all, Lee Jones, linux-leds, linux-kernel

Hi Amitesh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on lee-leds/for-leds-next]
[also build test WARNING on linus/master v6.7-rc4 next-20231208]
[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/Amitesh-Singh/feat-kernel-pca963x-implement-power-management/20231210-194846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next
patch link:    https://lore.kernel.org/r/881c6ba1-1701-41be-a4ac-81cdca5f0eea%40gmail.com
patch subject: [PATCH] feat(kernel/pca963x): implement power management
config: arc-randconfig-002-20231211 (https://download.01.org/0day-ci/archive/20231211/202312110656.twrTxNHo-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231211/202312110656.twrTxNHo-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312110656.twrTxNHo-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/leds/leds-pca963x.c:399:12: warning: 'pca963x_resume' defined but not used [-Wunused-function]
     399 | static int pca963x_resume(struct device *dev)
         |            ^~~~~~~~~~~~~~
>> drivers/leds/leds-pca963x.c:385:12: warning: 'pca963x_suspend' defined but not used [-Wunused-function]
     385 | static int pca963x_suspend(struct device *dev)
         |            ^~~~~~~~~~~~~~~


vim +/pca963x_resume +399 drivers/leds/leds-pca963x.c

   383	
   384	#ifdef CONFIG_PM
 > 385	static int pca963x_suspend(struct device *dev)
   386	{
   387		struct pca963x *chip;
   388		u8 reg;
   389	
   390		chip = dev_get_drvdata(dev);
   391	
   392		reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
   393		reg = reg | (1 << PCA963X_MODE1_SLEEP);
   394		i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
   395	
   396		return 0;
   397	}
   398	
 > 399	static int pca963x_resume(struct device *dev)
   400	{
   401		struct pca963x *chip;
   402		u8 reg;
   403	
   404		chip = dev_get_drvdata(dev);
   405	
   406		reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
   407		reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
   408		i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
   409	
   410		return 0;
   411	}
   412	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] feat(kernel/pca963x): implement power management
  2023-12-10 11:46 [PATCH] feat(kernel/pca963x): implement power management Amitesh Singh
  2023-12-10 22:37 ` kernel test robot
@ 2023-12-13 11:47 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-12-13 11:47 UTC (permalink / raw)
  To: Amitesh Singh; +Cc: Pavel Machek, linux-leds, linux-kernel

On Sun, 10 Dec 2023, Amitesh Singh wrote:

> From a22dbd7390ce875e81d67f14f05f593d7f03d5c1 Mon Sep 17 00:00:00 2001
> From: Amitesh Singh <singh.amitesh@gmail.com>
> Date: Fri, 8 Dec 2023 15:08:33 +0530
> Subject: [PATCH] feat(kernel/pca963x): implement power management

What are you using to send this patch?

Please use the Git tools provided:

  git format-patch
  git send-email

The subject line is also totally incorrect.  Again Git can help:

  git log --oneline -- <subsystem>

Please fix the bot's complaints before re-submitting.

Thank you.

> This implements power management in upstream driver
> for pca9633 which enables device sleep and resume
> on system-wide sleep/hibernation
> 
> Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
> ---
>  drivers/leds/leds-pca963x.c | 41 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index 47223c850e4b..462f917dc986 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -39,6 +39,7 @@
>  #define PCA963X_LED_PWM		0x2	/* Controlled through PWM */
>  #define PCA963X_LED_GRP_PWM	0x3	/* Controlled through PWM/GRPPWM */
> 
> +#define PCA963X_MODE1_SLEEP     0x04    /* Normal mode or Low Power mode,
> oscillator off */
>  #define PCA963X_MODE2_OUTDRV	0x04	/* Open-drain or totem pole */
>  #define PCA963X_MODE2_INVRT	0x10	/* Normal or inverted direction */
>  #define PCA963X_MODE2_DMBLNK	0x20	/* Enable blinking */
> @@ -380,6 +381,45 @@ static int pca963x_register_leds(struct i2c_client
> *client,
>  	return ret;
>  }
> 
> +#ifdef CONFIG_PM
> +static int pca963x_suspend(struct device *dev)
> +{
> +	struct pca963x *chip;
> +	u8 reg;
> +
> +	chip = dev_get_drvdata(dev);
> +
> +	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> +	reg = reg | (1 << PCA963X_MODE1_SLEEP);
> +	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> +	return 0;
> +}
> +
> +static int pca963x_resume(struct device *dev)
> +{
> +	struct pca963x *chip;
> +	u8 reg;
> +
> +	chip = dev_get_drvdata(dev);
> +
> +	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> +	reg = reg & ~(1 << PCA963X_MODE1_SLEEP);
> +	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> +	return 0;
> +}
> +
> +static const struct dev_pm_ops pca963x_pmops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume)
> +};
> +
> +#define PCA963X_SMBUS_PMOPS (&pca963x_pmops)
> +
> +#else
> +#define PCA963X_SMBUS_PMOPS NULL
> +#endif
> +
>  static const struct of_device_id of_pca963x_match[] = {
>  	{ .compatible = "nxp,pca9632", },
>  	{ .compatible = "nxp,pca9633", },
> @@ -430,6 +470,7 @@ static struct i2c_driver pca963x_driver = {
>  	.driver = {
>  		.name	= "leds-pca963x",
>  		.of_match_table = of_pca963x_match,
> +		.pm = PCA963X_SMBUS_PMOPS
>  	},
>  	.probe = pca963x_probe,
>  	.id_table = pca963x_id,
> -- 
> 2.43.0
> 

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-13 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-10 11:46 [PATCH] feat(kernel/pca963x): implement power management Amitesh Singh
2023-12-10 22:37 ` kernel test robot
2023-12-13 11:47 ` Lee Jones

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).