devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Min Guo <min.guo@mediatek.com>
To: Bin Liu <b-liu@ti.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	chunfeng.yun@mediatek.com, linux-usb@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, tony@atomide.com,
	hdegoede@redhat.com, Yonglong Wu <yonglong.wu@mediatek.com>
Subject: Re: [PATCH v4 6/6] usb: musb: Add support for MediaTek musb controller
Date: Tue, 22 Jan 2019 09:45:15 +0800	[thread overview]
Message-ID: <1548121515.4433.259.camel@mhfsdcap03> (raw)
In-Reply-To: <20190121160749.GD30080@uda0271908>

Hi Bin,

On Mon, 2019-01-21 at 10:07 -0600, Bin Liu wrote:
> Hi Min,
> 
> On Mon, Jan 21, 2019 at 08:22:31PM +0800, min.guo@mediatek.com wrote:
> > From: Min Guo <min.guo@mediatek.com>
> > 
> > This adds support for MediaTek musb controller in
> > host, peripheral and otg mode.
> > There are some quirk of MediaTek musb controller, such as:
> >  -W1C interrupt status registers
> >  -Private data toggle registers
> >  -No dedicated DMA interrupt line
> > 
> > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > Signed-off-by: Yonglong Wu <yonglong.wu@mediatek.com>
> > ---
> > changes in v4:
> > 1. no changes
> > 
> > changes in v3:
> > suggested by Bin:
> > 1. Remove 'u8/u16 data' parameter in clearb/w() hooks
> > 2. Replace musb_readb/w() with musb_clearb/w() to clear interrupts status
> > 
> > changes in v2:
> > suggested by Bin:
> > 1. Add summarize of MediaTek musb controller differences in the commit log
> > 2. Add "|| COMPILE_TEST" in Kconfig
> > 3. Move MediaTek's private toggle registers from musb_regs.h to mediatek.c
> > 4. Replace musb_readl() with musb_readw() to read 16bit toggle register
> > ---
> >  drivers/usb/musb/Kconfig    |   8 +-
> >  drivers/usb/musb/Makefile   |   1 +
> >  drivers/usb/musb/mediatek.c | 624 ++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 632 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/usb/musb/mediatek.c
> > 
> 
> [snip]
> 
> > +static irqreturn_t generic_interrupt(int irq, void *__hci)
> > +{
> > +	unsigned long flags;
> > +	irqreturn_t retval = IRQ_NONE;
> > +	struct musb *musb = __hci;
> > +
> > +	spin_lock_irqsave(&musb->lock, flags);
> > +	musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB) &
> > +	    musb_readb(musb->mregs, MUSB_INTRUSBE);
> > +	musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX)
> > +	    & musb_readw(musb->mregs, MUSB_INTRTXE);
> > +	musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX)
> > +	    & musb_readw(musb->mregs, MUSB_INTRRXE);
> 
> Based on my comment in 5/6, the above 3 musb_readb/w() can be changed to
> 
> > +	/* MediaTek controller interrupt status is W1C */
> > +	musb_clearw(musb->mregs, MUSB_INTRRX);
> > +	musb_clearw(musb->mregs, MUSB_INTRTX);
> > +	musb_clearb(musb->mregs, MUSB_INTRUSB);
> 
> 	musb->int_usb = musb_clearb(musb->mregs, MUSB_INTRUSB)
> 	musb->int_tx = musb_clearw(musb->mregs, MUSB_INTRTX);
> 	musb->int_rx = musb_clearw(musb->mregs, MUSB_INTRRX);

Okay.

> > +
> > +	if (musb->int_usb || musb->int_tx || musb->int_rx)
> > +		retval = musb_interrupt(musb);
> > +
> > +	spin_unlock_irqrestore(&musb->lock, flags);
> > +
> > +	return retval;
> > +}
> > +
> 
> [snip]
> 
> > +
> > +static u8 mtk_musb_clearb(void __iomem *addr, unsigned int offset)
> > +{
> > +	u8 data;
> > +
> > +	/* W1C */
> > +	data = musb_readb(addr, offset);
> > +	musb_writeb(addr, offset, data);
> > +	return musb_readb(addr, offset);
> 
> 	return data;

Okay.

> > +}
> > +
> > +static u16 mtk_musb_clearw(void __iomem *addr, unsigned int offset)
> > +{
> > +	u16 data;
> > +
> > +	/* W1C */
> > +	data = musb_readw(addr, offset);
> > +	musb_writew(addr, offset, data);
> > +	return musb_readw(addr, offset);
> 
> 	return data;

Okay.

> 
> Regards,
> -Bin.

      reply	other threads:[~2019-01-22  1:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 12:22 [PATCH v4 0/6] Add MediaTek MUSB Controller Driver min.guo
2019-01-21 12:22 ` [PATCH v4 1/6] dt-bindings: usb: musb: Add support for MediaTek musb controller min.guo
2019-01-21 15:14   ` Rob Herring
2019-01-22  9:36     ` Min Guo
2019-01-22 14:33       ` Bin Liu
2019-01-25  2:07         ` Min Guo
2019-02-14  8:30           ` Min Guo
2019-01-21 12:22 ` [PATCH v4 2/6] arm: dts: mt2701: Add usb2 device nodes min.guo
2019-01-21 12:22 ` [PATCH v4 3/6] usb: musb: Add get/set toggle hooks min.guo
2019-01-21 12:22 ` [PATCH v4 4/6] usb: musb: Add noirq type of dma create interface min.guo
2019-01-21 12:22 ` [PATCH v4 5/6] usb: musb: Add musb_clearb/w() interface min.guo
2019-01-21 15:59   ` Bin Liu
2019-01-22  1:43     ` Min Guo
2019-01-21 12:22 ` [PATCH v4 6/6] usb: musb: Add support for MediaTek musb controller min.guo
2019-01-21 16:07   ` Bin Liu
2019-01-22  1:45     ` Min Guo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1548121515.4433.259.camel@mhfsdcap03 \
    --to=min.guo@mediatek.com \
    --cc=b-liu@ti.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tony@atomide.com \
    --cc=yonglong.wu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).