Skip to content

Commit 873ec69

Browse files
committed
Merge remote-tracking branch 'remotes/cminyard/tags/for-qemu-i2c-5' into staging
Minor changes to: Add an SMBus config entry Cleanup/simplify/document some I2C interfaces # gpg: Signature made Thu 16 Jul 2020 18:46:55 BST # gpg: using RSA key FD0D5CE67CE0F59A6688268661F38C90919BFF81 # gpg: Good signature from "Corey Minyard <[email protected]>" [unknown] # gpg: aka "Corey Minyard <[email protected]>" [unknown] # gpg: aka "Corey Minyard <[email protected]>" [unknown] # gpg: aka "Corey Minyard <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: FD0D 5CE6 7CE0 F59A 6688 2686 61F3 8C90 919B FF81 * remotes/cminyard/tags/for-qemu-i2c-5: hw/i2c: Document the I2C qdev helpers hw/i2c: Rename i2c_create_slave() as i2c_slave_create_simple() hw/i2c: Rename i2c_realize_and_unref() as i2c_slave_realize_and_unref() hw/i2c: Rename i2c_try_create_slave() as i2c_slave_new() hw/i2c/aspeed_i2c: Simplify aspeed_i2c_get_bus() hw/i2c/Kconfig: Add an entry for the SMBus Signed-off-by: Peter Maydell <[email protected]>
2 parents d69cda7 + 73d5f22 commit 873ec69

File tree

20 files changed

+131
-77
lines changed

20 files changed

+131
-77
lines changed

hw/arm/aspeed.c

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,14 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
386386

387387
/* The palmetto platform expects a ds3231 RTC but a ds1338 is
388388
* enough to provide basic RTC features. Alarms will be missing */
389-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
389+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68);
390390

391-
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
391+
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50,
392392
eeprom_buf);
393393

394394
/* add a TMP423 temperature sensor */
395-
dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
396-
"tmp423", 0x4c);
395+
dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
396+
"tmp423", 0x4c));
397397
object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
398398
object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
399399
object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
@@ -405,16 +405,16 @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc)
405405
AspeedSoCState *soc = &bmc->soc;
406406
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
407407

408-
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
408+
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 0x50,
409409
eeprom_buf);
410410

411411
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
412-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
412+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7),
413413
TYPE_TMP105, 0x4d);
414414

415415
/* The AST2500 EVB does not have an RTC. Let's pretend that one is
416416
* plugged on the I2C bus header */
417-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
417+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
418418
}
419419

420420
static void ast2600_evb_i2c_init(AspeedMachineState *bmc)
@@ -429,69 +429,69 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
429429

430430
/* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
431431
* good enough */
432-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
432+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
433433
}
434434

435435
static void swift_bmc_i2c_init(AspeedMachineState *bmc)
436436
{
437437
AspeedSoCState *soc = &bmc->soc;
438438

439-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
439+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "pca9552", 0x60);
440440

441441
/* The swift board expects a TMP275 but a TMP105 is compatible */
442-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
442+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "tmp105", 0x48);
443443
/* The swift board expects a pca9551 but a pca9552 is compatible */
444-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
444+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9552", 0x60);
445445

446446
/* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
447-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
448-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
447+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "ds1338", 0x32);
448+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60);
449449

450-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c);
450+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c);
451451
/* The swift board expects a pca9539 but a pca9552 is compatible */
452-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74);
452+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "pca9552", 0x74);
453453

454-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c);
454+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c);
455455
/* The swift board expects a pca9539 but a pca9552 is compatible */
456-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552",
456+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "pca9552",
457457
0x74);
458458

459459
/* The swift board expects a TMP275 but a TMP105 is compatible */
460-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48);
461-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a);
460+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x48);
461+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x4a);
462462
}
463463

464464
static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc)
465465
{
466466
AspeedSoCState *soc = &bmc->soc;
467467

468468
/* bus 2 : */
469-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x48);
470-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x49);
469+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x48);
470+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x49);
471471
/* bus 2 : pca9546 @ 0x73 */
472472

473473
/* bus 3 : pca9548 @ 0x70 */
474474

475475
/* bus 4 : */
476476
uint8_t *eeprom4_54 = g_malloc0(8 * 1024);
477-
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), 0x54,
477+
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54,
478478
eeprom4_54);
479479
/* PCA9539 @ 0x76, but PCA9552 is compatible */
480-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x76);
480+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x76);
481481
/* PCA9539 @ 0x77, but PCA9552 is compatible */
482-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x77);
482+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x77);
483483

484484
/* bus 6 : */
485-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x48);
486-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x49);
485+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x48);
486+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x49);
487487
/* bus 6 : pca9546 @ 0x73 */
488488

489489
/* bus 8 : */
490490
uint8_t *eeprom8_56 = g_malloc0(8 * 1024);
491-
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), 0x56,
491+
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 8), 0x56,
492492
eeprom8_56);
493-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
494-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x61);
493+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60);
494+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x61);
495495
/* bus 8 : adc128d818 @ 0x1d */
496496
/* bus 8 : adc128d818 @ 0x1f */
497497

@@ -514,28 +514,30 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
514514
/* Bus 3: TODO bmp280@77 */
515515
/* Bus 3: TODO max31785@52 */
516516
/* Bus 3: TODO dps310@76 */
517-
dev = i2c_try_create_slave(TYPE_PCA9552, 0x60);
517+
dev = DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60));
518518
qdev_prop_set_string(dev, "description", "pca1");
519-
i2c_realize_and_unref(dev, aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3),
520-
&error_fatal);
519+
i2c_slave_realize_and_unref(I2C_SLAVE(dev),
520+
aspeed_i2c_get_bus(&soc->i2c, 3),
521+
&error_fatal);
521522

522-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
523-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
523+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c);
524+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c);
524525

525526
/* The Witherspoon expects a TMP275 but a TMP105 is compatible */
526-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
527+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105,
527528
0x4a);
528529

529530
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
530531
* good enough */
531-
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
532+
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
532533

533-
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
534+
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51,
534535
eeprom_buf);
535-
dev = i2c_try_create_slave(TYPE_PCA9552, 0x60);
536+
dev = DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60));
536537
qdev_prop_set_string(dev, "description", "pca0");
537-
i2c_realize_and_unref(dev, aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11),
538-
&error_fatal);
538+
i2c_slave_realize_and_unref(I2C_SLAVE(dev),
539+
aspeed_i2c_get_bus(&soc->i2c, 11),
540+
&error_fatal);
539541
/* Bus 11: TODO ucd90160@64 */
540542
}
541543

hw/arm/musicpal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ static void musicpal_init(MachineState *machine)
15841584
DeviceState *i2c_dev;
15851585
DeviceState *lcd_dev;
15861586
DeviceState *key_dev;
1587-
DeviceState *wm8750_dev;
1587+
I2CSlave *wm8750_dev;
15881588
SysBusDevice *s;
15891589
I2CBus *i2c;
15901590
int i;
@@ -1687,7 +1687,7 @@ static void musicpal_init(MachineState *machine)
16871687
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
16881688
}
16891689

1690-
wm8750_dev = i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR);
1690+
wm8750_dev = i2c_slave_create_simple(i2c, TYPE_WM8750, MP_WM_ADDR);
16911691
dev = qdev_new(TYPE_MV88W8618_AUDIO);
16921692
s = SYS_BUS_DEVICE(dev);
16931693
object_property_set_link(OBJECT(dev), "wm8750", OBJECT(wm8750_dev),

hw/arm/nseries.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static void n8x0_i2c_setup(struct n800_s *s)
215215
I2CBus *i2c = omap_i2c_bus(s->mpu->i2c[0]);
216216

217217
/* Attach a menelaus PM chip */
218-
dev = i2c_create_slave(i2c, "twl92230", N8X0_MENELAUS_ADDR);
218+
dev = DEVICE(i2c_slave_create_simple(i2c, "twl92230", N8X0_MENELAUS_ADDR));
219219
qdev_connect_gpio_out(dev, 3,
220220
qdev_get_gpio_in(s->mpu->ih[0],
221221
OMAP_INT_24XX_SYS_NIRQ));
@@ -224,7 +224,7 @@ static void n8x0_i2c_setup(struct n800_s *s)
224224
qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier);
225225

226226
/* Attach a TMP105 PM chip (A0 wired to ground) */
227-
dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR);
227+
dev = DEVICE(i2c_slave_create_simple(i2c, TYPE_TMP105, N8X0_TMP105_ADDR));
228228
qdev_connect_gpio_out(dev, 0, tmp_irq);
229229
}
230230

@@ -416,8 +416,8 @@ static void n810_kbd_setup(struct n800_s *s)
416416

417417
/* Attach the LM8322 keyboard to the I2C bus,
418418
* should happen in n8x0_i2c_setup and s->kbd be initialised here. */
419-
s->kbd = i2c_create_slave(omap_i2c_bus(s->mpu->i2c[0]),
420-
"lm8323", N810_LM8323_ADDR);
419+
s->kbd = DEVICE(i2c_slave_create_simple(omap_i2c_bus(s->mpu->i2c[0]),
420+
"lm8323", N810_LM8323_ADDR));
421421
qdev_connect_gpio_out(s->kbd, 0, kbd_irq);
422422
}
423423

hw/arm/pxa2xx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,8 +1522,9 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
15221522
s = PXA2XX_I2C(i2c_dev);
15231523
/* FIXME: Should the slave device really be on a separate bus? */
15241524
i2cbus = i2c_init_bus(dev, "dummy");
1525-
dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
1526-
s->slave = PXA2XX_I2C_SLAVE(dev);
1525+
s->slave = PXA2XX_I2C_SLAVE(i2c_slave_create_simple(i2cbus,
1526+
TYPE_PXA2XX_I2C_SLAVE,
1527+
0));
15271528
s->slave->host = s;
15281529

15291530
return s;

hw/arm/realview.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void realview_init(MachineState *machine,
285285

286286
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
287287
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
288-
i2c_create_slave(i2c, "ds1338", 0x68);
288+
i2c_slave_create_simple(i2c, "ds1338", 0x68);
289289

290290
/* Memory map for RealView Emulation Baseboard: */
291291
/* 0x10000000 System registers. */

hw/arm/spitz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
787787
DeviceState *wm;
788788

789789
/* Attach a WM8750 to the bus */
790-
wm = i2c_create_slave(bus, TYPE_WM8750, 0);
790+
wm = DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0));
791791

792792
spitz_wm8750_addr(wm, 0, 0);
793793
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,
@@ -802,7 +802,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
802802
static void spitz_akita_i2c_setup(PXA2xxState *cpu)
803803
{
804804
/* Attach a Max7310 to Akita I2C bus. */
805-
i2c_create_slave(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310",
805+
i2c_slave_create_simple(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310",
806806
AKITA_MAX_ADDR);
807807
}
808808

hw/arm/stellaris.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
13801380
qdev_get_gpio_in(nvic, 8));
13811381
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
13821382
if (board->peripherals & BP_OLED_I2C) {
1383-
i2c_create_slave(i2c, "ssd0303", 0x3d);
1383+
i2c_slave_create_simple(i2c, "ssd0303", 0x3d);
13841384
}
13851385
}
13861386

hw/arm/tosa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static uint8_t tosa_dac_recv(I2CSlave *s)
234234
static void tosa_tg_init(PXA2xxState *cpu)
235235
{
236236
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
237-
i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE);
237+
i2c_slave_create_simple(bus, TYPE_TOSA_DAC, DAC_BASE);
238238
ssi_create_slave(cpu->ssp[1], "tosa-ssp");
239239
}
240240

hw/arm/versatilepb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static void versatile_init(MachineState *machine, int board_id)
317317

318318
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
319319
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
320-
i2c_create_slave(i2c, "ds1338", 0x68);
320+
i2c_slave_create_simple(i2c, "ds1338", 0x68);
321321

322322
/* Add PL041 AACI Interface to the LM4549 codec */
323323
pl041 = qdev_new("pl041");

hw/arm/vexpress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static void vexpress_common_init(MachineState *machine)
642642

643643
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NULL);
644644
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
645-
i2c_create_slave(i2c, "sii9022", 0x39);
645+
i2c_slave_create_simple(i2c, "sii9022", 0x39);
646646

647647
sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
648648

0 commit comments

Comments
 (0)