hw/misc: Add LED device
Subsystems (2)
v3 cover hw/misc: Add LED device
Hello,
These patches are part of the GSoC unselected 'QEMU visualizer' project. As the AVR port is not merged, I switched to microbit to keep working on it.
This series presents a proof of concept of LED device that can be easily connected to a GPIO.
Since v2:
- Rebased on PCA9552
- Model intensity to be ready for PWM use (Dave)
- Remove QMP events until we get a UI visualizer (Peter)
- Remove microbit patch (Peter)
Since v1: addressed Eric Blake review comments
- Added QMP rate limit
Next steps planned:
- PoC visualizer...
- look at using a dbus backend (elmarco)
- look at LED array/matrix such 7segments.
Regards,
Phil.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (7):
hw/misc: Add a LED device
hw/misc/led: Add helper to connect LED to GPIO output hw/misc/led: Emit a trace event when LED intensity has changed hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1 hw/misc/mps2-fpgaio: Use the LED device hw/misc/mps2-scc: Use the LED device
hw/arm/tosa: Replace fprintf() calls by LED devices
include/hw/misc/led.h | 100 ++++++++++++++++++++++ include/hw/misc/mps2-fpgaio.h | 1 + include/hw/misc/mps2-scc.h | 1 + hw/arm/aspeed.c | 17 ++++ hw/arm/tosa.c | 40 +++------ hw/misc/led.c | 151 ++++++++++++++++++++++++++++++++++ hw/misc/mps2-fpgaio.c | 13 +-- hw/misc/mps2-scc.c | 23 +++--- MAINTAINERS | 6 ++ hw/arm/Kconfig | 2 + hw/misc/Kconfig | 5 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 6 +- 13 files changed, 321 insertions(+), 45 deletions(-) create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.c
Signature · 1 line
2.21.3
PATCH v3 1/7 hw/misc: Add a LED device
Add a LED device which can be connected to a GPIO output. LEDs are limited to a set of colors.
They can also be dimmed with PWM devices. For now we do not implement the dimmed mode, but in preparation of a future implementation, we start using the LED intensity. When used with GPIOs, the intensity can only be either minium or maximum. This depends of the polarity of the GPIO.
--- include/hw/misc/led.h | 79 +++++++++++++++++++++++++++ hw/misc/led.c | 121 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 +++ hw/misc/Kconfig | 3 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 3 ++ 6 files changed, 213 insertions(+) create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.c
include/hw/misc/led.h new file +79 -0
@@ -0,0 +1,79 @@ +/* +* QEMU single LED device +* +* Copyright (C) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HW_MISC_LED_H +#define HW_MISC_LED_H + +#include "hw/qdev-core.h" + +#define TYPE_LED "led" +#define LED (obj) OBJECT_CHECK(LEDState, (obj), TYPE_LED) + +typedef enum { +LED_COLOR_UNKNOWN , +LED_COLOR_RED , +LED_COLOR_ORANGE , +LED_COLOR_AMBER , +LED_COLOR_YELLOW , +LED_COLOR_GREEN , +LED_COLOR_BLUE , +LED_COLOR_VIOLET ,/* PURPLE */ +LED_COLOR_WHITE , +LED_COLOR_COUNT +}LEDColor ; + +/* Definitions useful when a LED is connected to a GPIO */ +#define LED_RESET_INTENSITY_ACTIVE_LOW UINT16_MAX +#define LED_RESET_INTENSITY_ACTIVE_HIGH 0U + +typedef struct LEDState { +/* Private */ +DeviceState parent_obj; +/* Public */ + +/* Properties */ +char *description; +char *color; +/* +* When used with GPIO, the intensity at reset is related to GPIO polarity +*/ +uint16_t reset_intensity; +}LEDState ; + +/** +* led_set_intensity: set the intensity of a LED device +* @s: the LED object +* @intensity: new intensity +* +* This utility is meant for LED connected to PWM. +*/ +void led_set_intensity (LEDState *s,uint16_t intensity); + +/** +* led_set_intensity: set the state of a LED device +* @s: the LED object +* @is_on: boolean indicating whether the LED is emitting +* +* This utility is meant for LED connected to GPIO. +*/ +void led_set_state (LEDState *s,bool is_on); + +/** +* create_led: create and LED device +* @parent: the parent object +* @color: color of the LED +* @description: description of the LED (optional) +* @reset_intensity: LED intensity at reset +* +* This utility function creates a LED object. +*/ +DeviceState *create_led (Object *parentobj, +LEDColor color, +const char *description, +uint16_t reset_intensity); + +#endif /* HW_MISC_LED_H */
hw/misc/led.c new file +121 -0
121 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1863,6 +1863,12 @@ F: docs/specs/vmgenid.txt F: tests/qtest/vmgenid-test.c F: stubs/vmgenid.c +LED +M: Philippe Mathieu-Daudé <[email protected]> +S: Maintained +F: include/hw/misc/led.h +F: hw/misc/led.c + Unimplemented device M: Peter Maydell <[email protected]> R: Philippe Mathieu-Daudé <[email protected]>
hw/misc/Kconfig +3 -0
@@ -126,6 +126,9 @@ config AUX config UNIMP bool +config LED + bool + config MAC_VIA bool select MOS6522
hw/misc/Makefile.objs +1 -0
@@ -91,3 +91,4 @@ common-obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o obj-$(CONFIG_MAC_VIA) += mac_via.o common-obj-$(CONFIG_GRLIB) += grlib_ahb_apb_pnp.o +common-obj-$(CONFIG_LED) += led.o
hw/misc/trace-events +3 -0
@@ -207,6 +207,9 @@ via1_rtc_cmd_pram_sect_write(int sector, int offset, int addr, int value) "secto grlib_ahb_pnp_read(uint64_t addr, uint32_t value) "AHB PnP read addr:0x%03"PRIx64" data:0x%08x" grlib_apb_pnp_read(uint64_t addr, uint32_t value) "APB PnP read addr:0x%03"PRIx64" data:0x%08x" +# led.c +led_set_intensity(const char *color, const char *desc, uint16_t intensity) "LED desc:'%s' color:%s intensity: 0x%04"PRIx16 + # pca9552.c pca9552_gpio_status(const char *description, const char *buf) "%s GPIOs 0-15 [%s]" pca9552_gpio_change(const char *description, unsigned id, unsigned prev_state, unsigned current_state) "%s GPIO id:%u status: %u -> %u"
Signature · 1 line
2.21.3
Re: [PATCH v3 1/7] hw/misc: Add a LED device
Quoted 44 lines · Philippe Mathieu-Daudé
Add a LED device which can be connected to a GPIO output. LEDs are limited to a set of colors.
They can also be dimmed with PWM devices. For now we do not implement the dimmed mode, but in preparation of a future implementation, we start using the LED intensity. When used with GPIOs, the intensity can only be either minium or maximum. This depends of the polarity of the GPIO.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/misc/led.h | 79 +++++++++++++++++++++++++++ hw/misc/led.c | 121 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 +++ hw/misc/Kconfig | 3 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 3 ++ 6 files changed, 213 insertions(+) create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.cinclude/hw/misc/led.h new file +17
-0@@ -0,0 +1,79 @@ +/* +* QEMU single LED device +* +* Copyright (C) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HW_MISC_LED_H +#define HW_MISC_LED_H + +#include "hw/qdev-core.h" + +#define TYPE_LED "led" +#define LED(obj) OBJECT_CHECK(LEDState, (obj), TYPE_LED) + +typedef enum { + LED_COLOR_UNKNOWN,
include/hw/misc/led.h line 27
Quoted 10 lines
include/hw/misc/led.h new file +10
-0+LED_COLOR_RED , +LED_COLOR_ORANGE , +LED_COLOR_AMBER , +LED_COLOR_YELLOW , +LED_COLOR_GREEN , +LED_COLOR_BLUE , +LED_COLOR_VIOLET ,/* PURPLE */ +LED_COLOR_WHITE , +LED_COLOR_COUNT +} LEDColor;
Is color especially interesting, given that we only actually "display" the color via tracing?
include/hw/misc/led.h line 40
Quoted 12 lines
include/hw/misc/led.h new file +12
-0+/* Definitions useful when a LED is connected to a GPIO */ +#define LED_RESET_INTENSITY_ACTIVE_LOW UINT16_MAX +#define LED_RESET_INTENSITY_ACTIVE_HIGH 0U + +typedef struct LEDState { + /* Private */ + DeviceState parent_obj; + /* Public */ + + /* Properties */ + char *description; + char *color;
The enumeration is unused by the actual device, it would seem?
include/hw/misc/led.h line 63
Quoted 8 lines
include/hw/misc/led.h new file +8
-0+/** +* led_set_intensity: set the state of a LED device +* @s: the LED object +* @is_on: boolean indicating whether the LED is emitting +* +* This utility is meant for LED connected to GPIO. +*/ +void led_set_state (LEDState *s,bool is_on);
Comment mismatch.
include/hw/misc/led.h line 51
Quoted 4 lines
include/hw/misc/led.h new file +4
-0+void led_set_intensity (LEDState *s,uint16_t new_intensity) +{ +trace_led_set_intensity (s->description ? s->description :"n/a" , + s->color, new_intensity);
Why not default description upon reset/realize?
include/hw/misc/led.h line 60
Quoted 9 lines
include/hw/misc/led.h new file +9
-0+static void led_realize (DeviceState *dev,Error **errp) +{ +LEDState *s =LED (dev); + +if (s->color ==NULL ) { +error_setg (errp,"property 'color' not specified" ); +return ; + } +}
Indeed, why not insist that description is set? If a board is forced to say that the led is red, should it not also be forced to label it?
include/hw/misc/led.h line 62
Quoted 2 lines
include/hw/misc/led.h new file +2
-0+static Property led_properties[] = { +DEFINE_PROP_STRING ("color" , LEDState, color),
It would appear that one can set any color via properties, including "plaid". So if you do want the char *color field, what's the point in the enum?
include/hw/misc/led.h line 64
Quoted 2 lines
include/hw/misc/led.h new file +2
-0+# led .c +led_set_intensity(const char *color, const char *desc, uint16_t intensity) "LED desc:'%s' color:%s intensity: 0x%04"PRIx16
Is 0...65535 the best set of intensities?
Is that more valuable than e.g. a percentage?
r~
Re: [PATCH v3 1/7] hw/misc: Add a LED device
Hi Richard,
Quoted 50 lines · Richard Henderson
Quoted 49 lines · Philippe Mathieu-Daudé
Add a LED device which can be connected to a GPIO output. LEDs are limited to a set of colors.
They can also be dimmed with PWM devices. For now we do not implement the dimmed mode, but in preparation of a future implementation, we start using the LED intensity. When used with GPIOs, the intensity can only be either minium or maximum. This depends of the polarity of the GPIO.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/misc/led.h | 79 +++++++++++++++++++++++++++ hw/misc/led.c | 121 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 +++ hw/misc/Kconfig | 3 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 3 ++ 6 files changed, 213 insertions(+) create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.cinclude/hw/misc/led.h new file +22
-0@@ -0,0 +1,79 @@ +/* +* QEMU single LED device +* +* Copyright (C) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HW_MISC_LED_H +#define HW_MISC_LED_H + +#include "hw/qdev-core.h" + +#define TYPE_LED "led" +#define LED(obj) OBJECT_CHECK(LEDState, (obj), TYPE_LED) + +typedef enum { + LED_COLOR_UNKNOWN, + LED_COLOR_RED, + LED_COLOR_ORANGE, + LED_COLOR_AMBER, + LED_COLOR_YELLOW, + LED_COLOR_GREEN,
Quoted 8 lines
include/hw/misc/led.h line 27
Quoted 5 lines
include/hw/misc/led.h new file +5
-0+LED_COLOR_BLUE , +LED_COLOR_VIOLET ,/* PURPLE */ +LED_COLOR_WHITE , + LED_COLOR_COUNT +} LEDColor;Is color especially interesting, given that we only actually "display" the color via tracing?
The idea of this device is to easily visualize events. Currently via tracing, but eventually an external UI could introspect the board for devices able to represent visual changes such LEDs, and automatically display them.
To limit the list of representable object the visualizer has to support, I prefer to restrict this device to the existing LED physical colors.
Quoted 15 lines
include/hw/misc/led.h line 40
Quoted 13 lines
include/hw/misc/led.h new file +12
-0+/* Definitions useful when a LED is connected to a GPIO */ +#define LED_RESET_INTENSITY_ACTIVE_LOW UINT16_MAX +#define LED_RESET_INTENSITY_ACTIVE_HIGH 0U + +typedef struct LEDState { + /* Private */ + DeviceState parent_obj; + /* Public */ + + /* Properties */ + char *description; + char *color;The enumeration is unused by the actual device, it would seem?
I want to, but it seems having a enum qdev property involves a lot of code.
Quoted 13 lines
include/hw/misc/led.h line 63
Quoted 9 lines
include/hw/misc/led.h new file +8
-0+/** +* led_set_intensity: set the state of a LED device +* @s: the LED object +* @is_on: boolean indicating whether the LED is emitting +* +* This utility is meant for LED connected to GPIO. +*/ +void led_set_state (LEDState *s,bool is_on);Comment mismatch.
Quoted 6 lines
include/hw/misc/led.h line 51
Quoted 4 lines
include/hw/misc/led.h new file +4
-0+void led_set_intensity (LEDState *s,uint16_t new_intensity) +{ +trace_led_set_intensity (s->description ? s->description :"n/a" , + s->color, new_intensity);Why not default description upon reset/realize?
Yes.
Quoted 13 lines
include/hw/misc/led.h line 60
Quoted 10 lines
include/hw/misc/led.h new file +9
-0+static void led_realize (DeviceState *dev,Error **errp) +{ +LEDState *s =LED (dev); + +if (s->color ==NULL ) { +error_setg (errp,"property 'color' not specified" ); +return ; + } +}Indeed, why not insist that description is set? If a board is forced to say that the led is red, should it not also be forced to label it?
Because when we don't have access to the hardware schematics, we can not specify the label. I'll add a comment about this.
Quoted 6 lines
include/hw/misc/led.h line 62
Quoted 3 lines
include/hw/misc/led.h new file +2
-0+static Property led_properties[] = { +DEFINE_PROP_STRING ("color" , LEDState, color),It would appear that one can set any color via properties, including "plaid". So if you do want the char *color field, what's the point in the enum?
Good catch... I will either use an enum propery, or check the property is in the allowed color names.
Quoted 5 lines
include/hw/misc/led.h line 64
Quoted 3 lines
include/hw/misc/led.h new file +2
-0+# led .c +led_set_intensity(const char *color, const char *desc, uint16_t intensity) "LED desc:'%s' color:%s intensity: 0x%04"PRIx16Is 0...65535 the best set of intensities?
You are right. I was thinking of PWM resolution (limiting to 16-bits). This is a different API to model, I mixed.
Quoted 1 line
Is that more valuable than e.g. a percentage?
Yes, the [0-100] range of integer is sufficient to represent light intensity =)
Thanks for your review!
Phil.
Re: [PATCH v3 1/7] hw/misc: Add a LED device
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 2 lines
Is color especially interesting, given that we only actually "display" the color via tracing?
The idea of this device is to easily visualize events. Currently via tracing, but eventually an external UI could introspect the board for devices able to represent visual changes such LEDs, and automatically display them.
To limit the list of representable object the visualizer has to support, I prefer to restrict this device to the existing LED physical colors.
Ok. This does suggest that we do use then enum in the structure.
Quoted 5 lines
Quoted 2 lines
Indeed, why not insist that description is set? If a board is forced to say that the led is red, should it not also be forced to label it?
Because when we don't have access to the hardware schematics, we can not specify the label. I'll add a comment about this.
Well, if we don't have a hardware schematic label, then we must have the i/o pin; we could insist that the board label the led in some way that makes some sense.
r~
PATCH v3 2/7 hw/misc/led: Add helper to connect LED to GPIO output
In reply to Philippe Mathieu-DaudéSome devices expose GPIO lines. Add the create_led_by_gpio_id() helper to connect a LED to such GPIO.
---
Adding support for named GPIO is trivial. We don't need it yet.
--- include/hw/misc/led.h | 20 ++++++++++++++++++++ hw/misc/led.c | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
include/hw/misc/led.h +20 -0
@@ -35,6 +35,8 @@ typedef struct LEDState {DeviceState parent_obj;/* Public */ +qemu_irq irq; +/* Properties */ char *description;char *color;
@@ -76,4 +78,22 @@ DeviceState *create_led(Object *parentobj,const char *description, uint16_t reset_intensity); +/** +* create_led_by_gpio_id: create and LED device and connect it to a GPIO output +* @parent: the parent object +* @gpio_dev: device exporting GPIOs +* @gpio_id: GPIO ID of this LED +* @color: color of the LED +* @description: description of the LED (optional) +* @reset_intensity: LED intensity at reset +* +* This utility function creates a LED and connects it to a +* GPIO exported by another device. +*/ +DeviceState *create_led_by_gpio_id (Object *parentobj, +DeviceState *gpio_dev,unsigned gpio_id, +LEDColor color, +const char *description, +uint16_t reset_intensity); +#endif /* HW_MISC_LED_H */
hw/misc/led.c +25 -0
@@ -10,6 +10,7 @@#include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/misc/led.h" +#include "hw/irq.h" #include "trace.h" static const char *led_color (LEDColor color)
@@ -39,6 +40,14 @@ void led_set_state(LEDState *s, bool is_on)led_set_intensity (s, is_on ?UINT16_MAX :0 ); } +static void gpio_led_set (void *opaque,int line,int new_state) +{ +LEDState *s =LED (opaque); + +assert (line ==0 ); +led_set_state (s, !!new_state); +} +static void led_reset (DeviceState *dev) {LEDState *s =LED (dev);
@@ -63,6 +72,8 @@ static void led_realize(DeviceState *dev, Error **errp)error_setg (errp,"property 'color' not specified" );return ; } + +qdev_init_gpio_in (DEVICE (s), gpio_led_set,1 ); }static Property led_properties[] = {
@@ -119,3 +130,17 @@ DeviceState *create_led(Object *parentobj,return dev; } + +DeviceState *create_led_by_gpio_id (Object *parentobj, +DeviceState *gpio_dev,unsigned gpio_id, +LEDColor color, +const char *description, +uint16_t reset_intensity) +{ +DeviceState *dev; + + dev =create_led (parentobj, color, description, reset_intensity); +qdev_connect_gpio_out (gpio_dev, gpio_id,qdev_get_gpio_in (dev,0 )); + +return dev; +}
Signature · 1 line
2.21.3
Re: [PATCH v3 2/7] hw/misc/led: Add helper to connect LED to GPIO output
Quoted 10 lines · Philippe Mathieu-Daudé
Some devices expose GPIO lines. Add the
create_led_by_gpio_id()helper to connect a LED to such GPIO.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Adding support for named GPIO is trivial. We don't need it yet.--- include/hw/misc/led.h | 20 ++++++++++++++++++++ hw/misc/led.c | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
Modulo my question re colors, looks good.
r~
PATCH v3 3/7 hw/misc/led: Emit a trace event when LED intensity has changed
In reply to Philippe Mathieu-DaudéTrack the LED intensity, and emit a trace event when it changes.
--- include/hw/misc/led.h | 1 + hw/misc/led.c | 5 +++++ hw/misc/trace-events | 1 + 3 files changed, 7 insertions(+)
include/hw/misc/led.h +1 -0
@@ -35,6 +35,7 @@ typedef struct LEDState {DeviceState parent_obj;/* Public */ +uint16_t current_intensity;qemu_irq irq;/* Properties */
hw/misc/led.c +5 -0
@@ -32,6 +32,11 @@ void led_set_intensity(LEDState *s, uint16_t new_intensity) {trace_led_set_intensity (s->description ? s->description :"n/a" , s->color, new_intensity); +if (new_intensity != s->current_intensity) { +trace_led_change_intensity (s->description ? s->description :"n/a" , + s->color, + s->current_intensity, new_intensity); + } s->current_intensity = new_intensity; }
hw/misc/trace-events +1 -0
@@ -209,6 +209,7 @@ grlib_apb_pnp_read(uint64_t addr, uint32_t value) "APB PnP read addr:0x%03"PRIx6 # led.c led_set_intensity(const char *color, const char *desc, uint16_t intensity) "LED desc:'%s' color:%s intensity: 0x%04"PRIx16 +led_change_intensity(const char *color, const char *desc, uint16_t old_intensity, uint16_t new_intensity) "LED desc:'%s' color:%s intensity 0x%04"PRIx16" -> 0x%04"PRIx16"" # pca9552.c pca9552_gpio_status(const char *description, const char *buf) "%s GPIOs 0-15 [%s]"
Signature · 1 line
2.21.3
Re: [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed
Quoted 14 lines · Philippe Mathieu-Daudé
Track the LED intensity, and emit a trace event when it changes.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/misc/led.h | 1 + hw/misc/led.c | 5 +++++ hw/misc/trace-events | 1 + 3 files changed, 7 insertions(+)include/hw/misc/led.h +0
-0
include/hw/misc/led.h typedef struct LEDState { · line 39
Quoted 5 lines
include/hw/misc/led.h +1
-0@@ -35,6 +35,7 @@ typedef struct LEDState {DeviceState parent_obj;/* Public */ +uint16_t current_intensity;qemu_irq irq;
Why not sort this new field next to the other uint16_t and (partially) fill the hole?
Otherwise,
r~
Re: [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed
Quoted 18 lines · Richard Henderson
Quoted 17 lines · Philippe Mathieu-Daudé
Track the LED intensity, and emit a trace event when it changes.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/misc/led.h | 1 + hw/misc/led.c | 5 +++++ hw/misc/trace-events | 1 + 3 files changed, 7 insertions(+)include/hw/misc/led.h +0
-0@@ -35,6 +35,7 @@ typedef struct LEDState {DeviceState parent_obj;/* Public */
Quoted 5 lines
include/hw/misc/led.h typedef struct LEDState { · line 39
Quoted 2 lines
include/hw/misc/led.h +1
-0+uint16_t current_intensity;qemu_irq irq;Why not sort this new field next to the other
uint16_tand (partially) fill the hole?
From a reviewer point of view, I prefer to keep the state fields separated from the properties fields, wasting few bits of RAM.
Anyway I switched to a percent value. What is better to hold it, an 'unsigned' or 'uint8_t' type?
Quoted 3 lines
Otherwise,
Reviewed-by Richard Henderson <[email protected]>
Thanks!
Quoted 4 lines
r~
Re: [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed
Quoted 2 lines · Philippe Mathieu-Daudé
Anyway I switched to a percent value. What is better to hold it, an 'unsigned' or '
uint8_t' type?
Might as well use unsigned; you'll not be saving space with uint8_t.
r~
Re: [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed
Quoted 5 lines · Richard Henderson
Quoted 2 lines · Philippe Mathieu-Daudé
Anyway I switched to a percent value. What is better to hold it, an 'unsigned' or '
uint8_t' type?Might as well use unsigned; you'll not be saving space with
uint8_t.
Bah if we want to migrate the intensity, we can't use 'unsigned', so I'll keep uint8_t / VMSTATE_UINT8.
PATCH v3 4/7 hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1
In reply to Philippe Mathieu-DaudéThe Witherspoon has 3 LEDs connected to a PCA9552. Add them. The names and reset values are taken from:
https://github.com/open-power/witherspoon-xml/blob/master/witherspoon.xml
Example booting obmc-phosphor-image:
$ qemu-system-arm -M witherspoon-bmc -trace led_change_intensity 1592693373.997015:led_change_intensity LED desc:'front-fault-4' color:green intensity 0x0000 -> 0xffff 1592693373.997632:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693373.998239:led_change_intensity LED desc:'front-id-5' color:green intensity 0x0000 -> 0xffff 1592693500.291805:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693500.312041:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693500.821254:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693501.331517:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693501.841367:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693502.350839:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693502.861134:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693503.371090:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff
We notice the front-power LED starts to blink.
--- hw/arm/aspeed.c | 17 +++++++++++++++++ hw/arm/Kconfig | 1 + 2 files changed, 18 insertions(+)
hw/arm/aspeed.c +17 -0
@@ -20,6 +20,7 @@#include "hw/i2c/smbus_eeprom.h" #include "hw/misc/pca9552.h" #include "hw/misc/tmp105.h" +#include "hw/misc/led.h" #include "hw/qdev-properties.h" #include "qemu/log.h" #include "sysemu/block-backend.h"
@@ -506,6 +507,16 @@ static void sonorapass_bmc_i2c_init(AspeedBoardState *bmc)static void witherspoon_bmc_i2c_init (AspeedBoardState *bmc) { +static const struct { +unsigned gpio_id; +LEDColor color; +const char *description; +uint16_t reset_intensity; + } pca1_leds[] = { + {13 ,LED_COLOR_GREEN ,"front-fault-4" ,LED_RESET_INTENSITY_ACTIVE_LOW }, + {14 ,LED_COLOR_GREEN ,"front-power-3" ,LED_RESET_INTENSITY_ACTIVE_LOW }, + {15 ,LED_COLOR_GREEN ,"front-id-5" ,LED_RESET_INTENSITY_ACTIVE_LOW }, + };AspeedSoCState *soc = &bmc->soc;uint8_t *eeprom_buf =g_malloc0 (8 *1024 );DeviceState *dev;
@@ -518,6 +529,12 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)i2c_realize_and_unref (dev,aspeed_i2c_get_bus (DEVICE (&soc->i2c),3 ), &error_fatal); +for (size_t i =0 ; i <ARRAY_SIZE (pca1_leds); i++) { +create_led_by_gpio_id (OBJECT (bmc), dev, + pca1_leds[i].gpio_id, pca1_leds[i].color, + pca1_leds[i].description, + pca1_leds[i].reset_intensity); + }i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),4 ),"tmp423" ,0x4c );i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),5 ),"tmp423" ,0x4c );
hw/arm/Kconfig +1 -0
@@ -393,6 +393,7 @@ config ASPEED_SOC select TMP105 select TMP421 select UNIMP + select LED config MPS2 bool
Signature · 1 line
2.21.3
Re: [PATCH v3 4/7] hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1
Quoted 19 lines · Philippe Mathieu-Daudé
The Witherspoon has 3 LEDs connected to a PCA9552. Add them. The names and reset values are taken from:
https://github.com/open-power/witherspoon-xml/blob/master/witherspoon.xmlExample booting obmc-phosphor-image:
$ qemu-system-arm -M witherspoon-bmc -trace led_change_intensity 1592693373.997015:led_change_intensity LED desc:'front-fault-4' color:green intensity 0x0000 -> 0xffff 1592693373.997632:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693373.998239:led_change_intensity LED desc:'front-id-5' color:green intensity 0x0000 -> 0xffff 1592693500.291805:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693500.312041:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693500.821254:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693501.331517:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693501.841367:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693502.350839:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff 1592693502.861134:led_change_intensity LED desc:'front-power-3' color:green intensity 0xffff -> 0x0000 1592693503.371090:led_change_intensity LED desc:'front-power-3' color:green intensity 0x0000 -> 0xffff
Quoted 7 lines
We notice the front-power LED starts to blink.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/aspeed.c | 17 +++++++++++++++++ hw/arm/Kconfig | 1 + 2 files changed, 18 insertions(+)
r~
PATCH v3 5/7 hw/misc/mps2-fpgaio: Use the LED device
In reply to Philippe Mathieu-DaudéPer the 'ARM MPS2 and MPS2+ FPGA Prototyping Boards Technical Reference Manual' (100112_0200_07_en):
2.1 Overview of the MPS2 and MPS2+ hardware
The MPS2 and MPS2+ FPGA Prototyping Boards contain the following components and interfaces:
* User switches and user LEDs:
- Two green LEDs and two push buttons that connect to the FPGA.
- Eight green LEDs and one 8-way dip switch that connect to the MCC.
Add the 2 LEDs connected to the FPGA.
This remplaces the 'mps2_fpgaio_leds' trace events by the generic 'led_set_intensity' event.
--- include/hw/misc/mps2-fpgaio.h | 1 + hw/misc/mps2-fpgaio.c | 13 ++++++++----- hw/misc/Kconfig | 1 + hw/misc/trace-events | 1 - 4 files changed, 10 insertions(+), 6 deletions(-)
include/hw/misc/mps2-fpgaio.h +1 -0
@@ -32,6 +32,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +DeviceState *led[2 ];uint32_t led0;uint32_t prescale;
hw/misc/mps2-fpgaio.c +8 -5
@@ -24,6 +24,7 @@#include "migration/vmstate.h" #include "hw/registerfields.h" #include "hw/misc/mps2-fpgaio.h" +#include "hw/misc/led.h" #include "hw/qdev-properties.h" #include "qemu/timer.h"
@@ -176,12 +177,9 @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,switch (offset) {case A_LED0 : -/* LED bits [1:0] control board LEDs. We don't currently have -* a mechanism for displaying this graphically, so use a trace event. -*/ -trace_mps2_fpgaio_leds (value &0x02 ?'*' :'.' , - value &0x01 ?'*' :'.' ); s->led0 = value &0x3 ; +led_set_state (LED (s->led[0 ]), value &0x01 ); +led_set_state (LED (s->led[1 ]), value &0x02 );break ;case A_PRESCALE :resync_counter (s);
@@ -249,6 +247,11 @@ static void mps2_fpgaio_init(Object *obj)memory_region_init_io (&s->iomem, obj, &mps2_fpgaio_ops, s,"mps2-fpgaio" ,0x1000 );sysbus_init_mmio (sbd, &s->iomem); + + s->led[0 ] =create_led (obj,LED_COLOR_GREEN , +"USERLED0" ,LED_RESET_INTENSITY_ACTIVE_HIGH ); + s->led[1 ] =create_led (obj,LED_COLOR_GREEN , +"USERLED1" ,LED_RESET_INTENSITY_ACTIVE_HIGH ); }static bool mps2_fpgaio_counters_needed (void *opaque)
hw/misc/Kconfig +1 -0
@@ -93,6 +93,7 @@ config MIPS_ITU config MPS2_FPGAIO bool + select LED config MPS2_SCC bool
hw/misc/trace-events +0 -1
@@ -89,7 +89,6 @@ mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC mps2_fpgaio_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_fpgaio_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_fpgaio_reset(void) "MPS2 FPGAIO: reset" -mps2_fpgaio_leds(char led1, char led0) "MPS2 FPGAIO LEDs: %c%c" # msf2-sysreg.c msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" PRIx64 " data 0x%" PRIx32 " prev 0x%" PRIx32
Signature · 1 line
2.21.3
Re: [PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device
Quoted 1 line · Philippe Mathieu-Daudé
+ DeviceState *led[2];
Perhaps better as LEDState? And perhaps return that from create_led.
r~
Re: [PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device
Quoted 4 lines · Richard Henderson
Quoted 1 line · Philippe Mathieu-Daudé
+ DeviceState *led[2];
Perhaps better as LEDState? And perhaps return that from
create_led.
I guess I first thought about using an opaque structure with forward typedef declaration, but in this case I also prefer your suggestion.
Thanks :)
PATCH v3 6/7 hw/misc/mps2-scc: Use the LED device
In reply to Philippe Mathieu-DaudéPer the 'ARM MPS2 and MPS2+ FPGA Prototyping Boards Technical Reference Manual' (100112_0200_07_en):
2.1 Overview of the MPS2 and MPS2+ hardware
The MPS2 and MPS2+ FPGA Prototyping Boards contain the following components and interfaces:
* User switches and user LEDs:
- Two green LEDs and two push buttons that connect to the FPGA.
- Eight green LEDs and one 8-way dip switch that connect to the MCC.
Add the 8 LEDs connected to the MCC.
This remplaces the 'mps2_scc_leds' trace events by the generic 'led_set_intensity' event.
---
https://youtu.be/l9kD70uPchk?t=288
--- include/hw/misc/mps2-scc.h | 1 + hw/misc/mps2-scc.c | 23 ++++++++++++----------- hw/misc/Kconfig | 1 + hw/misc/trace-events | 1 - 4 files changed, 14 insertions(+), 12 deletions(-)
include/hw/misc/mps2-scc.h +1 -0
@@ -25,6 +25,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +DeviceState *led[8 ];uint32_t cfg0;uint32_t cfg1;
hw/misc/mps2-scc.c +12 -11
@@ -20,11 +20,13 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qemu/bitops.h" #include "trace.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/registerfields.h" #include "hw/misc/mps2-scc.h" +#include "hw/misc/led.h" #include "hw/qdev-properties.h" REG32 (CFG0 ,0 )
@@ -152,18 +154,10 @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, s->cfg0 = value;break ;case A_CFG1 : -/* CFG1 bits [7:0] control the board LEDs. We don't currently have -* a mechanism for displaying this graphically, so use a trace event. -*/ -trace_mps2_scc_leds (value &0x80 ?'*' :'.' , - value &0x40 ?'*' :'.' , - value &0x20 ?'*' :'.' , - value &0x10 ?'*' :'.' , - value &0x08 ?'*' :'.' , - value &0x04 ?'*' :'.' , - value &0x02 ?'*' :'.' , - value &0x01 ?'*' :'.' ); s->cfg1 = value; +for (size_t i =0 ; i <ARRAY_SIZE (s->led); i++) { +led_set_state (LED (s->led[i]), !!extract32 (value, i,1 )); + }break ;case A_CFGDATA_OUT : s->cfgdata_out = value;
@@ -245,6 +239,13 @@ static void mps2_scc_init(Object *obj)memory_region_init_io (&s->iomem, obj, &mps2_scc_ops, s,"mps2-scc" ,0x1000 );sysbus_init_mmio (sbd, &s->iomem); + +for (size_t i =0 ; i <ARRAY_SIZE (s->led); i++) { +char *name =g_strdup_printf ("SCC LED%zu" , i); + s->led[i] =create_led (obj,LED_COLOR_GREEN , + name,LED_RESET_INTENSITY_ACTIVE_HIGH ); +g_free (name); + } }static void mps2_scc_realize (DeviceState *dev,Error **errp)
hw/misc/Kconfig +1 -0
@@ -97,6 +97,7 @@ config MPS2_FPGAIO config MPS2_SCC bool + select LED config TZ_MPC bool
hw/misc/trace-events +0 -1
@@ -81,7 +81,6 @@ aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_scc_reset(void) "MPS2 SCC: reset" -mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c" mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32 mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
Signature · 1 line
2.21.3
Re: [PATCH v3 6/7] hw/misc/mps2-scc: Use the LED device
Quoted 83 lines · Philippe Mathieu-Daudé
Per the 'ARM MPS2 and MPS2+ FPGA Prototyping Boards Technical Reference Manual' (100112_0200_07_en):
2.1 Overview of the MPS2 and MPS2+ hardware
The MPS2 and MPS2+ FPGA Prototyping Boards contain the following components and interfaces:
* User switches and user LEDs:
- Two green LEDs and two push buttons that connect to the FPGA.
- Eight green LEDs and one 8-way dip switch that connect to the MCC.Add the 8 LEDs connected to the MCC.
This remplaces the '
mps2_scc_leds' trace events by the generic 'led_set_intensity' event.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
https://youtu.be/l9kD70uPchk?t=288--- include/hw/misc/mps2-scc.h | 1 + hw/misc/mps2-scc.c | 23 ++++++++++++----------- hw/misc/Kconfig | 1 + hw/misc/trace-events | 1 - 4 files changed, 14 insertions(+), 12 deletions(-)include/hw/misc/mps2-scc.h +1
-0@@ -25,6 +25,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +DeviceState *led[8 ];uint32_t cfg0;uint32_t cfg1;hw/misc/mps2-scc.c +5
-11@@ -20,11 +20,13 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qemu/bitops.h" #include "trace.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/registerfields.h" #include "hw/misc/mps2-scc.h" +#include "hw/misc/led.h" #include "hw/qdev-properties.h" REG32 (CFG0 ,0 )@@ -152,18 +154,10 @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, s->cfg0 = value;break ;case A_CFG1 : -/* CFG1 bits [7:0] control the board LEDs. We don't currently have -* a mechanism for displaying this graphically, so use a trace event. -*/ -trace_mps2_scc_leds (value &0x80 ?'*' :'.' , - value &0x40 ?'*' :'.' , - value &0x20 ?'*' :'.' , - value &0x10 ?'*' :'.' , - value &0x08 ?'*' :'.' , - value &0x04 ?'*' :'.' , - value &0x02 ?'*' :'.' , - value &0x01 ?'*' :'.' ); s->cfg1 = value; +for (size_t i =0 ; i <ARRAY_SIZE (s->led); i++) { +led_set_state (LED (s->led[i]), !!extract32 (value, i,1 )); + }break ;case A_CFGDATA_OUT : s->cfgdata_out = value;
hw/misc/mps2-scc.c static void mps2_scc_init(Object *obj) · line 248
Quoted 10 lines
hw/misc/mps2-scc.c +7
-0@@ -245,6 +239,13 @@ static void mps2_scc_init(Object *obj)memory_region_init_io (&s->iomem, obj, &mps2_scc_ops, s,"mps2-scc" ,0x1000 );sysbus_init_mmio (sbd, &s->iomem); + +for (size_t i =0 ; i <ARRAY_SIZE (s->led); i++) { +char *name =g_strdup_printf ("SCC LED%zu" , i); + s->led[i] =create_led (obj,LED_COLOR_GREEN , + name,LED_RESET_INTENSITY_ACTIVE_HIGH ); +g_free (name); + }
This has to go ...
hw/misc/mps2-scc.c static void mps2_scc_init(Object *obj) · line 251
Quoted 3 lines
hw/misc/mps2-scc.c +0
-0}static void mps2_scc_realize (DeviceState *dev,Error **errp)
... here to avoid:
** ERROR:/tmp/qemu-test/src/hw/core/qdev.c:1074:device_finalize: assertion
failed: (dev->canonical_path)
Broken pipe/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
Quoted 25 lines
hw/misc/Kconfig +1
-0@@ -97,6 +97,7 @@ config MPS2_FPGAIO config MPS2_SCC bool + select LED config TZ_MPC boolhw/misc/trace-events +0
-1@@ -81,7 +81,6 @@ aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_scc_reset(void) "MPS2 SCC: reset" -mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c" mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32 mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
Re: [PATCH v3 6/7] hw/misc/mps2-scc: Use the LED device
In reply to Philippe Mathieu-Daudéinclude/hw/misc/mps2-scc.h typedef struct { · line 28
Quoted 5 lines · Philippe Mathieu-Daudé
include/hw/misc/mps2-scc.h +1
-0@@ -25,6 +25,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +DeviceState *led[8 ];
LEDState?
hw/misc/mps2-scc.c static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, · line 160
Quoted 3 lines
hw/misc/mps2-scc.c +3
-0+for (size_t i =0 ; i <ARRAY_SIZE (s->led); i++) { +led_set_state (LED (s->led[i]), !!extract32 (value, i,1 )); + }
No need for !!.
r~
PATCH v3 7/7 hw/arm/tosa: Replace fprintf() calls by LED devices
In reply to Philippe Mathieu-DaudéThe recently added LED device reports LED status changes with the 'led_set_intensity' trace event. It is less invasive than the fprintf() calls. We need however to have a binary built with tracing support.
--- hw/arm/tosa.c | 40 +++++++++++++--------------------------- hw/arm/Kconfig | 1 + 2 files changed, 14 insertions(+), 27 deletions(-)
hw/arm/tosa.c +13 -27
@@ -24,6 +24,7 @@#include "hw/irq.h" #include "hw/ssi/ssi.h" #include "hw/sysbus.h" +#include "hw/misc/led.h" #include "exec/address-spaces.h" #define TOSA_RAM 0x04000000
@@ -65,27 +66,6 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)pxa2xx_pcmcia_attach (cpu->pcmcia[0 ], md); } -static void tosa_out_switch (void *opaque,int line,int level) -{ -switch (line) { -case 0 : -fprintf (stderr,"blue LED %s.\n" , level ?"on" :"off" ); -break ; -case 1 : -fprintf (stderr,"green LED %s.\n" , level ?"on" :"off" ); -break ; -case 2 : -fprintf (stderr,"amber LED %s.\n" , level ?"on" :"off" ); -break ; -case 3 : -fprintf (stderr,"wlan LED %s.\n" , level ?"on" :"off" ); -break ; -default : -fprintf (stderr,"Uhandled out event: %d = %d\n" , line, level); -break ; - } -} -static void tosa_reset (void *opaque,int line,int level) {if (level) {
@@ -98,7 +78,6 @@ static void tosa_gpio_setup(PXA2xxState *cpu, DeviceState *scp1, TC6393xbState *tmio) { -qemu_irq *outsignals =qemu_allocate_irqs (tosa_out_switch, cpu,4 );qemu_irq reset;/* MMC/SD host */
@@ -119,11 +98,6 @@ static void tosa_gpio_setup(PXA2xxState *cpu,qdev_get_gpio_in (cpu->gpio,TOSA_GPIO_JC_CF_IRQ ), NULL); -qdev_connect_gpio_out (scp1,TOSA_GPIO_BT_LED , outsignals[0 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_NOTE_LED , outsignals[1 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_CHRG_ERR_LED , outsignals[2 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_WLAN_LED , outsignals[3 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_TC6393XB_L3V_ON ,tc6393xb_l3v_get (tmio));/* UDC Vbus */
@@ -234,6 +208,18 @@ static void tosa_init(MachineState *machine) scp0 =sysbus_create_simple ("scoop" ,0x08800000 ,NULL ); scp1 =sysbus_create_simple ("scoop" ,0x14800040 ,NULL ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_BT_LED , +LED_COLOR_BLUE ,"bluetooth" ,0 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_NOTE_LED , +LED_COLOR_GREEN ,"note" ,1 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_CHRG_ERR_LED , +LED_COLOR_AMBER ,"charger-error" ,2 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_WLAN_LED , +LED_COLOR_GREEN ,"wlan" ,3 );tosa_gpio_setup (mpu, scp0, scp1, tmio);
hw/arm/Kconfig +1 -0
@@ -150,6 +150,7 @@ config TOSA select ZAURUS # scoop select MICRODRIVE select PXA2XX + select LED config SPITZ bool
Signature · 1 line
2.21.3
Re: [PATCH v3 7/7] hw/arm/tosa: Replace fprintf() calls by LED devices
Quoted 77 lines · Philippe Mathieu-Daudé
The recently added LED device reports LED status changes with the '
led_set_intensity' trace event. It is less invasive than thefprintf()calls. We need however to have a binary built with tracing support.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/tosa.c | 40 +++++++++++++--------------------------- hw/arm/Kconfig | 1 + 2 files changed, 14 insertions(+), 27 deletions(-)hw/arm/tosa.c +3
-27@@ -24,6 +24,7 @@#include "hw/irq.h" #include "hw/ssi/ssi.h" #include "hw/sysbus.h" +#include "hw/misc/led.h" #include "exec/address-spaces.h" #define TOSA_RAM 0x04000000@@ -65,27 +66,6 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)pxa2xx_pcmcia_attach (cpu->pcmcia[0 ], md); } -static void tosa_out_switch (void *opaque,int line,int level) -{ -switch (line) { -case 0 : -fprintf (stderr,"blue LED %s.\n" , level ?"on" :"off" ); -break ; -case 1 : -fprintf (stderr,"green LED %s.\n" , level ?"on" :"off" ); -break ; -case 2 : -fprintf (stderr,"amber LED %s.\n" , level ?"on" :"off" ); -break ; -case 3 : -fprintf (stderr,"wlan LED %s.\n" , level ?"on" :"off" ); -break ; -default : -fprintf (stderr,"Uhandled out event: %d = %d\n" , line, level); -break ; - } -} -static void tosa_reset (void *opaque,int line,int level) {if (level) {@@ -98,7 +78,6 @@ static void tosa_gpio_setup(PXA2xxState *cpu, DeviceState *scp1, TC6393xbState *tmio) { -qemu_irq *outsignals =qemu_allocate_irqs (tosa_out_switch, cpu,4 );qemu_irq reset;/* MMC/SD host */ @@ -119,11 +98,6 @@ static void tosa_gpio_setup(PXA2xxState *cpu,qdev_get_gpio_in (cpu->gpio,TOSA_GPIO_JC_CF_IRQ ), NULL); -qdev_connect_gpio_out (scp1,TOSA_GPIO_BT_LED , outsignals[0 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_NOTE_LED , outsignals[1 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_CHRG_ERR_LED , outsignals[2 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_WLAN_LED , outsignals[3 ]); -qdev_connect_gpio_out (scp1,TOSA_GPIO_TC6393XB_L3V_ON ,tc6393xb_l3v_get (tmio));/* UDC Vbus */ @@ -234,6 +208,18 @@ static void tosa_init(MachineState *machine) scp0 =sysbus_create_simple ("scoop" ,0x08800000 ,NULL ); scp1 =sysbus_create_simple ("scoop" ,0x14800040 ,NULL ); + create_led_by_gpio_id(OBJECT(machine), DEVICE(scp1), + TOSA_GPIO_BT_LED,
hw/arm/tosa.c static void tosa_init(MachineState *machine) · line 222
Quoted 10 lines
hw/arm/tosa.c +10
-0+ LED_COLOR_BLUE, "bluetooth", 0); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_NOTE_LED , +LED_COLOR_GREEN ,"note" ,1 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_CHRG_ERR_LED , +LED_COLOR_AMBER ,"charger-error" ,2 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (scp1), +TOSA_GPIO_WLAN_LED , +LED_COLOR_GREEN ,"wlan" ,3 );
Oops, wrong last argument...
Quoted 16 lines
hw/arm/tosa.c +0
-0tosa_gpio_setup (mpu, scp0, scp1, tmio);hw/arm/Kconfig +1
-0@@ -150,6 +150,7 @@ config TOSA select ZAURUS # scoop select MICRODRIVE select PXA2XX + select LED config SPITZ bool
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
TEST iotest-qcow2: 143
TEST iotest-qcow2: 150
**
ERROR:/tmp/qemu-test/src/hw/core/qdev.c:1074:device_finalize: assertion failed: (dev->canonical_path)
Broken pipe/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 154
TEST iotest-qcow2: 156
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=33590eb6142241b28b0d323737d99da2', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-0uwqudqi/src/docker-src.2020-06-20-19.46.06.26129:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=33590eb6142241b28b0d323737d99da2
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-0uwqudqi/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 12m38.919s
user 0m8.142s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]