aboutsummaryrefslogtreecommitdiff
path: root/hw/tosa.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:08 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:08 +0100
commitfd1eb2ea4286bb42ea4cf008ece14bbfbb598d21 (patch)
tree2886cb4a54862f4747c47cfc7bf0acc528185a4a /hw/tosa.c
parentd335681177137c4bf455aabc95a0bd9277085e58 (diff)
TOSC DAC i2c qdev voncersion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/tosa.c')
-rw-r--r--hw/tosa.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/hw/tosa.c b/hw/tosa.c
index 39febd57cf..1f87e54f09 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -132,7 +132,7 @@ typedef struct {
static int tosa_dac_send(i2c_slave *i2c, uint8_t data)
{
- TosaDACState *s = (TosaDACState *)i2c;
+ TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
s->buf[s->len] = data;
if (s->len ++ > 2) {
#ifdef VERBOSE
@@ -151,7 +151,7 @@ static int tosa_dac_send(i2c_slave *i2c, uint8_t data)
static void tosa_dac_event(i2c_slave *i2c, enum i2c_event event)
{
- TosaDACState *s = (TosaDACState *)i2c;
+ TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
s->len = 0;
switch (event) {
case I2C_START_SEND:
@@ -178,14 +178,15 @@ static int tosa_dac_recv(i2c_slave *s)
return -1;
}
+static void tosa_dac_init(i2c_slave *i2c)
+{
+ /* Nothing to do. */
+}
+
static void tosa_tg_init(PXA2xxState *cpu)
{
i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
- i2c_slave *dac = i2c_slave_init(bus, 0, sizeof(TosaDACState));
- dac->send = tosa_dac_send;
- dac->event = tosa_dac_event;
- dac->recv = tosa_dac_recv;
- i2c_set_slave_address(dac, DAC_BASE);
+ i2c_create_slave(bus, "tosa_dac", DAC_BASE);
pxa2xx_ssp_attach(cpu->ssp[1], tosa_ssp_read,
tosa_ssp_write, cpu);
}
@@ -241,3 +242,17 @@ QEMUMachine tosapda_machine = {
.desc = "Tosa PDA (PXA255)",
.init = tosa_init,
};
+
+static I2CSlaveInfo tosa_dac_info = {
+ .init = tosa_dac_init,
+ .event = tosa_dac_event,
+ .recv = tosa_dac_recv,
+ .send = tosa_dac_send
+};
+
+static void tosa_register_devices(void)
+{
+ i2c_register_slave("tosa_dac", sizeof(TosaDACState), &tosa_dac_info);
+}
+
+device_init(tosa_register_devices)