mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
API to model LED.
CI jobs results: . https://cirrus-ci.com/build/4879251751043072 .207661784
.738958191
. https://app.shippable.com/github/philmd/qemu/runs/891/summary/console -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAl+XR88ACgkQ4+MsLN6t wN4Org//UPv8cTDvJwsS2vaw0CRHQmU7/t2hI6xN1mDMFaUDwj6AjtdO6W3FUOcV KQbwFP16Po684h4xhDayUs15RcPz/mCSaiiz4WkS3sA5M0y0SWQE+1HgvGZwrEXn o5j8Lilh8m4/WE97Q7hVPD2cesMv9W3EziWBMEqukaXCSnTfAURiUUWmXpu7jyQ8 tc439KhFXnLx6Gx/XyPoN2CLfC5q1OReGTGvAP2GqFDPxPnIAGyqHLaVOZBXlX3a PsRl9HKvuPL86zrSXLRqsnUiiQ5vHg0Quw4jntd+ZF+V97Qlg01x0BuxI2+9GqO4 b/RVBbvrLdWEpmKffr6EsmNNLaREeTfjQWVowD2uy3IK6JxkG7oiljAj7sDySSzs WYo8PCE/xpTtrtbLZNtRkkz3Ui/h0Qjdvi8oS/8k84/0/+fDufWekXz1pX6YZ4jI 2GK+aa/OrTZQh5uUYdzQPxf0ieviOVCSf0IgKvHkOlAqnZIQRkFmtIOdPyNlctQx cGNMT9pgz+n4g1ge9LaBlyAMwxCGkU5nygbbPyYHGZyN8xiDNUKOAMRhXgLiKpXb tbseixu4TDGr2iuc291G9dkeKbPkxeIE3NIbFwcB4UtTftxLko7pTZ5l3G0jvUt1 VCfK1ot6DKO8B+TzXyIgAWiZmWSV8KhHA4EkX4BihqLL3hIvlNk= =inaF -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/philmd-gitlab/tags/led-api-20201026' into staging API to model LED. CI jobs results: . https://cirrus-ci.com/build/4879251751043072 .207661784
.738958191
. https://app.shippable.com/github/philmd/qemu/runs/891/summary/console # gpg: Signature made Mon 26 Oct 2020 22:03:59 GMT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * remotes/philmd-gitlab/tags/led-api-20201026: hw/arm/tosa: Replace fprintf() calls by LED devices hw/misc/mps2-scc: Use the LED device hw/misc/mps2-fpgaio: Use the LED device hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1 hw/misc/led: Emit a trace event when LED intensity has changed hw/misc/led: Allow connecting from GPIO output hw/misc/led: Add a LED device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
cddfbe0774
14 changed files with 365 additions and 43 deletions
97
include/hw/misc/led.h
Normal file
97
include/hw/misc/led.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* QEMU single LED device
|
||||
*
|
||||
* Copyright (C) 2020 Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef HW_MISC_LED_H
|
||||
#define HW_MISC_LED_H
|
||||
|
||||
#include "qom/object.h"
|
||||
#include "hw/qdev-core.h"
|
||||
|
||||
#define TYPE_LED "led"
|
||||
|
||||
/**
|
||||
* LEDColor: Color of a LED
|
||||
*
|
||||
* This set is restricted to physically available LED colors.
|
||||
*
|
||||
* LED colors from 'Table 1. Product performance of LUXEON Rebel Color
|
||||
* Line' of the 'DS68 LUXEON Rebel Color Line' datasheet available at:
|
||||
* https://www.lumileds.com/products/color-leds/luxeon-rebel-color/
|
||||
*/
|
||||
typedef enum { /* Coarse wavelength range */
|
||||
LED_COLOR_VIOLET, /* 425 nm */
|
||||
LED_COLOR_BLUE, /* 475 nm */
|
||||
LED_COLOR_CYAN, /* 500 nm */
|
||||
LED_COLOR_GREEN, /* 535 nm */
|
||||
LED_COLOR_AMBER, /* 590 nm */
|
||||
LED_COLOR_ORANGE, /* 615 nm */
|
||||
LED_COLOR_RED, /* 630 nm */
|
||||
} LEDColor;
|
||||
|
||||
struct LEDState {
|
||||
/* Private */
|
||||
DeviceState parent_obj;
|
||||
/* Public */
|
||||
|
||||
uint8_t intensity_percent;
|
||||
qemu_irq irq;
|
||||
|
||||
/* Properties */
|
||||
char *description;
|
||||
char *color;
|
||||
/*
|
||||
* Determines whether a GPIO is using a positive (active-high)
|
||||
* logic (when used with GPIO, the intensity at reset is related
|
||||
* to the GPIO polarity).
|
||||
*/
|
||||
bool gpio_active_high;
|
||||
};
|
||||
typedef struct LEDState LEDState;
|
||||
DECLARE_INSTANCE_CHECKER(LEDState, LED, TYPE_LED)
|
||||
|
||||
/**
|
||||
* led_set_intensity: Set the intensity of a LED device
|
||||
* @s: the LED object
|
||||
* @intensity_percent: intensity as percentage in range 0 to 100.
|
||||
*/
|
||||
void led_set_intensity(LEDState *s, unsigned intensity_percent);
|
||||
|
||||
/**
|
||||
* led_get_intensity:
|
||||
* @s: the LED object
|
||||
*
|
||||
* Returns: The LED intensity as percentage in range 0 to 100.
|
||||
*/
|
||||
unsigned led_get_intensity(LEDState *s);
|
||||
|
||||
/**
|
||||
* led_set_state: Set the state of a LED device
|
||||
* @s: the LED object
|
||||
* @is_emitting: boolean indicating whether the LED is emitting
|
||||
*
|
||||
* This utility is meant for LED connected to GPIO.
|
||||
*/
|
||||
void led_set_state(LEDState *s, bool is_emitting);
|
||||
|
||||
/**
|
||||
* led_create_simple: Create and realize a LED device
|
||||
* @parentobj: the parent object
|
||||
* @gpio_polarity: GPIO polarity
|
||||
* @color: color of the LED
|
||||
* @description: description of the LED (optional)
|
||||
*
|
||||
* Create the device state structure, initialize it, and
|
||||
* drop the reference to it (the device is realized).
|
||||
*
|
||||
* Returns: The newly allocated and instantiated LED object.
|
||||
*/
|
||||
LEDState *led_create_simple(Object *parentobj,
|
||||
GpioPolarity gpio_polarity,
|
||||
LEDColor color,
|
||||
const char *description);
|
||||
|
||||
#endif /* HW_MISC_LED_H */
|
|
@ -22,6 +22,7 @@
|
|||
#define MPS2_FPGAIO_H
|
||||
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/misc/led.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_MPS2_FPGAIO "mps2-fpgaio"
|
||||
|
@ -33,6 +34,7 @@ struct MPS2FPGAIO {
|
|||
|
||||
/*< public >*/
|
||||
MemoryRegion iomem;
|
||||
LEDState *led[2];
|
||||
|
||||
uint32_t led0;
|
||||
uint32_t prescale;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define MPS2_SCC_H
|
||||
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/misc/led.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_MPS2_SCC "mps2-scc"
|
||||
|
@ -26,6 +27,7 @@ struct MPS2SCC {
|
|||
|
||||
/*< public >*/
|
||||
MemoryRegion iomem;
|
||||
LEDState *led[8];
|
||||
|
||||
uint32_t cfg0;
|
||||
uint32_t cfg1;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue