From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757281AbcEDH2z (ORCPT ); Wed, 4 May 2016 03:28:55 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:17069 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757213AbcEDH2w (ORCPT ); Wed, 4 May 2016 03:28:52 -0400 X-AuditID: cbfec7f4-f796c6d000001486-1e-5729a4b054fb Message-id: <5729A4AB.5080901@samsung.com> Date: Wed, 04 May 2016 09:28:43 +0200 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: Anders Darander Cc: rpurdie@rpsys.net, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, Olliver Schinagl , Ricardo Ribalda Delgado Subject: Re: [PATCH] leds-pca963x: add bindings to invert polarity References: <1462182104-21450-1-git-send-email-anders@chargestorm.se> In-reply-to: <1462182104-21450-1-git-send-email-anders@chargestorm.se> Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeLIzCtJLcpLzFFi42I5/e/4Zd0NSzTDDVYcEbLoXnuKzWL+kXOs Fv1vFrJanHu1ktHi8q45bBZb36xjtFh6/SKTxctJD1ktJkxfy2LR1T2PyaJ17xF2i927nrI6 8HismbeG0eNrG5/H5b5eJo+ds+6ye6xc/oXNY9OqTjaPPfN/sHq0tixn9fi8SS6AM4rLJiU1 J7MstUjfLoErY8PT7WwFy6Urlt65y9rA2CXWxcjBISFgItFzJbWLkRPIFJO4cG89WxcjF4eQ wFJGib0dC9lBEkICzxglPh0IAbF5BbQknj5ezw7SyyKgKtG90REkzCZgKPHzxWsmEFtUIELi z+l9rBDlghI/Jt9jAbFFBLQlWq4uB5vPLHCISeL2+9fMIAlhASeJU2cfMEHscpX4M3892F5O ATeJ+f2X2UBsZgFriZWTtjFC2PISm9e8ZZ7AKDALyY5ZSMpmISlbwMi8ilE0tTS5oDgpPddQ rzgxt7g0L10vOT93EyMkdr7sYFx8zOoQowAHoxIP7wtvzXAh1sSy4srcQ4wSHMxKIrzL5wGF eFMSK6tSi/Lji0pzUosPMUpzsCiJ887d9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwNiyS+Rt+cb/ X3kXvD3ydz7fFL2eONbG/htlh2MsdTYUmrBuLOdUiGO/L9VUvGwV7115644M3lqBFXP32/RN YQ2s2rA+cmNi/8zg83pLK7dOXrDizremAJlvEYaVDmcUbzqr7T8dwcbMnJ95NntClbZm4opM 6711tpw2DxfxtIvcOdLE/nD9eyWW4oxEQy3mouJEAAMgKwmZAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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*/ >