hw/misc/led: Allow connecting from GPIO output

Some devices expose GPIO lines.

Add a GPIO qdev input to our LED device, so we can
connect a GPIO output using qdev_connect_gpio_out().

When used with GPIOs, the intensity can only be either
minium or maximum. This depends of the polarity of the
GPIO (which can be inverted).
Declare the GpioPolarity type to model the polarity.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Message-Id: <20200912134041.946260-3-f4bug@amsat.org>
This commit is contained in:
Philippe Mathieu-Daudé 2020-06-16 06:23:50 +02:00
parent c1b2982627
commit ddb67f6402
3 changed files with 42 additions and 1 deletions

View file

@ -443,6 +443,22 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
void qdev_machine_creation_done(void);
bool qdev_machine_modified(void);
/**
* GpioPolarity: Polarity of a GPIO line
*
* GPIO lines use either positive (active-high) logic,
* or negative (active-low) logic.
*
* In active-high logic (%GPIO_POLARITY_ACTIVE_HIGH), a pin is
* active when the voltage on the pin is high (relative to ground);
* whereas in active-low logic (%GPIO_POLARITY_ACTIVE_LOW), a pin
* is active when the voltage on the pin is low (or grounded).
*/
typedef enum {
GPIO_POLARITY_ACTIVE_LOW,
GPIO_POLARITY_ACTIVE_HIGH
} GpioPolarity;
/**
* qdev_get_gpio_in: Get one of a device's anonymous input GPIO lines
* @dev: Device whose GPIO we want