mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrea Scian - DAVE Embedded Systems <andrea.scian@dave.eu>,
	Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <j.anaszewski@samsung.com>,
	linux-leds@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: about pca955x led driver gpio management
Date: Mon, 23 Oct 2017 21:12:22 +0200	[thread overview]
Message-ID: <9fc08465-db1e-66d4-d07e-f7a9b45add4f@gmail.com> (raw)
In-Reply-To: <4ac527f2-c59e-70a2-efd4-da52370ea557@dave.eu>

Hi Cedric,

Andrea seems to come across a real issue. We might proceed with the
contribution of his patch without your review and possibly
Tested-by, but it would be nevertheless beneficial if we had them.

Best regards,
Jacek Anaszewski

On 10/17/2017 11:16 AM, Andrea Scian - DAVE Embedded Systems wrote:
> 
>> On 10/17/2017 10:20 AM, Andrea Scian - DAVE Embedded Systems wrote:
>>>
>>> Il 17/10/2017 10:18, Cédric Le Goater ha scritto:
>>>> On 10/17/2017 09:36 AM, Andrea Scian - DAVE Embedded Systems wrote:
>>>>> Dear all,
>>>>>
>>>>> I'm working on an iMX6 based board with a PCA9555 which is used
>>>>> both to drive LEDs and manage some GPIOs.
>>>> The PCA9555 chip and the PCA955[0-3] chips have different control
>>>> registers. You need a different led driver for it.
>>>
>>> My typo sorry, as you can see in the device tree below, I'm using
>>> pca9551
>>
>> ok.
>>
>> You might want to take a look at how we mixed gpios and leds on the
>> witherspoon
>> system using pca9552 chips. we added a gpio-leds binding.
>>
>> https://github.com/openbmc/linux/blob/dev-4.10/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
>>
> 
> understood: you configure all pins of PCA955x as GPIOs and the map the
> one you need as led with gpio-leds binding.
> 
> However to me this is a kind of workaround or, at least, there's nothing
> about this limitation into the devicetree binding (in fact, IMHO, the
> device tree binding example will just fail)
> 
> I wrote the attached patch which should fix the issue and allow a more
> generic approach. WDYT?
> 
> (in case it looks good, I'll send the patch in the correct way)
> 
> 
> Kind Regards,
> 
> Andrea
> 
>>>
>>>>> My current kernel is quite old (4.1.15) but I've found Cédric
>>>>> patches on mainline and backported to this old revision.
>>>>>
>>>>> I'm facing an issue with it, because it seems that it fails when
>>>>> it's used in a mixed (led/gpios) environment.
>>>>>
>>>>> E.g.: let's say that I have one led connected to LED0 output and
>>>>> one GPIO connected at LED1 output.
>>>>>
>>>>> I define it as
>>>>>
>>>>>                           pca9551: pca9551@60 {
>>>>>                                   compatible = "nxp,pca9551";
>>>>>                                   reg = <0x60>;
>>>>>                                   #address-cells = <1>;
>>>>>                                   #size-cells = <0>;
>>>>>                                   #gpio-cells = <1>;
>>>>>
>>>>>                                   led@0 {
>>>>>                                           label = "led0";
>>>>>                                           reg = <0>;
>>>>>                                           linux,default-trigger =
>>>>> "none";
>>>>>                                   };
>>>>>                                   gpio@1 {
>>>>>                                           label = "gpio1";
>>>>>                                           reg = <1>;
>>>>>                                           type = <2>; /* GPIO */
>>>>>                                   };
>>>>>                   };
>>>>>
>>>>> At boot it's probed as
>>>>>
>>>>> root@sbc-lynx:~# dmesg | grep pca
>>>>> [    5.315425] leds-pca955x 5-0060: leds-pca955x: Using pca9551
>>>>> 8-bit LED driver at slave address 0x60
>>>>> [    5.350349] leds-pca955x 5-0060: gpios 511...511
>>>>>
>>>>> But I cannot access it:
>>>>>
>>>>> root@sbc-lynx:~# echo 511 > /sys/class/gpio/export
>>>>> -sh: echo: write error: Device or resource busy
>>>>>
>>>>> Because for pca955x_gpio_request_pin() this is at offset 0 (in fact
>>>>> is the first gpio registered of this gpio_chip) but it's the index
>>>>> 1 inside pca955x->leds[]
>>>>>
>>>>> Am I missing something? (maybe I made a mistake in my backport
>>>>> and/or I'm missing some patches about the GPIO subsystems).
>>>>>
>>>>> If I'm right I think I can send a patch to fix this (I'm thinking
>>>>> about having an array of GPIO index to map offset ->
>>>>> pca955x->leds[] index or just register all pins as GPIOs and then
>>>>> just report the busy state)
>>>>>
>>>>> WDYT?
>>>>>
>>>>> Kind Regards,
>>>>>
>>>
>>

  reply	other threads:[~2017-10-23 19:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17  7:36 Andrea Scian - DAVE Embedded Systems
2017-10-17  8:18 ` Cédric Le Goater
2017-10-17  8:20   ` Andrea Scian - DAVE Embedded Systems
2017-10-17  8:52     ` Cédric Le Goater
2017-10-17  9:16       ` Andrea Scian - DAVE Embedded Systems
2017-10-23 19:12         ` Jacek Anaszewski [this message]
2017-10-24  5:51         ` Cédric Le Goater
2017-10-24 22:36           ` Andrea Scian - DAVE Embedded Systems
2017-10-25  8:18             ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fc08465-db1e-66d4-d07e-f7a9b45add4f@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=andrea.scian@dave.eu \
    --cc=clg@kaod.org \
    --cc=cooloney@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®