All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: minyard@acm.org, Thomas Huth <thuth@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Corey Minyard" <cminyard@mvista.com>,
	"Titus Rwantare" <titusr@google.com>,
	qemu-devel@nongnu.org, "Hao Wu" <wuhaotsh@google.com>,
	qemu-arm@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"John Wang" <wangzhiqiang.bj@bytedance.com>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [PATCH] hw: Add a 'Sensor devices' qdev category
Date: Mon, 27 Sep 2021 14:47:32 +0200	[thread overview]
Message-ID: <d25c8d0b-f5d1-0ac1-fc8f-3fad56820f42@amsat.org> (raw)
In-Reply-To: <20210927113349.GH5381@minyard.net>

On 9/27/21 13:33, Corey Minyard wrote:
> On Mon, Sep 27, 2021 at 12:15:18AM +0200, Philippe Mathieu-Daudé wrote:
>> Sensors models are listed in the 'Misc devices' category.
>> Move them to their own category.
>>
>> For the devices in the hw/sensor/ directory, the category
>> is obvious.
>>
>> hw/arm/z2.c models the AER915 model which is described
>> on [*] as:
>>
>>   The 14-pin chip marked AER915 just below the expansion
>>   port is a 80C51-type microcontroller, similar to Philips
>>   P89LPC915. It has an 8-bit A/D which is used to determine
>>   which of six buttons are pressed on the resistor-network
>>   wired remote.  It communicates with the main cpu via I2C.
>>
>> It was introduced in commit 3bf11207c06 ("Add support for
>> Zipit Z2 machine") with this comment:
>>
>>   248 static uint8_t aer915_recv(I2CSlave *slave)
>>   249 {
>>   ...
>>   253     switch (s->buf[0]) {
>>   254     /* Return hardcoded battery voltage,
>>   255      * 0xf0 means ~4.1V
>>   256      */
>>   257     case 0x02:
>>   258         retval = 0xf0;
>>   259         break;
>>
>> For QEMU the AER915 is a very simple sensor model.
>>
>> [*] https://www.bealecorner.org/best/measure/z2/index.html
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> This makes sense to me.  I'd like to hear from others on this.

Devices on a bus (in particular I2C) are usually user-creatable
by default. The AER915 is more a band aid for the z2 machine,
but is not really a device. IMO it would be better to hide it
as non-user-creatable qdev.

>> ---
>>  include/hw/qdev-core.h | 1 +
>>  hw/arm/z2.c            | 1 +
>>  hw/sensor/adm1272.c    | 1 +
>>  hw/sensor/dps310.c     | 1 +
>>  hw/sensor/emc141x.c    | 1 +
>>  hw/sensor/max34451.c   | 2 ++
>>  hw/sensor/tmp105.c     | 1 +
>>  hw/sensor/tmp421.c     | 1 +
>>  softmmu/qdev-monitor.c | 1 +
>>  9 files changed, 10 insertions(+)

>> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
>> index 9c1e876207b..62db9741106 100644
>> --- a/hw/arm/z2.c
>> +++ b/hw/arm/z2.c
>> @@ -288,6 +288,7 @@ static void aer915_class_init(ObjectClass *klass, void *data)
>>      k->recv = aer915_recv;
>>      k->send = aer915_send;
>>      dc->vmsd = &vmstate_aer915_state;
>> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>>  }


      reply	other threads:[~2021-09-27 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 22:15 [PATCH] hw: Add a 'Sensor devices' qdev category Philippe Mathieu-Daudé
2021-09-27 10:03 ` Cédric Le Goater
2021-09-27 15:49   ` Hao Wu
2021-09-27 11:33 ` Corey Minyard
2021-09-27 12:47   ` Philippe Mathieu-Daudé [this message]

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=d25c8d0b-f5d1-0ac1-fc8f-3fad56820f42@amsat.org \
    --to=f4bug@amsat.org \
    --cc=berrange@redhat.com \
    --cc=bmeng.cn@gmail.com \
    --cc=clg@kaod.org \
    --cc=cminyard@mvista.com \
    --cc=ehabkost@redhat.com \
    --cc=joel@jms.id.au \
    --cc=minyard@acm.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=titusr@google.com \
    --cc=wangzhiqiang.bj@bytedance.com \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.