From: Pavan Kondeti <pkondeti@codeaurora.org>
To: Igor Grinberg <grinberg@compulab.co.il>
Cc: Matthieu CASTET <matthieu.castet@parrot.com>,
"greg@kroah.com" <greg@kroah.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
Mike Lockwood <lockwood@android.com>,
Brian Swetland <swetland@google.com>
Subject: Re: [PATCH v2] USB: Add MSM USB Device Controller driver
Date: Wed, 10 Nov 2010 07:49:09 +0530 [thread overview]
Message-ID: <20101110021909.GC16558@codeaurora.org> (raw)
In-Reply-To: <4CD96A7C.4040703@compulab.co.il>
On Tue, Nov 09, 2010 at 05:36:28PM +0200, Igor Grinberg wrote:
>
>
> On 11/09/10 15:52, Matthieu CASTET wrote:
> > Hi,
> >
> > Pavankumar Kondeti a écrit :
> >
> >> diff --git a/drivers/usb/gadget/msm72k_udc.c b/drivers/usb/gadget/msm72k_udc.c
> >> new file mode 100644
> >> index 0000000..3fa4192
> >> --- /dev/null
> >> +++ b/drivers/usb/gadget/msm72k_udc.c
> >
> >> +
> >> +static unsigned ulpi_read(struct usb_info *ui, unsigned reg)
> >> +{
> >> + unsigned timeout = 100000;
> >> +
> >> + /* initiate read operation */
> >> + writel(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg),
> >> + USB_ULPI_VIEWPORT);
> >> +
> >> + /* wait for completion */
> >> + while ((readl(USB_ULPI_VIEWPORT) & ULPI_RUN) && (--timeout))
> >> + ;
> >> +
> >> + if (timeout == 0) {
> >> + dev_err(&ui->pdev->dev, "ulpi_read: timeout %08x\n",
> >> + readl(USB_ULPI_VIEWPORT));
> >> + return 0xffffffff;
> >> + }
> >> + return ULPI_DATA_READ(readl(USB_ULPI_VIEWPORT));
> >> +}
> >> +
> >> +static int ulpi_write(struct usb_info *ui, unsigned val, unsigned reg)
> >> +{
> >> + unsigned timeout = 10000;
> >> +
> >> + /* initiate write operation */
> >> + writel(ULPI_RUN | ULPI_WRITE |
> >> + ULPI_ADDR(reg) | ULPI_DATA(val),
> >> + USB_ULPI_VIEWPORT);
> >> +
> >> + /* wait for completion */
> >> + while ((readl(USB_ULPI_VIEWPORT) & ULPI_RUN) && (--timeout))
> >> + ;
> >> +
> >> + if (timeout == 0) {
> >> + dev_err(&ui->pdev->dev, "ulpi_write: timeout\n");
> >> + return -1;
> >> + }
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static void ulpi_init(struct usb_info *ui)
> >> +{
> >> + int *seq = ui->phy_init_seq;
> >> +
> >> + if (!seq)
> >> + return;
> >> +
> >> + while (seq[0] >= 0) {
> >> + dev_vdbg(&ui->pdev->dev, "ulpi: write 0x%02x to 0x%02x\n",
> >> + seq[0], seq[1]);
> >> + ulpi_write(ui, seq[0], seq[1]);
> >> + seq += 2;
> >> + }
> >> +}
> >> +
> >
> >
> > --- /dev/null
> > +++ b/drivers/usb/otg/msm72k_otg.c
> >
> > +
> > +#define ULPI_IO_TIMEOUT_USEC (10 * 1000)
> > +static int ulpi_read(struct otg_transceiver *otg, u32 reg)
> > +{
> > + int cnt = 0;
> > +
> > + /* initiate read operation */
> > + writel(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg),
> > + USB_ULPI_VIEWPORT);
> > +
> > + /* wait for completion */
> > + while (cnt < ULPI_IO_TIMEOUT_USEC) {
> > + if (!(readl(USB_ULPI_VIEWPORT) & ULPI_RUN))
> > + break;
> > + udelay(1);
> > + cnt++;
> > + }
> > +
> > + if (cnt >= ULPI_IO_TIMEOUT_USEC) {
> > + dev_err(otg->dev, "ulpi_read: timeout %08x\n",
> > + readl(USB_ULPI_VIEWPORT));
> > + return -ETIMEDOUT;
> > + }
> > + return ULPI_DATA_READ(readl(USB_ULPI_VIEWPORT));
> > +}
> > +
> > +static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg)
> > +{
> > + int cnt = 0;
> > +
> > + /* initiate write operation */
> > + writel(ULPI_RUN | ULPI_WRITE |
> > + ULPI_ADDR(reg) | ULPI_DATA(val),
> > + USB_ULPI_VIEWPORT);
> > +
> > + /* wait for completion */
> > + while (cnt < ULPI_IO_TIMEOUT_USEC) {
> > + if (!(readl(USB_ULPI_VIEWPORT) & ULPI_RUN))
> > + break;
> > + udelay(1);
> > + cnt++;
> > + }
> > +
> > + if (cnt >= ULPI_IO_TIMEOUT_USEC) {
> > + dev_err(otg->dev, "ulpi_write: timeout\n");
> > + return -ETIMEDOUT;
> > + }
> > + return 0;
> > +}
> > +
> > +static struct otg_io_access_ops msm_otg_io_ops = {
> > + .read = ulpi_read,
> > + .write = ulpi_write,
> > +};
> > +
> > +static void ulpi_init(struct msm_otg *motg)
> > +{
> > + struct msm_otg_platform_data *pdata = motg->pdata;
> > + int *seq = pdata->phy_init_seq;
> > +
> > + if (!seq)
> > + return;
> > +
> > + while (seq[0] >= 0) {
> > + dev_vdbg(motg->otg.dev, "ulpi: write 0x%02x to 0x%02x\n",
> > + seq[0], seq[1]);
> > + ulpi_write(&motg->otg, seq[0], seq[1]);
> > + seq += 2;
> > + }
> > +}
> >
> >
> > can't you share the ulpi fonctions from udc and otg ?
>
> The best would be to use the usb/otg/ulpi.c driver for the ulpi access.
>
This driver will eventually use msm72k_otg.c transceiver.
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2010-11-10 2:19 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 11:18 [PATCH v2] Add MSM USB Device Controller support Pavankumar Kondeti
2010-11-09 11:18 ` [PATCH v2] USB: Add MSM USB Device Controller driver Pavankumar Kondeti
2010-11-09 11:40 ` Matthieu CASTET
2010-11-09 12:16 ` Pavan Kondeti
2010-11-09 13:36 ` Matthieu CASTET
2010-11-10 2:12 ` Pavan Kondeti
2010-11-10 2:54 ` David Brownell
2010-11-10 6:22 ` Brian Swetland
2010-11-19 17:16 ` Matthieu CASTET
2010-11-27 14:00 ` Pavan Kondeti
2010-11-28 6:30 ` David Brownell
2010-11-28 12:09 ` Pavan Kondeti
2010-12-07 12:44 ` Pavan Kondeti
2010-11-09 13:25 ` Heikki Krogerus
2010-11-09 13:52 ` Matthieu CASTET
2010-11-09 15:36 ` Igor Grinberg
2010-11-10 2:19 ` Pavan Kondeti [this message]
2010-11-10 6:47 ` Igor Grinberg
2010-11-11 2:10 ` Pavan Kondeti
2010-11-19 5:50 ` Pavan Kondeti
2010-11-21 8:09 ` Igor Grinberg
2010-11-10 2:17 ` Pavan Kondeti
2010-11-09 11:18 ` [PATCH v2] USB: msm72k_udc: Add debugfs support Pavankumar Kondeti
2010-11-09 11:18 ` [PATCH v2] USB: msm72k_udc: Add Remote wakeup support Pavankumar Kondeti
2010-11-09 11:18 ` [PATCH v2] USB: msm72k_udc: Add Test Mode support Pavankumar Kondeti
2010-11-09 11:18 ` [PATCH] USB: msm72k_udc: Add charging notification support Pavankumar Kondeti
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=20101110021909.GC16558@codeaurora.org \
--to=pkondeti@codeaurora.org \
--cc=greg@kroah.com \
--cc=grinberg@compulab.co.il \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lockwood@android.com \
--cc=matthieu.castet@parrot.com \
--cc=swetland@google.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).