Commit Graph

6 Commits

Author SHA1 Message Date
Paolo Bonzini 06599472ec libqos: i2c: move address into QI2CDevice
This removes the hardcoded I2C address from the tests.  The address
is passed via QOSGraphEdgeOptions to i2c_device_create and stored
in the QI2CDevice.

The i2c_send and i2c_recv functions, along with their wrappers,
therefore, can be changed to take a QI2CDevice rather than an
adapter/address pair.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-06-03 14:03:02 +02:00
Paolo Bonzini 93c3fe2a34 tests: convert OMAP i2c tests to qgraph
This way, pca9952-test and tmp105-test will run for every machine
that exposes an i2c-bus.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-06-03 14:03:02 +02:00
Paolo Bonzini 732c919cf0 libqos: split I2CAdapter initialization and allocation
Provide *_init functions that populate an I2CAdapter struct without
allocating one, and make the existing *_create functions wrap them.

Because in the new setup *_create might return a pointer inside the
IMXI2C or OMAPI2C struct, create companion *_free functions to go
back to the outer pointer.

All this is temporary until allocation will be handled entirely by
qgraph.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-06-03 14:03:02 +02:00
Paolo Bonzini eadcd3b252 pca9552-test: do not rely on state across tests
receive_autoinc is relying on the LED state that is set by
send_and_receive.  Stop doing that, because qgraph resets the
machine between tests.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-06-03 14:03:01 +02:00
Paolo Bonzini e8ecb706a8 libqos: move common i2c code to libqos
The functions to read/write 8-bit or 16-bit registers are the same
in tmp105 and pca9552 tests, and in fact they are a special case of
"read block"/"write block" functionality; read block in turn is used
in ds1338-test.

Move everything inside libqos-test, removing the duplication.  Account
for the small differences by adding to tmp105-test.c the "read register
after writing" behavior that is specific to it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-06-03 14:03:01 +02:00
Cédric Le Goater 5141d4158c misc: add pca9552 LED blinker model
Specs are available here :

    https://www.nxp.com/docs/en/application-note/AN264.pdf

This is a simple model supporting the basic registers for led and GPIO
mode. The device also supports two blinking rates but not the model
yet.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180530064049.27976-7-clg@kaod.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-06-08 13:15:32 +01:00