[PATCH qemu] arm: aspeed: Add palmetto and evb EEPROM I2C devices

Cédric Le Goater clg at kaod.org
Fri Sep 15 17:25:37 AEST 2017


On 09/15/2017 08:18 AM, Joel Stanley wrote:
> Signed-off-by: Joel Stanley <joel at jms.id.au>

We could fill the eeprom_buf with some valid data if needed.

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

> ---
>  hw/arm/aspeed.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 9ef5fb3b6ddc..2f596959649a 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -253,6 +253,7 @@ static void aspeed_board_init(MachineState *machine,
>  
>  static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
>  {
> +    uint8_t *eeprom_buf = g_malloc0(256 * 1024);
>      AspeedSoCState *soc = &bmc->soc;
>      DeviceState *dev;
>  
> @@ -260,6 +261,13 @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
>       * enough to provide basic RTC features. Alarms will be missing */
>      i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
>  
> +    /* 256KB EEPROM */
> +    dev = qdev_create((BusState *) aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0),
> +                      "smbus-eeprom");
> +    qdev_prop_set_uint8(dev, "address", 0x50);
> +    qdev_prop_set_ptr(dev, "data", eeprom_buf);
> +    qdev_init_nofail(dev);
> +
>      /* add a TMP423 temperature sensor */
>      dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
>                             "tmp423", 0x4c);
> @@ -295,7 +303,15 @@ static const TypeInfo palmetto_bmc_type = {
>  
>  static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
>  {
> +    uint8_t *eeprom_buf = g_malloc0(8 * 1024);
>      AspeedSoCState *soc = &bmc->soc;
> +    DeviceState *dev;
> +
> +    dev = qdev_create((BusState *) aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3),
> +                      "smbus-eeprom");
> +    qdev_prop_set_uint8(dev, "address", 0x50);
> +    qdev_prop_set_ptr(dev, "data", eeprom_buf);
> +    qdev_init_nofail(dev);
>  
>      /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
>      i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
> 



More information about the openbmc mailing list