DWC back port from Linux kernel
Subsystems (5)
cover DWC back port from Linux kernel
This patch series has been generated in an effort to get comments on the implementation of the dwc code within the uBoot.
The first patch is the one of major concern as this patch will make an attempt to commonize the usb headers so that there is re-use and prepare the usb headers for future usb code back ports from the linux kernel.
This code will compile for omap5 and omap4 but fails for am335x. Before I invest anymore time in this I would like to understand if there are any comments on the overall implemenation.
Makefile | 1 + arch/arm/cpu/armv7/omap5/hw_data.c | 14 + arch/arm/cpu/armv7/omap5/prcm-regs.c | 1 + arch/arm/include/asm/arch-omap5/clocks.h | 4 + arch/arm/include/asm/omap_common.h | 1 + common/cmd_usb.c | 6 +- drivers/usb/dwc3/Makefile | 53 + drivers/usb/dwc3/core.c | 847 +++++++++ drivers/usb/dwc3/core.h | 974 +++++++++++ drivers/usb/dwc3/dwc3-omap.c | 505 ++++++ drivers/usb/dwc3/dwc3-omap.h | 41 + drivers/usb/dwc3/dwc3-uboot.c | 384 ++++ drivers/usb/dwc3/ep0.c | 1085 ++++++++++++ drivers/usb/dwc3/gadget.c | 2806 ++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.h | 196 +++ drivers/usb/dwc3/host.c | 107 ++ drivers/usb/dwc3/io.h | 81 + drivers/usb/host/Makefile | 2 + drivers/usb/musb-new/musb_host.h | 1 + drivers/usb/musb-new/usb-compat.h | 30 - include/configs/omap5_common.h | 9 + include/linux/usb/gadget.h | 184 ++- include/linux/usb/linux-compat.h | 234 +++ include/linux/usb/usb-compat.h | 1957 +++++++++++++++++++++ include/linux/usb/usb-mod-devicetable.h | 131 ++ include/usb.h | 119 +-- include/usb/lin_gadget_compat.h | 29 +- 27 files changed, 9590 insertions(+), 212 deletions(-)
RFC PATCH 1/4 USB: Port usb.h file from linux kernel to uBoot
Port the usb.h file that defines the USB structures for the client and the host.
In this patch files are created under the include/linux/usb directory.
usb-compat.h - Back port from include usb.h kernel commit 84ebc10294a3d7be4c66f51070b7aedbaa24de9b
linux-compat.h - Linux kernel compatibility definitions that do not exist in the uBoot. Moved the compatibility definitions from lin_gadget_compat.h to this file as well.
usb-mod-devicetable.h - Is a partial back port of mod_devicetable.h in the linux kernel for USB.
kernel commit e5354107e14755991da82e0d2a4791db92908d9d
Already existing header files were modified to pick up the new header files.
Currently musb will not compile.
--- drivers/usb/musb-new/musb_host.h | 1 + drivers/usb/musb-new/usb-compat.h | 30 - include/linux/usb/gadget.h | 184 +++- include/linux/usb/linux-compat.h | 234 ++++ include/linux/usb/usb-compat.h | 1957 +++++++++++++++++++++++++++++++ include/linux/usb/usb-mod-devicetable.h | 131 ++ include/usb.h | 119 +-- include/usb/lin_gadget_compat.h | 29 +- 8 files changed, 2474 insertions(+), 211 deletions(-) create mode 100644 include/linux/usb/linux-compat.h create mode 100644 include/linux/usb/usb-compat.h create mode 100644 include/linux/usb/usb-mod-devicetable.h
drivers/usb/musb-new/musb_host.h +1 -0
@@ -35,6 +35,7 @@#ifndef _MUSB_HOST_H#define _MUSB_HOST_H#ifdef __UBOOT__ +#include <linux/usb/usb-compat.h> #include "usb-compat.h" #endif
drivers/usb/musb-new/usb-compat.h +0 -30
@@ -6,13 +6,6 @@struct usb_hcd {void *hcd_priv; }; - -struct usb_host_endpoint { -struct usb_endpoint_descriptor desc; -struct list_head urb_list; -void *hcpriv; -}; -/* * urb->transfer_flags: *
@@ -20,29 +13,6 @@ struct usb_host_endpoint {*/ #define URB_SHORT_NOT_OK 0x0001/* report short reads as errors */ #define URB_ZERO_PACKET 0x0040/* Finish bulk OUT with short packet */ - -struct urb ; - -typedef void (*usb_complete_t )(struct urb *); - -struct urb { -void *hcpriv;/* private data for host controller */ -struct list_head urb_list;/* list head for use by the urb's -* current owner */ -struct usb_device *dev;/* (in) pointer to associated device */ -struct usb_host_endpoint *ep;/* (internal) pointer to endpoint */ -unsigned int pipe;/* (in) pipe information */ -int status;/* (return) non-ISO status */ -unsigned int transfer_flags;/* (in) URB_SHORT_NOT_OK | ...*/ -void *transfer_buffer;/* (in) associated data buffer */ -dma_addr_t transfer_dma;/* (in) dma addr for transfer_buffer */ -u32 transfer_buffer_length;/* (in) data buffer length */ -u32 actual_length;/* (return) actual transfer length */ -unsigned char *setup_packet;/* (in) setup packet (control only) */ -int start_frame;/* (modify) start frame (ISO) */ -usb_complete_t complete;/* (in) completion routine */ -}; -#define usb_hcd_link_urb_to_ep (hcd, urb) ({ \ int ret = 0; \ list_add_tail(&urb->urb_list, &urb->ep->urb_list); \
include/linux/usb/gadget.h +148 -36
260 lines not on this page · raw message
include/linux/usb/linux-compat.h new file +234 -0
234 lines not on this page · raw message
include/linux/usb/usb-compat.h new file +1957 -0
1,957 lines not on this page · raw message
include/linux/usb/usb-mod-devicetable.h new file +131 -0
131 lines not on this page · raw message
include/usb.h +2 -117
163 lines not on this page · raw message
include/usb/lin_gadget_compat.h +1 -28
@@ -24,34 +24,7 @@#define __LIN_COMPAT_H__#include <linux/compat.h> - -/* common */ -#define spin_lock_init (...) -#define spin_lock (...) -#define spin_lock_irqsave (lock, flags) do { debug("%lu\n", flags); } while (0) -#define spin_unlock (...) -#define spin_unlock_irqrestore (lock, flags) do {flags = 0; } while (0) -#define disable_irq (...) -#define enable_irq (...) - -#define mutex_init (...) -#define mutex_lock (...) -#define mutex_unlock (...) - -#define GFP_KERNEL 0 - -#define IRQ_HANDLED 1 - -#define ENOTSUPP 524/* Operation is not supported */ - -#define BITS_PER_BYTE 8 -#define BITS_TO_LONGS (nr) \ - DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -#define DECLARE_BITMAP (name, bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - -#define small_const_nbits (nbits) \ - (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) +#include <linux/usb/linux-compat.h> static inline void bitmap_zero (unsigned long *dst,int nbits) {
Signature · 1 line
1.7.5.4
RFC PATCH 2/4 USB: dwc3: Initial back port of dwc3 code
In reply to Dan MurphyThis is the initial back port of the linux kernel
usb dwc3 code based on commit
commit 3b9561e9d9b88eca9d4ed6aab025dec2eeeed501
All code not applicable to uBoot is ifdef'd out with
ifndef __UBOOT__ as it is done in the musb-new directory.
This code has not been fully debuged or excersized.
--- drivers/usb/dwc3/Makefile | 53 + drivers/usb/dwc3/core.c | 847 +++++++++++++ drivers/usb/dwc3/core.h | 974 ++++++++++++++ drivers/usb/dwc3/dwc3-omap.c | 505 ++++++++ drivers/usb/dwc3/dwc3-omap.h | 41 + drivers/usb/dwc3/dwc3-uboot.c | 384 ++++++ drivers/usb/dwc3/ep0.c | 1085 ++++++++++++++++ drivers/usb/dwc3/gadget.c | 2806 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.h | 196 +++ drivers/usb/dwc3/host.c | 107 ++ drivers/usb/dwc3/io.h | 81 ++ 11 files changed, 7079 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/dwc3/Makefile create mode 100644 drivers/usb/dwc3/core.c create mode 100644 drivers/usb/dwc3/core.h create mode 100644 drivers/usb/dwc3/dwc3-omap.c create mode 100644 drivers/usb/dwc3/dwc3-omap.h create mode 100644 drivers/usb/dwc3/dwc3-uboot.c create mode 100644 drivers/usb/dwc3/ep0.c create mode 100644 drivers/usb/dwc3/gadget.c create mode 100644 drivers/usb/dwc3/gadget.h create mode 100644 drivers/usb/dwc3/host.c create mode 100644 drivers/usb/dwc3/io.h
drivers/usb/dwc3/Makefile new file +53 -0
@@ -0,0 +1,53 @@ +# +# (C) Copyright 2013 +# Texas Instruments Incorporated. +# +# Author: Dan Murphy <[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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +LIB := $(obj)libusb_dwc3.o + +COBJS-$(CONFIG_USB_DWC3) += core.o dwc3-uboot.o +COBJS-$(CONFIG_USB_DWC3_GADGET) += gadget.o ep0.o +COBJS-$(CONFIG_USB_DWC3_HOST) += host.o +COBJS-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o + +CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-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): $(obj).depend $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### +
drivers/usb/dwc3/core.c new file +847 -0
847 lines not on this page · raw message
drivers/usb/dwc3/core.h new file +974 -0
974 lines not on this page · raw message
drivers/usb/dwc3/dwc3-omap.c new file +505 -0
505 lines not on this page · raw message
drivers/usb/dwc3/dwc3-omap.h new file +41 -0
41 lines not on this page · raw message
drivers/usb/dwc3/dwc3-uboot.c new file +384 -0
384 lines not on this page · raw message
drivers/usb/dwc3/ep0.c new file +1085 -0
196 lines not on this page · raw message
drivers/usb/dwc3/gadget.c new file +2806 -0
2,806 lines not on this page · raw message
drivers/usb/dwc3/gadget.h new file +196 -0
196 lines not on this page · raw message
drivers/usb/dwc3/host.c new file +107 -0
107 lines not on this page · raw message
drivers/usb/dwc3/io.h new file +81 -0
81 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.5.4
Part of the diff is not shown here. View the raw message.
RFC PATCH 2/4 USB: dwc3: Initial back port of dwc3 code
Hi Dan,
Quoted 4 lines
drivers/usb/dwc3/ep0.c | 1085 ++++++++++++++++ drivers/usb/dwc3/gadget.c | 2806+++++++++++++++++++++++++++++++++++++++++
drivers/usb/dwc3/gadget.h| 196 +++
How does this code map to the one already available at ./drivers/usb/gadget ?
Is there a change to reuse that code?
Is your dwc3 gadget implementation working with composite layer?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
RFC PATCH 2/4 USB: dwc3: Initial back port of dwc3 code
Ludasz
Quoted 8 lines · Lukasz Majewski
Hi Dan,
Quoted 4 lines
drivers/usb/dwc3/ep0.c | 1085 ++++++++++++++++ drivers/usb/dwc3/gadget.c | 2806+++++++++++++++++++++++++++++++++++++++++
drivers/usb/dwc3/gadget.h| 196 +++How does this code map to the one already available at
./drivers/usb/gadget?
Which code specifically are you referring to in the the drivers/usb/gadget? The dwc3 gadget.c is the plumbing for the dwc to the gadget driver.
Quoted 3 lines
Is there a change to reuse that code?
Is your dwc3 gadget implementation working with composite layer?
Currently I have only back ported the code for compilation. I was RFCing to get comments on how the header files will need to be updated and moved in order to accommodate the DWC and host stack.
Quoted 1 line
Signature · 2 lines
------------------ Dan Murphy
RFC PATCH 3/4 omap5: usb: Add usb otg clocks and enable
In reply to Dan MurphyAdd and enable the USB OTG clocks.
--- arch/arm/cpu/armv7/omap5/hw_data.c | 14 ++++++++++++++ arch/arm/cpu/armv7/omap5/prcm-regs.c | 1 + arch/arm/include/asm/arch-omap5/clocks.h | 4 ++++ arch/arm/include/asm/omap_common.h | 1 + common/cmd_usb.c | 6 +++++- include/configs/omap5_common.h | 9 +++++++++ 6 files changed, 34 insertions(+), 1 deletions(-)
arch/arm/cpu/armv7/omap5/hw_data.c +14 -0
@@ -394,6 +394,20 @@ void enable_basic_clocks(void) OPTFCLKEN_SCRM_PER_MASK);setbits_le32 ((*prcm)->cm_wkupaon_scrm_clkctrl,OPTFCLKEN_SCRM_CORE_MASK ); + +/* TODO wrap this with USB defines */ +/* Setting OCP2SCP1 register */ +setbits_le32 ((*prcm)->cm_l3init_ocp2scp1_clkctrl, +MODULE_CLKCTRL_MODULEMODE_HW_AUTO ); + +/* Select USB OTG SS clock */ +setbits_le32 ((*prcm)->cm_l3init_usb_otg_ss_clkctrl, + (MODULE_CLKCTRL_MODULEMODE_HW_AUTO | +OPTFCLKEN_USB_OTG_SS_FCLK_MASK )); + +/* Setting l3init register */ +setbits_le32 ((*prcm)->cm_l3init_clkstctrl,OPTFCLKEN_USB_OTG_SS_FCLK_MASK ); + }void enable_basic_uboot_clocks (void )
arch/arm/cpu/armv7/omap5/prcm-regs.c +1 -0
@@ -708,6 +708,7 @@ struct prcm_regs const omap5_es2_prcm = { .cm_l3init_p1500_clkctrl = 0x4a009678, .cm_l3init_fsusb_clkctrl = 0x4a0096d0, .cm_l3init_ocp2scp1_clkctrl = 0x4a0096e0, + .cm_l3init_usb_otg_ss_clkctrl = 0x4a0096f0,/* l4 wkup regs */ .cm_abe_pll_ref_clksel = 0x4ae0610c,
arch/arm/include/asm/arch-omap5/clocks.h +4 -0
@@ -174,6 +174,10 @@/* CM_L3INIT_USBPHY_CLKCTRL */ #define USBPHY_CLKCTRL_OPTFCLKEN_PHY_48M_MASK 8 +/* CM_L3INIT_USB_OTG_SS_CLKCTRL */ +#define OPTFCLKEN_USB_OTG_SS_FCLK_SHIFT 8 +#define OPTFCLKEN_USB_OTG_SS_FCLK_MASK (1 << 8) +/* CM_MPU_MPU_CLKCTRL */ #define MPU_CLKCTRL_CLKSEL_EMIF_DIV_MODE_SHIFT 24#define MPU_CLKCTRL_CLKSEL_EMIF_DIV_MODE_MASK (3 << 24)
arch/arm/include/asm/omap_common.h +1 -0
@@ -241,6 +241,7 @@ struct prcm_regs {u32 cm_l3init_p1500_clkctrl;u32 cm_l3init_fsusb_clkctrl;u32 cm_l3init_ocp2scp1_clkctrl; +u32 cm_l3init_usb_otg_ss_clkctrl;/* cm2.l4per */ u32 cm_l4per_clkstctrl;
common/cmd_usb.c +5 -1
@@ -31,6 +31,7 @@#include <asm/unaligned.h> #include <part.h> #include <usb.h> +#include <linux/usb/usb-compat.h> #ifdef CONFIG_USB_STORAGE static int usb_stor_curr_dev =-1 ;/* current device */
@@ -160,6 +161,7 @@ static void usb_display_string(struct usb_device *dev, int index) static void usb_display_desc(struct usb_device *dev) { +#if 0 if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) { printf("%d: %s, USB Revision %x.%x\n", dev->devnum, usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
@@ -189,7 +191,7 @@ static void usb_display_desc(struct usb_device *dev) (dev->descriptor.bcdDevice>>8 ) &0xff , dev->descriptor.bcdDevice & 0xff); } - +#endif } static void usb_display_conf_desc(struct usb_config_descriptor *config,
@@ -350,10 +352,12 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) pre[index++] =' ' ; pre[index++] = has_child ?'|' :' ' ; pre[index] =0 ; +#if 0 printf (" %s (%s, %dmA)\n" ,usb_get_class_desc ( dev->config.if_desc[0 ].desc.bInterfaceClass),portspeed (dev->speed), dev->config.desc.bMaxPower *2 ); +#endif if (strlen (dev->mf) ||strlen (dev->prod) ||strlen (dev->serial))printf (" %s %s %s %s\n" , pre, dev->mf, dev->prod, dev->serial);printf (" %s\n" , pre);
include/configs/omap5_common.h +9 -0
@@ -104,6 +104,15 @@#define CONFIG_SYS_CONSOLE_IS_IN_ENV +/* USB */ +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#define CONFIG_USB_DWC3 +#define CONFIG_USB_DWC3_GADGET +#define CONFIG_USB_DWC3_DUAL_ROLE +#define CONFIG_USB_DWC3_OMAP +#define CONFIG_USB_DWC3_HOST +/* Flash */ #define CONFIG_SYS_NO_FLASH
Signature · 1 line
1.7.5.4
RFC PATCH 4/4 Makefile: Add the libdwc3 to the main Makefile
In reply to Dan MurphyAdd the libdwc3 to the Makefile so that drivers/usb/dwc3 is included in the build
--- Makefile | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile +1 -0
@@ -327,6 +327,7 @@ LIBS-y += drivers/usb/gadget/libusb_gadget.o LIBS-y += drivers/usb/host/libusb_host.o LIBS-y += drivers/usb/musb/libusb_musb.o LIBS-y += drivers/usb/musb-new/libusb_musb-new.o +LIBS-y += drivers/usb/dwc3/libusb_dwc3.o LIBS-y += drivers/usb/phy/libusb_phy.o LIBS-y += drivers/usb/ulpi/libusb_ulpi.o LIBS-y += drivers/video/libvideo.o
Signature · 1 line
1.7.5.4
cover DWC back port from Linux kernel
In reply to Dan MurphyQuoted 10 lines · Dan Murphy
This patch series has been generated in an effort to get comments on the implementation of the dwc code within the uBoot.
The first patch is the one of major concern as this patch will make an attempt to commonize the usb headers so that there is re-use and prepare the usb headers for future usb code back ports from the linux kernel.
This code will compile for omap5 and omap4 but fails for am335x. Before I invest anymore time in this I would like to understand if there are any comments on the overall implemenation.
A few minor, I hope, comments to make review easier. While in the final commit we would squash these into two commits, I'd like to suggest:
commit 1: Import vanilla kernel files A/B/C
commit 2: U-Boot adaptation of files A/B/C
commit 3: Import vanilla kernel dwc3 driver
commit 4: U-Boot adaptation of dwc3 driver
Also, note that we don't need the last kernel commit ID to change the file, but the kernel commit ID you backported the whole thing from. In other words, you can just grab everything from v3.10-rc6 and use that ID in the commit messages.
Oh, and doing things in the above split will make it easier for you to re-sync with v3.10 when it comes out and so forth.
Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130621/a527213f/attachment.pgp>