All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw: Add a 'Sensor devices' qdev category
@ 2021-09-26 22:15 Philippe Mathieu-Daudé
  2021-09-27 10:03 ` Cédric Le Goater
  2021-09-27 11:33 ` Corey Minyard
  0 siblings, 2 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-26 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Corey Minyard, Daniel P. Berrangé,
	Eduardo Habkost, Peter Maydell, Titus Rwantare,
	Philippe Mathieu-Daudé,
	Hao Wu, qemu-arm, Joel Stanley, Paolo Bonzini, Bin Meng,
	John Wang, Cédric Le Goater

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>
---
 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/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 34c8a7506a1..f6241212247 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -26,6 +26,7 @@ typedef enum DeviceCategory {
     DEVICE_CATEGORY_SOUND,
     DEVICE_CATEGORY_MISC,
     DEVICE_CATEGORY_CPU,
+    DEVICE_CATEGORY_SENSOR,
     DEVICE_CATEGORY_MAX
 } DeviceCategory;
 
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);
 }
 
 static const TypeInfo aer915_info = {
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 7310c769be2..2942ac75f90 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -518,6 +518,7 @@ static void adm1272_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
 
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
     dc->desc = "Analog Devices ADM1272 Hot Swap controller";
     dc->vmsd = &vmstate_adm1272;
     k->write_data = adm1272_write_data;
diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c
index d60a18ac41b..1e24a499b38 100644
--- a/hw/sensor/dps310.c
+++ b/hw/sensor/dps310.c
@@ -208,6 +208,7 @@ static void dps310_class_init(ObjectClass *klass, void *data)
     k->send = dps310_tx;
     dc->reset = dps310_reset;
     dc->vmsd = &vmstate_dps310;
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
 }
 
 static const TypeInfo dps310_info = {
diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c
index 7ce8f4e9794..4202d8f185a 100644
--- a/hw/sensor/emc141x.c
+++ b/hw/sensor/emc141x.c
@@ -270,6 +270,7 @@ static void emc141x_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
 
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
     dc->reset = emc141x_reset;
     k->event = emc141x_event;
     k->recv = emc141x_rx;
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index a91d8bd487c..8300bf4ff43 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -751,6 +751,8 @@ static void max34451_class_init(ObjectClass *klass, void *data)
     ResettableClass *rc = RESETTABLE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
     PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
+
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
     dc->desc = "Maxim MAX34451 16-Channel V/I monitor";
     dc->vmsd = &vmstate_max34451;
     k->write_data = max34451_write_data;
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index 20564494899..43d79b9eeec 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -305,6 +305,7 @@ static void tmp105_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
 
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
     dc->realize = tmp105_realize;
     k->event = tmp105_event;
     k->recv = tmp105_rx;
diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c
index a3db57dcb5a..c328978af9c 100644
--- a/hw/sensor/tmp421.c
+++ b/hw/sensor/tmp421.c
@@ -343,6 +343,7 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
     TMP421Class *sc = TMP421_CLASS(klass);
 
+    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
     dc->realize = tmp421_realize;
     k->event = tmp421_event;
     k->recv = tmp421_rx;
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 0705f008466..db56f328228 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -162,6 +162,7 @@ static void qdev_print_devinfos(bool show_no_user)
         [DEVICE_CATEGORY_SOUND]   = "Sound",
         [DEVICE_CATEGORY_MISC]    = "Misc",
         [DEVICE_CATEGORY_CPU]     = "CPU",
+        [DEVICE_CATEGORY_SENSOR]  = "Sensor",
         [DEVICE_CATEGORY_MAX]     = "Uncategorized",
     };
     GSList *list, *elt;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw: Add a 'Sensor devices' qdev category
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2021-09-27 10:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Corey Minyard, Daniel P. Berrangé,
	Eduardo Habkost, Peter Maydell, Titus Rwantare, Hao Wu, qemu-arm,
	Joel Stanley, Paolo Bonzini, Bin Meng, John Wang

On 9/27/21 00:15, 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>

Reviewed-by: Cédric Le Goater <clg@kaod.org>


> ---
>   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/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 34c8a7506a1..f6241212247 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -26,6 +26,7 @@ typedef enum DeviceCategory {
>       DEVICE_CATEGORY_SOUND,
>       DEVICE_CATEGORY_MISC,
>       DEVICE_CATEGORY_CPU,
> +    DEVICE_CATEGORY_SENSOR,
>       DEVICE_CATEGORY_MAX
>   } DeviceCategory;
>   
> 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);
>   }
>   
>   static const TypeInfo aer915_info = {
> diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
> index 7310c769be2..2942ac75f90 100644
> --- a/hw/sensor/adm1272.c
> +++ b/hw/sensor/adm1272.c
> @@ -518,6 +518,7 @@ static void adm1272_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
>   
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>       dc->desc = "Analog Devices ADM1272 Hot Swap controller";
>       dc->vmsd = &vmstate_adm1272;
>       k->write_data = adm1272_write_data;
> diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c
> index d60a18ac41b..1e24a499b38 100644
> --- a/hw/sensor/dps310.c
> +++ b/hw/sensor/dps310.c
> @@ -208,6 +208,7 @@ static void dps310_class_init(ObjectClass *klass, void *data)
>       k->send = dps310_tx;
>       dc->reset = dps310_reset;
>       dc->vmsd = &vmstate_dps310;
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>   }
>   
>   static const TypeInfo dps310_info = {
> diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c
> index 7ce8f4e9794..4202d8f185a 100644
> --- a/hw/sensor/emc141x.c
> +++ b/hw/sensor/emc141x.c
> @@ -270,6 +270,7 @@ static void emc141x_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>   
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>       dc->reset = emc141x_reset;
>       k->event = emc141x_event;
>       k->recv = emc141x_rx;
> diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
> index a91d8bd487c..8300bf4ff43 100644
> --- a/hw/sensor/max34451.c
> +++ b/hw/sensor/max34451.c
> @@ -751,6 +751,8 @@ static void max34451_class_init(ObjectClass *klass, void *data)
>       ResettableClass *rc = RESETTABLE_CLASS(klass);
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
> +
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>       dc->desc = "Maxim MAX34451 16-Channel V/I monitor";
>       dc->vmsd = &vmstate_max34451;
>       k->write_data = max34451_write_data;
> diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
> index 20564494899..43d79b9eeec 100644
> --- a/hw/sensor/tmp105.c
> +++ b/hw/sensor/tmp105.c
> @@ -305,6 +305,7 @@ static void tmp105_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>   
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>       dc->realize = tmp105_realize;
>       k->event = tmp105_event;
>       k->recv = tmp105_rx;
> diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c
> index a3db57dcb5a..c328978af9c 100644
> --- a/hw/sensor/tmp421.c
> +++ b/hw/sensor/tmp421.c
> @@ -343,6 +343,7 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
>       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>       TMP421Class *sc = TMP421_CLASS(klass);
>   
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>       dc->realize = tmp421_realize;
>       k->event = tmp421_event;
>       k->recv = tmp421_rx;
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 0705f008466..db56f328228 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -162,6 +162,7 @@ static void qdev_print_devinfos(bool show_no_user)
>           [DEVICE_CATEGORY_SOUND]   = "Sound",
>           [DEVICE_CATEGORY_MISC]    = "Misc",
>           [DEVICE_CATEGORY_CPU]     = "CPU",
> +        [DEVICE_CATEGORY_SENSOR]  = "Sensor",
>           [DEVICE_CATEGORY_MAX]     = "Uncategorized",
>       };
>       GSList *list, *elt;
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw: Add a 'Sensor devices' qdev category
  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 11:33 ` Corey Minyard
  2021-09-27 12:47   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Corey Minyard @ 2021-09-27 11:33 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Daniel P. Berrangé,
	Eduardo Habkost, Corey Minyard, Titus Rwantare, qemu-devel,
	Hao Wu, qemu-arm, Joel Stanley, Paolo Bonzini, Bin Meng,
	John Wang, Cédric Le Goater

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.

-corey

> ---
>  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/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 34c8a7506a1..f6241212247 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -26,6 +26,7 @@ typedef enum DeviceCategory {
>      DEVICE_CATEGORY_SOUND,
>      DEVICE_CATEGORY_MISC,
>      DEVICE_CATEGORY_CPU,
> +    DEVICE_CATEGORY_SENSOR,
>      DEVICE_CATEGORY_MAX
>  } DeviceCategory;
>  
> 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);
>  }
>  
>  static const TypeInfo aer915_info = {
> diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
> index 7310c769be2..2942ac75f90 100644
> --- a/hw/sensor/adm1272.c
> +++ b/hw/sensor/adm1272.c
> @@ -518,6 +518,7 @@ static void adm1272_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
>  
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>      dc->desc = "Analog Devices ADM1272 Hot Swap controller";
>      dc->vmsd = &vmstate_adm1272;
>      k->write_data = adm1272_write_data;
> diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c
> index d60a18ac41b..1e24a499b38 100644
> --- a/hw/sensor/dps310.c
> +++ b/hw/sensor/dps310.c
> @@ -208,6 +208,7 @@ static void dps310_class_init(ObjectClass *klass, void *data)
>      k->send = dps310_tx;
>      dc->reset = dps310_reset;
>      dc->vmsd = &vmstate_dps310;
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>  }
>  
>  static const TypeInfo dps310_info = {
> diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c
> index 7ce8f4e9794..4202d8f185a 100644
> --- a/hw/sensor/emc141x.c
> +++ b/hw/sensor/emc141x.c
> @@ -270,6 +270,7 @@ static void emc141x_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>      dc->reset = emc141x_reset;
>      k->event = emc141x_event;
>      k->recv = emc141x_rx;
> diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
> index a91d8bd487c..8300bf4ff43 100644
> --- a/hw/sensor/max34451.c
> +++ b/hw/sensor/max34451.c
> @@ -751,6 +751,8 @@ static void max34451_class_init(ObjectClass *klass, void *data)
>      ResettableClass *rc = RESETTABLE_CLASS(klass);
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
> +
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>      dc->desc = "Maxim MAX34451 16-Channel V/I monitor";
>      dc->vmsd = &vmstate_max34451;
>      k->write_data = max34451_write_data;
> diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
> index 20564494899..43d79b9eeec 100644
> --- a/hw/sensor/tmp105.c
> +++ b/hw/sensor/tmp105.c
> @@ -305,6 +305,7 @@ static void tmp105_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>      dc->realize = tmp105_realize;
>      k->event = tmp105_event;
>      k->recv = tmp105_rx;
> diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c
> index a3db57dcb5a..c328978af9c 100644
> --- a/hw/sensor/tmp421.c
> +++ b/hw/sensor/tmp421.c
> @@ -343,6 +343,7 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
>      I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>      TMP421Class *sc = TMP421_CLASS(klass);
>  
> +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
>      dc->realize = tmp421_realize;
>      k->event = tmp421_event;
>      k->recv = tmp421_rx;
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 0705f008466..db56f328228 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -162,6 +162,7 @@ static void qdev_print_devinfos(bool show_no_user)
>          [DEVICE_CATEGORY_SOUND]   = "Sound",
>          [DEVICE_CATEGORY_MISC]    = "Misc",
>          [DEVICE_CATEGORY_CPU]     = "CPU",
> +        [DEVICE_CATEGORY_SENSOR]  = "Sensor",
>          [DEVICE_CATEGORY_MAX]     = "Uncategorized",
>      };
>      GSList *list, *elt;
> -- 
> 2.31.1
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw: Add a 'Sensor devices' qdev category
  2021-09-27 11:33 ` Corey Minyard
@ 2021-09-27 12:47   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-27 12:47 UTC (permalink / raw)
  To: minyard, Thomas Huth
  Cc: Peter Maydell, Daniel P. Berrangé,
	Eduardo Habkost, Corey Minyard, Titus Rwantare, qemu-devel,
	Hao Wu, qemu-arm, Joel Stanley, Paolo Bonzini, Bin Meng,
	John Wang, Cédric Le Goater

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);
>>  }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw: Add a 'Sensor devices' qdev category
  2021-09-27 10:03 ` Cédric Le Goater
@ 2021-09-27 15:49   ` Hao Wu
  0 siblings, 0 replies; 5+ messages in thread
From: Hao Wu @ 2021-09-27 15:49 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Philippe Mathieu-Daudé,
	QEMU Developers, Corey Minyard, Daniel P. Berrangé,
	Joel Stanley, Peter Maydell, Bin Meng, qemu-arm, Titus Rwantare,
	John Wang, Eduardo Habkost, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 6589 bytes --]

On Mon, Sep 27, 2021 at 3:03 AM Cédric Le Goater <clg@kaod.org> wrote:

> On 9/27/21 00:15, 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>
>
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
>
Reviewed-by: Hao Wu <wuhaotsh@google.com>

>
>
> > ---
> >   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/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 34c8a7506a1..f6241212247 100644
> > --- a/include/hw/qdev-core.h
> > +++ b/include/hw/qdev-core.h
> > @@ -26,6 +26,7 @@ typedef enum DeviceCategory {
> >       DEVICE_CATEGORY_SOUND,
> >       DEVICE_CATEGORY_MISC,
> >       DEVICE_CATEGORY_CPU,
> > +    DEVICE_CATEGORY_SENSOR,
> >       DEVICE_CATEGORY_MAX
> >   } DeviceCategory;
> >
> > 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);
> >   }
> >
> >   static const TypeInfo aer915_info = {
> > diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
> > index 7310c769be2..2942ac75f90 100644
> > --- a/hw/sensor/adm1272.c
> > +++ b/hw/sensor/adm1272.c
> > @@ -518,6 +518,7 @@ static void adm1272_class_init(ObjectClass *klass,
> void *data)
> >       DeviceClass *dc = DEVICE_CLASS(klass);
> >       PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
> >
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >       dc->desc = "Analog Devices ADM1272 Hot Swap controller";
> >       dc->vmsd = &vmstate_adm1272;
> >       k->write_data = adm1272_write_data;
> > diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c
> > index d60a18ac41b..1e24a499b38 100644
> > --- a/hw/sensor/dps310.c
> > +++ b/hw/sensor/dps310.c
> > @@ -208,6 +208,7 @@ static void dps310_class_init(ObjectClass *klass,
> void *data)
> >       k->send = dps310_tx;
> >       dc->reset = dps310_reset;
> >       dc->vmsd = &vmstate_dps310;
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >   }
> >
> >   static const TypeInfo dps310_info = {
> > diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c
> > index 7ce8f4e9794..4202d8f185a 100644
> > --- a/hw/sensor/emc141x.c
> > +++ b/hw/sensor/emc141x.c
> > @@ -270,6 +270,7 @@ static void emc141x_class_init(ObjectClass *klass,
> void *data)
> >       DeviceClass *dc = DEVICE_CLASS(klass);
> >       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
> >
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >       dc->reset = emc141x_reset;
> >       k->event = emc141x_event;
> >       k->recv = emc141x_rx;
> > diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
> > index a91d8bd487c..8300bf4ff43 100644
> > --- a/hw/sensor/max34451.c
> > +++ b/hw/sensor/max34451.c
> > @@ -751,6 +751,8 @@ static void max34451_class_init(ObjectClass *klass,
> void *data)
> >       ResettableClass *rc = RESETTABLE_CLASS(klass);
> >       DeviceClass *dc = DEVICE_CLASS(klass);
> >       PMBusDeviceClass *k = PMBUS_DEVICE_CLASS(klass);
> > +
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >       dc->desc = "Maxim MAX34451 16-Channel V/I monitor";
> >       dc->vmsd = &vmstate_max34451;
> >       k->write_data = max34451_write_data;
> > diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
> > index 20564494899..43d79b9eeec 100644
> > --- a/hw/sensor/tmp105.c
> > +++ b/hw/sensor/tmp105.c
> > @@ -305,6 +305,7 @@ static void tmp105_class_init(ObjectClass *klass,
> void *data)
> >       DeviceClass *dc = DEVICE_CLASS(klass);
> >       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
> >
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >       dc->realize = tmp105_realize;
> >       k->event = tmp105_event;
> >       k->recv = tmp105_rx;
> > diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c
> > index a3db57dcb5a..c328978af9c 100644
> > --- a/hw/sensor/tmp421.c
> > +++ b/hw/sensor/tmp421.c
> > @@ -343,6 +343,7 @@ static void tmp421_class_init(ObjectClass *klass,
> void *data)
> >       I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
> >       TMP421Class *sc = TMP421_CLASS(klass);
> >
> > +    set_bit(DEVICE_CATEGORY_SENSOR, dc->categories);
> >       dc->realize = tmp421_realize;
> >       k->event = tmp421_event;
> >       k->recv = tmp421_rx;
> > diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> > index 0705f008466..db56f328228 100644
> > --- a/softmmu/qdev-monitor.c
> > +++ b/softmmu/qdev-monitor.c
> > @@ -162,6 +162,7 @@ static void qdev_print_devinfos(bool show_no_user)
> >           [DEVICE_CATEGORY_SOUND]   = "Sound",
> >           [DEVICE_CATEGORY_MISC]    = "Misc",
> >           [DEVICE_CATEGORY_CPU]     = "CPU",
> > +        [DEVICE_CATEGORY_SENSOR]  = "Sensor",
> >           [DEVICE_CATEGORY_MAX]     = "Uncategorized",
> >       };
> >       GSList *list, *elt;
> >
>
>

[-- Attachment #2: Type: text/html, Size: 8612 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-27 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.