From nobody Tue Feb 10 03:39:58 2026 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=1587472044; cv=none; d=zohomail.com; s=zohoarc; b=mL4f7MAinY3WWYC16RxDAWV59xPO1jA1WdN4OxfeBgAKHTdoghWC0ie9yaT9Puq6hFKPcgcWSii9lfRdAZMwVTZI+KzuQMARQgRfwV7jjDeI+OJ7BXn2XD7babtJBF6oV6XmiCTj/ID8fWbR9fGeuFexA/jMYj/QDMpghVrla18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587472044; 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=6IZGXEDwfoPtCg1GsMDYigPQKwJxDM34TttvkoqeAQE=; b=kSXqp/ZIpXrqiqwNmSI/dF+Qd+sQ53dFevjZcMXruw94ATI2STucvzoZLPUZG5qobFSsWfPItG6dhHo629EpkgOYDZ6uahD9+MxFdP8n6GMWnCAYUoeKKjbYmCybizJDkLySZTjqwAfsSgFZOm/0bmdbWvFHDP5CWTNjmj0gZMY= 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 1587472044820419.8227138050569; Tue, 21 Apr 2020 05:27:24 -0700 (PDT) Received: from localhost ([::1]:57062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQrzm-0004gE-EZ for importer@patchew.org; Tue, 21 Apr 2020 08:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQrpm-0005ho-EC for qemu-devel@nongnu.org; Tue, 21 Apr 2020 08:17:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQrpk-0006uH-Qe for qemu-devel@nongnu.org; Tue, 21 Apr 2020 08:17:01 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQrpi-0006dA-SF; Tue, 21 Apr 2020 08:16:59 -0400 Received: by mail-wm1-x343.google.com with SMTP id y24so3411611wma.4; Tue, 21 Apr 2020 05:16:55 -0700 (PDT) Received: from x1w.redhat.com (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id z76sm3761140wmc.9.2020.04.21.05.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 05:16:53 -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=6IZGXEDwfoPtCg1GsMDYigPQKwJxDM34TttvkoqeAQE=; b=cld4TGjXlImqH0i0Lx9y7Jn/yVaEqLd0qkfCoCKNfcIqctdkFSoFFTgxOLZY3AffYE FM0xjenwG0+N2/SINbmuvXhTOZ5hgHiS3GCsDLDCSCs5rUtDDVUNzrFbvSZDdvAoFZkJ s5VlXJwhMC9Zp8/Gc3IZx3lmB07cvvxXqgnjRd+aIEeXPU/mmsgh4KD8JWi3MN1n/dEg aLYTAId3WRlgFST9uUntla4IdEFECOezHme9rdd346di9T+O2W5fOMPdEoNe68xFN1qn MCngY4a0nPnfTcGXcmms+7RMTlwyJArgcc8I5KWTZMJi1Gk7qpT+plwkrgQyJyo/lCso TVsw== 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=6IZGXEDwfoPtCg1GsMDYigPQKwJxDM34TttvkoqeAQE=; b=kNYFgg49V+SwKvM5GKgDgMJtF/5zZvZakvvD7OGX+sNNmB6j4JMvPifnnrp9eMiAg/ tx5rlx+baSJTbxyElZu0HQr98Ii/7Tfx0GmNxUZaaHZ3w2tN2I91LXGaF5fwfVPquq9A QAJiSkO4Ye0SaBCYMV4fil8KrqT53s1O3GWDiSeYBh15QUWMGojJ2SfzPpNPa4AjJiJi rwYOmpXcfZg9hEWfMYvlEZ8tIFti4rlcCfZcoEq9iPyAzksVfNvz2ZLxLMldsSF4dEVu /Y2xlMe5X3ndihXQFyyFxu1vMmAVYH6RK+YxtpZfRaaZUICC81YUAM1Rvp5Ffmkm6NNT X3xQ== X-Gm-Message-State: AGi0PuZYhHwD4vG7byIli6vmqmfMSsk+opkGYatm34GFqGA3FZhzvW5j lqpX+uroa3TdKyZ4zwxsD9Rwf5kDynA= X-Google-Smtp-Source: APiQypKkBl6/Wv7/xjSPwC6+whbKMyjIMWK75D5sxM+69/jcpVqMC5dEkTNbIVRKSahKpmd3K+c8BQ== X-Received: by 2002:a05:600c:2c04:: with SMTP id q4mr4410317wmg.7.1587471414039; Tue, 21 Apr 2020 05:16:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 13/17] hw/misc/bcm2835_property: Implement the 'temperature-sensor' interface Date: Tue, 21 Apr 2020 14:16:22 +0200 Message-Id: <20200421121626.23791-14-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200421121626.23791-1-f4bug@amsat.org> References: <20200421121626.23791-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: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a00:1450:4864:20::343 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: Laurent Vivier , Peter Maydell , Thomas Huth , qemu-block@nongnu.org, qemu-trivial@nongnu.org, Michael Tokarev , Markus Armbruster , Andrew Baumann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini , Jean-Christophe Dubois , John Snow , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The BCM2835 'property' QEMU device models the serialized responses from the VideoCore firmware. As we can query the VC for its current temperatyre, let this model implement the 'temperature-sensor' interface. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/bcm2835_property.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index bbe80affd4..dd1e9a2e03 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -12,6 +12,7 @@ #include "migration/vmstate.h" #include "hw/irq.h" #include "hw/misc/bcm2835_mbox_defs.h" +#include "hw/misc/temp-sensor.h" #include "sysemu/dma.h" #include "qemu/log.h" #include "qemu/module.h" @@ -372,6 +373,27 @@ static const VMStateDescription vmstate_bcm2835_proper= ty =3D { } }; =20 +static const char *bcm2835_property_get_temp_sensor_name(TempSensor *obj, + unsigned sensor_i= d) +{ + return "videocore"; +} + +static float bcm2835_property_get_temp(TempSensor *obj, unsigned sensor_id) +{ + BCM2835PropertyState *s =3D BCM2835_PROPERTY(obj); + + return s->temp_mC / 1000; +} + +static void bcm2835_property_set_temp(TempSensor *obj, unsigned sensor_id, + float temp_C, Error **errp) +{ + BCM2835PropertyState *s =3D BCM2835_PROPERTY(obj); + + s->temp_mC =3D temp_C * 1000; +} + static void bcm2835_property_init(Object *obj) { BCM2835PropertyState *s =3D BCM2835_PROPERTY(obj); @@ -429,10 +451,15 @@ static Property bcm2835_property_props[] =3D { static void bcm2835_property_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + TempSensorClass *tc =3D TEMPSENSOR_INTERFACE_CLASS(klass); =20 device_class_set_props(dc, bcm2835_property_props); dc->realize =3D bcm2835_property_realize; dc->vmsd =3D &vmstate_bcm2835_property; + tc->sensor_count =3D 1; + tc->get_name =3D bcm2835_property_get_temp_sensor_name; + tc->set_temperature =3D bcm2835_property_set_temp; + tc->get_temperature =3D bcm2835_property_get_temp; } =20 static TypeInfo bcm2835_property_info =3D { @@ -441,6 +468,10 @@ static TypeInfo bcm2835_property_info =3D { .instance_size =3D sizeof(BCM2835PropertyState), .class_init =3D bcm2835_property_class_init, .instance_init =3D bcm2835_property_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_TEMPSENSOR_INTERFACE }, + { } + }, }; =20 static void bcm2835_property_register_types(void) --=20 2.21.1