From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934779AbdJQJht (ORCPT ); Tue, 17 Oct 2017 05:37:49 -0400 Received: from 8.mo2.mail-out.ovh.net ([188.165.52.147]:51723 "EHLO 8.mo2.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933261AbdJQJhr (ORCPT ); Tue, 17 Oct 2017 05:37:47 -0400 X-Greylist: delayed 2395 seconds by postgrey-1.27 at vger.kernel.org; Tue, 17 Oct 2017 05:37:46 EDT Subject: Re: about pca955x led driver gpio management To: Andrea Scian - DAVE Embedded Systems Cc: Bryan Wu , Richard Purdie , Jacek Anaszewski , linux-leds@vger.kernel.org, linux-kernel References: From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: Date: Tue, 17 Oct 2017 10:18:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 13603967099676887831 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrudeggddtfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. C. > 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, >