- case 0x7: /* Status */ + case 0x7: /* Status */ ret = s->dav | (s->reset << 7) | (s->pdst << 2) | 0x0; s->dav &= ~(mode_regs[TSC_MODE_X_TEST] | mode_regs[TSC_MODE_Y_TEST] | mode_regs[TSC_MODE_TS_TEST]); s->reset = true; return ret;
- case 0x8: /* AUX high threshold */ + case 0x8: /* AUX high threshold */ return s->aux_thr[1]; - case 0x9: /* AUX low threshold */ + case 0x9: /* AUX low threshold */ return s->aux_thr[0];
- case 0xa: /* TEMP high threshold */ + case 0xa: /* TEMP high threshold */ return s->temp_thr[1]; - case 0xb: /* TEMP low threshold */ + case 0xb: /* TEMP low threshold */ return s->temp_thr[0];
case 1: - if (s->command) + if (s->command) { ret = (s->data >> 8) & 0xff; - else + } else { s->data |= value << 8; + } break;
case 2: @@ -409,8 +417,9 @@ static void tsc2005_timer_tick(void *opaque)
/* Timer ticked -- a set of conversions has been finished. */
- if (!s->busy) + if (!s->busy) { return; + }
s->busy = false; s->dav |= mode_regs[s->function]; @@ -435,8 +444,9 @@ static void tsc2005_touchscreen_event(void *opaque, * signaling TS events immediately, but for now we simulate * the first conversion delay for sake of correctness. */ - if (p != s->pressure) + if (p != s->pressure) { tsc2005_pin_update(s); + } }
static int tsc2005_post_load(void *opaque, int version_id) diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c index c4e32c7a42..b94e346af1 100644 --- a/hw/input/tsc210x.c +++ b/hw/input/tsc210x.c @@ -33,13 +33,13 @@ #include "migration/vmstate.h" #include "qapi/error.h"
- case 0x01: /* Status / Keypad Control */ + case 0x01: /* Status / Keypad Control */ if ((s->model & 0xff00) == 0x2100) s->pin_func = value >> 14; else { @@ -591,7 +599,7 @@ static void tsc2102_control_register_write( } return;
- case 0x02: /* DAC Control */ + case 0x02: /* DAC Control */ if ((s->model & 0xff00) == 0x2300) { s->dac_power &= 0x7fff; s->dac_power |= 0x8000 & value; @@ -599,14 +607,15 @@ static void tsc2102_control_register_write( goto bad_reg; break;
- case 0x03: /* Reference */ + case 0x03: /* Reference */ s->ref = value & 0x1f; return;
- case 0x04: /* Reset */ + case 0x04: /* Reset */ if (value == 0xbb00) { - if (s->busy) + if (s->busy) { timer_del(s->timer); + } tsc210x_reset(s); #ifdef TSC_VERBOSE } else { @@ -616,7 +625,7 @@ static void tsc2102_control_register_write( } return;
- case 0x05: /* Configuration */ + case 0x05: /* Configuration */ s->timing = value & 0x3f; #ifdef TSC_VERBOSE if (value & ~0x3f) @@ -625,16 +634,18 @@ static void tsc2102_control_register_write( #endif return;
- case 0x06: /* Secondary configuration */ - if ((s->model & 0xff00) == 0x2100) + case 0x06: /* Secondary configuration */ + if ((s->model & 0xff00) == 0x2100) { goto bad_reg; + } s->kb.mode = value >> 14; s->pll[2] = value & 0x3ffff; return;
- case 0x10: /* Keypad Mask */ - if ((s->model & 0xff00) == 0x2100) + case 0x10: /* Keypad Mask */ + if ((s->model & 0xff00) == 0x2100) { goto bad_reg; + } s->kb.mask = value; return;
@@ -649,7 +660,7 @@ static void tsc2102_audio_register_write( TSC210xState *s, int reg, uint16_t value) { switch (reg) { - case 0x00: /* Audio Control 1 */ + case 0x00: /* Audio Control 1 */ s->audio_ctrl1 = value & 0x0f3f; #ifdef TSC_VERBOSE if ((value & ~0x0f3f) || ((value & 7) != ((value >> 3) & 7))) @@ -668,7 +679,7 @@ static void tsc2102_audio_register_write( #endif return;
- case 0x02: /* DAC Volume Control */ + case 0x02: /* DAC Volume Control */ s->volume = value; s->volume_change = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); return; @@ -681,7 +692,7 @@ static void tsc2102_audio_register_write( #endif return;
- case 0x04: /* Audio Control 2 */ + case 0x04: /* Audio Control 2 */ s->audio_ctrl2 = value & 0xf7f2; #ifdef TSC_VERBOSE if (value & ~0xf7fd) @@ -690,9 +701,10 @@ static void tsc2102_audio_register_write( #endif return;
- case 0x05: /* Stereo DAC Power Control */ - if ((value & ~s->dac_power) & (1 << 10)) + case 0x05: /* Stereo DAC Power Control */ + if ((value & ~s->dac_power) & (1 << 10)) { s->powerdown = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + }
- case 0x06: /* Audio Control 3 */ + case 0x06: /* Audio Control 3 */ s->audio_ctrl3 &= 0x00c0; s->audio_ctrl3 |= value & 0xf800; #ifdef TSC_VERBOSE @@ -715,30 +727,30 @@ static void tsc2102_audio_register_write( tsc2102_audio_output_update(s); return;
- case 0x07: /* LCH_BASS_BOOST_N0 */ - case 0x08: /* LCH_BASS_BOOST_N1 */ - case 0x09: /* LCH_BASS_BOOST_N2 */ - case 0x0a: /* LCH_BASS_BOOST_N3 */ - case 0x0b: /* LCH_BASS_BOOST_N4 */ - case 0x0c: /* LCH_BASS_BOOST_N5 */ - case 0x0d: /* LCH_BASS_BOOST_D1 */ - case 0x0e: /* LCH_BASS_BOOST_D2 */ - case 0x0f: /* LCH_BASS_BOOST_D4 */ - case 0x10: /* LCH_BASS_BOOST_D5 */ - case 0x11: /* RCH_BASS_BOOST_N0 */ - case 0x12: /* RCH_BASS_BOOST_N1 */ - case 0x13: /* RCH_BASS_BOOST_N2 */ - case 0x14: /* RCH_BASS_BOOST_N3 */ - case 0x15: /* RCH_BASS_BOOST_N4 */ - case 0x16: /* RCH_BASS_BOOST_N5 */ - case 0x17: /* RCH_BASS_BOOST_D1 */ - case 0x18: /* RCH_BASS_BOOST_D2 */ - case 0x19: /* RCH_BASS_BOOST_D4 */ - case 0x1a: /* RCH_BASS_BOOST_D5 */ + case 0x07: /* LCH_BASS_BOOST_N0 */ + case 0x08: /* LCH_BASS_BOOST_N1 */ + case 0x09: /* LCH_BASS_BOOST_N2 */ + case 0x0a: /* LCH_BASS_BOOST_N3 */ + case 0x0b: /* LCH_BASS_BOOST_N4 */ + case 0x0c: /* LCH_BASS_BOOST_N5 */ + case 0x0d: /* LCH_BASS_BOOST_D1 */ + case 0x0e: /* LCH_BASS_BOOST_D2 */ + case 0x0f: /* LCH_BASS_BOOST_D4 */ + case 0x10: /* LCH_BASS_BOOST_D5 */ + case 0x11: /* RCH_BASS_BOOST_N0 */ + case 0x12: /* RCH_BASS_BOOST_N1 */ + case 0x13: /* RCH_BASS_BOOST_N2 */ + case 0x14: /* RCH_BASS_BOOST_N3 */ + case 0x15: /* RCH_BASS_BOOST_N4 */ + case 0x16: /* RCH_BASS_BOOST_N5 */ + case 0x17: /* RCH_BASS_BOOST_D1 */ + case 0x18: /* RCH_BASS_BOOST_D2 */ + case 0x19: /* RCH_BASS_BOOST_D4 */ + case 0x1a: /* RCH_BASS_BOOST_D5 */ s->filter_data[reg - 0x07] = value; return;
- case 0x1b: /* PLL Programmability 1 */ + case 0x1b: /* PLL Programmability 1 */ s->pll[0] = value & 0xfffc; #ifdef TSC_VERBOSE if (value & ~0xfffc) @@ -747,7 +759,7 @@ static void tsc2102_audio_register_write( #endif return;
- case 0x1c: /* PLL Programmability 2 */ + case 0x1c: /* PLL Programmability 2 */ s->pll[1] = value & 0xfffc; #ifdef TSC_VERBOSE if (value & ~0xfffc) @@ -756,7 +768,7 @@ static void tsc2102_audio_register_write( #endif return;
- case 0x1d: /* Audio Control 4 */ + case 0x1d: /* Audio Control 4 */ s->softstep = !(value & 0x4000); #ifdef TSC_VERBOSE if (value & ~0x4000) @@ -789,8 +801,9 @@ static void tsc210x_pin_update(TSC210xState *s) pin_state = s->pressure && !s->dav; }
- if (!s->enabled) + if (!s->enabled) { pin_state = false; + }
if (pin_state != s->irq) { s->irq = pin_state; @@ -800,23 +813,26 @@ static void tsc210x_pin_update(TSC210xState *s) switch (s->nextfunction) { case TSC_MODE_XY_SCAN: case TSC_MODE_XYZ_SCAN: - if (!s->pressure) + if (!s->pressure) { return; + } break;
case TSC_MODE_X: case TSC_MODE_Y: case TSC_MODE_Z: - if (!s->pressure) + if (!s->pressure) { return; + } /* Fall through */ case TSC_MODE_BAT1: case TSC_MODE_BAT2: case TSC_MODE_AUX: case TSC_MODE_TEMP1: case TSC_MODE_TEMP2: - if (s->dav) + if (s->dav) { s->enabled = false; + } break;
- if (!s->command) + if (!s->command) { fprintf(stderr, "tsc210x_read: SPI underrun!\n"); + }
switch (s->page) { case TSC_DATA_REGISTERS_PAGE: ret = tsc2102_data_register_read(s, s->offset); - if (!s->dav) + if (!s->dav) { qemu_irq_raise(s->davint); + } break; case TSC_CONTROL_REGISTERS_PAGE: ret = tsc2102_control_register_read(s, s->offset); @@ -868,7 +887,7 @@ static uint16_t tsc210x_read(TSC210xState *s) tsc210x_pin_update(s);
/* Allow sequential reads. */ - s->offset ++; + s->offset++; s->state = false; return ret; } @@ -921,10 +940,12 @@ uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len) /* TODO: sequential reads etc - how do we make sure the host doesn't * unintentionally read out a conversion result from a register while * transmitting the command word of the next command? */ - if (!value || (s->state && s->command)) + if (!value || (s->state && s->command)) { ret = tsc210x_read(s); - if (value || (s->state && !s->command)) + } + if (value || (s->state && !s->command)) { tsc210x_write(s, value); + }
/* Timer ticked -- a set of conversions has been finished. */
- if (!s->busy) + if (!s->busy) { return; + }
s->busy = false; s->dav |= mode_regs[s->function]; @@ -961,16 +983,18 @@ static void tsc210x_touchscreen_event(void *opaque, * signaling TS events immediately, but for now we simulate * the first conversion delay for sake of correctness. */ - if (p != s->pressure) + if (p != s->pressure) { tsc210x_pin_update(s); + } }
/* This version assumes touchscreen X & Y axis are parallel or * perpendicular to LCD's X & Y axis in some way. */ @@ -1218,17 +1216,17 @@ void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info) s->tr[4] >>= 11; s->tr[5] >>= 11; s->tr[7] <<= 4; -#endif }
void tsc210x_key_event(uWireSlave *chip, int key, int down) { TSC210xState *s = (TSC210xState *) chip->opaque;
switch (offset) { - case 0x00: /* ITR */ + case 0x00: /* ITR */ /* Important: ignore the clearing if the IRQ is level-triggered and the input bit is 1 */ bank->irqs &= value | (bank->inputs & bank->sens_edge); return;
- case 0x04: /* MIR */ + case 0x04: /* MIR */ bank->mask = value; omap_inth_update(s, 0); omap_inth_update(s, 1); return;
- case 0x10: /* SIR_IRQ_CODE */ - case 0x14: /* SIR_FIQ_CODE */ + case 0x10: /* SIR_IRQ_CODE */ + case 0x14: /* SIR_FIQ_CODE */ OMAP_RO_REG(addr); break;
- case 0x18: /* CONTROL_REG */ - if (bank_no != 0) + case 0x18: /* CONTROL_REG */ + if (bank_no != 0) { break; + } if (value & 2) { qemu_set_irq(s->parent_intr[1], 0); s->new_agr[1] = ~0; @@ -273,38 +277,38 @@ static void omap_inth_write(void *opaque, hwaddr addr, } return;
- case 0x1c: /* ILR0 */ - case 0x20: /* ILR1 */ - case 0x24: /* ILR2 */ - case 0x28: /* ILR3 */ - case 0x2c: /* ILR4 */ - case 0x30: /* ILR5 */ - case 0x34: /* ILR6 */ - case 0x38: /* ILR7 */ - case 0x3c: /* ILR8 */ - case 0x40: /* ILR9 */ - case 0x44: /* ILR10 */ - case 0x48: /* ILR11 */ - case 0x4c: /* ILR12 */ - case 0x50: /* ILR13 */ - case 0x54: /* ILR14 */ - case 0x58: /* ILR15 */ - case 0x5c: /* ILR16 */ - case 0x60: /* ILR17 */ - case 0x64: /* ILR18 */ - case 0x68: /* ILR19 */ - case 0x6c: /* ILR20 */ - case 0x70: /* ILR21 */ - case 0x74: /* ILR22 */ - case 0x78: /* ILR23 */ - case 0x7c: /* ILR24 */ - case 0x80: /* ILR25 */ - case 0x84: /* ILR26 */ - case 0x88: /* ILR27 */ - case 0x8c: /* ILR28 */ - case 0x90: /* ILR29 */ - case 0x94: /* ILR30 */ - case 0x98: /* ILR31 */ + case 0x1c: /* ILR0 */ + case 0x20: /* ILR1 */ + case 0x24: /* ILR2 */ + case 0x28: /* ILR3 */ + case 0x2c: /* ILR4 */ + case 0x30: /* ILR5 */ + case 0x34: /* ILR6 */ + case 0x38: /* ILR7 */ + case 0x3c: /* ILR8 */ + case 0x40: /* ILR9 */ + case 0x44: /* ILR10 */ + case 0x48: /* ILR11 */ + case 0x4c: /* ILR12 */ + case 0x50: /* ILR13 */ + case 0x54: /* ILR14 */ + case 0x58: /* ILR15 */ + case 0x5c: /* ILR16 */ + case 0x60: /* ILR17 */ + case 0x64: /* ILR18 */ + case 0x68: /* ILR19 */ + case 0x6c: /* ILR20 */ + case 0x70: /* ILR21 */ + case 0x74: /* ILR22 */ + case 0x78: /* ILR23 */ + case 0x7c: /* ILR24 */ + case 0x80: /* ILR25 */ + case 0x84: /* ILR26 */ + case 0x88: /* ILR27 */ + case 0x8c: /* ILR28 */ + case 0x90: /* ILR29 */ + case 0x94: /* ILR30 */ + case 0x98: /* ILR31 */ i = (offset - 0x1c) >> 2; bank->priority[i] = (value >> 2) & 0x1f; bank->sens_edge &= ~(1 << i); @@ -313,8 +317,8 @@ static void omap_inth_write(void *opaque, hwaddr addr, bank->fiq |= (value & 1) << i; return;
- case 0x9c: /* ISR */ - for (i = 0; i < 32; i ++) + case 0x9c: /* ISR */ + for (i = 0; i < 32; i++) if (value & (1 << i)) { omap_set_intr(s, 32 * bank_no + i, 1); return; @@ -339,7 +343,7 @@ static void omap_inth_reset(DeviceState *dev) OMAPIntcState *s = OMAP_INTC(dev); int i;
- for (i = 0; i < s->nbanks; ++i){ + for (i = 0; i < s->nbanks; ++i) { s->bank[i].irqs = 0x00000000; s->bank[i].mask = 0xffffffff; s->bank[i].sens_edge = 0x00000000; @@ -348,8 +352,9 @@ static void omap_inth_reset(DeviceState *dev) s->bank[i].swi = 0x00000000; memset(s->bank[i].priority, 0, sizeof(s->bank[i].priority));
- if (s->level_only) + if (s->level_only) { s->bank[i].sens_edge = 0xffffffff; + } }
- case 0x4c: /* INTC_PROTECTION */ + case 0x4c: /* INTC_PROTECTION */ /* TODO: Make a bitmap (or sizeof(char)map) of access privileges * for every register, see Chapter 3 and 4 for privileged mode. */ if (value & 1) @@ -551,44 +557,45 @@ static void omap2_inth_write(void *opaque, hwaddr addr, __func__); return;
- case 0x50: /* INTC_IDLE */ + case 0x50: /* INTC_IDLE */ s->autoidle &= ~3; s->autoidle |= value & 3; return;
- int running; /* Is currently ticking */ - int enabled; /* Is enabled, regardless of its input clk */ - unsigned long rate; /* Current rate (if .running) */ - unsigned int divisor; /* Rate relative to input (if .enabled) */ - unsigned int multiplier; /* Rate relative to input (if .enabled) */ - qemu_irq users[16]; /* Who to notify on change */ - int usecount; /* Automatically idle when unused */ + int running; /* Is currently ticking */ + int enabled; /* Is enabled, regardless of its input clk */ + unsigned long rate; /* Current rate (if .running) */ + unsigned int divisor; /*g Rate relative to input (if .enabled) */ + unsigned int multiplier; /*g Rate relative to input (if .enabled) */ + qemu_irq users[16]; /* Who to notify on change */ + int usecount; /* Automatically idle when unused */ };
void omap_clk_put(struct clk *clk) { - if (!(clk->usecount --)) + if (!(clk->usecount--)) { hw_error("%s: %s is not in use\n", __func__, clk->name); + } }
running = parent && (clk->enabled || ((clk->flags & ALWAYS_ENABLED) && clk->usecount)); if (clk->running != running) { clk->running = running; - for (user = clk->users; *user; user ++) + for (user = clk->users; *user; user++) { qemu_set_irq(*user, running); - for (i = clk->child1; i; i = i->sibling) + } + for (i = clk->child1; i; i = i->sibling) { omap_clk_update(i); + } } }
@@ -1155,8 +1162,9 @@ static void omap_clk_rate_update_full(struct clk *clk, unsigned long int rate,
clk->rate = muldiv64(rate, mult, div); if (clk->running) - for (user = clk->users; *user; user ++) + for (user = clk->users; *user; user++) { qemu_irq_raise(*user); + } for (i = clk->child1; i; i = i->sibling) omap_clk_rate_update_full(i, rate, div * i->divisor, mult * i->multiplier); @@ -1180,7 +1188,9 @@ void omap_clk_reparent(struct clk *clk, struct clk *parent) struct clk **p;
if (clk->parent) { - for (p = &clk->parent->child1; *p != clk; p = &(*p)->sibling); + for (p = &clk->parent->child1; *p != clk; p = &(*p)->sibling) { + ; + } *p = clk->sibling; }
@@ -1202,10 +1212,11 @@ void omap_clk_onoff(struct clk *clk, int on)
void omap_clk_canidle(struct clk *clk, int can) { - if (can) + if (can) { omap_clk_put(clk); - else + } else { omap_clk_get(clk); + } }
void omap_clk_setrate(struct clk *clk, int divide, int multiply) @@ -1226,27 +1237,29 @@ void omap_clk_init(struct omap_mpu_state_s *mpu) int count; int flag;
- if (cpu_is_omap310(mpu)) + if (cpu_is_omap310(mpu)) { flag = CLOCK_IN_OMAP310; - else if (cpu_is_omap1510(mpu)) + } else if (cpu_is_omap1510(mpu)) { flag = CLOCK_IN_OMAP1510; - else if (cpu_is_omap2410(mpu) || cpu_is_omap2420(mpu)) + } else if (cpu_is_omap2410(mpu) || cpu_is_omap2420(mpu)) { flag = CLOCK_IN_OMAP242X; - else if (cpu_is_omap2430(mpu)) + } else if (cpu_is_omap2430(mpu)) { flag = CLOCK_IN_OMAP243X; - else if (cpu_is_omap3430(mpu)) + } else if (cpu_is_omap3430(mpu)) { flag = CLOCK_IN_OMAP243X; - else + } else { return; + }
- for (i = onchip_clks, count = 0; *i; i ++) - if ((*i)->flags & flag) - count ++; + for (i = onchip_clks, count = 0; *i; i++) + if ((*i)->flags & flag) { + count++; + } mpu->clks = g_new0(struct clk, count + 1); - for (i = onchip_clks, j = mpu->clks; *i; i ++) + for (i = onchip_clks, j = mpu->clks; *i; i++) if ((*i)->flags & flag) { memcpy(j, *i, sizeof(struct clk)); - for (k = mpu->clks; k < j; k ++) + for (k = mpu->clks; k < j; k++) if (j->parent && !strcmp(j->parent->name, k->name)) { j->parent = k; j->sibling = k->child1; @@ -1258,9 +1271,9 @@ void omap_clk_init(struct omap_mpu_state_s *mpu) } j->divisor = j->divisor ?: 1; j->multiplier = j->multiplier ?: 1; - j ++; + j++; } - for (j = mpu->clks; count --; j ++) { + for (j = mpu->clks; count--; j++) { omap_clk_update(j); omap_clk_rate_update(j); } diff --git a/hw/misc/omap_l4.c b/hw/misc/omap_l4.c index b7875489da..e0f5cea921 100644 --- a/hw/misc/omap_l4.c +++ b/hw/misc/omap_l4.c @@ -61,13 +61,13 @@ static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, unsigned size) }
switch (addr) { - case 0x00: /* COMPONENT */ + case 0x00: /* COMPONENT */ return s->component;
- case 0x20: /* AGENT_CONTROL */ + case 0x20: /* AGENT_CONTROL */ return s->control;
- case 0x28: /* AGENT_STATUS */ + case 0x28: /* AGENT_STATUS */ return s->status; }
- for (i = 0; i < bus->ta_num; i ++) + for (i = 0; i < bus->ta_num; i++) if (agents[i].ta == cs) { ta = &bus->ta[i]; info = &agents[i]; @@ -134,7 +135,7 @@ struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus,
switch (addr) { - case 0x204: /* IDCODE_reg */ + case 0x204: /* IDCODE_reg */ switch (s->mpu_model) { case omap2420: case omap2422: case omap2423: - return 0x5b5d902f; /* ES 2.2 */ + return 0x5b5d902f; /* ES 2.2 */ case omap2430: - return 0x5b68a02f; /* ES 2.2 */ + return 0x5b68a02f; /* ES 2.2 */ case omap3430: - return 0x1b7ae02f; /* ES 2 */ + return 0x1b7ae02f; /* ES 2 */ default: hw_error("%s: Bad mpu model\n", __func__); }
- case 0x208: /* PRODUCTION_ID_reg for OMAP2 */ - case 0x210: /* PRODUCTION_ID_reg for OMAP3 */ + case 0x208: /* PRODUCTION_ID_reg for OMAP2 */ + case 0x210: /* PRODUCTION_ID_reg for OMAP3 */ switch (s->mpu_model) { case omap2420: - return 0x000254f0; /* POP ESHS2.1.1 in N91/93/95, ES2 in N800 */ + return 0x000254f0; /* POP ESHS2.1.1 in N91/93/95, ES2 in N800 */ case omap2422: return 0x000400f0; case omap2423: @@ -68,22 +68,22 @@ static uint64_t omap_tap_read(void *opaque, hwaddr addr, unsigned size) case omap2420: case omap2422: case omap2423: - return 0xcafeb5d9; /* ES 2.2 */ + return 0xcafeb5d9; /* ES 2.2 */ case omap2430: - return 0xcafeb68a; /* ES 2.2 */ + return 0xcafeb68a; /* ES 2.2 */ case omap3430: - return 0xcafeb7ae; /* ES 2 */ + return 0xcafeb7ae; /* ES 2 */ default: hw_error("%s: Bad mpu model\n", __func__); }
- if (timeout) + if (timeout) { host->status |= 0x0080; - else if (cmd == 12) - host->status |= 0x0005; /* Makes it more real */ - else + } else if (cmd == 12) { + host->status |= 0x0005; /* Makes it more real */ + } else { host->status |= 0x0001; + } }
/* Route internal interrupt lines to the global IC and DMA */ static void pxa2xx_mmci_int_update(PXA2xxMMCIState *s) @@ -179,23 +179,25 @@ static void pxa2xx_mmci_int_update(PXA2xxMMCIState *s)
static void pxa2xx_mmci_fifo_update(PXA2xxMMCIState *s) { - if (!s->active) + if (!s->active) { return; + }
static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer) { - if (timer->pt) + if (timer->pt) { /* TODO in overflow-and-match mode if the first event to * occur is the match, don't toggle. */ omap_gp_timer_out(timer, !timer->out_val); - else + } else { /* TODO inverted pulse on timer->out_val == 1? */ qemu_irq_pulse(timer->out); + } }
- case 0x28: /* TCRR */ + case 0x28: /* TCRR */ s->time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); s->val = value; omap_gp_timer_update(s); break;
- case 0x2c: /* TLDR */ + case 0x2c: /* TLDR */ s->load_val = value; break;
- case 0x30: /* TTGR */ + case 0x30: /* TTGR */ s->time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); s->val = s->load_val; omap_gp_timer_update(s); break;
- case 0x38: /* TMAR */ + case 0x38: /* TMAR */ omap_gp_timer_sync(s); s->match_val = value; omap_gp_timer_update(s); break;
- case 0x40: /* TSICR */ + case 0x40: /* TSICR */ s->posted = (value >> 2) & 1; - if (value & 2) /* How much exactly are we supposed to reset? */ + if (value & 2) { /* How much exactly are we supposed to reset? */ omap_gp_timer_reset(s); + } break;
if (!s->tm4[counter].freq) { timer_del(s->tm4[n].tm.qtimer); @@ -167,52 +168,71 @@ static uint64_t pxa2xx_timer_read(void *opaque, hwaddr offset, int tm = 0;
switch (offset) { - case OSMR3: tm ++; + case OSMR3: + tm++; /* fall through */ - case OSMR2: tm ++; + case OSMR2: + tm++; /* fall through */ - case OSMR1: tm ++; + case OSMR1: + tm++; /* fall through */ case OSMR0: return s->timer[tm].value; - case OSMR11: tm ++; + case OSMR11: + tm++; /* fall through */ - case OSMR10: tm ++; + case OSMR10: + tm++; /* fall through */ - case OSMR9: tm ++; + case OSMR9: + tm++; /* fall through */ - case OSMR8: tm ++; + case OSMR8: + tm++; /* fall through */ - case OSMR7: tm ++; + case OSMR7: + tm++; /* fall through */ - case OSMR6: tm ++; + case OSMR6: + tm++; /* fall through */ - case OSMR5: tm ++; + case OSMR5: + tm++; /* fall through */ case OSMR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } return s->tm4[tm].tm.value; case OSCR: return s->clock + muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->lastload, s->freq, NANOSECONDS_PER_SECOND); - case OSCR11: tm ++; + case OSCR11: + tm++; /* fall through */ - case OSCR10: tm ++; + case OSCR10: + tm++; /* fall through */ - case OSCR9: tm ++; + case OSCR9: + tm++; /* fall through */ - case OSCR8: tm ++; + case OSCR8: + tm++; /* fall through */ - case OSCR7: tm ++; + case OSCR7: + tm++; /* fall through */ - case OSCR6: tm ++; + case OSCR6: + tm++; /* fall through */ - case OSCR5: tm ++; + case OSCR5: + tm++; /* fall through */ case OSCR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + }
- if (!s->tm4[tm].freq) + if (!s->tm4[tm].freq) { return s->tm4[tm].clock; + } return s->tm4[tm].clock + muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->tm4[tm].lastload, s->tm4[tm].freq, NANOSECONDS_PER_SECOND); case OIER: return s->irq_enabled; - case OSSR: /* Status register */ + case OSSR: /* Status register */ return s->events; case OWER: return s->reset3; - case OMCR11: tm ++; + case OMCR11: + tm++; /* fall through */ - case OMCR10: tm ++; + case OMCR10: + tm++; /* fall through */ - case OMCR9: tm ++; + case OMCR9: + tm++; /* fall through */ - case OMCR8: tm ++; + case OMCR8: + tm++; /* fall through */ - case OMCR7: tm ++; + case OMCR7: + tm++; /* fall through */ - case OMCR6: tm ++; + case OMCR6: + tm++; /* fall through */ - case OMCR5: tm ++; + case OMCR5: + tm++; /* fall through */ case OMCR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } return s->tm4[tm].control; case OSNR: return s->snapshot; @@ -277,33 +306,44 @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset, PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
switch (offset) { - case OSMR3: tm ++; + case OSMR3: + tm++; /* fall through */ - case OSMR2: tm ++; + case OSMR2: + tm++; /* fall through */ - case OSMR1: tm ++; + case OSMR1: + tm++; /* fall through */ case OSMR0: s->timer[tm].value = value; pxa2xx_timer_update(s, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); break; - case OSMR11: tm ++; + case OSMR11: + tm++; /* fall through */ - case OSMR10: tm ++; + case OSMR10: + tm++; /* fall through */ - case OSMR9: tm ++; + case OSMR9: + tm++; /* fall through */ - case OSMR8: tm ++; + case OSMR8: + tm++; /* fall through */ - case OSMR7: tm ++; + case OSMR7: + tm++; /* fall through */ - case OSMR6: tm ++; + case OSMR6: + tm++; /* fall through */ - case OSMR5: tm ++; + case OSMR5: + tm++; /* fall through */ case OSMR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } s->tm4[tm].tm.value = value; pxa2xx_timer_update4(s, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tm); break; @@ -313,23 +353,31 @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset, s->clock = value; pxa2xx_timer_update(s, s->lastload); break; - case OSCR11: tm ++; + case OSCR11: + tm++; /* fall through */ - case OSCR10: tm ++; + case OSCR10: + tm++; /* fall through */ - case OSCR9: tm ++; + case OSCR9: + tm++; /* fall through */ - case OSCR8: tm ++; + case OSCR8: + tm++; /* fall through */ - case OSCR7: tm ++; + case OSCR7: + tm++; /* fall through */ - case OSCR6: tm ++; + case OSCR6: + tm++; /* fall through */ - case OSCR5: tm ++; + case OSCR5: + tm++; /* fall through */ case OSCR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } s->tm4[tm].oldclock = s->tm4[tm].clock; s->tm4[tm].lastload = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); s->tm4[tm].clock = value; @@ -338,27 +386,33 @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset, case OIER: s->irq_enabled = value & 0xfff; break; - case OSSR: /* Status register */ + case OSSR: /* Status register */ value &= s->events; s->events &= ~value; - for (i = 0; i < 4; i ++, value >>= 1) - if (value & 1) + for (i = 0; i < 4; i++, value >>= 1) + if (value & 1) { qemu_irq_lower(s->timer[i].irq); - if (pxa2xx_timer_has_tm4(s) && !(s->events & 0xff0) && value) + } + if (pxa2xx_timer_has_tm4(s) && !(s->events & 0xff0) && value) { qemu_irq_lower(s->irq4); + } break; - case OWER: /* XXX: Reset on OSMR3 match? */ + case OWER: /* XXX: Reset on OSMR3 match? */ s->reset3 = value; break; - case OMCR7: tm ++; + case OMCR7: + tm++; /* fall through */ - case OMCR6: tm ++; + case OMCR6: + tm++; /* fall through */ - case OMCR5: tm ++; + case OMCR5: + tm++; /* fall through */ case OMCR4: - if (!pxa2xx_timer_has_tm4(s)) + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } s->tm4[tm].control = value & 0x0ff; /* XXX Stop if running (shouldn't happen) */ if ((value & (1 << 7)) || tm == 0) @@ -368,15 +422,20 @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset, pxa2xx_timer_update4(s, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tm); } break; - case OMCR11: tm ++; + case OMCR11: + tm++; /* fall through */ - case OMCR10: tm ++; + case OMCR10: + tm++; /* fall through */ - case OMCR9: tm ++; + case OMCR9: + tm++; /* fall through */ - case OMCR8: tm += 4; - if (!pxa2xx_timer_has_tm4(s)) + case OMCR8: + tm += 4; + if (!pxa2xx_timer_has_tm4(s)) { goto badreg; + } s->tm4[tm].control = value & 0x3ff; /* XXX Stop if running (shouldn't happen) */ if ((value & (1 << 7)) || !(tm & 1)) @@ -428,12 +487,15 @@ static void pxa2xx_timer_tick4(void *opaque) PXA2xxTimerInfo *i = (PXA2xxTimerInfo *) t->tm.info;
pxa2xx_timer_tick(&t->tm); - if (t->control & (1 << 3)) + if (t->control & (1 << 3)) { t->clock = 0; - if (t->control & (1 << 6)) + } + if (t->control & (1 << 6)) { pxa2xx_timer_update4(i, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), t->tm.num - 4); - if (i->events & 0xff0) + } + if (i->events & 0xff0) { qemu_irq_raise(i->irq4); + } }
static int pxa25x_timer_post_load(void *opaque, int version_id) @@ -446,8 +508,9 @@ static int pxa25x_timer_post_load(void *opaque, int version_id) pxa2xx_timer_update(s, now);
if (pxa2xx_timer_has_tm4(s)) - for (i = 0; i < 8; i ++) + for (i = 0; i < 8; i++) { pxa2xx_timer_update4(s, now, i); + }