static void omap_pwt_write(void *opaque, hwaddr addr,

                           uint64_t value, unsigned size)

{

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

    int offset = addr & OMAP_MPUI_REG_MASK;



    if (size != 1) {

        omap_badwidth_write8(opaque, addr, value);

        return;

    }



    switch (offset) {

    case 0x00:	/* FRC */

        s->frc = value & 0x3f;

        break;

    case 0x04:	/* VRC */

        if ((value ^ s->vrc) & 1) {

            if (value & 1)

                printf("%s: %iHz buzz on\n", __FUNCTION__, (int)

                                /* 1.5 MHz from a 12-MHz or 13-MHz PWT_CLK */

                                ((omap_clk_getrate(s->clk) >> 3) /

                                 /* Pre-multiplexer divider */

                                 ((s->gcr & 2) ? 1 : 154) /

                                 /* Octave multiplexer */

                                 (2 << (value & 3)) *

                                 /* 101/107 divider */

                                 ((value & (1 << 2)) ? 101 : 107) *

                                 /*  49/55 divider */

                                 ((value & (1 << 3)) ?  49 : 55) *

                                 /*  50/63 divider */

                                 ((value & (1 << 4)) ?  50 : 63) *

                                 /*  80/127 divider */

                                 ((value & (1 << 5)) ?  80 : 127) /

                                 (107 * 55 * 63 * 127)));

            else

                printf("%s: silence!\n", __FUNCTION__);

        }

        s->vrc = value & 0x7f;

        break;

    case 0x08:	/* GCR */

        s->gcr = value & 3;

        break;

    default:

        OMAP_BAD_REG(addr);

        return;

    }

}

static void omap_pwt_write(void *opaque, hwaddr addr,

                           uint64_t value, unsigned size)

{

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

    int offset = addr & OMAP_MPUI_REG_MASK;



    if (size != 1) {

        omap_badwidth_write8(opaque, addr, value);

        return;

    }



    switch (offset) {

    case 0x00:	

        s->frc = value & 0x3f;

        break;

    case 0x04:	

        if ((value ^ s->vrc) & 1) {

            if (value & 1)

                printf("%s: %iHz buzz on\n", __FUNCTION__, (int)

                                

                                ((omap_clk_getrate(s->clk) >> 3) /

                                 

                                 ((s->gcr & 2) ? 1 : 154) /

                                 

                                 (2 << (value & 3)) *

                                 

                                 ((value & (1 << 2)) ? 101 : 107) *

                                 

                                 ((value & (1 << 3)) ?  49 : 55) *

                                 

                                 ((value & (1 << 4)) ?  50 : 63) *

                                 

                                 ((value & (1 << 5)) ?  80 : 127) /

                                 (107 * 55 * 63 * 127)));

            else

                printf("%s: silence!\n", __FUNCTION__);

        }

        s->vrc = value & 0x7f;

        break;

    case 0x08:	

        s->gcr = value & 3;

        break;

    default:

        OMAP_BAD_REG(addr);

        return;

    }

}

static void FUNC_0(void *VAR_0, hwaddr VAR_1,

                           uint64_t VAR_2, unsigned VAR_3)

{

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

    int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK;



    if (VAR_3 != 1) {

        omap_badwidth_write8(VAR_0, VAR_1, VAR_2);

        return;

    }



    switch (VAR_5) {

    case 0x00:	

        VAR_4->frc = VAR_2 & 0x3f;

        break;

    case 0x04:	

        if ((VAR_2 ^ VAR_4->vrc) & 1) {

            if (VAR_2 & 1)

                printf("%VAR_4: %iHz buzz on\n", __FUNCTION__, (int)

                                

                                ((omap_clk_getrate(VAR_4->clk) >> 3) /

                                 

                                 ((VAR_4->gcr & 2) ? 1 : 154) /

                                 

                                 (2 << (VAR_2 & 3)) *

                                 

                                 ((VAR_2 & (1 << 2)) ? 101 : 107) *

                                 

                                 ((VAR_2 & (1 << 3)) ?  49 : 55) *

                                 

                                 ((VAR_2 & (1 << 4)) ?  50 : 63) *

                                 

                                 ((VAR_2 & (1 << 5)) ?  80 : 127) /

                                 (107 * 55 * 63 * 127)));

            else

                printf("%VAR_4: silence!\n", __FUNCTION__);

        }

        VAR_4->vrc = VAR_2 & 0x7f;

        break;

    case 0x08:	

        VAR_4->gcr = VAR_2 & 3;

        break;

    default:

        OMAP_BAD_REG(VAR_1);

        return;

    }

}

static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{ struct omap_pwt_s *VAR_4 = (struct omap_pwt_s *) VAR_0; int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK; if (VAR_3 != 1) { omap_badwidth_write8(VAR_0, VAR_1, VAR_2); return; } switch (VAR_5) { case 0x00:
VAR_4->frc = VAR_2 & 0x3f; break; case 0x04:
if ((VAR_2 ^ VAR_4->vrc) & 1) { if (VAR_2 & 1)
printf("%VAR_4: %iHz buzz on\n", __FUNCTION__, (int)
((omap_clk_getrate(VAR_4->clk) >> 3) /
((VAR_4->gcr & 2) ? 1 : 154) /
(2 << (VAR_2 & 3)) *
((VAR_2 & (1 << 2)) ? 101 : 107) *
((VAR_2 & (1 << 3)) ?  49 : 55) *
((VAR_2 & (1 << 4)) ?  50 : 63) *
((VAR_2 & (1 << 5)) ?  80 : 127) /
(107 * 55 * 63 * 127))); else
printf("%VAR_4: silence!\n", __FUNCTION__); } VAR_4->vrc = VAR_2 & 0x7f; break; case 0x08:
VAR_4->gcr = VAR_2 & 3; break; default:
OMAP_BAD_REG(VAR_1); return; } }