Commit 697454eb8e2335c21e07b8cd0a7468d1c53bed08

Authored by Paul Brook
1 parent e3b42536

TMP105 qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
hw/i2c.h
@@ -96,8 +96,6 @@ qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c); @@ -96,8 +96,6 @@ qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c);
96 void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler); 96 void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
97 97
98 /* tmp105.c */ 98 /* tmp105.c */
99 -struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm);  
100 -void tmp105_reset(i2c_slave *i2c);  
101 void tmp105_set(i2c_slave *i2c, int temp); 99 void tmp105_set(i2c_slave *i2c, int temp);
102 100
103 /* lm832x.c */ 101 /* lm832x.c */
hw/nseries.c
@@ -179,6 +179,7 @@ static void n8x0_nand_setup(struct n800_s *s) @@ -179,6 +179,7 @@ static void n8x0_nand_setup(struct n800_s *s)
179 179
180 static void n8x0_i2c_setup(struct n800_s *s) 180 static void n8x0_i2c_setup(struct n800_s *s)
181 { 181 {
  182 + DeviceState *dev;
182 qemu_irq tmp_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TMP105_GPIO)[0]; 183 qemu_irq tmp_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TMP105_GPIO)[0];
183 184
184 /* Attach the CPU on one end of our I2C bus. */ 185 /* Attach the CPU on one end of our I2C bus. */
@@ -191,7 +192,8 @@ static void n8x0_i2c_setup(struct n800_s *s) @@ -191,7 +192,8 @@ static void n8x0_i2c_setup(struct n800_s *s)
191 N8X0_MENELAUS_ADDR); 192 N8X0_MENELAUS_ADDR);
192 193
193 /* Attach a TMP105 PM chip (A0 wired to ground) */ 194 /* Attach a TMP105 PM chip (A0 wired to ground) */
194 - i2c_set_slave_address(tmp105_init(s->i2c, tmp_irq), N8X0_TMP105_ADDR); 195 + dev = i2c_create_slave(s->i2c, "tmp105", N8X0_TMP105_ADDR);
  196 + qdev_connect_gpio_out(dev, 0, tmp_irq);
195 } 197 }
196 198
197 /* Touchscreen and keypad controller */ 199 /* Touchscreen and keypad controller */
hw/tmp105.c
@@ -214,7 +214,7 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id) @@ -214,7 +214,7 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id)
214 return 0; 214 return 0;
215 } 215 }
216 216
217 -void tmp105_reset(i2c_slave *i2c) 217 +static void tmp105_reset(i2c_slave *i2c)
218 { 218 {
219 TMP105State *s = (TMP105State *) i2c; 219 TMP105State *s = (TMP105State *) i2c;
220 220
@@ -227,19 +227,27 @@ void tmp105_reset(i2c_slave *i2c) @@ -227,19 +227,27 @@ void tmp105_reset(i2c_slave *i2c)
227 tmp105_interrupt_update(s); 227 tmp105_interrupt_update(s);
228 } 228 }
229 229
230 -struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm) 230 +static void tmp105_init(i2c_slave *i2c)
231 { 231 {
232 - TMP105State *s = (TMP105State *)  
233 - i2c_slave_init(bus, 0, sizeof(TMP105State)); 232 + TMP105State *s = FROM_I2C_SLAVE(TMP105State, i2c);
234 233
235 - s->i2c.event = tmp105_event;  
236 - s->i2c.recv = tmp105_rx;  
237 - s->i2c.send = tmp105_tx;  
238 - s->pin = alarm; 234 + qdev_init_gpio_out(&i2c->qdev, &s->pin, 1);
239 235
240 tmp105_reset(&s->i2c); 236 tmp105_reset(&s->i2c);
241 237
242 register_savevm("TMP105", -1, 0, tmp105_save, tmp105_load, s); 238 register_savevm("TMP105", -1, 0, tmp105_save, tmp105_load, s);
  239 +}
  240 +
  241 +static I2CSlaveInfo tmp105_info = {
  242 + .init = tmp105_init,
  243 + .event = tmp105_event,
  244 + .recv = tmp105_rx,
  245 + .send = tmp105_tx
  246 +};
243 247
244 - return &s->i2c; 248 +static void tmp105_register_devices(void)
  249 +{
  250 + i2c_register_slave("tmp105", sizeof(TMP105State), &tmp105_info);
245 } 251 }
  252 +
  253 +device_init(tmp105_register_devices)