Skip to contentSkip to conversation

Make mv_udc work for i.mx6

PATCH Superseded Troy Kisky 2 participants 48 messages Sep 20, 2013 – Sep 23, 2013

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Troy Kisky

author
#0 lore raw

v4 cover Make mv_udc work for i.mx6

Hi Marek, Stefano

Sorry, for the long delay between postings.

This series is based on u-boot-usb/master branch. After this series, nitrogen6x works with tftpboot to transfer files over usb, and will recognize a usb stick in the OTG port.

This V4 has been rebased to the latest u-boot-usb/master branch and changed to address Marek comments.

The most noticeable change is the addition of
"add support for host mode otg port"

Stefano, if you would you like to take the last 3 patches, there should not be a problem.

The patches are mostly independent, so if a patch has
an issue, please feel free to skip it.
An exception is 1/17 should be before 2/17 if Stefano's branch merges upstream first, otherwise nitrogen6x will get a build error.

Thanks

Troy Kisky (17):
usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT
usb: ehci-mx6: add support for host mode otg port
usb: gadget: ether set wMaxPacketSize
usb: gadget: ether: return error from rx_submit if no request
usb: gadget: mv_udc: split mv_udc.h file
usb: udc: add udc.h include file
usb: gadget: mv_udc: fix typo in error message
usb: gadget: mv_udc: set is_dualspeed = 1
usb: gadget: mv_udc: fix full speed connections
usb: gadget: mv_udc: optimize bounce
usb: gadget: mv_udc: flush item before head
usb: gadget: mv_udc: optimize ep_enable
usb: gadget: mv_udc: zero transfer descriptor memory on probe
usb: gadget: mv_udc: clear desc upon ep_disable
mx6: iomux: add GPR1 defines for use with nitrogen6x
nitrogen6x: add otg usb host/device mode support
nitrogen6x: add CONFIG_MV_UDC

 arch/arm/include/asm/arch-mx6/iomux.h  |   6 ++
 board/boundary/nitrogen6x/nitrogen6x.c |  33 ++++++++
 drivers/serial/usbtty.h                |   3 +-
 drivers/usb/gadget/designware_udc.c    |   1 +
 drivers/usb/gadget/ether.c             |   4 +
 drivers/usb/gadget/mpc8xx_udc.c        |   1 +
 drivers/usb/gadget/mv_udc.c            | 113 ++++++++++++++++-----------
 drivers/usb/gadget/mv_udc.h            | 115 ++++++++++++++++++++++++++++
 drivers/usb/gadget/omap1510_udc.c      |   1 +
 drivers/usb/gadget/pxa27x_udc.c        |   1 +
 drivers/usb/host/ehci-hcd.c            |   7 ++
 drivers/usb/host/ehci-mx6.c            | 135 +++++++++++++++++++++++----------
 drivers/usb/musb/musb_udc.c            |   3 +-
 include/configs/mx6qsabreauto.h        |   2 +-
 include/configs/nitrogen6x.h           |   8 +-
 include/usb/designware_udc.h           |  31 --------
 include/usb/mpc8xx_udc.h               |  19 +----
 include/usb/musb_udc.h                 |  40 ----------
 include/usb/mv_udc.h                   | 118 ----------------------------
 include/usb/omap1510_udc.h             |  27 +------
 include/usb/pxa27x_udc.h               |  26 +------
 include/usb/udc.h                      |  61 +++++++++++++++
 22 files changed, 409 insertions(+), 346 deletions(-)
 create mode 100644 drivers/usb/gadget/mv_udc.h
 delete mode 100644 include/usb/musb_udc.h
 create mode 100644 include/usb/udc.h
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

---
v4: new patch

---
 drivers/usb/gadget/mv_udc.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/usb/gadget/mv_udc.c +0 -4
index 7574e31..b87119c 100644
@@ -17,10 +17,6 @@
 #include <linux/types.h>
 #include <usb/mv_udc.h>
 
-#if CONFIG_USB_MAX_CONTROLLER_COUNT > 1
-#error This driver only supports one single controller.
-#endif
-
 /*
  * Check if the system has too long cachelines. If the cachelines are
  * longer then 128b, the driver will not be able flush/invalidate data
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Dear Troy Kisky,

Quoted 6 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Best regards,
Marek Vasut

author
#3 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Quoted 6 lines · Marek Vasut

Dear Troy Kisky,

Quoted 4 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

Quoted 9 lines
Quoted 2 lines

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Best regards,
Marek Vasut

The next patch checks the OTG id before switching to host mode. If it is grounded, then it enters
host mode, otherwise it doesn't. But, running 'usb reset' on a netconsole may kill your connection.
I haven't tested that. Do you have a suggestion to fix that? I've been testing with tftp transfers only.

Thanks
Troy

#4 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Dear Troy Kisky,

Quoted 13 lines · Marek Vasut
Quoted 12 lines

Dear Troy Kisky,

Quoted 5 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Quoted 7 lines
Quoted 2 lines

Best regards,
Marek Vasut

The next patch checks the OTG id before switching to host mode. If it is grounded, then it enters
host mode, otherwise it doesn't. But, running 'usb reset' on a netconsole may kill your connection.

It won't if you properly ignore rhis one controller depending on the OTG pin then, no ?

Quoted 5 lines

I haven't tested that. Do you have a suggestion to fix that? I've been testing with tftp transfers only.

Thanks
Troy

Best regards,
Marek Vasut

author
#5 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Quoted 14 lines · Marek Vasut

Dear Troy Kisky,

Quoted 12 lines · Marek Vasut
Quoted 11 lines

Dear Troy Kisky,

Quoted 5 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Best regards,
Marek Vasut

The next patch checks the OTG id before switching to host mode. If it is grounded, then it enters
host mode, otherwise it doesn't. But, running 'usb reset' on a netconsole may kill your connection.

It won't if you properly ignore rhis one controller depending on the OTG pin then, no ?

I can return an error code from ehci_hcd_init, so that ehci_reset will not be called. But then
usb_lowlevel_init will also return an error, which is good for the call from usb_init, but bad
for the call in usb_gadget_register_driver.

Perhaps I should return a 1, instead of 0, when the otg_id pin is high? And check for < 0
before aborting from usb_gadget_register_driver ?

Thanks
Troy

author
#6 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Quoted 32 lines · Troy Kisky
Quoted 16 lines · Marek Vasut

Dear Troy Kisky,

Quoted 14 lines · Marek Vasut
Quoted 13 lines

Dear Troy Kisky,

Quoted 5 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Best regards,
Marek Vasut

Quoted 9 lines
Quoted 5 lines

The next patch checks the OTG id before switching to host mode. If it is
grounded, then it enters
host mode, otherwise it doesn't. But, running 'usb reset' on a netconsole may kill your connection.

It won't if you properly ignore rhis one controller depending on the OTG pin
then, no ?

I can return an error code from ehci_hcd_init, so that ehci_reset will not be called. But then
usb_lowlevel_init will also return an error, which is good for the call from usb_init, but bad
for the call in usb_gadget_register_driver.

Quoted 9 lines

Perhaps I should return a 1, instead of 0, when the otg_id pin is high? And check for < 0
before aborting from usb_gadget_register_driver ?

Thanks
Troy

Or maybe add a parameter to usb_lowlevel_init specifying if I desire host or device mode?

Thanks
Troy

#7 lore raw

PATCH v4 1/17 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT

Dear Troy Kisky,

Quoted 40 lines · Troy Kisky
Quoted 39 lines · Marek Vasut
Quoted 24 lines

Dear Troy Kisky,

Quoted 13 lines · Marek Vasut
Quoted 12 lines

Dear Troy Kisky,

Quoted 5 lines

i.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.

The problem is, will the 3 additional ports still work? I suspect they will, but then if you run 'usb reset', the gadget port will also be switched back into USB Host function, no

Quoted 8 lines
Quoted 2 lines

Best regards,
Marek Vasut

The next patch checks the OTG id before switching to host mode. If it is
grounded, then it enters
host mode, otherwise it doesn't. But, running 'usb reset' on a netconsole may kill your connection.

Quoted 3 lines

It won't if you properly ignore rhis one controller depending on the OTG pin
then, no ?

I can return an error code from ehci_hcd_init, so that ehci_reset will not be called. But then
usb_lowlevel_init will also return an error, which is good for the call from usb_init, but bad
for the call in usb_gadget_register_driver.

Perhaps I should return a 1, instead of 0, when the otg_id pin is high? And check for < 0
before aborting from usb_gadget_register_driver ?

Quoted 5 lines
Quoted 2 lines

Thanks
Troy

Or maybe add a parameter to usb_lowlevel_init specifying if I desire host or device mode?

Check

[PATCH v4] usb: new board-specific USB init interface

That might give you some ideas.

Best regards,
Marek Vasut

author
#8 lore raw

PATCH v4 2/17 usb: ehci-mx6: add support for host mode otg port

In reply to Troy Kisky

Previously, only host1 was supported using an index of 0. Now, otg has index 0, host1 is 1, host2 is 2, host3 is 3. Since OTG requires usbmode to be set after reset, I added a weak function ehci_hcd_init_after_reset to handle this, and removed it from ehci_hcd_init. I also added a weak function board_ehci_power to handle turning power on/off for otg.

---
V4: new patch, replaces "usb: gadget: mv_udc: fix hardware udc address for i.MX6" and has the bonus of giving OTG host mode support

---
 drivers/usb/host/ehci-hcd.c     |   7 +++
 drivers/usb/host/ehci-mx6.c     | 135 ++++++++++++++++++++++++++++------------
 include/configs/mx6qsabreauto.h |   2 +-
 include/configs/nitrogen6x.h    |   2 +-
 4 files changed, 105 insertions(+), 41 deletions(-)
drivers/usb/host/ehci-hcd.c +7 -0
index fdad739..3c570ef 100644
@@ -881,6 +881,11 @@ int usb_lowlevel_stop(int index)
 	return ehci_hcd_stop(index);
 }
 
+int __weak ehci_hcd_init_after_reset(int index)
+{
+	return 0;
+}
+
 int usb_lowlevel_init(int index, void **controller)
 {
 	uint32_t reg;
@@ -900,6 +905,8 @@ int usb_lowlevel_init(int index, void **controller)
 	if (ehci_hcd_init(index, &ehcic[index].hccr, &ehcic[index].hcor))
 		return -1;
 #endif
+	ehci_hcd_init_after_reset(index);
+
 	/* Set the high address word (aka segment) for 64-bit controller */
 	if (ehci_readl(&ehcic[index].hccr->cr_hccparams) & 1)
 		ehci_writel(ehcic[index].hcor->or_ctrldssegment, 0);
drivers/usb/host/ehci-mx6.c +96 -39

216 lines not on this page · raw message

include/configs/mx6qsabreauto.h +1 -1
index 5530fc6..805c7be 100644
@@ -23,7 +23,7 @@
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_ASIX
-#define CONFIG_MXC_USB_PORT	1
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
 #define CONFIG_MXC_USB_PORTSC	(PORT_PTS_UTMI | PORT_PTS_PTW)
 #define CONFIG_MXC_USB_FLAGS	0
 
include/configs/nitrogen6x.h +1 -1
index 3454b86..b1ca91e 100644
@@ -119,7 +119,7 @@
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_ASIX
 #define CONFIG_USB_ETHER_SMSC95XX
-#define CONFIG_MXC_USB_PORT	1
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
 #define CONFIG_MXC_USB_PORTSC	(PORT_PTS_UTMI | PORT_PTS_PTW)
 #define CONFIG_MXC_USB_FLAGS	0
 
Signature · 1 line
1.8.1.2
#9 lore raw

PATCH v4 2/17 usb: ehci-mx6: add support for host mode otg port

Dear Troy Kisky,

Quoted 8 lines

Previously, only host1 was supported using an index of 0. Now, otg has index 0, host1 is 1, host2 is 2, host3 is 3. Since OTG requires usbmode to be set after reset, I added a weak function ehci_hcd_init_after_reset to handle this, and removed it from ehci_hcd_init. I also added a weak function board_ehci_power to handle turning power on/off for otg.

Quoted 6 lines

---
V4: new patch, replaces "usb: gadget: mv_udc: fix hardware udc address for i.MX6" and has the bonus of giving OTG host mode support
---

Would it be a problem to implement this in ehci_hcd_init() call instead of adding a new call?

Best regards,
Marek Vasut

author
#10 lore raw

PATCH v4 2/17 usb: ehci-mx6: add support for host mode otg port

Quoted 16 lines · Marek Vasut

Dear Troy Kisky,

Quoted 8 lines

Previously, only host1 was supported using an index of 0. Now, otg has index 0, host1 is 1, host2 is 2, host3 is 3. Since OTG requires usbmode to be set after reset, I added a weak function ehci_hcd_init_after_reset to handle this, and removed it from ehci_hcd_init. I also added a weak function board_ehci_power to handle turning power on/off for otg.

Quoted 6 lines

---
V4: new patch, replaces "usb: gadget: mv_udc: fix hardware udc address for i.MX6" and has the bonus of giving OTG host mode support
---

Quoted 6 lines

Would it be a problem to implement this in ehci_hcd_init() call instead of adding a new call?

Best regards,
Marek Vasut

Maybe. I could try defining CONFIG_EHCI_HCD_INIT_AFTER_RESET and see if anything breaks.
Although, I suspect the processor may hang if the clocks aren't setup before ehci_reset.
I'll give it a try and let you know.

Thanks
Troy

author
#11 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

In reply to Troy Kisky

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

---
v4: expanded commit message

---
 drivers/usb/gadget/ether.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/ether.c +2 -0
index 700d5fb..988cffb 100644
@@ -635,6 +635,7 @@ fs_source_desc = {
 
 	.bEndpointAddress =	USB_DIR_IN,
 	.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize =	__constant_cpu_to_le16(64),
 };
 
 static struct usb_endpoint_descriptor
@@ -644,6 +645,7 @@ fs_sink_desc = {
 
 	.bEndpointAddress =	USB_DIR_OUT,
 	.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize =	__constant_cpu_to_le16(64),
 };
 
 static const struct usb_descriptor_header *fs_eth_function[11] = {
Signature · 1 line
1.8.1.2
#12 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

Dear Troy Kisky,

Quoted 10 lines

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

Why do we need this patch? What issue does this fix ?

Best regards,
Marek Vasut

author
#13 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

Quoted 8 lines · Marek Vasut

Dear Troy Kisky,

Quoted 6 lines

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

Quoted 9 lines
Quoted 4 lines

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

Why do we need this patch? What issue does this fix ?

Best regards,
Marek Vasut

I could try full speed mode without this and see how linux behaves when given bad data,
but that would not says anything about other O.S.es. It seems safer just not to give out
bad data.

Troy

#14 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

Dear Troy Kisky,

Quoted 16 lines · Marek Vasut
Quoted 15 lines

Dear Troy Kisky,

Quoted 10 lines

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

Why do we need this patch? What issue does this fix ?

Quoted 8 lines
Quoted 2 lines

Best regards,
Marek Vasut

I could try full speed mode without this and see how linux behaves when given bad data,
but that would not says anything about other O.S.es. It seems safer just not to give out
bad data.

Certainly. Will this not cause issues with the MPC8xx controller and OMAP1510 controller?

Best regards,
Marek Vasut

author
#15 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

Quoted 24 lines · Marek Vasut

Dear Troy Kisky,

Quoted 15 lines · Marek Vasut
Quoted 14 lines

Dear Troy Kisky,

Quoted 10 lines

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

Why do we need this patch? What issue does this fix ?

Quoted 7 lines
Quoted 2 lines

Best regards,
Marek Vasut

I could try full speed mode without this and see how linux behaves when given bad data,
but that would not says anything about other O.S.es. It seems safer just not to give out
bad data.

Quoted 6 lines

Certainly. Will this not cause issues with the MPC8xx controller and OMAP1510 controller?

Best regards,
Marek Vasut

Good point. ether.c is compiled when CONFIG_USB_ETHER is set. And omap1510_udc.c, mpc8xx_udc.c will only be compiled when CONFIG_USB_ETHER is NOT set.

So, not a issue at present. I doubt anyone will upgrade these old boards to support CONFIG_USB_ETHER.

Thanks
Troy

#16 lore raw

PATCH v4 3/17 usb: gadget: ether set wMaxPacketSize

Dear Troy Kisky,

Quoted 35 lines · Marek Vasut
Quoted 28 lines

Dear Troy Kisky,

Quoted 17 lines · Marek Vasut
Quoted 16 lines

Dear Troy Kisky,

Quoted 11 lines

set wMaxPacketSize for full speed descriptors
fs_source_desc, fs_sink_desc to 64.

Full-speed bulk endpoint can have a maximum packet size of 8, 16, 32, or 64 bytes, so choice 64.

The hs_source_desc, hs_sink_desc, already have their wMaxPacketSize set to 512. That is the only legal value for high speed bulk endpoints.

Why do we need this patch? What issue does this fix ?

Quoted 8 lines
Quoted 2 lines

Best regards,
Marek Vasut

I could try full speed mode without this and see how linux behaves when given bad data,
but that would not says anything about other O.S.es. It seems safer just not to give out
bad data.

Quoted 5 lines

Certainly. Will this not cause issues with the MPC8xx controller and OMAP1510 controller?

Best regards,
Marek Vasut

Quoted 7 lines

Good point. ether.c is compiled when CONFIG_USB_ETHER is set. And omap1510_udc.c, mpc8xx_udc.c will only be compiled when CONFIG_USB_ETHER is NOT set.

So, not a issue at present. I doubt anyone will upgrade these old boards to support CONFIG_USB_ETHER.

Did you manage to get any feedback from the OMAP1 and MPC8xx guys on the USB topic?

btw. it might be actually better to split out the MX6 fixes and general USB fixes so the MX6 ones can go in before the rest.

Best regards,
Marek Vasut

author
#17 lore raw

PATCH v4 4/17 usb: gadget: ether: return error from rx_submit if no request

In reply to Troy Kisky

This prevents a crash if tftpboot is given a bad filename.

rx_req will be released by eth_reset_config
which is called by eth_disconnect,
which is called using the .disconnect member of usb_gadget_driver by mv_pullup in mv_udc which is called using the .pullup member of usb_gadget_ops by usb_gadget_disconnect which is called by usb_eth_halt
which is called using the .halt member of eth_device by eth_halt
which is called by TftpHandler when TFTP_ERR_FILE_NOT_FOUND or TFTP_ERR_ACCESS_DENIED occurs

---
v4: expanded commit message

---
 drivers/usb/gadget/ether.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/ether.c +2 -0
index 988cffb..cc6cc1f 100644
@@ -1536,6 +1536,8 @@ static int rx_submit(struct eth_dev *dev, struct usb_request *req,
 	 */
 
 	debug("%s\n", __func__);
+	if (!req)
+		return -EINVAL;
 
 	size = (ETHER_HDR_SIZE + dev->mtu + RX_EXTRA);
 	size += dev->out_ep->maxpacket - 1;
Signature · 1 line
1.8.1.2
#18 lore raw

PATCH v4 4/17 usb: gadget: ether: return error from rx_submit if no request

Dear Troy Kisky,

Quoted 11 lines

This prevents a crash if tftpboot is given a bad filename.

rx_req will be released by eth_reset_config
which is called by eth_disconnect,
which is called using the .disconnect member of usb_gadget_driver by mv_pullup in mv_udc which is called using the .pullup member of usb_gadget_ops by usb_gadget_disconnect which is called by usb_eth_halt which is called using the .halt member of eth_device by eth_halt which is called by TftpHandler when TFTP_ERR_FILE_NOT_FOUND or TFTP_ERR_ACCESS_DENIED occurs

Quoted 2 lines

How do I trigger this? It'd be nice to have a test-case in the commit message.

Best regards,
Marek Vasut

author
#19 lore raw

PATCH v4 5/17 usb: gadget: mv_udc: split mv_udc.h file

In reply to Troy Kisky

Move defines only needed by mv_udc.c to a file
in the same directory.

This allows usbtty to compile for mv_udc,
but it still doesn't link.

---
v4: unchanged

---
 drivers/usb/gadget/mv_udc.c |   6 +++
 drivers/usb/gadget/mv_udc.h | 115 ++++++++++++++++++++++++++++++++++++++++++
 include/usb/mv_udc.h        | 118 --------------------------------------------
 3 files changed, 121 insertions(+), 118 deletions(-)
 create mode 100644 drivers/usb/gadget/mv_udc.h
drivers/usb/gadget/mv_udc.c +6 -0
index b87119c..322c04f 100644
@@ -13,9 +13,15 @@
 #include <config.h>
 #include <net.h>
 #include <malloc.h>
+#include <asm/byteorder.h>
 #include <asm/io.h>
+#include <asm/errno.h>
 #include <linux/types.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
 #include <usb/mv_udc.h>
+#include "../host/ehci.h"
+#include "mv_udc.h"
 
 /*
  * Check if the system has too long cachelines. If the cachelines are
drivers/usb/gadget/mv_udc.h new file +115 -0

115 lines not on this page · raw message

include/usb/mv_udc.h +0 -118

124 lines not on this page · raw message

Signature · 1 line
1.8.1.2
author
#20 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

In reply to Troy Kisky

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

---
 drivers/serial/usbtty.h             |  3 +-
 drivers/usb/gadget/designware_udc.c |  1 +
 drivers/usb/gadget/mpc8xx_udc.c     |  1 +
 drivers/usb/gadget/omap1510_udc.c   |  1 +
 drivers/usb/gadget/pxa27x_udc.c     |  1 +
 drivers/usb/musb/musb_udc.c         |  3 +-
 include/usb/designware_udc.h        | 31 -------------------
 include/usb/mpc8xx_udc.h            | 19 +-----------
 include/usb/musb_udc.h              | 40 ------------------------
 include/usb/omap1510_udc.h          | 27 ++--------------
 include/usb/pxa27x_udc.h            | 26 +---------------
 include/usb/udc.h                   | 61 +++++++++++++++++++++++++++++++++++++
 12 files changed, 73 insertions(+), 141 deletions(-)
 delete mode 100644 include/usb/musb_udc.h
 create mode 100644 include/usb/udc.h
drivers/serial/usbtty.h +1 -2
index e243a8e..819dec6 100644
@@ -16,8 +16,6 @@
 #include <usb/mpc8xx_udc.h>
 #elif defined(CONFIG_OMAP1510)
 #include <usb/omap1510_udc.h>
-#elif defined(CONFIG_MUSB_UDC)
-#include <usb/musb_udc.h>
 #elif defined(CONFIG_CPU_PXA27X)
 #include <usb/pxa27x_udc.h>
 #elif defined(CONFIG_DW_UDC)
@@ -26,6 +24,7 @@
 #include <usb/mv_udc.h>
 #endif
 
+#include <usb/udc.h>
 #include <version.h>
 
 /* If no VendorID/ProductID is defined in config.h, pretend to be Linux
drivers/usb/gadget/designware_udc.c +1 -0
index 1aab31b..b7c1038 100644
@@ -14,6 +14,7 @@
 #include <usbdevice.h>
 #include "ep0.h"
 #include <usb/designware_udc.h>
+#include <usb/udc.h>
 #include <asm/arch/hardware.h>
 
 #define UDC_INIT_MDELAY		80	/* Device settle delay */
drivers/usb/gadget/mpc8xx_udc.c +1 -0
index 0207d39..7f72972 100644
@@ -47,6 +47,7 @@
 #include <commproc.h>
 #include <usbdevice.h>
 #include <usb/mpc8xx_udc.h>
+#include <usb/udc.h>
 
 #include "ep0.h"
 
drivers/usb/gadget/omap1510_udc.c +1 -0
index 8553fe5..bdc1b88 100644
@@ -20,6 +20,7 @@
 #endif
 #include <usbdevice.h>
 #include <usb/omap1510_udc.h>
+#include <usb/udc.h>
 
 #include "ep0.h"
 
drivers/usb/gadget/pxa27x_udc.c +1 -0
index 05d1b56..733558d 100644
@@ -16,6 +16,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/io.h>
 #include <usb/pxa27x_udc.h>
+#include <usb/udc.h>
 
 #include "ep0.h"
 
drivers/usb/musb/musb_udc.c +2 -1
index 3e3e05e..87640f4 100644
@@ -39,7 +39,8 @@
  */
 
 #include <common.h>
-#include <usb/musb_udc.h>
+#include <usbdevice.h>
+#include <usb/udc.h>
 #include "../gadget/ep0.h"
 #include "musb_core.h"
 #if defined(CONFIG_USB_OMAP3)
include/usb/designware_udc.h +0 -31
index 2e29a7e..2e1cdf1 100644
@@ -174,19 +174,6 @@ struct udcfifo_regs {
 };
 
 /*
- * USBTTY definitions
- */
-#define  EP0_MAX_PACKET_SIZE		64
-#define  UDC_INT_ENDPOINT		1
-#define  UDC_INT_PACKET_SIZE		64
-#define  UDC_OUT_ENDPOINT		2
-#define  UDC_BULK_PACKET_SIZE		64
-#define  UDC_BULK_HS_PACKET_SIZE	512
-#define  UDC_IN_ENDPOINT		3
-#define  UDC_OUT_PACKET_SIZE		64
-#define  UDC_IN_PACKET_SIZE		64
-
-/*
  * UDC endpoint definitions
  */
 #define  UDC_EP0			0
@@ -194,22 +181,4 @@ struct udcfifo_regs {
 #define  UDC_EP2			2
 #define  UDC_EP3			3
 
-/*
- * Function declarations
- */
-
-void udc_irq(void);
-
-void udc_set_nak(int epid);
-void udc_unset_nak(int epid);
-int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
-int udc_init(void);
-void udc_enable(struct usb_device_instance *device);
-void udc_disable(void);
-void udc_connect(void);
-void udc_disconnect(void);
-void udc_startup_events(struct usb_device_instance *device);
-void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
-		  struct usb_endpoint_instance *endpoint);
-
 #endif /* __DW_UDC_H */
include/usb/mpc8xx_udc.h +1 -18
index 475dd41..9906c75 100644
@@ -111,11 +111,9 @@
 
 /* UDC device defines */
 #define EP0_MAX_PACKET_SIZE	EP_MAX_PKT
-#define UDC_OUT_ENDPOINT	0x02
+
 #define UDC_OUT_PACKET_SIZE	EP_MIN_PACKET_SIZE
-#define UDC_IN_ENDPOINT		0x03
 #define UDC_IN_PACKET_SIZE	EP_MIN_PACKET_SIZE
-#define UDC_INT_ENDPOINT	0x01
 #define UDC_INT_PACKET_SIZE	UDC_IN_PACKET_SIZE
 #define UDC_BULK_PACKET_SIZE	EP_MIN_PACKET_SIZE
 
@@ -178,18 +176,3 @@ typedef enum mpc8xx_udc_state{
 	STATE_READY,
 }mpc8xx_udc_state_t;
 
-/* Declarations */
-int udc_init(void);
-void udc_irq(void);
-int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
-void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
-		  struct usb_endpoint_instance *endpoint);
-void udc_connect(void);
-void udc_disconnect(void);
-void udc_enable(struct usb_device_instance *device);
-void udc_disable(void);
-void udc_startup_events(struct usb_device_instance *device);
-
-/* Flow control */
-void udc_set_nak(int epid);
-void udc_unset_nak (int epid);
include/usb/musb_udc.h deleted +0 -40
deleted file mode 100644
index 3500c7a..0000000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2009 Wind River Systems, Inc.
- * Tom Rix <[email protected]>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-#ifndef __MUSB_UDC_H__
-#define __MUSB_UDC_H__
-
-#include <usbdevice.h>
-
-/* UDC level routines */
-void udc_irq(void);
-void udc_set_nak(int ep_num);
-void udc_unset_nak(int ep_num);
-int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
-void udc_setup_ep(struct usb_device_instance *device, unsigned int id,
-		  struct usb_endpoint_instance *endpoint);
-void udc_connect(void);
-void udc_disconnect(void);
-void udc_enable(struct usb_device_instance *device);
-void udc_disable(void);
-void udc_startup_events(struct usb_device_instance *device);
-int udc_init(void);
-
-/* usbtty */
-#ifdef CONFIG_USB_TTY
-
-#define EP0_MAX_PACKET_SIZE	64 /* MUSB_EP0_FIFOSIZE */
-#define UDC_INT_ENDPOINT	1
-#define UDC_INT_PACKET_SIZE	64
-#define UDC_OUT_ENDPOINT	2
-#define UDC_OUT_PACKET_SIZE	64
-#define UDC_IN_ENDPOINT		3
-#define UDC_IN_PACKET_SIZE	64
-#define UDC_BULK_PACKET_SIZE	64
-
-#endif /* CONFIG_USB_TTY */
-
-#endif /* __MUSB_UDC_H__ */
include/usb/omap1510_udc.h +3 -24
index ece0e95..934930b 100644
@@ -162,32 +162,11 @@
 #define UDC_VBUS_MODE	    (1 << 18)
 
 /* OMAP Endpoint parameters */
-#define EP0_MAX_PACKET_SIZE 64
-#define UDC_OUT_ENDPOINT 2
-#define UDC_OUT_PACKET_SIZE 64
-#define UDC_IN_ENDPOINT	1
-#define UDC_IN_PACKET_SIZE 64
-#define UDC_INT_ENDPOINT 5
 #define UDC_INT_PACKET_SIZE	16
 #define UDC_BULK_PACKET_SIZE 16
 
-void udc_irq (void);
-/* Flow control */
-void udc_set_nak(int epid);
-void udc_unset_nak (int epid);
-
-/* Higher level functions for abstracting away from specific device */
-int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
-
-int  udc_init (void);
-
-void udc_enable(struct usb_device_instance *device);
-void udc_disable(void);
-
-void udc_connect(void);
-void udc_disconnect(void);
-
-void udc_startup_events(struct usb_device_instance *device);
-void udc_setup_ep(struct usb_device_instance *device, unsigned int ep, struct usb_endpoint_instance *endpoint);
+#define UDC_INT_ENDPOINT 5
+#define UDC_OUT_ENDPOINT 2
+#define UDC_IN_ENDPOINT	1
 
 #endif
include/usb/pxa27x_udc.h +1 -25
index 7fdbe2a..7eaa000 100644
@@ -22,35 +22,11 @@
 
 /* Endpoint parameters */
 #define MAX_ENDPOINTS		4
-#define EP_MAX_PACKET_SIZE	64
 
 #define EP0_MAX_PACKET_SIZE     16
+
 #define UDC_OUT_ENDPOINT        0x02
-#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
 #define UDC_IN_ENDPOINT         0x01
-#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
 #define UDC_INT_ENDPOINT        0x05
-#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
-#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
-
-void udc_irq(void);
-/* Flow control */
-void udc_set_nak(int epid);
-void udc_unset_nak(int epid);
-
-/* Higher level functions for abstracting away from specific device */
-int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
-
-int  udc_init(void);
-
-void udc_enable(struct usb_device_instance *device);
-void udc_disable(void);
-
-void udc_connect(void);
-void udc_disconnect(void);
-
-void udc_startup_events(struct usb_device_instance *device);
-void udc_setup_ep(struct usb_device_instance *device,
-	 unsigned int ep, struct usb_endpoint_instance *endpoint);
 
 #endif
include/usb/udc.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#21 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 26 lines

#endif

include/usb/udc.h new file +19 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE

include/usb/udc.h line 29

Quoted 10 lines
include/usb/udc.h new file +10 -0
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

include/usb/udc.h line 43

Quoted 13 lines
include/usb/udc.h new file +13 -0
+#define UDC_BULK_HS_PACKET_SIZE	512
+
+#ifndef UDC_INT_ENDPOINT
+#define UDC_INT_ENDPOINT	1
+#endif
+
+#ifndef UDC_OUT_ENDPOINT
+#define UDC_OUT_ENDPOINT	2
+#endif
+
+#ifndef UDC_IN_ENDPOINT
+#define UDC_IN_ENDPOINT		3
+#endif

[...]

Best regards,
Marek Vasut

author
#22 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Quoted 43 lines · Marek Vasut

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 30 lines
  #endif
include/usb/udc.h new file +23 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 6 lines
include/usb/udc.h new file +6 -0
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Quoted 18 lines

include/usb/udc.h line 43

Quoted 13 lines
include/usb/udc.h new file +13 -0
+#define UDC_BULK_HS_PACKET_SIZE	512
+
+#ifndef UDC_INT_ENDPOINT
+#define UDC_INT_ENDPOINT	1
+#endif
+
+#ifndef UDC_OUT_ENDPOINT
+#define UDC_OUT_ENDPOINT	2
+#endif
+
+#ifndef UDC_IN_ENDPOINT
+#define UDC_IN_ENDPOINT		3
+#endif

[...]

Best regards,
Marek Vasut

#23 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Dear Troy Kisky,

Quoted 62 lines · Marek Vasut
Quoted 46 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 32 lines
  #endif
include/usb/udc.h new file +24 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 5 lines
include/usb/udc.h new file +5 -0
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

Quoted 6 lines

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Are you sure this is not OHCI ?

Best regards,
Marek Vasut

author
#24 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Quoted 65 lines · Marek Vasut

Dear Troy Kisky,

Quoted 63 lines · Marek Vasut
Quoted 44 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 31 lines
   #endif
include/usb/udc.h new file +23 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 6 lines
include/usb/udc.h new file +6 -0
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

Quoted 7 lines
Quoted 2 lines

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Are you sure this is not OHCI ?

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Thanks
Troy

#25 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Dear Troy Kisky,

Quoted 74 lines · Marek Vasut
Quoted 73 lines

Dear Troy Kisky,

Quoted 62 lines · Marek Vasut
Quoted 46 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 32 lines
   #endif
include/usb/udc.h new file +24 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 5 lines
include/usb/udc.h new file +5 -0
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

Quoted 6 lines

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Are you sure this is not OHCI ?

Quoted 7 lines
Quoted 2 lines

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

author
#26 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Quoted 78 lines · Marek Vasut

Dear Troy Kisky,

Quoted 68 lines · Marek Vasut
Quoted 67 lines

Dear Troy Kisky,

Quoted 65 lines · Marek Vasut
Quoted 44 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 31 lines
    #endif
include/usb/udc.h new file +23 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 6 lines
include/usb/udc.h new file +6 -0
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Quoted 8 lines
Quoted 4 lines

Are you sure this is not OHCI ?

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Quoted 7 lines

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

Ok, I checked the spec for the OMAP1510, and found "Table 14?23. Endpoint n Size Values"
lists maximum packet sizes of 8, 16, 32, or 64 bytes for Non-isochronous endpoints, and 8, 16, 32, 64, 128, 256, 512 for Isochronous endpoints

So, I still don't understand the limit of 16, but that isn't required.

So, are you saying I should edit omap1510_udc.h and add

#define EP_MAX_PACKET_SIZE 16

and remove
#ifndef UDC_BULK_PACKET_SIZE

in udc.h and do

#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE

unconditionally?

Thanks
Troy

#27 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Dear Troy Kisky,

Quoted 105 lines · Marek Vasut
Quoted 84 lines

Dear Troy Kisky,

Quoted 74 lines · Marek Vasut
Quoted 73 lines

Dear Troy Kisky,

Quoted 62 lines · Marek Vasut
Quoted 46 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 32 lines
    #endif
include/usb/udc.h new file +24 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 5 lines
include/usb/udc.h new file +5 -0
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

Quoted 6 lines

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Are you sure this is not OHCI ?

Quoted 7 lines
Quoted 2 lines

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Quoted 6 lines

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

Ok, I checked the spec for the OMAP1510, and found "Table 14?23. Endpoint n Size Values"
lists maximum packet sizes of 8, 16, 32, or 64 bytes for Non-isochronous endpoints, and 8, 16, 32, 64, 128, 256, 512 for Isochronous endpoints

So, I still don't understand the limit of 16, but that isn't required.

So, are you saying I should edit omap1510_udc.h and add

#define EP_MAX_PACKET_SIZE 16

Quoted 8 lines

and remove
#ifndef UDC_BULK_PACKET_SIZE

in udc.h and do

#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE

unconditionally?

I'd say you should check if the controller is OHCI or EHCI , check what kind of endpoint it is and based on that , configure the max packet size. Or is this really controller specific ? What do the OHCI and EHCI specs say ?

Best regards,
Marek Vasut

author
#28 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Quoted 107 lines · Marek Vasut

Dear Troy Kisky,

Quoted 105 lines · Marek Vasut
Quoted 78 lines

Dear Troy Kisky,

Quoted 68 lines · Marek Vasut
Quoted 67 lines

Dear Troy Kisky,

Quoted 65 lines · Marek Vasut
Quoted 44 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 31 lines
     #endif
include/usb/udc.h new file +23 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 6 lines
include/usb/udc.h new file +6 -0
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Quoted 8 lines
Quoted 4 lines

Are you sure this is not OHCI ?

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Quoted 6 lines

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

Ok, I checked the spec for the OMAP1510, and found "Table 14?23. Endpoint n Size Values"
lists maximum packet sizes of 8, 16, 32, or 64 bytes for Non-isochronous endpoints, and 8, 16, 32, 64, 128, 256, 512 for Isochronous endpoints

So, I still don't understand the limit of 16, but that isn't required.

So, are you saying I should edit omap1510_udc.h and add

#define EP_MAX_PACKET_SIZE 16

and remove
#ifndef UDC_BULK_PACKET_SIZE

in udc.h and do

#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE

Quoted 8 lines
Quoted 1 line

unconditionally?

I'd say you should check if the controller is OHCI or EHCI , check what kind of endpoint it is and based on that , configure the max packet size. Or is this really controller specific ? What do the OHCI and EHCI specs say ?

Best regards,
Marek Vasut

The omap1510 does have an OHCI host controller, I don't know how that relates to the device
controller so I think a check would just be confusing.

Troy

#29 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Dear Troy Kisky,

Quoted 122 lines · Marek Vasut
Quoted 121 lines

Dear Troy Kisky,

Quoted 105 lines · Marek Vasut
Quoted 84 lines

Dear Troy Kisky,

Quoted 74 lines · Marek Vasut
Quoted 73 lines

Dear Troy Kisky,

Quoted 62 lines · Marek Vasut
Quoted 46 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 32 lines
     #endif
include/usb/udc.h new file +24 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 5 lines
include/usb/udc.h new file +5 -0
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

Quoted 6 lines

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Are you sure this is not OHCI ?

Quoted 7 lines
Quoted 2 lines

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Quoted 6 lines

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

Ok, I checked the spec for the OMAP1510, and found "Table 14?23. Endpoint n Size Values"
lists maximum packet sizes of 8, 16, 32, or 64 bytes for Non-isochronous endpoints, and 8, 16, 32, 64, 128, 256, 512 for Isochronous endpoints

So, I still don't understand the limit of 16, but that isn't required.

So, are you saying I should edit omap1510_udc.h and add

#define EP_MAX_PACKET_SIZE 16

Quoted 8 lines

and remove
#ifndef UDC_BULK_PACKET_SIZE

in udc.h and do

#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE

unconditionally?

I'd say you should check if the controller is OHCI or EHCI , check what kind of endpoint it is and based on that , configure the max packet size. Or is this really controller specific ? What do the OHCI and EHCI specs say ?

Quoted 6 lines
Quoted 2 lines

Best regards,
Marek Vasut

The omap1510 does have an OHCI host controller, I don't know how that relates to the device
controller so I think a check would just be confusing.

I see the difference now. For EHCI UDC, the max packet sizes are as they are. For OMAP/MPC8xx, these are non-standard arbitrary values, it's just that the name is the same.

This is pretty ugly and confusing, ick. I'd say you #ifdef this stuff like this:
#ifdef OMAP1510 ...
#elif MPC8xx
#elif ....
#endif

And put a comment around it that the old UDCs simply follow no standard.

Best regards,

author
#30 lore raw

PATCH v4 6/17 usb: udc: add udc.h include file

Quoted 131 lines · Marek Vasut

Dear Troy Kisky,

Quoted 114 lines · Marek Vasut
Quoted 113 lines

Dear Troy Kisky,

Quoted 98 lines · Marek Vasut
Quoted 78 lines

Dear Troy Kisky,

Quoted 68 lines · Marek Vasut
Quoted 67 lines

Dear Troy Kisky,

Quoted 65 lines · Marek Vasut
Quoted 44 lines

Dear Troy Kisky,

Quoted 9 lines

Move common definitions to udc.h
This allows musb_udc.h to be removed as well.

---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.

[...]

Quoted 31 lines
      #endif
include/usb/udc.h new file +23 -0
new file mode 100644
index 0000000..3bcbbbc
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef USB_UDC_H
+#define USB_UDC_H
+
+#ifndef EP0_MAX_PACKET_SIZE
+#define EP0_MAX_PACKET_SIZE     64
+#endif
+
+#ifndef EP_MAX_PACKET_SIZE
+#define EP_MAX_PACKET_SIZE	64
+#endif
+
+#ifndef UDC_OUT_PACKET_SIZE
+#define UDC_OUT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_IN_PACKET_SIZE
+#define UDC_IN_PACKET_SIZE      EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_INT_PACKET_SIZE
Quoted 8 lines

include/usb/udc.h line 29

Quoted 6 lines
include/usb/udc.h new file +6 -0
+#define UDC_INT_PACKET_SIZE     EP_MAX_PACKET_SIZE
+#endif
+
+#ifndef UDC_BULK_PACKET_SIZE
+#define UDC_BULK_PACKET_SIZE    EP_MAX_PACKET_SIZE
+#endif

Do you expect these values to change on per-controller basis? Or why do you have these ifndefs here ?

I don't know why they change but

include/usb/mpc8xx_udc.h:#define UDC_BULK_PACKET_SIZE
EP_MIN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_BULK_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_INT_PACKET_SIZE
UDC_IN_PACKET_SIZE /* 8 */
include/usb/omap1510_udc.h:#define UDC_INT_PACKET_SIZE 16

include/usb/mpc8xx_udc.h:#define UDC_OUT_PACKET_SIZE
EP_MIN_PACKET_SIZE /* */

Quoted 8 lines
Quoted 4 lines

Are you sure this is not OHCI ?

Best regards,
Marek Vasut

I don't know.
I don't understand the relevance of the question. Can you explain the issue a little more
for me.

Quoted 6 lines

OMAP1510 has only OHCI controller in it, dunno about MPC8xx, but that seems to be the case as well. Therefore, in OHCI case, the max packet is 16 and in ehci it's 64 . Check the specs ;-)

Best regards,
Marek Vasut

Ok, I checked the spec for the OMAP1510, and found "Table 14?23. Endpoint n Size Values"
lists maximum packet sizes of 8, 16, 32, or 64 bytes for Non-isochronous endpoints, and 8, 16, 32, 64, 128, 256, 512 for Isochronous endpoints

So, I still don't understand the limit of 16, but that isn't required.

So, are you saying I should edit omap1510_udc.h and add

#define EP_MAX_PACKET_SIZE 16

Quoted 8 lines

and remove
#ifndef UDC_BULK_PACKET_SIZE

in udc.h and do

#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE

unconditionally?

I'd say you should check if the controller is OHCI or EHCI , check what kind of endpoint it is and based on that , configure the max packet size. Or is this really controller specific ? What do the OHCI and EHCI specs say ?

Quoted 5 lines
Quoted 2 lines

Best regards,
Marek Vasut

The omap1510 does have an OHCI host controller, I don't know how that relates to the device
controller so I think a check would just be confusing.

I see the difference now. For EHCI UDC, the max packet sizes are as they are. For OMAP/MPC8xx, these are non-standard arbitrary values, it's just that the name is the same.

This is pretty ugly and confusing, ick. I'd say you #ifdef this stuff like this:
#ifdef OMAP1510 ...
#elif MPC8xx
#elif ....
#endif

Quoted 4 lines

And put a comment around it that the old UDCs simply follow no standard.

Best regards,

I suspect omap1510 will work with a value of 64 for the sizes, since it and mpc8xx
were added by Bryan O'Donoghue - 29 May 2006

I've added him to the CC.
Bryan, can you test changing

include/usb/omap1510_udc.h
#define UDC_INT_PACKET_SIZE 16
#define UDC_BULK_PACKET_SIZE 16
--------
or on a very old u-boot
include/usbdcore_omap1510.h
#define UDC_INT_PKTSIZE 16
#define UDC_BULK_PKTSIZE 16

from 16 to 64? Or maybe you remember the reason 16 was needed? Also, do your remember anything about the MPC885 family and why endpoint 0 could be 16 bytes, but bulk endpoints are limited to 8?

Thanks, I'd like my comments to be accurate...

Troy

author
#31 lore raw

PATCH v4 7/17 usb: gadget: mv_udc: fix typo in error message

In reply to Troy Kisky

Change 'nfo=' to 'info='

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -2
index 322c04f..cc21306 100644
@@ -368,8 +368,8 @@ static void handle_ep_complete(struct mv_ep *ep)
 	mv_invalidate_qtd(num);
 	
 	if (item->info & 0xff)
-		printf("EP%d/%s FAIL nfo=%x pg0=%x\n",
-			num, in ? "in" : "out", item->info, item->page0);
+		printf("EP%d/%s FAIL info=%x pg0=%x\n",
+		       num, in ? "in" : "out", item->info, item->page0);
 
 	len = (item->info >> 16) & 0x7fff;
 
Signature · 1 line
1.8.1.2
author
#32 lore raw

PATCH v4 8/17 usb: gadget: mv_udc: set is_dualspeed = 1

In reply to Troy Kisky

This controller support full and high speed.

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/mv_udc.c +1 -0
index cc21306..b04ac47 100644
@@ -109,6 +109,7 @@ static struct mv_drv controller = {
 	.gadget	= {
 		.name	= "mv_udc",
 		.ops	= &mv_udc_ops,
+		.is_dualspeed = 1,
 	},
 };
 
Signature · 1 line
1.8.1.2
author
#33 lore raw

PATCH v4 9/17 usb: gadget: mv_udc: fix full speed connections

In reply to Troy Kisky

Set maximum packet length in queue header to wMaxPacketSize of endpoint.

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 48 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 14 deletions(-)
drivers/usb/gadget/mv_udc.c +34 -14
index b04ac47..c2df749 100644
@@ -16,6 +16,7 @@
 #include <asm/byteorder.h>
 #include <asm/io.h>
 #include <asm/errno.h>
+#include <asm/unaligned.h>
 #include <linux/types.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -213,7 +214,7 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req)
 	return;
 }
 
-static void ep_enable(int num, int in)
+static void ep_enable(int num, int in, int maxpacket)
 {
 	struct ept_queue_head *head;
 	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
@@ -227,7 +228,7 @@ static void ep_enable(int num, int in)
 		n |= (CTRL_RXE | CTRL_RXR | CTRL_RXT_BULK);
 
 	if (num != 0) {
-		head->config = CONFIG_MAX_PKT(EP_MAX_PACKET_SIZE) | CONFIG_ZLT;
+		head->config = CONFIG_MAX_PKT(maxpacket) | CONFIG_ZLT;
 		mv_flush_qh(num);
 	}
 	writel(n, &udc->epctrl[num]);
@@ -240,8 +241,21 @@ static int mv_ep_enable(struct usb_ep *ep,
 	int num, in;
 	num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
 	in = (desc->bEndpointAddress & USB_DIR_IN) != 0;
-	ep_enable(num, in);
 	mv_ep->desc = desc;
+
+	if (num) {
+		int max = get_unaligned_le16(&desc->wMaxPacketSize);
+
+		if ((max > 64) && (controller.gadget.speed == USB_SPEED_FULL))
+			max = 64;
+		if (ep->maxpacket != max) {
+			DBG("%s: from %d to %d\n", __func__,
+			    ep->maxpacket, max);
+			ep->maxpacket = max;
+		}
+	}
+	ep_enable(num, in, ep->maxpacket);
+	DBG("%s: num=%d maxpacket=%d\n", __func__, num, ep->maxpacket);
 	return 0;
 }
 
@@ -414,14 +428,16 @@ static void handle_setup(void)
 		if ((r.wValue == 0) && (r.wLength == 0)) {
 			req->length = 0;
 			for (i = 0; i < NUM_ENDPOINTS; i++) {
-				if (!controller.ep[i].desc)
+				struct mv_ep *ep = &controller.ep[i];
+
+				if (!ep->desc)
 					continue;
-				num = controller.ep[i].desc->bEndpointAddress
+				num = ep->desc->bEndpointAddress
 						& USB_ENDPOINT_NUMBER_MASK;
-				in = (controller.ep[i].desc->bEndpointAddress
+				in = (ep->desc->bEndpointAddress
 						& USB_DIR_IN) != 0;
 				if ((num == _num) && (in == _in)) {
-					ep_enable(num, in);
+					ep_enable(num, in, ep->ep.maxpacket);
 					usb_ep_queue(controller.gadget.ep0,
 							req, 0);
 					break;
@@ -505,15 +521,19 @@ void udc_irq(void)
 		DBG("-- suspend --\n");
 
 	if (n & STS_PCI) {
-		DBG("-- portchange --\n");
+		int max = 64;
+		int speed = USB_SPEED_FULL;
+
 		bit = (readl(&udc->portsc) >> 26) & 3;
+		DBG("-- portchange %x %s\n", bit, (bit == 2) ? "High" : "Full");
 		if (bit == 2) {
-			controller.gadget.speed = USB_SPEED_HIGH;
-			for (i = 1; i < NUM_ENDPOINTS && n; i++)
-				if (controller.ep[i].desc)
-					controller.ep[i].ep.maxpacket = 512;
-		} else {
-			controller.gadget.speed = USB_SPEED_FULL;
+			speed = USB_SPEED_HIGH;
+			max = 512;
+		}
+		controller.gadget.speed = speed;
+		for (i = 1; i < NUM_ENDPOINTS; i++) {
+			if (controller.ep[i].ep.maxpacket > max)
+				controller.ep[i].ep.maxpacket = max;
 		}
 	}
 
Signature · 1 line
1.8.1.2
author
#34 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

In reply to Troy Kisky

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/usb/gadget/mv_udc.c +16 -21
index c2df749..97bab93 100644
@@ -264,7 +264,7 @@ static int mv_ep_disable(struct usb_ep *ep)
 	return 0;
 }
 
-static int mv_bounce(struct mv_ep *ep)
+static int mv_bounce(struct mv_ep *ep, int in)
 {
 	uint32_t addr = (uint32_t)ep->req.buf;
 	uint32_t ba;
@@ -293,8 +293,8 @@ align:
 		if (!ep->b_buf)
 			return -ENOMEM;
 	}
-
-	memcpy(ep->b_buf, ep->req.buf, ep->req.length);
+	if (in)
+		memcpy(ep->b_buf, ep->req.buf, ep->req.length);
 
 flush:
 	ba = (uint32_t)ep->b_buf;
@@ -303,29 +303,25 @@ flush:
 	return 0;
 }
 
-static void mv_debounce(struct mv_ep *ep)
+static void mv_debounce(struct mv_ep *ep, int in)
 {
 	uint32_t addr = (uint32_t)ep->req.buf;
 	uint32_t ba = (uint32_t)ep->b_buf;
 
+	if (in) {
+		if (addr == ba)
+			return;		/* not a bounce */
+		goto free;
+	}
 	invalidate_dcache_range(ba, ba + ep->b_len);
 
-	/* Input buffer address is not aligned. */
-	if (addr & (ARCH_DMA_MINALIGN - 1))
-		goto copy;
-
-	/* Input buffer length is not aligned. */
-	if (ep->req.length & (ARCH_DMA_MINALIGN - 1))
-		goto copy;
-
-	/* The buffer is well aligned, only invalidate cache. */
-	return;
+	if (addr == ba)
+		return;		/* not a bounce */
 
-copy:
 	memcpy(ep->req.buf, ep->b_buf, ep->req.length);
-
+free:
 	/* Large payloads use allocated buffer, free it. */
-	if (ep->req.length > 64)
+	if (ep->b_buf != ep->b_fast)
 		free(ep->b_buf);
 }
 
@@ -343,7 +339,7 @@ static int mv_ep_queue(struct usb_ep *ep,
 	head = mv_get_qh(num, in);
 	len = req->length;
 
-	ret = mv_bounce(mv_ep);
+	ret = mv_bounce(mv_ep, in);
 	if (ret)
 		return ret;
 
@@ -387,10 +383,9 @@ static void handle_ep_complete(struct mv_ep *ep)
 		       num, in ? "in" : "out", item->info, item->page0);
 
 	len = (item->info >> 16) & 0x7fff;
-
-	mv_debounce(ep);
-
 	ep->req.length -= len;
+	mv_debounce(ep, in);
+
 	DBG("ept%d %s complete %x\n",
 			num, in ? "in" : "out", len);
 	ep->req.complete(&ep->ep, &ep->req);
Signature · 1 line
1.8.1.2
#35 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

Dear Troy Kisky,

Quoted 11 lines

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

---
v4: no change

Just a question here. Are you sure we never Send AND Reserve the data in one turn? Because that would need two copyings.

Best regards,
Marek Vasut

author
#36 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

Quoted 9 lines · Marek Vasut

Dear Troy Kisky,

Quoted 7 lines

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

Quoted 6 lines
Quoted 4 lines

---
v4: no change

Just a question here. Are you sure we never Send AND Reserve the data in one turn? Because that would need two copyings.

??? s/Reserve/Receive/

As far as I'm aware, a single buffer is only ever used to capture or provide data not both.
But, if 2 transfers were queued, an OUT and then an IN using the same buffer, if it worked before
this patch, it should work after as well.

Quoted 4 lines

Best regards,
Marek Vasut

#37 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

Dear Troy Kisky,

Quoted 18 lines · Marek Vasut
Quoted 9 lines

Dear Troy Kisky,

Quoted 7 lines

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

Quoted 7 lines
Quoted 4 lines

---
v4: no change

Just a question here. Are you sure we never Send AND Reserve the data in one turn? Because that would need two copyings.

Quoted 7 lines

??? s/Reserve/Receive/

As far as I'm aware, a single buffer is only ever used to capture or provide data not both.
But, if 2 transfers were queued, an OUT and then an IN using the same buffer, if it worked before
this patch, it should work after as well.

How come? Before, it was doing flush before and inval after the transfer, right ?

btw what does this part of the patch do/mean ? Why is it there?

@@ -387,10 +383,9 @@ static void handle_ep_complete(struct mv_ep *ep)

                       num, in ? "in" : "out", item->info, item->page0);
 
        len = (item->info >> 16) & 0x7fff;
-
-       mv_debounce(ep);
-
        ep->req.length -= len;
+       mv_debounce(ep, in);
+
        DBG("ept%d %s complete %x\n",
                        num, in ? "in" : "out", len);
        ep->req.complete(&ep->ep, &ep->req);

Best regards,
Marek Vasut

author
#38 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

Quoted 23 lines · Marek Vasut

Dear Troy Kisky,

Quoted 21 lines · Marek Vasut
Quoted 9 lines

Dear Troy Kisky,

Quoted 7 lines

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

Quoted 6 lines
Quoted 4 lines

---
v4: no change

Just a question here. Are you sure we never Send AND Reserve the data in one turn? Because that would need two copyings.

??? s/Reserve/Receive/

As far as I'm aware, a single buffer is only ever used to capture or provide data not both.
But, if 2 transfers were queued, an OUT and then an IN using the same

Actually, I should have said "an IN (tx to the host controller) and then an OUT(rx from the host controller)"

Quoted 4 lines
Quoted 2 lines

buffer, if it worked before
this patch, it should work after as well.

How come? Before, it was doing flush before and inval after the transfer, right ?

The 1st "IN" transfer (tx to the host), will [copy]/flush on mv_bounce and [free]/nothing on mv_debounce.
The 2nd "OUT" transfer (rx from the host) will flush on mv_bounce and invalidate/[copy/free] on mv_debounce.

Quoted 4 lines

btw what does this part of the patch do/mean ? Why is it there?

drivers/usb/gadget/mv_udc.c static void handle_ep_complete(struct mv_ep *ep) · line 389

Quoted 10 lines
drivers/usb/gadget/mv_udc.c +2 -3
@@ -387,10 +383,9 @@ static void handle_ep_complete(struct mv_ep *ep)
                        num, in ? "in" : "out", item->info, item->page0);
 
         len = (item->info >> 16) & 0x7fff;
-
-       mv_debounce(ep);
-
         ep->req.length -= len;
+       mv_debounce(ep, in);
+
 

That implements the "On out transfers, only copy the number of bytes received from the bounce buffer"
portion of the commit message.

Thanks
Troy

#39 lore raw

PATCH v4 10/17 usb: gadget: mv_udc: optimize bounce

Dear Troy Kisky,

Quoted 53 lines · Marek Vasut
Quoted 25 lines

Dear Troy Kisky,

Quoted 23 lines · Marek Vasut
Quoted 9 lines

Dear Troy Kisky,

Quoted 7 lines

Only perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.

On out transfers, only copy the number of bytes received from the bounce buffer

Quoted 8 lines
Quoted 4 lines

---
v4: no change

Just a question here. Are you sure we never Send AND Reserve the data in one turn? Because that would need two copyings.

??? s/Reserve/Receive/

As far as I'm aware, a single buffer is only ever used to capture or provide data not both.
But, if 2 transfers were queued, an OUT and then an IN using the same

Actually, I should have said "an IN (tx to the host controller) and then an OUT(rx from the host controller)"

Quoted 5 lines
Quoted 2 lines

buffer, if it worked before
this patch, it should work after as well.

How come? Before, it was doing flush before and inval after the transfer, right ?

The 1st "IN" transfer (tx to the host), will [copy]/flush on mv_bounce and [free]/nothing on mv_debounce.
The 2nd "OUT" transfer (rx from the host) will flush on mv_bounce and invalidate/[copy/free] on mv_debounce.

Quoted 12 lines

btw what does this part of the patch do/mean ? Why is it there?

drivers/usb/gadget/mv_udc.c +0 -3
@@ -387,10 +383,9 @@ static void handle_ep_complete(struct mv_ep *ep)
 
                        num, in ? "in" : "out", item->info, item->page0);
 
         len = (item->info >> 16) & 0x7fff;
 
-
-       mv_debounce(ep);
-
 
Quoted 8 lines

drivers/usb/gadget/mv_udc.c static void handle_ep_complete(struct mv_ep *ep) · line 388

Quoted 4 lines
drivers/usb/gadget/mv_udc.c +2 -0
         ep->req.length -= len;
 
+       mv_debounce(ep, in);
+

That implements the "On out transfers, only copy the number of bytes received from the bounce buffer"
portion of the commit message.

OK, thanks.

Best regards,
Marek Vasut

author
#40 lore raw

PATCH v4 11/17 usb: gadget: mv_udc: flush item before head

In reply to Troy Kisky

Make sure the transfer descriptor is flushed before the queue is updated so that the controller will not see old information.

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -3
index 97bab93..075b039 100644
@@ -347,21 +347,20 @@ static int mv_ep_queue(struct usb_ep *ep,
 	item->info = INFO_BYTES(len) | INFO_IOC | INFO_ACTIVE;
 	item->page0 = (uint32_t)mv_ep->b_buf;
 	item->page1 = ((uint32_t)mv_ep->b_buf & 0xfffff000) + 0x1000;
+	mv_flush_qtd(num);
 
 	head->next = (unsigned) item;
 	head->info = 0;
 
 	DBG("ept%d %s queue len %x, buffer %p\n",
 	    num, in ? "in" : "out", len, mv_ep->b_buf);
+	mv_flush_qh(num);
 
 	if (in)
 		bit = EPT_TX(num);
 	else
 		bit = EPT_RX(num);
 
-	mv_flush_qh(num);
-	mv_flush_qtd(num);
-
 	writel(bit, &udc->epprime);
 
 	return 0;
Signature · 1 line
1.8.1.2
author
#41 lore raw

PATCH v4 12/17 usb: gadget: mv_udc: optimize ep_enable

In reply to Troy Kisky

Only get head if not ep0.

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -2
index 075b039..995585d 100644
@@ -216,10 +216,8 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req)
 
 static void ep_enable(int num, int in, int maxpacket)
 {
-	struct ept_queue_head *head;
 	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
 	unsigned n;
-	head = mv_get_qh(num, in);
 
 	n = readl(&udc->epctrl[num]);
 	if (in)
@@ -228,6 +226,8 @@ static void ep_enable(int num, int in, int maxpacket)
 		n |= (CTRL_RXE | CTRL_RXR | CTRL_RXT_BULK);
 
 	if (num != 0) {
+		struct ept_queue_head *head = mv_get_qh(num, in);
+
 		head->config = CONFIG_MAX_PKT(maxpacket) | CONFIG_ZLT;
 		mv_flush_qh(num);
 	}
Signature · 1 line
1.8.1.2
author
#42 lore raw

PATCH v4 13/17 usb: gadget: mv_udc: zero transfer descriptor memory on probe

In reply to Troy Kisky

Since we flush the TD, we may as well set it to a known value.

---
v4: no change

---
 drivers/usb/gadget/mv_udc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/mv_udc.c +1 -0
index 995585d..ea296cc 100644
@@ -643,6 +643,7 @@ static int mvudc_probe(void)
 		free(controller.epts);
 		return -ENOMEM;
 	}
+	memset(controller.items_mem, 0, ilist_sz);
 
 	for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
 		/*
Signature · 1 line
1.8.1.2
author
#43 lore raw

PATCH v4 14/17 usb: gadget: mv_udc: clear desc upon ep_disable

In reply to Troy Kisky

desc is set at ep_enable, so for symmetry,
clear it at ep_disable.

v4: no change

---
 drivers/usb/gadget/mv_udc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/gadget/mv_udc.c +3 -0
index ea296cc..766df7f 100644
@@ -261,6 +261,9 @@ static int mv_ep_enable(struct usb_ep *ep,
 
 static int mv_ep_disable(struct usb_ep *ep)
 {
+	struct mv_ep *mv_ep = container_of(ep, struct mv_ep, ep);
+
+	mv_ep->desc = NULL;
 	return 0;
 }
 
Signature · 1 line
1.8.1.2
author
#44 lore raw

PATCH v4 15/17 mx6: iomux: add GPR1 defines for use with nitrogen6x

In reply to Troy Kisky

Select GPIO1 as the USB OTG ID pin for Nitrogen6x

---
v4: move the Nitrogen6x bits into this patch as well

---
 arch/arm/include/asm/arch-mx6/iomux.h  | 6 ++++++
 board/boundary/nitrogen6x/nitrogen6x.c | 7 +++++++
 2 files changed, 13 insertions(+)
arch/arm/include/asm/arch-mx6/iomux.h +6 -0
index f4cfd4f..9e6d40f 100644
@@ -10,6 +10,12 @@
 #define MX6_IOMUXC_GPR7		0x020e001c
 
 /*
+ * IOMUXC_GPR1 bit fields
+ */
+#define IOMUXC_GPR1_OTG_ID_ENET_RX_ERR	(0<<13)
+#define IOMUXC_GPR1_OTG_ID_GPIO1	(1<<13)
+#define IOMUXC_GPR1_OTG_ID_MASK		(1<<13)
+/*
  * IOMUXC_GPR13 bit fields
  */
 #define IOMUXC_GPR13_SDMA_STOP_REQ	(1<<30)
board/boundary/nitrogen6x/nitrogen6x.c +7 -0
index f664f6d..c6efafc 100644
@@ -704,6 +704,13 @@ int overwrite_console(void)
 
 int board_init(void)
 {
+	struct iomuxc_base_regs *const iomuxc_regs
+		= (struct iomuxc_base_regs *)IOMUXC_BASE_ADDR;
+
+	clrsetbits_le32(&iomuxc_regs->gpr[1],
+			IOMUXC_GPR1_OTG_ID_MASK,
+			IOMUXC_GPR1_OTG_ID_GPIO1);
+
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
Signature · 1 line
1.8.1.2
author
#45 lore raw

PATCH v4 16/17 nitrogen6x: add otg usb host/device mode support

In reply to Troy Kisky

---
v4: similar to Nitrogen6x: add otg usb ethernet gadget support But I added pad setup for over current, otg_id, and power control Added board_ehci_power function to enable power for host mode. Removed otg_id selection done now in previous patch.

---
 board/boundary/nitrogen6x/nitrogen6x.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
board/boundary/nitrogen6x/nitrogen6x.c +26 -0
index c6efafc..9b07846 100644
@@ -30,6 +30,7 @@
 #include <i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
+#define GP_USB_OTG_PWR	IMX_GPIO_NR(3, 22)
 
 #define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
 	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm |			\
@@ -179,6 +180,14 @@ iomux_v3_cfg_t const enet_pads2[] = {
 	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL	| MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const misc_pads[] = {
+	MX6_PAD_GPIO_1__USBOTG_ID		| MUX_PAD_CTRL(WEAK_PULLUP),
+	MX6_PAD_KEY_COL4__USBOH3_USBOTG_OC	| MUX_PAD_CTRL(WEAK_PULLUP),
+	MX6_PAD_EIM_D30__USBOH3_USBH1_OC	| MUX_PAD_CTRL(WEAK_PULLUP),
+	/* OTG Power enable */
+	MX6_PAD_EIM_D22__GPIO_3_22		| MUX_PAD_CTRL(OUTPUT_40OHM),
+};
+
 /* wl1271 pads on nitrogen6x */
 iomux_v3_cfg_t const wl12xx_pads[] = {
 	(MX6_PAD_NANDF_CS1__GPIO_6_14 & ~MUX_PAD_CTRL_MASK)
@@ -250,6 +259,15 @@ int board_ehci_hcd_init(int port)
 
 	return 0;
 }
+
+int board_ehci_power(int port, int on)
+{
+	if (port)
+		return 0;
+	gpio_set_value(GP_USB_OTG_PWR, on);
+	return 0;
+}
+
 #endif
 
 #ifdef CONFIG_FSL_ESDHC
@@ -369,6 +387,11 @@ int board_eth_init(bd_t *bis)
 		free(bus);
 	}
 #endif
+
+#ifdef CONFIG_MV_UDC
+	/* For otg ethernet*/
+	usb_eth_initialize(bis);
+#endif
 	return 0;
 }
 
@@ -683,6 +706,7 @@ int board_early_init_f(void)
 	gpio_direction_input(WL12XX_WL_IRQ_GP);
 	gpio_direction_output(WL12XX_WL_ENABLE_GP, 0);
 	gpio_direction_output(WL12XX_BT_ENABLE_GP, 0);
+	gpio_direction_output(GP_USB_OTG_PWR, 0); /* OTG power off */
 
 	imx_iomux_v3_setup_multiple_pads(wl12xx_pads, ARRAY_SIZE(wl12xx_pads));
 	setup_buttons();
@@ -711,6 +735,8 @@ int board_init(void)
 			IOMUXC_GPR1_OTG_ID_MASK,
 			IOMUXC_GPR1_OTG_ID_GPIO1);
 
+	imx_iomux_v3_setup_multiple_pads(misc_pads, ARRAY_SIZE(misc_pads));
+
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
Signature · 1 line
1.8.1.2
author
#46 lore raw

PATCH v4 16/17 nitrogen6x: add otg usb host/device mode support

Quoted 25 lines · Troy Kisky

---
v4: similar to Nitrogen6x: add otg usb ethernet gadget support But I added pad setup for over current, otg_id, and power control Added board_ehci_power function to enable power for host mode. Removed otg_id selection done now in previous patch.

---
  board/boundary/nitrogen6x/nitrogen6x.c | 26 ++++++++++++++++++++++++++
  1 file changed, 26 insertions(+)
board/boundary/nitrogen6x/nitrogen6x.c +1 -0
index c6efafc..9b07846 100644
@@ -30,6 +30,7 @@
  #include <i2c.h>
 
  DECLARE_GLOBAL_DATA_PTR;
+#define GP_USB_OTG_PWR	IMX_GPIO_NR(3, 22)
 
  #define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
  	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm |			\
@@ -179,6 +180,14 @@ iomux_v3_cfg_t const enet_pads2[] = {
  	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL	| MUX_PAD_CTRL(ENET_PAD_CTRL),

board/boundary/nitrogen6x/nitrogen6x.c iomux_v3_cfg_t const enet_pads2[] = { · line 190

Quoted 10 lines
board/boundary/nitrogen6x/nitrogen6x.c +8 -0
  };
 
+static iomux_v3_cfg_t const misc_pads[] = {
+	MX6_PAD_GPIO_1__USBOTG_ID		| MUX_PAD_CTRL(WEAK_PULLUP),
+	MX6_PAD_KEY_COL4__USBOH3_USBOTG_OC	| MUX_PAD_CTRL(WEAK_PULLUP),
+	MX6_PAD_EIM_D30__USBOH3_USBH1_OC	| MUX_PAD_CTRL(WEAK_PULLUP),
+	/* OTG Power enable */
+	MX6_PAD_EIM_D22__GPIO_3_22		| MUX_PAD_CTRL(OUTPUT_40OHM),
+};
+

MX6_PAD_GPIO_1__USBOTG_ID is undefined, so please skip this patch and let me correct.

The was defined in a patch by Eric that I missed including.

Thanks

author
#47 lore raw

PATCH v4 17/17 nitrogen6x: add CONFIG_MV_UDC

In reply to Troy Kisky

Also, add other USB related config items.

---
v4: Updated commit message

---
 include/configs/nitrogen6x.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/configs/nitrogen6x.h +6 -0
index b1ca91e..06f173e 100644
@@ -30,6 +30,12 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
+#define CONFIG_MV_UDC
+#define CONFIG_USBD_HS
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_CDC
+#define CONFIG_NETCONSOLE
 
 #define CONFIG_CMD_FUSE
 #ifdef CONFIG_CMD_FUSE
Signature · 1 line
1.8.1.2