Skip to contentSkip to conversation

Port of MUSB gadget driver from Linux

RFC PATCH New Ilya Yanok 3 participants 11 messages Aug 8, 2012 – Aug 10, 2012

Subsystems (3)
lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

cover Port of MUSB gadget driver from Linux

Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable.

This is initial port, performed mostly by putting DM, host and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code.

This is not a replacement for existing MUSB driver (at least for now), cause host mode is not supported and there are still consumers of the old interface.

Host mode, OTG and DMA are not supported. The only ported driver is for TI AM33xx, but others should be easy to port too.

Tested it on AM335x EVM and BeagleBone with CDC Ethernet gadget.

Ilya Yanok (5):
linux/usb/ch9.h: update with the version from Linux tree
musb-new: port of Linux musb gadget driver
musb-new: dsps backend driver
am33xx: init OTG hardware and new musb gadget driver
am335x_evm: enable musb gadget on port 0

 Makefile                                    |    1 +
 arch/arm/cpu/armv7/am33xx/board.c           |   81 +-
 arch/arm/cpu/armv7/am33xx/clock.c           |    8 +
 arch/arm/include/asm/arch-am33xx/cpu.h      |   11 +-
 arch/arm/include/asm/arch-am33xx/hardware.h |    4 +
 arch/arm/include/asm/omap_musb.h            |   25 +
 drivers/usb/gadget/config.c                 |    1 -
 drivers/usb/gadget/epautoconf.c             |    1 -
 drivers/usb/gadget/ether.c                  |    1 -
 drivers/usb/gadget/gadget_chips.h           |    2 +
 drivers/usb/gadget/s3c_udc_otg.c            |    1 -
 drivers/usb/gadget/usbstring.c              |    1 -
 drivers/usb/musb-new/Makefile               |   36 +
 drivers/usb/musb-new/musb_core.c            | 2489 +++++++++++++++++++++++++++
 drivers/usb/musb-new/musb_core.h            |  611 +++++++
 drivers/usb/musb-new/musb_debug.h           |   58 +
 drivers/usb/musb-new/musb_dma.h             |  186 ++
 drivers/usb/musb-new/musb_dsps.c            |  769 +++++++++
 drivers/usb/musb-new/musb_gadget.c          | 2319 +++++++++++++++++++++++++
 drivers/usb/musb-new/musb_gadget.h          |  127 ++
 drivers/usb/musb-new/musb_gadget_ep0.c      | 1089 ++++++++++++
 drivers/usb/musb-new/musb_gadget_uboot.c    |   72 +
 drivers/usb/musb-new/musb_io.h              |  146 ++
 drivers/usb/musb-new/musb_regs.h            |  645 +++++++
 include/configs/am335x_evm.h                |   19 +
 include/linux/usb/ch9.h                     |  514 +++++-
 include/linux/usb/musb.h                    |  162 ++
 include/usb/s3c_udc.h                       |    1 -
 28 files changed, 9355 insertions(+), 25 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_musb.h
 create mode 100644 drivers/usb/musb-new/Makefile
 create mode 100644 drivers/usb/musb-new/musb_core.c
 create mode 100644 drivers/usb/musb-new/musb_core.h
 create mode 100644 drivers/usb/musb-new/musb_debug.h
 create mode 100644 drivers/usb/musb-new/musb_dma.h
 create mode 100644 drivers/usb/musb-new/musb_dsps.c
 create mode 100644 drivers/usb/musb-new/musb_gadget.c
 create mode 100644 drivers/usb/musb-new/musb_gadget.h
 create mode 100644 drivers/usb/musb-new/musb_gadget_ep0.c
 create mode 100644 drivers/usb/musb-new/musb_gadget_uboot.c
 create mode 100644 drivers/usb/musb-new/musb_io.h
 create mode 100644 drivers/usb/musb-new/musb_regs.h
 create mode 100644 include/linux/usb/musb.h
Signature · 1 line
1.7.9.5
author
#1 lore raw

RFC PATCH 1/5 linux/usb/ch9.h: update with the version from Linux tree

---
 drivers/usb/gadget/config.c      |    1 -
 drivers/usb/gadget/epautoconf.c  |    1 -
 drivers/usb/gadget/ether.c       |    1 -
 drivers/usb/gadget/s3c_udc_otg.c |    1 -
 drivers/usb/gadget/usbstring.c   |    1 -
 include/linux/usb/ch9.h          |  514 ++++++++++++++++++++++++++++++++++++--
 include/usb/s3c_udc.h            |    1 -
 7 files changed, 499 insertions(+), 21 deletions(-)
drivers/usb/gadget/config.c +0 -1
index f88d0c1..f9163a8 100644
@@ -27,7 +27,6 @@
 #include <linux/string.h>
 
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <linux/usb/gadget.h>
 
 
drivers/usb/gadget/epautoconf.c +0 -1
index b656c8b..5b8776e 100644
@@ -23,7 +23,6 @@
 
 #include <common.h>
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <asm/errno.h>
 #include <linux/usb/gadget.h>
 #include <asm/unaligned.h>
drivers/usb/gadget/ether.c +0 -1
index d975fb6..6f7e4cd 100644
@@ -24,7 +24,6 @@
 #include <asm/errno.h>
 #include <linux/netdevice.h>
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <linux/usb/cdc.h>
 #include <linux/usb/gadget.h>
 #include <net.h>
drivers/usb/gadget/s3c_udc_otg.c +0 -1
index 3fdfdf7..f9d24e3 100644
@@ -37,7 +37,6 @@
 #include <malloc.h>
 
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <linux/usb/gadget.h>
 
 #include <asm/byteorder.h>
drivers/usb/gadget/usbstring.c +0 -1
index 4dbe060..95555cf 100644
@@ -13,7 +13,6 @@
 #include <common.h>
 #include <asm/errno.h>
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <linux/usb/gadget.h>
 
 #include <asm/unaligned.h>
include/linux/usb/ch9.h +499 -15

641 lines not on this page · raw message

include/usb/s3c_udc.h +0 -1
index 6a8fd44..7114dae 100644
@@ -24,7 +24,6 @@
 
 #include <asm/errno.h>
 #include <linux/usb/ch9.h>
-#include <usbdescriptors.h>
 #include <linux/usb/gadget.h>
 #include <linux/list.h>
 #include <usb/lin_gadget_compat.h>
Signature · 1 line
1.7.9.5
author
#2 lore raw

RFC PATCH 2/5 musb-new: port of Linux musb gadget driver

In reply to Ilya Yanok

Existing U-Boot musb driver has no support for the new gadget framework and also seems to have other limitations. As gadget framework is ported from Linux it seems pretty natural to port musb gadget driver as well.

This is not a replacement for current musb driver (at least now) as host mode is not supported and there are still some consumers of the old UDC interface.

No DMA operation support included, CONFIG_MUSB_PIO_ONLY should be defined.

---
 Makefile                                 |    1 +
 drivers/usb/gadget/gadget_chips.h        |    2 +
 drivers/usb/musb-new/Makefile            |   35 +
 drivers/usb/musb-new/musb_core.c         | 2489 ++++++++++++++++++++++++++++++
 drivers/usb/musb-new/musb_core.h         |  611 ++++++++
 drivers/usb/musb-new/musb_debug.h        |   58 +
 drivers/usb/musb-new/musb_dma.h          |  186 +++
 drivers/usb/musb-new/musb_gadget.c       | 2319 ++++++++++++++++++++++++++++
 drivers/usb/musb-new/musb_gadget.h       |  127 ++
 drivers/usb/musb-new/musb_gadget_ep0.c   | 1089 +++++++++++++
 drivers/usb/musb-new/musb_gadget_uboot.c |   72 +
 drivers/usb/musb-new/musb_io.h           |  146 ++
 drivers/usb/musb-new/musb_regs.h         |  645 ++++++++
 include/linux/usb/musb.h                 |  162 ++
 14 files changed, 7942 insertions(+)
 create mode 100644 drivers/usb/musb-new/Makefile
 create mode 100644 drivers/usb/musb-new/musb_core.c
 create mode 100644 drivers/usb/musb-new/musb_core.h
 create mode 100644 drivers/usb/musb-new/musb_debug.h
 create mode 100644 drivers/usb/musb-new/musb_dma.h
 create mode 100644 drivers/usb/musb-new/musb_gadget.c
 create mode 100644 drivers/usb/musb-new/musb_gadget.h
 create mode 100644 drivers/usb/musb-new/musb_gadget_ep0.c
 create mode 100644 drivers/usb/musb-new/musb_gadget_uboot.c
 create mode 100644 drivers/usb/musb-new/musb_io.h
 create mode 100644 drivers/usb/musb-new/musb_regs.h
 create mode 100644 include/linux/usb/musb.h
Makefile +1 -0
index 8b555fb..2e82429 100644
@@ -296,6 +296,7 @@ LIBS += drivers/usb/eth/libusb_eth.o
 LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
+LIBS += drivers/usb/musb-new/libusb_musb-new.o
 LIBS += drivers/usb/phy/libusb_phy.o
 LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
drivers/usb/gadget/gadget_chips.h +2 -0
index 5d7b638..3b1db2e 100644
@@ -133,6 +133,8 @@
 /* Mentor high speed "dual role" controller, in peripheral role */
 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
 #define gadget_is_musbhdrc(g)	(!strcmp("musb_hdrc", (g)->name))
+#elif defined(CONFIG_MUSB_GADGET)
+#define gadget_is_musbhdrc(g)	(!strcmp("musb-hdrc", (g)->name))
 #else
 #define gadget_is_musbhdrc(g)	0
 #endif
drivers/usb/musb-new/Makefile new file +35 -0
new file mode 100644
index 0000000..a518dcd
@@ -0,0 +1,35 @@
+#
+# for USB OTG silicon based on Mentor Graphics INVENTRA designs
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	:= $(obj)libusb_musb-new.o
+
+COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o
+COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget_uboot.o
+
+CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \
+			$(call cc-option,-Wno-unused-but-set-variable) \
+			$(call cc-option,-Wno-unused-label)
+CFLAGS += $(CFLAGS_NO_WARN)
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+#$(LIB):	$(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
+
drivers/usb/musb-new/musb_core.c new file +2489 -0

2,489 lines not on this page · raw message

drivers/usb/musb-new/musb_core.h new file +611 -0

461 lines not on this page · raw message

drivers/usb/musb-new/musb_debug.h new file +58 -0

58 lines not on this page · raw message

drivers/usb/musb-new/musb_dma.h new file +186 -0

186 lines not on this page · raw message

drivers/usb/musb-new/musb_gadget.c new file +2319 -0

2,319 lines not on this page · raw message

drivers/usb/musb-new/musb_gadget.h new file +127 -0

127 lines not on this page · raw message

drivers/usb/musb-new/musb_gadget_ep0.c new file +1089 -0

1,089 lines not on this page · raw message

drivers/usb/musb-new/musb_gadget_uboot.c new file +72 -0

72 lines not on this page · raw message

drivers/usb/musb-new/musb_io.h new file +146 -0

146 lines not on this page · raw message

drivers/usb/musb-new/musb_regs.h new file +645 -0

645 lines not on this page · raw message

include/linux/usb/musb.h new file +162 -0

162 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

author
#3 lore raw

RFC PATCH 3/5 musb-new: dsps backend driver

In reply to Ilya Yanok

Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only).

---
 arch/arm/include/asm/omap_musb.h |   25 ++
 drivers/usb/musb-new/Makefile    |    1 +
 drivers/usb/musb-new/musb_dsps.c |  769 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 795 insertions(+)
 create mode 100644 arch/arm/include/asm/omap_musb.h
 create mode 100644 drivers/usb/musb-new/musb_dsps.c
arch/arm/include/asm/omap_musb.h new file +25 -0
new file mode 100644
index 0000000..0081a68
@@ -0,0 +1,25 @@
+/*
+ * Board data structure for musb gadget on OMAPs
+ *
+ * Copyright (C) 2012, Ilya Yanok <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ASM_ARM_OMAP_MUSB_H
+#define __ASM_ARM_OMAP_MUSB_H
+
+extern struct musb_platform_ops musb_dsps_ops;
+
+struct omap_musb_board_data {
+	void (*set_phy_power)(u8 on);
+};
+#endif /* __ASM_ARM_OMAP_MUSB_H */
drivers/usb/musb-new/Makefile +1 -0
index a518dcd..e0c9263 100644
@@ -8,6 +8,7 @@ LIB	:= $(obj)libusb_musb-new.o
 
 COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o
 COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget_uboot.o
+COBJS-$(CONFIG_USB_AM335X) += musb_dsps.o
 
 CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \
 			$(call cc-option,-Wno-unused-but-set-variable) \
drivers/usb/musb-new/musb_dsps.c new file +769 -0

769 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#4 lore raw

RFC PATCH 4/5 am33xx: init OTG hardware and new musb gadget driver

In reply to Ilya Yanok

AM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget.

---
 arch/arm/cpu/armv7/am33xx/board.c           |   81 ++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/am33xx/clock.c           |    8 +++
 arch/arm/include/asm/arch-am33xx/cpu.h      |   11 +++-
 arch/arm/include/asm/arch-am33xx/hardware.h |    4 ++
 4 files changed, 100 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +80 -1
index 2ca4ca7..dafc264 100644
@@ -33,6 +33,11 @@
 #include <i2c.h>
 #include <miiphy.h>
 #include <cpsw.h>
+#include <asm/errno.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/musb.h>
+#include <asm/omap_musb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -273,9 +278,65 @@ static struct cpsw_platform_data cpsw_data = {
 	.host_port_num		= 0,
 	.version		= CPSW_CTRL_VERSION_2,
 };
+#endif
+
+#ifdef CONFIG_MUSB_GADGET
+#ifdef CONFIG_MUSB_GADGET_PORT0
+#define USB_CTRL_REG &cdev->usb_ctrl0
+#define OTG_REGS_BASE ((void *)AM335X_USB0_OTG_BASE)
+#elif defined(CONFIG_MUSB_GADGET_PORT1)
+#define USB_CTRL_REG &cdev->usb_ctrl1
+#define OTG_REGS_BASE ((void *)AM335X_USB1_OTG_BASE)
+#else
+#error "Please define CONFIG_MUSB_GADGET_PORT0 or CONFIG_MUSB_GADGET_PORT1"
+#endif
+
+/* USB 2.0 PHY Control */
+#define CM_PHY_PWRDN			(1 << 0)
+#define CM_PHY_OTG_PWRDN		(1 << 1)
+#define OTGVDET_EN			(1 << 19)
+#define OTGSESSENDEN			(1 << 20)
+
+static void am33xx_usb_set_phy_power(u8 on)
+{
+	u32 usb_ctrl_reg;
+
+	usb_ctrl_reg = readl(USB_CTRL_REG);
+	if (on) {
+		usb_ctrl_reg &= ~(CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
+		usb_ctrl_reg |= (OTGVDET_EN | OTGSESSENDEN);
+	} else {
+		usb_ctrl_reg |= (CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
+	}
+	writel(usb_ctrl_reg, USB_CTRL_REG);
+}
+
+static struct musb_hdrc_config musb_config = {
+	.multipoint     = 1,
+	.dyn_fifo       = 1,
+	.num_eps        = 16,
+	.ram_bits       = 12,
+};
 
+struct omap_musb_board_data musb_board_data = {
+	.set_phy_power = am33xx_usb_set_phy_power,
+};
+
+static struct musb_hdrc_platform_data musb_plat = {
+	.mode           = MUSB_PERIPHERAL,
+	.config         = &musb_config,
+	.power          = 50,
+	.platform_ops	= &musb_dsps_ops,
+	.board_data	= &musb_board_data,
+};
+#endif
+
+#if defined(CONFIG_DRIVER_TI_CPSW) || \
+	(defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET))
 int board_eth_init(bd_t *bis)
 {
+	int rv, n = 0;
+#ifdef CONFIG_DRIVER_TI_CPSW
 	uint8_t mac_addr[6];
 	uint32_t mac_hi, mac_lo;
 
@@ -307,6 +368,24 @@ int board_eth_init(bd_t *bis)
 				PHY_INTERFACE_MODE_RGMII;
 	}
 
-	return cpsw_register(&cpsw_data);
+	rv = cpsw_register(&cpsw_data);
+	if (rv < 0)
+		printf("Error %d registering CPSW switch\n", rv);
+	else
+		n += rv;
+#endif
+#ifdef CONFIG_USB_ETHER
+	rv = musb_register(&musb_plat, &musb_board_data, OTG_REGS_BASE);
+	if (rv < 0) {
+		printf("Error %d registering MUSB device\n", rv);
+	} else {
+		rv = usb_eth_initialize(bis);
+		if (rv < 0)
+			printf("Error %d registering USB_ETHER\n", rv);
+		else
+			n += rv;
+	}
+#endif
+	return n;
 }
 #endif
arch/arm/cpu/armv7/am33xx/clock.c +8 -0
index 1071f92..5ad84ce 100644
@@ -40,6 +40,7 @@
 #define CLK_MODE_MASK		0xfffffff8
 #define CLK_DIV_SEL		0xFFFFFFE0
 #define CPGMAC0_IDLE		0x30000
+#define DPLL_CLKDCOLDO_GATE_CTRL        0x300
 
 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER;
 const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP;
@@ -148,6 +149,11 @@ static void enable_per_clocks(void)
 	writel(PRCM_MOD_EN, &cmper->cpgmac0clkctrl);
 	while ((readl(&cmper->cpgmac0clkctrl) & CPGMAC0_IDLE) != PRCM_FUNCTL)
 		;
+
+	/* MUSB */
+	writel(PRCM_MOD_EN, &cmper->usb0clkctrl);
+	while (readl(&cmper->usb0clkctrl) != PRCM_MOD_EN)
+		;
 }
 
 static void mpu_pll_config(void)
@@ -244,6 +250,8 @@ static void per_pll_config(void)
 
 	while (readl(&cmwkup->idlestdpllper) != ST_DPLL_CLK)
 		;
+
+	writel(DPLL_CLKDCOLDO_GATE_CTRL, &cmwkup->clkdcoldodpllper);
 }
 
 void ddr_pll_config(unsigned int ddrpll_m)
arch/arm/include/asm/arch-am33xx/cpu.h +8 -3
index de9ee91..a98ffa2 100644
@@ -82,7 +82,8 @@ struct cm_wkuppll {
 	unsigned int clkseldpllcore;	/* offset 0x68 */
 	unsigned int resv9[1];
 	unsigned int idlestdpllper;	/* offset 0x70 */
-	unsigned int resv10[3];
+	unsigned int resv10[2];
+	unsigned int clkdcoldodpllper;	/* offset 0x7c */
 	unsigned int divm4dpllcore;	/* offset 0x80 */
 	unsigned int divm5dpllcore;	/* offset 0x84 */
 	unsigned int clkmoddpllmpu;	/* offset 0x88 */
@@ -258,12 +259,16 @@ struct ctrl_stat {
 /* Control Device Register */
 struct ctrl_dev {
 	unsigned int deviceid;		/* offset 0x00 */
-	unsigned int resv1[11];
+	unsigned int resv1[7];
+	unsigned int usb_ctrl0;		/* offset 0x20 */
+	unsigned int resv2;
+	unsigned int usb_ctrl1;		/* offset 0x28 */
+	unsigned int resv3;
 	unsigned int macid0l;		/* offset 0x30 */
 	unsigned int macid0h;		/* offset 0x34 */
 	unsigned int macid1l;		/* offset 0x38 */
 	unsigned int macid1h;		/* offset 0x3c */
-	unsigned int resv2[4];
+	unsigned int resv4[4];
 	unsigned int miisel;		/* offset 0x50 */
 };
 #endif /* __ASSEMBLY__ */
arch/arm/include/asm/arch-am33xx/hardware.h +4 -0
index c617331..f98f497 100644
@@ -82,4 +82,8 @@
 #define AM335X_CPSW_BASE		0x4A100000
 #define AM335X_CPSW_MDIO_BASE		0x4A101000
 
+/* OTG */
+#define AM335X_USB0_OTG_BASE		0x47401000
+#define AM335X_USB1_OTG_BASE		0x47401800
+
 #endif /* __AM33XX_HARDWARE_H */
Signature · 1 line
1.7.9.5
author
#5 lore raw

RFC PATCH 5/5 am335x_evm: enable musb gadget on port 0

In reply to Ilya Yanok

Enable musb gadget in Ethernet mode on port 0.

---
 include/configs/am335x_evm.h |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
include/configs/am335x_evm.h +19 -0
index c827ebf..e0f0656 100644
@@ -224,6 +224,25 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
 
+
+/*
+ * USB configuration
+ */
+
+#define CONFIG_USB_AM335X
+#define CONFIG_MUSB_GADGET
+#define CONFIG_MUSB_GADGET_PORT0
+#define CONFIG_MUSB_PIO_ONLY
+#define CONFIG_USB_GADGET_DUALSPEED
+
+#ifdef CONFIG_MUSB_GADGET
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_TFTP
+#endif /* CONFIG_MUSB_GADGET */
+
 /* Unsupported features */
 #undef CONFIG_USE_IRQ
 
Signature · 1 line
1.7.9.5
#6 lore raw

cover Port of MUSB gadget driver from Linux

In reply to Ilya Yanok

Dear Ilya Yanok,

Quoted 14 lines

Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable.

This is initial port, performed mostly by putting DM, host and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code.

Quoted 8 lines

This is not a replacement for existing MUSB driver (at least for now), cause host mode is not supported and there are still consumers of the old interface.

Host mode, OTG and DMA are not supported. The only ported driver is for TI AM33xx, but others should be easy to port too.

Tested it on AM335x EVM and BeagleBone with CDC Ethernet gadget.

I hate to say it ... but given that this will cause duplication of code, I'm somehow inclined to push you to do a complete replacement of the old musb code, remove it and add this.

Tom, what do you think?

Quoted 6 lines

Ilya Yanok (5):
linux/usb/ch9.h: update with the version from Linux tree
musb-new: port of Linux musb gadget driver
musb-new: dsps backend driver
am33xx: init OTG hardware and new musb gadget driver
am335x_evm: enable musb gadget on port 0

Best regards,
Marek Vasut

#7 lore raw

cover Port of MUSB gadget driver from Linux

Dear Marek Vasut,

Quoted 4 lines · In message <[email protected]> you wrote:

I hate to say it ... but given that this will cause duplication of code, I'm somehow inclined to push you to do a complete replacement of the old musb code, remove it and add this.

Agreed, we should avoid such duplication.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A right is not what someone gives you; it's what no one can take from
you.                                                   - Ramsey Clark
author
#8 lore raw

cover Port of MUSB gadget driver from Linux

Dear Marek, Wolfgang,

Quoted 10 lines · Wolfgang Denk
Quoted 2 lines

I hate to say it ... but given that this will cause duplication of code,

I'm

Quoted 1 line

somehow inclined to push you to do a complete replacement of the old

musb code,

Quoted 1 line

remove it and add this.

Agreed, we should avoid such duplication.

I agree with you generally. But I fear I won't have enough time now to port the host part too. Also please note that usbtty works only with the old API now.

Regards, Ilya.

author
#9 lore raw

cover Port of MUSB gadget driver from Linux

Marek, Wolfgang,

Quoted 12 lines · Ilya Yanok

Dear Marek, Wolfgang,

Quoted 8 lines · Wolfgang Denk
Quoted 2 lines

I hate to say it ... but given that this will cause duplication of

code, I'm

Quoted 1 line

somehow inclined to push you to do a complete replacement of the old

musb code,

Quoted 1 line

remove it and add this.

Quoted 7 lines
Quoted 2 lines

Agreed, we should avoid such duplication.

I agree with you generally. But I fear I won't have enough time now to port the host part too. Also please note that usbtty works only with the old API now.

Also current MUSB code supports a number of systems, I could add support for all these to the new code (I just don't have the hardware). So I think it's better to allow the two versions coexist for some time.

Regards, Ilya.

author
#10 lore raw

cover Port of MUSB gadget driver from Linux

Argh, sorry. could = could not.