Message ID | 20210126193237.1534208-5-wuhaotsh@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/i2c: Add NPCM7XX SMBus Device | expand |
On Tue, Jan 26, 2021 at 11:32:35AM -0800, wuhaotsh--- via wrote: > Add an I2C device tree for Quanta GSJ. We only included devices with > existing QEMU implementation, including AT24 EEPROM and temperature > sensors. > > Reviewed-by: Doug Evans<dje@google.com> > Reviewed-by: Tyrong Ting<kfting@nuvoton.com> > Signed-off-by: Hao Wu <wuhaotsh@google.com> > --- > hw/arm/npcm7xx_boards.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c > index 2d82f48848..1418629e06 100644 > --- a/hw/arm/npcm7xx_boards.c > +++ b/hw/arm/npcm7xx_boards.c > @@ -19,6 +19,7 @@ > #include "exec/address-spaces.h" > #include "hw/arm/npcm7xx.h" > #include "hw/core/cpu.h" > +#include "hw/i2c/smbus_eeprom.h" > #include "hw/loader.h" > #include "hw/qdev-properties.h" > #include "qapi/error.h" > @@ -112,6 +113,21 @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc) > i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); > } > > +static void quanta_gsj_i2c_init(NPCM7xxState *soc) > +{ > + uint8_t *eeprom_buf0 = g_malloc0(32 * 1024); > + uint8_t *eeprom_buf1 = g_malloc0(32 * 1024); This is kind of pointless because the smbus eeprom is 256 bytes. It would be nice to modify the smbus eeprom code to take different sizes, if you want to submit a patch. -corey > + > + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x48); > + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x48); > + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x48); > + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x48); > + smbus_eeprom_init_one(npcm7xx_i2c_get_bus(soc, 9), 0x55, eeprom_buf0); > + smbus_eeprom_init_one(npcm7xx_i2c_get_bus(soc, 10), 0x55, eeprom_buf1); > + > + /* TODO: Add addtional i2c devices. */ > +} > + > static void npcm750_evb_init(MachineState *machine) > { > NPCM7xxState *soc; > @@ -137,6 +153,7 @@ static void quanta_gsj_init(MachineState *machine) > npcm7xx_load_bootrom(machine, soc); > npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", > drive_get(IF_MTD, 0, 0)); > + quanta_gsj_i2c_init(soc); > npcm7xx_load_kernel(machine, soc); > } > > -- > 2.30.0.365.g02bc693789-goog > >
On Tue, 26 Jan 2021 at 19:32, Hao Wu <wuhaotsh@google.com> wrote: > > Add an I2C device tree for Quanta GSJ. We only included devices with > existing QEMU implementation, including AT24 EEPROM and temperature > sensors. > > Reviewed-by: Doug Evans<dje@google.com> > Reviewed-by: Tyrong Ting<kfting@nuvoton.com> > Signed-off-by: Hao Wu <wuhaotsh@google.com> Same remarks as for patch 3 apply here too. thanks -- PMM
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 2d82f48848..1418629e06 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -19,6 +19,7 @@ #include "exec/address-spaces.h" #include "hw/arm/npcm7xx.h" #include "hw/core/cpu.h" +#include "hw/i2c/smbus_eeprom.h" #include "hw/loader.h" #include "hw/qdev-properties.h" #include "qapi/error.h" @@ -112,6 +113,21 @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc) i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); } +static void quanta_gsj_i2c_init(NPCM7xxState *soc) +{ + uint8_t *eeprom_buf0 = g_malloc0(32 * 1024); + uint8_t *eeprom_buf1 = g_malloc0(32 * 1024); + + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x48); + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x48); + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x48); + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x48); + smbus_eeprom_init_one(npcm7xx_i2c_get_bus(soc, 9), 0x55, eeprom_buf0); + smbus_eeprom_init_one(npcm7xx_i2c_get_bus(soc, 10), 0x55, eeprom_buf1); + + /* TODO: Add addtional i2c devices. */ +} + static void npcm750_evb_init(MachineState *machine) { NPCM7xxState *soc; @@ -137,6 +153,7 @@ static void quanta_gsj_init(MachineState *machine) npcm7xx_load_bootrom(machine, soc); npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", drive_get(IF_MTD, 0, 0)); + quanta_gsj_i2c_init(soc); npcm7xx_load_kernel(machine, soc); }