Skip to contentSkip to conversation

musb: am35x: fix compile error due to control apis

PATCH Superseded Ajay Kumar Gupta 10 participants 16 messages Dec 3, 2010 – Dec 30, 2010 5 messages not in the archive

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 musb: am35x: fix compile error due to control apis

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

---
Patch created against today's linus tree.

 arch/arm/mach-omap2/board-am3517evm.c |   13 +++-
 arch/arm/mach-omap2/usb-musb.c        |   79 ++++++++++++++++++++
 arch/arm/plat-omap/include/plat/usb.h |    3 +
 drivers/usb/musb/am35x.c              |  127 ++++++++++-----------------------
 4 files changed, 133 insertions(+), 89 deletions(-)
arch/arm/mach-omap2/board-am3517evm.c +12 -1
index 0739950..da9a70a 100644
@@ -403,7 +403,18 @@ static struct omap_musb_board_data musb_board_data = {
 
 static __init void am3517_evm_musb_init(void)
 {
-	u32 devconf2;
+	u32 devconf2, regval;
+
+	/* Reset the musb interface */
+	regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
+
+	regval |= AM35XX_USBOTGSS_SW_RST;
+	omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
+
+	regval &= ~AM35XX_USBOTGSS_SW_RST;
+	omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
+
+	regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
 
 	/*
 	 * Set up USB clock/mode in the DEVCONF2 register.
arch/arm/mach-omap2/usb-musb.c +79 -0

91 lines not on this page · raw message

arch/arm/plat-omap/include/plat/usb.h +3 -0
index 59c7fe7..4299097 100644
@@ -69,6 +69,9 @@ struct omap_musb_board_data {
 	u8	mode;
 	u16	power;
 	unsigned extvbus:1;
+	void	(*set_phy_power) (u8 on);
+	void	(*clear_irq) (void);
+	void	(*set_mode) (u8 mode);
 };
 
 enum musb_interface    {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
drivers/usb/musb/am35x.c +39 -88

200 lines not on this page · raw message

Signature · 6 lines
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1291399965-19623-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org

#2 lore raw
Quoted 8 lines · Ajay Kumar Gupta

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

---
Patch created against today's linus tree.

I hope this is a short-term fix only; otherwise you will need to duplicate this code in all boards that use an AM3517.

- Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 11 lines
Quoted 8 lines

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

---
Patch created against today's linus tree.

I hope this is a short-term fix only; otherwise you will need to duplicate this code in all boards that use an AM3517.

most of the stuff are in usb-musb.c so can be reused by all the boards. Only the musb reset part is added in board file.

Ajay

Quoted 2 lines

- Anand

#4 lore raw
In reply to Ajay Kumar Gupta

Hello.

Quoted 6 lines · Ajay Kumar Gupta

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

[...]

Quoted 15 lines
arch/arm/mach-omap2/usb-musb.c +7 -0
index 7260558..1f32fdb 100644
@@ -33,6 +33,82 @@
 
 #ifdef CONFIG_USB_MUSB_SOC
 
+static void am35x_musb_phy_power(u8 on)
+{
+	unsigned long timeout = jiffies + msecs_to_jiffies(100);
+	u32 devconf2;
+
+	if (on) {
+		/*

arch/arm/mach-omap2/usb-musb.c line 52

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +10 -0
+		 * Start the on-chip PHY and its PLL.
+		 */
+		devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+		devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN);
+		devconf2 |= CONF2_PHY_PLLON;
+
+		omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+
+		printk(KERN_INFO "Waiting for PHY clock good...\n");

pr_info().

arch/arm/mach-omap2/usb-musb.c line 58

Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6 -0
+		while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2)
+				& CONF2_PHYCLKGD)) {
+			cpu_relax();
+
+			if (time_after(jiffies, timeout)) {
+				printk(KERN_ERR "musb PHY clock good timed out\n");

pr_err().

arch/arm/plat-omap/include/plat/usb.h struct omap_musb_board_data { · line 74

Quoted 11 lines
arch/arm/plat-omap/include/plat/usb.h +3 -0
index 59c7fe7..4299097 100644
@@ -69,6 +69,9 @@ struct omap_musb_board_data {
 	u8	mode;
 	u16	power;
 	unsigned extvbus:1;
+	void	(*set_phy_power) (u8 on);
+	void	(*clear_irq) (void);
+	void	(*set_mode) (u8 mode);

Should be no spaces between ) and (. scripts/checkpatch.pl used to complain
about such things, now it's silent though...

Quoted 21 lines
arch/arm/plat-omap/include/plat/usb.h +3 -13
@@ -364,37 +324,21 @@ eoi:
 
 int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
 {
-	u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+	struct device *dev = musb->controller;
+	struct musb_hdrc_platform_data *plat = dev->platform_data;
+	struct omap_musb_board_data *data = plat->board_data;
 
-	devconf2 &= ~CONF2_OTGMODE;
-	switch (musb_mode) {
-#ifdef	CONFIG_USB_MUSB_HDRC_HCD
-	case MUSB_HOST:		/* Force VBUS valid, ID = 0 */
-		devconf2 |= CONF2_FORCE_HOST;
-		break;
-#endif
-#ifdef	CONFIG_USB_GADGET_MUSB_HDRC
-	case MUSB_PERIPHERAL:	/* Force VBUS valid, ID = 1 */
-		devconf2 |= CONF2_FORCE_DEVICE;
-		break;
-#endif

arch/arm/plat-omap/include/plat/usb.h eoi: · line 332

Quoted 10 lines
arch/arm/plat-omap/include/plat/usb.h +2 -8
-#ifdef	CONFIG_USB_MUSB_OTG
-	case MUSB_OTG:		/* Don't override the VBUS/ID comparators */
-		devconf2 |= CONF2_NO_OVERRIDE;
-		break;
-#endif
-	default:
-		DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
-	}
+	if (data->set_mode)
+		data->set_mode(musb_mode);

You should return -EIO if data->set_mode is NULL.

WBR, Sergei

#5 lore raw
Quoted 20 lines

arch/arm/mach-omap2/usb-

Quoted 1 line
arch/arm/mach-omap2/usb- renamed from arch/arm/mach-omap2/usb-musb.c +0 -0

musb.c

Quoted 18 lines

index 7260558..1f32fdb 100644

arch/arm/mach-omap2/usb-musb.c +11 -0
@@ -33,6 +33,82 @@
 
 #ifdef CONFIG_USB_MUSB_SOC
 
+static void am35x_musb_phy_power(u8 on)
+{
+	unsigned long timeout = jiffies + msecs_to_jiffies(100);
+	u32 devconf2;
+
+	if (on) {
+		/*
+		 * Start the on-chip PHY and its PLL.
+		 */
+		devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
Quoted 8 lines

arch/arm/mach-omap2/usb-musb.c line 52

Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6 -0
+		devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN);
+		devconf2 |= CONF2_PHY_PLLON;
+
+		omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+
+		printk(KERN_INFO "Waiting for PHY clock good...\n");
    pr_info().

This file already uses printk() so used it for uniformity.

Quoted 13 lines

arch/arm/mach-omap2/usb-musb.c

Quoted 7 lines
arch/arm/mach-omap2/usb-musb.c +6 -0
+		while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2)
+				& CONF2_PHYCLKGD)) {
+			cpu_relax();
+
+			if (time_after(jiffies, timeout)) {
+				printk(KERN_ERR "musb PHY clock good timed

out\n");

    pr_err().

arch/arm/plat-

Quoted 1 line
arch/arm/plat- renamed from arch/arm/plat-omap/include/plat/usb.h +0 -0

omap/include/plat/usb.h

Quoted 14 lines

arch/arm/plat-omap/include/plat/usb.h struct omap_musb_board_data { · line 74

Quoted 10 lines

index 59c7fe7..4299097 100644

arch/arm/plat-omap/include/plat/usb.h +3 -0
@@ -69,6 +69,9 @@ struct omap_musb_board_data {
 	u8	mode;
 	u16	power;
 	unsigned extvbus:1;
+	void	(*set_phy_power) (u8 on);
+	void	(*clear_irq) (void);
+	void	(*set_mode) (u8 mode);

Should be no spaces between ) and (. scripts/checkpatch.pl used to
complain
about such things, now it's silent though...

Yes, I tried with ./scripts/checkpatch and didn't get any error/warning.

Quoted 26 lines
Quoted 26 lines
arch/arm/plat-omap/include/plat/usb.h +3 -17
@@ -364,37 +324,21 @@ eoi:
 
 int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
 {
-	u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+	struct device *dev = musb->controller;
+	struct musb_hdrc_platform_data *plat = dev->platform_data;
+	struct omap_musb_board_data *data = plat->board_data;
 
-	devconf2 &= ~CONF2_OTGMODE;
-	switch (musb_mode) {
-#ifdef	CONFIG_USB_MUSB_HDRC_HCD
-	case MUSB_HOST:		/* Force VBUS valid, ID = 0 */
-		devconf2 |= CONF2_FORCE_HOST;
-		break;
-#endif
-#ifdef	CONFIG_USB_GADGET_MUSB_HDRC
-	case MUSB_PERIPHERAL:	/* Force VBUS valid, ID = 1 */
-		devconf2 |= CONF2_FORCE_DEVICE;
-		break;
-#endif
-#ifdef	CONFIG_USB_MUSB_OTG
-	case MUSB_OTG:		/* Don't override the VBUS/ID comparators */
-		devconf2 |= CONF2_NO_OVERRIDE;
-		break;
Quoted 8 lines

arch/arm/plat-omap/include/plat/usb.h eoi: · line 332

Quoted 6 lines
arch/arm/plat-omap/include/plat/usb.h +2 -4
-#endif
-	default:
-		DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
-	}
+	if (data->set_mode)
+		data->set_mode(musb_mode);
    You should return -EIO if data->set_mode is NULL.

Ok fine...

Ajay

Quoted 2 lines

WBR, Sergei

#6 lore raw
In reply to Ajay Kumar Gupta
Quoted 5 lines · Ajay Kumar Gupta

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

Is this change slated to go into 2.6.37? As it stands it looks like 2.6.37 will be released with completely broken musb support on many boards (including the BeagleBoard).

- Ben

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 9 lines · Ben Gamari
Quoted 5 lines · Ajay Kumar Gupta

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

Is this change slated to go into 2.6.37? As it stands it looks like 2.6.37 will be released with completely broken musb support on many boards (including the BeagleBoard).

yes, it is.

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20101227092038.GB2301-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#10 lore raw
Quoted 7 lines · Felipe Balbi
Quoted 3 lines · Ben Gamari

Is this change slated to go into 2.6.37? As it stands it looks like 2.6.37 will be released with completely broken musb support on many boards (including the BeagleBoard).

yes, it is.

Are you sure? We are currently at -rc8 and yet this patch has yet to make it into my tree.

- Ben
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 10 lines · Ben Gamari
Quoted 7 lines · Felipe Balbi
Quoted 3 lines · Ben Gamari

Is this change slated to go into 2.6.37? As it stands it looks like 2.6.37 will be released with completely broken musb support on many boards (including the BeagleBoard).

yes, it is.

Are you sure? We are currently at -rc8 and yet this patch has yet to make it into my tree.

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

Hello.

Quoted 11 lines · Felipe Balbi
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Is this change slated to go into 2.6.37? As it stands it looks like 2.6.37 will be released with completely broken musb support on many boards (including the BeagleBoard).

yes, it is.

Are you sure? We are currently at -rc8 and yet this patch has yet to make it into my tree.

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

And yet he was asking you about 2.6.37. :-)

WBR, Sergei

#14 lore raw
In reply to Felipe Balbi
Quoted 3 lines · Felipe Balbi

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

So I guess no working USB in 2.6.37 in that case?

- Ben

#15 lore raw
Quoted 5 lines · Ben Gamari
Quoted 3 lines · Felipe Balbi

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

So I guess no working USB in 2.6.37 in that case?

You can ask Greg to make an pull request, or mail Linus directly. It is an driver, and Linus will accept patches that makes drivers work.

A message that is not in the archive (sent off-list or not yet received): AANLkTinE9Dgz9nCFv-1d=DdF22OEXSYn16s7krxo3CGp-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#17 lore raw
Quoted 9 lines · Anca Emanuel
Quoted 5 lines · Ben Gamari
Quoted 3 lines · Felipe Balbi

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

So I guess no working USB in 2.6.37 in that case?

You can ask Greg to make an pull request, or mail Linus directly. It is an driver, and Linus will accept patches that makes drivers work.

Don't do that. I'll back port the changes to 2.6.37-stable. If you do any such thing you'll break the changes which are on Greg's queue. Sorry

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#18 lore raw
In reply to Ben Gamari
Quoted 5 lines · Ben Gamari
Quoted 3 lines · Felipe Balbi

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

So I guess no working USB in 2.6.37 in that case?

For am35x, I guess not. All in all, it was a change to omap's arch code which "broke" am35x in the first place. Well, the driver shouldn't be using that header anyway.

Signature · 1 line
balbi
#19 lore raw

Hello.

Quoted 8 lines · Felipe Balbi
Quoted 4 lines
Quoted 2 lines

Yes. The patch is waiting for the merge window, check linux-next or Greg's usb-next branch.

So I guess no working USB in 2.6.37 in that case?

For am35x, I guess not. All in all, it was a change to omap's arch code which "broke" am35x in the first place. Well, the driver shouldn't be using that header anyway.

This was a dubious decision, IMHO. It would have been better to accept the
initial patch to make things compile in 2.6.37, and then do the big change for 2.6.38...

WBR, Sergei

#20 lore raw
In reply to Ajay Kumar Gupta
Quoted 5 lines · Ajay Kumar Gupta

As the control.h have been moved to new location and it's uses are not allowed to drivers directly so moving the phy control, interrupt clear and reset functionality to board files.

I could have sworn I tried applying this before but I guess I must be wrong. Perhaps I am missing something?

CC arch/arm/mach-omap2/usb-musb.o
arch/arm/mach-omap2/usb-musb.c: In function ‘am35x_musb_phy_power’:
arch/arm/mach-omap2/usb-musb.c:45: error: implicit declaration of function ‘omap_ctrl_readl’ arch/arm/mach-omap2/usb-musb.c:45: error: ‘AM35XX_CONTROL_DEVCONF2’ undeclared (first use in this function) arch/arm/mach-omap2/usb-musb.c:45: error: (Each undeclared identifier is reported only once arch/arm/mach-omap2/usb-musb.c:45: error: for each function it appears in.) arch/arm/mach-omap2/usb-musb.c:50: error: implicit declaration of function ‘omap_ctrl_writel’ arch/arm/mach-omap2/usb-musb.c: In function ‘am35x_musb_clear_irq’:
arch/arm/mach-omap2/usb-musb.c:78: error: ‘AM35XX_CONTROL_LVL_INTR_CLEAR’ undeclared (first use in this function) arch/arm/mach-omap2/usb-musb.c:79: error: ‘AM35XX_USBOTGSS_INT_CLR’ undeclared (first use in this function) arch/arm/mach-omap2/usb-musb.c: In function ‘am35x_musb_set_mode’:
arch/arm/mach-omap2/usb-musb.c:86: error: ‘AM35XX_CONTROL_DEVCONF2’ undeclared (first use in this function) arch/arm/mach-omap2/usb-musb.c: In function ‘usb_musb_init’:
arch/arm/mach-omap2/usb-musb.c:175: error: expected expression before ‘}’ token

- Ben
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html