Port of MUSB driver from Linux (changes from Linux)
Subsystems (10)
v4 cover Port of MUSB driver from Linux (changes from Linux)
My apologies for double posting -- I was so stupid to forget to fix the Signed-off-by 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 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 there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now.
OTG and DMA are not supported. Ported drivers include:musb_dsps (should work both with TI AM33xx and TI81xx, tested only on AM33xx), am35x (tested on AM3517 EVM) and omap2plus (should work on OMAP2/3/4, tested on omap3_beagle, omap4_panda doesn't work and needs more work). Others should be easy to port too.
Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform.
Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future.
[1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux-v4
Changes in v4:
- fix indent
- minor style fixes
Changes in v3:
- fix old MUSB code compilation
- bugfix: struct musb should be zeroed after alloc
- fix musb gadget_chips entry
- fix for new multi-interface usb API
- use clrsetbits_le32 for USB PHY ops
Changes in v2:
- add missing linux-compat.h header
- added host support
- glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly.
- added check for malloc return value
- define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled
- added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled
- rename backend config option to CONFIG_USB_MUSB_DSPS
- we are providing host support now so add yourself to usb.h
Ilya Yanok (13):
linux/usb/ch9.h: update with the version from Linux tree
usb: use linux/usb/ch9.h instead of usbdescriptors.h
musb-new: port of Linux musb driver
musb-new: dsps backend driver
am33xx: init OTG hardware and new musb gadget driver
am335x_evm: enable both musb gadget and host
musb-new: am35x backend driver
OMAP3: am35x_def.h: add USB defines
OMAP3: am35x: add musb functions
am3517_evm: switch to musb-new
musb-new: omap2plus backend driver
omap3_beagle: add musb-new init
omap3_beagle: use new MUSB intstead of the old one
Makefile | 1 + arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c | 2 +- arch/arm/cpu/armv7/am33xx/board.c | 103 +- arch/arm/cpu/armv7/am33xx/clock.c | 8 + arch/arm/cpu/armv7/omap3/Makefile | 1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 + arch/arm/include/asm/arch-am33xx/cpu.h | 11 +- arch/arm/include/asm/arch-am33xx/hardware.h | 4 + arch/arm/include/asm/arch-omap3/am35x_def.h | 27 + arch/arm/include/asm/arch-omap3/musb.h | 28 + arch/arm/include/asm/omap_musb.h | 32 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c | 2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c | 2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c | 2 +- board/logicpd/am3517evm/am3517evm.c | 74 + board/ti/beagle/beagle.c | 43 + common/cmd_usb.c | 2 +- common/usb.c | 4 +- drivers/usb/gadget/config.c | 1 - drivers/usb/gadget/epautoconf.c | 1 - drivers/usb/gadget/ether.c | 1 - drivers/usb/gadget/gadget_chips.h | 4 +- drivers/usb/gadget/s3c_udc_otg.c | 1 - drivers/usb/gadget/usbstring.c | 1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/usb/musb-new/Makefile | 39 + drivers/usb/musb-new/am35x.c | 709 +++++++ drivers/usb/musb-new/linux-compat.h | 119 ++ drivers/usb/musb-new/musb_core.c | 2497 +++++++++++++++++++++++++ drivers/usb/musb-new/musb_core.h | 623 ++++++ drivers/usb/musb-new/musb_debug.h | 58 + drivers/usb/musb-new/musb_dma.h | 186 ++ drivers/usb/musb-new/musb_dsps.c | 771 ++++++++ drivers/usb/musb-new/musb_gadget.c | 2333 +++++++++++++++++++++++ drivers/usb/musb-new/musb_gadget.h | 130 ++ drivers/usb/musb-new/musb_gadget_ep0.c | 1089 +++++++++++ drivers/usb/musb-new/musb_host.c | 2400 ++++++++++++++++++++++++ drivers/usb/musb-new/musb_host.h | 114 ++ drivers/usb/musb-new/musb_io.h | 146 ++ drivers/usb/musb-new/musb_regs.h | 645 +++++++ drivers/usb/musb-new/musb_uboot.c | 237 +++ drivers/usb/musb-new/omap2430.c | 626 +++++++ drivers/usb/musb-new/omap2430.h | 56 + drivers/usb/musb-new/usb-compat.h | 88 + drivers/usb/musb/musb_core.h | 3 +- drivers/usb/musb/musb_hcd.c | 5 +- include/configs/am335x_evm.h | 27 + include/configs/am3517_evm.h | 37 +- include/configs/omap3_beagle.h | 13 +- include/linux/usb/ch9.h | 514 ++++- include/linux/usb/musb.h | 162 ++ include/usb.h | 19 +- include/usb/s3c_udc.h | 1 - include/usb_defs.h | 6 - 57 files changed, 14015 insertions(+), 90 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap3/am35x_musb.c create mode 100644 arch/arm/include/asm/arch-omap3/musb.h 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/am35x.c create mode 100644 drivers/usb/musb-new/linux-compat.h 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_host.c create mode 100644 drivers/usb/musb-new/musb_host.h create mode 100644 drivers/usb/musb-new/musb_io.h create mode 100644 drivers/usb/musb-new/musb_regs.h create mode 100644 drivers/usb/musb-new/musb_uboot.c create mode 100644 drivers/usb/musb-new/omap2430.c create mode 100644 drivers/usb/musb-new/omap2430.h create mode 100644 drivers/usb/musb-new/usb-compat.h create mode 100644 include/linux/usb/musb.h
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 1/13 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.10.2 (Apple Git-33)
PATCH v4 2/13 usb: use linux/usb/ch9.h instead of usbdescriptors.h
In reply to Ilya YanokLinux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one.
As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device->speed instead.
Old usbdescriptors.h included is not removed as it seems to be used by old USB device code.
This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all).
---
Changes in v4:
- fix indent
Changes in v3:
- fix old MUSB code compilation
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c | 2 +- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c | 2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c | 2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c | 2 +- common/cmd_usb.c | 2 +- common/usb.c | 4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++++++++++++++-- drivers/usb/host/isp116x-hcd.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/usb/musb/musb_core.h | 3 +-- drivers/usb/musb/musb_hcd.c | 5 +++-- include/usb.h | 15 +++------------ include/usb_defs.h | 6 ------ 14 files changed, 31 insertions(+), 34 deletions(-)
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +1 -1
@@ -620,7 +620,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol (pipe) ?0 : (usb_pipeout (pipe) ?0x800 :0x1000 )) - |usb_pipeslow (pipe) <<13 | + | (usb_dev->speed ==USB_SPEED_LOW ) <<13 | usb_maxpacket(usb_dev, pipe) << 16);return ed_ret;
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +1 -1
@@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) << 7 | (usb_pipeisoc (pipe)?0x8000 :0 ) | (usb_pipecontrol (pipe)?0 : (usb_pipeout (pipe)?0x800 :0x1000 )) - |usb_pipeslow (pipe) <<13 + | (usb_dev->speed ==USB_SPEED_LOW ) <<13 | usb_maxpacket (usb_dev, pipe) << 16);return ed_ret;
arch/powerpc/cpu/mpc5xxx/usb_ohci.c +1 -1
@@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) << 7 | (usb_pipeisoc (pipe)?0x8000 :0 ) | (usb_pipecontrol (pipe)?0 : (usb_pipeout (pipe)?0x800 :0x1000 )) - |usb_pipeslow (pipe) <<13 + | (usb_dev->speed ==USB_SPEED_LOW ) <<13 | usb_maxpacket (usb_dev, pipe) << 16);return ed_ret;
arch/powerpc/cpu/ppc4xx/usb_ohci.c +1 -1
@@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) << 7 | (usb_pipeisoc (pipe)?0x8000 :0 ) | (usb_pipecontrol (pipe)?0 : (usb_pipeout (pipe)?0x800 :0x1000 )) - |usb_pipeslow (pipe) <<13 + | (usb_dev->speed ==USB_SPEED_LOW ) <<13 | usb_maxpacket (usb_dev, pipe) << 16);return ed_ret;
common/cmd_usb.c +1 -1
@@ -192,7 +192,7 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc (struct usb_configuration_descriptor *config, +void usb_display_conf_desc (struct usb_config_descriptor *config,struct usb_device *dev) {printf (" Configuration: %d\n" , config->bConfigurationValue);
common/usb.c +2 -2
@@ -492,9 +492,9 @@ int usb_get_configuration_no(struct usb_device *dev, {int result;unsigned int tmp; -struct usb_configuration_descriptor *config; +struct usb_config_descriptor *config; - config = (struct usb_configuration_descriptor *)&buffer[0 ]; + config = (struct usb_config_descriptor *)&buffer[0 ]; result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, buffer,9 );if (result <9 ) {if (result <0 )
drivers/usb/host/ehci-hcd.c +14 -2
@@ -210,6 +210,18 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)return 0 ; } +static inline u8 ehci_encode_speed (enum usb_device_speed speed) +{ +#define QH_HIGH_SPEED 2 +#define QH_FULL_SPEED 0 +#define QH_LOW_SPEED 1 +if (speed ==USB_SPEED_HIGH ) +return QH_HIGH_SPEED ; +if (speed ==USB_SPEED_LOW ) +return QH_LOW_SPEED ; +return QH_FULL_SPEED ; +} +static int ehci_submit_async (struct usb_device *dev,unsigned long pipe,void *buffer,int length,struct devrequest *req)
@@ -318,12 +330,12 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,* - qh_overlay.qt_altnext */ qh->qh_link =cpu_to_hc32 ((uint32_t )&ctrl->qh_list |QH_LINK_TYPE_QH ); - c =usb_pipespeed (pipe) !=USB_SPEED_HIGH && !usb_pipeendpoint (pipe); + c = (dev->speed !=USB_SPEED_HIGH ) && !usb_pipeendpoint (pipe); maxpacket =usb_maxpacket (dev, pipe); endpt =QH_ENDPT1_RL (8 ) |QH_ENDPT1_C (c) |QH_ENDPT1_MAXPKTLEN (maxpacket) |QH_ENDPT1_H (0 ) |QH_ENDPT1_DTC (QH_ENDPT1_DTC_DT_FROM_QTD ) | -QH_ENDPT1_EPS (usb_pipespeed (pipe)) | +QH_ENDPT1_EPS (ehci_encode_speed (dev->speed)) |QH_ENDPT1_ENDPT (usb_pipeendpoint (pipe)) |QH_ENDPT1_I (0 ) |QH_ENDPT1_DEVADDR (usb_pipedevice (pipe)); qh->qh_endpt1 =cpu_to_hc32 (endpt);
drivers/usb/host/isp116x-hcd.c +1 -1
@@ -617,7 +617,7 @@ static int isp116x_submit_job(struct usb_device *dev, unsigned long pipe,int epnum =usb_pipeendpoint (pipe);int max =usb_maxpacket (dev, pipe);int dir_out =usb_pipeout (pipe); -int speed_low =usb_pipeslow (pipe); +int speed_low = (dev->speed ==USB_SPEED_LOW );int i, done =0 , stat, timeout, cc;/* 500 frames or 0.5s timeout when function is busy and NAKs transactions for a while */
drivers/usb/host/ohci-hcd.c +1 -1
@@ -803,7 +803,7 @@ static ed_t *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe, | (usb_pipeisoc(pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)?0 : \ (usb_pipeout (pipe)?0x800 :0x1000 )) - |usb_pipeslow (pipe) <<13 + | (usb_dev->speed ==USB_SPEED_LOW ) <<13 | usb_maxpacket(usb_dev, pipe) << 16);if (ed->type ==PIPE_INTERRUPT && ed->state ==ED_UNLINK ) {
drivers/usb/host/sl811-hcd.c +1 -1
@@ -234,7 +234,7 @@ static int sl811_send_packet(struct usb_device *dev, unsigned long pipe, __u8 *b__u16 status =0 ;int err =0 , time_start =get_timer (0 );int need_preamble = !(rh_status.wPortStatus &USB_PORT_STAT_LOW_SPEED ) && -usb_pipeslow (pipe); + (dev->speed ==USB_SPEED_LOW );if (len >239 )return -1 ;
drivers/usb/musb/musb_core.h +1 -2
@@ -34,7 +34,6 @@#ifndef __MUSB_HDRC_DEFS_H__#define __MUSB_HDRC_DEFS_H__ -#include <usb.h> #include <usb_defs.h> #include <asm/io.h>
@@ -145,7 +144,7 @@ struct musb_regs { struct musb_epN_regs epN; } ep[16 ]; -} __attribute__((packed, aligned(USB_DMA_MINALIGN))); +} __attribute__((packed));#endif /*
drivers/usb/musb/musb_hcd.c +3 -2
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <usb.h> #include "musb_hcd.h" /* MSC control transfers */
@@ -485,8 +486,8 @@ static int ctrlreq_in_status_phase(struct usb_device *dev)*/ static u8 get_dev_speed (struct usb_device *dev) { -return (dev->speed &USB_SPEED_HIGH ) ?MUSB_TYPE_SPEED_HIGH : - ((dev->speed &USB_SPEED_LOW ) ?MUSB_TYPE_SPEED_LOW : +return (dev->speed ==USB_SPEED_HIGH ) ?MUSB_TYPE_SPEED_HIGH : + ((dev->speed ==USB_SPEED_LOW ) ?MUSB_TYPE_SPEED_LOW :MUSB_TYPE_SPEED_FULL ); }
include/usb.h +3 -12
@@ -27,7 +27,7 @@#define _USB_H_#include <usb_defs.h> -#include <usbdescriptors.h> +#include <linux/usb/ch9.h> /* * The EHCI spec says that we must align to at least 32 bytes. However,
@@ -67,12 +67,6 @@ struct devrequest {unsigned short length; } __attribute__ ((packed)); -/* All standard descriptors have these 2 fields in common */ -struct usb_descriptor_header { -unsigned char bLength; -unsigned char bDescriptorType; -} __attribute__ ((packed)); -/* Interface */ struct usb_interface {struct usb_interface_descriptor desc;
@@ -86,7 +80,7 @@ struct usb_interface {/* Configuration information.. */ struct usb_config { -struct usb_configuration_descriptor desc; +struct usb_config_descriptor desc;unsigned char no_of_if;/* number of interfaces */ struct usb_interface if_desc[USB_MAXINTERFACES ];
@@ -285,7 +279,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);* - device: bits 8-14 * - endpoint: bits 15-18 * - Data0/1: bit 19 -* - speed: bit 26 (0 = Full, 1 = Low Speed, 2 = High) * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, * 10 = control, 11 = bulk) *
@@ -297,7 +290,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);/* Create various pipes... */ #define create_pipe (dev,endpoint) \ (((dev)->devnum << 8) | ((endpoint) << 15) | \ - ((dev)->speed << 26) | (dev)->maxpacketsize) + (dev)->maxpacketsize)#define default_pipe (dev) ((dev)->speed << 26)#define usb_sndctrlpipe (dev, endpoint) ((PIPE_CONTROL << 30) | \
@@ -348,8 +341,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);#define usb_pipe_endpdev (pipe) (((pipe) >> 8) & 0x7ff)#define usb_pipeendpoint (pipe) (((pipe) >> 15) & 0xf)#define usb_pipedata (pipe) (((pipe) >> 19) & 1) -#define usb_pipespeed (pipe) (((pipe) >> 26) & 3) -#define usb_pipeslow (pipe) (usb_pipespeed(pipe) == USB_SPEED_LOW)#define usb_pipetype (pipe) (((pipe) >> 30) & 3)#define usb_pipeisoc (pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)#define usb_pipeint (pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT)
include/usb_defs.h +0 -6
@@ -80,12 +80,6 @@#define USB_DIR_OUT 0#define USB_DIR_IN 0x80 -/* USB device speeds */ -#define USB_SPEED_FULL 0x0/* 12Mbps */ -#define USB_SPEED_LOW 0x1/* 1.5Mbps */ -#define USB_SPEED_HIGH 0x2/* 480Mbps */ -#define USB_SPEED_RESERVED 0x3 -/* Descriptor types */ #define USB_DT_DEVICE 0x01#define USB_DT_CONFIG 0x02
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 3/13 musb-new: port of Linux musb driver
In reply to Ilya YanokExisting 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 driver supports both host and peripheral modes.
This is not a replacement for current musb driver (at least now) as there are still some consumers of the old UDC interface.
No DMA operation support included, CONFIG_MUSB_PIO_ONLY should be defined.
Virtual root hub device is not implemented.
Known problems: with no devices connected usb_lowlevel_start() fails.
---
Changes in v4:
- minor style fixes
Changes in v3:
- bugfix: struct musb should be zeroed after alloc
- fix musb gadget_chips entry
- fix for new multi-interface usb API
Changes in v2:
- add missing linux-compat.h header
- added host support
- glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly.
- added check for malloc return value
- define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled
- added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled
Makefile | 1 + drivers/usb/gadget/gadget_chips.h | 4 +- drivers/usb/musb-new/Makefile | 36 + drivers/usb/musb-new/linux-compat.h | 109 ++ drivers/usb/musb-new/musb_core.c | 2497 ++++++++++++++++++++++++++++++++ drivers/usb/musb-new/musb_core.h | 623 ++++++++ drivers/usb/musb-new/musb_debug.h | 58 + drivers/usb/musb-new/musb_dma.h | 186 +++ drivers/usb/musb-new/musb_gadget.c | 2333 +++++++++++++++++++++++++++++ drivers/usb/musb-new/musb_gadget.h | 130 ++ drivers/usb/musb-new/musb_gadget_ep0.c | 1089 ++++++++++++++ drivers/usb/musb-new/musb_host.c | 2400 ++++++++++++++++++++++++++++++ drivers/usb/musb-new/musb_host.h | 114 ++ drivers/usb/musb-new/musb_io.h | 146 ++ drivers/usb/musb-new/musb_regs.h | 645 +++++++++ drivers/usb/musb-new/musb_uboot.c | 237 +++ drivers/usb/musb-new/usb-compat.h | 88 ++ include/linux/usb/musb.h | 162 +++ 18 files changed, 10856 insertions(+), 2 deletions(-) create mode 100644 drivers/usb/musb-new/Makefile create mode 100644 drivers/usb/musb-new/linux-compat.h 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_host.c create mode 100644 drivers/usb/musb-new/musb_host.h create mode 100644 drivers/usb/musb-new/musb_io.h create mode 100644 drivers/usb/musb-new/musb_regs.h create mode 100644 drivers/usb/musb-new/musb_uboot.c create mode 100644 drivers/usb/musb-new/usb-compat.h create mode 100644 include/linux/usb/musb.h
Makefile +1 -0
@@ -299,6 +299,7 @@ LIBS-y += drivers/usb/eth/libusb_eth.o 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/phy/libusb_phy.o LIBS-y += drivers/usb/ulpi/libusb_ulpi.o LIBS-y += drivers/video/libvideo.o
drivers/usb/gadget/gadget_chips.h +2 -2
@@ -131,8 +131,8 @@#endif /* 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)) +#ifdef 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 +36 -0
@@ -0,0 +1,36 @@ +# +# 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_uboot.o +COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_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 := $(sort $(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/linux-compat.h new file +109 -0
109 lines not on this page · raw message
drivers/usb/musb-new/musb_core.c new file +2497 -0
2,497 lines not on this page · raw message
drivers/usb/musb-new/musb_core.h new file +623 -0
341 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 +2333 -0
2,333 lines not on this page · raw message
drivers/usb/musb-new/musb_gadget.h new file +130 -0
130 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_host.c new file +2400 -0
2,400 lines not on this page · raw message
drivers/usb/musb-new/musb_host.h new file +114 -0
114 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
drivers/usb/musb-new/musb_uboot.c new file +237 -0
237 lines not on this page · raw message
drivers/usb/musb-new/usb-compat.h new file +88 -0
88 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.10.2 (Apple Git-33)
Part of the diff is not shown here. View the raw message.
PATCH v4 4/13 musb-new: dsps backend driver
In reply to Ilya YanokBackend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only).
---
Changes in v2:
- rename backend config option to CONFIG_USB_MUSB_DSPS
- we are providing host support now so add yourself to usb.h
arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile | 1 + drivers/usb/musb-new/musb_dsps.c | 771 ++++++++++++++++++++++++++++++++++++++ include/usb.h | 3 +- 4 files changed, 799 insertions(+), 1 deletion(-) 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
@@ -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
@@ -9,6 +9,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_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += 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 +771 -0
771 lines not on this page · raw message
include/usb.h +2 -1
@@ -147,7 +147,8 @@ struct usb_device {defined (CONFIG_USB_SL811HS ) ||defined (CONFIG_USB_ISP116X_HCD ) || \defined (CONFIG_USB_R8A66597_HCD ) ||defined (CONFIG_USB_DAVINCI ) || \defined (CONFIG_USB_OMAP3 ) ||defined (CONFIG_USB_DA8XX ) || \ - defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) +defined (CONFIG_USB_BLACKFIN ) ||defined (CONFIG_USB_AM35X ) || \ + defined(CONFIG_USB_MUSB_DSPS)int usb_lowlevel_init (int index,void **controller);int usb_lowlevel_stop (int index);
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 5/13 am33xx: init OTG hardware and new musb gadget driver
In reply to Ilya YanokAM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget.
---
Changes in v3:
- use clrsetbits_le32 for USB PHY ops
arch/arm/cpu/armv7/am33xx/board.c | 103 ++++++++++++++++++++++++++- 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, 122 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +102 -1
@@ -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 ;
@@ -209,6 +214,84 @@ void setup_clocks_for_console(void)return ; } +/* AM33XX has two MUSB controllers which can be host or gadget */ +#if (defined(CONFIG_MUSB_GADGET ) || defined(CONFIG_MUSB_HOST )) && \ + (defined(CONFIG_AM335X_USB0 ) || defined(CONFIG_AM335X_USB1 )) +/* 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 *reg_addr) +{ +if (on) { +clrsetbits_le32 (reg_addr,CM_PHY_PWRDN |CM_PHY_OTG_PWRDN , +OTGVDET_EN |OTGSESSENDEN ); + }else { +clrsetbits_le32 (reg_addr,0 ,CM_PHY_PWRDN |CM_PHY_OTG_PWRDN ); + } +} + +static struct musb_hdrc_config musb_config = { + .multipoint =1 , + .dyn_fifo =1 , + .num_eps =16 , + .ram_bits =12 , +}; + +#ifdef CONFIG_AM335X_USB0 +static void am33xx_otg0_set_phy_power (u8 on) +{ +am33xx_usb_set_phy_power (on, &cdev->usb_ctrl0); +} + +struct omap_musb_board_data otg0_board_data = { + .set_phy_power = am33xx_otg0_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg0_plat = { + .mode =CONFIG_AM335X_USB0_MODE , + .config = &musb_config, + .power =50 , + .platform_ops = &musb_dsps_ops, + .board_data = &otg0_board_data, +}; +#endif + +#ifdef CONFIG_AM335X_USB1 +static void am33xx_otg1_set_phy_power (u8 on) +{ +am33xx_usb_set_phy_power (on, &cdev->usb_ctrl1); +} + +struct omap_musb_board_data otg1_board_data = { + .set_phy_power = am33xx_otg1_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg1_plat = { + .mode =CONFIG_AM335X_USB1_MODE , + .config = &musb_config, + .power =50 , + .platform_ops = &musb_dsps_ops, + .board_data = &otg1_board_data, +}; +#endif +#endif + +int arch_misc_init (void ) +{ +#ifdef CONFIG_AM335X_USB0 +musb_register (&otg0_plat, &otg0_board_data, + (void *)AM335X_USB0_OTG_BASE ); +#endif +#ifdef CONFIG_AM335X_USB1 +musb_register (&otg1_plat, &otg1_board_data, + (void *)AM335X_USB1_OTG_BASE ); +#endif +return 0 ; +} +/* * Basic board specific setup. Pinmux has been handled already. */
@@ -261,9 +344,14 @@ static struct cpsw_platform_data cpsw_data = { .host_port_num = 0, .version = CPSW_CTRL_VERSION_2, }; +#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;
@@ -295,6 +383,19 @@ 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 =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
@@ -40,6 +40,7 @@#define CLK_MODE_MASK 0xfffffff8#define CLK_DIV_SEL 0xFFFFFFE0#define CPGMAC0_IDLE 0x30000 +#define DPLL_CLKDCOLDO_GATE_CTRL 0x300const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER ;const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP ;
@@ -153,6 +154,11 @@ static void enable_per_clocks(void)writel (PRCM_MOD_EN , &cmper->spi0clkctrl);while (readl (&cmper->spi0clkctrl) !=PRCM_MOD_EN ) ; + +/* MUSB */ +writel (PRCM_MOD_EN , &cmper->usb0clkctrl); +while (readl (&cmper->usb0clkctrl) !=PRCM_MOD_EN ) + ; }static void mpu_pll_config (void )
@@ -249,6 +255,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
@@ -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 */
@@ -260,12 +261,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
@@ -83,4 +83,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.10.2 (Apple Git-33)
PATCH v4 6/13 am335x_evm: enable both musb gadget and host
In reply to Ilya YanokEnable musb gadget in Ethernet mode on port 0 and
musb host on port1.
---
include/configs/am335x_evm.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
include/configs/am335x_evm.h +27 -0
@@ -237,6 +237,33 @@#define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* +* USB configuration +*/ +#define CONFIG_USB_MUSB_DSPS +#define CONFIG_ARCH_MISC_INIT +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_MUSB_HOST +#define CONFIG_AM335X_USB0 +#define CONFIG_AM335X_USB0_MODE MUSB_PERIPHERAL +#define CONFIG_AM335X_USB1 +#define CONFIG_AM335X_USB1_MODE MUSB_HOST + +#ifdef CONFIG_MUSB_HOST +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#endif + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +/* Unsupported features */ +#undef CONFIG_USE_IRQ +#define CONFIG_CMD_NET #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 7/13 musb-new: am35x backend driver
In reply to Ilya YanokBackend driver for MUSB OTG controllers found on TI AM35x.
It seems that on AM35X interrupt status registers can be updated _before_ core registers. As we don't use true interrupts in U-Boot and poll interrupt status registers instead this can result in interrupt handler being called with non-updated core registers. This confuses the code and result in hanged transfers. Add a small delay in am35x_interrupt as a workaround.
---
arch/arm/include/asm/omap_musb.h | 3 + drivers/usb/musb-new/Makefile | 1 + drivers/usb/musb-new/am35x.c | 709 +++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/linux-compat.h | 1 + include/usb.h | 2 +- 5 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/am35x.c
arch/arm/include/asm/omap_musb.h +3 -0
@@ -18,8 +18,11 @@#define __ASM_ARM_OMAP_MUSB_Hextern struct musb_platform_ops musb_dsps_ops; +extern const struct musb_platform_ops am35x_ops;struct omap_musb_board_data {void (*set_phy_power)(u8 on); +void (*clear_irq)(void ); +void (*reset)(void ); };#endif /* __ASM_ARM_OMAP_MUSB_H */
drivers/usb/musb-new/Makefile +1 -0
@@ -10,6 +10,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \
drivers/usb/musb-new/am35x.c new file +709 -0
709 lines not on this page · raw message
drivers/usb/musb-new/linux-compat.h +1 -0
@@ -106,4 +106,5 @@ typedef unsigned long dmaaddr_t;#define wmb () asm volatile ("" : : : "memory")#endif +#define msleep (a) udelay(a * 1000)#endif /* __LINUX_COMPAT_H__ */
include/usb.h +1 -1
@@ -148,7 +148,7 @@ struct usb_device {defined (CONFIG_USB_R8A66597_HCD ) ||defined (CONFIG_USB_DAVINCI ) || \defined (CONFIG_USB_OMAP3 ) ||defined (CONFIG_USB_DA8XX ) || \defined (CONFIG_USB_BLACKFIN ) ||defined (CONFIG_USB_AM35X ) || \ - defined(CONFIG_USB_MUSB_DSPS) + defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X)int usb_lowlevel_init (int index,void **controller);int usb_lowlevel_stop (int index);
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 8/13 OMAP3: am35x_def.h: add USB defines
In reply to Ilya YanokAdd defines for MUSB IP block on AM35X SoCs.
---
arch/arm/include/asm/arch-omap3/am35x_def.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm/include/asm/arch-omap3/am35x_def.h +27 -0
@@ -32,9 +32,34 @@#ifndef __KERNEL_STRICT_NAMES#ifndef __ASSEMBLY__ +/* LVL_INTR_CLEAR bits */ +#define USBOTGSS_INT_CLR (1 << 4) +/* IP_SW_RESET bits */ +#define USBOTGSS_SW_RST (1 << 0)/* reset USBOTG */ #define CPGMACSS_SW_RST (1 << 1)/* reset CPGMAC */ +/* DEVCONF2 bits */ +#define CONF2_PHY_GPIOMODE (1 << 23) +#define CONF2_OTGMODE (3 << 14) +#define CONF2_NO_OVERRIDE (0 << 14) +#define CONF2_FORCE_HOST (1 << 14) +#define CONF2_FORCE_DEVICE (2 << 14) +#define CONF2_FORCE_HOST_VBUS_LOW (3 << 14) +#define CONF2_SESENDEN (1 << 13) +#define CONF2_VBDTCTEN (1 << 12) +#define CONF2_REFFREQ_24MHZ (2 << 8) +#define CONF2_REFFREQ_26MHZ (7 << 8) +#define CONF2_REFFREQ_13MHZ (6 << 8) +#define CONF2_REFFREQ (0xf << 8) +#define CONF2_PHYCLKGD (1 << 7) +#define CONF2_VBUSSENSE (1 << 6) +#define CONF2_PHY_PLLON (1 << 5) +#define CONF2_RESET (1 << 4) +#define CONF2_PHYPWRDN (1 << 3) +#define CONF2_OTGPWRDN (1 << 2) +#define CONF2_DATPOL (1 << 1) +/* General register mappings of system control module */ #define AM35X_SCM_GEN_BASE 0x48002270 struct am35x_scm_general {
@@ -49,6 +74,8 @@ struct am35x_scm_general { };#define am35x_scm_general_regs ((struct am35x_scm_general *)AM35X_SCM_GEN_BASE) +#define AM35XX_IPSS_USBOTGSS_BASE 0x5C040000 +#endif /*__ASSEMBLY__ */ #endif /* __KERNEL_STRICT_NAMES */
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 9/13 OMAP3: am35x: add musb functions
In reply to Ilya YanokAM35XX specific functions for integrated USB PHY/MUSB IP.
---
arch/arm/cpu/armv7/omap3/Makefile | 1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 ++++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-omap3/musb.h | 28 ++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 arch/arm/cpu/armv7/omap3/am35x_musb.c create mode 100644 arch/arm/include/asm/arch-omap3/musb.h
arch/arm/cpu/armv7/omap3/Makefile +1 -0
@@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_DRIVER_TI_EMAC) += emac.o COBJS-$(CONFIG_EMIF4) += emif4.o COBJS-$(CONFIG_SDRC) += sdrc.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x_musb.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS))
arch/arm/cpu/armv7/omap3/am35x_musb.c new file +75 -0
75 lines not on this page · raw message
arch/arm/include/asm/arch-omap3/musb.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* (C) Copyright 2012 +* Ilya Yanok, <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* 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. +*/ + +#ifndef __ASM_ARCH_OMAP3_MUSB_H +#define __ASM_ARCH_OMAP3_MUSB_H +extern void am35x_musb_reset (void ); +extern void am35x_musb_phy_power (u8 on); +extern void am35x_musb_clear_irq (void ); +#endif
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 10/13 am3517_evm: switch to musb-new
In reply to Ilya YanokUse new musb framework instead of the old one on AM3517_EVM.
---
board/logicpd/am3517evm/am3517evm.c | 74 +++++++++++++++++++++++++++++++++++ include/configs/am3517_evm.h | 37 ++++++++---------- 2 files changed, 90 insertions(+), 21 deletions(-)
board/logicpd/am3517evm/am3517evm.c +74 -0
@@ -25,12 +25,20 @@#include <common.h> #include <asm/io.h> +#include <asm/omap_musb.h> +#include <asm/arch/am35x_def.h> #include <asm/arch/mem.h> #include <asm/arch/mux.h> #include <asm/arch/sys_proto.h> #include <asm/arch/mmc_host_def.h> +#include <asm/arch/musb.h> #include <asm/mach-types.h> +#include <asm/errno.h> +#include <linux/usb/ch9.h> +#include <linux/usb/gadget.h> +#include <linux/usb/musb.h> #include <i2c.h> +#include <netdev.h> #include "am3517evm.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -50,6 +58,52 @@ int board_init(void)return 0 ; } +#ifdef CONFIG_USB_MUSB_AM35X +static struct musb_hdrc_config musb_config = { + .multipoint =1 , + .dyn_fifo =1 , + .num_eps =16 , + .ram_bits =12 , +}; + +static struct omap_musb_board_data musb_board_data = { + .set_phy_power = am35x_musb_phy_power, + .clear_irq = am35x_musb_clear_irq, + .reset = am35x_musb_reset, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST ) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET ) + .mode = MUSB_PERIPHERAL, +#else +#error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET" +#endif + .config = &musb_config, + .power = 250, + .platform_ops = &am35x_ops, + .board_data = &musb_board_data, +}; + +static void am3517_evm_musb_init (void ) +{ +/* +* Set up USB clock/mode in the DEVCONF2 register. +* USB2.0 PHY reference clock is 13 MHz +*/ +clrsetbits_le32 (&am35x_scm_general_regs->devconf2, +CONF2_REFFREQ |CONF2_OTGMODE |CONF2_PHY_GPIOMODE , +CONF2_REFFREQ_13MHZ |CONF2_SESENDEN | +CONF2_VBDTCTEN |CONF2_DATPOL ); + +musb_register (&musb_plat, &musb_board_data, + (void *)AM35XX_IPSS_USBOTGSS_BASE ); +} +#else +#define am3517_evm_musb_init () do {} while (0) +#endif +/* * Routine: misc_init_r * Description: Init i2c, ethernet, etc... (done here so udelay works)
@@ -62,6 +116,8 @@ int misc_init_r(void)dieid_num_r (); +am3517_evm_musb_init (); +return 0 ; }
@@ -83,3 +139,21 @@ int board_mmc_init(bd_t *bis) return 0; }#endif + +#if defined(CONFIG_USB_ETHER ) && defined(CONFIG_MUSB_GADGET ) +int board_eth_init (bd_t *bis) +{ +int rv, n =0 ; + + rv =cpu_eth_init (bis); +if (rv >0 ) + n += rv; + + rv =usb_eth_initialize (bis); +if (rv >0 ) + n += rv; + +return n; +} +#endif +
include/configs/am3517_evm.h +16 -21
@@ -97,15 +97,16 @@/* * USB configuration -* Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard -* Enable CONFIG_MUSB_UDC for Device functionalities. +* Enable CONFIG_MUSB_HOST for Host functionalities MSC, keyboard +* Enable CONFIG_MUSB_GADGET for Device functionalities. */ -#define CONFIG_USB_AM35X 1 -#define CONFIG_MUSB_HCD 1 +#define CONFIG_USB_MUSB_AM35X +#define CONFIG_MUSB_HOST +#define CONFIG_MUSB_PIO_ONLY -#ifdef CONFIG_USB_AM35X +#ifdef CONFIG_USB_MUSB_AM35X -#ifdef CONFIG_MUSB_HCD +#ifdef CONFIG_MUSB_HOST #define CONFIG_CMD_USB #define CONFIG_USB_STORAGE
@@ -117,21 +118,15 @@#define CONFIG_PREBOOT "usb start"#endif /* CONFIG_USB_KEYBOARD */ -#endif /* CONFIG_MUSB_HCD */ - -#ifdef CONFIG_MUSB_UDC -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 -/* Change these to suit your needs */ -#define CONFIG_USBD_VENDORID 0x0451 -#define CONFIG_USBD_PRODUCTID 0x5678 -#define CONFIG_USBD_MANUFACTURER "Texas Instruments" -#define CONFIG_USBD_PRODUCT_NAME "AM3517EVM" -#endif /* CONFIG_MUSB_UDC */ - -#endif /* CONFIG_USB_AM35X */ +#endif /* CONFIG_MUSB_HOST */ + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +#endif /* CONFIG_USB_MUSB_AM35X */ /* commands to include */ #include <config_cmd_default.h>
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 11/13 musb-new: omap2plus backend driver
In reply to Ilya YanokBackend driver for MUSB OTG controllers found on TI OMAP2/3/4 (tested only on OMAP3 Beagle).
---
arch/arm/include/asm/omap_musb.h | 4 + drivers/usb/musb-new/Makefile | 1 + drivers/usb/musb-new/linux-compat.h | 9 + drivers/usb/musb-new/omap2430.c | 626 +++++++++++++++++++++++++++++++++++ drivers/usb/musb-new/omap2430.h | 56 ++++ include/usb.h | 3 +- 6 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/omap2430.c create mode 100644 drivers/usb/musb-new/omap2430.h
arch/arm/include/asm/omap_musb.h +4 -0
@@ -19,10 +19,14 @@extern struct musb_platform_ops musb_dsps_ops;extern const struct musb_platform_ops am35x_ops; +extern const struct musb_platform_ops omap2430_ops;struct omap_musb_board_data { +u8 interface_type;void (*set_phy_power)(u8 on);void (*clear_irq)(void );void (*reset)(void ); }; + +enum musb_interface {MUSB_INTERFACE_ULPI ,MUSB_INTERFACE_UTMI };#endif /* __ASM_ARM_OMAP_MUSB_H */
drivers/usb/musb-new/Makefile +1 -0
@@ -11,6 +11,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o +COBJS-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \
drivers/usb/musb-new/linux-compat.h +9 -0
@@ -37,6 +37,7 @@ typedef unsigned long dmaaddr_t;#define spin_unlock_irqrestore (lock, flags) do {} while (0)#define setup_timer (timer, func, data) do {} while (0) +#define del_timer_sync (timer) do {} while (0)#define schedule_work (work) do {} while (0)#define INIT_WORK (work, fun) do {} while (0)
@@ -107,4 +108,12 @@ typedef unsigned long dmaaddr_t;#endif #define msleep (a) udelay(a * 1000) + +/* +* Map U-Boot config options to Linux ones +*/ +#ifdef CONFIG_OMAP34XX +#define CONFIG_SOC_OMAP3430 +#endif +#endif /* __LINUX_COMPAT_H__ */
drivers/usb/musb-new/omap2430.c new file +626 -0
626 lines not on this page · raw message
drivers/usb/musb-new/omap2430.h new file +56 -0
56 lines not on this page · raw message
include/usb.h +2 -1
@@ -148,7 +148,8 @@ struct usb_device {defined (CONFIG_USB_R8A66597_HCD ) ||defined (CONFIG_USB_DAVINCI ) || \defined (CONFIG_USB_OMAP3 ) ||defined (CONFIG_USB_DA8XX ) || \defined (CONFIG_USB_BLACKFIN ) ||defined (CONFIG_USB_AM35X ) || \ - defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) +defined (CONFIG_USB_MUSB_DSPS ) ||defined (CONFIG_USB_MUSB_AM35X ) || \ + defined(CONFIG_USB_MUSB_OMAP2PLUS)int usb_lowlevel_init (int index,void **controller);int usb_lowlevel_stop (int index);
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 12/13 omap3_beagle: add musb-new init
In reply to Ilya YanokAdd initialization for new MUSB framework.
---
board/ti/beagle/beagle.c | 43 ++++++++++++++++++++++++++++++++++++++++ include/configs/omap3_beagle.h | 2 ++ 2 files changed, 45 insertions(+)
board/ti/beagle/beagle.c +43 -0
@@ -42,6 +42,11 @@#include <asm/arch/sys_proto.h> #include <asm/gpio.h> #include <asm/mach-types.h> +#include <asm/omap_musb.h> +#include <asm/errno.h> +#include <linux/usb/ch9.h> +#include <linux/usb/gadget.h> +#include <linux/usb/musb.h> #include "beagle.h" #include <command.h>
@@ -285,6 +290,33 @@ static void beagle_dvi_pup(void) }#endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS +static struct musb_hdrc_config musb_config = { + .multipoint =1 , + .dyn_fifo =1 , + .num_eps =16 , + .ram_bits =12 , +}; + +static struct omap_musb_board_data musb_board_data = { + .interface_type =MUSB_INTERFACE_ULPI , +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST ) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET ) + .mode = MUSB_PERIPHERAL, +#else +#error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET" +#endif + .config = &musb_config, + .power = 100, + .platform_ops = &omap2430_ops, + .board_data = &musb_board_data, +}; +#endif +/* * Routine: misc_init_r * Description: Configure board specific parts
@@ -466,6 +498,10 @@ int misc_init_r(void)omap3_dss_enable ();#endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS +musb_register (&musb_plat, &musb_board_data, (void *)MUSB_BASE ); +#endif +return 0 ; }
@@ -513,3 +549,10 @@ int ehci_hcd_stop(int index) }#endif /* CONFIG_USB_EHCI */ + +#if defined(CONFIG_USB_ETHER ) && defined(CONFIG_MUSB_GADGET ) +int board_eth_init (bd_t *bis) +{ +return usb_eth_initialize (bis); +} +#endif
include/configs/omap3_beagle.h +2 -0
@@ -120,6 +120,8 @@#define CONFIG_MUSB_UDC 1#define CONFIG_USB_OMAP3 1#define CONFIG_TWL4030_USB 1 +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETHER_RNDIS /* USB device configuration */ #define CONFIG_USB_DEVICE 1
Signature · 1 line
1.7.10.2 (Apple Git-33)
PATCH v4 13/13 omap3_beagle: use new MUSB intstead of the old one
In reply to Ilya YanokEnable using of new MUSB framework on Beagle.
NOTE! This is not just a change of backend code: top-level behavior is also changed, we now use USB device port for USB Ethernet instead of serial.
---
include/configs/omap3_beagle.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
include/configs/omap3_beagle.h +4 -7
@@ -117,17 +117,14 @@#define CONFIG_SYS_I2C_NOPROBES {{0x0, 0x0}}/* USB */ -#define CONFIG_MUSB_UDC 1 -#define CONFIG_USB_OMAP3 1 +#define CONFIG_MUSB_GADGET +#define CONFIG_USB_MUSB_OMAP2PLUS +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED #define CONFIG_TWL4030_USB 1#define CONFIG_USB_ETHER #define CONFIG_USB_ETHER_RNDIS -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 -/* USB EHCI */ #define CONFIG_CMD_USB #define CONFIG_USB_EHCI
Signature · 1 line
1.7.10.2 (Apple Git-33)
v4 cover Port of MUSB driver from Linux (changes from Linux)
In reply to Ilya YanokDear Ilya Yanok,
Quoted 2 lines
My apologies for double posting -- I was so stupid to forget to fix the Signed-off-by lines....
[...]
Hi, sorry, but this doesn't apply anymore, can you rebase and repost please?
Best regards,
Marek Vasut