From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592694608; cv=none; d=zohomail.com; s=zohoarc; b=Y+/w6/MtojUg+vOBvj/vUxgT3mPOtWQrkLtrU5rWrnNhUj9+VnmZwjvF77llOL1Mp9aEeCDnVnfdnAfOrHWUglaR6Jt1rUdk8Yl4Wry+3aOL8VF4Sgm/roK83rPi1jLhI/9+rnRDNgdV6xVmy8kOv+WnSdW8J6J3ApH6TYzEZqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694608; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Uy+mvISrtHvQu5hNX7wJEHS7Ifd/2AZK2mIPsLbgTkA=; b=Utq+A19dnvOBF18LyC/DObpm3Dc2x4yg94NE4XIFMxw7aYJ2Ln/JPhXRMIQoaeMUGkqfz/0kbbc+yRt7UqOxOpFiV73KHqn/khKxkeU5Fd73zwhPPFnLiqwOGoof6tsgwzLxSoVkYQsQYY2Oy/nb/VKdWJbbFAkQsHBB7a3iUTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694608607799.8885639462778; Sat, 20 Jun 2020 16:10:08 -0700 (PDT) Received: from localhost ([::1]:35122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmch-0003A6-9O for importer@patchew.org; Sat, 20 Jun 2020 19:10:07 -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) 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) 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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=C3=A9 + * + * 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 pola= rity + */ + 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=C3=A9 + * + * 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] =3D { + [LED_COLOR_RED] =3D "red", + [LED_COLOR_ORANGE] =3D "orange", + [LED_COLOR_AMBER] =3D "amber", + [LED_COLOR_YELLOW] =3D "yellow", + [LED_COLOR_GREEN] =3D "green", + [LED_COLOR_BLUE] =3D "blue", + [LED_COLOR_VIOLET] =3D "violet", /* PURPLE */ + [LED_COLOR_WHITE] =3D "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 =3D 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 =3D LED(dev); + + led_set_intensity(s, s->reset_intensity); +} + +static const VMStateDescription vmstate_led =3D { + .name =3D TYPE_LED, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + +static void led_realize(DeviceState *dev, Error **errp) +{ + LEDState *s =3D LED(dev); + + if (s->color =3D=3D NULL) { + error_setg(errp, "property 'color' not specified"); + return; + } +} + +static Property led_properties[] =3D { + 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 =3D DEVICE_CLASS(klass); + + dc->desc =3D "LED"; + dc->vmsd =3D &vmstate_led; + dc->reset =3D led_reset; + dc->realize =3D led_realize; + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); + device_class_set_props(dc, led_properties); +} + +static const TypeInfo led_info =3D { + .name =3D TYPE_LED, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(LEDState), + .class_init =3D 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 =3D 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 =3D g_ascii_strdown(description, -1); + name =3D 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 =20 +LED +M: Philippe Mathieu-Daud=C3=A9 +S: Maintained +F: include/hw/misc/led.h +F: hw/misc/led.c + Unimplemented device M: Peter Maydell R: Philippe Mathieu-Daud=C3=A9 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 =20 +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) +=3D nrf51_rng.o obj-$(CONFIG_MAC_VIA) +=3D mac_via.o =20 common-obj-$(CONFIG_GRLIB) +=3D grlib_ahb_apb_pnp.o +common-obj-$(CONFIG_LED) +=3D 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, in= t 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" =20 +# 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_st= ate, unsigned current_state) "%s GPIO id:%u status: %u -> %u" --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592694563; cv=none; d=zohomail.com; s=zohoarc; b=B47X1eJJyOGC+y8je87up8pbKBLZfj/iMaxRW2Jmm7vTggJyBcwIQMPxZTrn9sHAGoB3joPqun6tcJce2MBT+MUSRbWR33hnKQsnqy98/jCTMHUv5B2iXLiuwO+tkE7DHFMM38SqmxvVoFJkqInFXMpTksqkXGeuMNxWZRSqqNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694563; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5hUQ5otQW5bygweFKI3rW4XNSTTh4n8sfBRqu0ySVvs=; b=VDtLClm8zBK62817ECY9tiIY6vK5JnNwW6az3aOME/RHP+CLsH/iE3Jq1O2hlxhYKMJ0a5AAFGjhb35ILnrZxKt9Y92jM7CxEZUQpu3itXjuEqN36sqBvVXxhPBW0eqnpjBtQ+hW/W/u9qOZMIjP4t1/ITxgg8NTjcc/nlHzBWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159269456335023.831683627991993; Sat, 20 Jun 2020 16:09:23 -0700 (PDT) Received: from localhost ([::1]:59372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmbx-0000wF-Tz for importer@patchew.org; Sat, 20 Jun 2020 19:09:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmma8-0006zZ-EE; Sat, 20 Jun 2020 19:07:28 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmma6-0002MG-U3; Sat, 20 Jun 2020 19:07:28 -0400 Received: by mail-wr1-x442.google.com with SMTP id o11so5446615wrv.9; 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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:24 -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=5hUQ5otQW5bygweFKI3rW4XNSTTh4n8sfBRqu0ySVvs=; b=Zy9rrEO8pPRm0FO7p7zU69pbshb81SUnExVa5YSCHy02tmPi8DWS+JcDT1RaaQRBRF pPkN2QpRpevLiyOn15BxBlL/jUIiDb7aLN63bS+RrWSoVY5ofD8b7mJtwvNd255/G34z JYH0JjIVn6ZvK0R+P3wWyk5E7LHj8t20J50KYo9yE05J0nbr4SDlxfC9zABcsjTz1AEw ug+CYaBZaYfzreKN3BiA3ksgKn75kUWyZ0xIaeOKFteIG8+lCH29spz0Y1uuC3+n3aqS qi19k3qZOpuSl1YG4VNTdWTBOmzyzNkNP4MynEllnlAUUn+lXQvDuHyO7XVOAepJXvqY YN0Q== 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=5hUQ5otQW5bygweFKI3rW4XNSTTh4n8sfBRqu0ySVvs=; b=FLCXld6krxikbjsDkagSy1LmM9KMrHdJGbh3bLXsyowUkrTYoc/IM3VqsFQ0qLPITe t+wEXzbi7MmO+EPE89JeIH4wNsGgi2waqbecyfyE7N96WVeaACHXJ49xNvBBVnn9JqZB 1UF/s7Bmzb3fmdoLA/a0+GEfd+lKaDSVsfXANuTdEJHogIFG5HAxFmyih1D8So9iUlJu kzE7xSjATELnHZZLGYBcdtj/pdJVsoZ5Dd8vmgTpzfZMbNSwQboo/qxtEmU/8iy1y4RA p2xaNKx8kv4HU3ast9RSO+/1qhkpvheegG3b5cRrtwjM3THs2X3fKrcMhUmCNVm/IXb1 HU8w== X-Gm-Message-State: AOAM530CqYs1zPqzt+s9t9MZ4sKfGX+gFEh2J7NUllp7aD2reU4qSSS1 CzOzuWHp7i2cVziHLE6Z/La60dGA X-Google-Smtp-Source: ABdhPJxxVcqONhTJVlMbMTJaPerxTfSnA0zYj8eAnzbrPq/NR1cmH+ORcXA2jHbDhe+b5PSpRx1G0w== X-Received: by 2002:adf:ed47:: with SMTP id u7mr6541699wro.201.1592694444884; Sat, 20 Jun 2020 16:07:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 2/7] hw/misc/led: Add helper to connect LED to GPIO output Date: Sun, 21 Jun 2020 01:07:14 +0200 Message-Id: <20200620230719.32139-3-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Reviewed-by: Richard Henderson --- 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(+) diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h index 821ee1247d..883006bb8f 100644 --- a/include/hw/misc/led.h +++ b/include/hw/misc/led.h @@ -35,6 +35,8 @@ typedef struct LEDState { DeviceState parent_obj; /* Public */ =20 + qemu_irq irq; + /* Properties */ char *description; char *color; @@ -76,4 +78,22 @@ DeviceState *create_led(Object *parentobj, const char *description, uint16_t reset_intensity); =20 +/** + * create_led_by_gpio_id: create and LED device and connect it to a GPIO o= utput + * @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 */ diff --git a/hw/misc/led.c b/hw/misc/led.c index e55ed7dbc4..8503dde777 100644 --- a/hw/misc/led.c +++ b/hw/misc/led.c @@ -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" =20 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); } =20 +static void gpio_led_set(void *opaque, int line, int new_state) +{ + LEDState *s =3D LED(opaque); + + assert(line =3D=3D 0); + led_set_state(s, !!new_state); +} + static void led_reset(DeviceState *dev) { LEDState *s =3D 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); } =20 static Property led_properties[] =3D { @@ -119,3 +130,17 @@ DeviceState *create_led(Object *parentobj, =20 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 =3D create_led(parentobj, color, description, reset_intensity); + qdev_connect_gpio_out(gpio_dev, gpio_id, qdev_get_gpio_in(dev, 0)); + + return dev; +} --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1592694546; cv=none; d=zohomail.com; s=zohoarc; b=HF0oHeFND3aF6bJh0I9ko6MzWwtDiQWhFtH738ouweds9u1ap9ZPKV9Iq67X5/r8r1aSLADv+7CHrhlwt6S/WElHudX229oSVAKgJZ7D7y353AtuUAoBuJYXFuYt6ee6HGBhN7D+TtmNyAQcSm8Jjibt/wFOBGuPZGks6dZDcl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694546; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+2AZIJNfLoRM7W1nhvrnhDoshMHCbhObjMtaHucBvyY=; b=c/98twY6Aa/kKlMAJdnJo9ZclRqMCfXOQl82W7HCz91Gu0LsC+jlDyVvdLu7AijdSkwBusiXCPxVSudnASYOQdMvDfgx1UOu7M3RL+0HSxpYXYwLuhT/si8ORp9LX0v3lGcbk4dlw4k6WYoa0iQmZcjObDHp1Js10V8y/BV1WRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694546061495.1513821155287; Sat, 20 Jun 2020 16:09:06 -0700 (PDT) Received: from localhost ([::1]:57924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmbg-0000Lv-TQ for importer@patchew.org; Sat, 20 Jun 2020 19:09:04 -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) 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) 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Track the LED intensity, and emit a trace event when it changes. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 */ =20 + uint16_t current_intensity; qemu_irq irq; =20 /* 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_intensi= ty) { trace_led_set_intensity(s->description ? s->description : "n/a", s->color, new_intensity); + if (new_intensity !=3D s->current_intensity) { + trace_led_change_intensity(s->description ? s->description : "n/a", + s->color, + s->current_intensity, new_intensity); + } s->current_intensity =3D new_intensity; } =20 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 =20 # 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_int= ensity, uint16_t new_intensity) "LED desc:'%s' color:%s intensity 0x%04"PRI= x16" -> 0x%04"PRIx16"" =20 # pca9552.c pca9552_gpio_status(const char *description, const char *buf) "%s GPIOs 0-= 15 [%s]" --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1592694656; cv=none; d=zohomail.com; s=zohoarc; b=Z8W35bOcxztXImXQDpFItREDEuVKHhW7Als7eMNI9GCRIAOOd837JMD0sutOySvHohOfM4QKr4ceIWSy1D157pGkFOWFteHgxibz39EaF3ZsVB0V/ZkFHfhIJCzLbDd18V1TunDXhx2+f6UJz/OrmpAjIE5HXotouGPZueNOG6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694656; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L7Y35LMk2Ma+Lon7EzcxgbVJFXZUaFqzrr3RXETrmOQ=; b=fp1FBDvi89L2c1lErs9mrgIeE3mLrX40tKlEEIJPu9xmo3+Xa14lKfHdBZ3y4SBuamrjwWkXLVf+YZlTc39jmKPzRiRGj58i86lz3GdE5lernXf7fF0D9Ik0V8wp+P+Sf/7rd+1FqdsY4IoNsgsKVbuvRc7aej8N+Hbh6p4Wjho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694656052128.11054634192703; Sat, 20 Jun 2020 16:10:56 -0700 (PDT) Received: from localhost ([::1]:37286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmdS-0004Uz-RO for importer@patchew.org; Sat, 20 Jun 2020 19:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmmaB-00076s-88; Sat, 20 Jun 2020 19:07:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmma9-0002Md-HF; Sat, 20 Jun 2020 19:07:30 -0400 Received: by mail-wr1-x444.google.com with SMTP id q2so10719772wrv.8; 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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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=L7Y35LMk2Ma+Lon7EzcxgbVJFXZUaFqzrr3RXETrmOQ=; b=k6VxCSMDgEdEDsiaM6vtAhIPZymGdRmGefv4UZVGsNQ70nKYIRkUj7i1ujUNc3qc3U lS4qrSjXSz1pCIQDQNf7BEDU6sy6ebiVAF9dL9le+LyPMUwcvTzQUf8gXFRokFnbzkcY biV6ZIhConz/vN9Sa00siyogwyjSieiNLbow85GAWPswqUgaHMlyfOLj+5VhIhXnJQ+Z rv38WmeGXkQqlMgDigry+ZLwYgRSLMmNelq7BXMRHb3jsPLzi3Wc687OKRCIfqw4/h3J awmirJWZ8Q7d7B2RTuX8YOLFkA3T+yY2HYS2d5OVZR2gTCW3kyuySTTpxLErWC/kL2oD VuDQ== 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=L7Y35LMk2Ma+Lon7EzcxgbVJFXZUaFqzrr3RXETrmOQ=; b=qYpmd9jCIBWu1s1BzAwBbApHPA/B427sBYP+fid7RABpn4bJa4sxUa1kSniAQSikZX e1jH+s5ee8BpuWUsGTOoAsWNLUWV4ttxOvS3i7OuoVsfL7PSVKWPMM0kqRjsQN4LOpPb KuDQeCjKbNxE8mFGnT5aVZ45KgKENpaJIAH+L2JO0txWwBRkquMH5v+RVLYkASCg5lNU DQzO34wxXdJ9+EppseElbb0XY7Dju0mHSlPoHNOOl/IS3m059wUw1GDjiIr52rTgYbtJ 7lf7EEf2yGUIZSrJgndRu8YphG4Gjljcg7wul5kkGdLRtuycwyVaduRdu6N0lucZLsN/ xwrw== X-Gm-Message-State: AOAM533p1XZFtD/W4HAFmVdjehtGyXDpkVtAZ+VYMaPCITgpo15sO2iy nnMWiD6a9WZc9oKik4+Ynu8P/bDb X-Google-Smtp-Source: ABdhPJwi2ycvqI0fhGiGhapj06F7HM5xGwQwG2GGJrOOwU6awWZypl9oBtK07LQeu6Si4vVEBa2GNg== X-Received: by 2002:adf:ecc2:: with SMTP id s2mr12209614wro.60.1592694447696; Sat, 20 Jun 2020 16:07:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 4/7] hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1 Date: Sun, 21 Jun 2020 01:07:16 +0200 Message-Id: <20200620230719.32139-5-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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:gre= en intensity 0x0000 -> 0xffff 1592693373.997632:led_change_intensity LED desc:'front-power-3' color:gre= en 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:gre= en intensity 0xffff -> 0x0000 1592693500.312041:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0x0000 -> 0xffff 1592693500.821254:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0xffff -> 0x0000 1592693501.331517:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0x0000 -> 0xffff 1592693501.841367:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0xffff -> 0x0000 1592693502.350839:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0x0000 -> 0xffff 1592693502.861134:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0xffff -> 0x0000 1592693503.371090:led_change_intensity LED desc:'front-power-3' color:gre= en intensity 0x0000 -> 0xffff We notice the front-power LED starts to blink. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/arm/aspeed.c | 17 +++++++++++++++++ hw/arm/Kconfig | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 3d5dec4692..217f8ad7d5 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -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) =20 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[] =3D { + {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 =3D &bmc->soc; uint8_t *eeprom_buf =3D 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); =20 + for (size_t i =3D 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", 0= x4c); i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0= x4c); =20 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 9afa6eee79..1a57a861ac 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -393,6 +393,7 @@ config ASPEED_SOC select TMP105 select TMP421 select UNIMP + select LED =20 config MPS2 bool --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592694708; cv=none; d=zohomail.com; s=zohoarc; b=dydhQNNPgynq2S29EbSUIiH3eKquK/loQUd6NlxyrZrIYxadtgZLgP0EAxVSke8ET93F7qEvu0cQvaGO18tubE5TaF0i0+W5FcPGAqc9ZlNu6/kJUu84nIe6sS70AxAUP/PKfYxopXnJkNrqcumWt2OKZl7NbpVzxdHarvoC7EQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694708; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zb02tNNP3k4Arx05DuNHXof+/AxtMqtoGOWXwVkHhHE=; b=ZauEKlx8WpeEsWJPsD9BQHBKtC0hHn12pM+DP7ebdN5ic8q2qGzue74QTpXVZdPQ0SdYknfb99GMD5EEncM6S99WojYIp3a5wwTy2br+Xn5mGTx88RiaFTvjlpckKxecbeDpOt7b99VfczOICU89PrWtv16rn+ipo6G/RwfshbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694708193555.5565639032008; Sat, 20 Jun 2020 16:11:48 -0700 (PDT) Received: from localhost ([::1]:39492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmeI-0005gR-VG for importer@patchew.org; Sat, 20 Jun 2020 19:11:46 -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) 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) 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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 { =20 /*< public >*/ MemoryRegion iomem; + DeviceState *led[2]; =20 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" =20 @@ -176,12 +177,9 @@ static void mps2_fpgaio_write(void *opaque, hwaddr off= set, uint64_t value, =20 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 eve= nt. - */ - trace_mps2_fpgaio_leds(value & 0x02 ? '*' : '.', - value & 0x01 ? '*' : '.'); s->led0 =3D 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] =3D create_led(obj, LED_COLOR_GREEN, + "USERLED0", LED_RESET_INTENSITY_ACTIVE_HIGH); + s->led[1] =3D create_led(obj, LED_COLOR_GREEN, + "USERLED1", LED_RESET_INTENSITY_ACTIVE_HIGH); } =20 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 =20 config MPS2_FPGAIO bool + select LED =20 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, uin= t32_t value) "MPS2 SCC mps2_fpgaio_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGA= IO read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_fpgaio_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPG= AIO 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" =20 # msf2-sysreg.c msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysr= eg write: addr 0x%08" PRIx64 " data 0x%" PRIx32 " prev 0x%" PRIx32 --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592694775; cv=none; d=zohomail.com; s=zohoarc; b=EeHAhEN5yFFBecQegi4IUxFtYSIHCfJs93o5ejNBqS8sMYsIwikfnG2+CiE24jK/+buuudmQAUQm0ClA4BhKA8I4ygZCsmNa/EqoA5tsGqhEs2hO9MsI5nWNLbztlVCbYQSE0N7w4AN9IxKitOw9B3u0dRInfN7dlj2aGcPU10c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694775; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iRQDsCaGbstPl2leufRUxE6mmev54DrPXBIJv8GpU9I=; b=nUaPrQOEMyKHnj4yAl9Gr6zt0SLrx4VihTPmHSOhA2EBTvyk18SjhEuJ1nVbakiEY6IqbAeLHhiPadznKy3gjQWVbD6Ji8yLBqThIk4Zoiu3Zg3YMJniowm/7I7ZwF0dBFNYUny40CBgwWMuTlk90Vqle3x1WqoALayIw49HmnQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694775427671.9185814318884; Sat, 20 Jun 2020 16:12:55 -0700 (PDT) Received: from localhost ([::1]:43154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmfO-0007Rp-4n for importer@patchew.org; Sat, 20 Jun 2020 19:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmmaD-0007Dk-Ru; Sat, 20 Jun 2020 19:07:33 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43338) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmmaC-0002Mu-1n; Sat, 20 Jun 2020 19:07:33 -0400 Received: by mail-wr1-x444.google.com with SMTP id l10so13144705wrr.10; 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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 16:07:29 -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=iRQDsCaGbstPl2leufRUxE6mmev54DrPXBIJv8GpU9I=; b=c4xvfzZyfG+QNtJZMuNlZkc63tl1l5maSRo9RKUW+BK1bc6uFzssPcX4WaDmsbVskW VMawIC3lAXb3Ptrgpg8+zSq3MPLyjeeWc/fj6UBnhBr2+6r/kYuWF9EHD/vfvVh0ebN8 knKV0PuGRQMsPoMMpRD7HEGGI6nSfBzfMQqaPizF/Z83N2AegA9o1+ZAvnGSKfwQUXuS 20ga8LTksAcFAXfwhpcsHwsSzptRpPpSo7pDZODGSPCEqljwVG1TLpMJPRmyPJBNXUIT B3JTxFyH9Dt7q+DGykQYS6zHBP/X5rj/R3I5P9tJqfJikZTooXaQ98IM76mAic6DWbNZ V/Xw== 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=iRQDsCaGbstPl2leufRUxE6mmev54DrPXBIJv8GpU9I=; b=S/xSqjjwZR+QTBMABkUJ8KNdPel7lhT8pDBXkXZP6t7ztTqveND92R0d+EqLgpI+94 zX/kHLneVq3Z9bd+4DpVVoC67aqpPYdbm0w9iTo8wZC9xPA3ukGYRbPyc4RDPv+ZP8W0 3gCBxsGmyYX0LVsYI5ev9iGcCPO/e4OnO7A3ok7Y5b3DCGDH9KgMhOiRiZohW9foNVZp 6S9Xsdwv9QDCFu8HBI6vUIrGB/kOQBU9CPIc3NVWBFZGeoIEhefuuwTv1UgbbnsH2cGw 60th8UIjdYHIAavwpMl7ip5ejwaIan+AfDBj3aYSvBJ4BojWFKVmwblLDbg242wi9RBd Tjfg== X-Gm-Message-State: AOAM532rcwYuuoc/dzmIxaWwKuJycuIPBBASpqy8OJDoo5d4lhnfYnN6 C2DklLW11QQLjpNEE+Vc356bcO2n X-Google-Smtp-Source: ABdhPJwV8hIOSd0q181rY0A5eLseezbMdmJEFrPYScCZKBppOuMc4rn/DNTTY05+WawPAsQVJF/45Q== X-Received: by 2002:adf:bb02:: with SMTP id r2mr11613908wrg.143.1592694450151; Sat, 20 Jun 2020 16:07:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 6/7] hw/misc/mps2-scc: Use the LED device Date: Sun, 21 Jun 2020 01:07:18 +0200 Message-Id: <20200620230719.32139-7-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- https://youtu.be/l9kD70uPchk?t=3D288 --- 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(-) diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h index 7045473788..29e12b832b 100644 --- a/include/hw/misc/mps2-scc.h +++ b/include/hw/misc/mps2-scc.h @@ -25,6 +25,7 @@ typedef struct { =20 /*< public >*/ MemoryRegion iomem; + DeviceState *led[8]; =20 uint32_t cfg0; uint32_t cfg1; diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c index 9d0909e7b3..2e59a382ec 100644 --- a/hw/misc/mps2-scc.c +++ b/hw/misc/mps2-scc.c @@ -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" =20 REG32(CFG0, 0) @@ -152,18 +154,10 @@ static void mps2_scc_write(void *opaque, hwaddr offse= t, uint64_t value, s->cfg0 =3D 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 eve= nt. - */ - trace_mps2_scc_leds(value & 0x80 ? '*' : '.', - value & 0x40 ? '*' : '.', - value & 0x20 ? '*' : '.', - value & 0x10 ? '*' : '.', - value & 0x08 ? '*' : '.', - value & 0x04 ? '*' : '.', - value & 0x02 ? '*' : '.', - value & 0x01 ? '*' : '.'); s->cfg1 =3D value; + for (size_t i =3D 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 =3D value; @@ -245,6 +239,13 @@ static void mps2_scc_init(Object *obj) =20 memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x= 1000); sysbus_init_mmio(sbd, &s->iomem); + + for (size_t i =3D 0; i < ARRAY_SIZE(s->led); i++) { + char *name =3D g_strdup_printf("SCC LED%zu", i); + s->led[i] =3D create_led(obj, LED_COLOR_GREEN, + name, LED_RESET_INTENSITY_ACTIVE_HIGH); + g_free(name); + } } =20 static void mps2_scc_realize(DeviceState *dev, Error **errp) diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 889757731b..f278f7f354 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -97,6 +97,7 @@ config MPS2_FPGAIO =20 config MPS2_SCC bool + select LED =20 config TZ_MPC bool diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 8bc7a675e8..490a0f341a 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -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 rea= d: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC wr= ite: 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) "MP= S2 SCC config write: function %d device %d data 0x%" PRIx32 mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS= 2 SCC config read: function %d device %d data 0x%" PRIx32 =20 --=20 2.21.3 From nobody Sat Jun 1 05:45:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592694834; cv=none; d=zohomail.com; s=zohoarc; b=APj9tivvAJdMPO1s8OOhQ8gauZnoN8jEAmupfg5mpwRgcWvosRgdaCGnJpuIrXmZF24ipkQuTQDQ6fXvs0jb1iLFvLpnifgJkCRpyApQrQWbIB9av5f2HW8H//vMim62wlNVTGOkuTLkhtEt6eP7W8V65sRaaCvaom5JurVJS44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592694834; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dqGlIc+jv7onYHOT7vp+iSAvaDEPRQt/mIvRK1NcKyk=; b=m60Si3A6GdxZ6Wl2hIDnR9BHxNRsnnVf4rlCJFdYhuZye0+xucmIi05JITFLszUHGCctem1XWoz75R+AZn3Pf+aehW2HiLJg8muWLByCRbreztrTCn4smwzGUu0xD2frlZSAerQ8QEsPrlhpJ16dNf3T8zJxeC41cqedJjmyRU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592694834783507.4391572478821; Sat, 20 Jun 2020 16:13:54 -0700 (PDT) Received: from localhost ([::1]:46088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmmgL-0000ze-J8 for importer@patchew.org; Sat, 20 Jun 2020 19:13:53 -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) 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) 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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" =20 #define TOSA_RAM 0x04000000 @@ -65,27 +66,6 @@ static void tosa_microdrive_attach(PXA2xxState *cpu) pxa2xx_pcmcia_attach(cpu->pcmcia[0], md); } =20 -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 =3D %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 =3D qemu_allocate_irqs(tosa_out_switch, cpu, 4); qemu_irq reset; =20 /* 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); =20 - 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_ge= t(tmio)); =20 /* UDC Vbus */ @@ -234,6 +208,18 @@ static void tosa_init(MachineState *machine) =20 scp0 =3D sysbus_create_simple("scoop", 0x08800000, NULL); scp1 =3D 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); =20 tosa_gpio_setup(mpu, scp0, scp1, tmio); =20 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 =20 config SPITZ bool --=20 2.21.3