qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-arm@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PATCH v3 7/7] hw/arm/tosa: Replace fprintf() calls by LED devices
Date: Sun, 21 Jun 2020 01:07:19 +0200	[thread overview]
Message-ID: <20200620230719.32139-8-f4bug@amsat.org> (raw)
In-Reply-To: <20200620230719.32139-1-f4bug@amsat.org>

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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/tosa.c  | 40 +++++++++++++---------------------------
 hw/arm/Kconfig |  1 +
 2 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 5dee2d76c6..74b5fd1049 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -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);
 
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 1a57a861ac..057c869d65 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -150,6 +150,7 @@ config TOSA
     select ZAURUS  # scoop
     select MICRODRIVE
     select PXA2XX
+    select LED
 
 config SPITZ
     bool
-- 
2.21.3



  parent reply	other threads:[~2020-06-20 23:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 23:07 [PATCH v3 0/7] hw/misc: Add LED device Philippe Mathieu-Daudé
2020-06-20 23:07 ` [PATCH v3 1/7] hw/misc: Add a " Philippe Mathieu-Daudé
2020-06-21  2:00   ` Richard Henderson
2020-06-21 20:35     ` Philippe Mathieu-Daudé
2020-06-21 20:50       ` Richard Henderson
2020-06-20 23:07 ` [PATCH v3 2/7] hw/misc/led: Add helper to connect LED to GPIO output Philippe Mathieu-Daudé
2020-06-21 19:09   ` Richard Henderson
2020-06-20 23:07 ` [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed Philippe Mathieu-Daudé
2020-06-21 19:23   ` Richard Henderson
2020-06-21 22:25     ` Philippe Mathieu-Daudé
2020-06-22 16:48       ` Richard Henderson
2020-06-23  7:45         ` Philippe Mathieu-Daudé
2020-06-20 23:07 ` [PATCH v3 4/7] hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1 Philippe Mathieu-Daudé
2020-06-21 20:51   ` Richard Henderson
2020-06-20 23:07 ` [PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device Philippe Mathieu-Daudé
2020-06-21 21:00   ` Richard Henderson
2020-06-21 21:09     ` Philippe Mathieu-Daudé
2020-06-20 23:07 ` [PATCH v3 6/7] hw/misc/mps2-scc: " Philippe Mathieu-Daudé
2020-06-21 17:31   ` Philippe Mathieu-Daudé
2020-06-21 21:05   ` Richard Henderson
2020-06-20 23:07 ` Philippe Mathieu-Daudé [this message]
2020-06-21 16:52   ` [PATCH v3 7/7] hw/arm/tosa: Replace fprintf() calls by LED devices Philippe Mathieu-Daudé
2020-06-20 23:58 ` [PATCH v3 0/7] hw/misc: Add LED device no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200620230719.32139-8-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).