Skip to contentSkip to conversation

Help needed to force USB host mode on AM335x CPU

DISCUSSION Mark Jackson 2 participants 2 messages Nov 22, 2013 – Nov 25, 2013

lore
Share & tools
lore
#0 lore raw

We have a custom AM335x board where the USB0_ID pin has been left floating.

By default, this puts the USB controller into peripheral mode, but we need to force it into host mode.

This can be achieved in s/w by setting some bits in the relevant USB mode register (see TRM 16.5.2.35).

This mode register's offset is already defined in musb_dsps.c

static const struct dsps_musb_wrapper am33xx_driver_data = {
...

	.mode			= 0xe8,

...
};

I can manually set this register to the correct value in musb_host.c and the USB all seems to work as expected.

int musb_host_setup(struct musb *musb, int power_budget)

{
	int ret;
	struct usb_hcd *hcd = musb->hcd;

/* Force HOST mode */
unsigned long __iomem *p;
p = ioremap(0x474010e8, 4);
*p = 0x80; /* IDDIG = 0, IDDIG_MUX = 1 */

	MUSB_HST_MODE(musb);

...
};

Ideally I'd like to add an entry in my dts file to flag for this "force mode" to be setup, such as:-

usb@47401000 {
	status = "okay";
	dr_mode = "host";
	ti,force-host;		/* force host mode */
};

Can anyone point me in the right direction as to where to put this extra code ?

I see there's a musb_am335x.c file, but that just seems to be a wrapper.

Any help would be greatly apperciated.

Regards
Mark J.

#1 lore raw

Hi,

Quoted 42 lines · Mark Jackson

We have a custom AM335x board where the USB0_ID pin has been left floating.

By default, this puts the USB controller into peripheral mode, but we need to force it into host mode.

This can be achieved in s/w by setting some bits in the relevant USB mode register (see TRM 16.5.2.35).

This mode register's offset is already defined in musb_dsps.c

static const struct dsps_musb_wrapper am33xx_driver_data = {
...

	.mode			= 0xe8,

...
};

I can manually set this register to the correct value in musb_host.c and the USB all seems to work as expected.

int musb_host_setup(struct musb *musb, int power_budget)

{
	int ret;
	struct usb_hcd *hcd = musb->hcd;

/* Force HOST mode */
unsigned long __iomem *p;
p = ioremap(0x474010e8, 4);
*p = 0x80; /* IDDIG = 0, IDDIG_MUX = 1 */

	MUSB_HST_MODE(musb);

...
};

Ideally I'd like to add an entry in my dts file to flag for this "force mode" to be setup, such as:-

usb@47401000 {
	status = "okay";
	dr_mode = "host";
	ti,force-host;		/* force host mode */
};
Quoted 5 lines

Can anyone point me in the right direction as to where to put this extra code ?

I see there's a musb_am335x.c file, but that just seems to be a wrapper.

Any help would be greatly apperciated.

I just sent two patches to linux-usb and I suppose they can help. In fact, I remember now that I have to fix commit log on one of them. I'll do that now.

cheers

Signature · 1 line
balbi