<feed xmlns='http://www.w3.org/2005/Atom'>
<title>BMC/Intel-BMC/linux.git/drivers/leds, branch dev-4.10</title>
<subtitle>Intel OpenBMC Linux kernel source tree (mirror)</subtitle>
<id>https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-4.10</id>
<link rel='self' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-4.10'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/'/>
<updated>2018-01-16T17:54:28+00:00</updated>
<entry>
<title>gpiolib: Convert fwnode_get_named_gpiod() to configure GPIO</title>
<updated>2018-01-16T17:54:28+00:00</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2018-01-10T22:44:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=51840cf1e0fcb406750b76a34a65a3bd1b24c884'/>
<id>urn:sha1:51840cf1e0fcb406750b76a34a65a3bd1b24c884</id>
<content type='text'>
Make fwnode_get_named_gpiod() consistent with the rest of
gpiod_get() like API, i.e. configure GPIO pin immediately after
request.

Besides obvious clean up it will help to configure pins based
on firmware provided resources.

Reviewed-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
(cherry picked from commit a264d10ff45c688293d9112fddd8d29c819e0853)
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: Fix GPIO request for input setting</title>
<updated>2017-10-04T04:04:14+00:00</updated>
<author>
<name>Andrew Jeffery</name>
<email>andrew@aj.id.au</email>
</author>
<published>2017-09-25T01:53:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=07ef154156591704e2d0a051184ec9a4333da30b'/>
<id>urn:sha1:07ef154156591704e2d0a051184ec9a4333da30b</id>
<content type='text'>
The prior patch which fixed the problem with output inversion failed to
account for a necessary fix to requesting a pin for input, which is
affected by the open-drain nature of the hardware.

Previously pca955x_gpio_direction_input() called through
pca955x_set_value() to configure the direction, however continuing down
this route lead to a brain-hemorrhaging level of necessary inversions.
Instead, remove one layer by calling directly into pca955x_led_set(),
and define PCA955X_GPIO_INPUT to paper over the rest of the confusion.

OpenBMC-Staging-Count: 1
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
Tested-by: Matt Spinler &lt;mspinler@linux.vnet.ibm.com&gt;
Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: check for I2C errors</title>
<updated>2017-08-29T05:31:04+00:00</updated>
<author>
<name>Cédric Le Goater</name>
<email>clg@kaod.org</email>
</author>
<published>2017-08-28T06:37:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=76ff93cf4565068e97b802e41748eb6745500606'/>
<id>urn:sha1:76ff93cf4565068e97b802e41748eb6745500606</id>
<content type='text'>
This should also allow probing to fail when a pca955x chip is not
found on a I2C bus.

Signed-off-by: Cédric Le Goater &lt;clg@kaod.org&gt;
[arj: Resolve conflicts introduced by fix for GPIO inversion]
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: Don't invert requested value in pca955x_gpio_set_value()</title>
<updated>2017-08-29T05:25:06+00:00</updated>
<author>
<name>Andrew Jeffery</name>
<email>andrew@aj.id.au</email>
</author>
<published>2017-08-25T06:52:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=f1d699831b14119c703cd0be06ea10b48413692c'/>
<id>urn:sha1:f1d699831b14119c703cd0be06ea10b48413692c</id>
<content type='text'>
The PCA9552 lines can be used either for driving LEDs or as GPIOs. The
manual states that for LEDs, the operation is open-drain:

         The LSn LED select registers determine the source of the LED data.

           00 = output is set LOW (LED on)
           01 = output is set high-impedance (LED off; default)
           10 = output blinks at PWM0 rate
           11 = output blinks at PWM1 rate

For GPIOs it suggests a pull-up so that the open-case drives the line
high:

         For use as output, connect external pull-up resistor to the pin
         and size it according to the DC recommended operating
         characteristics.  LED output pin is HIGH when the output is
         programmed as high-impedance, and LOW when the output is
         programmed LOW through the ‘LED selector’ register.  The output
         can be pulse-width controlled when PWM0 or PWM1 are used.

Now, I have a hardware design that uses the LED controller to control
LEDs. However, for $reasons, we're using the leds-gpio driver to drive
the LEDs which means wending our way through the gpiochip abstractions.
So with that in mind we need to describe an active-low GPIO
configuration to drive the LEDs as though they were GPIOs.

The set() gpiochip callback in leds-pca955x does the following:

         ...
         if (val)
                pca955x_led_set(&amp;led-&gt;led_cdev, LED_FULL);
         else
                pca955x_led_set(&amp;led-&gt;led_cdev, LED_OFF);
         ...

Where LED_FULL = 255. pca955x_led_set() in turn does:

         ...
         switch (value) {
         case LED_FULL:
                ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON);
                break;
         ...

Where PCA955X_LS_LED_ON is defined as:

         #define PCA955X_LS_LED_ON	0x0	/* Output LOW */

So here we have some type confusion: We've crossed domains from GPIO
behaviour to LED behaviour without accounting for possible inversions
in the process.

Stepping back to leds-gpio for a moment, during probe() we call
create_gpio_led(), which eventually executes:

         if (template-&gt;default_state == LEDS_GPIO_DEFSTATE_KEEP) {
                state = gpiod_get_value_cansleep(led_dat-&gt;gpiod);
                if (state &lt; 0)
                        return state;
         } else {
                state = (template-&gt;default_state == LEDS_GPIO_DEFSTATE_ON);
         }
         ...
         ret = gpiod_direction_output(led_dat-&gt;gpiod, state);

In the devicetree the GPIO is annotated as active-low, and
gpiod_get_value_cansleep() handles this for us:

         int gpiod_get_value_cansleep(const struct gpio_desc *desc)
         {
                 int value;

                 might_sleep_if(extra_checks);
                 VALIDATE_DESC(desc);
                 value = _gpiod_get_raw_value(desc);
                 if (value &lt; 0)
                         return value;

                 if (test_bit(FLAG_ACTIVE_LOW, &amp;desc-&gt;flags))
                         value = !value;

                 return value;
         }

_gpiod_get_raw_value() in turn calls through the get() callback for the
gpiochip implementation, so returning to our get() implementation in
leds-pca955x we find we extract the raw value from hardware:

         static int pca955x_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
         {
                 struct pca955x *pca955x = gpiochip_get_data(gc);
                 struct pca955x_led *led = &amp;pca955x-&gt;leds[offset];
                 u8 reg = pca955x_read_input(pca955x-&gt;client, led-&gt;led_num / 8);

                 return !!(reg &amp; (1 &lt;&lt; (led-&gt;led_num % 8)));
         }

This behaviour is not symmetric with that of set(), where the val is
inverted by the driver.

Closing the loop on the GPIO_ACTIVE_LOW inversions,
gpiod_direction_output(), like gpiod_get_value_cansleep, handles it for
us:

         int gpiod_direction_output(struct gpio_desc *desc, int value)
         {
                  VALIDATE_DESC(desc);
                  if (test_bit(FLAG_ACTIVE_LOW, &amp;desc-&gt;flags))
                           value = !value;
                  else
                           value = !!value;
                  return _gpiod_direction_output_raw(desc, value);
         }

All-in-all, with a value of 'keep' for default-state property in the
gpio-leds child node, the current state of the hardware will in-fact be
inverted; precisely the opposite of what was intended.

Rework leds-pca955x so that we avoid the incorrect inversion and clarify
the semantics with respect to GPIO.

Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
Tested-by: Brandon Wyman &lt;bjwyman@gmail.com&gt;
</content>
</entry>
<entry>
<title>leds: gpio: Allow LED to retain state at shutdown</title>
<updated>2017-08-29T00:48:36+00:00</updated>
<author>
<name>Andrew Jeffery</name>
<email>andrew@aj.id.au</email>
</author>
<published>2017-08-28T00:17:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=4c148ccf851cb28ab95958c9ca4e4beb54559fa1'/>
<id>urn:sha1:4c148ccf851cb28ab95958c9ca4e4beb54559fa1</id>
<content type='text'>
In some systems, such as Baseboard Management Controllers (BMCs), we
want to retain the state of LEDs across a reboot of the BMC (whilst the
host remains up). Implement support for the retain-state-shutdown
devicetree property in leds-gpio.

Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
Acked-by: Pavel Machek &lt;pavel@ucw.cz&gt;
Signed-off-by: Jacek Anaszewski &lt;jacek.anaszewski@gmail.com&gt;
(cherry picked from commit ab9fa30883635b7a579ed318ac7ec7d85fe1e4d5)
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: Prevent crippled LED device name</title>
<updated>2017-08-28T03:14:46+00:00</updated>
<author>
<name>Jacek Anaszewski</name>
<email>jacek.anaszewski@gmail.com</email>
</author>
<published>2017-08-17T20:16:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=a9d91d041f958c1950619c683dfa37c5f83b5bd8'/>
<id>urn:sha1:a9d91d041f958c1950619c683dfa37c5f83b5bd8</id>
<content type='text'>
In case platform data provided empty LED name string the resulting
LED class device name would be crippled. Use corresponding LED chip
bit in place of "function" segment of LED class device name then to
make the LEDs at least distinguishable.

Signed-off-by: Jacek Anaszewski &lt;jacek.anaszewski@gmail.com&gt;
Reported-by: Colin King &lt;colin.king@canonical.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Suggested-by: Nate Case &lt;ncase@xes-inc.com&gt;
(cherry picked from commit 41e9ee90f1433f762e2a5b6b0b239f8c83bb9398)
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: sync with mainline driver</title>
<updated>2017-08-28T01:34:44+00:00</updated>
<author>
<name>Cédric Le Goater</name>
<email>clg@kaod.org</email>
</author>
<published>2017-08-27T16:45:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=a8060609ba3b22b677bb02113f60cf802cc86a3b'/>
<id>urn:sha1:a8060609ba3b22b677bb02113f60cf802cc86a3b</id>
<content type='text'>
The result should be in sync with kernel 4.14 once the gpio extension
is merged in the pca955x driver.

Signed-off-by: Cédric Le Goater &lt;clg@kaod.org&gt;
Signed-off-by: Andrew Jeffery &lt;andrew@aj.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: fix typo</title>
<updated>2017-07-31T08:21:43+00:00</updated>
<author>
<name>Cédric Le Goater</name>
<email>clg@kaod.org</email>
</author>
<published>2017-07-31T07:53:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=f3040fb5404ee27552b3cbff42f3f9d96930ed64'/>
<id>urn:sha1:f3040fb5404ee27552b3cbff42f3f9d96930ed64</id>
<content type='text'>
Spotted by the 01 bot when compiling without OF support :

   drivers/leds/leds-pca955x.c:319:1: note: expected 'struct pca963x_chipdef *' but argument is of type 'struct pca955x_chipdef *'
    pca955x_pdata_of_init(struct i2c_client *client, struct pca963x_chipdef *chip)
    ^~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

OpenBMC-Staging-Count: 1
Signed-off-by: Cédric Le Goater &lt;clg@kaod.org&gt;
Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: add GPIO support</title>
<updated>2017-06-16T06:49:04+00:00</updated>
<author>
<name>Cédric Le Goater</name>
<email>clg@kaod.org</email>
</author>
<published>2017-06-09T13:12:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=c7e9e91a9be1ac4333051972dbc65e7cd2cea0dc'/>
<id>urn:sha1:c7e9e91a9be1ac4333051972dbc65e7cd2cea0dc</id>
<content type='text'>
The PCA955x family of chips are I2C LED blinkers whose pins not used
to control LEDs can be used as general purpose I/Os (GPIOs).

The following adds such a support by defining different operation
modes for the pins (See bindings documentation for more details). The
pca955x driver is then extended with a gpio_chip when some of pins are
operating as GPIOs. The default operating mode is to behave as a LED.

The GPIO support is conditioned by CONFIG_LEDS_PCA955X_GPIO.

OpenBMC-Staging-Count: 1
Signed-off-by: Cédric Le Goater &lt;clg@kaod.org&gt;
Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
</content>
</entry>
<entry>
<title>leds: pca955x: use devm_led_classdev_register</title>
<updated>2017-06-16T06:49:01+00:00</updated>
<author>
<name>Cédric Le Goater</name>
<email>clg@kaod.org</email>
</author>
<published>2017-06-09T13:12:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=5f86011a773e6fb8a21ba367b78c0d2ca75f5938'/>
<id>urn:sha1:5f86011a773e6fb8a21ba367b78c0d2ca75f5938</id>
<content type='text'>
This lets us remove the loop doing the cleanup in case of failure and
also the remove handler of the i2c_driver.

OpenBMC-Staging-Count: 1
Signed-off-by: Cédric Le Goater &lt;clg@kaod.org&gt;
Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
</content>
</entry>
</feed>
