From patchwork Sat Jun 20 23:07:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CC1C433DF for ; Sat, 20 Jun 2020 23:10:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD0552474A for ; Sat, 20 Jun 2020 23:10:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JGg8rQyi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD0552474A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmce-0003A6-07 for qemu-devel@archiver.kernel.org; Sat, 20 Jun 2020 19:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmma7-0006y0-Jl; Sat, 20 Jun 2020 19:07:27 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmma5-0002M6-PS; Sat, 20 Jun 2020 19:07:27 -0400 Received: by mail-wm1-x341.google.com with SMTP id g75so3579615wme.5; Sat, 20 Jun 2020 16:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Uy+mvISrtHvQu5hNX7wJEHS7Ifd/2AZK2mIPsLbgTkA=; b=JGg8rQyiBhYfEhkOhiF5taHN0lhmvxsp1hH/zfjri8ttF6SdQGQs8EF7SfzSum0pdk V7jBwyH5iHPyUAFgC8q4q2xyomY+x9Ic4i6LF3JfRIHaC3AXRoYKSWjm2OwTcx3sCSRG rTqhBZQ16AFybOIIlgtBdAt4EIgFftzTV/XKLyzn7zoiDgS4K8zLNOY2li4yKI4HnWtT ZOrzE0LyaW1D8hSra8QT4QBKjDE+rIO6Kjvk/3aFj8MVkjkTFIg+8SXqOcno5q3ENvu9 FtTbPiLx+IRh80Rld86asfC2G9wRbN68v1AaxCiISDzAHA0/yyqk2eXEY891kcv9axrm xwcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Uy+mvISrtHvQu5hNX7wJEHS7Ifd/2AZK2mIPsLbgTkA=; b=SxUMZabXK866wSYQXDXPmXe0VrM6X7eS7sO/T6TK/g0GGHiBFhDrwOIBBFkN6DHIBU fa/wOETpd3f7We1V+No3roOGDFQHiu8006/tA2a0HvIFOyCj6bcFkUg6Z0ebqFqcn/M5 MUsPQim/sUGnyGeU/zaXDDONjaRixRE3sVSbngB4+Xz6MVKDN3x6bAX9jLAdx5u/DhHP viG6Tn7N+DlTKxPr+6RBrt+vVDvwQ8RoVDftDLC8VJPusvDHag1fiYd/oU66bYnD8HIf h2p3ee4S4GSPVb4Xc41bhsLqYWnLXeZfo5AV9CtZy8jVmqgYGVrq35c7beNZblTPZmFA TsOw== X-Gm-Message-State: AOAM530t77W4gbKv3WYtZI5Gv0GqZUAgqd0uHc6gNdH6c54ccOKFnAQ3 2CWMlrvnQngujWZfzdehb3b80pXS X-Google-Smtp-Source: ABdhPJxRfZEQgcTTNvzDDBuQrNyJ7CQogaYSRlj4BJA+fP15KLt2lzfWYcHkllFZKol2wRKlwzmTcg== X-Received: by 2002:a05:600c:2201:: with SMTP id z1mr10423246wml.70.1592694443322; Sat, 20 Jun 2020 16:07:23 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id o82sm11455037wmo.40.2020.06.20.16.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 1/7] hw/misc: Add a LED device Date: Sun, 21 Jun 2020 01:07:13 +0200 Message-Id: <20200620230719.32139-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200620230719.32139-1-f4bug@amsat.org> References: <20200620230719.32139-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?utf-8?b?Q8Op?= =?utf-8?q?dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h new file mode 100644 index 0000000000..821ee1247d --- /dev/null +++ b/include/hw/misc/led.h @@ -0,0 +1,79 @@ +/* + * QEMU single LED device + * + * Copyright (C) 2020 Philippe Mathieu-Daudé + * + * 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 */ diff --git a/hw/misc/led.c b/hw/misc/led.c new file mode 100644 index 0000000000..e55ed7dbc4 --- /dev/null +++ b/hw/misc/led.c @@ -0,0 +1,121 @@ +/* + * QEMU single LED device + * + * Copyright (C) 2020 Philippe Mathieu-Daudé + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/misc/led.h" +#include "trace.h" + +static const char *led_color(LEDColor color) +{ + static const char *color_name[LED_COLOR_COUNT] = { + [LED_COLOR_RED] = "red", + [LED_COLOR_ORANGE] = "orange", + [LED_COLOR_AMBER] = "amber", + [LED_COLOR_YELLOW] = "yellow", + [LED_COLOR_GREEN] = "green", + [LED_COLOR_BLUE] = "blue", + [LED_COLOR_VIOLET] = "violet", /* PURPLE */ + [LED_COLOR_WHITE] = "white", + }; + return color_name[color] ? color_name[color] : "unknown"; +} + +void led_set_intensity(LEDState *s, uint16_t new_intensity) +{ + trace_led_set_intensity(s->description ? s->description : "n/a", + s->color, new_intensity); + s->current_intensity = new_intensity; +} + +void led_set_state(LEDState *s, bool is_on) +{ + led_set_intensity(s, is_on ? UINT16_MAX : 0); +} + +static void led_reset(DeviceState *dev) +{ + LEDState *s = LED(dev); + + led_set_intensity(s, s->reset_intensity); +} + +static const VMStateDescription vmstate_led = { + .name = TYPE_LED, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + +static void led_realize(DeviceState *dev, Error **errp) +{ + LEDState *s = LED(dev); + + if (s->color == NULL) { + error_setg(errp, "property 'color' not specified"); + return; + } +} + +static Property led_properties[] = { + DEFINE_PROP_STRING("color", LEDState, color), + DEFINE_PROP_STRING("description", LEDState, description), + DEFINE_PROP_UINT16("reset_intensity", LEDState, reset_intensity, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void led_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "LED"; + dc->vmsd = &vmstate_led; + dc->reset = led_reset; + dc->realize = led_realize; + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); + device_class_set_props(dc, led_properties); +} + +static const TypeInfo led_info = { + .name = TYPE_LED, + .parent = TYPE_DEVICE, + .instance_size = sizeof(LEDState), + .class_init = led_class_init +}; + +static void led_register_types(void) +{ + type_register_static(&led_info); +} + +type_init(led_register_types) + +DeviceState *create_led(Object *parentobj, + LEDColor color, + const char *description, + uint16_t reset_intensity) +{ + DeviceState *dev; + char *name; + + assert(description); + dev = qdev_new(TYPE_LED); + qdev_prop_set_uint16(dev, "reset_intensity", reset_intensity); + qdev_prop_set_string(dev, "color", led_color(color)); + qdev_prop_set_string(dev, "description", description); + name = g_ascii_strdown(description, -1); + name = g_strdelimit(name, " #", '-'); + object_property_add_child(parentobj, name, OBJECT(dev)); + g_free(name); + qdev_realize_and_unref(dev, NULL, &error_fatal); + + return dev; +} diff --git a/MAINTAINERS b/MAINTAINERS index 955cc8dd5c..0fb8896b43 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1863,6 +1863,12 @@ F: docs/specs/vmgenid.txt F: tests/qtest/vmgenid-test.c F: stubs/vmgenid.c +LED +M: Philippe Mathieu-Daudé +S: Maintained +F: include/hw/misc/led.h +F: hw/misc/led.c + Unimplemented device M: Peter Maydell R: Philippe Mathieu-Daudé diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index bdd77d8020..f60dce694d 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -126,6 +126,9 @@ config AUX config UNIMP bool +config LED + bool + config MAC_VIA bool select MOS6522 diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs index 5aaca8a039..9efa3c941c 100644 --- a/hw/misc/Makefile.objs +++ b/hw/misc/Makefile.objs @@ -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 diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 805d2110e0..f58853d367 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -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" From patchwork Sat Jun 20 23:07:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91648C433E0 for ; Sat, 20 Jun 2020 23:08:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 607B52474A for ; Sat, 20 Jun 2020 23:08:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MMXuAsbK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 607B52474A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmbZ-0000Lv-EU for qemu-devel@archiver.kernel.org; Sat, 20 Jun 2020 19:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmma9-00072v-SO; Sat, 20 Jun 2020 19:07:29 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmma8-0002MO-9I; Sat, 20 Jun 2020 19:07:29 -0400 Received: by mail-wm1-x343.google.com with SMTP id g75so3579642wme.5; Sat, 20 Jun 2020 16:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+2AZIJNfLoRM7W1nhvrnhDoshMHCbhObjMtaHucBvyY=; b=MMXuAsbKzPtw7rmEOVHoV8Oop7VX86Tkj4DrAl46aA2mOaOjz9HzpDmKsuaVb3KxAh vku1E6fv41DU2qKN5/D+apHbo4FGqnox4RyNYrHt5VvY+8EsveqC8YmK1OXEDuS1MLv6 nnN16xbYLL7YSHdKEetrrSYx3MObTS434z8+rB4cjjSrElsXRW19Cz+KgtXH2bSVf5PB 0Gl/VTOvmqCA6C1thQIhux6Q/gqgjRsEVHhDk/q6VcZVNjp12hxvvgDq6uE0cDOX3Q1+ gdhUDQJ9LfETRUJxOJts5Zy/8OS7uyFZ/bxE7xkVe3RI5eNdwuuyJX0jskt66g0XZGR6 QPQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+2AZIJNfLoRM7W1nhvrnhDoshMHCbhObjMtaHucBvyY=; b=b+KculVetlfRO6zn8u8sDOLP4bzyPkp08Ohxl6V8zellPfSuMlcK4MLHPt0FFEteN4 ouzfaKNusJb6F3gISDfFs5bcUBcG8uBK70/FpdWXmKssaZ9w1EonD9VQCWmBaTJtuEeD EmUKF7evW2nnraXO6Qh5r0z6iZyJTvhTXI2AFqqh4R8ovhDmLE6Mnn9JdX4xZfd6dH+m KkfvBfhuR4pOgd4NovG6jOc6TolkwvRMLv5yZfWj1uXJUjmYQiD+E5hQE5O0BofLMKLM at6iFsopT7Cy7LA8Lz7j2/PR/Q6Hn6XHDqJjUJaR+twfU3UgUZLFFAMUrTSpRi6mkEKM zbPw== X-Gm-Message-State: AOAM532x9SitZDXnAXYBtRQNqO6o3MeV7UZ1fpAiwFuGsLuV47+NO61M /st3rRQxgCDVEHBcH60fbbUA8olp X-Google-Smtp-Source: ABdhPJyGR+eoAV+MqIXDn7Tg8PLjadjC83sNT4bs9d5/O/4DfozIbWEBtPwgqLm7Ep1FjMQj+cyLiA== X-Received: by 2002:a7b:cc8b:: with SMTP id p11mr39464wma.180.1592694446355; Sat, 20 Jun 2020 16:07:26 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id o82sm11455037wmo.40.2020.06.20.16.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed Date: Sun, 21 Jun 2020 01:07:15 +0200 Message-Id: <20200620230719.32139-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200620230719.32139-1-f4bug@amsat.org> References: <20200620230719.32139-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?utf-8?b?Q8Op?= =?utf-8?q?dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Track the LED intensity, and emit a trace event when it changes. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/misc/led.h | 1 + hw/misc/led.c | 5 +++++ hw/misc/trace-events | 1 + 3 files changed, 7 insertions(+) diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h index 883006bb8f..df5b32a2db 100644 --- a/include/hw/misc/led.h +++ b/include/hw/misc/led.h @@ -35,6 +35,7 @@ typedef struct LEDState { DeviceState parent_obj; /* Public */ + uint16_t current_intensity; qemu_irq irq; /* Properties */ diff --git a/hw/misc/led.c b/hw/misc/led.c index 8503dde777..37d9f1f3d2 100644 --- a/hw/misc/led.c +++ b/hw/misc/led.c @@ -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; } diff --git a/hw/misc/trace-events b/hw/misc/trace-events index f58853d367..57d39bf9b9 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -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]" From patchwork Sat Jun 20 23:07:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06F7EC433DF for ; Sat, 20 Jun 2020 23:11:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C652823E1E for ; Sat, 20 Jun 2020 23:11:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ChozLKdb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C652823E1E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmeF-0005gR-2g for qemu-devel@archiver.kernel.org; Sat, 20 Jun 2020 19:11:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmmaC-0007B4-NB; Sat, 20 Jun 2020 19:07:32 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmmaB-0002Mn-3y; Sat, 20 Jun 2020 19:07:32 -0400 Received: by mail-wm1-x329.google.com with SMTP id r15so12422190wmh.5; Sat, 20 Jun 2020 16:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zb02tNNP3k4Arx05DuNHXof+/AxtMqtoGOWXwVkHhHE=; b=ChozLKdbQ6jvH8LOrBEmhTiTnB6CM+KaxSJdPJhNfUQdvp+Fbh+88XYQq+WPSKInD3 Xkq9bOIrF+jqzR56B1axkXGlgG0EhSOqtU4HMbH939mn0vVwpKYdkJp7tdpV6HnPJoAJ D+zKWH3VtEgbC05QjDHppTqE8X/LqasuySfLvoxr1Va9Aba9GTFVI+GPbo8xUMBOwssF df2l1p36/tOI4KieRx4Zr0uTySdF3Qz1/kgW+mV7TCL3BPf7gdivfz14u0oAwgWKkbE9 tAWOGoTXm4A8Jxjr0IK049PuAuro/O32n3h2krOyNuPBTjDus4txUa6f27mooZjyPQco r8tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Zb02tNNP3k4Arx05DuNHXof+/AxtMqtoGOWXwVkHhHE=; b=YNY5Bqw8jIQID3Q54r1ynJsTe+Ur7C09wXlUNQDRMWobP2GRYhFgqU6VyvWOmMGewB CGpkry6byiz+YbtTalGMriShiO162X6B28HDxwNPtXxLZtHib1sM3Xjs1kORkXIBvcSt z3Hd8wsp3X2p/SxgsqNu/P4tUR7gYq3OeSbhKksHqvKb+ddFoVElwUxEo6NgAgCTwiX9 WLapnI19z7pDKDPmRM81Ds2wTAJF+Nk8goJMEVJPbdVJNRJLieS5cA2KXFkVyB+Goukc f+Z/rI4YvfsToYvSrLNlVXfVns1H/pxHWzTA9dzgAtR/EYsy2bmCpm5U5cmVM4LeAs9N 20JQ== X-Gm-Message-State: AOAM530R3kw1GjlotMjs4ThpjooND/NaXZBXrH4SlWaxKVLCs8iQOrZT p64lJHfNnbmeec/4vDuyEQv/589F X-Google-Smtp-Source: ABdhPJwcWZvw2SW4J2OX6umGvBK8DrcWhC2bxhD5ZS1TJWagkAT0K7vuxYMLiW2tYzhulGsr6ScL4Q== X-Received: by 2002:a05:600c:ce:: with SMTP id u14mr10382440wmm.131.1592694448968; Sat, 20 Jun 2020 16:07:28 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id o82sm11455037wmo.40.2020.06.20.16.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device Date: Sun, 21 Jun 2020 01:07:17 +0200 Message-Id: <20200620230719.32139-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200620230719.32139-1-f4bug@amsat.org> References: <20200620230719.32139-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?utf-8?b?Q8Op?= =?utf-8?q?dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Philippe Mathieu-Daudé --- 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(-) diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h index 69e265cd4b..228b813fd3 100644 --- a/include/hw/misc/mps2-fpgaio.h +++ b/include/hw/misc/mps2-fpgaio.h @@ -32,6 +32,7 @@ typedef struct { /*< public >*/ MemoryRegion iomem; + DeviceState *led[2]; uint32_t led0; uint32_t prescale; diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c index 2f3fbeef34..65488f8634 100644 --- a/hw/misc/mps2-fpgaio.c +++ b/hw/misc/mps2-fpgaio.c @@ -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) diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index f60dce694d..889757731b 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -93,6 +93,7 @@ config MIPS_ITU config MPS2_FPGAIO bool + select LED config MPS2_SCC bool diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 57d39bf9b9..8bc7a675e8 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -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 From patchwork Sat Jun 20 23:07:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C04BAC433DF for ; Sat, 20 Jun 2020 23:13:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89026246EF for ; Sat, 20 Jun 2020 23:13:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKh/GdEt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89026246EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmgI-0000ze-Rj for qemu-devel@archiver.kernel.org; Sat, 20 Jun 2020 19:13:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmmaE-0007GQ-TX; Sat, 20 Jun 2020 19:07:34 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmmaD-0002N8-8M; Sat, 20 Jun 2020 19:07:34 -0400 Received: by mail-wr1-x441.google.com with SMTP id l10so13144728wrr.10; Sat, 20 Jun 2020 16:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dqGlIc+jv7onYHOT7vp+iSAvaDEPRQt/mIvRK1NcKyk=; b=jKh/GdEt/HW1QsvtpsCneycRhcGokA0wBKP/6lBsRCfkrMDNOJ24oFuVM5dp7qf49q 3XpqVv0Do4gzwzvLLxvp+fm9s7yMpLfVffjOD8zlEc6U7wRJUpvlhUvzArbbhmrPDA/5 Wnfmds4aTncR9Whux0eiOXQbzHBIc+bCFqHIJmEb787CtAkThq1xO4YIKqT/jzT4DC1z b6xvS0jcZ7o8/rogUANGVIZptHGsjR8TjSmPZNySQDtGhKACbFlKT7jYzQF3MkZdWzx6 agGW2cyofSRw6fufORUzkW75mjfkSRCGIK6a0Ha+fou0kvLBMH6shcYbhGXaqyz6ZBsr ixeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dqGlIc+jv7onYHOT7vp+iSAvaDEPRQt/mIvRK1NcKyk=; b=dRamd0R1/XvNh7/PnqnnW2Ds02TlGNR53LwCnjVklrEx87Q2+LsXmU00TfF9wHkjmq bTX66+yWGn/tOIBrxeV7/11Y3G8+fE8dJ/m4bVL0OZom3eSAryQjYuLkczNtOJrl7qmP uK+8b0mYEGm6WDaX0Ff2WcdwltlbsFe3R+da2XCyTOhpgwFA4qk4zo9oaXsY1jrPcXuk IF3O3IWaPOn5Co+ZFZWPPuUsm+2zjQDveBRY6fb6OgaA+hVK2kujhgnUCGaA0Gp2Aa/h zW8OlsPg0vcm2ToV7bQvT12QZKs/YpJC0o8WQD2lvS+ik9g2SFYxa//BkewDr8OBMoFF kj1w== X-Gm-Message-State: AOAM533hBsyL7nlz0Y0Rtns5y35PKuNCjE2Ss6RT9oBdgxV0BgRIHwAt anrp5xP6u0THXcHh7AwWsHYat6yE X-Google-Smtp-Source: ABdhPJxQ2xwfMc7RNoy61gt7hL3XowZlJJt/Ffbes6D8Zn9Rt97UaK2OeetCreMBGUf/xeate7Ql0Q== X-Received: by 2002:a5d:45cb:: with SMTP id b11mr10617176wrs.235.1592694451400; Sat, 20 Jun 2020 16:07:31 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id o82sm11455037wmo.40.2020.06.20.16.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 7/7] hw/arm/tosa: Replace fprintf() calls by LED devices Date: Sun, 21 Jun 2020 01:07:19 +0200 Message-Id: <20200620230719.32139-8-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200620230719.32139-1-f4bug@amsat.org> References: <20200620230719.32139-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?utf-8?b?Q8Op?= =?utf-8?q?dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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