Emmanuel Blot via qemu development <[email protected]> 於
2026年10月15日週四 下午11:12寫道:
>
> Include the new tmp421.h and refer to the sensor variants through
> TYPE_TMP421/TYPE_TMP422/TYPE_TMP423 instead of open-coded string
> literals and per-board local defines.
>
> Signed-off-by: Emmanuel Blot <[email protected]>
> ---
>  hw/arm/aspeed_ast2400_palmetto.c          |  3 ++-
>  hw/arm/aspeed_ast2400_supermicrox11.c     |  3 ++-
>  hw/arm/aspeed_ast2500_supermicro-x11spi.c |  3 ++-
>  hw/arm/aspeed_ast2500_tiogapass.c         | 10 +++++++---
>  hw/arm/aspeed_ast2500_witherspoon.c       |  7 +++++--
>  hw/arm/aspeed_ast2500_yosemitev2.c        | 10 +++++++---
>  hw/arm/aspeed_ast2600_bletchley.c         |  3 +--
>  hw/arm/aspeed_ast2600_catalina.c          |  3 +--
>  hw/arm/aspeed_ast2600_fby35.c             |  2 +-
>  hw/arm/aspeed_ast2600_fuji.c              |  3 +--
>  hw/arm/aspeed_ast2600_rainier.c           | 13 +++++++++----
>  11 files changed, 38 insertions(+), 22 deletions(-)
>
> diff --git a/hw/arm/aspeed_ast2400_palmetto.c 
> b/hw/arm/aspeed_ast2400_palmetto.c
> index 185185f0bb..7b165394c2 100644
> --- a/hw/arm/aspeed_ast2400_palmetto.c
> +++ b/hw/arm/aspeed_ast2400_palmetto.c
> @@ -12,6 +12,7 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/rtc/ds1338.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* Palmetto hardware value: 0x120CE416 */
>  #define PALMETTO_BMC_HW_STRAP1 (                                        \
> @@ -45,7 +46,7 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
>
>      /* add a TMP423 temperature sensor */
>      dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
> -                                         "tmp423", 0x4c));
> +                                         TYPE_TMP423, 0x4c));
>      object_property_set_int(OBJECT(dev), "temperature0", 31000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature1", 28000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature2", 20000, 
> &error_abort);
> diff --git a/hw/arm/aspeed_ast2400_supermicrox11.c 
> b/hw/arm/aspeed_ast2400_supermicrox11.c
> index 051e072c5a..fd2fda9290 100644
> --- a/hw/arm/aspeed_ast2400_supermicrox11.c
> +++ b/hw/arm/aspeed_ast2400_supermicrox11.c
> @@ -12,6 +12,7 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/rtc/ds1338.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* TODO: Find the actual hardware value */
>  #define SUPERMICROX11_BMC_HW_STRAP1 (                                   \
> @@ -45,7 +46,7 @@ static void supermicrox11_bmc_i2c_init(AspeedMachineState 
> *bmc)
>
>      /* add a TMP423 temperature sensor */
>      dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
> -                                         "tmp423", 0x4c));
> +                                         TYPE_TMP423, 0x4c));
>      object_property_set_int(OBJECT(dev), "temperature0", 31000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature1", 28000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature2", 20000, 
> &error_abort);
> diff --git a/hw/arm/aspeed_ast2500_supermicro-x11spi.c 
> b/hw/arm/aspeed_ast2500_supermicro-x11spi.c
> index dc0248422d..1ea61348f6 100644
> --- a/hw/arm/aspeed_ast2500_supermicro-x11spi.c
> +++ b/hw/arm/aspeed_ast2500_supermicro-x11spi.c
> @@ -12,6 +12,7 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/rtc/ds1338.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* TODO: Find the actual hardware value */
>  #define SUPERMICRO_X11SPI_BMC_HW_STRAP1 (                               \
> @@ -41,7 +42,7 @@ static void 
> supermicro_x11spi_bmc_i2c_init(AspeedMachineState *bmc)
>
>      /* add a TMP423 temperature sensor */
>      dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
> -                                         "tmp423", 0x4c));
> +                                         TYPE_TMP423, 0x4c));
>      object_property_set_int(OBJECT(dev), "temperature0", 31000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature1", 28000, 
> &error_abort);
>      object_property_set_int(OBJECT(dev), "temperature2", 20000, 
> &error_abort);
> diff --git a/hw/arm/aspeed_ast2500_tiogapass.c 
> b/hw/arm/aspeed_ast2500_tiogapass.c
> index 6cb567526c..5433198abd 100644
> --- a/hw/arm/aspeed_ast2500_tiogapass.c
> +++ b/hw/arm/aspeed_ast2500_tiogapass.c
> @@ -11,6 +11,7 @@
>  #include "hw/arm/aspeed.h"
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/nvram/eeprom_at24c.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* value: 0xF100C2E6 */
>  #define TIOGAPASS_BMC_HW_STRAP1 ((                                        \
> @@ -54,9 +55,12 @@ static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)
>      at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
>                            tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);
>      /* TMP421 */
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "tmp421", 
> 0x1f);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp421", 
> 0x4f);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp421", 
> 0x4e);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8),
> +                            TYPE_TMP421, 0x1f);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6),
> +                            TYPE_TMP421, 0x4f);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6),
> +                            TYPE_TMP421, 0x4e);
>  }
>
>  static void aspeed_machine_tiogapass_class_init(ObjectClass *oc,
> diff --git a/hw/arm/aspeed_ast2500_witherspoon.c 
> b/hw/arm/aspeed_ast2500_witherspoon.c
> index c69065846c..385deb2154 100644
> --- a/hw/arm/aspeed_ast2500_witherspoon.c
> +++ b/hw/arm/aspeed_ast2500_witherspoon.c
> @@ -12,6 +12,7 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/misc/led.h"
>  #include "hw/sensor/tmp105.h"
> +#include "hw/sensor/tmp421.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/gpio/pca9552.h"
>  #include "hw/rtc/ds1338.h"
> @@ -60,8 +61,10 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState 
> *bmc)
>      }
>      i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "dps310", 
> 0x76);
>      i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "max31785", 
> 0x52);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 
> 0x4c);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 
> 0x4c);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4),
> +                            TYPE_TMP423, 0x4c);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5),
> +                            TYPE_TMP423, 0x4c);
>
>      /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
>      i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105,
> diff --git a/hw/arm/aspeed_ast2500_yosemitev2.c 
> b/hw/arm/aspeed_ast2500_yosemitev2.c
> index 3ba1ed5f6f..3dd0d37175 100644
> --- a/hw/arm/aspeed_ast2500_yosemitev2.c
> +++ b/hw/arm/aspeed_ast2500_yosemitev2.c
> @@ -11,6 +11,7 @@
>  #include "hw/arm/aspeed.h"
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/nvram/eeprom_at24c.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* value: 0xF100C2E6 */
>  #define YOSEMITEV2_BMC_HW_STRAP1 ((                                        \
> @@ -54,9 +55,12 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState 
> *bmc)
>      at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
>                            yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);
>      /* TMP421 */
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "tmp421", 
> 0x1f);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp421", 
> 0x4e);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp421", 
> 0x4f);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11),
> +                            TYPE_TMP421, 0x1f);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9),
> +                            TYPE_TMP421, 0x4e);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9),
> +                            TYPE_TMP421, 0x4f);
>
>  }
>
> diff --git a/hw/arm/aspeed_ast2600_bletchley.c 
> b/hw/arm/aspeed_ast2600_bletchley.c
> index 0e746055a2..536e910229 100644
> --- a/hw/arm/aspeed_ast2600_bletchley.c
> +++ b/hw/arm/aspeed_ast2600_bletchley.c
> @@ -13,8 +13,7 @@
>  #include "hw/gpio/pca9552.h"
>  #include "hw/nvram/eeprom_at24c.h"
>  #include "hw/rtc/ds1338.h"
> -
> -#define TYPE_TMP421 "tmp421"
> +#include "hw/sensor/tmp421.h"
>  /* Bletchley hardware value */
>  #define BLETCHLEY_BMC_HW_STRAP1 0x00002000
>  #define BLETCHLEY_BMC_HW_STRAP2 0x00000801
> diff --git a/hw/arm/aspeed_ast2600_catalina.c 
> b/hw/arm/aspeed_ast2600_catalina.c
> index b15d932086..13dca7a846 100644
> --- a/hw/arm/aspeed_ast2600_catalina.c
> +++ b/hw/arm/aspeed_ast2600_catalina.c
> @@ -16,14 +16,13 @@
>  #include "hw/nvram/eeprom_at24c.h"
>  #include "hw/rtc/ds1338.h"
>  #include "hw/sensor/tmp105.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* Catalina hardware value */
>  #define CATALINA_BMC_HW_STRAP1 0x00002002
>  #define CATALINA_BMC_HW_STRAP2 0x00000800
>  #define CATALINA_BMC_RAM_SIZE (2 * GiB)
>
> -#define TYPE_TMP421 "tmp421"
> -
>  /*
>   * "BMC Storage Module" FRU data.  Generated with frugen.
>   *
> diff --git a/hw/arm/aspeed_ast2600_fby35.c b/hw/arm/aspeed_ast2600_fby35.c
> index 28c9c143d8..25f39d5135 100644
> --- a/hw/arm/aspeed_ast2600_fby35.c
> +++ b/hw/arm/aspeed_ast2600_fby35.c
> @@ -12,10 +12,10 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/nvram/eeprom_at24c.h"
>  #include "hw/sensor/tmp105.h"
> +#include "hw/sensor/tmp421.h"
>  #include "system/reset.h"
>
>  #define TYPE_LM75 TYPE_TMP105
> -#define TYPE_TMP421 "tmp421"
>  #define FBY35_BMC_RAM_SIZE (2 * GiB)
>
>  static const uint8_t fby35_nic_fruid[] = {
> diff --git a/hw/arm/aspeed_ast2600_fuji.c b/hw/arm/aspeed_ast2600_fuji.c
> index 08d809b2fd..526494ecfe 100644
> --- a/hw/arm/aspeed_ast2600_fuji.c
> +++ b/hw/arm/aspeed_ast2600_fuji.c
> @@ -12,10 +12,9 @@
>  #include "hw/arm/aspeed_soc.h"
>  #include "hw/i2c/i2c_mux_pca954x.h"
>  #include "hw/sensor/tmp105.h"
> +#include "hw/sensor/tmp421.h"
>  #include "hw/nvram/eeprom_at24c.h"
>
> -#define TYPE_TMP422 "tmp422"
> -
>  /* Fuji hardware value */
>  #define FUJI_BMC_HW_STRAP1    0x00000000
>  #define FUJI_BMC_HW_STRAP2    0x00000000
> diff --git a/hw/arm/aspeed_ast2600_rainier.c b/hw/arm/aspeed_ast2600_rainier.c
> index 43a8f01a9e..bdbc78aee7 100644
> --- a/hw/arm/aspeed_ast2600_rainier.c
> +++ b/hw/arm/aspeed_ast2600_rainier.c
> @@ -13,6 +13,7 @@
>  #include "hw/nvram/eeprom_at24c.h"
>  #include "hw/i2c/i2c_mux_pca954x.h"
>  #include "hw/sensor/tmp105.h"
> +#include "hw/sensor/tmp421.h"
>
>  /* Rainier hardware value: (QEMU prototype) */
>  #define RAINIER_BMC_HW_STRAP1 (0x00422016 | 
> SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC)
> @@ -137,12 +138,16 @@ static void rainier_bmc_i2c_init(AspeedMachineState 
> *bmc)
>      /* Bus 8: ucd90320@b */
>      /* Bus 8: ucd90320@c */
>
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 
> 0x4c);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 
> 0x4d);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9),
> +                            TYPE_TMP423, 0x4c);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9),
> +                            TYPE_TMP423, 0x4d);
>      at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
>
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 
> 0x4c);
> -    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 
> 0x4d);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10),
> +                            TYPE_TMP423, 0x4c);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10),
> +                            TYPE_TMP423, 0x4d);
>      at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
>
>      i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105,
>
> --
> 2.53.0-Meta
>
>

Reviewed-by: Jamin Lin <[email protected]>

Reply via email to