Skip to contentSkip to conversation

musb: Use name based initialization for musb_config

PATCH New Ajay Kumar Gupta 5 participants 16 messages Jun 10, 2010 – Jul 6, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/4 musb: Use name based initialization for musb_config

Changed musb_config initialization for omap3.c, davinci.c and da8xx.c using name of structure fields. This would cause the uninitialized field to be null by default and thus would help in avoiding to init some flags required to be set only for a few selected platforms.

---
No change from v2.

 drivers/usb/musb/da8xx.c   |    6 +++---
 drivers/usb/musb/davinci.c |    6 +++---
 drivers/usb/musb/omap3.c   |    6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/usb/musb/da8xx.c +3 -3
index 40bfe44..617d88e 100644
@@ -27,9 +27,9 @@
 
 /* MUSB platform configuration */
 struct musb_config musb_cfg = {
-	(struct	musb_regs *)DA8XX_USB_OTG_CORE_BASE,
-	DA8XX_USB_OTG_TIMEOUT,
-	0
+	.regs		= (struct musb_regs *)DA8XX_USB_OTG_CORE_BASE,
+	.timeout	= DA8XX_USB_OTG_TIMEOUT,
+	.musb_speed	= 0,
 };
 
 /*
drivers/usb/musb/davinci.c +3 -3
index 8fbadc9..f56f2df 100644
@@ -28,9 +28,9 @@
 
 /* MUSB platform configuration */
 struct musb_config musb_cfg = {
-	(struct	musb_regs *)MENTOR_USB0_BASE,
-	DAVINCI_USB_TIMEOUT,
-	0
+	.regs		= (struct musb_regs *)MENTOR_USB0_BASE,
+	.timeout	= DAVINCI_USB_TIMEOUT,
+	.musb_speed	= 0,
 };
 
 /* MUSB module register overlay */
drivers/usb/musb/omap3.c +3 -3
index 3bfd0a0..785629c 100644
@@ -36,9 +36,9 @@
 static int platform_needs_initialization = 1;
 
 struct musb_config musb_cfg = {
-	(struct	musb_regs *)MENTOR_USB0_BASE,
-	OMAP3_USB_TIMEOUT,
-	0
+	.regs		= (struct musb_regs *)MENTOR_USB0_BASE,
+	.timeout	= OMAP3_USB_TIMEOUT,
+	.musb_speed	= 0,
 };
 
 /*
Signature · 1 line
1.6.2.4
#1 lore raw

PATCH v3 2/4 musb: Add Phy programming for using external Vbus

MUSB PHY on OMAP3EVM Rev >= E uses external Vbus supply to support 500mA of power.We need to program MUSB PHY to use external Vbus for this purpose.

Adding 'extvbus' member in musb_config structure which should be set by all the boards where MUSB interface is using external Vbus supply.

Also added ULPI bus control register read/write abstraction for Blackfin processor as it doesn't have ULPI registers.

---
Changes from v2:
Added 'return 0' in Blackfin version if ulpi read function.

 drivers/usb/musb/musb_core.c |    7 +++++++
 drivers/usb/musb/musb_core.h |   30 +++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)
drivers/usb/musb/musb_core.c +7 -0
index 7766069..dc740cf 100644
@@ -34,6 +34,7 @@ void musb_start(void)
 {
 #if defined(CONFIG_MUSB_HCD)
 	u8 devctl;
+	u8 busctl;
 #endif
 
 	/* disable all interrupts */
@@ -45,6 +46,12 @@ void musb_start(void)
 	/* put into basic highspeed mode and start session */
 	writeb(MUSB_POWER_HSENAB, &musbr->power);
 #if defined(CONFIG_MUSB_HCD)
+	/* Program PHY to use EXT VBUS if required */
+	if (musb_cfg.extvbus == 1) {
+		busctl = musb_read_ulpi_buscontrol(musbr);
+		musb_write_ulpi_buscontrol(musbr, busctl | ULPI_USE_EXTVBUS);
+	}
+
 	devctl = readb(&musbr->devctl);
 	writeb(devctl | MUSB_DEVCTL_SESSION, &musbr->devctl);
 #endif
drivers/usb/musb/musb_core.h +29 -1
index 9a1fb4f..4771876 100644
@@ -112,7 +112,10 @@ struct musb_regs {
 	u16	rxfifoadd;
 	u32	vcontrol;
 	u16	hwvers;
-	u16	reserved2[5];
+	u16	reserved2a[1];
+	u8	ulpi_busctl;
+	u8	reserved2b[1];
+	u16	reserved2[3];
 	u8	epinfo;
 	u8	raminfo;
 	u8	linkinfo;
@@ -181,6 +184,10 @@ struct musb_regs {
 #define MUSB_DEVCTL_HR		0x02
 #define MUSB_DEVCTL_SESSION	0x01
 
+/* ULPI VBUSCONTROL */
+#define ULPI_USE_EXTVBUS	0x01
+#define ULPI_USE_EXTVBUSIND	0x02
+
 /* TESTMODE */
 #define MUSB_TEST_FORCE_HOST	0x80
 #define MUSB_TEST_FIFO_ACCESS	0x40
@@ -341,6 +348,7 @@ struct musb_config {
 	struct	musb_regs	*regs;
 	u32			timeout;
 	u8			musb_speed;
+	u8			extvbus;
 };
 
 /* externally defined data */
@@ -361,6 +369,26 @@ extern void read_fifo(u8 ep, u32 length, void *fifo_data);
 # define readb(addr)     (u8)bfin_read16(addr)
 # undef  writeb
 # define writeb(b, addr) bfin_write16(addr, b)
+/*
+ * The USB PHY on current Blackfin processors is a UTMI+ level 2 PHY.
+ * However, it has no ULPI support - so there are no registers at all.
+ * That means accesses to ULPI_BUSCONTROL have to be abstracted away.
+ */
+static inline u8 musb_read_ulpi_buscontrol(struct musb_regs *musbr)
+{
+	return 0;
+}
+static inline void musb_write_ulpi_buscontrol(struct musb_regs *musbr, u8 val)
+{}
+#else
+static inline u8 musb_read_ulpi_buscontrol(struct musb_regs *musbr)
+{
+	return readb(&musbr->ulpi_busctl);
+}
+static inline void musb_write_ulpi_buscontrol(struct musb_regs *musbr, u8 val)
+{
+	writeb(val, &musbr->ulpi_busctl);
+}
 #endif
 
 #endif	/* __MUSB_HDRC_DEFS_H__ */
Signature · 1 line
1.6.2.4
#2 lore raw

PATCH v3 3/4 omap3evm: Add board revision function

Added function to differentiate between the OMAP3EVM revisions. The chip-id of the ethernet PHY is being used for this purpose.

Rev A to D : 0x01150000
Rev >= E : 0x92200000

---
No change from v2.

 board/ti/evm/evm.c |   30 ++++++++++++++++++++++++++++++
 board/ti/evm/evm.h |   14 ++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
board/ti/evm/evm.c +30 -0
index 0718a08..fcc1803 100644
@@ -37,6 +37,33 @@
 #include <asm/mach-types.h>
 #include "evm.h"
 
+static u8 omap3_evm_version;
+
+u8 get_omap3_evm_rev(void)
+{
+	return omap3_evm_version;
+}
+
+static void omap3_evm_get_revision(void)
+{
+	unsigned int smsc_id;
+
+	/* Ethernet PHY ID is stored at ID_REV register */
+	smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
+	printf("Read back SMSC id 0x%x\n", smsc_id);
+
+	switch (smsc_id) {
+	/* SMSC9115 chipset */
+	case 0x01150000:
+		omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
+		break;
+	/* SMSC 9220 chipset */
+	case 0x92200000:
+	default:
+		omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
+       }
+}
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -121,6 +148,9 @@ static void setup_net_chip(void)
 	writel(GPIO0, &gpio3_base->cleardataout);
 	udelay(1);
 	writel(GPIO0, &gpio3_base->setdataout);
+
+	/* determine omap3evm revision */
+	omap3_evm_get_revision();
 }
 
 int board_eth_init(bd_t *bis)
board/ti/evm/evm.h +14 -0
index 37da29d..e2581f6 100644
@@ -33,6 +33,20 @@ const omap3_sysinfo sysinfo = {
 #endif
 };
 
+/*
+ * OMAP35x EVM revision
+ * Run time detection of EVM revision is done by reading Ethernet
+ * PHY ID -
+ *      GEN_1   = 0x01150000
+ *      GEN_2   = 0x92200000
+ */
+enum {
+	OMAP3EVM_BOARD_GEN_1 = 0,	/* EVM Rev between  A - D */
+	OMAP3EVM_BOARD_GEN_2,		/* EVM Rev >= Rev E */
+};
+
+u8 get_omap3_evm_rev(void);
+
 static void setup_net_chip(void);
 
 /*
Signature · 1 line
1.6.2.4
#3 lore raw

PATCH v3 4/4 musb: Program extvbus for OMAP3EVM Rev >= E

OMAP3EVM Rev >=E uses external Vbus supply so setting 'extvbus' to '1' for OMAP3EVM Rev >=E runtime based on EVM revision.

---
No change from v2.

 board/ti/evm/evm.c       |   13 +++++++++++++
 drivers/usb/musb/omap3.c |    3 +++
 drivers/usb/musb/omap3.h |    4 ++++
 3 files changed, 20 insertions(+), 0 deletions(-)
board/ti/evm/evm.c +13 -0
index fcc1803..9948b9c 100644
@@ -65,6 +65,19 @@ static void omap3_evm_get_revision(void)
 }
 
 /*
+ * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
+ */
+u8 omap3_evm_need_extvbus(void)
+{
+	u8 retval = 0;
+
+	if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
+		retval = 1;
+
+	return retval;
+}
+
+/*
  * Routine: board_init
  * Description: Early hardware init.
  */
drivers/usb/musb/omap3.c +3 -0
index 785629c..a983552 100644
@@ -119,6 +119,9 @@ int musb_platform_init(void)
 		stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
 		writel(stdby, &otg->forcestdby);
 
+#ifdef CONFIG_OMAP3_EVM
+		musb_cfg.extvbus = omap3_evm_need_extvbus();
+#endif
 		platform_needs_initialization = 0;
 	}
 
drivers/usb/musb/omap3.h +4 -0
index b591862..c934e0c 100644
@@ -44,4 +44,8 @@
 
 int musb_platform_init(void);
 
+#ifdef CONFIG_OMAP3_EVM
+extern u8 omap3_evm_use_extvbus(void);
+#endif
+
 #endif /* _MUSB_OMAP3_H */
Signature · 1 line
1.6.2.4
#4 lore raw

PATCH v3 4/4 musb: Program extvbus for OMAP3EVM Rev >= E

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 5 lines

OMAP3EVM Rev >=E uses external Vbus supply so setting 'extvbus' to '1' for OMAP3EVM Rev >=E runtime based on EVM revision.

Quoted 8 lines

---
No change from v2.

?board/ti/evm/evm.c ? ? ? | ? 13 +++++++++++++
?drivers/usb/musb/omap3.c | ? ?3 +++
?drivers/usb/musb/omap3.h | ? ?4 ++++

?3 files changed, 20 insertions(+), 0 deletions(-)

Applied to u-boot-usb

Thanks.

Remy

#5 lore raw

PATCH v3 3/4 omap3evm: Add board revision function

In reply to Ajay Kumar Gupta

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 6 lines

Added function to differentiate between the OMAP3EVM revisions. The chip-id of the ethernet PHY is being used for this purpose.

Rev A to D : 0x01150000
Rev >= E ? : 0x92200000

Quoted 6 lines

---
No change from v2.

If you can get an Ack for this patch from Sandeep, I will take the complete series into the u-boot-usb tree along with the USB patches from this series.

Kind regards,

Remy

#6 lore raw

PATCH v3 3/4 omap3evm: Add board revision function

Quoted 19 lines

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 6 lines

Added function to differentiate between the OMAP3EVM revisions. The chip-id of the ethernet PHY is being used for this purpose.

Rev A to D : 0x01150000
Rev >= E ? : 0x92200000

Quoted 6 lines

---
No change from v2.

Quoted 3 lines

If you can get an Ack for this patch from Sandeep, I will take the complete series into the u-boot-usb tree along with the USB patches from this series.

Quoted 4 lines

Kind regards,

Remy

#7 lore raw

PATCH v3 3/4 omap3evm: Add board revision function

In reply to Ajay Kumar Gupta

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 10 lines

Added function to differentiate between the OMAP3EVM revisions. The chip-id of the ethernet PHY is being used for this purpose.

Rev A to D : 0x01150000
Rev >= E ? : 0x92200000

Quoted 6 lines

---
No change from v2.

?board/ti/evm/evm.c | ? 30 ++++++++++++++++++++++++++++++ ?board/ti/evm/evm.h | ? 14 ++++++++++++++
?2 files changed, 44 insertions(+), 0 deletions(-)

Applied to u-boot-usb

Thanks.

Remy

#8 lore raw

PATCH v3 2/4 musb: Add Phy programming for using external Vbus

In reply to Ajay Kumar Gupta
Quoted 9 lines · On Thursday, June 10, 2010 01:50:48 Ajay Kumar Gupta wrote:

MUSB PHY on OMAP3EVM Rev >= E uses external Vbus supply to support 500mA of power.We need to program MUSB PHY to use external Vbus for this purpose.

Adding 'extvbus' member in musb_config structure which should be set by all the boards where MUSB interface is using external Vbus supply.

Also added ULPI bus control register read/write abstraction for Blackfin processor as it doesn't have ULPI registers.

doesnt seem to cause problems with bf548-ezkit, so:

-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100610/e3059808/attachment.pgp

#9 lore raw

PATCH v3 2/4 musb: Add Phy programming for using external Vbus

In reply to Ajay Kumar Gupta

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 7 lines

MUSB PHY on OMAP3EVM Rev >= E uses external Vbus supply to support 500mA of power.We need to program MUSB PHY to use external Vbus for this purpose.

Adding 'extvbus' member in musb_config structure which should be set by all the boards where MUSB interface is using external Vbus supply.

Quoted 8 lines

Also added ULPI bus control register read/write abstraction for Blackfin processor as it doesn't have ULPI registers.

---
Changes from v2:
Added 'return 0' in Blackfin version if ulpi read function.

Applied to u-boot-usb

Thanks.

Remy

#10 lore raw

PATCH v3 2/4 musb: Add Phy programming for usingexternal Vbus

In reply to Ajay Kumar Gupta
Quoted 6 lines · Ajay Kumar Gupta

MUSB PHY on OMAP3EVM Rev>= E uses external Vbus supply to support 500mA of power.We need to program MUSB PHY to use external Vbus for this purpose.

Adding 'extvbus' member in musb_config structure which should be set by all the boards where MUSB interface is using external Vbus supply.

Ajay,

How does the DRVVBUS bit behave on the OMAP3 EVM board on issuing the 'usb reset' command (with musb_cfg.extvbus being set)? This post has a few more details, but in short it seems that DRVVBUS is automatically set by the TPS chip when doing the bus reset:

http://lists.denx.de/pipermail/u-boot/2011-June/095221.html

(And indeed, on a board with *no* external vbus, setting musb_cfg.extvbus and reading from a memory stick works just fine.)

I checked the u-boot in the current DVSDK (4.02.00.06) and the git repo for u-boot-ti and they all have the same construct.

Thanks,
Orjan

Signature · 2 lines
Orjan Friberg
FlatFrog Laboratories AB
#11 lore raw

PATCH v3 2/4 musb: Add Phy programming for usingexternal Vbus

Hello,

Quoted 11 lines
Quoted 6 lines

MUSB PHY on OMAP3EVM Rev>= E uses external Vbus supply to support 500mA of power.We need to program MUSB PHY to use external Vbus for this purpose.

Adding 'extvbus' member in musb_config structure which should be set by all the boards where MUSB interface is using external Vbus supply.

Ajay,

How does the DRVVBUS bit behave on the OMAP3 EVM board on issuing the 'usb reset' command (with musb_cfg.extvbus being set)?

OMAP3EVM doesn't use TPS PHY but it has ISP1507 PHY and uses external Vbus And so it needs extvbus programming (musb_cfg.extvbus =1)in OTG_CTRL register. As for as I know it is not needed for boards using usb PHY on TPS device.

Quoted 3 lines

This post has a
few more details, but in short it seems that DRVVBUS is automatically set by the TPS chip when doing the bus reset:

Looks like TPS sets the extvbus and so musb_cfg.extvbus doesn't have Any effect.

Ajay

Quoted 15 lines

http://lists.denx.de/pipermail/u-boot/2011-June/095221.html

(And indeed, on a board with *no* external vbus, setting musb_cfg.extvbus and reading from a memory stick works just fine.)

I checked the u-boot in the current DVSDK (4.02.00.06) and the git repo for u-boot-ti and they all have the same construct.

Thanks,
Orjan

--
Orjan Friberg
FlatFrog Laboratories AB

#12 lore raw

PATCH v3 2/4 musb: Add Phy programming for usingexternal Vbus

Quoted 4 lines · Ajay Kumar

OMAP3EVM doesn't use TPS PHY but it has ISP1507 PHY and uses external Vbus And so it needs extvbus programming (musb_cfg.extvbus =1)in OTG_CTRL register. As for as I know it is not needed for boards using usb PHY on TPS device.

Can you clarify what you mean by "not needed for boards using usb PHY on TPS device"? How does that differ from the ISP1507? From what I'm reading, the ISP1507 does have an integrated 5V charge pump. Or is it simply a matter of how the board is designed?

(On our custom board, we have added an external vbus supply to be able to draw > 100 mA.)

Thanks,
Orjan

Signature · 2 lines
Orjan Friberg
FlatFrog Laboratories AB
#13 lore raw

PATCH v3 2/4 musb: Add Phy programming for usingexternal Vbus

Hi,

Quoted 10 lines · Ajay Kumar
Quoted 1 line

OMAP3EVM doesn't use TPS PHY but it has ISP1507 PHY and uses external

Vbus

Quoted 2 lines

And so it needs extvbus programming (musb_cfg.extvbus =1)in OTG_CTRL register. As for as I know it is not needed for boards using usb PHY on

TPS

Quoted 1 line

device.

Can you clarify what you mean by "not needed for boards using usb PHY on TPS device"?

This comment was more for boards such as Beagle which uses TPS device and Uses internal charge pump of PHY.

Quoted 3 lines

How does that differ from the ISP1507? From what I'm
reading, the ISP1507 does have an integrated 5V charge pump. Or is it simply a matter of how the board is designed?

Correct. OMAP3EVM (Rev-G) doesn't use internal charge pump but external Vbus and thus we need to tell the PHY about this using BUS_CTRL.EXTVBUS Register (Sorry I wrote OTG_CTRL wrongly in previous post)

Quoted 3 lines

(On our custom board, we have added an external vbus supply to be able to draw > 100 mA.)

So it seems you are using PHY inside TPS659x but external Vbus for which I think you need to,
1. Explicitly set "OTG_CTRL.D5 = 0" so that PHY doesn't drive 5V.
2. Do not set musb_cfg.extvbus

I have not seen anyone with this option on TPS PHY so not sure of above Steps would work.

Thanks,
Ajay

Quoted 7 lines

Thanks,
Orjan

--
Orjan Friberg
FlatFrog Laboratories AB

#14 lore raw

PATCH v3 2/4 musb: Add Phy programming for usingexternal Vbus

Quoted 6 lines · Ajay Kumar
Quoted 2 lines

(On our custom board, we have added an external vbus supply to be able to draw> 100 mA.)

So it seems you are using PHY inside TPS659x but external Vbus for which I think you need to,
1. Explicitly set "OTG_CTRL.D5 = 0" so that PHY doesn't drive 5V.
2. Do not set musb_cfg.extvbus

Great, thanks for clarifying (and agreed on all points).

It seems the best I can do is turn off DRVVBUS as soon as the chip has entered host mode (and turned thus it on).

Thanks,
Orjan

Signature · 2 lines
Orjan Friberg
FlatFrog Laboratories AB
#15 lore raw

PATCH v3 1/4 musb: Use name based initialization for musb_config

In reply to Ajay Kumar Gupta

Hi,

2010/6/10 Ajay Kumar Gupta <[email protected]>:

Quoted 8 lines

Changed musb_config initialization for omap3.c, davinci.c and da8xx.c using name of structure fields. This would cause the uninitialized field to be null by default and thus would help in avoiding to init some flags required to be set only for a few selected platforms.

Quoted 7 lines

---
No change from v2.

?drivers/usb/musb/da8xx.c ? | ? ?6 +++---
?drivers/usb/musb/davinci.c | ? ?6 +++---
?drivers/usb/musb/omap3.c ? | ? ?6 +++---

?3 files changed, 9 insertions(+), 9 deletions(-)

Applied to u-boot-usb

Thanks.

Remy