hw/misc: Add LED device
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.
The LED emit QMP events, so an external visualizer can display the LED events.
If there is no negative opinion on this series, next step will be add Zephyr test for the microbit, then we'll work on LED array/matrix.
Regards,
Phil.
Philippe Mathieu-Daudé (5):
hw/misc: Add a LED device
hw/misc/led: Add LED_STATUS_CHANGED QAPI event hw/misc/led: Add create_led_by_gpio_id() helper hw/arm/microbit: Add a fake LED to use as proof-of-concept with Zephyr hw/arm/tosa: Use LED device for the Bluetooth led
qapi/led.json | 47 ++++++++++++++++++ qapi/qapi-schema.json | 1 + include/hw/misc/led.h | 44 +++++++++++++++++ hw/arm/microbit.c | 3 ++ hw/arm/tosa.c | 7 ++- hw/misc/led.c | 108 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 7 +++ hw/arm/Kconfig | 2 + hw/misc/Kconfig | 3 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 3 ++ qapi/Makefile.objs | 2 +- 12 files changed, 223 insertions(+), 5 deletions(-) create mode 100644 qapi/led.json create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.c
Signature · 1 line
2.21.3
RFC PATCH 1/5 hw/misc: Add a LED device
A LED device can be connected to a GPIO output.
--- include/hw/misc/led.h | 30 ++++++++++++++++ hw/misc/led.c | 84 +++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 ++++ hw/misc/Kconfig | 3 ++ hw/misc/Makefile.objs | 1 + hw/misc/trace-events | 3 ++ 6 files changed, 127 insertions(+) create mode 100644 include/hw/misc/led.h create mode 100644 hw/misc/led.c
include/hw/misc/led.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* 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" +#include "hw/sysbus.h" /* FIXME remove */ + +#define TYPE_LED "led" +#define LED (obj) OBJECT_CHECK(LEDState, (obj), TYPE_LED) + +typedef struct LEDState { +/* Private */ +SysBusDevice parent_obj;/* FIXME DeviceState */ +/* Public */ + +qemu_irq irq; +uint8_t current_state; + +/* Properties */ +char *name; +uint8_t reset_state;/* TODO [GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH] */ +}LEDState ; + +#endif /* HW_MISC_LED_H */
hw/misc/led.c new file +84 -0
84 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1864,6 +1864,12 @@ S: Maintained F: include/hw/misc/unimp.h F: hw/misc/unimp.c +LED +M: Philippe Mathieu-Daudé <[email protected]> +S: Maintained +F: include/hw/misc/led.h +F: hw/misc/led.c + Standard VGA M: Gerd Hoffmann <[email protected]> S: Maintained
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
@@ -90,3 +90,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
@@ -198,3 +198,6 @@ via1_rtc_cmd_pram_read(int addr, int value) "addr=%u value=0x%02x" via1_rtc_cmd_pram_write(int addr, int value) "addr=%u value=0x%02x" via1_rtc_cmd_pram_sect_read(int sector, int offset, int addr, int value) "sector=%u offset=%u addr=%d value=0x%02x" via1_rtc_cmd_pram_sect_write(int sector, int offset, int addr, int value) "sector=%u offset=%u addr=%d value=0x%02x" + +# led.c +led_set(const char *name, uint8_t old_state, uint8_t new_state) "led name:'%s' state %d -> %d"
Signature · 1 line
2.21.3
RFC PATCH 2/5 hw/misc/led: Add LED_STATUS_CHANGED QAPI event
In reply to Philippe Mathieu-DaudéAllow LED devices to emit STATUS_CHANGED events on a QMP chardev.
QMP event examples:
{
"timestamp": {
"seconds": 1591704274,
"microseconds": 520850
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "on"
}
}
{
"timestamp": {
"seconds": 1591704275,
"microseconds": 530912
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "off"
}
}--- qapi/led.json | 47 +++++++++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + hw/misc/led.c | 4 ++++ MAINTAINERS | 1 + qapi/Makefile.objs | 2 +- 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 qapi/led.json
qapi/led.json new file +47 -0
@@ -0,0 +1,47 @@ +# -*- Mode: Python -*- +# + +## +# = LED device +## + +## +# @LedState: +# +# Status of a LED +# +# @on: device is emitting +# +# @off: device is off +# +# Since: 5.1 +## +{ 'enum': 'LedState', 'data': [ 'on', 'off' ] } + +## +# @LED_STATUS_CHANGED: +# +# Emitted when LED status changed +# +# @name: LED description +# +# @status: New status +# +# Since: 5.1 +# +# Example: +# +# <- {"timestamp": {"seconds": 1541579657, "microseconds": 986760}, +# "event": "LED_STATUS_CHANGED", +# "data": +# {"name": "Blue LED #3", +# "status": "on" +# } +# } +# +## +{ 'event': 'LED_STATUS_CHANGED', + 'data': { 'name' : 'str', + 'status' : 'LedState' + } +}
qapi/qapi-schema.json +1 -0
@@ -84,3 +84,4 @@ { 'include': 'misc.json' } { 'include': 'misc-target.json' } { 'include': 'audio.json' } +{ 'include': 'led.json' }
hw/misc/led.c +4 -0
@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-led.h" #include "hw/qdev-properties.h" #include "hw/misc/led.h" #include "hw/irq.h"
@@ -19,6 +20,9 @@ static void led_set(void *opaque, int line, int new_state)trace_led_set (s->name, s->current_state, new_state); +/* FIXME QMP rate limite? */ +qapi_event_send_led_status_changed (s->name, new_state + ?LED_STATE_ON :LED_STATE_OFF ); s->current_state = new_state; }
MAINTAINERS +1 -0
@@ -1867,6 +1867,7 @@ F: hw/misc/unimp.c LED M: Philippe Mathieu-Daudé <[email protected]> S: Maintained +F: qapi/led.json F: include/hw/misc/led.h F: hw/misc/led.c
qapi/Makefile.objs +1 -1
@@ -6,7 +6,7 @@ util-obj-y += qmp-event.o util-obj-y += qapi-util.o QAPI_COMMON_MODULES = audio authz block-core block char common control crypto -QAPI_COMMON_MODULES += dump error introspect job machine migration misc +QAPI_COMMON_MODULES += dump error introspect job led machine migration misc QAPI_COMMON_MODULES += net pragma qdev qom rdma rocker run-state sockets tpm QAPI_COMMON_MODULES += trace transaction ui QAPI_TARGET_MODULES = machine-target misc-target
Signature · 1 line
2.21.3
Re: [RFC PATCH 2/5] hw/misc/led: Add LED_STATUS_CHANGED QAPI event
Quoted 27 lines · Philippe Mathieu-Daudé
Allow LED devices to emit
STATUS_CHANGEDevents on a QMP chardev.QMP event examples:
{ "timestamp": { "seconds": 1591704274, "microseconds": 520850 }, "event": "LED_STATUS_CHANGED", "data": { "name": "Green LED #0", "status": "on" } } { "timestamp": { "seconds": 1591704275, "microseconds": 530912 }, "event": "LED_STATUS_CHANGED", "data": { "name": "Green LED #0", "status": "off" } }
Quoted 2 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
The QAPI addition looks reasonable, however,
Quoted 10 lines
+++
b/hw/misc/led.chw/misc/led.c +1
-0@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-led.h" #include "hw/qdev-properties.h" #include "hw/misc/led.h" #include "hw/irq.h"
hw/misc/led.c static void led_set(void *opaque, int line, int new_state) · line 23
Quoted 4 lines
hw/misc/led.c +1
-0@@ -19,6 +20,9 @@ static void led_set(void *opaque, int line, int new_state)trace_led_set (s->name, s->current_state, new_state); +/* FIXME QMP rate limite? */
s/limite/limit/
Yes, this is under guest control, so you MUST rate limit to avoid the guest being able to DoS qemu by changing the LED so frequently as to overwhelm the QMP connection with events.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [RFC PATCH 2/5] hw/misc/led: Add LED_STATUS_CHANGED QAPI event
Hi Eric,
Quoted 49 lines · Eric Blake
Quoted 27 lines · Philippe Mathieu-Daudé
Allow LED devices to emit
STATUS_CHANGEDevents on a QMP chardev.QMP event examples:
{
"timestamp": {
"seconds": 1591704274,
"microseconds": 520850
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "on"
}
}
{
"timestamp": {
"seconds": 1591704275,
"microseconds": 530912
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "off"
}
}Quoted 2 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
The QAPI addition looks reasonable, however,
Quoted 12 lines
+++
b/hw/misc/led.chw/misc/led.c +1
-0@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-led.h" #include "hw/qdev-properties.h" #include "hw/misc/led.h" #include "hw/irq.h"@@ -19,6 +20,9 @@ static void led_set(void *opaque, int line, int new_state) trace_led_set(s->name, s->current_state, new_state);Quoted 1 line
+ /* FIXME QMP rate limite? */
s/limite/limit/
Quoted 3 lines
Yes, this is under guest control, so you MUST rate limit to avoid the guest being able to DoS qemu by changing the LED so frequently as to overwhelm the QMP connection with events.
Commits f544d174dfc and 7f1e7b23d5 refers to the qmp-events.txt for documentation on rate-limiting QMP events, but I can't find it in the codebase. Two files matches 'qmp-events' but don't have
documentation: qapi/qmp-event.c and include/qapi/qmp-event.h.
Last trace of it is in commit 231aaf3a8217. Apparently it was somehow split qapi/event.json, then later c09656f1d392 move it to qapi-schema.json, finally eb815e248f50 moved it to qapi/.
Is the referred documentation now in docs/devel/qapi-code-gen.txt? There is only one occurence of 'limit' but it is unrelated to rate-limit.
Thanks,
Phil.
Re: [RFC PATCH 2/5] hw/misc/led: Add LED_STATUS_CHANGED QAPI event
Quoted 61 lines · Philippe Mathieu-Daudé
Hi Eric,
Quoted 49 lines · Eric Blake
Quoted 27 lines · Philippe Mathieu-Daudé
Allow LED devices to emit
STATUS_CHANGEDevents on a QMP chardev.QMP event examples:
{
"timestamp": {
"seconds": 1591704274,
"microseconds": 520850
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "on"
}
}
{
"timestamp": {
"seconds": 1591704275,
"microseconds": 530912
},
"event": "LED_STATUS_CHANGED",
"data": {
"name": "Green LED #0",
"status": "off"
}
}Quoted 2 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
The QAPI addition looks reasonable, however,
Quoted 12 lines
+++
b/hw/misc/led.chw/misc/led.c +1
-0@@ -7,6 +7,7 @@*/ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-led.h" #include "hw/qdev-properties.h" #include "hw/misc/led.h" #include "hw/irq.h"@@ -19,6 +20,9 @@ static void led_set(void *opaque, int line, int new_state) trace_led_set(s->name, s->current_state, new_state);Quoted 1 line
+ /* FIXME QMP rate limite? */
s/limite/limit/
Quoted 3 lines
Yes, this is under guest control, so you MUST rate limit to avoid the guest being able to DoS qemu by changing the LED so frequently as to overwhelm the QMP connection with events.
Commits
f544d174dfcand7f1e7b23d5refers to the qmp-events.txt for documentation on rate-limiting QMP events, but I can't find it in the codebase. Two files matches 'qmp-events' but don't have
documentation:qapi/qmp-event.candinclude/qapi/qmp-event.h.
Quoted 7 lines
Last trace of it is in commit
231aaf3a8217. Apparently it was somehow splitqapi/event.json, then laterc09656f1d392move it to qapi-schema.json, finallyeb815e248f50moved it to qapi/.Is the referred documentation now in
docs/devel/qapi-code-gen.txt? There is only one occurence of 'limit' but it is unrelated to rate-limit.
Commit 231aaf3a8217 is part of Marc-André's herculean QAPI/QMP doc
reorganization: use only schema doc comments instead of spreading the knowledge over schema and several other files, with duplicated contents, confused readers, and annoyed writers.
Before the reorganization, docs/qmp-events.txt listed the QMP events, and rate-limited events carried a
Note: this event is rate-limited.
The reorganization moved this note into its event's doc comment. Example:
##
# @WATCHDOG:
#
# Emitted when the watchdog device's timer is expired
#
# @action: action that has been taken
#
# Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is
# followed respectively by the RESET, SHUTDOWN, or STOP events
#
--> # Note: This event is rate-limited.
#
[...]
##
{ 'event': 'WATCHDOG',
'data': { 'action': 'WatchdogAction' } }The QMP *protocol* is still documented in docs/interop/qmp-spec.txt. Relevant part:
2.5 Asynchronous events
-----------------------
As a result of state changes, the Server may send messages unilaterally to the Client at any time, when not in the middle of any other response. They are called "asynchronous events".
The format of asynchronous events is:
{ "event": json-string, "data": json-object,
"timestamp": { "seconds": json-number, "microseconds": json-number } }
Where,
- The "event" member contains the event's name
- The "data" member contains event specific data, which is defined in a per-event basis, it is optional
- The "timestamp" member contains the exact time of when the event occurred in the Server. It is a fixed json-object with time in seconds and microseconds relative to the Unix Epoch (1 Jan 1970); if there is a failure to retrieve host time, both members of the timestamp will be set to -1.
For a listing of supported asynchronous events, please, refer to the qmp-events.txt file.
Some events are rate-limited to at most one per second. If additional "similar" events arrive within one second, all but the last one are dropped, and the last one is delayed. "Similar" normally means same event type. See qmp-events.txt for details.
The reorganization neglected to update it for the removal of qmp-events.txt. Should point to docs/interop/qemu-qmp-ref.{7,html,info,pdf,txt} now.
Event rate-limiting is defined in monitor_qapi_event_conf[]. To rate-limit an event, add it to monitor_qapi_event_conf[], and also add the "Note: This event is rate-limited." to its schema doc comment.
Doc bug: commit e2ae6159de "virtio-serial: report frontend connection state via monitor" neglected to add the note.
Patches welcome!
Re: [RFC PATCH 2/5] hw/misc/led: Add LED_STATUS_CHANGED QAPI event
Quoted 1 line · Markus Armbruster
Philippe Mathieu-Daudé <[email protected]> writes:
[...]
Quoted 81 lines
Quoted 5 lines
Commits
f544d174dfcand7f1e7b23d5refers to the qmp-events.txt for documentation on rate-limiting QMP events, but I can't find it in the codebase. Two files matches 'qmp-events' but don't have
documentation:qapi/qmp-event.candinclude/qapi/qmp-event.h.Quoted 7 lines
Last trace of it is in commit
231aaf3a8217. Apparently it was somehow splitqapi/event.json, then laterc09656f1d392move it to qapi-schema.json, finallyeb815e248f50moved it to qapi/.Is the referred documentation now in
docs/devel/qapi-code-gen.txt? There is only one occurence of 'limit' but it is unrelated to rate-limit.Commit
231aaf3a8217is part of Marc-André's herculean QAPI/QMP doc
reorganization: use only schema doc comments instead of spreading the knowledge over schema and several other files, with duplicated contents, confused readers, and annoyed writers.Before the reorganization,
docs/qmp-events.txtlisted the QMP events, and rate-limited events carried aNote: this event is rate-limited.
The reorganization moved this note into its event's doc comment. Example:
## # @WATCHDOG: # # Emitted when the watchdog device's timer is expired # # @action: action that has been taken # # Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is # followed respectively by the RESET, SHUTDOWN, or STOP events # --> # Note: This event is rate-limited. # [...] ## { 'event': 'WATCHDOG', 'data': { 'action': 'WatchdogAction' } }The QMP *protocol* is still documented in
docs/interop/qmp-spec.txt. Relevant part:2.5 Asynchronous events
-----------------------As a result of state changes, the Server may send messages unilaterally to the Client at any time, when not in the middle of any other response. They are called "asynchronous events".
The format of asynchronous events is:
{ "event": json-string, "data": json-object,
"timestamp": { "seconds": json-number, "microseconds": json-number } }Where,
- The "event" member contains the event's name
- The "data" member contains event specific data, which is defined in a per-event basis, it is optional
- The "timestamp" member contains the exact time of when the event occurred in the Server. It is a fixed json-object with time in seconds and microseconds relative to the Unix Epoch (1 Jan 1970); if there is a failure to retrieve host time, both members of the timestamp will be set to -1.For a listing of supported asynchronous events, please, refer to the qmp-events.txt file.
Some events are rate-limited to at most one per second. If additional "similar" events arrive within one second, all but the last one are dropped, and the last one is delayed. "Similar" normally means same event type. See qmp-events.txt for details.
The reorganization neglected to update it for the removal of qmp-events.txt. Should point to docs/interop/qemu-qmp-ref.{7,html,info,pdf,txt} now.
Quoted 8 lines
Event rate-limiting is defined in monitor_qapi_event_conf[]. To rate-limit an event, add it to monitor_qapi_event_conf[], and also add the "Note: This event is rate-limited." to its schema doc comment.
Doc bug: commit
e2ae6159de"virtio-serial: report frontend connection state via monitor" neglected to add the note.Patches welcome!
Subject: [PATCH 1/3] docs/interop/qmp-spec: Point to the QEMU QMP reference manual
Message-Id: <[email protected]>
Subject: [PATCH 2/3] qapi: Document event VSERPORT_CHANGE is rate-limited
Message-Id: <[email protected]>
RFC PATCH 3/5 hw/misc/led: Add create_led_by_gpio_id() helper
In reply to Philippe Mathieu-DaudéAdd create_led_by_gpio_id() to easily connect a LED to a GPIO output.
--- include/hw/misc/led.h | 14 ++++++++++++++ hw/misc/led.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+)
include/hw/misc/led.h +14 -0
@@ -27,4 +27,18 @@ typedef struct LEDState { uint8_t reset_state; /* TODO [GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH] */ } LEDState; +/** +* create_led_by_gpio_id: create and LED device +* @parent: the parent object +* @gpio_dev: device exporting GPIOs +* @gpio_id: GPIO ID of this LED +* @name: name of the LED +* +* 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, +const char *led_name); +#endif /* HW_MISC_LED_H */
hw/misc/led.c +20 -0
@@ -86,3 +86,23 @@ static void led_register_types(void) }type_init (led_register_types) + +DeviceState *create_led_by_gpio_id(Object *parentobj, +DeviceState *gpio_dev,unsigned gpio_id, +const char *led_name) +{ +DeviceState *dev; +char *name; + + dev =qdev_create (NULL ,TYPE_LED ); +/* TODO set "reset_state" */ +qdev_prop_set_string (dev,"name" , led_name); + name =g_ascii_strdown (led_name,-1 ); + name =g_strdelimit (name," #" ,'-' ); +object_property_add_child (parentobj, name,OBJECT (dev)); +g_free (name); +qdev_init_nofail (dev); +qdev_connect_gpio_out (gpio_dev, gpio_id,qdev_get_gpio_in (dev,0 )); + +return dev; +}
Signature · 1 line
2.21.3
RFC PATCH 4/5 hw/arm/microbit: Add a fake LED to use as proof-of-concept with Zephyr
In reply to Philippe Mathieu-DaudéWe were using an AVR based Arduino to use this device, but since the port is not merged, the microbit is the easiest board to use with Zephyr.
Note the microbit doesn't have a such LED, this is simply a proof of concept.
How to test:
- Apply this patch on zephyr-v2.3.0
diff --git a/boards/arm/qemu_cortex_m0/qemu_cortex_m0.dts b/boards/arm/qemu_cortex_m0/qemu_cortex_m0.dts index a1b3044275..61b39506b1 100644
--- a/boards/arm/qemu_cortex_m0/qemu_cortex_m0.dts
+++ b/boards/arm/qemu_cortex_m0/qemu_cortex_m0.dts
@@ -21,6 +21,18 @@
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
}; +
+ leds {
+ compatible = "gpio-leds";
+ led0: led_0 {
+ gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
+ label = "Green LED 0";
+ };
+ };
+
+ aliases {
+ led0 = &led0;
+ };
};
&gpiote {- Build Zephyr blinky:
$ west build -b qemu_cortex_m0 samples/basic/blinky
- Run QEMU
$ qemu-system-arm -M microbit -trace led\* \
-kernel ~/zephyrproject/zephyr/build/zephyr/zephyr.elf -trace led\*
[email protected]:led_set led name:'Green LED #0' state 0 -> 0
[email protected]:led_set led name:'Green LED #0' state 0 -> 1
[email protected]:led_set led name:'Green LED #0' state 1 -> 0--- hw/arm/microbit.c | 3 +++ hw/arm/Kconfig | 1 + 2 files changed, 4 insertions(+)
hw/arm/microbit.c +3 -0
@@ -18,6 +18,7 @@#include "hw/arm/nrf51_soc.h" #include "hw/i2c/microbit_i2c.h" #include "hw/qdev-properties.h" +#include "hw/misc/led.h" typedef struct { MachineState parent;
@@ -58,6 +59,8 @@ static void microbit_init(MachineState *machine)memory_region_add_subregion_overlap (&s->nrf51.container,NRF51_TWI_BASE , mr,-1 ); +create_led_by_gpio_id (OBJECT (machine),DEVICE (soc),21 ,"Green LED #0" ); +armv7m_load_kernel (ARM_CPU (first_cpu), machine->kernel_filename,NRF51_SOC (soc)->flash_size); }
hw/arm/Kconfig +1 -0
@@ -436,6 +436,7 @@ config FSL_IMX6UL config MICROBIT bool select NRF51_SOC + select LED config NRF51_SOC bool
Signature · 1 line
2.21.3
RFC PATCH 5/5 hw/arm/tosa: Use LED device for the Bluetooth led
In reply to Philippe Mathieu-Daudé--- hw/arm/tosa.c | 7 +++---- hw/arm/Kconfig | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
hw/arm/tosa.c +3 -4
@@ -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
@@ -68,9 +69,6 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)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 ;
@@ -119,7 +117,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 ]);
@@ -234,6 +231,8 @@ 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 ,"blue LED" );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