Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758141AbcJYHPv (ORCPT ); Tue, 25 Oct 2016 03:15:51 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:11084 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753647AbcJYHPt (ORCPT ); Tue, 25 Oct 2016 03:15:49 -0400 X-AuditID: cbfec7f4-f791c6d000006eac-d8-580f06a01d18 Subject: Re: [PATCH] leds: leds-pca963x: workaround group blink scaling issue To: Matt Ranostay , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Matt Ranostay , Tony Lindgren , Rob Herring From: Jacek Anaszewski Message-id: <381331a9-29f8-f2de-2e07-d0c30a31ae06@samsung.com> Date: Tue, 25 Oct 2016 09:15:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-version: 1.0 In-reply-to: <1476364572-26849-1-git-send-email-matt@ranostay.consulting> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleLIzCtJLcpLzFFi42LZduzned0FbPwRBtv3cVrMP3KO1eLyrjls Fh+/9TNbfD15jM2ide8Rdov9V7wc2Dy+fZ3E4rFz1l12j02rOtk8Dj5sZvf4vEkugDWKyyYl NSezLLVI3y6BK+PSHo2COTIVtw5tYmxgPCfWxcjBISFgItG12rSLkRPIFJO4cG89G4gtJLCU UeLQhhoI+zOjxJcrSRA1JhJHr19m7GLkAoovY5RY++kvE4TzjFHi/OOtTCBVwgL+Ei/fHwWb JCKQLDFx7j8wm1mgSGLLgi9gNWwChhI/X7wGs3kF7CSeft3PCGKzCKhK/Hn5jxnkOFGBCInd d1MhSgQlfky+xwJicwp4ShzYcoYJYqSjxINFO1khbHmJzWveMkMcOp1d4tEVB4gfZSU2HWCG MF0klsyrh6gQlnh1fAs7hC0j0dlxEO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2I0BXpiIrOUaHI+MNrzSuINTQzNLQ2NjC0szI2MlMR5Sz5cCRcSSE8sSc1OTS1ILYLp Y+LglGpgNHtRFhOv1NX6M+KWlmCO/48p7w8El9bdb/zCFfTiw3X2bTNiDqS/Z9IMWsyfc5vb 3/vhvv/3D7823rqy8WBvu1LDF7Ff9rH/pfh0963buE5Af5fSZv+kqhXXE+uWty2+MndLenWm W2Ld3YTFEtdV451f/UifesXpT+OSVvtdL/Y7pfhmVB65oMRSnJFoqMVcVJwIAOcOdoO+AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161025071543eucas1p2e9574d3560a7e6610069005aa7c249a9 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SmFjZWsgQW5hc3pld3NraRtTUlBPTC1TeXN0ZW0gRlcgIChN?= =?UTF-8?B?Qikb7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?SmFjZWsgQW5hc3pld3NraRtTUlBPTC1TeXN0ZW0gRlcgIChN?= =?UTF-8?B?QikbU2Ftc3VuZyBFbGVjdHJvbmljcxtTZW5pb3IgU29mdHdhcmUgRW5naW5l?= =?UTF-8?B?ZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjc1MjY=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161013131722eucas1p10501fce7ca4fa256fce58c5411d2a097 X-RootMTR: 20161013131722eucas1p10501fce7ca4fa256fce58c5411d2a097 References: <1476364572-26849-1-git-send-email-matt@ranostay.consulting> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3509 Lines: 103 Hi Matt, Patch applied. Thanks, Jacek Anaszewski On 10/13/2016 03:16 PM, Matt Ranostay wrote: > PCA9632TK part seems to incorrectly blink at ~1.3x of the programmed > rate. This patchset add a nxp,period-scale devicetree property to > adjust for this misconfiguration. > > Cc: Tony Lindgren > Cc: Jacek Anaszewski > Signed-off-by: Matt Ranostay > --- > Documentation/devicetree/bindings/leds/pca963x.txt | 3 +++ > drivers/leds/leds-pca963x.c | 18 +++++++++++++++--- > 2 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/leds/pca963x.txt b/Documentation/devicetree/bindings/leds/pca963x.txt > index dafbe9931c2b..dfbdb123a9bf 100644 > --- a/Documentation/devicetree/bindings/leds/pca963x.txt > +++ b/Documentation/devicetree/bindings/leds/pca963x.txt > @@ -7,6 +7,9 @@ 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,period-scale : In some configurations, the chip blinks faster than expected. > + This parameter provides a scaling ratio (fixed point, decimal divided > + by 1000) to compensate, e.g. 1300=1.3x and 750=0.75x. > > 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 407eba11e187..b6ce1f2ec33e 100644 > --- a/drivers/leds/leds-pca963x.c > +++ b/drivers/leds/leds-pca963x.c > @@ -59,6 +59,7 @@ struct pca963x_chipdef { > u8 grpfreq; > u8 ledout_base; > int n_leds; > + unsigned int scaling; > }; > > static struct pca963x_chipdef pca963x_chipdefs[] = { > @@ -189,6 +190,14 @@ static int pca963x_led_set(struct led_classdev *led_cdev, > return pca963x_brightness(pca963x, value); > } > > +static unsigned int pca963x_period_scale(struct pca963x_led *pca963x, > + unsigned int val) > +{ > + unsigned int scaling = pca963x->chip->chipdef->scaling; > + > + return scaling ? DIV_ROUND_CLOSEST(val * scaling, 1000) : val; > +} > + > static int pca963x_blink_set(struct led_classdev *led_cdev, > unsigned long *delay_on, unsigned long *delay_off) > { > @@ -207,14 +216,14 @@ static int pca963x_blink_set(struct led_classdev *led_cdev, > time_off = 500; > } > > - period = time_on + time_off; > + period = pca963x_period_scale(pca963x, time_on + time_off); > > /* If period not supported by hardware, default to someting sane. */ > if ((period < PCA963X_BLINK_PERIOD_MIN) || > (period > PCA963X_BLINK_PERIOD_MAX)) { > time_on = 500; > time_off = 500; > - period = time_on + time_off; > + period = pca963x_period_scale(pca963x, 1000); > } > > /* > @@ -222,7 +231,7 @@ static int pca963x_blink_set(struct led_classdev *led_cdev, > * (time_on / period) = (GDC / 256) -> > * GDC = ((time_on * 256) / period) > */ > - gdc = (time_on * 256) / period; > + gdc = (pca963x_period_scale(pca963x, time_on) * 256) / period; > > /* > * From manual: period = ((GFRQ + 1) / 24) in seconds. > @@ -294,6 +303,9 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) > else > pdata->blink_type = PCA963X_SW_BLINK; > > + if (of_property_read_u32(np, "nxp,period-scale", &chip->scaling)) > + chip->scaling = 1000; > + > return pdata; > } > > -- Best regards, Jacek Anaszewski