Make mv_udc work for i.mx6
Subsystems (3)
cover Make mv_udc work for i.mx6
Hi Marek,
This series is based on your u-boot-testing/chipidea branch. After this series, nitrogen6x works with tftpboot to transfer files over usb. But I still cannot enable CONFIG_USB_TTY because of link errors.
Do you have a plan for defining the following symbols in general code? setup_epudc_endpoint_writeudc_initudc_startup_eventsudc_connectudc_unset_nakudc_set_nakudc_unset_nak
Or should usbtty be hacked to use more gadget style functions?
Troy Kisky (18):
Add functions for use with i.mx6 otg udc
mx6: iomux: add GPR1 defines
mx6: define OTG_BASE_ADDR
nitrogen6x: add otg usb ethernet gadget support
nitrogen6x: add CONFIG_MV_UDC
usb: gadget: config: fix unaligned access issues
usb: gadget: mv_udc: set udc after controller.udc is initialized
usb: gadget: mv_udc: add MX6Q specific reset
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: use static initialization of ops,udc
usb: gadget: mv_udc: set is_dualspeed = 1
usb: gadget: mv_udc: fix full speed connections
usb: gadget: mv_udc: fix cache issues
usb: gadget: mv_udc: clear desc upon ep_disable
arch/arm/cpu/armv7/mx6/soc.c | 70 ++++++++++++++++++ arch/arm/include/asm/arch-mx6/imx-regs.h | 2 + arch/arm/include/asm/arch-mx6/iomux.h | 6 ++ arch/arm/include/asm/arch-mx6/sys_proto.h | 4 + board/boundary/nitrogen6x/nitrogen6x.c | 16 ++++ drivers/serial/usbtty.h | 3 +- drivers/usb/gadget/config.c | 6 +- drivers/usb/gadget/ether.c | 5 +- drivers/usb/gadget/mv_udc.c | 100 ++++++++++++++++++------- drivers/usb/gadget/mv_udc.h | 117 +++++++++++++++++++++++++++++ include/configs/nitrogen6x.h | 7 ++ include/usb/designware_udc.h | 31 -------- include/usb/mpc8xx_udc.h | 19 +---- include/usb/musb_udc.h | 53 -------------- include/usb/mv_udc.h | 118 ------------------------------ include/usb/omap1510_udc.h | 27 +------ include/usb/pxa27x_udc.h | 26 +------ include/usb/udc.h | 60 +++++++++++++++ 18 files changed, 371 insertions(+), 299 deletions(-) create mode 100644 drivers/usb/gadget/mv_udc.h create mode 100644 include/usb/udc.h
Signature · 1 line
1.8.1.2
RFC PATCH 1/18 Add functions for use with i.mx6 otg udc
Add functions for use with mx6 soc
void otg_enable(void);
void reset_usb_phy1(void);
--- arch/arm/cpu/armv7/mx6/soc.c | 70 +++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 4 ++ 2 files changed, 74 insertions(+)
arch/arm/cpu/armv7/mx6/soc.c +70 -0
@@ -28,11 +28,81 @@#include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> +#include <asm/arch/crm_regs.h> #include <asm/arch/sys_proto.h> #include <asm/imx-common/boot_mode.h> #include <asm/imx-common/dma.h> #include <stdbool.h> +#ifdef CONFIG_MV_UDC + +struct set_clr_tog { +u32 val; +u32 set; +u32 clr; +u32 tog; +}; + +struct usbphy { +struct set_clr_tog pwd; +struct set_clr_tog tx; +struct set_clr_tog rx; +struct set_clr_tog ctrl; +}; + +#define BM_USBPHY_CTRL_CLKGATE 0x40000000 + +static void enable_usb_phy1_clk (unsigned char enable) +{ +struct usbphy *phy = (struct usbphy *)USB_PHY0_BASE_ADDR ; + +writel (BM_USBPHY_CTRL_CLKGATE , + enable ? &phy->ctrl.clr : &phy->ctrl.set); +} + +#define BM_USBPHY_CTRL_SFTRST 0x80000000 + +void reset_usb_phy1 (void ) +{ +struct usbphy *phy = (struct usbphy *)USB_PHY0_BASE_ADDR ; + +/* Reset USBPHY module */ +writel (BM_USBPHY_CTRL_SFTRST , &phy->ctrl.set); +udelay (10 ); + +/* Remove CLKGATE and SFTRST */ +writel (BM_USBPHY_CTRL_CLKGATE |BM_USBPHY_CTRL_SFTRST , &phy->ctrl.clr); +udelay (10 ); + +/* Power up the PHY */ +writel (0 , &phy->pwd.val); +} + + +#define BM_ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B 0x00080000 +#define BM_ANADIG_USB1_CHRG_DETECT_EN_B 0x00100000 + +static void set_usb_phy1_clk (void ) +{ +struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR ; + +writel (BM_ANADIG_USB1_CHRG_DETECT_EN_B + |BM_ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B , + &anatop->usb1_chrg_detect_set); + +/* make sure pll is enable here */ +writel (BM_ANADIG_USB1_PLL_480_CTRL_EN_USB_CLKS , + &anatop->usb1_pll_480_ctrl_set); +} + +void otg_enable (void ) +{ +set_usb_phy1_clk (); +enable_usboh3_clk (1 ); +enable_usb_phy1_clk (1 ); +} +#endif +struct scu_regs {u32 ctrl;u32 config;
arch/arm/include/asm/arch-mx6/sys_proto.h +4 -0
@@ -56,4 +56,8 @@ int mxs_wait_mask_set(struct mxs_register_32 *reg,int mxs_wait_mask_clr (struct mxs_register_32 *reg,uint32_t mask,unsigned int timeout); + +void otg_enable (void ); +void reset_usb_phy1 (void ); +#endif
Signature · 1 line
1.8.1.2
RFC PATCH 2/18 mx6: iomux: add GPR1 defines
In reply to Troy Kisky--- arch/arm/include/asm/arch-mx6/iomux.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/include/asm/arch-mx6/iomux.h +6 -0
@@ -22,6 +22,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)
Signature · 1 line
1.8.1.2
RFC PATCH 3/18 mx6: define OTG_BASE_ADDR
In reply to Troy Kisky--- arch/arm/include/asm/arch-mx6/imx-regs.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +2 -0
@@ -181,9 +181,11 @@#ifdef CONFIG_MX6SL #define USBO2H_PL301_IPS_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x0000)#define USBO2H_USB_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x4000) +#define OTG_BASE_ADDR USBO2H_USB_BASE_ADDR#else #define USBOH3_PL301_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x0000)#define USBOH3_USB_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x4000) +#define OTG_BASE_ADDR USBOH3_USB_BASE_ADDR#endif #define ENET_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x8000)
Signature · 1 line
1.8.1.2
RFC PATCH 3/18 mx6: define OTG_BASE_ADDR
Dear Troy Kisky,
Please add commit messages. Btw I removed this horrible macro in my patchset.
Quoted 11 lines
Signed-off-by Troy Kisky <[email protected]>--- arch/arm/include/asm/arch-mx6/imx-regs.h | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/arch/arm/include/asm/arch-mx6/imx-regs.hindex 03abb2a..30a9687 100644arch/arm/include/asm/arch-mx6/imx-regs.h +0
-0@@ -181,9 +181,11 @@#ifdef CONFIG_MX6SL
arch/arm/include/asm/arch-mx6/imx-regs.h line 191
Quoted 10 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +2
-0#define USBO2H_PL301_IPS_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x0000)#define USBO2H_USB_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x4000) +#define OTG_BASE_ADDR USBO2H_USB_BASE_ADDR#else #define USBOH3_PL301_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x0000)#define USBOH3_USB_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x4000) +#define OTG_BASE_ADDR USBOH3_USB_BASE_ADDR#endif #define ENET_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x8000)
Best regards,
Marek Vasut
RFC PATCH 4/18 nitrogen6x: add otg usb ethernet gadget support
In reply to Troy Kisky--- board/boundary/nitrogen6x/nitrogen6x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
board/boundary/nitrogen6x/nitrogen6x.c +16 -0
@@ -46,6 +46,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 | \
@@ -385,6 +386,13 @@ int board_eth_init(bd_t *bis) free(bus); }#endif + +#ifdef CONFIG_MV_UDC +otg_enable (); + +/* For otg ethernet*/ +usb_eth_initialize (bis); +#endif return 0 ; }
@@ -733,6 +741,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 ();
@@ -754,6 +763,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
RFC PATCH 5/18 nitrogen6x: add CONFIG_MV_UDC
In reply to Troy Kisky--- include/configs/nitrogen6x.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/configs/nitrogen6x.h +7 -0
@@ -43,6 +43,13 @@#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_REG_BASE OTG_BASE_ADDR +#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
RFC PATCH 6/18 usb: gadget: config: fix unaligned access issues
In reply to Troy Kisky--- drivers/usb/gadget/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/gadget/config.c +4 -2
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <asm/unaligned.h> #include <asm/errno.h> #include <linux/list.h> #include <linux/string.h>
@@ -98,7 +99,8 @@ int usb_gadget_config_buf(/* config descriptor first */ if (length <USB_DT_CONFIG_SIZE || !desc)return -EINVAL ; - *cp = *config; +/* config need not be aligned */ +memcpy (cp, config,sizeof (*cp));/* then interface/endpoint/class/vendor/... */ len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf,
@@ -112,7 +114,7 @@ int usb_gadget_config_buf(/* patch up the config descriptor */ cp->bLength =USB_DT_CONFIG_SIZE ; cp->bDescriptorType =USB_DT_CONFIG ; - cp->wTotalLength =cpu_to_le16 (len); +put_unaligned_le16 (len, &cp->wTotalLength); cp->bmAttributes |=USB_CONFIG_ATT_ONE ;return len; }
Signature · 1 line
1.8.1.2
RFC PATCH 6/18 usb: gadget: config: fix unaligned access issues
Dear Troy Kisky,
Missing commit message :-(
Quoted 28 lines
Signed-off-by Troy Kisky <[email protected]>--- drivers/usb/gadget/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/usb/gadget/config.c +3
-1@@ -22,6 +22,7 @@*/ #include <common.h> +#include <asm/unaligned.h> #include <asm/errno.h> #include <linux/list.h> #include <linux/string.h> @@ -98,7 +99,8 @@ int usb_gadget_config_buf(/* config descriptor first */ if (length <USB_DT_CONFIG_SIZE || !desc)return -EINVAL ; - *cp = *config; +/* config need not be aligned */ +memcpy (cp, config,sizeof (*cp));/* then interface/endpoint/class/vendor/... */ len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf,
drivers/usb/gadget/config.c int usb_gadget_config_buf( · line 120
Quoted 8 lines
drivers/usb/gadget/config.c +1
-1@@ -112,7 +114,7 @@ int usb_gadget_config_buf(/* patch up the config descriptor */ cp->bLength =USB_DT_CONFIG_SIZE ; cp->bDescriptorType =USB_DT_CONFIG ; - cp->wTotalLength =cpu_to_le16 (len); +put_unaligned_le16 (len, &cp->wTotalLength); cp->bmAttributes |=USB_CONFIG_ATT_ONE ;return len; }
Best regards,
Marek Vasut
RFC PATCH 7/18 usb: gadget: mv_udc: set udc after controller.udc is initialized
In reply to Troy Kiskymvudc_probe initializes controller.udc, so move initialization of local udc variable after this call.
--- drivers/usb/gadget/mv_udc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/mv_udc.c +2 -1
@@ -471,7 +471,6 @@ static int mvudc_probe(void)int usb_gadget_register_driver (struct usb_gadget_driver *driver) { -struct mv_udc *udc = controller.udc;int retval;void *ctrl;
@@ -484,6 +483,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) }if (!mvudc_probe ()) { +struct mv_udc *udc = controller.udc; +usb_lowlevel_init (0 , &ctrl);/* select ULPI phy */ writel (PTS (PTS_ENABLE ) |PFSC , &udc->portsc);
Signature · 1 line
1.8.1.2
RFC PATCH 8/18 usb: gadget: mv_udc: add MX6Q specific reset
In reply to Troy Kisky---
I don't know if this is needed, but it doesn't hurt.
--- drivers/usb/gadget/mv_udc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/mv_udc.c +3 -0
@@ -392,6 +392,9 @@ static int mv_pullup(struct usb_gadget *gadget, int is_on)/* RESET */ writel (USBCMD_ITC (MICRO_8FRAME ) |USBCMD_RST , &udc->usbcmd);udelay (200 ); +#if defined(CONFIG_MX6Q ) || defined(CONFIG_MX6DL ) +reset_usb_phy1 (); +#endif writel ((unsigned ) epts, &udc->epinitaddr);
Signature · 1 line
1.8.1.2
RFC PATCH 9/18 usb: gadget: ether set wMaxPacketSize
In reply to Troy Kiskyset wMaxPacketSize for full speed descriptors
--- drivers/usb/gadget/ether.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/ether.c +2 -0
@@ -647,6 +647,7 @@ fs_source_desc = { .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = __constant_cpu_to_le16(64), }; static struct usb_endpoint_descriptor
@@ -656,6 +657,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
RFC PATCH 10/18 usb: gadget: ether: return error from rx_submit if no request
In reply to Troy KiskyThis prevents a crash if tftpboot is given a bad filename.
--- drivers/usb/gadget/ether.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/ether.c +2 -1
@@ -2401,7 +2401,8 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) } packet_received =0 ; -rx_submit (dev, dev->rx_req,0 ); +if (dev->rx_req) +rx_submit (dev, dev->rx_req,0 );return 0 ; fail:return -1 ;
Signature · 1 line
1.8.1.2
RFC PATCH 10/18 usb: gadget: ether: return error from rx_submit if no request
Quoted 12 lines · Troy Kisky
This prevents a crash if tftpboot is given a bad filename.
Signed-off-by Troy Kisky <[email protected]>--- drivers/usb/gadget/ether.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/gadget/ether.c +0
-0
drivers/usb/gadget/ether.c static int usb_eth_init(struct eth_device *netdev, bd_t *bd) · line 2408
Quoted 9 lines
drivers/usb/gadget/ether.c +2
-1@@ -2401,7 +2401,8 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) } packet_received =0 ; -rx_submit (dev, dev->rx_req,0 ); +if (dev->rx_req) +rx_submit (dev, dev->rx_req,0 );return 0 ; fail:return -1 ;
This patch is wrong. I will put the check in rx_submit, because this call was not the problem.
RFC PATCH 11/18 usb: gadget: mv_udc: split mv_udc.h file
In reply to Troy KiskyMove 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.
--- drivers/usb/gadget/mv_udc.c | 6 +++ drivers/usb/gadget/mv_udc.h | 117 +++++++++++++++++++++++++++++++++++++++++++ include/usb/mv_udc.h | 118 -------------------------------------------- 3 files changed, 123 insertions(+), 118 deletions(-) create mode 100644 drivers/usb/gadget/mv_udc.h
drivers/usb/gadget/mv_udc.c +6 -0
@@ -29,10 +29,16 @@#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 "mv_udc.h" +#if CONFIG_USB_MAX_CONTROLLER_COUNT >1 #error This driver only supports one single controller.#endif
drivers/usb/gadget/mv_udc.h new file +117 -0
117 lines not on this page · raw message
include/usb/mv_udc.h +0 -118
130 lines not on this page · raw message
Signature · 1 line
1.8.1.2
RFC PATCH 12/18 usb: udc: add udc.h include file
In reply to Troy KiskyMove common defintions to udc.h
--- drivers/serial/usbtty.h | 3 +-- include/usb/designware_udc.h | 31 ----------------------- include/usb/mpc8xx_udc.h | 19 +------------- include/usb/musb_udc.h | 53 -------------------------------------- include/usb/omap1510_udc.h | 27 +++----------------- include/usb/pxa27x_udc.h | 26 +------------------ include/usb/udc.h | 60 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 153 deletions(-) create mode 100644 include/usb/udc.h
drivers/serial/usbtty.h +1 -2
@@ -29,8 +29,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 )
@@ -39,6 +37,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
include/usb/designware_udc.h +0 -31
@@ -190,19 +190,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
@@ -210,22 +197,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
@@ -126,11 +126,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
@@ -193,18 +191,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 +0 -53
53 lines not on this page · raw message
include/usb/omap1510_udc.h +3 -24
@@ -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
@@ -35,35 +35,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 +60 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.1.2
RFC PATCH 13/18 usb: gadget: mv_udc: fix typo in error message
In reply to Troy KiskyChange 'nfo=' to 'info='
squash typo
--- drivers/usb/gadget/mv_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -2
@@ -210,8 +210,8 @@ static void handle_ep_complete(struct mv_ep *ep) item = items[2 * num + in];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 ; ep->req.length -= len;
Signature · 1 line
1.8.1.2
RFC PATCH 14/18 usb: gadget: mv_udc: use static initialization of ops, udc
In reply to Troy KiskyMove the initialization of gadget.ops and udc from code to the static structure.
--- drivers/usb/gadget/mv_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -2
@@ -107,9 +107,11 @@ static struct usb_ep_ops mv_ep_ops = {static struct mv_ep ep[2 *NUM_ENDPOINTS ];static struct mv_drv controller = { + .udc = (struct mv_udc *)CONFIG_USB_REG_BASE , .gadget = { .ep0 = &ep[0 ].ep, .name ="mv_udc" , + .ops = &mv_udc_ops, }, };
@@ -438,8 +440,6 @@ static int mvudc_probe(void)struct ept_queue_head *head;int i; - controller.gadget.ops = &mv_udc_ops; - controller.udc = (struct mv_udc *)CONFIG_USB_REG_BASE ; epts =memalign (PAGE_SIZE ,QH_MAXNUM *sizeof (struct ept_queue_head ));memset (epts,0 ,QH_MAXNUM *sizeof (struct ept_queue_head ));for (i =0 ; i <2 *NUM_ENDPOINTS ; i++) {
Signature · 1 line
1.8.1.2
RFC PATCH 15/18 usb: gadget: mv_udc: set is_dualspeed = 1
In reply to Troy KiskyThis controller support full and high speed.
--- drivers/usb/gadget/mv_udc.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/mv_udc.c +1 -0
@@ -112,6 +112,7 @@ static struct mv_drv controller = { .ep0 = &ep[0].ep, .name = "mv_udc", .ops = &mv_udc_ops, + .is_dualspeed = 1, }, };
Signature · 1 line
1.8.1.2
RFC PATCH 16/18 usb: gadget: mv_udc: fix full speed connections
In reply to Troy KiskySet maximum packet length in queue header to wMaxPacketSize of endpoint.
--- drivers/usb/gadget/mv_udc.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-)
drivers/usb/gadget/mv_udc.c +29 -11
@@ -32,6 +32,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>
@@ -128,7 +129,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 = controller.udc;
@@ -142,7 +143,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 ;writel (n, &udc->epctrl[num]); }
@@ -153,8 +154,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 ; }
@@ -262,7 +276,7 @@ static void handle_setup(void) in = (ep[i].desc->bEndpointAddress &USB_DIR_IN ) !=0 ;if ((num == _num) && (in == _in)) { -ep_enable (num, in); +ep_enable (num, in, ep[i].ep.maxpacket);usb_ep_queue (controller.gadget.ep0, req,0 );break ;
@@ -344,15 +358,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 (ep[i].desc) - 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 && n; i++) { +if (ep[i].ep.maxpacket > max) + ep[i].ep.maxpacket = max; } }
Signature · 1 line
1.8.1.2
RFC PATCH 17/18 usb: gadget: mv_udc: fix cache issues
In reply to Troy KiskyAllow mv_udc to work when cache is enabled by
adding flushing and invalidating calls.
--- drivers/usb/gadget/mv_udc.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
drivers/usb/gadget/mv_udc.c +27 -9
@@ -131,10 +131,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 = controller.udc;unsigned n; - head = epts +2 *num + in; n =readl (&udc->epctrl[num]);if (in)
@@ -142,8 +140,12 @@ static void ep_enable(int num, int in, int maxpacket)else n |= (CTRL_RXE |CTRL_RXR |CTRL_RXT_BULK ); -if (num !=0 ) +if (num !=0 ) { +struct ept_queue_head *head = epts +2 *num + in; + head->config =CONFIG_MAX_PKT (maxpacket) |CONFIG_ZLT ; +flush_cache ((unsigned long )head,sizeof (struct ept_queue_head )); + }writel (n, &udc->epctrl[num]); }
@@ -192,25 +194,26 @@ static int mv_ep_queue(struct usb_ep *ep, head = epts +2 * num + in; phys = (unsigned )req->buf; len = req->length; +flush_cache (phys, len); item->next =TERMINATE ; item->info =INFO_BYTES (len) |INFO_IOC |INFO_ACTIVE ; item->page0 = phys; item->page1 = (phys &0xfffff000 ) +0x1000 ; +flush_cache ((unsigned long )item,sizeof (struct ept_queue_item )); head->next = (unsigned ) item; head->info =0 ;DBG ("ept%d %s queue len %x, buffer %x\n" , num, in ?"in" :"out" , len, phys); +flush_cache ((unsigned long )head,sizeof (struct ept_queue_head ));if (in) bit =EPT_TX (num);else bit =EPT_RX (num); -flush_cache (phys, len); -flush_cache ((unsigned long )item,sizeof (struct ept_queue_item ));writel (bit, &udc->epprime);return 0 ;
@@ -234,6 +237,13 @@ static void handle_ep_complete(struct mv_ep *ep) ep->req.length -= len;DBG ("ept%d %s complete %x\n" , num, in ?"in" :"out" , len); +if (ep->req.length && !in) { +unsigned start = (unsigned )ep->req.buf & ~0x3f ; +unsigned end = ((unsigned )ep->req.buf + ep->req.length + +0x3f ) & ~0x3f ; + +invalidate_dcache_range (start, end); + } ep->req.complete (&ep->ep, &ep->req);if (num ==0 ) { ep->req.length =0 ;
@@ -255,7 +265,8 @@ static void handle_setup(void)char *buf; head = epts; -flush_cache ((unsigned long )head,sizeof (struct ept_queue_head )); +invalidate_dcache_range ((unsigned long )head, (unsigned long )head + +sizeof (struct ept_queue_head ));memcpy (&r, head->setup_data,sizeof (struct usb_ctrlrequest ));writel (EPT_RX (0 ), &udc->epstat); DBG("handle setup %s, %x, %x index %x value %x\n", reqname(r.bRequest),
@@ -335,6 +346,8 @@ static void stop_activity(void) in = (ep[i].desc->bEndpointAddress &USB_DIR_IN ) !=0 ; head = epts + (num *2 ) + (in); head->info =INFO_ACTIVE ; +flush_cache ((unsigned long )head, +sizeof (struct ept_queue_head )); } } }
@@ -458,9 +471,11 @@ static int mvudc_probe(void) {struct ept_queue_head *head;int i; +const int qh_size =QH_MAXNUM *sizeof (struct ept_queue_head ); +const int item_size =sizeof (struct ept_queue_item ); - epts =memalign (PAGE_SIZE ,QH_MAXNUM *sizeof (struct ept_queue_head )); -memset (epts,0 ,QH_MAXNUM *sizeof (struct ept_queue_head )); + epts =memalign (PAGE_SIZE , qh_size); +memset (epts,0 , qh_size);for (i =0 ; i <2 *NUM_ENDPOINTS ; i++) {/* * For item0 and item1, they are served as ep0
@@ -476,8 +491,11 @@ static int mvudc_probe(void) head->next =TERMINATE ; head->info =0 ; - items[i] =memalign (PAGE_SIZE ,sizeof (struct ept_queue_item )); + items[i] =memalign (PAGE_SIZE , item_size); +memset (items[i],0 , item_size); +flush_cache ((unsigned long )items[i], item_size); } +flush_cache ((unsigned long )epts, qh_size);INIT_LIST_HEAD (&controller.gadget.ep_list); ep[0 ].ep.maxpacket =64 ;
Signature · 1 line
1.8.1.2
RFC PATCH 18/18 usb: gadget: mv_udc: clear desc upon ep_disable
In reply to Troy Kiskydesc is set at ep_enable, so for symmetry,
clear it at ep_disable.
--- drivers/usb/gadget/mv_udc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/mv_udc.c +3 -0
@@ -176,6 +176,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
cover Make mv_udc work for i.mx6
In reply to Troy KiskyHi Troy,
Quoted 1 line
Hi Marek,
Can you please base the series on top of my series I posted a while ago [1] ? I feel bad about asking you to, but that series was out earlier and I'm planning to apply it for next MW.
btw review would be nice ;-)
Quoted 4 lines
This series is based on your u-boot-testing/chipidea branch. After this series, nitrogen6x works with tftpboot to transfer files over usb. But I still cannot enable
CONFIG_USB_TTYbecause of link errors.
Ugh, USB TTY is not compatible with the new code, right? I use either netconsole or the right way would be to port g_serial from Linux 2.6.37 .
Quoted 49 lines
Do you have a plan for defining the following symbols in general code?
setup_epudc_endpoint_writeudc_initudc_startup_eventsudc_connectudc_unset_nakudc_set_nakudc_unset_nakOr should usbtty be hacked to use more gadget style functions?
Troy Kisky (18):
Add functions for use with i.mx6 otg udc
mx6: iomux: add GPR1 defines
mx6: defineOTG_BASE_ADDR
nitrogen6x: add otg usb ethernet gadget support
nitrogen6x: addCONFIG_MV_UDC
usb: gadget: config: fix unaligned access issues
usb: gadget:mv_udc: set udc after controller.udc is initialized
usb: gadget:mv_udc: add MX6Q specific reset
usb: gadget: ether set wMaxPacketSize
usb: gadget: ether: return error fromrx_submitif no request
usb: gadget:mv_udc: splitmv_udc.hfile
usb: udc: addudc.hinclude file
usb: gadget:mv_udc: fix typo in error message
usb: gadget:mv_udc: use static initialization of ops,udc
usb: gadget:mv_udc: setis_dualspeed= 1
usb: gadget:mv_udc: fix full speed connections
usb: gadget:mv_udc: fix cache issues
usb: gadget:mv_udc: clear desc uponep_disablearch/arm/cpu/armv7/mx6/soc.c | 70 ++++++++++++++++++ arch/arm/include/asm/arch-mx6/imx-regs.h | 2 + arch/arm/include/asm/arch-mx6/iomux.h | 6 ++ arch/arm/include/asm/arch-mx6/sys_proto.h | 4 + board/boundary/nitrogen6x/nitrogen6x.c | 16 ++++ drivers/serial/usbtty.h | 3 +- drivers/usb/gadget/config.c | 6 +- drivers/usb/gadget/ether.c | 5 +- drivers/usb/gadget/mv_udc.c | 100 ++++++++++++++++++------- drivers/usb/gadget/mv_udc.h | 117 +++++++++++++++++++++++++++++ include/configs/nitrogen6x.h | 7 ++ include/usb/designware_udc.h | 31 -------- include/usb/mpc8xx_udc.h | 19 +---- include/usb/musb_udc.h | 53 --------------
Quoted 8 lines
include/usb/mv_udc.h | 118 ------------------------------ include/usb/omap1510_udc.h | 27 +------ include/usb/pxa27x_udc.h | 26 +------ include/usb/udc.h | 60 +++++++++++++++ 18 files changed, 371 insertions(+), 299 deletions(-) create mode 100644 drivers/usb/gadget/mv_udc.h create mode 100644 include/usb/udc.h
[1] http://patchwork.ozlabs.org/patch/257935/
Best regards,
Marek Vasut
cover Make mv_udc work for i.mx6
Quoted 6 lines · Marek Vasut
Hi Troy,
Quoted 1 line
Hi Marek,
Can you please base the series on top of my series I posted a while ago [1] ? I feel bad about asking you to, but that series was out earlier and I'm planning to apply it for next MW.
Since it is 17 patches, do you have a branch I can pull from ?
Quoted 2 lines
btw review would be nice ;-)
Sure, I'll look through it.
Quoted 6 lines
Quoted 4 lines
This series is based on your u-boot-testing/chipidea branch. After this series, nitrogen6x works with tftpboot to transfer files over usb. But I still cannot enable
CONFIG_USB_TTYbecause of link errors.Ugh, USB TTY is not compatible with the new code, right? I use either netconsole or the right way would be to port
g_serialfrom Linux 2.6.37 .
Thanks for the direction.
Quoted 5 lines
[1] http://patchwork.ozlabs.org/patch/257935/
Best regards,
Marek Vasut
cover Make mv_udc work for i.mx6
Dear Troy Kisky,
Quoted 10 lines · Marek Vasut
Quoted 7 lines
Hi Troy,
Quoted 1 line
Hi Marek,
Can you please base the series on top of my series I posted a while ago
[1] ? I feel bad about asking you to, but that series was out earlier and I'm planning to apply it for next MW.Since it is 17 patches, do you have a branch I can pull from ?
Use this bundle : http://patchwork.ozlabs.org/bundle/marex/mvudc/
Quoted 3 lines
Quoted 1 line
btw review would be nice ;-)
Sure, I'll look through it.
Thanks!
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
This series is based on your u-boot-testing/chipidea branch. After this series, nitrogen6x works with tftpboot to transfer files over usb. But I still cannot enable
CONFIG_USB_TTYbecause of link errors.
Quoted 10 lines
Quoted 3 lines
Ugh, USB TTY is not compatible with the new code, right? I use either netconsole or the right way would be to port
g_serialfrom Linux 2.6.37 .Thanks for the direction.
Quoted 4 lines
[1] http://patchwork.ozlabs.org/patch/257935/
Best regards,
Marek Vasut
Best regards,
Marek Vasut