linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds-pca963x: add bindings to invert polarity
@ 2016-05-02  9:41 Anders Darander
  2016-05-04  7:28 ` Jacek Anaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Anders Darander @ 2016-05-02  9:41 UTC (permalink / raw)
  To: rpurdie, robh+dt, devicetree, linux-kernel, linux-leds, j.anaszewski
  Cc: pawel.moll, mark.rutland, ijc+devicetree, galak, Anders Darander

Add a new DT property, nxp,inverted, to invert the polarity of the output.

Tested on PCA9634.

Signed-off-by: Anders Darander <anders@chargestorm.se>
---
 Documentation/devicetree/bindings/leds/pca963x.txt |  1 +
 drivers/leds/leds-pca963x.c                        | 17 +++++++++++++++--
 include/linux/platform_data/leds-pca963x.h         |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt b/Documentation/devicetree/bindings/leds/pca963x.txt
index dafbe99..68579c5 100644
--- a/Documentation/devicetree/bindings/leds/pca963x.txt
+++ b/Documentation/devicetree/bindings/leds/pca963x.txt
@@ -7,6 +7,7 @@ Optional properties:
 - nxp,totem-pole : use totem pole (push-pull) instead of open-drain (pca9632 defaults
   to open-drain, newer chips to totem pole)
 - nxp,hw-blink : use hardware blinking instead of software blinking
+- nxp,inverted: invert the polarity of the generated PWM
 
 Each led is represented as a sub-node of the nxp,pca963x device.
 
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 407eba1..41b7648 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -294,6 +294,12 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
 	else
 		pdata->blink_type = PCA963X_SW_BLINK;
 
+	/* default to non-inverted output, unless inverted is specified */
+	if (of_property_read_bool(np, "nxp,inverted"))
+		pdata->dir = PCA963X_INVERTED;
+	else
+		pdata->dir = PCA963X_NORMAL;
+
 	return pdata;
 }
 
@@ -395,11 +401,18 @@ static int pca963x_probe(struct i2c_client *client,
 	i2c_smbus_write_byte_data(client, PCA963X_MODE1, 0x00);
 
 	if (pdata) {
+		u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client,
+						    PCA963X_MODE2);
 		/* Configure output: open-drain or totem pole (push-pull) */
 		if (pdata->outdrv == PCA963X_OPEN_DRAIN)
-			i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x01);
+			mode2 |= 0x01;
 		else
-			i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x05);
+			mode2 |= 0x05;
+		/* Configure direction: normal or inverted */
+		if (pdata->dir == PCA963X_INVERTED)
+			mode2 |= 0x10;
+		i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
+					  mode2);
 	}
 
 	return 0;
diff --git a/include/linux/platform_data/leds-pca963x.h b/include/linux/platform_data/leds-pca963x.h
index e731f00..54e845f 100644
--- a/include/linux/platform_data/leds-pca963x.h
+++ b/include/linux/platform_data/leds-pca963x.h
@@ -33,10 +33,16 @@ enum pca963x_blink_type {
 	PCA963X_HW_BLINK,
 };
 
+enum pca963x_direction {
+	PCA963X_NORMAL,
+	PCA963X_INVERTED,
+};
+
 struct pca963x_platform_data {
 	struct led_platform_data leds;
 	enum pca963x_outdrv outdrv;
 	enum pca963x_blink_type blink_type;
+	enum pca963x_direction dir;
 };
 
 #endif /* __LINUX_PCA963X_H*/
-- 
2.8.1

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

* Re: [PATCH] leds-pca963x: add bindings to invert polarity
  2016-05-02  9:41 [PATCH] leds-pca963x: add bindings to invert polarity Anders Darander
@ 2016-05-04  7:28 ` Jacek Anaszewski
  2016-05-04  7:55   ` Anders Darander
  0 siblings, 1 reply; 6+ messages in thread
From: Jacek Anaszewski @ 2016-05-04  7:28 UTC (permalink / raw)
  To: Anders Darander
  Cc: rpurdie, robh+dt, devicetree, linux-kernel, linux-leds,
	pawel.moll, mark.rutland, ijc+devicetree, galak,
	Olliver Schinagl, Ricardo Ribalda Delgado

Hi Anders,

Thanks for the patch.
Please note that there has already been an attempt to add
the support for inverted output polarity to this driver and related
discussion [1]. This thread remains quiet for around two weeks.

Cc Olliver and Ricardo.

[1] https://lkml.org/lkml/2016/4/19/95

Best regards,
Jacek Anaszewski

On 05/02/2016 11:41 AM, Anders Darander wrote:
> Add a new DT property, nxp,inverted, to invert the polarity of the output.
>
> Tested on PCA9634.
>
> Signed-off-by: Anders Darander <anders@chargestorm.se>
> ---
>   Documentation/devicetree/bindings/leds/pca963x.txt |  1 +
>   drivers/leds/leds-pca963x.c                        | 17 +++++++++++++++--
>   include/linux/platform_data/leds-pca963x.h         |  6 ++++++
>   3 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt b/Documentation/devicetree/bindings/leds/pca963x.txt
> index dafbe99..68579c5 100644
> --- a/Documentation/devicetree/bindings/leds/pca963x.txt
> +++ b/Documentation/devicetree/bindings/leds/pca963x.txt
> @@ -7,6 +7,7 @@ Optional properties:
>   - nxp,totem-pole : use totem pole (push-pull) instead of open-drain (pca9632 defaults
>     to open-drain, newer chips to totem pole)
>   - nxp,hw-blink : use hardware blinking instead of software blinking
> +- nxp,inverted: invert the polarity of the generated PWM
>
>   Each led is represented as a sub-node of the nxp,pca963x device.
>
> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index 407eba1..41b7648 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -294,6 +294,12 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
>   	else
>   		pdata->blink_type = PCA963X_SW_BLINK;
>
> +	/* default to non-inverted output, unless inverted is specified */
> +	if (of_property_read_bool(np, "nxp,inverted"))
> +		pdata->dir = PCA963X_INVERTED;
> +	else
> +		pdata->dir = PCA963X_NORMAL;
> +
>   	return pdata;
>   }
>
> @@ -395,11 +401,18 @@ static int pca963x_probe(struct i2c_client *client,
>   	i2c_smbus_write_byte_data(client, PCA963X_MODE1, 0x00);
>
>   	if (pdata) {
> +		u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client,
> +						    PCA963X_MODE2);
>   		/* Configure output: open-drain or totem pole (push-pull) */
>   		if (pdata->outdrv == PCA963X_OPEN_DRAIN)
> -			i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x01);
> +			mode2 |= 0x01;
>   		else
> -			i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x05);
> +			mode2 |= 0x05;
> +		/* Configure direction: normal or inverted */
> +		if (pdata->dir == PCA963X_INVERTED)
> +			mode2 |= 0x10;
> +		i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
> +					  mode2);
>   	}
>
>   	return 0;
> diff --git a/include/linux/platform_data/leds-pca963x.h b/include/linux/platform_data/leds-pca963x.h
> index e731f00..54e845f 100644
> --- a/include/linux/platform_data/leds-pca963x.h
> +++ b/include/linux/platform_data/leds-pca963x.h
> @@ -33,10 +33,16 @@ enum pca963x_blink_type {
>   	PCA963X_HW_BLINK,
>   };
>
> +enum pca963x_direction {
> +	PCA963X_NORMAL,
> +	PCA963X_INVERTED,
> +};
> +
>   struct pca963x_platform_data {
>   	struct led_platform_data leds;
>   	enum pca963x_outdrv outdrv;
>   	enum pca963x_blink_type blink_type;
> +	enum pca963x_direction dir;
>   };
>
>   #endif /* __LINUX_PCA963X_H*/
>

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

* Re: [PATCH] leds-pca963x: add bindings to invert polarity
  2016-05-04  7:28 ` Jacek Anaszewski
@ 2016-05-04  7:55   ` Anders Darander
  2016-05-04  8:10     ` Olliver Schinagl
  0 siblings, 1 reply; 6+ messages in thread
From: Anders Darander @ 2016-05-04  7:55 UTC (permalink / raw)
  To: Jacek Anaszewski
  Cc: rpurdie, robh+dt, devicetree, linux-kernel, linux-leds,
	pawel.moll, mark.rutland, ijc+devicetree, galak,
	Olliver Schinagl, Ricardo Ribalda Delgado

Hi,

Thanks for the info.

* Jacek Anaszewski <j.anaszewski@samsung.com> [160504 09:28]:
> Please note that there has already been an attempt to add
> the support for inverted output polarity to this driver and related
> discussion [1]. This thread remains quiet for around two weeks.

Ah, nice coincidence! Unfortunately, I made the work earlier than his
posting, otherwise I could have spent the time on somethinge else. ;)

Well, then I hope v2 of his patches comes along.

Cheers,
Anders

-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB

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

* Re: [PATCH] leds-pca963x: add bindings to invert polarity
  2016-05-04  7:55   ` Anders Darander
@ 2016-05-04  8:10     ` Olliver Schinagl
  2016-09-05 11:02       ` Anders Darander
  0 siblings, 1 reply; 6+ messages in thread
From: Olliver Schinagl @ 2016-05-04  8:10 UTC (permalink / raw)
  To: Anders Darander, Jacek Anaszewski
  Cc: rpurdie, robh+dt, devicetree, linux-kernel, linux-leds,
	pawel.moll, mark.rutland, ijc+devicetree, galak,
	Ricardo Ribalda Delgado

Hey Jacek,

On 04-05-16 09:55, Anders Darander wrote:
> Hi,
>
> Thanks for the info.
>
> * Jacek Anaszewski <j.anaszewski@samsung.com> [160504 09:28]:
>> Please note that there has already been an attempt to add
>> the support for inverted output polarity to this driver and related
>> discussion [1]. This thread remains quiet for around two weeks.
> Ah, nice coincidence! Unfortunately, I made the work earlier than his
> posting, otherwise I could have spent the time on somethinge else. ;)
Sorry to be so slacking with submitting this, I've been sitting on it 
for 6 months now :) I just kept postponing in submitting it. But as they 
say, great minds, and all that.
>
> Well, then I hope v2 of his patches comes along.
>
> Cheers,
> Anders
>

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

* Re: [PATCH] leds-pca963x: add bindings to invert polarity
  2016-05-04  8:10     ` Olliver Schinagl
@ 2016-09-05 11:02       ` Anders Darander
  2016-09-06  9:29         ` Olliver Schinagl
  0 siblings, 1 reply; 6+ messages in thread
From: Anders Darander @ 2016-09-05 11:02 UTC (permalink / raw)
  To: Olliver Schinagl
  Cc: Jacek Anaszewski, robh+dt, devicetree, linux-kernel, linux-leds,
	pawel.moll, mark.rutland, ijc+devicetree, galak,
	Ricardo Ribalda Delgado

Hi,

* Olliver Schinagl <oliver@schinagl.nl> [160504 10:10]:
> On 04-05-16 09:55, Anders Darander wrote:
> > * Jacek Anaszewski <j.anaszewski@samsung.com> [160504 09:28]:
> > > Please note that there has already been an attempt to add
> > > the support for inverted output polarity to this driver and related
> > > discussion [1]. This thread remains quiet for around two weeks.
> > Ah, nice coincidence! Unfortunately, I made the work earlier than his
> > posting, otherwise I could have spent the time on somethinge else. ;)
> Sorry to be so slacking with submitting this, I've been sitting on it for 6
> months now :) I just kept postponing in submitting it. But as they say,
> great minds, and all that.

> > Well, then I hope v2 of his patches comes along.

Any news on a v2?

Otherwise, could we agree on a dt binding for the inverted output, and
look into merging that prior to the rest of the series? I'd like to get
rid of my local patch... 

Cheers,
Anders

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

* Re: [PATCH] leds-pca963x: add bindings to invert polarity
  2016-09-05 11:02       ` Anders Darander
@ 2016-09-06  9:29         ` Olliver Schinagl
  0 siblings, 0 replies; 6+ messages in thread
From: Olliver Schinagl @ 2016-09-06  9:29 UTC (permalink / raw)
  To: Anders Darander
  Cc: Jacek Anaszewski, robh+dt, devicetree, linux-kernel, linux-leds,
	pawel.moll, mark.rutland, ijc+devicetree, galak,
	Ricardo Ribalda Delgado

Hi Anders,

On ma, 2016-09-05 at 13:02 +0200, Anders Darander wrote:
> Hi,
> 
> * Olliver Schinagl <oliver@schinagl.nl> [160504 10:10]:
> > 
> > On 04-05-16 09:55, Anders Darander wrote:
> > > 
> > > * Jacek Anaszewski <j.anaszewski@samsung.com> [160504 09:28]:
> > > > 
> > > > Please note that there has already been an attempt to add
> > > > the support for inverted output polarity to this driver and
> > > > related
> > > > discussion [1]. This thread remains quiet for around two weeks.
> > > Ah, nice coincidence! Unfortunately, I made the work earlier than
> > > his
> > > posting, otherwise I could have spent the time on somethinge
> > > else. ;)
> > Sorry to be so slacking with submitting this, I've been sitting on
> > it for 6
> > months now :) I just kept postponing in submitting it. But as they
> > say,
> > great minds, and all that.
> 
> > 
> > > 
> > > Well, then I hope v2 of his patches comes along.
> 
> Any news on a v2?
> 
> Otherwise, could we agree on a dt binding for the inverted output,
> and
> look into merging that prior to the rest of the series? I'd like to
> get
> rid of my local patch... 
I almost forgotten about this bit, I'll read back on the mails and
check/verify my results/discussions from back then.

Thanks for bringing it up again!

Olliver

> 
> Cheers,
> Anders

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

end of thread, other threads:[~2016-09-06  9:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-02  9:41 [PATCH] leds-pca963x: add bindings to invert polarity Anders Darander
2016-05-04  7:28 ` Jacek Anaszewski
2016-05-04  7:55   ` Anders Darander
2016-05-04  8:10     ` Olliver Schinagl
2016-09-05 11:02       ` Anders Darander
2016-09-06  9:29         ` Olliver Schinagl

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