Message ID | 20240416184722.28334-3-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/i2c: Convert to spec v7 (inclusive) terminology | expand |
Hello, On 4/16/24 20:47, Philippe Mathieu-Daudé wrote: > We are going to modify these lines, fix their style > in order to avoid checkpatch.pl warnings: > > WARNING: line over 80 characters > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > include/hw/i2c/i2c.h | 11 ++- > include/hw/nvram/eeprom_at24c.h | 6 +- > hw/arm/aspeed.c | 140 +++++++++++++++++++------------- > hw/nvram/eeprom_at24c.c | 6 +- > 4 files changed, 98 insertions(+), 65 deletions(-) > > diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h > index c18a69e4b6..a1b3f4d179 100644 > --- a/include/hw/i2c/i2c.h > +++ b/include/hw/i2c/i2c.h > @@ -31,7 +31,10 @@ struct I2CSlaveClass { > /* Master to slave. Returns non-zero for a NAK, 0 for success. */ > int (*send)(I2CSlave *s, uint8_t data); > > - /* Master to slave (asynchronous). Receiving slave must call i2c_ack(). */ > + /* > + * Master to slave (asynchronous). > + * Receiving slave must call i2c_ack(). > + */ > void (*send_async)(I2CSlave *s, uint8_t data); > > /* > @@ -83,7 +86,8 @@ struct I2CPendingMaster { > }; > > typedef QLIST_HEAD(I2CNodeList, I2CNode) I2CNodeList; > -typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) I2CPendingMasters; > +typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) > + I2CPendingMasters; > > struct I2CBus { > BusState qbus; > @@ -176,7 +180,8 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr); > * Create the device state structure, initialize it, put it on the > * specified @bus, and drop the reference to it (the device is realized). > */ > -I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr); > +I2CSlave *i2c_slave_create_simple(I2CBus *bus, > + const char *name, uint8_t addr); > > /** > * Realize and drop a reference an I2C slave device > diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h > index acb9857b2a..9d29f0a69a 100644 > --- a/include/hw/nvram/eeprom_at24c.h > +++ b/include/hw/nvram/eeprom_at24c.h > @@ -33,7 +33,9 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size); > * @bus, and drop the reference to it (the device is realized). Copies the data > * from @init_rom to the beginning of the EEPROM memory buffer. > */ > -I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, > - const uint8_t *init_rom, uint32_t init_rom_size); > +I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, > + uint8_t address, uint32_t rom_size, > + const uint8_t *init_rom, > + uint32_t init_rom_size); > > #endif > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c > index 93ca87fda2..8279ad748a 100644 > --- a/hw/arm/aspeed.c > +++ b/hw/arm/aspeed.c > @@ -649,18 +649,23 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) > qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id, > qdev_get_gpio_in(DEVICE(led), 0)); > } > - 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, 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); > > /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, > - 0x4a); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), > + TYPE_TMP105, 0x4a); > > /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is > * good enough */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), > + "ds1338", 0x32); If the definitions were on a single line, they would be more readable IMHO. So I would do the opposit change ... An alternate solution could be to define an array of devices at the machine class level, something like struct i2c_device [ const char *type; uint8_t bus; uint8_t addr; } devices[] = { ... }; Thanks, C. > smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, > eeprom_buf); > @@ -717,19 +722,20 @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc) > at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x50, 32768); > > /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105, > - 0x49); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), > + TYPE_TMP105, 0x49); > > i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), > "pca9546", 0x70); > /* It expects a TMP112 but a TMP105 is compatible */ > - i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), TYPE_TMP105, > - 0x4a); > + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), > + TYPE_TMP105, 0x4a); > > /* It expects a ds3232 but a ds1338 is good enough */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "ds1338", 0x68); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), > + "ds1338", 0x68); > > /* It expects a pca9555 but a pca9552 is compatible */ > create_pca9552(soc, 8, 0x30); > @@ -745,12 +751,12 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) > create_pca9552(soc, 3, 0x61); > > /* The rainier expects a TMP275 but a TMP105 is compatible */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, > - 0x49); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, > - 0x4a); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), > + TYPE_TMP105, 0x49); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), > + TYPE_TMP105, 0x4a); > i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), > "pca9546", 0x70); > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); > @@ -758,10 +764,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB); > create_pca9552(soc, 4, 0x60); > > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, > - 0x49); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), > + TYPE_TMP105, 0x49); > create_pca9552(soc, 5, 0x60); > create_pca9552(soc, 5, 0x61); > i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), > @@ -769,12 +775,12 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); > > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, > - 0x4a); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, > - 0x4b); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), > + TYPE_TMP105, 0x4a); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), > + TYPE_TMP105, 0x4b); > i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), > "pca9546", 0x70); > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); > @@ -788,18 +794,20 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) > create_pca9552(soc, 7, 0x33); > create_pca9552(soc, 7, 0x60); > create_pca9552(soc, 7, 0x61); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "dps310", 0x76); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), > + "dps310", 0x76); > /* Bus 7: TODO si7021-a20@20 */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "max31785", 0x52); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), > + "max31785", 0x52); > at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB); > at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB); > > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, > - 0x4a); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), > + TYPE_TMP105, 0x4a); > at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, > 64 * KiB, rainier_bb_fruid, rainier_bb_fruid_len); > at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, > @@ -810,18 +818,22 @@ 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), > + "tmp423", 0x4c); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), > + "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), > + "tmp423", 0x4c); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), > + "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, > - 0x48); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, > - 0x49); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), > + TYPE_TMP105, 0x48); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), > + TYPE_TMP105, 0x49); > i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), > "pca9546", 0x70); > at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); > @@ -1012,7 +1024,8 @@ static void qcom_dc_scm_bmc_i2c_init(AspeedMachineState *bmc) > { > AspeedSoCState *soc = bmc->soc; > > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), "tmp105", 0x4d); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), > + "tmp105", 0x4d); > } > > static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc) > @@ -1028,23 +1041,34 @@ static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc) > /* I2C7 CPUVR MUX */ > cpuvr_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), > "pca9546", 0x70); > - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 0), "pca9548", 0x72); > - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 1), "pca9548", 0x72); > - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 2), "pca9548", 0x72); > - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 3), "pca9548", 0x72); > + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 0), > + "pca9548", 0x72); > + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 1), > + "pca9548", 0x72); > + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 2), > + "pca9548", 0x72); > + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 3), > + "pca9548", 0x72); > > /* I2C8 Thermal Diodes*/ > therm_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), > "pca9548", 0x70); > - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 0), TYPE_LM75, 0x4C); > - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 1), TYPE_LM75, 0x4C); > - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 2), TYPE_LM75, 0x48); > - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 3), TYPE_LM75, 0x48); > - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 4), TYPE_LM75, 0x48); > + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 0), > + TYPE_LM75, 0x4C); > + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 1), > + TYPE_LM75, 0x4C); > + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 2), > + TYPE_LM75, 0x48); > + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 3), > + TYPE_LM75, 0x48); > + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 4), > + TYPE_LM75, 0x48); > > /* I2C9 Fan Controller (MAX31785) */ > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "max31785", 0x52); > - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "max31785", 0x54); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), > + "max31785", 0x52); > + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), > + "max31785", 0x54); > } > > static bool aspeed_get_mmio_exec(Object *obj, Error **errp) > diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c > index 3272068663..4db83d0dd6 100644 > --- a/hw/nvram/eeprom_at24c.c > +++ b/hw/nvram/eeprom_at24c.c > @@ -148,8 +148,10 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size) > return at24c_eeprom_init_rom(bus, address, rom_size, NULL, 0); > } > > -I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, > - const uint8_t *init_rom, uint32_t init_rom_size) > +I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, > + uint8_t address, uint32_t rom_size, > + const uint8_t *init_rom, > + uint32_t init_rom_size) > { > EEPROMState *s; >
On 17/4/24 08:24, Cédric Le Goater wrote: > Hello, > > On 4/16/24 20:47, Philippe Mathieu-Daudé wrote: >> We are going to modify these lines, fix their style >> in order to avoid checkpatch.pl warnings: >> >> WARNING: line over 80 characters >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> --- >> include/hw/i2c/i2c.h | 11 ++- >> include/hw/nvram/eeprom_at24c.h | 6 +- >> hw/arm/aspeed.c | 140 +++++++++++++++++++------------- >> hw/nvram/eeprom_at24c.c | 6 +- >> 4 files changed, 98 insertions(+), 65 deletions(-) >> - 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, 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); >> /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ >> - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), >> TYPE_TMP105, >> - 0x4a); >> + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), >> + TYPE_TMP105, 0x4a); >> /* The witherspoon board expects Epson RX8900 I2C RTC but a >> ds1338 is >> * good enough */ >> - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), >> "ds1338", 0x32); >> + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), >> + "ds1338", 0x32); > > If the definitions were on a single line, they would be more > readable IMHO. So I would do the opposit change ... > > An alternate solution could be to define an array of devices > at the machine class level, something like > struct i2c_device [ > const char *type; > uint8_t bus; > uint8_t addr; > } devices[] = { ... }; I agree this would be better, but this should be done separately of this series. For now I propose not modifying hw/arm/aspeed.c in this patch, and ignoring the checkpatch errors in the next patch. What do you think?
On 4/17/24 16:20, Philippe Mathieu-Daudé wrote: > On 17/4/24 08:24, Cédric Le Goater wrote: >> Hello, >> >> On 4/16/24 20:47, Philippe Mathieu-Daudé wrote: >>> We are going to modify these lines, fix their style >>> in order to avoid checkpatch.pl warnings: >>> >>> WARNING: line over 80 characters >>> >>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> >>> --- >>> include/hw/i2c/i2c.h | 11 ++- >>> include/hw/nvram/eeprom_at24c.h | 6 +- >>> hw/arm/aspeed.c | 140 +++++++++++++++++++------------- >>> hw/nvram/eeprom_at24c.c | 6 +- >>> 4 files changed, 98 insertions(+), 65 deletions(-) > > >>> - 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, 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); >>> /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ >>> - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, >>> - 0x4a); >>> + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), >>> + TYPE_TMP105, 0x4a); >>> /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is >>> * good enough */ >>> - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); >>> + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), >>> + "ds1338", 0x32); >> >> If the definitions were on a single line, they would be more >> readable IMHO. So I would do the opposit change ... >> >> An alternate solution could be to define an array of devices >> at the machine class level, something like >> struct i2c_device [ >> const char *type; >> uint8_t bus; >> uint8_t addr; >> } devices[] = { ... }; > > I agree this would be better, but this should be done separately > of this series. For now I propose not modifying hw/arm/aspeed.c > in this patch, and ignoring the checkpatch errors in the next > patch. What do you think? sure, np. Thanks, C.
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index c18a69e4b6..a1b3f4d179 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -31,7 +31,10 @@ struct I2CSlaveClass { /* Master to slave. Returns non-zero for a NAK, 0 for success. */ int (*send)(I2CSlave *s, uint8_t data); - /* Master to slave (asynchronous). Receiving slave must call i2c_ack(). */ + /* + * Master to slave (asynchronous). + * Receiving slave must call i2c_ack(). + */ void (*send_async)(I2CSlave *s, uint8_t data); /* @@ -83,7 +86,8 @@ struct I2CPendingMaster { }; typedef QLIST_HEAD(I2CNodeList, I2CNode) I2CNodeList; -typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) I2CPendingMasters; +typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) + I2CPendingMasters; struct I2CBus { BusState qbus; @@ -176,7 +180,8 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr); * Create the device state structure, initialize it, put it on the * specified @bus, and drop the reference to it (the device is realized). */ -I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr); +I2CSlave *i2c_slave_create_simple(I2CBus *bus, + const char *name, uint8_t addr); /** * Realize and drop a reference an I2C slave device diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h index acb9857b2a..9d29f0a69a 100644 --- a/include/hw/nvram/eeprom_at24c.h +++ b/include/hw/nvram/eeprom_at24c.h @@ -33,7 +33,9 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size); * @bus, and drop the reference to it (the device is realized). Copies the data * from @init_rom to the beginning of the EEPROM memory buffer. */ -I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, - const uint8_t *init_rom, uint32_t init_rom_size); +I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, + uint8_t address, uint32_t rom_size, + const uint8_t *init_rom, + uint32_t init_rom_size); #endif diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 93ca87fda2..8279ad748a 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -649,18 +649,23 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id, qdev_get_gpio_in(DEVICE(led), 0)); } - 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, 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); /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, - 0x4a); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + TYPE_TMP105, 0x4a); /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), + "ds1338", 0x32); smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, eeprom_buf); @@ -717,19 +722,20 @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc) at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x50, 32768); /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105, - 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), + TYPE_TMP105, 0x49); i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "pca9546", 0x70); /* It expects a TMP112 but a TMP105 is compatible */ - i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), TYPE_TMP105, - 0x4a); + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), + TYPE_TMP105, 0x4a); /* It expects a ds3232 but a ds1338 is good enough */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "ds1338", 0x68); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), + "ds1338", 0x68); /* It expects a pca9555 but a pca9552 is compatible */ create_pca9552(soc, 8, 0x30); @@ -745,12 +751,12 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) create_pca9552(soc, 3, 0x61); /* The rainier expects a TMP275 but a TMP105 is compatible */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, - 0x49); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, - 0x4a); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), + TYPE_TMP105, 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), + TYPE_TMP105, 0x4a); i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9546", 0x70); at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); @@ -758,10 +764,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB); create_pca9552(soc, 4, 0x60); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, - 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), + TYPE_TMP105, 0x49); create_pca9552(soc, 5, 0x60); create_pca9552(soc, 5, 0x61); i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), @@ -769,12 +775,12 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, - 0x4a); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, - 0x4b); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), + TYPE_TMP105, 0x4a); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), + TYPE_TMP105, 0x4b); i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "pca9546", 0x70); at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); @@ -788,18 +794,20 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) create_pca9552(soc, 7, 0x33); create_pca9552(soc, 7, 0x60); create_pca9552(soc, 7, 0x61); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "dps310", 0x76); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), + "dps310", 0x76); /* Bus 7: TODO si7021-a20@20 */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "max31785", 0x52); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), + "max31785", 0x52); at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB); at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, - 0x4a); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), + TYPE_TMP105, 0x4a); at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB, rainier_bb_fruid, rainier_bb_fruid_len); at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, @@ -810,18 +818,22 @@ 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), + "tmp423", 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + "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), + "tmp423", 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), + "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, - 0x48); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, - 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), + TYPE_TMP105, 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), + TYPE_TMP105, 0x49); i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "pca9546", 0x70); at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); @@ -1012,7 +1024,8 @@ static void qcom_dc_scm_bmc_i2c_init(AspeedMachineState *bmc) { AspeedSoCState *soc = bmc->soc; - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), "tmp105", 0x4d); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), + "tmp105", 0x4d); } static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc) @@ -1028,23 +1041,34 @@ static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc) /* I2C7 CPUVR MUX */ cpuvr_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9546", 0x70); - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 0), "pca9548", 0x72); - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 1), "pca9548", 0x72); - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 2), "pca9548", 0x72); - i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 3), "pca9548", 0x72); + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 0), + "pca9548", 0x72); + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 1), + "pca9548", 0x72); + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 2), + "pca9548", 0x72); + i2c_slave_create_simple(pca954x_i2c_get_bus(cpuvr_mux, 3), + "pca9548", 0x72); /* I2C8 Thermal Diodes*/ therm_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9548", 0x70); - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 0), TYPE_LM75, 0x4C); - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 1), TYPE_LM75, 0x4C); - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 2), TYPE_LM75, 0x48); - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 3), TYPE_LM75, 0x48); - i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 4), TYPE_LM75, 0x48); + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 0), + TYPE_LM75, 0x4C); + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 1), + TYPE_LM75, 0x4C); + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 2), + TYPE_LM75, 0x48); + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 3), + TYPE_LM75, 0x48); + i2c_slave_create_simple(pca954x_i2c_get_bus(therm_mux, 4), + TYPE_LM75, 0x48); /* I2C9 Fan Controller (MAX31785) */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "max31785", 0x52); - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "max31785", 0x54); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + "max31785", 0x52); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), + "max31785", 0x54); } static bool aspeed_get_mmio_exec(Object *obj, Error **errp) diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 3272068663..4db83d0dd6 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -148,8 +148,10 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size) return at24c_eeprom_init_rom(bus, address, rom_size, NULL, 0); } -I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, - const uint8_t *init_rom, uint32_t init_rom_size) +I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, + uint8_t address, uint32_t rom_size, + const uint8_t *init_rom, + uint32_t init_rom_size) { EEPROMState *s;
We are going to modify these lines, fix their style in order to avoid checkpatch.pl warnings: WARNING: line over 80 characters Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/hw/i2c/i2c.h | 11 ++- include/hw/nvram/eeprom_at24c.h | 6 +- hw/arm/aspeed.c | 140 +++++++++++++++++++------------- hw/nvram/eeprom_at24c.c | 6 +- 4 files changed, 98 insertions(+), 65 deletions(-)