aboutsummaryrefslogtreecommitdiff
path: root/hw/twl92230.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/twl92230.c')
-rw-r--r--hw/twl92230.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/hw/twl92230.c b/hw/twl92230.c
index f0e7318..35e16af 100644
--- a/hw/twl92230.c
+++ b/hw/twl92230.c
@@ -28,7 +28,7 @@
#define VERBOSE 1
-struct menelaus_s {
+typedef struct {
i2c_slave i2c;
qemu_irq irq;
@@ -66,20 +66,20 @@ struct menelaus_s {
qemu_irq *in;
int pwrbtn_state;
qemu_irq pwrbtn;
-};
+} MenelausState;
-static inline void menelaus_update(struct menelaus_s *s)
+static inline void menelaus_update(MenelausState *s)
{
qemu_set_irq(s->irq, s->status & ~s->mask);
}
-static inline void menelaus_rtc_start(struct menelaus_s *s)
+static inline void menelaus_rtc_start(MenelausState *s)
{
s->rtc.next =+ qemu_get_clock(rt_clock);
qemu_mod_timer(s->rtc.hz_tm, s->rtc.next);
}
-static inline void menelaus_rtc_stop(struct menelaus_s *s)
+static inline void menelaus_rtc_stop(MenelausState *s)
{
qemu_del_timer(s->rtc.hz_tm);
s->rtc.next =- qemu_get_clock(rt_clock);
@@ -87,12 +87,12 @@ static inline void menelaus_rtc_stop(struct menelaus_s *s)
s->rtc.next = 1;
}
-static void menelaus_rtc_update(struct menelaus_s *s)
+static void menelaus_rtc_update(MenelausState *s)
{
qemu_get_timedate(&s->rtc.tm, s->rtc.sec_offset);
}
-static void menelaus_alm_update(struct menelaus_s *s)
+static void menelaus_alm_update(MenelausState *s)
{
if ((s->rtc.ctrl & 3) == 3)
s->rtc.alm_sec = qemu_timedate_diff(&s->rtc.alm) - s->rtc.sec_offset;
@@ -100,7 +100,7 @@ static void menelaus_alm_update(struct menelaus_s *s)
static void menelaus_rtc_hz(void *opaque)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
s->rtc.next_comp --;
s->rtc.alm_sec --;
@@ -130,7 +130,7 @@ static void menelaus_rtc_hz(void *opaque)
static void menelaus_reset(i2c_slave *i2c)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
s->reg = 0x00;
s->vcore[0] = 0x0c; /* XXX: X-loader needs 0x8c? check! */
@@ -196,7 +196,7 @@ static inline int from_bcd(uint8_t val)
static void menelaus_gpio_set(void *opaque, int line, int level)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
/* No interrupt generated */
s->inputs &= ~(1 << line);
@@ -205,7 +205,7 @@ static void menelaus_gpio_set(void *opaque, int line, int level)
static void menelaus_pwrbtn_set(void *opaque, int line, int level)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
if (!s->pwrbtn_state && level) {
s->status |= 1 << 11; /* PSHBTN */
@@ -275,7 +275,7 @@ static void menelaus_pwrbtn_set(void *opaque, int line, int level)
static uint8_t menelaus_read(void *opaque, uint8_t addr)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
int reg = 0;
switch (addr) {
@@ -421,7 +421,7 @@ static uint8_t menelaus_read(void *opaque, uint8_t addr)
static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
int line;
int reg = 0;
struct tm tm;
@@ -721,7 +721,7 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
static void menelaus_event(i2c_slave *i2c, enum i2c_event event)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
if (event == I2C_START_SEND)
s->firstbyte = 1;
@@ -729,7 +729,7 @@ static void menelaus_event(i2c_slave *i2c, enum i2c_event event)
static int menelaus_tx(i2c_slave *i2c, uint8_t data)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
/* Interpret register address byte */
if (s->firstbyte) {
s->reg = data;
@@ -742,7 +742,7 @@ static int menelaus_tx(i2c_slave *i2c, uint8_t data)
static int menelaus_rx(i2c_slave *i2c)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
return menelaus_read(s, s->reg ++);
}
@@ -767,7 +767,7 @@ static void tm_get(QEMUFile *f, struct tm *tm) {
static void menelaus_save(QEMUFile *f, void *opaque)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
qemu_put_be32(f, s->firstbyte);
qemu_put_8s(f, &s->reg);
@@ -819,7 +819,7 @@ static void menelaus_save(QEMUFile *f, void *opaque)
static int menelaus_load(QEMUFile *f, void *opaque, int version_id)
{
- struct menelaus_s *s = (struct menelaus_s *) opaque;
+ MenelausState *s = (MenelausState *) opaque;
s->firstbyte = qemu_get_be32(f);
qemu_get_8s(f, &s->reg);
@@ -877,8 +877,8 @@ static int menelaus_load(QEMUFile *f, void *opaque, int version_id)
i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq)
{
- struct menelaus_s *s = (struct menelaus_s *)
- i2c_slave_init(bus, 0, sizeof(struct menelaus_s));
+ MenelausState *s = (MenelausState *)
+ i2c_slave_init(bus, 0, sizeof(MenelausState));
s->i2c.event = menelaus_event;
s->i2c.recv = menelaus_rx;
@@ -898,14 +898,14 @@ i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq)
qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
return s->in;
}
void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
{
- struct menelaus_s *s = (struct menelaus_s *) i2c;
+ MenelausState *s = (MenelausState *) i2c;
if (line >= 3 || line < 0) {
fprintf(stderr, "%s: No GPO line %i\n", __FUNCTION__, line);