Skip to content

Commit 0697206

Browse files
committed
hw/arm/tosa: Replace fprintf() calls by LED devices
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. Reviewed-by: Luc Michel <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]>
1 parent 435db7e commit 0697206

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

hw/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ config TOSA
151151
select ZAURUS # scoop
152152
select MICRODRIVE
153153
select PXA2XX
154+
select LED
154155

155156
config SPITZ
156157
bool

hw/arm/tosa.c

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "hw/irq.h"
2525
#include "hw/ssi/ssi.h"
2626
#include "hw/sysbus.h"
27+
#include "hw/misc/led.h"
2728
#include "exec/address-spaces.h"
2829
#include "qom/object.h"
2930

@@ -81,26 +82,6 @@ struct TosaMiscGPIOState {
8182
SysBusDevice parent_obj;
8283
};
8384

84-
static void tosa_gpio_leds(void *opaque, int line, int level)
85-
{
86-
switch (line) {
87-
case 0:
88-
fprintf(stderr, "blue LED %s.\n", level ? "on" : "off");
89-
break;
90-
case 1:
91-
fprintf(stderr, "green LED %s.\n", level ? "on" : "off");
92-
break;
93-
case 2:
94-
fprintf(stderr, "amber LED %s.\n", level ? "on" : "off");
95-
break;
96-
case 3:
97-
fprintf(stderr, "wlan LED %s.\n", level ? "on" : "off");
98-
break;
99-
default:
100-
g_assert_not_reached();
101-
}
102-
}
103-
10485
static void tosa_reset(void *opaque, int line, int level)
10586
{
10687
if (level) {
@@ -112,7 +93,6 @@ static void tosa_misc_gpio_init(Object *obj)
11293
{
11394
DeviceState *dev = DEVICE(obj);
11495

115-
qdev_init_gpio_in_named(dev, tosa_gpio_leds, "leds", 4);
11696
qdev_init_gpio_in_named(dev, tosa_reset, "reset", 1);
11797
}
11898

@@ -122,6 +102,7 @@ static void tosa_gpio_setup(PXA2xxState *cpu,
122102
TC6393xbState *tmio)
123103
{
124104
DeviceState *misc_gpio;
105+
LEDState *led[4];
125106

126107
misc_gpio = sysbus_create_simple(TYPE_TOSA_MISC_GPIO, -1, NULL);
127108

@@ -143,14 +124,23 @@ static void tosa_gpio_setup(PXA2xxState *cpu,
143124
qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_JC_CF_IRQ),
144125
NULL);
145126

127+
led[0] = led_create_simple(OBJECT(misc_gpio), GPIO_POLARITY_ACTIVE_HIGH,
128+
LED_COLOR_BLUE, "bluetooth");
129+
led[1] = led_create_simple(OBJECT(misc_gpio), GPIO_POLARITY_ACTIVE_HIGH,
130+
LED_COLOR_GREEN, "note");
131+
led[2] = led_create_simple(OBJECT(misc_gpio), GPIO_POLARITY_ACTIVE_HIGH,
132+
LED_COLOR_AMBER, "charger-error");
133+
led[3] = led_create_simple(OBJECT(misc_gpio), GPIO_POLARITY_ACTIVE_HIGH,
134+
LED_COLOR_GREEN, "wlan");
135+
146136
qdev_connect_gpio_out(scp1, TOSA_GPIO_BT_LED,
147-
qdev_get_gpio_in_named(misc_gpio, "leds", 0));
137+
qdev_get_gpio_in(DEVICE(led[0]), 0));
148138
qdev_connect_gpio_out(scp1, TOSA_GPIO_NOTE_LED,
149-
qdev_get_gpio_in_named(misc_gpio, "leds", 1));
139+
qdev_get_gpio_in(DEVICE(led[1]), 0));
150140
qdev_connect_gpio_out(scp1, TOSA_GPIO_CHRG_ERR_LED,
151-
qdev_get_gpio_in_named(misc_gpio, "leds", 2));
141+
qdev_get_gpio_in(DEVICE(led[2]), 0));
152142
qdev_connect_gpio_out(scp1, TOSA_GPIO_WLAN_LED,
153-
qdev_get_gpio_in_named(misc_gpio, "leds", 3));
143+
qdev_get_gpio_in(DEVICE(led[3]), 0));
154144

155145
qdev_connect_gpio_out(scp1, TOSA_GPIO_TC6393XB_L3V_ON, tc6393xb_l3v_get(tmio));
156146

0 commit comments

Comments
 (0)