From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wolverine01.qualcomm.com ([199.106.114.254]:59926 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067Ab0KJCRf (ORCPT ); Tue, 9 Nov 2010 21:17:35 -0500 Date: Wed, 10 Nov 2010 07:47:30 +0530 From: Pavan Kondeti Subject: Re: [PATCH v2] USB: Add MSM USB Device Controller driver Message-ID: <20101110021730.GB16558@codeaurora.org> References: <1289301494-26150-1-git-send-email-pkondeti@codeaurora.org> <1289301494-26150-2-git-send-email-pkondeti@codeaurora.org> <4CD95209.7010202@parrot.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4CD95209.7010202@parrot.com> Sender: linux-arm-msm-owner@vger.kernel.org List-ID: To: Matthieu CASTET Cc: "greg@kroah.com" , "linux-usb@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , Mike Lockwood , Brian Swetland On Tue, Nov 09, 2010 at 02:52:09PM +0100, 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 ? Yes. udc can use the ulpi ops defined by the otg. But in udc patch series, otg stuff is not integrated. I will post another patch to make udc work with otg. or you want me to add otg integration in the 1st patch series it self? -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.