static void omap_eac_write(void *opaque, target_phys_addr_t addr,

                           uint64_t value, unsigned size)

{

    struct omap_eac_s *s = (struct omap_eac_s *) opaque;



    if (size != 2) {

        return omap_badwidth_write16(opaque, addr, value);

    }



    switch (addr) {

    case 0x098:	/* APD1LCR */

    case 0x09c:	/* APD1RCR */

    case 0x0a0:	/* APD2LCR */

    case 0x0a4:	/* APD2RCR */

    case 0x0a8:	/* APD3LCR */

    case 0x0ac:	/* APD3RCR */

    case 0x0b0:	/* APD4R */

    case 0x0b8:	/* ADRDR */

    case 0x0d0:	/* MPDDMARR */

    case 0x0d8:	/* MPUDMARR */

    case 0x0e4:	/* BPDDMARR */

    case 0x0ec:	/* BPUDMARR */

    case 0x100:	/* VERSION_NUMBER */

    case 0x108:	/* SYSSTATUS */

        OMAP_RO_REG(addr);

        return;



    case 0x000:	/* CPCFR1 */

        s->config[0] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x004:	/* CPCFR2 */

        s->config[1] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x008:	/* CPCFR3 */

        s->config[2] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x00c:	/* CPCFR4 */

        s->config[3] = value & 0xff;

        omap_eac_format_update(s);

        break;



    case 0x010:	/* CPTCTL */

        /* Assuming TXF and TXE bits are read-only... */

        s->control = value & 0x5f;

        omap_eac_interrupt_update(s);

        break;



    case 0x014:	/* CPTTADR */

        s->address = value & 0xff;

        break;

    case 0x018:	/* CPTDATL */

        s->data &= 0xff00;

        s->data |= value & 0xff;

        break;

    case 0x01c:	/* CPTDATH */

        s->data &= 0x00ff;

        s->data |= value << 8;

        break;

    case 0x020:	/* CPTVSLL */

        s->vtol = value & 0xf8;

        break;

    case 0x024:	/* CPTVSLH */

        s->vtsl = value & 0x9f;

        break;

    case 0x040:	/* MPCTR */

        s->modem.control = value & 0x8f;

        break;

    case 0x044:	/* MPMCCFR */

        s->modem.config = value & 0x7fff;

        break;

    case 0x060:	/* BPCTR */

        s->bt.control = value & 0x8f;

        break;

    case 0x064:	/* BPMCCFR */

        s->bt.config = value & 0x7fff;

        break;

    case 0x080:	/* AMSCFR */

        s->mixer = value & 0x0fff;

        break;

    case 0x084:	/* AMVCTR */

        s->gain[0] = value & 0xffff;

        break;

    case 0x088:	/* AM1VCTR */

        s->gain[1] = value & 0xff7f;

        break;

    case 0x08c:	/* AM2VCTR */

        s->gain[2] = value & 0xff7f;

        break;

    case 0x090:	/* AM3VCTR */

        s->gain[3] = value & 0xff7f;

        break;

    case 0x094:	/* ASTCTR */

        s->att = value & 0xff;

        break;



    case 0x0b4:	/* ADWR */

        s->codec.txbuf[s->codec.txlen ++] = value;

        if (unlikely(s->codec.txlen == EAC_BUF_LEN ||

                                s->codec.txlen == s->codec.txavail)) {

            if (s->codec.txavail)

                omap_eac_out_empty(s);

            /* Discard what couldn't be written */

            s->codec.txlen = 0;

        }

        break;



    case 0x0bc:	/* AGCFR */

        s->codec.config[0] = value & 0x07ff;

        omap_eac_format_update(s);

        break;

    case 0x0c0:	/* AGCTR */

        s->codec.config[1] = value & 0x780f;

        omap_eac_format_update(s);

        break;

    case 0x0c4:	/* AGCFR2 */

        s->codec.config[2] = value & 0x003f;

        omap_eac_format_update(s);

        break;

    case 0x0c8:	/* AGCFR3 */

        s->codec.config[3] = value & 0xffff;

        omap_eac_format_update(s);

        break;

    case 0x0cc:	/* MBPDMACTR */

    case 0x0d4:	/* MPDDMAWR */

    case 0x0e0:	/* MPUDMAWR */

    case 0x0e8:	/* BPDDMAWR */

    case 0x0f0:	/* BPUDMAWR */

        break;



    case 0x104:	/* SYSCONFIG */

        if (value & (1 << 1))				/* SOFTRESET */

            omap_eac_reset(s);

        s->sysconfig = value & 0x31d;

        break;



    default:

        OMAP_BAD_REG(addr);

        return;

    }

}

static void omap_eac_write(void *opaque, target_phys_addr_t addr,

                           uint64_t value, unsigned size)

{

    struct omap_eac_s *s = (struct omap_eac_s *) opaque;



    if (size != 2) {

        return omap_badwidth_write16(opaque, addr, value);

    }



    switch (addr) {

    case 0x098:	

    case 0x09c:	

    case 0x0a0:	

    case 0x0a4:	

    case 0x0a8:	

    case 0x0ac:	

    case 0x0b0:	

    case 0x0b8:	

    case 0x0d0:	

    case 0x0d8:	

    case 0x0e4:	

    case 0x0ec:	

    case 0x100:	

    case 0x108:	

        OMAP_RO_REG(addr);

        return;



    case 0x000:	

        s->config[0] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x004:	

        s->config[1] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x008:	

        s->config[2] = value & 0xff;

        omap_eac_format_update(s);

        break;

    case 0x00c:	

        s->config[3] = value & 0xff;

        omap_eac_format_update(s);

        break;



    case 0x010:	

        

        s->control = value & 0x5f;

        omap_eac_interrupt_update(s);

        break;



    case 0x014:	

        s->address = value & 0xff;

        break;

    case 0x018:	

        s->data &= 0xff00;

        s->data |= value & 0xff;

        break;

    case 0x01c:	

        s->data &= 0x00ff;

        s->data |= value << 8;

        break;

    case 0x020:	

        s->vtol = value & 0xf8;

        break;

    case 0x024:	

        s->vtsl = value & 0x9f;

        break;

    case 0x040:	

        s->modem.control = value & 0x8f;

        break;

    case 0x044:	

        s->modem.config = value & 0x7fff;

        break;

    case 0x060:	

        s->bt.control = value & 0x8f;

        break;

    case 0x064:	

        s->bt.config = value & 0x7fff;

        break;

    case 0x080:	

        s->mixer = value & 0x0fff;

        break;

    case 0x084:	

        s->gain[0] = value & 0xffff;

        break;

    case 0x088:	

        s->gain[1] = value & 0xff7f;

        break;

    case 0x08c:	

        s->gain[2] = value & 0xff7f;

        break;

    case 0x090:	

        s->gain[3] = value & 0xff7f;

        break;

    case 0x094:	

        s->att = value & 0xff;

        break;



    case 0x0b4:	

        s->codec.txbuf[s->codec.txlen ++] = value;

        if (unlikely(s->codec.txlen == EAC_BUF_LEN ||

                                s->codec.txlen == s->codec.txavail)) {

            if (s->codec.txavail)

                omap_eac_out_empty(s);

            

            s->codec.txlen = 0;

        }

        break;



    case 0x0bc:	

        s->codec.config[0] = value & 0x07ff;

        omap_eac_format_update(s);

        break;

    case 0x0c0:	

        s->codec.config[1] = value & 0x780f;

        omap_eac_format_update(s);

        break;

    case 0x0c4:	

        s->codec.config[2] = value & 0x003f;

        omap_eac_format_update(s);

        break;

    case 0x0c8:	

        s->codec.config[3] = value & 0xffff;

        omap_eac_format_update(s);

        break;

    case 0x0cc:	

    case 0x0d4:	

    case 0x0e0:	

    case 0x0e8:	

    case 0x0f0:	

        break;



    case 0x104:	

        if (value & (1 << 1))				

            omap_eac_reset(s);

        s->sysconfig = value & 0x31d;

        break;



    default:

        OMAP_BAD_REG(addr);

        return;

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,

                           uint64_t VAR_2, unsigned VAR_3)

{

    struct omap_eac_s *VAR_4 = (struct omap_eac_s *) VAR_0;



    if (VAR_3 != 2) {

        return omap_badwidth_write16(VAR_0, VAR_1, VAR_2);

    }



    switch (VAR_1) {

    case 0x098:	

    case 0x09c:	

    case 0x0a0:	

    case 0x0a4:	

    case 0x0a8:	

    case 0x0ac:	

    case 0x0b0:	

    case 0x0b8:	

    case 0x0d0:	

    case 0x0d8:	

    case 0x0e4:	

    case 0x0ec:	

    case 0x100:	

    case 0x108:	

        OMAP_RO_REG(VAR_1);

        return;



    case 0x000:	

        VAR_4->config[0] = VAR_2 & 0xff;

        omap_eac_format_update(VAR_4);

        break;

    case 0x004:	

        VAR_4->config[1] = VAR_2 & 0xff;

        omap_eac_format_update(VAR_4);

        break;

    case 0x008:	

        VAR_4->config[2] = VAR_2 & 0xff;

        omap_eac_format_update(VAR_4);

        break;

    case 0x00c:	

        VAR_4->config[3] = VAR_2 & 0xff;

        omap_eac_format_update(VAR_4);

        break;



    case 0x010:	

        

        VAR_4->control = VAR_2 & 0x5f;

        omap_eac_interrupt_update(VAR_4);

        break;



    case 0x014:	

        VAR_4->address = VAR_2 & 0xff;

        break;

    case 0x018:	

        VAR_4->data &= 0xff00;

        VAR_4->data |= VAR_2 & 0xff;

        break;

    case 0x01c:	

        VAR_4->data &= 0x00ff;

        VAR_4->data |= VAR_2 << 8;

        break;

    case 0x020:	

        VAR_4->vtol = VAR_2 & 0xf8;

        break;

    case 0x024:	

        VAR_4->vtsl = VAR_2 & 0x9f;

        break;

    case 0x040:	

        VAR_4->modem.control = VAR_2 & 0x8f;

        break;

    case 0x044:	

        VAR_4->modem.config = VAR_2 & 0x7fff;

        break;

    case 0x060:	

        VAR_4->bt.control = VAR_2 & 0x8f;

        break;

    case 0x064:	

        VAR_4->bt.config = VAR_2 & 0x7fff;

        break;

    case 0x080:	

        VAR_4->mixer = VAR_2 & 0x0fff;

        break;

    case 0x084:	

        VAR_4->gain[0] = VAR_2 & 0xffff;

        break;

    case 0x088:	

        VAR_4->gain[1] = VAR_2 & 0xff7f;

        break;

    case 0x08c:	

        VAR_4->gain[2] = VAR_2 & 0xff7f;

        break;

    case 0x090:	

        VAR_4->gain[3] = VAR_2 & 0xff7f;

        break;

    case 0x094:	

        VAR_4->att = VAR_2 & 0xff;

        break;



    case 0x0b4:	

        VAR_4->codec.txbuf[VAR_4->codec.txlen ++] = VAR_2;

        if (unlikely(VAR_4->codec.txlen == EAC_BUF_LEN ||

                                VAR_4->codec.txlen == VAR_4->codec.txavail)) {

            if (VAR_4->codec.txavail)

                omap_eac_out_empty(VAR_4);

            

            VAR_4->codec.txlen = 0;

        }

        break;



    case 0x0bc:	

        VAR_4->codec.config[0] = VAR_2 & 0x07ff;

        omap_eac_format_update(VAR_4);

        break;

    case 0x0c0:	

        VAR_4->codec.config[1] = VAR_2 & 0x780f;

        omap_eac_format_update(VAR_4);

        break;

    case 0x0c4:	

        VAR_4->codec.config[2] = VAR_2 & 0x003f;

        omap_eac_format_update(VAR_4);

        break;

    case 0x0c8:	

        VAR_4->codec.config[3] = VAR_2 & 0xffff;

        omap_eac_format_update(VAR_4);

        break;

    case 0x0cc:	

    case 0x0d4:	

    case 0x0e0:	

    case 0x0e8:	

    case 0x0f0:	

        break;



    case 0x104:	

        if (VAR_2 & (1 << 1))				

            omap_eac_reset(VAR_4);

        VAR_4->sysconfig = VAR_2 & 0x31d;

        break;



    default:

        OMAP_BAD_REG(VAR_1);

        return;

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{ struct omap_eac_s *VAR_4 = (struct omap_eac_s *) VAR_0; if (VAR_3 != 2) { return omap_badwidth_write16(VAR_0, VAR_1, VAR_2); } switch (VAR_1) { case 0x098:
case 0x09c:
case 0x0a0:
case 0x0a4:
case 0x0a8:
case 0x0ac:
case 0x0b0:
case 0x0b8:
case 0x0d0:
case 0x0d8:
case 0x0e4:
case 0x0ec:
case 0x100:
case 0x108:
OMAP_RO_REG(VAR_1); return; case 0x000:
VAR_4->config[0] = VAR_2 & 0xff; omap_eac_format_update(VAR_4); break; case 0x004:
VAR_4->config[1] = VAR_2 & 0xff; omap_eac_format_update(VAR_4); break; case 0x008:
VAR_4->config[2] = VAR_2 & 0xff; omap_eac_format_update(VAR_4); break; case 0x00c:
VAR_4->config[3] = VAR_2 & 0xff; omap_eac_format_update(VAR_4); break; case 0x010:
VAR_4->control = VAR_2 & 0x5f; omap_eac_interrupt_update(VAR_4); break; case 0x014:
VAR_4->address = VAR_2 & 0xff; break; case 0x018:
VAR_4->data &= 0xff00; VAR_4->data |= VAR_2 & 0xff; break; case 0x01c:
VAR_4->data &= 0x00ff; VAR_4->data |= VAR_2 << 8; break; case 0x020:
VAR_4->vtol = VAR_2 & 0xf8; break; case 0x024:
VAR_4->vtsl = VAR_2 & 0x9f; break; case 0x040:
VAR_4->modem.control = VAR_2 & 0x8f; break; case 0x044:
VAR_4->modem.config = VAR_2 & 0x7fff; break; case 0x060:
VAR_4->bt.control = VAR_2 & 0x8f; break; case 0x064:
VAR_4->bt.config = VAR_2 & 0x7fff; break; case 0x080:
VAR_4->mixer = VAR_2 & 0x0fff; break; case 0x084:
VAR_4->gain[0] = VAR_2 & 0xffff; break; case 0x088:
VAR_4->gain[1] = VAR_2 & 0xff7f; break; case 0x08c:
VAR_4->gain[2] = VAR_2 & 0xff7f; break; case 0x090:
VAR_4->gain[3] = VAR_2 & 0xff7f; break; case 0x094:
VAR_4->att = VAR_2 & 0xff; break; case 0x0b4:
VAR_4->codec.txbuf[VAR_4->codec.txlen ++] = VAR_2; if (unlikely(VAR_4->codec.txlen == EAC_BUF_LEN ||
VAR_4->codec.txlen == VAR_4->codec.txavail)) { if (VAR_4->codec.txavail)
omap_eac_out_empty(VAR_4); VAR_4->codec.txlen = 0; } break; case 0x0bc:
VAR_4->codec.config[0] = VAR_2 & 0x07ff; omap_eac_format_update(VAR_4); break; case 0x0c0:
VAR_4->codec.config[1] = VAR_2 & 0x780f; omap_eac_format_update(VAR_4); break; case 0x0c4:
VAR_4->codec.config[2] = VAR_2 & 0x003f; omap_eac_format_update(VAR_4); break; case 0x0c8:
VAR_4->codec.config[3] = VAR_2 & 0xffff; omap_eac_format_update(VAR_4); break; case 0x0cc:
case 0x0d4:
case 0x0e0:
case 0x0e8:
case 0x0f0:
break; case 0x104:
if (VAR_2 & (1 << 1))
omap_eac_reset(VAR_4); VAR_4->sysconfig = VAR_2 & 0x31d; break; default:
OMAP_BAD_REG(VAR_1); return; } }