r2074 - trunk/src/host/qemu-neo1973/hw
andrew at sita.openmoko.org
andrew at sita.openmoko.org
Thu May 24 01:15:25 CEST 2007
Author: andrew
Date: 2007-05-24 01:15:23 +0200 (Thu, 24 May 2007)
New Revision: 2074
Modified:
trunk/src/host/qemu-neo1973/hw/i2c.h
trunk/src/host/qemu-neo1973/hw/max7310.c
trunk/src/host/qemu-neo1973/hw/pxa.h
trunk/src/host/qemu-neo1973/hw/pxa2xx.c
trunk/src/host/qemu-neo1973/hw/s3c2410.c
trunk/src/host/qemu-neo1973/hw/s3c24xx_rtc.c
trunk/src/host/qemu-neo1973/hw/smbus.c
trunk/src/host/qemu-neo1973/hw/spitz.c
Log:
Don't assume "savevm" is followed by poweroff and "loadvm" follows a cold start.
Modified: trunk/src/host/qemu-neo1973/hw/i2c.h
===================================================================
--- trunk/src/host/qemu-neo1973/hw/i2c.h 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/i2c.h 2007-05-23 23:15:23 UTC (rev 2074)
@@ -53,9 +53,8 @@
/* max7310.c */
i2c_slave *max7310_init(i2c_bus *bus);
void max7310_reset(i2c_slave *i2c);
-void max7310_gpio_set(i2c_slave *i2c, int line, int level);
-void max7310_gpio_handler_set(i2c_slave *i2c, int line,
- gpio_handler_t handler, void *opaque);
+qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
+void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
/* wm8750.c */
i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
Modified: trunk/src/host/qemu-neo1973/hw/max7310.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/max7310.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/max7310.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -19,10 +19,8 @@
uint8_t polarity;
uint8_t status;
uint8_t command;
- struct {
- gpio_handler_t fn;
- void *opaque;
- } handler[8];
+ qemu_irq handler[8];
+ qemu_irq *gpio_in;
};
void max7310_reset(i2c_slave *i2c)
@@ -94,9 +92,8 @@
for (diff = (data ^ s->level) & ~s->direction; diff;
diff &= ~(1 << line)) {
line = ffs(diff) - 1;
- if (s->handler[line].fn)
- s->handler[line].fn(line, (data >> line) & 1,
- s->handler[line].opaque);
+ if (s->handler[line])
+ qemu_set_irq(s->handler[line], (data >> line) & 1);
}
s->level = (s->level & s->direction) | (data & ~s->direction);
break;
@@ -181,6 +178,18 @@
static int max7310_iid = 0;
+static void max7310_gpio_set(void *opaque, int line, int level)
+{
+ struct max7310_s *s = (struct max7310_s *) opaque;
+ if (line >= sizeof(s->handler) / sizeof(*s->handler) || line < 0)
+ cpu_abort(cpu_single_env, "bad GPIO line");
+
+ if (level)
+ s->level |= s->direction & (1 << line);
+ else
+ s->level &= ~(s->direction & (1 << line));
+}
+
/* MAX7310 is SMBus-compatible (can be used with only SMBus protocols),
* but also accepts sequences that are not SMBus so return an I2C device. */
struct i2c_slave *max7310_init(i2c_bus *bus)
@@ -190,6 +199,8 @@
s->i2c.event = max7310_event;
s->i2c.recv = max7310_rx;
s->i2c.send = max7310_tx;
+ s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s,
+ sizeof(s->handler) / sizeof(*s->handler));
max7310_reset(&s->i2c);
@@ -199,25 +210,17 @@
return &s->i2c;
}
-void max7310_gpio_set(i2c_slave *i2c, int line, int level)
+qemu_irq *max7310_gpio_in_get(i2c_slave *i2c)
{
struct max7310_s *s = (struct max7310_s *) i2c;
- if (line >= sizeof(s->handler) / sizeof(*s->handler) || line < 0)
- cpu_abort(cpu_single_env, "bad GPIO line");
-
- if (level)
- s->level |= s->direction & (1 << line);
- else
- s->level &= ~(s->direction & (1 << line));
+ return s->gpio_in;
}
-void max7310_gpio_handler_set(i2c_slave *i2c, int line,
- gpio_handler_t handler, void *opaque)
+void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
{
struct max7310_s *s = (struct max7310_s *) i2c;
if (line >= sizeof(s->handler) / sizeof(*s->handler) || line < 0)
cpu_abort(cpu_single_env, "bad GPIO line");
- s->handler[line].fn = handler;
- s->handler[line].opaque = opaque;
+ s->handler[line] = handler;
}
Modified: trunk/src/host/qemu-neo1973/hw/pxa.h
===================================================================
--- trunk/src/host/qemu-neo1973/hw/pxa.h 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/pxa.h 2007-05-23 23:15:23 UTC (rev 2074)
@@ -116,6 +116,10 @@
void (*writefn)(void *opaque, uint32_t value), void *opaque);
struct pxa2xx_i2c_s;
+struct pxa2xx_i2c_s *pxa2xx_i2c_init(target_phys_addr_t base,
+ qemu_irq irq, int ioregister);
+i2c_bus *pxa2xx_i2c_bus(struct pxa2xx_i2c_s *s);
+
struct pxa2xx_i2s_s;
struct pxa2xx_fir_s;
@@ -176,18 +180,6 @@
QEMUTimer *rtc_pi;
};
-struct pxa2xx_i2c_s {
- i2c_slave slave;
- i2c_bus *bus;
- target_phys_addr_t base;
- qemu_irq irq;
-
- uint16_t control;
- uint16_t status;
- uint8_t ibmr;
- uint8_t data;
-};
-
struct pxa2xx_i2s_s {
target_phys_addr_t base;
qemu_irq irq;
Modified: trunk/src/host/qemu-neo1973/hw/pxa2xx.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/pxa2xx.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/pxa2xx.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -1266,6 +1266,18 @@
}
/* I2C Interface */
+struct pxa2xx_i2c_s {
+ i2c_slave slave;
+ i2c_bus *bus;
+ target_phys_addr_t base;
+ qemu_irq irq;
+
+ uint16_t control;
+ uint16_t status;
+ uint8_t ibmr;
+ uint8_t data;
+};
+
#define IBMR 0x80 /* I2C Bus Monitor register */
#define IDBR 0x88 /* I2C Data Buffer register */
#define ICR 0x90 /* I2C Control register */
@@ -1471,7 +1483,7 @@
return 0;
}
-static struct pxa2xx_i2c_s *pxa2xx_i2c_init(target_phys_addr_t base,
+struct pxa2xx_i2c_s *pxa2xx_i2c_init(target_phys_addr_t base,
qemu_irq irq, int ioregister)
{
int iomemtype;
@@ -1497,6 +1509,11 @@
return s;
}
+i2c_bus *pxa2xx_i2c_bus(struct pxa2xx_i2c_s *s)
+{
+ return s->bus;
+}
+
/* PXA Inter-IC Sound Controller */
static void pxa2xx_i2s_reset(struct pxa2xx_i2s_s *i2s)
{
@@ -2034,7 +2051,7 @@
s->dma = pxa27x_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]);
pxa27x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0],
- s->pic[PXA27X_PIC_OST_4_11], s->env);
+ s->pic[PXA27X_PIC_OST_4_11]);
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 121);
@@ -2146,7 +2163,7 @@
s->dma = pxa255_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]);
- pxa25x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0], s->env);
+ pxa25x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0]);
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 85);
Modified: trunk/src/host/qemu-neo1973/hw/s3c2410.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/s3c2410.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/s3c2410.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -1177,9 +1177,8 @@
int i;
for (i = 0; i < 5; i ++) {
qemu_put_be32(f, s->timer[i].running);
- s3c_timers_stop(s, i);
qemu_put_be32s(f, &s->timer[i].divider);
- qemu_put_be16s(f, &s->timer[i].count);
+ qemu_put_be16(f, s3c_timers_get(s, i));
qemu_put_be64s(f, &s->timer[i].reload);
}
@@ -1195,9 +1194,10 @@
static int s3c_timers_load(QEMUFile *f, void *opaque, int version_id)
{
struct s3c_timers_state_s *s = (struct s3c_timers_state_s *) opaque;
- int i;
+ int i, running[5];
for (i = 0; i < 5; i ++) {
- s->timer[i].running = qemu_get_be32(f);
+ s->timer[i].running = 0;
+ running[i] = qemu_get_be32(f);
qemu_get_be32s(f, &s->timer[i].divider);
qemu_get_be16s(f, &s->timer[i].count);
qemu_get_be64s(f, &s->timer[i].reload);
@@ -1212,7 +1212,8 @@
qemu_get_be32s(f, &s->control);
for (i = 0; i < 5; i ++)
- s3c_timers_start(s, i);
+ if (running[i])
+ s3c_timers_start(s, i);
return 0;
}
Modified: trunk/src/host/qemu-neo1973/hw/s3c24xx_rtc.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/s3c24xx_rtc.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/s3c24xx_rtc.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -302,8 +302,7 @@
qemu_get_be32s(f, &s->sec);
s->enable = (s->control == 0x1);
- if (s->tick & (1 << 7))
- s3c_rtc_tick_mod(s);
+ s3c_rtc_tick_mod(s);
return 0;
}
Modified: trunk/src/host/qemu-neo1973/hw/smbus.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/smbus.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/smbus.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -11,7 +11,7 @@
#include "vl.h"
-#define DEBUG_SMBUS 1
+//#define DEBUG_SMBUS 1
#ifdef DEBUG_SMBUS
#define DPRINTF(fmt, args...) \
@@ -42,9 +42,6 @@
static void smbus_do_write(SMBusDevice *dev)
{
- uint8_t *p;
- int len;
-
if (dev->data_len == 0) {
smbus_do_quick_cmd(dev, 0);
} else if (dev->data_len == 1) {
Modified: trunk/src/host/qemu-neo1973/hw/spitz.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/spitz.c 2007-05-23 20:38:00 UTC (rev 2073)
+++ trunk/src/host/qemu-neo1973/hw/spitz.c 2007-05-23 23:15:23 UTC (rev 2074)
@@ -938,7 +938,7 @@
static void spitz_i2c_setup(struct pxa2xx_state_s *cpu)
{
/* Attach the CPU on one end of our I2C bus. */
- i2c_bus *bus = cpu->i2c[0]->bus;
+ i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
#ifdef HAS_AUDIO
AudioState *audio;
@@ -963,7 +963,8 @@
static void spitz_akita_i2c_setup(struct pxa2xx_state_s *cpu)
{
/* Attach a Max7310 to Akita I2C bus. */
- i2c_set_slave_address(max7310_init(cpu->i2c[0]->bus), AKITA_MAX_ADDR);
+ i2c_set_slave_address(max7310_init(pxa2xx_i2c_bus(cpu->i2c[0])),
+ AKITA_MAX_ADDR);
}
/* Other peripherals */
More information about the commitlog
mailing list