Re: [PATCH 3/5] pcm037: Add USB Host support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guennadi,

On Tue, Apr 21, 2009 at 12:08:53PM +0200, Guennadi Liakhovetski wrote:
> On Tue, 21 Apr 2009, Sascha Hauer wrote:
> 
> > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> > ---
> >  arch/arm/mach-mx3/Kconfig  |    1 +
> >  arch/arm/mach-mx3/pcm037.c |  135 ++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 136 insertions(+), 0 deletions(-)
> > 
> > diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
> > index 194b842..4bb7d69 100644
> > --- a/arch/arm/mach-mx3/Kconfig
> > +++ b/arch/arm/mach-mx3/Kconfig
> > @@ -30,6 +30,7 @@ config MACH_MX31ADS_WM1133_EV1
> >  config MACH_PCM037
> >  	bool "Support Phytec pcm037 (i.MX31) platforms"
> >  	select ARCH_MX31
> > +	select MXC_ULPI
> >  	help
> >  	  Include support for Phytec pcm037 platform. This includes
> >  	  specific configurations for the board and its peripherals.
> > diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c
> > index b5227d8..dd16452 100644
> > --- a/arch/arm/mach-mx3/pcm037.c
> > +++ b/arch/arm/mach-mx3/pcm037.c
> > @@ -28,6 +28,7 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/i2c.h>
> >  #include <linux/i2c/at24.h>
> > +#include <linux/delay.h>
> >  
> >  #include <mach/hardware.h>
> >  #include <asm/mach-types.h>
> > @@ -43,6 +44,8 @@
> >  #ifdef CONFIG_I2C_IMX
> >  #include <mach/i2c.h>
> >  #endif
> > +#include <mach/mxc_ehci.h>
> > +#include <mach/ulpi.h>
> >  
> >  #include "devices.h"
> >  
> > @@ -210,6 +213,136 @@ static int uart2_pins[] = {
> >  	MX31_PIN_CSPI3_MISO__TXD3
> >  };
> >  
> > +static int isp1504_set_vbus_power(void __iomem *view, int on)
> > +{
> > +	int vid, pid, ret = 0;
> > +
> > +	vid = (ulpi_read(ISP1504_VID_HIGH, view) << 8) |
> > +		 ulpi_read(ISP1504_VID_LOW, view);
> > +	pid = (ulpi_read(ISP1504_PID_HIGH, view) << 8) |
> > +		 ulpi_read(ISP1504_PID_LOW, view);
> > +
> > +	pr_info("ULPI Vendor ID 0x%x    Product ID 0x%x\n", vid, pid);
> > +	if (vid != 0x4cc || pid != 0x1504) {
> > +		pr_err("No ISP1504 found\n");
> > +		return -1;
> > +	}
> > +
> > +	if (on) {
> > +		ret = ulpi_set(DRV_VBUS_EXT |	/* enable external Vbus */
> > +			    DRV_VBUS |		/* enable internal Vbus */
> > +			    USE_EXT_VBUS_IND |	/* use external indicator */
> > +			    CHRG_VBUS,		/* charge Vbus */
> > +			    ISP1504_OTGCTL, view);
> > +	} else {
> > +		ret = ulpi_clear(DRV_VBUS_EXT |	/* disable external Vbus */
> > +			      DRV_VBUS,		/* disable internal Vbus */
> > +			      ISP1504_OTGCTL, view);
> > +
> > +		ret |= ulpi_set(USE_EXT_VBUS_IND | /* use external indicator */
> > +			    DISCHRG_VBUS,	   /* discharge Vbus */
> > +			    ISP1504_OTGCTL, view);
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> > +static int pcm037_otg_init(struct platform_device *pdev)
> > +{
> > +	int ret;
> > +	unsigned int tmp;
> > +
> > +	tmp = readl(IO_ADDRESS(OTG_BASE_ADDR) + 0x600);
> > +	tmp &= ~((3 << 21) | 1);
> > +	tmp |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 11) | (1 << 20);
> > +	writel(tmp, IO_ADDRESS(OTG_BASE_ADDR) + 0x600);
> > +
> > +	tmp = readl(IO_ADDRESS(OTG_BASE_ADDR) + 0x184);
> > +	tmp &= ~(3 << 30);
> > +	tmp |= 2 << 30;
> > +	writel(tmp, IO_ADDRESS(OTG_BASE_ADDR) + 0x184);
> 
> ...some would say "no way! use macros!", I would be happy, if you 
> commented these. Or do both to make us all happy:-)

Of course all these will be cleaned up before I ask to submit these
patches. I mainly posted these patches to ask how to solve the problems
I mentioned in the introductory mail.

> 
> Have you also tested this in pure device mode? CanI pull these from some 
> tree or at least to which tree / branch can I apply this series?

These patches are against vanilla 2.6.30-rc2. Currently they conflict
with your USB device patches, so I haven't tested this particular tree
with the device patches. We'll need some Kconfig magic to let the user
decide whether to use host or device mode. I haven't implemented this
yet.

That said, I'm currently testing the udc driver. It seems to work so
far.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux