On Sat, Oct 23, 2010 at 6:11 PM, Mike Frysinger <vapier@xxxxxxxxxx> wrote: > From: Bob Liu <lliubbo@xxxxxxxxx> > > Rather than relying on a cpu-specific register offset between the base > of the musb registers and the endpoints, leverage the existing musb > structures to find the endpoint register base. ÂThis makes the code > work across processors including Blackfin parts. > > Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx> > Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> > --- > Âdrivers/usb/musb/musb_core.c |  46 ++++++++++++++++++++--------------------- > Â1 files changed, 22 insertions(+), 24 deletions(-) > > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index 540c766..d4f18bb 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -2266,6 +2266,7 @@ void musb_save_context(struct musb *musb) > Â{ >    Âint i; >    Âvoid __iomem *musb_base = musb->mregs; > +    void __iomem *epio; > >    Âif (is_host_enabled(musb)) { >        Âmusb_context.frame = musb_readw(musb_base, MUSB_FRAME); > @@ -2279,16 +2280,16 @@ void musb_save_context(struct musb *musb) >    Âmusb_context.index = musb_readb(musb_base, MUSB_INDEX); >    Âmusb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL); > > -    for (i = 0; i < MUSB_C_NUM_EPS; ++i) { > -        musb_writeb(musb_base, MUSB_INDEX, i); > +    for (i = 0; i < musb->config->num_eps; ++i) { > +        epio = musb->endpoints[i].regs; >        Âmusb_context.index_regs[i].txmaxp = > -            musb_readw(musb_base, 0x10 + MUSB_TXMAXP); > +            musb_readw(epio, MUSB_TXMAXP); >        Âmusb_context.index_regs[i].txcsr = > -            musb_readw(musb_base, 0x10 + MUSB_TXCSR); > +            musb_readw(epio, MUSB_TXCSR); >        Âmusb_context.index_regs[i].rxmaxp = > -            musb_readw(musb_base, 0x10 + MUSB_RXMAXP); > +            musb_readw(epio, MUSB_RXMAXP); >        Âmusb_context.index_regs[i].rxcsr = > -            musb_readw(musb_base, 0x10 + MUSB_RXCSR); > +            musb_readw(epio, MUSB_RXCSR); > >        Âif (musb->dyn_fifo) { >            Âmusb_context.index_regs[i].txfifoadd = > @@ -2302,13 +2303,13 @@ void musb_save_context(struct musb *musb) >        Â} >        Âif (is_host_enabled(musb)) { >            Âmusb_context.index_regs[i].txtype = > -                musb_readb(musb_base, 0x10 + MUSB_TXTYPE); > +                musb_readb(epio, MUSB_TXTYPE); >            Âmusb_context.index_regs[i].txinterval = > -                musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL); > +                musb_readb(epio, MUSB_TXINTERVAL); >            Âmusb_context.index_regs[i].rxtype = > -                musb_readb(musb_base, 0x10 + MUSB_RXTYPE); > +                musb_readb(epio, MUSB_RXTYPE); >            Âmusb_context.index_regs[i].rxinterval = > -                musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL); > +                musb_readb(epio, MUSB_RXINTERVAL); > >            Âmusb_context.index_regs[i].txfunaddr = >                Âmusb_read_txfunaddr(musb_base, i); > @@ -2326,8 +2327,6 @@ void musb_save_context(struct musb *musb) >        Â} >    Â} > > -    musb_writeb(musb_base, MUSB_INDEX, musb_context.index); > - >    Âmusb_platform_save_context(musb, &musb_context); > Â} > > @@ -2336,6 +2335,7 @@ void musb_restore_context(struct musb *musb) >    Âint i; >    Âvoid __iomem *musb_base = musb->mregs; >    Âvoid __iomem *ep_target_regs; > +    void __iomem *epio; > >    Âmusb_platform_restore_context(musb, &musb_context); > > @@ -2350,15 +2350,15 @@ void musb_restore_context(struct musb *musb) >    Âmusb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe); >    Âmusb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl); > > -    for (i = 0; i < MUSB_C_NUM_EPS; ++i) { > -        musb_writeb(musb_base, MUSB_INDEX, i); > -        musb_writew(musb_base, 0x10 + MUSB_TXMAXP, > +    for (i = 0; i < musb->config->num_eps; ++i) { > +        epio = musb->endpoints[i].regs; > +        musb_writew(epio, MUSB_TXMAXP, >            Âmusb_context.index_regs[i].txmaxp); > -        musb_writew(musb_base, 0x10 + MUSB_TXCSR, > +        musb_writew(epio, MUSB_TXCSR, >            Âmusb_context.index_regs[i].txcsr); > -        musb_writew(musb_base, 0x10 + MUSB_RXMAXP, > +        musb_writew(epio, MUSB_RXMAXP, >            Âmusb_context.index_regs[i].rxmaxp); > -        musb_writew(musb_base, 0x10 + MUSB_RXCSR, > +        musb_writew(epio, MUSB_RXCSR, >            Âmusb_context.index_regs[i].rxcsr); > >        Âif (musb->dyn_fifo) { > @@ -2373,13 +2373,13 @@ void musb_restore_context(struct musb *musb) >        Â} > >        Âif (is_host_enabled(musb)) { > -            musb_writeb(musb_base, 0x10 + MUSB_TXTYPE, > +            musb_writeb(epio, MUSB_TXTYPE, >                Âmusb_context.index_regs[i].txtype); > -            musb_writeb(musb_base, 0x10 + MUSB_TXINTERVAL, > +            musb_writeb(epio, MUSB_TXINTERVAL, >                Âmusb_context.index_regs[i].txinterval); > -            musb_writeb(musb_base, 0x10 + MUSB_RXTYPE, > +            musb_writeb(epio, MUSB_RXTYPE, >                Âmusb_context.index_regs[i].rxtype); > -            musb_writeb(musb_base, 0x10 + MUSB_RXINTERVAL, > +            musb_writeb(epio, MUSB_RXINTERVAL, > >            Âmusb_context.index_regs[i].rxinterval); >            Âmusb_write_txfunaddr(musb_base, i, > @@ -2400,8 +2400,6 @@ void musb_restore_context(struct musb *musb) >                Âmusb_context.index_regs[i].rxhubport); >        Â} >    Â} > - > -    musb_writeb(musb_base, MUSB_INDEX, musb_context.index); > Â} > > Âstatic int musb_suspend(struct device *dev) > -- Hi, Mike This patch has been added to general code. -- Thanks --Bob ÿô.nÇ·®+%˱é¥wÿº{.nÇ·¥{±þë)íèjg¬±¨¶Ýjÿ¾«þG«é¸¢·¦j:+v¨wèm¶ÿþø®w¥þ࣢·hâÿÙ