dra7xx: am43xx: add dwc3 gadget driver support and enable dfu
Subsystems (9)
v2 cover dra7xx: am43xx: add dwc3 gadget driver support and enable dfu
This patch series ports dwc3 gadget driver from linux kernel (3.19-rc1) to u-boot.
Changes from v2:
*) Made all the buffers which should be flushed to be memaligned and made
flush_dcache_range to flush only those memory regions.
*) In dwc3_ep0_complete_data, changed the conditional check in implementing
chained TRB for ep0.
*) Other misc fixes from review comments for v1.
*) Added "Reviewed-by: Lukasz Majewski <[email protected]>" in all the
patches.
Changes from RFC:
*) A patch has been added to copy the driver from linux kernel to u-boot and then
it's modfied to make it work in u-boot. This will help to understand the changes that's been done to make it work in u-boot and will also be easier to review.
*) Implemented chained TRB support in dwc3 ep0 so that we need not increase the size
of bounce buffer
Testing:
*) tested DFU RAM and DFU MMC in dra7xx and am43xx
TODO:
*) Add Kconfig support
*) Adapt dwc3 driver to use the driver model.
*) Make composite driver similar to the one in linux kernel.
Pushed these patches togit://git.ti.com/~kishon/ti-u-boot/kishons-ti-u-boot.git dwc3_upstream_v2
Kishon Vijay Abraham I (40):
ARM: DRA7: Enable clocks for USB OTGSS and USB PHY
ARM: AM43xx: Enable clocks for USB OTGSS and USB PHY
usb: gadget: udc: add udc-core from linux kernel to u-boot
include: usb: modify gadget.h to include udc support
usb: gadget: udc: make udc-core compile in u-boot build
include: asm: dma-mapping: get rid of the compilation warning in
udc-core
usb: dwc3: add dwc3 folder from linux kernel to u-boot
usb: dwc3: remove un-used files from dwc3 folder
usb: dwc3: Modify the file headers to u-boot format
usb: dwc3: remove trace_* APIs from dwc3 driver
usb: dwc3: fix dwc3 header files
usb: dwc3: remove pm related operations from dwc3 driver
arm: asm: dma-mapping: added dma_free_coherent API
usb: dwc3: linux-compat: Add header for dwc3 linux compatibiltiy
usb: dwc3: gadget: make dwc3 gadget build in uboot
include: asm: types: add resource_size_t type
usb: dwc3: ep0: make dwc3 ep0 build in uboot
include: usb: composite: add USB_GADGET_DELAYED_STATUS to avoid
compilation error
usb: dwc3: core: make dwc3 core build in uboot
include: dwc3-uboot: add a structure for populating platform data
dwc3: core: change probe and remove to uboot init and uboot exit code
dwc3: core: add support for multiple dwc3 controllers
dwc3: core: added an API to invoke irq handlers
usb: dwc3: dwc3-omap: make dwc3-omap build in uboot
include: dwc3-omap-uboot: add a structure for populating dwc3-omap
platform data
usb: dwc3: dwc3-omap: change probe and remove to uboot init and uboot
exit code
dwc3: dwc3-omap: add support for multiple dwc3-omap controllers
usb: dwc3: dwc3-omap: add interrupt status API to check for
interrupts
usb: dwc3: TI PHY: PHY driver for dwc3 in TI platforms
dwc3: flush the buffers before using it
usb: dwc3: ep0: preparation for implementing chained TRB
usb: dwc3: Add chained TRB support for ep0
usb: dwc3: Makefile: Make dwc3 driver compile in u-boot
usb: gadget: defer setting maxpacket till ->setup()
common: cmd_dfu: invoke board_usb_cleanup() for cleaning up
board: ti: DRA7: added USB initializtion code
include: configs: Enable DWC3 and DFU in DRA7xx
board: ti: AM43xx: added USB initializtion code
include: configs: Enable DWC3 and DFU in AM43xx
usb: modify usb_gadget_handle_interrupts to take controller index
Makefile | 2 + arch/arm/cpu/armv7/am33xx/clock_am43xx.c | 12 + arch/arm/cpu/armv7/omap5/hw_data.c | 14 + arch/arm/cpu/armv7/omap5/prcm-regs.c | 10 +- arch/arm/include/asm/arch-am33xx/cpu.h | 20 +- arch/arm/include/asm/arch-am33xx/hardware_am43xx.h | 12 + arch/arm/include/asm/arch-omap5/omap.h | 12 + arch/arm/include/asm/dma-mapping.h | 9 +- arch/arm/include/asm/omap_common.h | 4 +- arch/arm/include/asm/types.h | 1 + board/ti/am43xx/board.c | 108 + board/ti/dra7xx/evm.c | 109 + common/cmd_dfu.c | 3 +- common/cmd_fastboot.c | 2 +- common/cmd_usb_mass_storage.c | 2 +- common/usb.c | 6 + drivers/usb/dwc3/Makefile | 8 + drivers/usb/dwc3/core.c | 792 ++++++ drivers/usb/dwc3/core.h | 1033 ++++++++ drivers/usb/dwc3/dwc3-omap.c | 441 ++++ drivers/usb/dwc3/ep0.c | 1112 ++++++++ drivers/usb/dwc3/gadget.c | 2680 ++++++++++++++++++++ drivers/usb/dwc3/gadget.h | 108 + drivers/usb/dwc3/io.h | 55 + drivers/usb/dwc3/linux-compat.h | 38 + drivers/usb/dwc3/ti_usb_phy.c | 309 +++ drivers/usb/gadget/atmel_usba_udc.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/composite.c | 4 +- drivers/usb/gadget/ether.c | 12 +- drivers/usb/gadget/f_mass_storage.c | 2 +- drivers/usb/gadget/f_thor.c | 6 +- drivers/usb/gadget/fotg210.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/s3c_udc_otg.c | 2 +- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 354 +++ drivers/usb/musb-new/musb_uboot.c | 2 +- include/configs/am43xx_evm.h | 58 +- include/configs/dra7xx_evm.h | 63 + include/configs/ti_omap5_common.h | 5 + include/dwc3-omap-uboot.h | 32 + include/dwc3-uboot.h | 42 + include/linux/compat.h | 1 + include/linux/usb/composite.h | 9 + include/linux/usb/dwc3-omap.h | 19 + include/linux/usb/gadget.h | 84 +- include/linux/usb/otg.h | 20 + include/ti-usb-phy-uboot.h | 22 + 49 files changed, 7616 insertions(+), 35 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/ep0.c create mode 100644 drivers/usb/dwc3/gadget.c create mode 100644 drivers/usb/dwc3/gadget.h create mode 100644 drivers/usb/dwc3/io.h create mode 100644 drivers/usb/dwc3/linux-compat.h create mode 100644 drivers/usb/dwc3/ti_usb_phy.c create mode 100644 drivers/usb/gadget/udc/Makefile create mode 100644 drivers/usb/gadget/udc/udc-core.c create mode 100644 include/dwc3-omap-uboot.h create mode 100644 include/dwc3-uboot.h create mode 100644 include/linux/usb/dwc3-omap.h create mode 100644 include/linux/usb/otg.h create mode 100644 include/ti-usb-phy-uboot.h
Signature · 1 line
1.7.9.5
PATCH v2 1/40 ARM: DRA7: Enable clocks for USB OTGSS and USB PHY
Enabled clocks for dwc3 controller and USB PHY present in DRA7.
--- arch/arm/cpu/armv7/omap5/hw_data.c | 14 ++++++++++++++ arch/arm/cpu/armv7/omap5/prcm-regs.c | 10 +++++----- arch/arm/include/asm/omap_common.h | 4 ++-- 3 files changed, 21 insertions(+), 7 deletions(-)
arch/arm/cpu/armv7/omap5/hw_data.c +14 -0
@@ -455,6 +455,10 @@ void enable_basic_clocks(void) (*prcm)->cm_l4per_gpio6_clkctrl, (*prcm)->cm_l4per_gpio7_clkctrl, (*prcm)->cm_l4per_gpio8_clkctrl, +#ifdef CONFIG_USB_DWC3 + (*prcm)->cm_l3init_ocp2scp1_clkctrl, + (*prcm)->cm_l3init_usb_otg_ss1_clkctrl, +#endif 0 };
@@ -486,6 +490,16 @@ void enable_basic_clocks(void)setbits_le32 ((*prcm)->cm_l3init_hsmmc2_clkctrl,HSMMC_CLKCTRL_CLKSEL_MASK ); +#ifdef CONFIG_USB_DWC3 +/* Enable 960 MHz clock for dwc3 */ +setbits_le32 ((*prcm)->cm_l3init_usb_otg_ss1_clkctrl, +OPTFCLKEN_REFCLK960M ); + +/* Enable 32 KHz clock for dwc3 */ +setbits_le32 ((*prcm)->cm_coreaon_usb_phy1_core_clkctrl, +USBPHY_CORE_CLKCTRL_OPTFCLKEN_CLK32K ); +#endif +/* Set the correct clock dividers for mmc */ setbits_le32 ((*prcm)->cm_l3init_hsmmc1_clkctrl,HSMMC_CLKCTRL_CLKSEL_DIV_MASK );
arch/arm/cpu/armv7/omap5/prcm-regs.c +5 -5
@@ -575,7 +575,7 @@ struct prcm_regs const omap5_es2_prcm = { .cm_div_m2_dpll_unipro = 0x4a0081d0, .cm_ssc_deltamstep_dpll_unipro = 0x4a0081e8, .cm_ssc_modfreqdiv_dpll_unipro = 0x4a0081ec, - .cm_coreaon_usb_phy_core_clkctrl = 0x4A008640, + .cm_coreaon_usb_phy1_core_clkctrl = 0x4A008640, .cm_coreaon_bandgap_clkctrl = 0x4a008648, .cm_coreaon_io_srcomp_clkctrl = 0x4a008650,
@@ -709,7 +709,7 @@ struct prcm_regs const omap5_es2_prcm = { .cm_l3init_fsusb_clkctrl = 0x4a0096d0, .cm_l3init_ocp2scp1_clkctrl = 0x4a0096e0, .cm_l3init_ocp2scp3_clkctrl = 0x4a0096e8, - .cm_l3init_usb_otg_ss_clkctrl = 0x4a0096f0, + .cm_l3init_usb_otg_ss1_clkctrl = 0x4a0096f0,/* prm irqstatus regs */ .prm_irqstatus_mpu_2 = 0x4ae06014,
@@ -801,8 +801,8 @@ struct prcm_regs const dra7xx_prcm = { .cm_clkmode_dpll_dsp = 0x4a005234, .cm_shadow_freq_config1 = 0x4a005260, .cm_clkmode_dpll_gmac = 0x4a0052a8, - .cm_coreaon_usb_phy_core_clkctrl = 0x4a008640, - .cm_coreaon_usb_phy2_core_clkctrl = 0x4a008688, + .cm_coreaon_usb_phy1_core_clkctrl = 0x4a008640, + .cm_coreaon_usb_phy2_core_clkctrl = 0x4a008688,/* cm1.mpu */ .cm_mpu_mpu_clkctrl = 0x4a005320,
@@ -908,7 +908,7 @@ struct prcm_regs const dra7xx_prcm = { .cm_gmac_gmac_clkctrl = 0x4a0093d0, .cm_l3init_ocp2scp1_clkctrl = 0x4a0093e0, .cm_l3init_ocp2scp3_clkctrl = 0x4a0093e8, - .cm_l3init_usb_otg_ss_clkctrl = 0x4a0093f0, + .cm_l3init_usb_otg_ss1_clkctrl = 0x4a0093f0,/* cm2.l4per */ .cm_l4per_clkstctrl = 0x4a009700,
arch/arm/include/asm/omap_common.h +2 -2
@@ -143,7 +143,7 @@ struct prcm_regs {u32 cm_div_m2_dpll_unipro;u32 cm_ssc_deltamstep_dpll_unipro;u32 cm_ssc_modfreqdiv_dpll_unipro; -u32 cm_coreaon_usb_phy_core_clkctrl; +u32 cm_coreaon_usb_phy1_core_clkctrl;u32 cm_coreaon_usb_phy2_core_clkctrl;/* cm2.core */
@@ -230,7 +230,7 @@ struct prcm_regs {u32 cm_l3init_fsusb_clkctrl;u32 cm_l3init_ocp2scp1_clkctrl;u32 cm_l3init_ocp2scp3_clkctrl; -u32 cm_l3init_usb_otg_ss_clkctrl; +u32 cm_l3init_usb_otg_ss1_clkctrl;u32 prm_irqstatus_mpu_2;
Signature · 1 line
1.7.9.5
PATCH v2 2/40 ARM: AM43xx: Enable clocks for USB OTGSS and USB PHY
In reply to Kishon Vijay Abraham IEnabled clocks for dwc3 controller and USB PHY present in AM43xx.
--- arch/arm/cpu/armv7/am33xx/clock_am43xx.c | 12 ++++++++++++ arch/arm/include/asm/arch-am33xx/cpu.h | 20 +++++++++++++++----- arch/arm/include/asm/arch-am33xx/hardware_am43xx.h | 3 +++ 3 files changed, 30 insertions(+), 5 deletions(-)
arch/arm/cpu/armv7/am33xx/clock_am43xx.c +12 -0
@@ -111,9 +111,21 @@ void enable_basic_clocks(void) &cmper->emifclkctrl, &cmper->otfaemifclkctrl, &cmper->qspiclkctrl, + &cmper->usb0clkctrl, + &cmper->usbphyocp2scp0clkctrl, + &cmper->usb1clkctrl, + &cmper->usbphyocp2scp1clkctrl, 0 }; +setbits_le32 (&cmper->usb0clkctrl, +USBOTGSSX_CLKCTRL_OPTFCLKEN_REFCLK960 ); +setbits_le32 (&cmwkup->usbphy0clkctrl, +USBPHY0_CLKCTRL_OPTFCLKEN_CLK32K ); +setbits_le32 (&cmper->usb1clkctrl, +USBOTGSSX_CLKCTRL_OPTFCLKEN_REFCLK960 ); +setbits_le32 (&cmwkup->usbphy1clkctrl, +USBPHY0_CLKCTRL_OPTFCLKEN_CLK32K );do_enable_clocks (clk_domains, clk_modules_explicit_en,1 );/* Select the Master osc clk as Timer2 clock source */
arch/arm/include/asm/arch-am33xx/cpu.h +15 -5
@@ -224,7 +224,11 @@ struct cm_dpll {struct cm_wkuppll {unsigned int resv0[136 ];unsigned int wkl4wkclkctrl;/* offset 0x220 */ -unsigned int resv1[55 ]; +unsigned int resv1[7 ]; +unsigned int usbphy0clkctrl;/* offset 0x240 */ +unsigned int resv112; +unsigned int usbphy1clkctrl;/* offset 0x248 */ +unsigned int resv113[45 ];unsigned int wkclkstctrl;/* offset 0x300 */ unsigned int resv2[15 ];unsigned int wkup_i2c0ctrl;/* offset 0x340 */
@@ -283,7 +287,7 @@ struct cm_perpll {unsigned int l3clkstctrl;/* offset 0x00 */ unsigned int resv0[7 ];unsigned int l3clkctrl;/* Offset 0x20 */ -unsigned int resv1[7 ]; +unsigned int resv112[7 ];unsigned int l3instrclkctrl;/* offset 0x40 */ unsigned int resv2[3 ];unsigned int ocmcramclkctrl;/* offset 0x50 */
@@ -310,7 +314,9 @@ struct cm_perpll {unsigned int qspiclkctrl;/* offset 0x258 */ unsigned int resv121;unsigned int usb0clkctrl;/* offset 0x260 */ -unsigned int resv13[103 ]; +unsigned int resv122; +unsigned int usb1clkctrl;/* offset 0x268 */ +unsigned int resv13[101 ];unsigned int l4lsclkstctrl;/* offset 0x400 */ unsigned int resv14[7 ];unsigned int l4lsclkctrl;/* offset 0x420 */
@@ -364,10 +370,14 @@ struct cm_perpll {unsigned int uart4clkctrl;/* offset 0x598 */ unsigned int resv35;unsigned int uart5clkctrl;/* offset 0x5A0 */ -unsigned int resv36[87 ]; +unsigned int resv36[5 ]; +unsigned int usbphyocp2scp0clkctrl;/* offset 0x5B8 */ +unsigned int resv361; +unsigned int usbphyocp2scp1clkctrl;/* offset 0x5C0 */ +unsigned int resv3611[79 ];unsigned int emifclkstctrl;/* offset 0x700 */ -unsigned int resv361[7 ]; +unsigned int resv362[7 ];unsigned int emifclkctrl;/* offset 0x720 */ unsigned int resv37[3 ];unsigned int emiffwclkctrl;/* offset 0x730 */
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +3 -0
@@ -72,6 +72,9 @@#define USBPHYOCPSCP_MODULE_EN (1 << 1)#define CM_DEVICE_INST 0x44df4100 +#define USBOTGSSX_CLKCTRL_OPTFCLKEN_REFCLK960 (1 << 8) +#define USBPHY0_CLKCTRL_OPTFCLKEN_CLK32K (1 << 8) +/* Control status register */ #define CTRL_CRYSTAL_FREQ_SRC_MASK (1 << 31)#define CTRL_CRYSTAL_FREQ_SRC_SHIFT 31
Signature · 1 line
1.7.9.5
PATCH v2 3/40 usb: gadget: udc: add udc-core from linux kernel to u-boot
In reply to Kishon Vijay Abraham IAdded udc-core.c from linux kernel 3.19-rc1 (97bf6af1f9) to u-boot. This will be adapted to work with u-boot in the
following patches.
Adding support for udc will help to seamlessly port dwc3 driver from linux kernel to u-boot (since dwc3 uses udc-core) and it'll also help to add support for multiple gadget controllers to be functional at the same time.
All other gadget drivers can also be adapted to use udc-core.
--- drivers/usb/gadget/udc/Makefile | 4 + drivers/usb/gadget/udc/udc-core.c | 637 +++++++++++++++++++++++++++++++++++++ 2 files changed, 641 insertions(+) create mode 100644 drivers/usb/gadget/udc/Makefile create mode 100644 drivers/usb/gadget/udc/udc-core.c
drivers/usb/gadget/udc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# USB peripheral controller drivers +# +obj-$(CONFIG_USB_GADGET) += udc-core.o
drivers/usb/gadget/udc/udc-core.c new file +637 -0
637 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 4/40 include: usb: modify gadget.h to include udc support
In reply to Kishon Vijay Abraham IMade changes in gadget.h that is required after adding udc-core.c except changes that might break other platforms.
--- include/linux/usb/gadget.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
include/linux/usb/gadget.h +43 -0
@@ -396,6 +396,7 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)/*-------------------------------------------------------------------------*/ struct usb_gadget ; +struct usb_gadget_driver ;/* the rest of the api to the controller hardware: device operations, * which don't involve endpoints (or i/o).
@@ -409,6 +410,9 @@ struct usb_gadget_ops {int (*pullup) (struct usb_gadget *,int is_on);int (*ioctl)(struct usb_gadget *,unsigned code,unsigned long param); +int (*udc_start)(struct usb_gadget *, +struct usb_gadget_driver *); +int (*udc_stop)(struct usb_gadget *); };/**
@@ -459,6 +463,7 @@ struct usb_gadget {struct usb_ep *ep0;struct list_head ep_list;/* of usb_ep */ enum usb_device_speed speed; +enum usb_device_state state; unsigned is_dualspeed:1; unsigned is_otg:1; unsigned is_a_peripheral:1;
@@ -686,6 +691,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)/** * struct usb_gadget_driver - driver for usb 'slave' devices +* @function: String describing the gadget's function * @speed: Highest speed the driver handles. * @bind: Invoked when the driver is bound to a gadget, usually * after registering the driver.
@@ -707,6 +713,8 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)* Called in a context that permits sleeping. * @suspend: Invoked on USB suspend. May be called in_interrupt. * @resume: Invoked on USB resume. May be called in_interrupt. +* @reset: Invoked on USB bus reset. It is mandatory for all gadget drivers +* and should be called in_interrupt. * * Devices are disabled till a gadget driver successfully bind()s, which * means the driver will handle setup() requests needed to enumerate (and
@@ -753,6 +761,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)* power is maintained. */ struct usb_gadget_driver { +char *function;enum usb_device_speed speed;int (*bind)(struct usb_gadget *);void (*unbind)(struct usb_gadget *);
@@ -761,6 +770,7 @@ struct usb_gadget_driver {void (*disconnect)(struct usb_gadget *);void (*suspend)(struct usb_gadget *);void (*resume)(struct usb_gadget *); +void (*reset)(struct usb_gadget *); };
@@ -801,6 +811,10 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver);*/ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); +int usb_add_gadget_udc_release (struct device *parent, +struct usb_gadget *gadget,void (*release)(struct device *dev)); +int usb_add_gadget_udc (struct device *parent,struct usb_gadget *gadget); +void usb_del_gadget_udc (struct usb_gadget *gadget);/*-------------------------------------------------------------------------*/ /* utility to simplify dealing with string descriptors */
@@ -847,6 +861,35 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config, void *buf, unsigned buflen, const struct usb_descriptor_header **desc);/*-------------------------------------------------------------------------*/ +/* utility to simplify map/unmap of usb_requests to/from DMA */ + +extern int usb_gadget_map_request (struct usb_gadget *gadget, +struct usb_request *req,int is_in); + +extern void usb_gadget_unmap_request (struct usb_gadget *gadget, +struct usb_request *req,int is_in); + +/*-------------------------------------------------------------------------*/ + +/* utility to set gadget state properly */ + +extern void usb_gadget_set_state (struct usb_gadget *gadget, +enum usb_device_state state); + +/*-------------------------------------------------------------------------*/ + +/* utility to tell udc core that the bus reset occurs */ +extern void usb_gadget_udc_reset (struct usb_gadget *gadget, +struct usb_gadget_driver *driver); + +/*-------------------------------------------------------------------------*/ + +/* utility to give requests back to the gadget layer */ + +extern void usb_gadget_giveback_request (struct usb_ep *ep, +struct usb_request *req); + +/*-------------------------------------------------------------------------*/ /* utility wrapping a simple endpoint selection policy */
Signature · 1 line
1.7.9.5
PATCH v2 5/40 usb: gadget: udc: make udc-core compile in u-boot build
In reply to Kishon Vijay Abraham IMake udc-core compile in u-boot by removing all linux specific stuff and having only the bare minimal udc-core required for usb gadget drivers. Also modified the file header to a format that is generally being used in u-boot.
--- drivers/usb/gadget/udc/udc-core.c | 335 +++---------------------------------- 1 file changed, 26 insertions(+), 309 deletions(-)
drivers/usb/gadget/udc/udc-core.c +26 -309
@@ -1,33 +1,27 @@/** -* udc.c - Core UDC Framework +* udc-core.c - Core UDC Framework +* +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * -* Copyright (C) 2010 Texas Instruments * Author: Felipe Balbi <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/gadget/udc-core.c) and ported +* to uboot. * -* 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. +* commit 02e8c96627 : usb: gadget: udc: core: prepend udc_attach_driver with +* usb_ * -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* SPDX-License-Identifier: GPL-2.0 */ -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/device.h> -#include <linux/list.h> -#include <linux/err.h> -#include <linux/dma-mapping.h> -#include <linux/workqueue.h> +#include <linux/compat.h> +#include <malloc.h> +#include <asm/cache.h> +#include <asm/dma-mapping.h> +#include <common.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> -#include <linux/usb.h> /** * struct usb_udc - describes one usb device controller
@@ -48,38 +42,18 @@ struct usb_udc {static struct class *udc_class;static LIST_HEAD (udc_list); -static DEFINE_MUTEX (udc_lock); +DEFINE_MUTEX (udc_lock);/* ------------------------------------------------------------------------- */ -#ifdef CONFIG_HAS_DMA -int usb_gadget_map_request (struct usb_gadget *gadget,struct usb_request *req,int is_in) {if (req->length ==0 )return 0 ; -if (req->num_sgs) { -int mapped; - - mapped =dma_map_sg (&gadget->dev, req->sg, req->num_sgs, - is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); -if (mapped ==0 ) { -dev_err (&gadget->dev,"failed to map SGs\n" ); -return -EFAULT ; - } - - req->num_mapped_sgs = mapped; - }else { - req->dma =dma_map_single (&gadget->dev, req->buf, req->length, - is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); - -if (dma_mapping_error (&gadget->dev, req->dma)) { -dev_err (&gadget->dev,"failed to map buffer\n" ); -return -EFAULT ; - } - } + req->dma =dma_map_single (req->buf, req->length, + is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE );return 0 ; }
@@ -91,20 +65,11 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget,if (req->length ==0 )return ; -if (req->num_mapped_sgs) { -dma_unmap_sg (&gadget->dev, req->sg, req->num_mapped_sgs, - is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); - - req->num_mapped_sgs =0 ; - }else { -dma_unmap_single (&gadget->dev, req->dma, req->length, - is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); - } +dma_unmap_single ((void *)req->dma, req->length, + is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); }EXPORT_SYMBOL_GPL (usb_gadget_unmap_request); -#endif /* CONFIG_HAS_DMA */ -/* ------------------------------------------------------------------------- */ /**
@@ -117,39 +82,16 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);void usb_gadget_giveback_request (struct usb_ep *ep,struct usb_request *req) { -if (likely (req->status ==0 )) -usb_led_activity (USB_LED_EVENT_GADGET ); - req->complete (ep, req); }EXPORT_SYMBOL_GPL (usb_gadget_giveback_request);/* ------------------------------------------------------------------------- */ -static void usb_gadget_state_work (struct work_struct *work) -{ -struct usb_gadget *gadget =work_to_gadget (work); -struct usb_udc *udc =NULL ; - -mutex_lock (&udc_lock); -list_for_each_entry (udc, &udc_list, list) -if (udc->gadget == gadget) - goto found; -mutex_unlock (&udc_lock); - -return ; - -found: -mutex_unlock (&udc_lock); - -sysfs_notify (&udc->dev.kobj,NULL ,"state" ); -} -void usb_gadget_set_state (struct usb_gadget *gadget,enum usb_device_state state) { gadget->state = state; -schedule_work (&gadget->work); }EXPORT_SYMBOL_GPL (usb_gadget_set_state);
@@ -219,17 +161,9 @@ static void usb_udc_release(struct device *dev)struct usb_udc *udc; udc = container_of(dev, struct usb_udc, dev); -dev_dbg (dev,"releasing '%s'\n" ,dev_name (dev));kfree (udc); } -static const struct attribute_group *usb_udc_attr_groups[]; - -static void usb_udc_nop_release (struct device *dev) -{ -dev_vdbg (dev,"%s\n" , __func__); -} -/** * usb_add_gadget_udc_release - adds a new gadget to the udc class driver list * @parent: the parent device to this udc. Usually the controller driver's
@@ -250,59 +184,23 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, goto err1;dev_set_name (&gadget->dev,"gadget" ); -INIT_WORK (&gadget->work, usb_gadget_state_work); gadget->dev.parent = parent; -#ifdef CONFIG_HAS_DMA -dma_set_coherent_mask (&gadget->dev, parent->coherent_dma_mask); - gadget->dev.dma_parms = parent->dma_parms; - gadget->dev.dma_mask = parent->dma_mask; -#endif - -if (release) - gadget->dev.release = release; -else - gadget->dev.release = usb_udc_nop_release; - - ret =device_register (&gadget->dev); -if (ret) - goto err2; - -device_initialize (&udc->dev); udc->dev.release = usb_udc_release; udc->dev.class = udc_class; - udc->dev.groups = usb_udc_attr_groups; udc->dev.parent = parent; - ret =dev_set_name (&udc->dev,"%s" ,kobject_name (&parent->kobj)); -if (ret) - goto err3; udc->gadget = gadget;mutex_lock (&udc_lock);list_add_tail (&udc->list, &udc_list); - ret =device_add (&udc->dev); -if (ret) - goto err4; -usb_gadget_set_state (gadget,USB_STATE_NOTATTACHED );mutex_unlock (&udc_lock);return 0 ; -err4: -list_del (&udc->list); -mutex_unlock (&udc_lock); - -err3: -put_device (&udc->dev); - -err2: -put_device (&gadget->dev); -kfree (udc); - err1:return ret; }
@@ -327,16 +225,12 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)dev_dbg (&udc->dev,"unregistering UDC driver [%s]\n" , udc->driver->function); -kobject_uevent (&udc->dev.kobj,KOBJ_CHANGE ); -usb_gadget_disconnect (udc->gadget); udc->driver->disconnect (udc->gadget); udc->driver->unbind (udc->gadget);usb_gadget_udc_stop (udc); udc->driver =NULL ; - udc->dev.driver =NULL ; - udc->gadget->dev.driver =NULL ; }/**
@@ -368,11 +262,6 @@ found:if (udc->driver)usb_gadget_remove_driver (udc); - -kobject_uevent (&udc->dev.kobj,KOBJ_REMOVE ); -flush_work (&gadget->work); -device_unregister (&udc->dev); -device_unregister (&gadget->dev); }EXPORT_SYMBOL_GPL (usb_del_gadget_udc);
@@ -386,10 +275,8 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri driver->function); udc->driver = driver; - udc->dev.driver = &driver->driver; - udc->gadget->dev.driver = &driver->driver; - ret = driver->bind (udc->gadget, driver); + ret = driver->bind (udc->gadget);if (ret) goto err1; ret =usb_gadget_udc_start (udc);
@@ -399,43 +286,14 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri }usb_gadget_connect (udc->gadget); -kobject_uevent (&udc->dev.kobj,KOBJ_CHANGE );return 0 ; err1:if (ret != -EISNAM )dev_err (&udc->dev,"failed to start %s: %d\n" , udc->driver->function, ret); udc->driver =NULL ; - udc->dev.driver =NULL ; - udc->gadget->dev.driver =NULL ; -return ret; -} - -int usb_udc_attach_driver (const char *name,struct usb_gadget_driver *driver) -{ -struct usb_udc *udc =NULL ; -int ret = -ENODEV ; - -mutex_lock (&udc_lock); -list_for_each_entry (udc, &udc_list, list) { - ret =strcmp (name,dev_name (&udc->dev)); -if (!ret) -break ; - } -if (ret) { - ret = -ENODEV ; - goto out; - } -if (udc->driver) { - ret = -EBUSY ; - goto out; - } - ret =udc_bind_to_driver (udc, driver); -out: -mutex_unlock (&udc_lock);return ret; } -EXPORT_SYMBOL_GPL (usb_udc_attach_driver);int usb_gadget_probe_driver (struct usb_gadget_driver *driver) {
@@ -452,7 +310,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver) goto found; } -pr_debug ("couldn't find an available UDC\n" ); +printf ("couldn't find an available UDC\n" );mutex_unlock (&udc_lock);return -ENODEV ; found:
@@ -462,6 +320,12 @@ found: }EXPORT_SYMBOL_GPL (usb_gadget_probe_driver); +int usb_gadget_register_driver (struct usb_gadget_driver *driver) +{ +return usb_gadget_probe_driver (driver); +} +EXPORT_SYMBOL_GPL (usb_gadget_register_driver); +int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) {struct usb_udc *udc =NULL ;
@@ -485,153 +349,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) }EXPORT_SYMBOL_GPL (usb_gadget_unregister_driver); -/* ------------------------------------------------------------------------- */ - -static ssize_t usb_udc_srp_store (struct device *dev, -struct device_attribute *attr,const char *buf,size_t n) -{ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); - -if (sysfs_streq (buf,"1" )) -usb_gadget_wakeup (udc->gadget); - -return n; -} -static DEVICE_ATTR(srp, S_IWUSR, NULL, usb_udc_srp_store); - -static ssize_t usb_udc_softconn_store (struct device *dev, -struct device_attribute *attr,const char *buf,size_t n) -{ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); - -if (!udc->driver) { -dev_err (dev,"soft-connect without a gadget driver\n" ); -return -EOPNOTSUPP ; - } - -if (sysfs_streq (buf,"connect" )) { -usb_gadget_udc_start (udc); -usb_gadget_connect (udc->gadget); - }else if (sysfs_streq (buf,"disconnect" )) { -usb_gadget_disconnect (udc->gadget); - udc->driver->disconnect (udc->gadget); -usb_gadget_udc_stop (udc); - }else { -dev_err (dev,"unsupported command '%s'\n" , buf); -return -EINVAL ; - } - -return n; -} -static DEVICE_ATTR(soft_connect, S_IWUSR, NULL, usb_udc_softconn_store); - -static ssize_t state_show (struct device *dev,struct device_attribute *attr, -char *buf) -{ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); -struct usb_gadget *gadget = udc->gadget; - -return sprintf (buf,"%s\n" ,usb_state_string (gadget->state)); -} -static DEVICE_ATTR_RO (state); - -#define USB_UDC_SPEED_ATTR (name, param) \ -ssize_t name##_show(struct device *dev, \ - struct device_attribute *attr, char *buf) \ -{ \ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \ - return snprintf(buf, PAGE_SIZE, "%s\n", \ - usb_speed_string(udc->gadget->param)); \ -} \ -static DEVICE_ATTR_RO(name) - -static USB_UDC_SPEED_ATTR(current_speed, speed); -static USB_UDC_SPEED_ATTR(maximum_speed, max_speed); - -#define USB_UDC_ATTR (name) \ -ssize_t name##_show(struct device *dev, \ - struct device_attribute *attr, char *buf) \ -{ \ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \ - struct usb_gadget *gadget = udc->gadget; \ - \ - return snprintf(buf, PAGE_SIZE, "%d\n", gadget->name); \ -} \ -static DEVICE_ATTR_RO(name) - -static USB_UDC_ATTR (is_otg); -static USB_UDC_ATTR (is_a_peripheral); -static USB_UDC_ATTR (b_hnp_enable); -static USB_UDC_ATTR (a_hnp_support); -static USB_UDC_ATTR (a_alt_hnp_support); - -static struct attribute *usb_udc_attrs[] = { - &dev_attr_srp.attr, - &dev_attr_soft_connect.attr, - &dev_attr_state.attr, - &dev_attr_current_speed.attr, - &dev_attr_maximum_speed.attr, - - &dev_attr_is_otg.attr, - &dev_attr_is_a_peripheral.attr, - &dev_attr_b_hnp_enable.attr, - &dev_attr_a_hnp_support.attr, - &dev_attr_a_alt_hnp_support.attr, -NULL , -}; - -static const struct attribute_group usb_udc_attr_group = { - .attrs = usb_udc_attrs, -}; - -static const struct attribute_group *usb_udc_attr_groups[] = { - &usb_udc_attr_group, -NULL , -}; - -static int usb_udc_uevent (struct device *dev,struct kobj_uevent_env *env) -{ - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); -int ret; - - ret =add_uevent_var (env,"USB_UDC_NAME=%s" , udc->gadget->name); -if (ret) { -dev_err (dev,"failed to add uevent USB_UDC_NAME\n" ); -return ret; - } - -if (udc->driver) { - ret =add_uevent_var (env,"USB_UDC_DRIVER=%s" , - udc->driver->function); -if (ret) { -dev_err (dev,"failed to add uevent USB_UDC_DRIVER\n" ); -return ret; - } - } - -return 0 ; -} - -static int __init usb_udc_init (void ) -{ - udc_class =class_create (THIS_MODULE ,"udc" ); -if (IS_ERR (udc_class)) { -pr_err ("failed to create udc class --> %ld\n" , -PTR_ERR (udc_class)); -return PTR_ERR (udc_class); - } - - udc_class->dev_uevent = usb_udc_uevent; -return 0 ; -} -subsys_initcall (usb_udc_init); - -static void __exit usb_udc_exit(void) -{ -class_destroy (udc_class); -} -module_exit (usb_udc_exit); -MODULE_DESCRIPTION ("UDC Framework" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
1.7.9.5
PATCH v2 6/40 include: asm: dma-mapping: get rid of the compilation warning in udc-core
In reply to Kishon Vijay Abraham IFixed the following warning here.
"warning: ?dma_alloc_coherent? defined but not used" while compiling udc-core
--- arch/arm/include/asm/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/dma-mapping.h +1 -1
@@ -14,7 +14,7 @@ enum dma_data_direction { DMA_FROM_DEVICE = 2, }; -static void *dma_alloc_coherent (size_t len,unsigned long *handle) +static inline void *dma_alloc_coherent (size_t len,unsigned long *handle) { *handle = (unsigned long )memalign (ARCH_DMA_MINALIGN , len);return (void *)*handle;
Signature · 1 line
1.7.9.5
PATCH v2 7/40 usb: dwc3: add dwc3 folder from linux kernel to u-boot
In reply to Kishon Vijay Abraham IAdded dwc3 folder from linux kernel 3.19-rc1 (97bf6af1f9) to u-boot. This will be adapted to work with u-boot in the following patches.
--- drivers/usb/dwc3/Kconfig | 120 ++ drivers/usb/dwc3/Makefile | 40 + drivers/usb/dwc3/core.c | 1119 +++++++++++++++ drivers/usb/dwc3/core.h | 1041 ++++++++++++++ drivers/usb/dwc3/debug.c | 32 + drivers/usb/dwc3/debug.h | 228 +++ drivers/usb/dwc3/debugfs.c | 690 ++++++++++ drivers/usb/dwc3/dwc3-exynos.c | 301 ++++ drivers/usb/dwc3/dwc3-keystone.c | 197 +++ drivers/usb/dwc3/dwc3-omap.c | 645 +++++++++ drivers/usb/dwc3/dwc3-pci.c | 272 ++++ drivers/usb/dwc3/dwc3-qcom.c | 130 ++ drivers/usb/dwc3/dwc3-st.c | 367 +++++ drivers/usb/dwc3/ep0.c | 1092 +++++++++++++++ drivers/usb/dwc3/gadget.c | 2824 ++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/gadget.h | 107 ++ drivers/usb/dwc3/host.c | 91 ++ drivers/usb/dwc3/io.h | 70 + drivers/usb/dwc3/platform_data.h | 47 + drivers/usb/dwc3/trace.c | 19 + drivers/usb/dwc3/trace.h | 247 ++++ 21 files changed, 9679 insertions(+) create mode 100644 drivers/usb/dwc3/Kconfig 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/debug.c create mode 100644 drivers/usb/dwc3/debug.h create mode 100644 drivers/usb/dwc3/debugfs.c create mode 100644 drivers/usb/dwc3/dwc3-exynos.c create mode 100644 drivers/usb/dwc3/dwc3-keystone.c create mode 100644 drivers/usb/dwc3/dwc3-omap.c create mode 100644 drivers/usb/dwc3/dwc3-pci.c create mode 100644 drivers/usb/dwc3/dwc3-qcom.c create mode 100644 drivers/usb/dwc3/dwc3-st.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 create mode 100644 drivers/usb/dwc3/platform_data.h create mode 100644 drivers/usb/dwc3/trace.c create mode 100644 drivers/usb/dwc3/trace.h
drivers/usb/dwc3/Kconfig new file +120 -0
@@ -0,0 +1,120 @@ +config USB_DWC3 + tristate "DesignWare USB3 DRD Core Support" + depends on (USB || USB_GADGET) && HAS_DMA + select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD + help + Say Y or M here if your system has a Dual Role SuperSpeed + USB controller based on the DesignWare USB3 IP Core. + + If you choose to build this driver is a dynamically linked + module, the module will be called dwc3.ko. + +if USB_DWC3 + +choice + bool "DWC3 Mode Selection" + default USB_DWC3_DUAL_ROLE if (USB && USB_GADGET) + default USB_DWC3_HOST if (USB && !USB_GADGET) + default USB_DWC3_GADGET if (!USB && USB_GADGET) + +config USB_DWC3_HOST + bool "Host only mode" + depends on USB=y || USB=USB_DWC3 + help + Select this when you want to use DWC3 in host mode only, + thereby the gadget feature will be regressed. + +config USB_DWC3_GADGET + bool "Gadget only mode" + depends on USB_GADGET=y || USB_GADGET=USB_DWC3 + help + Select this when you want to use DWC3 in gadget mode only, + thereby the host feature will be regressed. + +config USB_DWC3_DUAL_ROLE + bool "Dual Role mode" + depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) + help + This is the default mode of working of DWC3 controller where + both host and gadget features are enabled. + +endchoice + +comment "Platform Glue Driver Support" + +config USB_DWC3_OMAP + tristate "Texas Instruments OMAP5 and similar Platforms" + depends on EXTCON && (ARCH_OMAP2PLUS || COMPILE_TEST) + depends on OF + default USB_DWC3 + help + Some platforms from Texas Instruments like OMAP5, DRA7xxx and + AM437x use this IP for USB2/3 functionality. + + Say 'Y' or 'M' here if you have one such device + +config USB_DWC3_EXYNOS + tristate "Samsung Exynos Platform" + depends on ARCH_EXYNOS && OF || COMPILE_TEST + default USB_DWC3 + help + Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, + say 'Y' or 'M' if you have one such device. + +config USB_DWC3_PCI + tristate "PCIe-based Platforms" + depends on PCI + default USB_DWC3 + help + If you're using the DesignWare Core IP with a PCIe, please say + 'Y' or 'M' here. + + One such PCIe-based platform is Synopsys' PCIe HAPS model of + this IP. + +config USB_DWC3_KEYSTONE + tristate "Texas Instruments Keystone2 Platforms" + depends on ARCH_KEYSTONE || COMPILE_TEST + default USB_DWC3 + help + Support of USB2/3 functionality in TI Keystone2 platforms. + Say 'Y' or 'M' here if you have one such device + +config USB_DWC3_ST + tristate "STMicroelectronics Platforms" + depends on ARCH_STI && OF + default USB_DWC3 + help + STMicroelectronics SoCs with one DesignWare Core USB3 IP + inside (i.e. STiH407). + Say 'Y' or 'M' if you have one such device. + +config USB_DWC3_QCOM + tristate "Qualcomm Platforms" + depends on ARCH_QCOM || COMPILE_TEST + default USB_DWC3 + help + Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, + say 'Y' or 'M' if you have one such device. + +comment "Debugging features" + +config USB_DWC3_DEBUG + bool "Enable Debugging Messages" + help + Say Y here to enable debugging messages on DWC3 Driver. + +config USB_DWC3_VERBOSE + bool "Enable Verbose Debugging Messages" + depends on USB_DWC3_DEBUG + help + Say Y here to enable verbose debugging messages on DWC3 Driver. + +config DWC3_HOST_USB3_LPM_ENABLE + bool "Enable USB3 LPM Capability" + depends on USB_DWC3_HOST=y || USB_DWC3_DUAL_ROLE=y + default n + help + Select this when you want to enable USB3 LPM with dwc3 xhci host. + +endif
drivers/usb/dwc3/Makefile new file +40 -0
@@ -0,0 +1,40 @@ +# define_trace.h needs to know how to find our header +CFLAGS_trace.o := -I$(src) + +ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG +ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG + +obj-$(CONFIG_USB_DWC3) += dwc3.o + +dwc3-y := core.o debug.o trace.o + +ifneq ($(filter y,$(CONFIG_USB_DWC3_HOST) $(CONFIG_USB_DWC3_DUAL_ROLE)),) + dwc3-y += host.o +endif + +ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) $(CONFIG_USB_DWC3_DUAL_ROLE)),) + dwc3-y += gadget.o ep0.o +endif + +ifneq ($(CONFIG_DEBUG_FS),) + dwc3-y += debugfs.o +endif + +## +# Platform-specific glue layers go here +# +# NOTICE: Make sure your glue layer doesn't depend on anything +# which is arch-specific and that it compiles on all situations. +# +# We want to keep this requirement in order to be able to compile +# the entire driver (with all its glue layers) on several architectures +# and make sure it compiles fine. This will also help with allmodconfig +# and allyesconfig builds. +## + +obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o +obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o +obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o +obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o +obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o +obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
drivers/usb/dwc3/core.c new file +1119 -0
1,119 lines not on this page · raw message
drivers/usb/dwc3/core.h new file +1041 -0
1,041 lines not on this page · raw message
drivers/usb/dwc3/debug.c new file +32 -0
@@ -0,0 +1,32 @@ +/** +* debug.c - DesignWare USB3 DRD Controller Debug/Trace Support +* +* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com +* +* Author: Felipe Balbi <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 of +* the License as published by the Free Software Foundation. +* +* 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. +*/ + +#include "debug.h" + +void dwc3_trace (void (*trace)(struct va_format *),const char *fmt, ...) +{ +struct va_format vaf; +va_list args; + +va_start (args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + +trace (&vaf); + +va_end (args); +}
drivers/usb/dwc3/debug.h new file +228 -0
228 lines not on this page · raw message
drivers/usb/dwc3/debugfs.c new file +690 -0
420 lines not on this page · raw message
drivers/usb/dwc3/dwc3-exynos.c new file +301 -0
301 lines not on this page · raw message
drivers/usb/dwc3/dwc3-keystone.c new file +197 -0
197 lines not on this page · raw message
drivers/usb/dwc3/dwc3-omap.c new file +645 -0
645 lines not on this page · raw message
drivers/usb/dwc3/dwc3-pci.c new file +272 -0
272 lines not on this page · raw message
drivers/usb/dwc3/dwc3-qcom.c new file +130 -0
130 lines not on this page · raw message
drivers/usb/dwc3/dwc3-st.c new file +367 -0
367 lines not on this page · raw message
drivers/usb/dwc3/ep0.c new file +1092 -0
1,092 lines not on this page · raw message
drivers/usb/dwc3/gadget.c new file +2824 -0
2,824 lines not on this page · raw message
drivers/usb/dwc3/gadget.h new file +107 -0
107 lines not on this page · raw message
drivers/usb/dwc3/host.c new file +91 -0
91 lines not on this page · raw message
drivers/usb/dwc3/io.h new file +70 -0
70 lines not on this page · raw message
drivers/usb/dwc3/platform_data.h new file +47 -0
47 lines not on this page · raw message
drivers/usb/dwc3/trace.h new file +247 -0
247 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH v2 8/40 usb: dwc3: remove un-used files from dwc3 folder
In reply to Kishon Vijay Abraham Iremoved un-used/un-supported files from dwc3. These files can be added later as and when the support is added.
--- drivers/usb/dwc3/Kconfig | 120 ------- drivers/usb/dwc3/debug.c | 32 -- drivers/usb/dwc3/debug.h | 228 ------------- drivers/usb/dwc3/debugfs.c | 690 -------------------------------------- drivers/usb/dwc3/dwc3-exynos.c | 301 ----------------- drivers/usb/dwc3/dwc3-keystone.c | 197 ----------- drivers/usb/dwc3/dwc3-pci.c | 272 --------------- drivers/usb/dwc3/dwc3-qcom.c | 130 ------- drivers/usb/dwc3/dwc3-st.c | 367 -------------------- drivers/usb/dwc3/host.c | 91 ----- drivers/usb/dwc3/platform_data.h | 47 --- drivers/usb/dwc3/trace.c | 19 -- drivers/usb/dwc3/trace.h | 247 -------------- 13 files changed, 2741 deletions(-) delete mode 100644 drivers/usb/dwc3/Kconfig delete mode 100644 drivers/usb/dwc3/debug.c delete mode 100644 drivers/usb/dwc3/debug.h delete mode 100644 drivers/usb/dwc3/debugfs.c delete mode 100644 drivers/usb/dwc3/dwc3-exynos.c delete mode 100644 drivers/usb/dwc3/dwc3-keystone.c delete mode 100644 drivers/usb/dwc3/dwc3-pci.c delete mode 100644 drivers/usb/dwc3/dwc3-qcom.c delete mode 100644 drivers/usb/dwc3/dwc3-st.c delete mode 100644 drivers/usb/dwc3/host.c delete mode 100644 drivers/usb/dwc3/platform_data.h delete mode 100644 drivers/usb/dwc3/trace.c delete mode 100644 drivers/usb/dwc3/trace.h
drivers/usb/dwc3/Kconfig deleted +0 -120
@@ -1,120 +0,0 @@ -config USB_DWC3 - tristate "DesignWare USB3 DRD Core Support" - depends on (USB || USB_GADGET) && HAS_DMA - select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD - help - Say Y or M here if your system has a Dual Role SuperSpeed - USB controller based on the DesignWare USB3 IP Core. - - If you choose to build this driver is a dynamically linked - module, the module will be called dwc3.ko. - -if USB_DWC3 - -choice - bool "DWC3 Mode Selection" - default USB_DWC3_DUAL_ROLE if (USB && USB_GADGET) - default USB_DWC3_HOST if (USB && !USB_GADGET) - default USB_DWC3_GADGET if (!USB && USB_GADGET) - -config USB_DWC3_HOST - bool "Host only mode" - depends on USB=y || USB=USB_DWC3 - help - Select this when you want to use DWC3 in host mode only, - thereby the gadget feature will be regressed. - -config USB_DWC3_GADGET - bool "Gadget only mode" - depends on USB_GADGET=y || USB_GADGET=USB_DWC3 - help - Select this when you want to use DWC3 in gadget mode only, - thereby the host feature will be regressed. - -config USB_DWC3_DUAL_ROLE - bool "Dual Role mode" - depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) - help - This is the default mode of working of DWC3 controller where - both host and gadget features are enabled. - -endchoice - -comment "Platform Glue Driver Support" - -config USB_DWC3_OMAP - tristate "Texas Instruments OMAP5 and similar Platforms" - depends on EXTCON && (ARCH_OMAP2PLUS || COMPILE_TEST) - depends on OF - default USB_DWC3 - help - Some platforms from Texas Instruments like OMAP5, DRA7xxx and - AM437x use this IP for USB2/3 functionality. - - Say 'Y' or 'M' here if you have one such device - -config USB_DWC3_EXYNOS - tristate "Samsung Exynos Platform" - depends on ARCH_EXYNOS && OF || COMPILE_TEST - default USB_DWC3 - help - Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, - say 'Y' or 'M' if you have one such device. - -config USB_DWC3_PCI - tristate "PCIe-based Platforms" - depends on PCI - default USB_DWC3 - help - If you're using the DesignWare Core IP with a PCIe, please say - 'Y' or 'M' here. - - One such PCIe-based platform is Synopsys' PCIe HAPS model of - this IP. - -config USB_DWC3_KEYSTONE - tristate "Texas Instruments Keystone2 Platforms" - depends on ARCH_KEYSTONE || COMPILE_TEST - default USB_DWC3 - help - Support of USB2/3 functionality in TI Keystone2 platforms. - Say 'Y' or 'M' here if you have one such device - -config USB_DWC3_ST - tristate "STMicroelectronics Platforms" - depends on ARCH_STI && OF - default USB_DWC3 - help - STMicroelectronics SoCs with one DesignWare Core USB3 IP - inside (i.e. STiH407). - Say 'Y' or 'M' if you have one such device. - -config USB_DWC3_QCOM - tristate "Qualcomm Platforms" - depends on ARCH_QCOM || COMPILE_TEST - default USB_DWC3 - help - Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, - say 'Y' or 'M' if you have one such device. - -comment "Debugging features" - -config USB_DWC3_DEBUG - bool "Enable Debugging Messages" - help - Say Y here to enable debugging messages on DWC3 Driver. - -config USB_DWC3_VERBOSE - bool "Enable Verbose Debugging Messages" - depends on USB_DWC3_DEBUG - help - Say Y here to enable verbose debugging messages on DWC3 Driver. - -config DWC3_HOST_USB3_LPM_ENABLE - bool "Enable USB3 LPM Capability" - depends on USB_DWC3_HOST=y || USB_DWC3_DUAL_ROLE=y - default n - help - Select this when you want to enable USB3 LPM with dwc3 xhci host. - -endif
drivers/usb/dwc3/debug.c deleted +0 -32
@@ -1,32 +0,0 @@ -/** -* debug.c - DesignWare USB3 DRD Controller Debug/Trace Support -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com -* -* Author: Felipe Balbi <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* 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. -*/ - -#include "debug.h" - -void dwc3_trace (void (*trace)(struct va_format *),const char *fmt, ...) -{ -struct va_format vaf; -va_list args; - -va_start (args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - -trace (&vaf); - -va_end (args); -}
drivers/usb/dwc3/debug.h deleted +0 -228
228 lines not on this page · raw message
drivers/usb/dwc3/debugfs.c deleted +0 -690
690 lines not on this page · raw message
drivers/usb/dwc3/dwc3-exynos.c deleted +0 -301
301 lines not on this page · raw message
drivers/usb/dwc3/dwc3-keystone.c deleted +0 -197
197 lines not on this page · raw message
drivers/usb/dwc3/dwc3-pci.c deleted +0 -272
272 lines not on this page · raw message
drivers/usb/dwc3/dwc3-qcom.c deleted +0 -130
130 lines not on this page · raw message
drivers/usb/dwc3/dwc3-st.c deleted +0 -367
367 lines not on this page · raw message
drivers/usb/dwc3/host.c deleted +0 -91
91 lines not on this page · raw message
drivers/usb/dwc3/platform_data.h deleted +0 -47
47 lines not on this page · raw message
drivers/usb/dwc3/trace.c deleted +0 -19
@@ -1,19 +0,0 @@ -/** -* trace.c - DesignWare USB3 DRD Controller Trace Support -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com -* -* Author: Felipe Balbi <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. -* -* 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. -*/ - -#define CREATE_TRACE_POINTS -#include "trace.h"
drivers/usb/dwc3/trace.h deleted +0 -247
247 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 9/40 usb: dwc3: Modify the file headers to u-boot format
In reply to Kishon Vijay Abraham IModified the file header to the format that is used in u-boot. Also included in the header, the commit in linux kernel from which each of these files are added.
--- drivers/usb/dwc3/core.c | 15 +++++---------- drivers/usb/dwc3/core.h | 15 +++++++-------- drivers/usb/dwc3/dwc3-omap.c | 14 ++++++-------- drivers/usb/dwc3/ep0.c | 14 ++++++-------- drivers/usb/dwc3/gadget.c | 14 ++++++-------- drivers/usb/dwc3/gadget.h | 16 ++++++++-------- drivers/usb/dwc3/io.h | 15 +++++++-------- 7 files changed, 45 insertions(+), 58 deletions(-)
drivers/usb/dwc3/core.c +5 -10
@@ -1,22 +1,17 @@/** * core.c - DesignWare USB3 DRD Controller Core file * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/core.c) and ported +* to uboot. * -* 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. +* commit cd72f890d2 : usb: dwc3: core: enable phy suspend quirk on non-FPGA * -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* SPDX-License-Identifier: GPL-2.0 */ #include <linux/version.h>
drivers/usb/dwc3/core.h +7 -8
@@ -1,19 +1,18 @@/** * core.h - DesignWare USB3 DRD Core Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/core.h) and ported +* to uboot. +* +* commit 460d098cb6 : usb: dwc3: make HIRD threshold configurable +* +* SPDX-License-Identifier: GPL-2.0 * -* 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 __DRIVERS_USB_DWC3_CORE_H
drivers/usb/dwc3/dwc3-omap.c +6 -8
@@ -1,19 +1,17 @@/** * dwc3-omap.c - OMAP Specific Glue layer * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/dwc3-omap.c) and ported +* to uboot. * -* 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. +* commit 7ee2566ff5 : usb: dwc3: dwc3-omap: get rid of ->prepare()/->complete() +* +* SPDX-License-Identifier: GPL-2.0 */ #include <linux/module.h>
drivers/usb/dwc3/ep0.c +6 -8
@@ -1,19 +1,17 @@/** * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/ep0.c) and ported +* to uboot. * -* 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. +* commit c00552ebaf : Merge 3.18-rc7 into usb-next +* +* SPDX-License-Identifier: GPL-2.0 */ #include <linux/kernel.h>
drivers/usb/dwc3/gadget.c +6 -8
@@ -1,19 +1,17 @@/** * gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/gadget.c) and ported +* to uboot. * -* 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. +* commit 8e74475b0e : usb: dwc3: gadget: use udc-core's reset notifier +* +* SPDX-License-Identifier: GPL-2.0 */ #include <linux/kernel.h>
drivers/usb/dwc3/gadget.h +8 -8
@@ -1,19 +1,19 @@/** * gadget.h - DesignWare USB3 DRD Gadget Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/gadget.h) and ported +* to uboot. +* +* commit 7a60855972 : usb: dwc3: gadget: fix set_halt() bug with pending +transfers +* +* SPDX-License-Identifier: GPL-2.0 * -* 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 __DRIVERS_USB_DWC3_GADGET_H
drivers/usb/dwc3/io.h +7 -8
@@ -1,19 +1,18 @@/** * io.h - DesignWare USB3 DRD IO Header * -* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com +* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <[email protected]>, * Sebastian Andrzej Siewior <[email protected]> * -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 of -* the License as published by the Free Software Foundation. +* Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported +* to uboot. +* +* commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging +* +* SPDX-License-Identifier: GPL-2.0 * -* 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 __DRIVERS_USB_DWC3_IO_H
Signature · 1 line
1.7.9.5
PATCH v2 10/40 usb: dwc3: remove trace_* APIs from dwc3 driver
In reply to Kishon Vijay Abraham IRemoved most of the trace_* APIs from dwc3 driver since tracepoints are not supported in u-boot. Replaced some of the trace_* API with dev_dbg/dev/vdbg.
--- drivers/usb/dwc3/Makefile | 5 +--- drivers/usb/dwc3/ep0.c | 70 ++++++++++++++++++--------------------------- drivers/usb/dwc3/gadget.c | 17 ----------- drivers/usb/dwc3/io.h | 17 ----------- 4 files changed, 29 insertions(+), 80 deletions(-)
drivers/usb/dwc3/Makefile +1 -4
@@ -1,12 +1,9 @@ -# define_trace.h needs to know how to find our header -CFLAGS_trace.o := -I$(src) - ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG obj-$(CONFIG_USB_DWC3) += dwc3.o -dwc3-y := core.o debug.o trace.o +dwc3-y := core.o debug.o ifneq ($(filter y,$(CONFIG_USB_DWC3_HOST) $(CONFIG_USB_DWC3_DUAL_ROLE)),) dwc3-y += host.o
drivers/usb/dwc3/ep0.c +28 -42
231 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +0 -17
@@ -265,7 +265,6 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,dev_dbg (dwc->dev,"request %p from %s completed %d/%d ===> %d\n" , req, dep->name, req->request.actual, req->request.length, status); -trace_dwc3_gadget_giveback (req);spin_unlock (&dwc->lock);usb_gadget_giveback_request (&dep->endpoint, &req->request);
@@ -277,8 +276,6 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)u32 timeout =500 ;u32 reg; -trace_dwc3_gadget_generic_cmd (cmd, param); -dwc3_writel (dwc->regs,DWC3_DGCMDPAR , param);dwc3_writel (dwc->regs,DWC3_DGCMD , cmd |DWC3_DGCMD_CMDACT );
@@ -308,8 +305,6 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,u32 timeout =500 ;u32 reg; -trace_dwc3_gadget_ep_cmd (dep, cmd, params); -dwc3_writel (dwc->regs,DWC3_DEPCMDPAR0 (ep), params->param0);dwc3_writel (dwc->regs,DWC3_DEPCMDPAR1 (ep), params->param1);dwc3_writel (dwc->regs,DWC3_DEPCMDPAR2 (ep), params->param2);
@@ -704,8 +699,6 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, req->epnum = dep->number; req->dep = dep; -trace_dwc3_alloc_request (req); -return &req->request; }
@@ -714,7 +707,6 @@ static void dwc3_gadget_ep_free_request(struct usb_ep *ep, {struct dwc3_request *req =to_dwc3_request (request); -trace_dwc3_free_request (req);kfree (req); }
@@ -796,8 +788,6 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, trb->ctrl |=DWC3_TRB_CTRL_SID_SOFN (req->request.stream_id); trb->ctrl |=DWC3_TRB_CTRL_HWO ; - -trace_dwc3_prepare_trb (dep, trb); }/*
@@ -1150,7 +1140,6 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,dev_vdbg (dwc->dev,"queing request %p to %s length %d\n" , request, ep->name, request->length); -trace_dwc3_ep_queue (req); ret =__dwc3_gadget_ep_queue (dep, req);
@@ -1172,8 +1161,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,unsigned long flags;int ret =0 ; -trace_dwc3_ep_dequeue (req); -spin_lock_irqsave (&dwc->lock, flags);list_for_each_entry (r, &dep->request_list, list) {
@@ -1771,8 +1758,6 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,unsigned int s_pkt =0 ;unsigned int trb_status; -trace_dwc3_complete_trb (dep, trb); -if ((trb->ctrl &DWC3_TRB_CTRL_HWO ) && status != -ESHUTDOWN )/* * We continue despite the error. There is not much we
@@ -2529,8 +2514,6 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,static void dwc3_process_event_entry (struct dwc3 *dwc,const union dwc3_event *event) { -trace_dwc3_event (event->raw); -/* Endpoint IRQ, handle it and return early */ if (event->type.is_devspec ==0 ) {/* depevt */
drivers/usb/dwc3/io.h +0 -17
@@ -19,7 +19,6 @@#define __DRIVERS_USB_DWC3_IO_H#include <linux/io.h> -#include "trace.h" #include "debug.h" #include "core.h"
@@ -35,14 +34,6 @@ static inline u32 dwc3_readl(void __iomem *base, u32 offset)*/ value =readl (base + offs); -/* -* When tracing we want to make it easy to find the correct address on -* documentation, so we revert it back to the proper addresses, the -* same way they are described on SNPS documentation -*/ -dwc3_trace (trace_dwc3_readl,"addr %p value %08x" , - base -DWC3_GLOBALS_REGS_START + offset, value); -return value; }
@@ -56,14 +47,6 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)* However, the offsets are given starting from xHCI address space. */ writel(value, base + offs); - -/* -* When tracing we want to make it easy to find the correct address on -* documentation, so we revert it back to the proper addresses, the -* same way they are described on SNPS documentation -*/ -dwc3_trace (trace_dwc3_writel,"addr %p value %08x" , - base - DWC3_GLOBALS_REGS_START + offset, value); }#endif /* __DRIVERS_USB_DWC3_IO_H */
Signature · 1 line
1.7.9.5
PATCH v2 11/40 usb: dwc3: fix dwc3 header files
In reply to Kishon Vijay Abraham IChanged the header files included in core.h and io.h to the u-boot header files so that these files can be included in other dwc3 source files and be compiled in uboot. Also added otg.h which has the defines for dr_mode.
--- drivers/usb/dwc3/core.h | 13 ++----------- drivers/usb/dwc3/io.h | 4 +--- include/linux/usb/otg.h | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 include/linux/usb/otg.h
drivers/usb/dwc3/core.h +2 -11
@@ -18,20 +18,11 @@#ifndef __DRIVERS_USB_DWC3_CORE_H#define __DRIVERS_USB_DWC3_CORE_H -#include <linux/device.h> -#include <linux/spinlock.h> #include <linux/ioport.h> -#include <linux/list.h> -#include <linux/dma-mapping.h> -#include <linux/mm.h> -#include <linux/debugfs.h> #include <linux/usb/ch9.h> -#include <linux/usb/gadget.h> #include <linux/usb/otg.h> -#include <linux/phy/phy.h> -#define DWC3_MSG_MAX 500/* Global constants */
@@ -981,7 +972,7 @@ struct dwc3_gadget_ep_cmd_params {void dwc3_set_mode (struct dwc3 *dwc,u32 mode);int dwc3_gadget_resize_tx_fifos (struct dwc3 *dwc); -#if IS_ENABLED (CONFIG_USB_DWC3_HOST ) ||IS_ENABLED (CONFIG_USB_DWC3_DUAL_ROLE ) +#ifdef CONFIG_USB_DWC3_HOST int dwc3_host_init (struct dwc3 *dwc);void dwc3_host_exit (struct dwc3 *dwc);#else
@@ -991,7 +982,7 @@ static inline void dwc3_host_exit(struct dwc3 *dwc) { }#endif -#if IS_ENABLED (CONFIG_USB_DWC3_GADGET ) ||IS_ENABLED (CONFIG_USB_DWC3_DUAL_ROLE ) +#ifdef CONFIG_USB_DWC3_GADGET int dwc3_gadget_init (struct dwc3 *dwc);void dwc3_gadget_exit (struct dwc3 *dwc);int dwc3_gadget_set_test_mode (struct dwc3 *dwc,int mode);
drivers/usb/dwc3/io.h +1 -3
@@ -18,9 +18,7 @@#ifndef __DRIVERS_USB_DWC3_IO_H#define __DRIVERS_USB_DWC3_IO_H -#include <linux/io.h> -#include "debug.h" -#include "core.h" +#include <asm/io.h> static inline u32 dwc3_readl (void __iomem *base,u32 offset) {
include/linux/usb/otg.h new file +20 -0
@@ -0,0 +1,20 @@ +/* include/linux/usb/otg.h +* +* Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com +* +* USB OTG (On The Go) defines +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __LINUX_USB_OTG_H +#define __LINUX_USB_OTG_H + +enum usb_dr_mode { +USB_DR_MODE_UNKNOWN , +USB_DR_MODE_HOST , +USB_DR_MODE_PERIPHERAL , +USB_DR_MODE_OTG , +}; + +#endif /* __LINUX_USB_OTG_H */
Signature · 1 line
1.7.9.5
PATCH v2 12/40 usb: dwc3: remove pm related operations from dwc3 driver
In reply to Kishon Vijay Abraham IRemoved all pm related operations including pm_runtime APIs, suspend/resume hooks as support for these are not present in u-boot.
--- drivers/usb/dwc3/core.c | 96 ------------------------------------------ drivers/usb/dwc3/core.h | 16 ------- drivers/usb/dwc3/dwc3-omap.c | 61 +++------------------------ drivers/usb/dwc3/gadget.c | 55 ------------------------ 4 files changed, 5 insertions(+), 223 deletions(-)
drivers/usb/dwc3/core.c +0 -96
@@ -20,7 +20,6 @@#include <linux/slab.h> #include <linux/spinlock.h> #include <linux/platform_device.h> -#include <linux/pm_runtime.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/io.h>
@@ -884,10 +883,6 @@ static int dwc3_probe(struct platform_device *pdev)dma_set_coherent_mask (dev, dev->parent->coherent_dma_mask); } -pm_runtime_enable (dev); -pm_runtime_get_sync (dev); -pm_runtime_forbid (dev); -dwc3_cache_hwparams (dwc); ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );
@@ -937,8 +932,6 @@ static int dwc3_probe(struct platform_device *pdev) goto err3; } -pm_runtime_allow (dev); -return 0 ; err3:
@@ -980,97 +973,9 @@ static int dwc3_remove(struct platform_device *pdev)dwc3_core_exit (dwc); -pm_runtime_put_sync (&pdev->dev); -pm_runtime_disable (&pdev->dev); - -return 0 ; -} - -#ifdef CONFIG_PM_SLEEP -static int dwc3_suspend (struct device *dev) -{ -struct dwc3 *dwc =dev_get_drvdata (dev); -unsigned long flags; - -spin_lock_irqsave (&dwc->lock, flags); - -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : -dwc3_gadget_suspend (dwc); -/* FALLTHROUGH */ -case USB_DR_MODE_HOST : -default : -dwc3_event_buffers_cleanup (dwc); -break ; - } - - dwc->gctl =dwc3_readl (dwc->regs,DWC3_GCTL ); -spin_unlock_irqrestore (&dwc->lock, flags); - -usb_phy_shutdown (dwc->usb3_phy); -usb_phy_shutdown (dwc->usb2_phy); -phy_exit (dwc->usb2_generic_phy); -phy_exit (dwc->usb3_generic_phy); -return 0 ; } -static int dwc3_resume (struct device *dev) -{ -struct dwc3 *dwc =dev_get_drvdata (dev); -unsigned long flags; -int ret; - -usb_phy_init (dwc->usb3_phy); -usb_phy_init (dwc->usb2_phy); - ret =phy_init (dwc->usb2_generic_phy); -if (ret <0 ) -return ret; - - ret =phy_init (dwc->usb3_generic_phy); -if (ret <0 ) - goto err_usb2phy_init; - -spin_lock_irqsave (&dwc->lock, flags); - -dwc3_event_buffers_setup (dwc); -dwc3_writel (dwc->regs,DWC3_GCTL , dwc->gctl); - -switch (dwc->dr_mode) { -case USB_DR_MODE_PERIPHERAL : -case USB_DR_MODE_OTG : -dwc3_gadget_resume (dwc); -/* FALLTHROUGH */ -case USB_DR_MODE_HOST : -default : -/* do nothing */ -break ; - } - -spin_unlock_irqrestore (&dwc->lock, flags); - -pm_runtime_disable (dev); -pm_runtime_set_active (dev); -pm_runtime_enable (dev); - -return 0 ; - -err_usb2phy_init: -phy_exit (dwc->usb2_generic_phy); - -return ret; -} - -static const struct dev_pm_ops dwc3_dev_pm_ops = { -SET_SYSTEM_SLEEP_PM_OPS (dwc3_suspend, dwc3_resume) -}; - -#define DWC3_PM_OPS &(dwc3_dev_pm_ops) -#else -#define DWC3_PM_OPS NULL -#endif - #ifdef CONFIG_OF static const struct of_device_id of_dwc3_match[] = { {
@@ -1102,7 +1007,6 @@ static struct platform_driver dwc3_driver = { .name = "dwc3", .of_match_table = of_match_ptr(of_dwc3_match), .acpi_match_table = ACPI_PTR(dwc3_acpi_match), - .pm = DWC3_PM_OPS, }, };
drivers/usb/dwc3/core.h +0 -16
@@ -1012,20 +1012,4 @@ static inline int dwc3_send_gadget_generic_command(struct dwc3 *dwc, {return 0 ; }#endif -/* power management interface */ -#if !IS_ENABLED (CONFIG_USB_DWC3_HOST ) -int dwc3_gadget_suspend (struct dwc3 *dwc); -int dwc3_gadget_resume (struct dwc3 *dwc); -#else -static inline int dwc3_gadget_suspend (struct dwc3 *dwc) -{ -return 0 ; -} - -static inline int dwc3_gadget_resume (struct dwc3 *dwc) -{ -return 0 ; -} -#endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */ -#endif /* __DRIVERS_USB_DWC3_CORE_H */
drivers/usb/dwc3/dwc3-omap.c +5 -56
119 lines not on this page · raw message
drivers/usb/dwc3/gadget.c +0 -55
58 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 13/40 arm: asm: dma-mapping: added dma_free_coherent API
In reply to Kishon Vijay Abraham IAdded dma_free_coherent corresponding to the dma_alloc_coherent in dma-mapping.h in order to free memory allocated using dma_alloc_coherent. This API is used in dwc3 driver.
--- arch/arm/include/asm/dma-mapping.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/include/asm/dma-mapping.h +7 -0
@@ -8,6 +8,8 @@#ifndef __ASM_ARM_DMA_MAPPING_H#define __ASM_ARM_DMA_MAPPING_H +#define dma_mapping_error (x, y) 0 +enum dma_data_direction {DMA_BIDIRECTIONAL =0 , DMA_TO_DEVICE = 1,
@@ -20,6 +22,11 @@ static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)return (void *)*handle; } +static inline void dma_free_coherent (void *addr) +{ +free (addr); +} +static inline unsigned long dma_map_single (volatile void *vaddr,size_t len,enum dma_data_direction dir) {
Signature · 1 line
1.7.9.5
PATCH v2 14/40 usb: dwc3: linux-compat: Add header for dwc3 linux compatibiltiy
In reply to Kishon Vijay Abraham IAdded a header file to include various linux specific APIs like pr_debug, WARN_ WARN_ON_ONCE etc.. in order to avoid compilation error while building dwc3 driver.
--- drivers/usb/dwc3/linux-compat.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 drivers/usb/dwc3/linux-compat.h
drivers/usb/dwc3/linux-compat.h new file +30 -0
@@ -0,0 +1,30 @@ +/** +* linux-compat.h - DesignWare USB3 Linux Compatibiltiy Adapter Header +* +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com +* +* Authors: Kishon Vijay Abraham I <[email protected]> +* +* Taken from Linux Kernel v3.16 (drivers/usb/dwc3/core.c) and ported +* to uboot. +* +* SPDX-License-Identifier: GPL-2.0 +* +*/ + +#ifndef __DWC3_LINUX_COMPAT__ +#define __DWC3_LINUX_COMPAT__ + +#define pr_debug (format) debug(format) +#define WARN(val, format, arg...) debug(format, ##arg) +#define WARN_ON_ONCE (val) debug("Error %d\n", val) + +#define BUILD_BUG_ON_NOT_POWER_OF_2 (n) + +static inline size_t strlcat (char *dest,const char *src,size_t n) +{ +strcat (dest, src); +return strlen (dest) +strlen (src); +} + +#endif
Signature · 1 line
1.7.9.5
PATCH v2 15/40 usb: dwc3: gadget: make dwc3 gadget build in uboot
In reply to Kishon Vijay Abraham IDid a bunch of things to get dwc3/gadget.c compile in u-boot without build errors and warnings
*) Changed the included header files to that used in u-boot.
*) Used dma_alloc_coherent and dma_free_coherent APIs of u-boot *) removed sg support
*) remove jiffies and used a simple while loop
*) removed irq support and added a function to call these interrupt handler.
--- drivers/usb/dwc3/gadget.c | 244 ++++++++++++++------------------------- drivers/usb/dwc3/gadget.h | 1 + drivers/usb/dwc3/linux-compat.h | 3 - include/linux/compat.h | 1 + include/linux/usb/gadget.h | 39 +++++++ 5 files changed, 125 insertions(+), 163 deletions(-)
drivers/usb/dwc3/gadget.c +84 -160
@@ -14,25 +14,22 @@* SPDX-License-Identifier: GPL-2.0 */ -#include <linux/kernel.h> -#include <linux/delay.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/platform_device.h> -#include <linux/pm_runtime.h> -#include <linux/interrupt.h> -#include <linux/io.h> +#include <common.h> +#include <malloc.h> +#include <asm/dma-mapping.h> +#include <usb/lin_gadget_compat.h> #include <linux/list.h> -#include <linux/dma-mapping.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> +#include <asm/arch/sys_proto.h> -#include "debug.h" #include "core.h" #include "gadget.h" #include "io.h" +#include "linux-compat.h" +/** * dwc3_gadget_set_test_mode - Enables USB2 Test Modes * @dwc: pointer to our context structure
@@ -166,7 +163,6 @@ int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state)int dwc3_gadget_resize_tx_fifos (struct dwc3 *dwc) {int last_fifo_depth =0 ; -int ram1_depth;int fifo_size;int mdwidth;int num;
@@ -174,7 +170,6 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)if (!dwc->needs_fifo_resize)return 0 ; - ram1_depth =DWC3_RAM1_DEPTH (dwc->hwparams.hwparams7); mdwidth =DWC3_MDWIDTH (dwc->hwparams.hwparams0);/* MDWIDTH is represented in bits, we need it in bytes */
@@ -232,24 +227,21 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, int status) {struct dwc3 *dwc = dep->dwc; -int i;if (req->queued) { - i =0 ; -do { + dep->busy_slot++; +/* +* Skip LINK TRB. We can't use req->trb and check for +* DWC3_TRBCTL_LINK_TRB because it points the TRB we +* just completed (not the LINK TRB). +*/ +if (((dep->busy_slot &DWC3_TRB_MASK ) == +DWC3_TRB_NUM -1 ) && +usb_endpoint_xfer_isoc (dep->endpoint.desc)) dep->busy_slot++; -/* -* Skip LINK TRB. We can't use req->trb and check for -* DWC3_TRBCTL_LINK_TRB because it points the TRB we -* just completed (not the LINK TRB). -*/ -if (((dep->busy_slot &DWC3_TRB_MASK ) == -DWC3_TRB_NUM -1 ) && -usb_endpoint_xfer_isoc (dep->endpoint.desc)) - dep->busy_slot++; - }while (++i < req->request.num_mapped_sgs); req->queued = false; } +list_del (&req->list); req->trb =NULL ;
@@ -301,7 +293,6 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)int dwc3_send_gadget_ep_cmd (struct dwc3 *dwc,unsigned ep,unsigned cmd,struct dwc3_gadget_ep_cmd_params *params) { -struct dwc3_ep *dep = dwc->eps[ep];u32 timeout =500 ;u32 reg;
@@ -340,17 +331,15 @@ static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep,static int dwc3_alloc_trb_pool (struct dwc3_ep *dep) { -struct dwc3 *dwc = dep->dwc; -if (dep->trb_pool)return 0 ;if (dep->number ==0 || dep->number ==1 )return 0 ; - dep->trb_pool =dma_alloc_coherent (dwc->dev, -sizeof (struct dwc3_trb ) *DWC3_TRB_NUM , - &dep->trb_pool_dma,GFP_KERNEL ); + dep->trb_pool =dma_alloc_coherent (sizeof (struct dwc3_trb ) * +DWC3_TRB_NUM , + (unsigned long *)&dep->trb_pool_dma);if (!dep->trb_pool) {dev_err (dep->dwc->dev,"failed to allocate trb pool for %s\n" , dep->name);
@@ -362,10 +351,7 @@ static int dwc3_alloc_trb_pool(struct dwc3_ep *dep)static void dwc3_free_trb_pool (struct dwc3_ep *dep) { -struct dwc3 *dwc = dep->dwc; - -dma_free_coherent (dwc->dev,sizeof (struct dwc3_trb ) *DWC3_TRB_NUM , - dep->trb_pool, dep->trb_pool_dma); +dma_free_coherent (dep->trb_pool); dep->trb_pool =NULL ; dep->trb_pool_dma =0 ;
@@ -607,7 +593,6 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) {struct dwc3_ep *dep; -struct dwc3 *dwc;unsigned long flags;int ret;
@@ -622,10 +607,9 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, } dep =to_dwc3_ep (ep); - dwc = dep->dwc;if (dep->flags &DWC3_EP_ENABLED ) { -dev_WARN_ONCE (dwc->dev, true,"%s is already enabled\n" , +WARN (true,"%s is already enabled\n" , dep->name);return 0 ; }
@@ -657,7 +641,6 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,static int dwc3_gadget_ep_disable (struct usb_ep *ep) {struct dwc3_ep *dep; -struct dwc3 *dwc;unsigned long flags;int ret;
@@ -667,10 +650,9 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep) } dep =to_dwc3_ep (ep); - dwc = dep->dwc;if (!(dep->flags &DWC3_EP_ENABLED )) { -dev_WARN_ONCE (dwc->dev, true,"%s is already disabled\n" , +WARN (true,"%s is already disabled\n" , dep->name);return 0 ; }
@@ -719,7 +701,6 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_request *req, dma_addr_t dma, unsigned length, unsigned last, unsigned chain, unsigned node) { - struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb; dev_vdbg(dwc->dev, "%s: req %p dma %08llx length %d%s%s\n",
@@ -856,57 +837,22 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)dma_addr_t dma; last_one = false; -if (req->request.num_mapped_sgs >0 ) { -struct usb_request *request = &req->request; -struct scatterlist *sg = request->sg; -struct scatterlist *s; -int i; - -for_each_sg (sg, s, request->num_mapped_sgs, i) { -unsigned chain = true; + dma = req->request.dma; + length = req->request.length; + trbs_left--; - length =sg_dma_len (s); - dma =sg_dma_address (s); +if (!trbs_left) + last_one =1 ; -if (i == (request->num_mapped_sgs -1 ) || -sg_is_last (s)) { -if (list_is_last (&req->list, - &dep->request_list)) - last_one = true; - chain = false; - } +/* Is this the last request? */ +if (list_is_last (&req->list, &dep->request_list)) + last_one =1 ; - trbs_left--; -if (!trbs_left) - last_one = true; +dwc3_prepare_one_trb (dep, req, dma, length, + last_one, false,0 ); -if (last_one) - chain = false; - -dwc3_prepare_one_trb (dep, req, dma, length, - last_one, chain, i); - -if (last_one) -break ; - } - }else { - dma = req->request.dma; - length = req->request.length; - trbs_left--; - -if (!trbs_left) - last_one =1 ; - -/* Is this the last request? */ -if (list_is_last (&req->list, &dep->request_list)) - last_one =1 ; - -dwc3_prepare_one_trb (dep, req, dma, length, - last_one, false,0 ); - -if (last_one) -break ; - } +if (last_one) +break ; } }
@@ -1103,8 +1049,6 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) ret =__dwc3_gadget_kick_transfer (dep,0 , true);if (ret && ret != -EBUSY ) { -struct dwc3 *dwc = dep->dwc; -dev_dbg (dwc->dev,"%s: failed to kick transfers\n" , dep->name); }
@@ -1118,7 +1062,6 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, {struct dwc3_request *req =to_dwc3_request (request);struct dwc3_ep *dep =to_dwc3_ep (ep); -struct dwc3 *dwc = dep->dwc;unsigned long flags;
@@ -1132,8 +1075,9 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, goto out; } -if (WARN (req->dep != dep,"request %p belongs to '%s'\n" , - request, req->dep->name)) { +if (req->dep != dep) { +WARN (true,"request %p belongs to '%s'\n" , + request, req->dep->name); ret = -EINVAL ; goto out; }
@@ -1239,7 +1183,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)static int dwc3_gadget_ep_set_halt (struct usb_ep *ep,int value) {struct dwc3_ep *dep =to_dwc3_ep (ep); -struct dwc3 *dwc = dep->dwc;unsigned long flags;
@@ -1255,7 +1198,6 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)static int dwc3_gadget_ep_set_wedge (struct usb_ep *ep) {struct dwc3_ep *dep =to_dwc3_ep (ep); -struct dwc3 *dwc = dep->dwc;unsigned long flags;int ret;
@@ -1371,9 +1313,9 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) }/* poll until Link State changes to ON */ - timeout = jiffies +msecs_to_jiffies (100 ); + timeout =1000 ; -while (!time_after (jiffies, timeout)) { +while (timeout--) { reg =dwc3_readl (dwc->regs,DWC3_DSTS );/* in HS, means ON */
@@ -1498,9 +1440,6 @@ static void dwc3_gadget_disable_irq(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_DEVTEN ,0x00 ); } -static irqreturn_t dwc3_interrupt (int irq,void *_dwc); -static irqreturn_t dwc3_thread_interrupt (int irq,void *_dwc); -static int dwc3_gadget_start (struct usb_gadget *g,struct usb_gadget_driver *driver) {
@@ -1508,24 +1447,14 @@ static int dwc3_gadget_start(struct usb_gadget *g,struct dwc3_ep *dep;unsigned long flags;int ret =0 ; -int irq;u32 reg; - irq =platform_get_irq (to_platform_device (dwc->dev),0 ); - ret =request_threaded_irq (irq, dwc3_interrupt, dwc3_thread_interrupt, -IRQF_SHARED ,"dwc3" , dwc); -if (ret) { -dev_err (dwc->dev,"failed to request irq #%d --> %d\n" , - irq, ret); - goto err0; - } -spin_lock_irqsave (&dwc->lock, flags);if (dwc->gadget_driver) {dev_err (dwc->dev,"%s is already bound to %s\n" , dwc->gadget.name, - dwc->gadget_driver->driver.name); + dwc->gadget_driver->function); ret = -EBUSY ; goto err1; }
@@ -1609,9 +1538,6 @@ err2: err1:spin_unlock_irqrestore (&dwc->lock, flags); -free_irq (irq, dwc); - -err0:return ret; }
@@ -1619,7 +1545,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g) {struct dwc3 *dwc =gadget_to_dwc (g);unsigned long flags; -int irq;spin_lock_irqsave (&dwc->lock, flags);
@@ -1631,9 +1556,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)spin_unlock_irqrestore (&dwc->lock, flags); - irq =platform_get_irq (to_platform_device (dwc->dev),0 ); -free_irq (irq, dwc); -return 0 ; }
@@ -1832,7 +1754,6 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,struct dwc3_request *req;struct dwc3_trb *trb;unsigned int slot; -unsigned int i;int ret; do {
@@ -1841,20 +1762,18 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,WARN_ON_ONCE (1 );return 1 ; } - i =0 ; -do { - slot = req->start_slot + i; -if ((slot ==DWC3_TRB_NUM -1 ) && -usb_endpoint_xfer_isoc (dep->endpoint.desc)) - slot++; - slot %=DWC3_TRB_NUM ; - trb = &dep->trb_pool[slot]; - - ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, - event, status); -if (ret) -break ; - }while (++i < req->request.num_mapped_sgs); + + slot = req->start_slot; +if ((slot ==DWC3_TRB_NUM -1 ) && +usb_endpoint_xfer_isoc (dep->endpoint.desc)) + slot++; + slot %=DWC3_TRB_NUM ; + trb = &dep->trb_pool[slot]; + + ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, + event, status); +if (ret) +break ;dwc3_gadget_giveback (dep, req, status);
@@ -2293,9 +2212,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)* BESL value in the LPM token is less than or equal to LPM * NYET threshold. */ -WARN_ONCE (dwc->revision <DWC3_REVISION_240A - && dwc->has_lpm_erratum, -"LPM Erratum not available on dwc3 revisisions < 2.40a\n" ); +if (dwc->revision <DWC3_REVISION_240A && dwc->has_lpm_erratum) +WARN (true,"LPM Erratum not available on dwc3 revisisions < 2.40a\n" );if (dwc->has_lpm_erratum && dwc->revision >=DWC3_REVISION_240A ) reg |=DWC3_DCTL_LPM_ERRATA (dwc->lpm_nyet_threshold);
@@ -2482,10 +2400,10 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,dwc3_gadget_wakeup_interrupt (dwc);break ;case DWC3_DEVICE_EVENT_HIBER_REQ : -if (dev_WARN_ONCE (dwc->dev, !dwc->has_hibernation, -"unexpected hibernation event\n" )) +if (!dwc->has_hibernation) { +WARN (1 ,"unexpected hibernation event\n" );break ; - + }dwc3_gadget_hibernation_interrupt (dwc, event->event_info);break ;case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE :
@@ -2649,16 +2567,16 @@ int dwc3_gadget_init(struct dwc3 *dwc) {int ret; - dwc->ctrl_req =dma_alloc_coherent (dwc->dev,sizeof (*dwc->ctrl_req), - &dwc->ctrl_req_addr,GFP_KERNEL ); + dwc->ctrl_req =dma_alloc_coherent (sizeof (*dwc->ctrl_req), + (unsigned long *)&dwc->ctrl_req_addr);if (!dwc->ctrl_req) {dev_err (dwc->dev,"failed to allocate ctrl request\n" ); ret = -ENOMEM ; goto err0; } - dwc->ep0_trb =dma_alloc_coherent (dwc->dev,sizeof (*dwc->ep0_trb), - &dwc->ep0_trb_addr,GFP_KERNEL ); + dwc->ep0_trb =dma_alloc_coherent (sizeof (*dwc->ep0_trb), + (unsigned long *)&dwc->ep0_trb_addr);if (!dwc->ep0_trb) {dev_err (dwc->dev,"failed to allocate ep0 trb\n" ); ret = -ENOMEM ;
@@ -2671,9 +2589,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err2; } - dwc->ep0_bounce =dma_alloc_coherent (dwc->dev, -DWC3_EP0_BOUNCE_SIZE , &dwc->ep0_bounce_addr, -GFP_KERNEL ); + dwc->ep0_bounce =dma_alloc_coherent (DWC3_EP0_BOUNCE_SIZE , + (unsigned long *)&dwc->ep0_bounce_addr);if (!dwc->ep0_bounce) {dev_err (dwc->dev,"failed to allocate ep0 bounce buffer\n" ); ret = -ENOMEM ;
@@ -2683,7 +2600,6 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc->gadget.ops = &dwc3_gadget_ops; dwc->gadget.max_speed =USB_SPEED_SUPER ; dwc->gadget.speed =USB_SPEED_UNKNOWN ; - dwc->gadget.sg_supported = true; dwc->gadget.name ="dwc3-gadget" ;/*
@@ -2711,19 +2627,16 @@ int dwc3_gadget_init(struct dwc3 *dwc) err4:dwc3_gadget_free_endpoints (dwc); -dma_free_coherent (dwc->dev,DWC3_EP0_BOUNCE_SIZE , - dwc->ep0_bounce, dwc->ep0_bounce_addr); +dma_free_coherent (dwc->ep0_bounce); err3:kfree (dwc->setup_buf); err2: -dma_free_coherent (dwc->dev,sizeof (*dwc->ep0_trb), - dwc->ep0_trb, dwc->ep0_trb_addr); +dma_free_coherent (dwc->ep0_trb); err1: -dma_free_coherent (dwc->dev,sizeof (*dwc->ctrl_req), - dwc->ctrl_req, dwc->ctrl_req_addr); +dma_free_coherent (dwc->ctrl_req); err0:return ret;
@@ -2737,14 +2650,25 @@ void dwc3_gadget_exit(struct dwc3 *dwc)dwc3_gadget_free_endpoints (dwc); -dma_free_coherent (dwc->dev,DWC3_EP0_BOUNCE_SIZE , - dwc->ep0_bounce, dwc->ep0_bounce_addr); +dma_free_coherent (dwc->ep0_bounce);kfree (dwc->setup_buf); -dma_free_coherent (dwc->dev,sizeof (*dwc->ep0_trb), - dwc->ep0_trb, dwc->ep0_trb_addr); +dma_free_coherent (dwc->ep0_trb); -dma_free_coherent (dwc->dev,sizeof (*dwc->ctrl_req), - dwc->ctrl_req, dwc->ctrl_req_addr); +dma_free_coherent (dwc->ctrl_req); +} + +/** +* dwc3_gadget_uboot_handle_interrupt - handle dwc3 gadget interrupt +* @dwc: struct dwce * +* +* Handles ep0 and gadget interrupt +* +* Should be called from dwc3 core. +*/ +void dwc3_gadget_uboot_handle_interrupt (struct dwc3 *dwc) +{ +dwc3_interrupt (0 , dwc); +dwc3_thread_interrupt (0 , dwc); }
drivers/usb/dwc3/gadget.h +1 -0
@@ -87,6 +87,7 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);int dwc3_gadget_ep0_queue (struct usb_ep *ep,struct usb_request *request,gfp_t gfp_flags);int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol); +void dwc3_gadget_uboot_handle_interrupt (struct dwc3 *dwc);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
drivers/usb/dwc3/linux-compat.h +0 -3
@@ -5,9 +5,6 @@* * Authors: Kishon Vijay Abraham I <[email protected]> * -* Taken from Linux Kernel v3.16 (drivers/usb/dwc3/core.c) and ported -* to uboot. -* * SPDX-License-Identifier: GPL-2.0 * */
include/linux/compat.h +1 -0
@@ -327,6 +327,7 @@ typedef unsigned long dmaaddr_t;#define IRQ_NONE 0#define IRQ_HANDLED 1 +#define IRQ_WAKE_THREAD 2#define dev_set_drvdata (dev, data) do {} while (0)
include/linux/usb/gadget.h +39 -0
@@ -31,6 +31,7 @@ struct usb_ep;* @dma: DMA address corresponding to 'buf'. If you don't set this * field, and the usb controller needs one, it is responsible * for mapping and unmapping the buffer. +* @stream_id: The stream id, when USB3.0 bulk streams are being used * @length: Length of that data * @no_interrupt: If true, hints that no completion irq is needed. * Helpful sometimes with deep request queues that are handled
@@ -85,6 +86,7 @@ struct usb_request {unsigned length;dma_addr_t dma; + unsigned stream_id:16; unsigned no_interrupt:1; unsigned zero:1; unsigned short_not_ok:1;
@@ -121,6 +123,7 @@ struct usb_ep_ops {int (*dequeue) (struct usb_ep *ep,struct usb_request *req);int (*set_halt) (struct usb_ep *ep,int value); +int (*set_wedge)(struct usb_ep *ep);int (*fifo_status) (struct usb_ep *ep);void (*fifo_flush) (struct usb_ep *ep); };
@@ -133,8 +136,18 @@ struct usb_ep_ops {* @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. +* @maxpacket_limit:The maximum packet size value which can be handled by this +* endpoint. It's set once by UDC driver when endpoint is initialized, and +* should not be changed. Should not be confused with maxpacket. +* @max_streams: The maximum number of streams supported +* by this EP (0 - 16, actual number is 2^n) +* @maxburst: the maximum number of bursts supported by this EP (for usb3) * @driver_data:for use by the gadget driver. all other fields are * read-only to gadget drivers. +* @desc: endpoint descriptor. This pointer is set before the endpoint is +* enabled and remains valid until the endpoint is disabled. +* @comp_desc: In case of SuperSpeed support, this is the endpoint companion +* descriptor that is used to configure the endpoint * * the bus controller driver lists all the general purpose endpoints in * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
@@ -146,11 +159,31 @@ struct usb_ep {const struct usb_ep_ops *ops;struct list_head ep_list; unsigned maxpacket:16; + unsigned maxpacket_limit:16; + unsigned max_streams:16; + unsigned maxburst:5; +const struct usb_endpoint_descriptor *desc; +const struct usb_ss_ep_comp_descriptor *comp_desc; };/*-------------------------------------------------------------------------*/ /** +* usb_ep_set_maxpacket_limit - set maximum packet size limit for endpoint +* @ep:the endpoint being configured +* @maxpacket_limit:value of maximum packet size limit +* +* This function shoud be used only in UDC drivers to initialize endpoint +* (usually in probe function). +*/ +static inline void usb_ep_set_maxpacket_limit (struct usb_ep *ep, +unsigned maxpacket_limit) +{ + ep->maxpacket_limit = maxpacket_limit; + ep->maxpacket = maxpacket_limit; +} + +/** * usb_ep_enable - configure endpoint, making it usable * @ep:the endpoint being configured. may not be the endpoint named "ep0". * drivers discover endpoints through the ep_list of a usb_gadget.
@@ -422,6 +455,8 @@ struct usb_gadget_ops {* driver setup() requests * @ep_list: List of other endpoints supported by the device. * @speed: Speed of current connection to USB host. +* @max_speed: Maximal speed the UDC can handle. UDC must support this +* and all slower speeds. * @is_dualspeed: true if the controller supports both high and full speed * operation. If it does, the gadget driver must also support both. * @is_otg: true if the USB device port uses a Mini-AB jack, so that the
@@ -438,6 +473,8 @@ struct usb_gadget_ops {* @name: Identifies the controller hardware type. Used in diagnostics * and sometimes configuration. * @dev: Driver model state for this abstract device. +* @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to +* MaxPacketSize. * * Gadgets have a mostly-portable "gadget driver" implementing device * functions, handling all usb configurations and interfaces. Gadget
@@ -463,6 +500,7 @@ struct usb_gadget {struct usb_ep *ep0;struct list_head ep_list;/* of usb_ep */ enum usb_device_speed speed; +enum usb_device_speed max_speed;enum usb_device_state state; unsigned is_dualspeed:1; unsigned is_otg:1;
@@ -472,6 +510,7 @@ struct usb_gadget { unsigned a_alt_hnp_support:1;const char *name;struct device dev; + unsigned quirk_ep_out_aligned_size:1; };static inline void set_gadget_data (struct usb_gadget *gadget,void *data)
Signature · 1 line
1.7.9.5
PATCH v2 16/40 include: asm: types: add resource_size_t type
In reply to Kishon Vijay Abraham IAdded resource_size_t type in order to get rid of the following compilation error whiel building dwc3 gadget. include/linux/ioport.h:19:2: error: unknown type name ?resource_size_t?
--- arch/arm/include/asm/types.h | 1 + 1 file changed, 1 insertion(+)
arch/arm/include/asm/types.h +1 -0
@@ -54,4 +54,5 @@ typedef unsigned long phys_size_t;#endif /* __KERNEL__ */ +typedef unsigned long resource_size_t ;#endif
Signature · 1 line
1.7.9.5
PATCH v2 17/40 usb: dwc3: ep0: make dwc3 ep0 build in uboot
In reply to Kishon Vijay Abraham I*) Changed the included header files to that used in u-boot. *) added dwc3_ep_event_string() used in ep0.c
*) Fixed other misc warnings
--- drivers/usb/dwc3/core.h | 24 ++++++++++++++++++++++++ drivers/usb/dwc3/ep0.c | 14 ++------------ drivers/usb/dwc3/linux-compat.h | 1 + 3 files changed, 27 insertions(+), 12 deletions(-)
drivers/usb/dwc3/core.h +24 -0
@@ -841,6 +841,30 @@ struct dwc3_event_type {#define DWC3_DEPEVT_EPCMDCMPLT 0x07/** +* dwc3_ep_event_string - returns event name +* @event: then event code +*/ +static inline const char *dwc3_ep_event_string (u8 event) +{ +switch (event) { +case DWC3_DEPEVT_XFERCOMPLETE : +return "Transfer Complete" ; +case DWC3_DEPEVT_XFERINPROGRESS : +return "Transfer In-Progress" ; +case DWC3_DEPEVT_XFERNOTREADY : +return "Transfer Not Ready" ; +case DWC3_DEPEVT_RXTXFIFOEVT : +return "FIFO" ; +case DWC3_DEPEVT_STREAMEVT : +return "Stream" ; +case DWC3_DEPEVT_EPCMDCMPLT : +return "Endpoint Command Complete" ; + } + +return "UNKNOWN" ; +} + +/** * struct dwc3_event_depvt - Device Endpoint Events * @one_bit: indicates this is an endpoint event (not used) * @endpoint_number: number of the endpoint
drivers/usb/dwc3/ep0.c +2 -12
@@ -15,24 +15,18 @@*/ #include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/platform_device.h> -#include <linux/pm_runtime.h> -#include <linux/interrupt.h> -#include <linux/io.h> #include <linux/list.h> -#include <linux/dma-mapping.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/composite.h> #include "core.h" -#include "debug.h" #include "gadget.h" #include "io.h" +#include "linux-compat.h" +static void __dwc3_ep0_do_control_status (struct dwc3 *dwc,struct dwc3_ep *dep);static void __dwc3_ep0_do_control_data (struct dwc3 *dwc,struct dwc3_ep *dep,struct dwc3_request *req);
@@ -277,8 +271,6 @@ int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)int dwc3_gadget_ep0_set_halt (struct usb_ep *ep,int value) { -struct dwc3_ep *dep =to_dwc3_ep (ep); -struct dwc3 *dwc = dep->dwc;unsigned long flags;int ret;
@@ -632,12 +624,10 @@ static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)struct dwc3_ep *dep;enum usb_device_state state = dwc->gadget.state;u16 wLength; -u16 wValue;if (state ==USB_STATE_DEFAULT )return -EINVAL ; - wValue =le16_to_cpu (ctrl->wValue); wLength =le16_to_cpu (ctrl->wLength);if (wLength !=6 ) {
drivers/usb/dwc3/linux-compat.h +1 -0
@@ -14,6 +14,7 @@#define pr_debug (format) debug(format) #define WARN(val, format, arg...) debug(format, ##arg) +#define dev_WARN(dev, format, arg...) debug(format, ##arg)#define WARN_ON_ONCE (val) debug("Error %d\n", val)#define BUILD_BUG_ON_NOT_POWER_OF_2 (n)
Signature · 1 line
1.7.9.5
PATCH v2 18/40 include: usb: composite: add USB_GADGET_DELAYED_STATUS to avoid compilation error
In reply to Kishon Vijay Abraham IAdded USB_GADGET_DELAYED_STATUS to avoid the following compilation error.
error: ?USB_GADGET_DELAYED_STATUS? undeclared (first use in this function) while compiling dwc3/ep0.c
While this is been added only to avoid compilation error, the complete fix should be something like the one added in linux kernel. The complete fix will be ported once we have the composite driver in u-boot look similar to the one in linux kernel.
commit 1b9ba000177ee47bcc5b44c7c34e48e735f5f9b1
Author: Roger Quadros <[email protected]> Date: Mon May 9 13:08:06 2011 +0300
usb: gadget: composite: Allow function drivers to pause control transfers
--- include/linux/usb/composite.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/linux/usb/composite.h +9 -0
@@ -27,6 +27,15 @@#include <linux/usb/gadget.h> #include <usb/lin_gadget_compat.h> +/* +* USB function drivers should return USB_GADGET_DELAYED_STATUS if they +* wish to delay the data/status stages of the control transfer till they +* are ready. The control transfer will then be kept from completing till +* all the function drivers that requested for USB_GADGET_DELAYED_STAUS +* invoke usb_composite_setup_continue(). +*/ +#define USB_GADGET_DELAYED_STATUS 0x7fff/* Impossibly large value */ +struct usb_configuration ;/**
Signature · 1 line
1.7.9.5
PATCH v2 19/40 usb: dwc3: core: make dwc3 core build in uboot
In reply to Kishon Vijay Abraham I*) Changed the include header files to that used in u-boot. *) Removed phy_* APIs
*) Removed jiffies and used a simple while loop
*) Used dma_alloc_coherent and dma_free_coherent APIs of u-boot *) Fixed other misc warnings
--- drivers/usb/dwc3/core.c | 216 ++++++--------------------------------- drivers/usb/dwc3/core.h | 10 -- drivers/usb/dwc3/linux-compat.h | 10 ++ 3 files changed, 40 insertions(+), 196 deletions(-)
drivers/usb/dwc3/core.c +30 -186
@@ -14,32 +14,19 @@* SPDX-License-Identifier: GPL-2.0 */ -#include <linux/version.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/platform_device.h> -#include <linux/interrupt.h> +#include <common.h> +#include <malloc.h> +#include <asm/dma-mapping.h> #include <linux/ioport.h> -#include <linux/io.h> -#include <linux/list.h> -#include <linux/delay.h> -#include <linux/dma-mapping.h> -#include <linux/of.h> -#include <linux/acpi.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> -#include <linux/usb/of.h> -#include <linux/usb/otg.h> -#include "platform_data.h" #include "core.h" #include "gadget.h" #include "io.h" -#include "debug.h" +#include "linux-compat.h" /* -------------------------------------------------------------------------- */
@@ -60,7 +47,6 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)static int dwc3_core_soft_reset (struct dwc3 *dwc) {u32 reg; -int ret;/* Before Resetting PHY, put Core in Reset */ reg =dwc3_readl (dwc->regs,DWC3_GCTL );
@@ -77,17 +63,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) reg |=DWC3_GUSB2PHYCFG_PHYSOFTRST ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); -usb_phy_init (dwc->usb2_phy); -usb_phy_init (dwc->usb3_phy); - ret =phy_init (dwc->usb2_generic_phy); -if (ret <0 ) -return ret; - - ret =phy_init (dwc->usb3_generic_phy); -if (ret <0 ) { -phy_exit (dwc->usb2_generic_phy); -return ret; - }mdelay (100 );/* Clear USB3 PHY reset */
@@ -118,7 +93,7 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)static void dwc3_free_one_event_buffer (struct dwc3 *dwc,struct dwc3_event_buffer *evt) { -dma_free_coherent (dwc->dev, evt->length, evt->buf, evt->dma); +dma_free_coherent (evt->buf); }/**
@@ -140,8 +115,8 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, evt->dwc = dwc; evt->length = length; - evt->buf =dma_alloc_coherent (dwc->dev, length, - &evt->dma,GFP_KERNEL ); + evt->buf =dma_alloc_coherent (length, + (unsigned long *)&evt->dma);if (!evt->buf)return ERR_PTR (-ENOMEM );
@@ -276,13 +251,9 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)if (!dwc->nr_scratch)return 0 ; -/* should never fall here */ -if (!WARN_ON (dwc->scratchbuf)) -return 0 ; - - scratch_addr =dma_map_single (dwc->dev, dwc->scratchbuf, - dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE , -DMA_BIDIRECTIONAL ); + scratch_addr =dma_map_single (dwc->scratchbuf, + dwc->nr_scratch *DWC3_SCRATCHBUF_SIZE , +DMA_BIDIRECTIONAL );if (dma_mapping_error (dwc->dev, scratch_addr)) {dev_err (dwc->dev,"failed to map scratch buffer\n" ); ret = -EFAULT ;
@@ -308,8 +279,8 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)return 0 ; err1: -dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * -DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); +dma_unmap_single ((void *)dwc->scratch_addr, dwc->nr_scratch * +DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); err0:return ret;
@@ -323,12 +294,8 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)if (!dwc->nr_scratch)return ; -/* should never fall here */ -if (!WARN_ON (dwc->scratchbuf)) -return ; - -dma_unmap_single (dwc->dev, dwc->scratch_addr, dwc->nr_scratch * -DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL ); +dma_unmap_single ((void *)dwc->scratch_addr, dwc->nr_scratch * +DWC3_SCRATCHBUF_SIZE ,DMA_BIDIRECTIONAL );kfree (dwc->scratchbuf); }
@@ -446,12 +413,6 @@ static int dwc3_core_init(struct dwc3 *dwc) } dwc->revision = reg; -/* -* Write Linux Version Code to our GUID register so it's easy to figure -* out which kernel version a bug was found. -*/ -dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE ); -/* Handle USB2.0-only core configuration */ if (DWC3_GHWPARAMS3_SSPHY_IFC (dwc->hwparams.hwparams3) ==DWC3_GHWPARAMS3_SSPHY_IFC_DIS ) {
@@ -460,21 +421,19 @@ static int dwc3_core_init(struct dwc3 *dwc) }/* issue device SoftReset too */ - timeout = jiffies +msecs_to_jiffies (500 ); + timeout =5000 ;dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); -do { +while (timeout--) { reg =dwc3_readl (dwc->regs,DWC3_DCTL );if (!(reg &DWC3_DCTL_CSFTRST ))break ; + }; -if (time_after (jiffies, timeout)) { -dev_err (dwc->dev,"Reset Timed Out\n" ); - ret = -ETIMEDOUT ; - goto err0; - } - -cpu_relax (); - }while (true); +if (!timeout) { +dev_err (dwc->dev,"Reset Timed Out\n" ); + ret = -ETIMEDOUT ; + goto err0; + } ret =dwc3_core_soft_reset (dwc);if (ret)
@@ -525,8 +484,9 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->is_fpga = true; } -WARN_ONCE (dwc->disable_scramble_quirk && !dwc->is_fpga, -"disable_scramble cannot be used on non-FPGA builds\n" ); +if (dwc->disable_scramble_quirk && !dwc->is_fpga) +WARN (true, +"disable_scramble cannot be used on non-FPGA builds\n" );if (dwc->disable_scramble_quirk && dwc->is_fpga) reg |=DWC3_GCTL_DISSCRAMBLE ;
@@ -553,22 +513,16 @@ static int dwc3_core_init(struct dwc3 *dwc) ret =dwc3_alloc_scratch_buffers (dwc);if (ret) - goto err1; + goto err0; ret =dwc3_setup_scratch_buffers (dwc);if (ret) - goto err2; + goto err1;return 0 ; -err2: -dwc3_free_scratch_buffers (dwc); - err1: -usb_phy_shutdown (dwc->usb2_phy); -usb_phy_shutdown (dwc->usb3_phy); -phy_exit (dwc->usb2_generic_phy); -phy_exit (dwc->usb3_generic_phy); +dwc3_free_scratch_buffers (dwc); err0:return ret;
@@ -577,82 +531,10 @@ err0:static void dwc3_core_exit (struct dwc3 *dwc) {dwc3_free_scratch_buffers (dwc); -usb_phy_shutdown (dwc->usb2_phy); -usb_phy_shutdown (dwc->usb3_phy); -phy_exit (dwc->usb2_generic_phy); -phy_exit (dwc->usb3_generic_phy); -} - -static int dwc3_core_get_phy (struct dwc3 *dwc) -{ -struct device *dev = dwc->dev; -struct device_node *node = dev->of_node; -int ret; - -if (node) { - dwc->usb2_phy =devm_usb_get_phy_by_phandle (dev,"usb-phy" ,0 ); - dwc->usb3_phy =devm_usb_get_phy_by_phandle (dev,"usb-phy" ,1 ); - }else { - dwc->usb2_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); - dwc->usb3_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB3 ); - } - -if (IS_ERR (dwc->usb2_phy)) { - ret =PTR_ERR (dwc->usb2_phy); -if (ret == -ENXIO || ret == -ENODEV ) { - dwc->usb2_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; - }else { -dev_err (dev,"no usb2 phy configured\n" ); -return ret; - } - } - -if (IS_ERR (dwc->usb3_phy)) { - ret =PTR_ERR (dwc->usb3_phy); -if (ret == -ENXIO || ret == -ENODEV ) { - dwc->usb3_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; - }else { -dev_err (dev,"no usb3 phy configured\n" ); -return ret; - } - } - - dwc->usb2_generic_phy =devm_phy_get (dev,"usb2-phy" ); -if (IS_ERR (dwc->usb2_generic_phy)) { - ret =PTR_ERR (dwc->usb2_generic_phy); -if (ret == -ENOSYS || ret == -ENODEV ) { - dwc->usb2_generic_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; - }else { -dev_err (dev,"no usb2 phy configured\n" ); -return ret; - } - } - - dwc->usb3_generic_phy =devm_phy_get (dev,"usb3-phy" ); -if (IS_ERR (dwc->usb3_generic_phy)) { - ret =PTR_ERR (dwc->usb3_generic_phy); -if (ret == -ENOSYS || ret == -ENODEV ) { - dwc->usb3_generic_phy =NULL ; - }else if (ret == -EPROBE_DEFER ) { -return ret; - }else { -dev_err (dev,"no usb3 phy configured\n" ); -return ret; - } - } - -return 0 ; }static int dwc3_core_init_mode (struct dwc3 *dwc) { -struct device *dev = dwc->dev;int ret;switch (dwc->dr_mode) {
@@ -870,10 +752,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); - ret =dwc3_core_get_phy (dwc); -if (ret) -return ret; -spin_lock_init (&dwc->lock);platform_set_drvdata (pdev, dwc);
@@ -888,8 +766,7 @@ static int dwc3_probe(struct platform_device *pdev) ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" ); - ret = -ENOMEM ; - goto err0; +return -ENOMEM ; }if (IS_ENABLED (CONFIG_USB_DWC3_HOST ))
@@ -906,49 +783,22 @@ static int dwc3_probe(struct platform_device *pdev) goto err0; } -usb_phy_set_suspend (dwc->usb2_phy,0 ); -usb_phy_set_suspend (dwc->usb3_phy,0 ); - ret =phy_power_on (dwc->usb2_generic_phy); -if (ret <0 ) - goto err1; - - ret =phy_power_on (dwc->usb3_generic_phy); -if (ret <0 ) - goto err_usb2phy_power; - ret =dwc3_event_buffers_setup (dwc);if (ret) {dev_err (dwc->dev,"failed to setup event buffers\n" ); - goto err_usb3phy_power; + goto err1; } ret =dwc3_core_init_mode (dwc);if (ret) goto err2; - ret =dwc3_debugfs_init (dwc); -if (ret) { -dev_err (dev,"failed to initialize debugfs\n" ); - goto err3; - } -return 0 ; -err3: -dwc3_core_exit_mode (dwc); - err2:dwc3_event_buffers_cleanup (dwc); -err_usb3phy_power: -phy_power_off (dwc->usb3_generic_phy); - -err_usb2phy_power: -phy_power_off (dwc->usb2_generic_phy); - err1: -usb_phy_set_suspend (dwc->usb2_phy,1 ); -usb_phy_set_suspend (dwc->usb3_phy,1 );dwc3_core_exit (dwc); err0:
@@ -961,16 +811,10 @@ static int dwc3_remove(struct platform_device *pdev) {struct dwc3 *dwc =platform_get_drvdata (pdev); -dwc3_debugfs_exit (dwc);dwc3_core_exit_mode (dwc);dwc3_event_buffers_cleanup (dwc);dwc3_free_event_buffers (dwc); -usb_phy_set_suspend (dwc->usb2_phy,1 ); -usb_phy_set_suspend (dwc->usb3_phy,1 ); -phy_power_off (dwc->usb2_generic_phy); -phy_power_off (dwc->usb3_generic_phy); -dwc3_core_exit (dwc);return 0 ;
drivers/usb/dwc3/core.h +0 -10
@@ -641,10 +641,6 @@ struct dwc3_scratchpad_array {* @maximum_speed: maximum speed requested (mainly for testing purposes) * @revision: revision register contents * @dr_mode: requested mode of operation -* @usb2_phy: pointer to USB2 PHY -* @usb3_phy: pointer to USB3 PHY -* @usb2_generic_phy: pointer to USB2 PHY -* @usb3_generic_phy: pointer to USB3 PHY * @dcfg: saved contents of DCFG register * @gctl: saved contents of GCTL register * @isoch_delay: wValue from Set Isochronous Delay request;
@@ -726,12 +722,6 @@ struct dwc3 {struct usb_gadget gadget;struct usb_gadget_driver *gadget_driver; -struct usb_phy *usb2_phy; -struct usb_phy *usb3_phy; - -struct phy *usb2_generic_phy; -struct phy *usb3_generic_phy; -void __iomem *regs;size_t regs_size;
drivers/usb/dwc3/linux-compat.h +10 -0
@@ -25,4 +25,14 @@ static inline size_t strlcat(char *dest, const char *src, size_t n) return strlen(dest) + strlen(src); } +static inline void *devm_kzalloc (struct device *dev,unsigned int size, +unsigned int flags) +{ +return kzalloc (size, flags); +} + +static inline void *kmalloc_array (size_t n,size_t size,gfp_t flags) +{ +return kzalloc (n * size, flags); +}#endif
Signature · 1 line
1.7.9.5
PATCH v2 20/40 include: dwc3-uboot: add a structure for populating platform data
In reply to Kishon Vijay Abraham IAdded a structure to populate dwc3 core platform data. The board file should populate these platform data before invoking dwc3 driver.
This will be removed once we have dwc3 driver adapted to use the driver model.
--- include/dwc3-uboot.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/dwc3-uboot.h
include/dwc3-uboot.h new file +40 -0
@@ -0,0 +1,40 @@ +/* include/dwc3-uboot.h +* +* Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com +* +* Designware SuperSpeed USB uboot init +* +* SPDX-License-Identifier: GPL-2.0 +*/ + +#ifndef __DWC3_UBOOT_H_ +#define __DWC3_UBOOT_H_ + +#include <linux/usb/otg.h> + +struct dwc3_device { +int base; +enum usb_dr_mode dr_mode; +u32 maximum_speed; +unsigned tx_fifo_resize:1 ; +unsigned has_lpm_erratum; +u8 lpm_nyet_threshold; +unsigned is_utmi_l1_suspend; +u8 hird_threshold; +unsigned disable_scramble_quirk; +unsigned u2exit_lfps_quirk; +unsigned u2ss_inp3_quirk; +unsigned req_p1p2p3_quirk; +unsigned del_p1p2p3_quirk; +unsigned del_phy_power_chg_quirk; +unsigned lfps_filter_quirk; +unsigned rx_detect_poll_quirk; +unsigned dis_u3_susphy_quirk; +unsigned dis_u2_susphy_quirk; +unsigned tx_de_emphasis_quirk; +unsigned tx_de_emphasis; +}; + +int dwc3_uboot_init (struct dwc3_device *dev); +void dwc3_uboot_exit (void ); +#endif /* __DWC3_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 21/40 dwc3: core: change probe and remove to uboot init and uboot exit code
In reply to Kishon Vijay Abraham IRemoved probe and remove that are specific to linux and replaced it with uboot init and uboot exit. These functions will be invoked from boardfile.
--- drivers/usb/dwc3/core.c | 218 +++++++++++------------------------------------ 1 file changed, 52 insertions(+), 166 deletions(-)
drivers/usb/dwc3/core.c +52 -166
@@ -16,6 +16,7 @@#include <common.h> #include <malloc.h> +#include <dwc3-uboot.h> #include <asm/dma-mapping.h> #include <linux/ioport.h>
@@ -28,6 +29,7 @@#include "linux-compat.h" +struct dwc3 *dwc;/* -------------------------------------------------------------------------- */ void dwc3_set_mode (struct dwc3 *dwc,u32 mode)
@@ -597,20 +599,26 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)#define DWC3_ALIGN_MASK (16 - 1) -static int dwc3_probe (struct platform_device *pdev) +/** +* dwc3_uboot_init - dwc3 core uboot initialization code +* @dwc3_dev: struct dwc3_device containing initialization data +* +* Entry point for dwc3 driver (equivalent to dwc3_probe in linux +* kernel driver). Pointer to dwc3_device should be passed containing +* base address and other initialization data. Returns '0' on success and +* a negative value on failure. +* +* Generally called from board_usb_init() implemented in board file. +*/ +int dwc3_uboot_init (struct dwc3_device *dwc3_dev) { -struct device *dev = &pdev->dev; -struct dwc3_platform_data *pdata =dev_get_platdata (dev); -struct device_node *node = dev->of_node; -struct resource *res; -struct dwc3 *dwc; +struct device *dev;u8 lpm_nyet_threshold;u8 tx_de_emphasis;u8 hird_threshold;int ret; -void __iomem *regs;void *mem; mem =devm_kzalloc (dev,sizeof (*dwc) +DWC3_ALIGN_MASK ,GFP_KERNEL );
@@ -619,48 +627,8 @@ static int dwc3_probe(struct platform_device *pdev) dwc =PTR_ALIGN (mem,DWC3_ALIGN_MASK +1 ); dwc->mem = mem; - dwc->dev = dev; - - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (!res) { -dev_err (dev,"missing IRQ\n" ); -return -ENODEV ; - } - dwc->xhci_resources[1 ].start = res->start; - dwc->xhci_resources[1 ].end = res->end; - dwc->xhci_resources[1 ].flags = res->flags; - dwc->xhci_resources[1 ].name = res->name; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (dev,"missing memory resource\n" ); -return -ENODEV ; - } - dwc->xhci_resources[0 ].start = res->start; - dwc->xhci_resources[0 ].end = dwc->xhci_resources[0 ].start + -DWC3_XHCI_REGS_END ; - dwc->xhci_resources[0 ].flags = res->flags; - dwc->xhci_resources[0 ].name = res->name; - - res->start +=DWC3_GLOBALS_REGS_START ; - -/* -* Request memory region but exclude xHCI regs, -* since it will be requested by the xhci-plat driver. -*/ - regs =devm_ioremap_resource (dev, res); -if (IS_ERR (regs)) -return PTR_ERR (regs); - - dwc->regs = regs; - dwc->regs_size =resource_size (res); -/* -* restore res->start back to its original value so that, -* in case the probe is deferred, we don't end up getting error in -* request the memory region the next time probe is called. -*/ - res->start -=DWC3_GLOBALS_REGS_START ; + dwc->regs = (int *)(dwc3_dev->base +DWC3_GLOBALS_REGS_START );/* default to highest possible threshold */ lpm_nyet_threshold =0xff ;
@@ -674,73 +642,31 @@ static int dwc3_probe(struct platform_device *pdev)*/ hird_threshold =12 ; -if (node) { - dwc->maximum_speed =of_usb_get_maximum_speed (node); - dwc->has_lpm_erratum =of_property_read_bool (node, -"snps,has-lpm-erratum" ); -of_property_read_u8 (node,"snps,lpm-nyet-threshold" , - &lpm_nyet_threshold); - dwc->is_utmi_l1_suspend =of_property_read_bool (node, -"snps,is-utmi-l1-suspend" ); -of_property_read_u8 (node,"snps,hird-threshold" , - &hird_threshold); - - dwc->needs_fifo_resize =of_property_read_bool (node, -"tx-fifo-resize" ); - dwc->dr_mode =of_usb_get_dr_mode (node); - - dwc->disable_scramble_quirk =of_property_read_bool (node, -"snps,disable_scramble_quirk" ); - dwc->u2exit_lfps_quirk =of_property_read_bool (node, -"snps,u2exit_lfps_quirk" ); - dwc->u2ss_inp3_quirk =of_property_read_bool (node, -"snps,u2ss_inp3_quirk" ); - dwc->req_p1p2p3_quirk =of_property_read_bool (node, -"snps,req_p1p2p3_quirk" ); - dwc->del_p1p2p3_quirk =of_property_read_bool (node, -"snps,del_p1p2p3_quirk" ); - dwc->del_phy_power_chg_quirk =of_property_read_bool (node, -"snps,del_phy_power_chg_quirk" ); - dwc->lfps_filter_quirk =of_property_read_bool (node, -"snps,lfps_filter_quirk" ); - dwc->rx_detect_poll_quirk =of_property_read_bool (node, -"snps,rx_detect_poll_quirk" ); - dwc->dis_u3_susphy_quirk =of_property_read_bool (node, -"snps,dis_u3_susphy_quirk" ); - dwc->dis_u2_susphy_quirk =of_property_read_bool (node, -"snps,dis_u2_susphy_quirk" ); - - dwc->tx_de_emphasis_quirk =of_property_read_bool (node, -"snps,tx_de_emphasis_quirk" ); -of_property_read_u8 (node,"snps,tx_de_emphasis" , - &tx_de_emphasis); - }else if (pdata) { - dwc->maximum_speed = pdata->maximum_speed; - dwc->has_lpm_erratum = pdata->has_lpm_erratum; -if (pdata->lpm_nyet_threshold) - lpm_nyet_threshold = pdata->lpm_nyet_threshold; - dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend; -if (pdata->hird_threshold) - hird_threshold = pdata->hird_threshold; - - dwc->needs_fifo_resize = pdata->tx_fifo_resize; - dwc->dr_mode = pdata->dr_mode; - - dwc->disable_scramble_quirk = pdata->disable_scramble_quirk; - dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk; - dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk; - dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk; - dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk; - dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk; - dwc->lfps_filter_quirk = pdata->lfps_filter_quirk; - dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk; - dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk; - dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk; - - dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk; -if (pdata->tx_de_emphasis) - tx_de_emphasis = pdata->tx_de_emphasis; - } + dwc->maximum_speed = dwc3_dev->maximum_speed; + dwc->has_lpm_erratum = dwc3_dev->has_lpm_erratum; +if (dwc3_dev->lpm_nyet_threshold) + lpm_nyet_threshold = dwc3_dev->lpm_nyet_threshold; + dwc->is_utmi_l1_suspend = dwc3_dev->is_utmi_l1_suspend; +if (dwc3_dev->hird_threshold) + hird_threshold = dwc3_dev->hird_threshold; + + dwc->needs_fifo_resize = dwc3_dev->tx_fifo_resize; + dwc->dr_mode = dwc3_dev->dr_mode; + + dwc->disable_scramble_quirk = dwc3_dev->disable_scramble_quirk; + dwc->u2exit_lfps_quirk = dwc3_dev->u2exit_lfps_quirk; + dwc->u2ss_inp3_quirk = dwc3_dev->u2ss_inp3_quirk; + dwc->req_p1p2p3_quirk = dwc3_dev->req_p1p2p3_quirk; + dwc->del_p1p2p3_quirk = dwc3_dev->del_p1p2p3_quirk; + dwc->del_phy_power_chg_quirk = dwc3_dev->del_phy_power_chg_quirk; + dwc->lfps_filter_quirk = dwc3_dev->lfps_filter_quirk; + dwc->rx_detect_poll_quirk = dwc3_dev->rx_detect_poll_quirk; + dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk; + dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk; + + dwc->tx_de_emphasis_quirk = dwc3_dev->tx_de_emphasis_quirk; +if (dwc3_dev->tx_de_emphasis) + tx_de_emphasis = dwc3_dev->tx_de_emphasis;/* default to superspeed if no maximum_speed passed */ if (dwc->maximum_speed ==USB_SPEED_UNKNOWN )
@@ -752,15 +678,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); -spin_lock_init (&dwc->lock); -platform_set_drvdata (pdev, dwc); - -if (!dev->dma_mask) { - dev->dma_mask = dev->parent->dma_mask; - dev->dma_parms = dev->parent->dma_parms; -dma_set_coherent_mask (dev, dev->parent->coherent_dma_mask); - } -dwc3_cache_hwparams (dwc); ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );
@@ -807,55 +724,24 @@ err0:return ret; } -static int dwc3_remove (struct platform_device *pdev) +/** +* dwc3_uboot_exit - dwc3 core uboot cleanup code +* @index: index of this controller +* +* Performs cleanup of memory allocated in dwc3_uboot_init and other misc +* cleanups (equivalent to dwc3_remove in linux). +* +* Generally called from board file. +*/ +void dwc3_uboot_exit () { -struct dwc3 *dwc =platform_get_drvdata (pdev); -dwc3_core_exit_mode (dwc);dwc3_event_buffers_cleanup (dwc);dwc3_free_event_buffers (dwc); -dwc3_core_exit (dwc); - -return 0 ; +kfree (dwc->mem); } -#ifdef CONFIG_OF -static const struct of_device_id of_dwc3_match[] = { - { - .compatible ="snps,dwc3" - }, - { - .compatible ="synopsys,dwc3" - }, - { }, -}; -MODULE_DEVICE_TABLE (of, of_dwc3_match); -#endif - -#ifdef CONFIG_ACPI - -#define ACPI_ID_INTEL_BSW "808622B7" - -static const struct acpi_device_id dwc3_acpi_match[] = { - {ACPI_ID_INTEL_BSW ,0 }, - { }, -}; -MODULE_DEVICE_TABLE (acpi, dwc3_acpi_match); -#endif - -static struct platform_driver dwc3_driver = { - .probe = dwc3_probe, - .remove = dwc3_remove, - .driver = { - .name ="dwc3" , - .of_match_table =of_match_ptr (of_dwc3_match), - .acpi_match_table =ACPI_PTR (dwc3_acpi_match), - }, -}; - -module_platform_driver (dwc3_driver); -MODULE_ALIAS ("platform:dwc3" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
1.7.9.5
PATCH v2 22/40 dwc3: core: add support for multiple dwc3 controllers
In reply to Kishon Vijay Abraham IAdded support for multiple dwc3 controllers. This gives uboot the capability to control multiple dwc3 controllers.
--- drivers/usb/dwc3/core.c | 32 ++++++++++++++++++++++++-------- drivers/usb/dwc3/core.h | 4 ++++ include/dwc3-uboot.h | 3 ++- 3 files changed, 30 insertions(+), 9 deletions(-)
drivers/usb/dwc3/core.c +24 -8
@@ -29,7 +29,7 @@#include "linux-compat.h" -struct dwc3 *dwc; +static LIST_HEAD (dwc3_list);/* -------------------------------------------------------------------------- */ void dwc3_set_mode (struct dwc3 *dwc,u32 mode)
@@ -612,6 +612,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)*/ int dwc3_uboot_init (struct dwc3_device *dwc3_dev) { +struct dwc3 *dwc;struct device *dev;u8 lpm_nyet_threshold;u8 tx_de_emphasis;
@@ -678,6 +679,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); + dwc->index = dwc3_dev->index; +dwc3_cache_hwparams (dwc); ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );
@@ -710,6 +713,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)if (ret) goto err2; +list_add_tail (&dwc->list, &dwc3_list); +return 0 ; err2:
@@ -729,17 +734,28 @@ err0:* @index: index of this controller * * Performs cleanup of memory allocated in dwc3_uboot_init and other misc -* cleanups (equivalent to dwc3_remove in linux). +* cleanups (equivalent to dwc3_remove in linux). index of _this_ controller +* should be passed and should match with the index passed in +* dwc3_device during init. * * Generally called from board file. */ -void dwc3_uboot_exit () +void dwc3_uboot_exit (int index) { -dwc3_core_exit_mode (dwc); -dwc3_event_buffers_cleanup (dwc); -dwc3_free_event_buffers (dwc); -dwc3_core_exit (dwc); -kfree (dwc->mem); +struct dwc3 *dwc; + +list_for_each_entry (dwc, &dwc3_list, list) { +if (dwc->index != index) +continue ; + +dwc3_core_exit_mode (dwc); +dwc3_event_buffers_cleanup (dwc); +dwc3_free_event_buffers (dwc); +dwc3_core_exit (dwc); +list_del (&dwc->list); +kfree (dwc->mem); +break ; + } }MODULE_ALIAS ("platform:dwc3" );
drivers/usb/dwc3/core.h +4 -0
@@ -695,6 +695,8 @@ struct dwc3_scratchpad_array {* 1 - -3.5dB de-emphasis * 2 - No de-emphasis * 3 - Reserved +* @index: index of _this_ controller +* @list: to maintain the list of dwc3 controllers */ struct dwc3 {struct usb_ctrlrequest *ctrl_req;
@@ -811,6 +813,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; +int index; +struct list_head list; };/* -------------------------------------------------------------------------- */
include/dwc3-uboot.h +2 -1
@@ -33,8 +33,9 @@ struct dwc3_device {unsigned dis_u2_susphy_quirk;unsigned tx_de_emphasis_quirk;unsigned tx_de_emphasis; + int index; };int dwc3_uboot_init (struct dwc3_device *dev); -void dwc3_uboot_exit (void ); +void dwc3_uboot_exit (int index);#endif /* __DWC3_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 23/40 dwc3: core: added an API to invoke irq handlers
In reply to Kishon Vijay Abraham ISince interrupt support is not present in u-boot, added an API to handle the interrupts in dwc3 core. This API can be polled to handle the interrupts.
--- drivers/usb/dwc3/core.c | 21 +++++++++++++++++++++ include/dwc3-uboot.h | 1 + 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +21 -0
@@ -758,6 +758,27 @@ void dwc3_uboot_exit(int index) } } +/** +* dwc3_uboot_handle_interrupt - handle dwc3 core interrupt +* @index: index of this controller +* +* Invokes dwc3 gadget interrupts. +* +* Generally called from board file. +*/ +void dwc3_uboot_handle_interrupt (int index) +{ +struct dwc3 *dwc =NULL ; + +list_for_each_entry (dwc, &dwc3_list, list) { +if (dwc->index != index) +continue ; + +dwc3_gadget_uboot_handle_interrupt (dwc); +break ; + } +} +MODULE_ALIAS ("platform:dwc3" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
include/dwc3-uboot.h +1 -0
@@ -38,4 +38,5 @@ struct dwc3_device {int dwc3_uboot_init (struct dwc3_device *dev);void dwc3_uboot_exit (int index); +void dwc3_uboot_handle_interrupt (int index);#endif /* __DWC3_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 24/40 usb: dwc3: dwc3-omap: make dwc3-omap build in uboot
In reply to Kishon Vijay Abraham I*) Changed the included header files to that used in u-boot. *) Removed extcon_* APIs
*) Removed regulator_* APIs
*) Fixed other misc warnings
*) Added dwc3-omap.h to include the definitions of UTMI modes.
--- drivers/usb/dwc3/dwc3-omap.c | 144 +++-------------------------------------- include/linux/usb/dwc3-omap.h | 19 ++++++ 2 files changed, 27 insertions(+), 136 deletions(-) create mode 100644 include/linux/usb/dwc3-omap.h
drivers/usb/dwc3/dwc3-omap.c +8 -136
@@ -14,21 +14,16 @@* SPDX-License-Identifier: GPL-2.0 */ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/platform_data/dwc3-omap.h> -#include <linux/dma-mapping.h> +#include <common.h> +#include <malloc.h> +#include <asm/io.h> +#include <linux/usb/dwc3-omap.h> #include <linux/ioport.h> -#include <linux/io.h> -#include <linux/of.h> -#include <linux/of_platform.h> -#include <linux/extcon.h> -#include <linux/regulator/consumer.h> #include <linux/usb/otg.h> +#include <linux/compat.h> + +#include "linux-compat.h" /* * All these registers belong to OMAP's Wrapper around the
@@ -113,7 +108,6 @@struct dwc3_omap {struct device *dev; -int irq;void __iomem *base;u32 utmi_otg_status;
@@ -124,13 +118,6 @@ struct dwc3_omap {u32 irq0_offset; u32 dma_status:1; - -struct extcon_specific_cable_nb extcon_vbus_dev; -struct extcon_specific_cable_nb extcon_id_dev; -struct notifier_block vbus_nb; -struct notifier_block id_nb; - -struct regulator *vbus_reg; };enum omap_dwc3_vbus_id_status {
@@ -205,21 +192,12 @@ static void dwc3_omap_write_irq0_set(struct dwc3_omap *omap, u32 value)static void dwc3_omap_set_mailbox (struct dwc3_omap *omap,enum omap_dwc3_vbus_id_status status) { -int ret;u32 val;switch (status) {case OMAP_DWC3_ID_GROUND :dev_dbg (omap->dev,"ID GND\n" ); -if (omap->vbus_reg) { - ret =regulator_enable (omap->vbus_reg); -if (ret) { -dev_dbg (omap->dev,"regulator enable failed\n" ); -return ; - } - } - val =dwc3_omap_read_utmi_status (omap); val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
@@ -242,9 +220,6 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,break ;case OMAP_DWC3_ID_FLOAT : -if (omap->vbus_reg) -regulator_disable (omap->vbus_reg); -case OMAP_DWC3_VBUS_OFF :dev_dbg (omap->dev,"VBUS Disconnect\n" );
@@ -349,32 +324,6 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)static u64 dwc3_omap_dma_mask =DMA_BIT_MASK (32 ); -static int dwc3_omap_id_notifier (struct notifier_block *nb, -unsigned long event,void *ptr) -{ - struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb); - -if (event) -dwc3_omap_set_mailbox (omap,OMAP_DWC3_ID_GROUND ); -else -dwc3_omap_set_mailbox (omap,OMAP_DWC3_ID_FLOAT ); - -return NOTIFY_DONE ; -} - -static int dwc3_omap_vbus_notifier (struct notifier_block *nb, -unsigned long event,void *ptr) -{ - struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb); - -if (event) -dwc3_omap_set_mailbox (omap,OMAP_DWC3_VBUS_VALID ); -else -dwc3_omap_set_mailbox (omap,OMAP_DWC3_VBUS_OFF ); - -return NOTIFY_DONE ; -} -static void dwc3_omap_map_offset (struct dwc3_omap *omap) {struct device_node *node = omap->dev->of_node;
@@ -420,42 +369,6 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)dwc3_omap_write_utmi_status (omap, reg); } -static int dwc3_omap_extcon_register (struct dwc3_omap *omap) -{ -int ret; -struct device_node *node = omap->dev->of_node; -struct extcon_dev *edev; - -if (of_property_read_bool (node,"extcon" )) { - edev =extcon_get_edev_by_phandle (omap->dev,0 ); -if (IS_ERR (edev)) { -dev_vdbg (omap->dev,"couldn't get extcon device\n" ); -return -EPROBE_DEFER ; - } - - omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier; - ret =extcon_register_interest (&omap->extcon_vbus_dev, - edev->name,"USB" , - &omap->vbus_nb); -if (ret <0 ) -dev_vdbg (omap->dev,"failed to register notifier for USB\n" ); - - omap->id_nb.notifier_call = dwc3_omap_id_notifier; - ret =extcon_register_interest (&omap->extcon_id_dev, - edev->name,"USB-HOST" , - &omap->id_nb); -if (ret <0 ) -dev_vdbg (omap->dev,"failed to register notifier for USB-HOST\n" ); - -if (extcon_get_cable_state (edev,"USB" ) == true) -dwc3_omap_set_mailbox (omap,OMAP_DWC3_VBUS_VALID ); -if (extcon_get_cable_state (edev,"USB-HOST" ) == true) -dwc3_omap_set_mailbox (omap,OMAP_DWC3_ID_GROUND ); - } - -return 0 ; -} -static int dwc3_omap_probe (struct platform_device *pdev) {struct device_node *node = pdev->dev.of_node;
@@ -463,11 +376,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)struct dwc3_omap *omap;struct resource *res;struct device *dev = &pdev->dev; -struct regulator *vbus_reg =NULL ;int ret; -int irq; -u32 reg;void __iomem *base;
@@ -483,29 +393,13 @@ static int dwc3_omap_probe(struct platform_device *pdev)platform_set_drvdata (pdev, omap); - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -dev_err (dev,"missing IRQ resource\n" ); -return -EINVAL ; - } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); base =devm_ioremap_resource (dev, res);if (IS_ERR (base))return PTR_ERR (base); -if (of_property_read_bool (node,"vbus-supply" )) { - vbus_reg =devm_regulator_get (dev,"vbus" ); -if (IS_ERR (vbus_reg)) { -dev_err (dev,"vbus init failed\n" ); -return PTR_ERR (vbus_reg); - } - } - omap->dev = dev; - omap->irq = irq; omap->base = base; - omap->vbus_reg = vbus_reg; dev->dma_mask = &dwc3_omap_dma_mask;dwc3_omap_map_offset (omap);
@@ -515,34 +409,16 @@ static int dwc3_omap_probe(struct platform_device *pdev) reg =dwc3_omap_readl (omap->base,USBOTGSS_SYSCONFIG ); omap->dma_status = !!(reg &USBOTGSS_SYSCONFIG_DMADISABLE ); - ret =devm_request_irq (dev, omap->irq, dwc3_omap_interrupt,0 , -"dwc3-omap" , omap); -if (ret) { -dev_err (dev,"failed to request IRQ #%d --> %d\n" , - omap->irq, ret); - goto err0; - } -dwc3_omap_enable_irqs (omap); - ret =dwc3_omap_extcon_register (omap); -if (ret <0 ) - goto err1; - ret =of_platform_populate (node,NULL ,NULL , dev);if (ret) {dev_err (&pdev->dev,"failed to create dwc3 core\n" ); - goto err2; + goto err1; }return 0 ; -err2: -if (omap->extcon_vbus_dev.edev) -extcon_unregister_interest (&omap->extcon_vbus_dev); -if (omap->extcon_id_dev.edev) -extcon_unregister_interest (&omap->extcon_id_dev); - err1:dwc3_omap_disable_irqs (omap);
@@ -554,10 +430,6 @@ static int dwc3_omap_remove(struct platform_device *pdev) {struct dwc3_omap *omap =platform_get_drvdata (pdev); -if (omap->extcon_vbus_dev.edev) -extcon_unregister_interest (&omap->extcon_vbus_dev); -if (omap->extcon_id_dev.edev) -extcon_unregister_interest (&omap->extcon_id_dev);dwc3_omap_disable_irqs (omap);device_for_each_child (&pdev->dev,NULL , dwc3_omap_remove_core);
include/linux/usb/dwc3-omap.h new file +19 -0
@@ -0,0 +1,19 @@ +/* include/linux/usb/dwc3-omap.h +* +* Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com +* +* Designware SuperSpeed Glue +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __DWC3_OMAP_H_ +#define __DWC3_OMAP_H_ + +enum dwc3_omap_utmi_mode { +DWC3_OMAP_UTMI_MODE_UNKNOWN =0 , +DWC3_OMAP_UTMI_MODE_HW , +DWC3_OMAP_UTMI_MODE_SW , +}; + +#endif /* __DWC3_OMAP_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 25/40 include: dwc3-omap-uboot: add a structure for populating dwc3-omap platform data
In reply to Kishon Vijay Abraham IAdded a structure to populate dwc3 omap platform data. The board file should populate these platform data before invoking dwc3 omap driver.
This will be removed once dwc3-omap driver is adapted to use the driver model.
--- drivers/usb/dwc3/dwc3-omap.c | 7 ------- include/dwc3-omap-uboot.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 include/dwc3-omap-uboot.h
drivers/usb/dwc3/dwc3-omap.c +0 -7
@@ -120,13 +120,6 @@ struct dwc3_omap { u32 dma_status:1; }; -enum omap_dwc3_vbus_id_status { -OMAP_DWC3_ID_FLOAT , -OMAP_DWC3_ID_GROUND , -OMAP_DWC3_VBUS_OFF , -OMAP_DWC3_VBUS_VALID , -}; -static inline u32 dwc3_omap_readl (void __iomem *base,u32 offset) {return readl (base + offset);
include/dwc3-omap-uboot.h new file +27 -0
@@ -0,0 +1,27 @@ +/* include/dwc3_omap_uboot.h +* +* Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com +* +* Designware SuperSpeed OMAP Glue uboot init +* +* SPDX-License-Identifier: GPL-2.0 +*/ + +#ifndef __DWC3_OMAP_UBOOT_H_ +#define __DWC3_OMAP_UBOOT_H_ + +#include <linux/usb/dwc3-omap.h> + +enum omap_dwc3_vbus_id_status { +OMAP_DWC3_ID_FLOAT , +OMAP_DWC3_ID_GROUND , +OMAP_DWC3_VBUS_OFF , +OMAP_DWC3_VBUS_VALID , +}; + +struct dwc3_omap_device { +void *base; +enum dwc3_omap_utmi_mode utmi_mode; +enum omap_dwc3_vbus_id_status vbus_id_status; +}; +#endif /* __DWC3_OMAP_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 26/40 usb: dwc3: dwc3-omap: change probe and remove to uboot init and uboot exit code
In reply to Kishon Vijay Abraham IRemoved probe and remove that are specific to linux and replaced it with uboot init and uboot exit. These functions will be invoked from boardfile.
This will change once we have dwc3-omap driver adapted to use the uboot driver model.
--- drivers/usb/dwc3/dwc3-omap.c | 128 +++++++++++++----------------------------- include/dwc3-omap-uboot.h | 3 + 2 files changed, 42 insertions(+), 89 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +39 -89
@@ -17,6 +17,7 @@#include <common.h> #include <malloc.h> #include <asm/io.h> +#include <dwc3-omap-uboot.h> #include <linux/usb/dwc3-omap.h> #include <linux/ioport.h>
@@ -120,6 +121,8 @@ struct dwc3_omap { u32 dma_status:1; }; +struct dwc3_omap *omap; +static inline u32 dwc3_omap_readl (void __iomem *base,u32 offset) {return readl (base + offset);
@@ -278,15 +281,6 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)return IRQ_HANDLED ; } -static int dwc3_omap_remove_core (struct device *dev,void *c) -{ -struct platform_device *pdev =to_platform_device (dev); - -of_device_unregister (pdev); - -return 0 ; -} -static void dwc3_omap_enable_irqs (struct dwc3_omap *omap) {u32 reg;
@@ -315,12 +309,8 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)dwc3_omap_write_irq0_set (omap,0x00 ); } -static u64 dwc3_omap_dma_mask =DMA_BIT_MASK (32 ); -static void dwc3_omap_map_offset (struct dwc3_omap *omap) { -struct device_node *node = omap->dev->of_node; -/* * Differentiate between OMAP5 and AM437x. *
@@ -329,25 +319,21 @@ static void dwc3_omap_map_offset(struct dwc3_omap *omap)* * Using dt compatible to differentiate AM437x. */ -if (of_device_is_compatible (node,"ti,am437x-dwc3" )) { - omap->irq_eoi_offset =USBOTGSS_EOI_OFFSET ; - omap->irq0_offset =USBOTGSS_IRQ0_OFFSET ; - omap->irqmisc_offset =USBOTGSS_IRQMISC_OFFSET ; - omap->utmi_otg_offset =USBOTGSS_UTMI_OTG_OFFSET ; - omap->debug_offset =USBOTGSS_DEBUG_OFFSET ; - } +#ifdef CONFIG_AM43XX + omap->irq_eoi_offset =USBOTGSS_EOI_OFFSET ; + omap->irq0_offset =USBOTGSS_IRQ0_OFFSET ; + omap->irqmisc_offset =USBOTGSS_IRQMISC_OFFSET ; + omap->utmi_otg_offset =USBOTGSS_UTMI_OTG_OFFSET ; + omap->debug_offset =USBOTGSS_DEBUG_OFFSET ; +#endif } -static void dwc3_omap_set_utmi_mode (struct dwc3_omap *omap) +static void dwc3_omap_set_utmi_mode (struct dwc3_omap *omap,int utmi_mode) {u32 reg; -struct device_node *node = omap->dev->of_node; -int utmi_mode =0 ; reg =dwc3_omap_read_utmi_status (omap); -of_property_read_u32 (node,"utmi-mode" , &utmi_mode); -switch (utmi_mode) {case DWC3_OMAP_UTMI_MODE_SW : reg |=USBOTGSS_UTMI_OTG_STATUS_SW_MODE ;
@@ -362,95 +348,59 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)dwc3_omap_write_utmi_status (omap, reg); } -static int dwc3_omap_probe (struct platform_device *pdev) +/** +* dwc3_omap_uboot_init - dwc3 omap uboot initialization code +* @dev: struct dwc3_omap_device containing initialization data +* +* Entry point for dwc3 omap driver (equivalent to dwc3_omap_probe in linux +* kernel driver). Pointer to dwc3_omap_device should be passed containing +* base address and other initialization data. Returns '0' on success and +* a negative value on failure. +* +* Generally called from board_usb_init() implemented in board file. +*/ +int dwc3_omap_uboot_init (struct dwc3_omap_device *omap_dev) { -struct device_node *node = pdev->dev.of_node; - -struct dwc3_omap *omap; -struct resource *res; -struct device *dev = &pdev->dev; - -int ret;u32 reg; - -void __iomem *base; - -if (!node) { -dev_err (dev,"device node not found\n" ); -return -EINVAL ; - } +struct device *dev; omap =devm_kzalloc (dev,sizeof (*omap),GFP_KERNEL );if (!omap)return -ENOMEM ; -platform_set_drvdata (pdev, omap); - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - base =devm_ioremap_resource (dev, res); -if (IS_ERR (base)) -return PTR_ERR (base); - - omap->dev = dev; - omap->base = base; - dev->dma_mask = &dwc3_omap_dma_mask; + omap->base = omap_dev->base;dwc3_omap_map_offset (omap); -dwc3_omap_set_utmi_mode (omap); +dwc3_omap_set_utmi_mode (omap, omap_dev->utmi_mode);/* check the DMA Status */ reg =dwc3_omap_readl (omap->base,USBOTGSS_SYSCONFIG ); omap->dma_status = !!(reg &USBOTGSS_SYSCONFIG_DMADISABLE ); -dwc3_omap_enable_irqs (omap); +dwc3_omap_set_mailbox (omap, omap_dev->vbus_id_status); - ret =of_platform_populate (node,NULL ,NULL , dev); -if (ret) { -dev_err (&pdev->dev,"failed to create dwc3 core\n" ); - goto err1; - } +dwc3_omap_enable_irqs (omap);return 0 ; - -err1: -dwc3_omap_disable_irqs (omap); - -err0: -return ret; } -static int dwc3_omap_remove (struct platform_device *pdev) +/** +* dwc3_omap_uboot_exit - dwc3 omap uboot cleanup code +* @index: index of this controller +* +* Performs cleanup of memory allocated in dwc3_omap_uboot_init +* (equivalent to dwc3_omap_remove in linux). +* +* Generally called from board file. +*/ +void dwc3_omap_uboot_exit (void ) { -struct dwc3_omap *omap =platform_get_drvdata (pdev); -dwc3_omap_disable_irqs (omap); -device_for_each_child (&pdev->dev,NULL , dwc3_omap_remove_core); +kfree (omap);return 0 ; } -static const struct of_device_id of_dwc3_match[] = { - { - .compatible ="ti,dwc3" - }, - { - .compatible ="ti,am437x-dwc3" - }, - { }, -}; -MODULE_DEVICE_TABLE (of, of_dwc3_match); - -static struct platform_driver dwc3_omap_driver = { - .probe = dwc3_omap_probe, - .remove = dwc3_omap_remove, - .driver = { - .name ="omap-dwc3" , - .of_match_table = of_dwc3_match, - }, -}; - -module_platform_driver (dwc3_omap_driver); -MODULE_ALIAS ("platform:omap-dwc3" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
include/dwc3-omap-uboot.h +3 -0
@@ -24,4 +24,7 @@ struct dwc3_omap_device {enum dwc3_omap_utmi_mode utmi_mode; enum omap_dwc3_vbus_id_status vbus_id_status; }; + +int dwc3_omap_uboot_init (struct dwc3_omap_device *dev); +void dwc3_omap_uboot_exit (void );#endif /* __DWC3_OMAP_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 27/40 dwc3: dwc3-omap: add support for multiple dwc3-omap controllers
In reply to Kishon Vijay Abraham IAdded support for multiple dwc3 omap controllers. This gives uboot the capability to control multiple dwc3 omap controllers.
--- drivers/usb/dwc3/dwc3-omap.c | 26 ++++++++++++++++++++------ include/dwc3-omap-uboot.h | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +20 -6
@@ -119,9 +119,11 @@ struct dwc3_omap {u32 irq0_offset; u32 dma_status:1; +struct list_head list; +u32 index; }; -struct dwc3_omap *omap; +static LIST_HEAD (dwc3_omap_list);static inline u32 dwc3_omap_readl (void __iomem *base,u32 offset) {
@@ -363,12 +365,14 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev) {u32 reg;struct device *dev; +struct dwc3_omap *omap; omap =devm_kzalloc (dev,sizeof (*omap),GFP_KERNEL );if (!omap)return -ENOMEM ; omap->base = omap_dev->base; + omap->index = omap_dev->index;dwc3_omap_map_offset (omap);dwc3_omap_set_utmi_mode (omap, omap_dev->utmi_mode);
@@ -380,6 +384,7 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev)dwc3_omap_set_mailbox (omap, omap_dev->vbus_id_status);dwc3_omap_enable_irqs (omap); +list_add_tail (&omap->list, &dwc3_omap_list);return 0 ; }
@@ -389,16 +394,25 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev)* @index: index of this controller * * Performs cleanup of memory allocated in dwc3_omap_uboot_init -* (equivalent to dwc3_omap_remove in linux). +* (equivalent to dwc3_omap_remove in linux). index of _this_ controller +* should be passed and should match with the index passed in +* dwc3_omap_device during init. * * Generally called from board file. */ -void dwc3_omap_uboot_exit (void ) +void dwc3_omap_uboot_exit (int index) { -dwc3_omap_disable_irqs (omap); -kfree (omap); +struct dwc3_omap *omap =NULL ; -return 0 ; +list_for_each_entry (omap, &dwc3_omap_list, list) { +if (omap->index != index) +continue ; + +dwc3_omap_disable_irqs (omap); +list_del (&omap->list); +kfree (omap); +break ; + } }MODULE_ALIAS ("platform:omap-dwc3" );
include/dwc3-omap-uboot.h +2 -1
@@ -21,10 +21,11 @@ enum omap_dwc3_vbus_id_status {struct dwc3_omap_device {void *base; +int index;enum dwc3_omap_utmi_mode utmi_mode;enum omap_dwc3_vbus_id_status vbus_id_status; };int dwc3_omap_uboot_init (struct dwc3_omap_device *dev); -void dwc3_omap_uboot_exit (void ); +void dwc3_omap_uboot_exit (int index);#endif /* __DWC3_OMAP_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 28/40 usb: dwc3: dwc3-omap: add interrupt status API to check for interrupts
In reply to Kishon Vijay Abraham IAdded an API to check for interrupt status. This API is generally called from board file to check for interrupt status.
--- drivers/usb/dwc3/dwc3-omap.c | 20 ++++++++++++++++++++ include/dwc3-omap-uboot.h | 1 + 2 files changed, 21 insertions(+)
drivers/usb/dwc3/dwc3-omap.c +20 -0
@@ -415,6 +415,26 @@ void dwc3_omap_uboot_exit(int index) } } +/** +* dwc3_omap_uboot_interrupt_status - check the status of interrupt +* @index: index of this controller +* +* Checks the status of interrupts and returns true if an interrupt +* is detected or false otherwise. +* +* Generally called from board file. +*/ +int dwc3_omap_uboot_interrupt_status (int index) +{ +struct dwc3_omap *omap =NULL ; + +list_for_each_entry (omap, &dwc3_omap_list, list) +if (omap->index == index) +return dwc3_omap_interrupt (-1 , omap); + +return 0 ; +} +MODULE_ALIAS ("platform:omap-dwc3" );MODULE_AUTHOR ("Felipe Balbi <[email protected]>" );MODULE_LICENSE ("GPL v2" );
include/dwc3-omap-uboot.h +1 -0
@@ -28,4 +28,5 @@ struct dwc3_omap_device {int dwc3_omap_uboot_init (struct dwc3_omap_device *dev);void dwc3_omap_uboot_exit (int index); +int dwc3_omap_uboot_interrupt_status (int index);#endif /* __DWC3_OMAP_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 29/40 usb: dwc3: TI PHY: PHY driver for dwc3 in TI platforms
In reply to Kishon Vijay Abraham IAdded a single driver for both USB2 PHY programming and USB3 PHY programming.
USB3 PHY is taken from drivers/phy/phy-ti-pipe3.c in linux kernel. commit 56042e : phy: ti-pipe3: Fix suspend/resume and module reload.
USB2 PHY is taken from drivers/phy/phy-omap-usb2.c in linux kernel. commit eb82a3 : phy: omap-usb2: Balance pm_runtime_enable() on probe failure and remove.
--- drivers/usb/dwc3/ti_usb_phy.c | 309 +++++++++++++++++++++++++++++++++++++++++ include/ti-usb-phy-uboot.h | 22 +++ 2 files changed, 331 insertions(+) create mode 100644 drivers/usb/dwc3/ti_usb_phy.c create mode 100644 include/ti-usb-phy-uboot.h
drivers/usb/dwc3/ti_usb_phy.c new file +309 -0
@@ -0,0 +1,309 @@ +/** +* ti_usb_phy.c - USB3 and USB3 PHY programming for dwc3 +* +* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com +* +* Author: Kishon Vijay Abraham I <[email protected]> +* +* Taken from Linux Kernel v3.16 (drivers/phy/phy-ti-pipe3.c and +* drivers/phy/phy-omap-usb2.c) and ported to uboot. +* +* "commit 56042e : phy: ti-pipe3: Fix suspend/resume and module reload" for +* phy-ti-pipe3.c +* +* "commit eb82a3 : phy: omap-usb2: Balance pm_runtime_enable() on probe failure +* and remove" for phy-omap-usb2.c +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <malloc.h> +#include <ti-usb-phy-uboot.h> +#include <usb/lin_gadget_compat.h> +#include <linux/ioport.h> +#include <asm/io.h> +#include <asm/arch/sys_proto.h> + +#include "linux-compat.h" + +#define PLL_STATUS 0x00000004 +#define PLL_GO 0x00000008 +#define PLL_CONFIGURATION1 0x0000000C +#define PLL_CONFIGURATION2 0x00000010 +#define PLL_CONFIGURATION3 0x00000014 +#define PLL_CONFIGURATION4 0x00000020 + +#define PLL_REGM_MASK 0x001FFE00 +#define PLL_REGM_SHIFT 0x9 +#define PLL_REGM_F_MASK 0x0003FFFF +#define PLL_REGM_F_SHIFT 0x0 +#define PLL_REGN_MASK 0x000001FE +#define PLL_REGN_SHIFT 0x1 +#define PLL_SELFREQDCO_MASK 0x0000000E +#define PLL_SELFREQDCO_SHIFT 0x1 +#define PLL_SD_MASK 0x0003FC00 +#define PLL_SD_SHIFT 10 +#define SET_PLL_GO 0x1 +#define PLL_LDOPWDN BIT(15) +#define PLL_TICOPWDN BIT(16) +#define PLL_LOCK 0x2 +#define PLL_IDLE 0x1 + +#define OMAP_CTRL_DEV_PHY_PD BIT(0) +#define OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_MASK 0x003FC000 +#define OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_SHIFT 0xE + +#define OMAP_CTRL_USB3_PHY_PWRCTL_CLK_FREQ_MASK 0xFFC00000 +#define OMAP_CTRL_USB3_PHY_PWRCTL_CLK_FREQ_SHIFT 0x16 + +#define OMAP_CTRL_USB3_PHY_TX_RX_POWERON 0x3 +#define OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF 0x0 + +#define OMAP_CTRL_USB2_PHY_PD BIT(28) + +#define AM437X_CTRL_USB2_PHY_PD BIT(0) +#define AM437X_CTRL_USB2_OTG_PD BIT(1) +#define AM437X_CTRL_USB2_OTGVDET_EN BIT(19) +#define AM437X_CTRL_USB2_OTGSESSEND_EN BIT(20) + +static LIST_HEAD (ti_usb_phy_list); +typedef unsigned int u32 ; + +struct usb3_dpll_params { +u16 m; +u8 n; +u8 freq:3 ; +u8 sd; +u32 mf; +}; + +struct usb3_dpll_map { +unsigned long rate; +struct usb3_dpll_params params; +struct usb3_dpll_map *dpll_map; +}; + +struct ti_usb_phy { +void __iomem *pll_ctrl_base; +void __iomem *usb2_phy_power; +void __iomem *usb3_phy_power; +struct usb3_dpll_map *dpll_map; +struct list_head list; +int index; +}; + +static struct usb3_dpll_map dpll_map_usb[] = { + {12000000 , {1250 ,5 ,4 ,20 ,0 } },/* 12 MHz */ + {16800000 , {3125 ,20 ,4 ,20 ,0 } },/* 16.8 MHz */ + {19200000 , {1172 ,8 ,4 ,20 ,65537 } },/* 19.2 MHz */ + {20000000 , {1000 ,7 ,4 ,10 ,0 } },/* 20 MHz */ + {26000000 , {1250 ,12 ,4 ,20 ,0 } },/* 26 MHz */ + {38400000 , {3125 ,47 ,4 ,20 ,92843 } },/* 38.4 MHz */ + { },/* Terminator */ +}; + +static inline unsigned int ti_usb3_readl (void __iomem *base,u32 offset) +{ +return readl (base + offset); +} + +static inline void ti_usb3_writel (void __iomem *base,u32 offset,u32 value) +{ +writel (value, base + offset); +} + +#ifndef CONFIG_AM43XX +static struct usb3_dpll_params *ti_usb3_get_dpll_params (struct ti_usb_phy *phy) +{ +unsigned long rate; +struct usb3_dpll_map *dpll_map = phy->dpll_map; + + rate =get_sys_clk_freq (); + +for (; dpll_map->rate; dpll_map++) { +if (rate == dpll_map->rate) +return &dpll_map->params; + } + +dev_err (phy->dev,"No DPLL configuration for %lu Hz SYS CLK\n" , rate); + +return NULL ; +} + +static int ti_usb3_dpll_wait_lock (struct ti_usb_phy *phy) +{ +u32 val; +do { + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_STATUS ); +if (val &PLL_LOCK ) +break ; + }while (1 ); + +return 0 ; +} + +static int ti_usb3_dpll_program (struct ti_usb_phy *phy) +{ +u32 val; +struct usb3_dpll_params *dpll_params; + +if (!phy->pll_ctrl_base) +return -EINVAL ; + + dpll_params =ti_usb3_get_dpll_params (phy); +if (!dpll_params) +return -EINVAL ; + + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_CONFIGURATION1 ); + val &= ~PLL_REGN_MASK ; + val |= dpll_params->n <<PLL_REGN_SHIFT ; +ti_usb3_writel (phy->pll_ctrl_base,PLL_CONFIGURATION1 , val); + + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_CONFIGURATION2 ); + val &= ~PLL_SELFREQDCO_MASK ; + val |= dpll_params->freq <<PLL_SELFREQDCO_SHIFT ; +ti_usb3_writel (phy->pll_ctrl_base,PLL_CONFIGURATION2 , val); + + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_CONFIGURATION1 ); + val &= ~PLL_REGM_MASK ; + val |= dpll_params->m <<PLL_REGM_SHIFT ; +ti_usb3_writel (phy->pll_ctrl_base,PLL_CONFIGURATION1 , val); + + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_CONFIGURATION4 ); + val &= ~PLL_REGM_F_MASK ; + val |= dpll_params->mf <<PLL_REGM_F_SHIFT ; +ti_usb3_writel (phy->pll_ctrl_base,PLL_CONFIGURATION4 , val); + + val =ti_usb3_readl (phy->pll_ctrl_base,PLL_CONFIGURATION3 ); + val &= ~PLL_SD_MASK ; + val |= dpll_params->sd <<PLL_SD_SHIFT ; +ti_usb3_writel (phy->pll_ctrl_base,PLL_CONFIGURATION3 , val); + +ti_usb3_writel (phy->pll_ctrl_base,PLL_GO ,SET_PLL_GO ); + +return ti_usb3_dpll_wait_lock (phy); +} +#endif + +void ti_usb2_phy_power (struct ti_usb_phy *phy,int on) +{ +u32 val; + + val =readl (phy->usb2_phy_power); + +if (on) { +#ifdef CONFIG_DRA7XX + val &= ~OMAP_CTRL_DEV_PHY_PD ; +#elif defined(CONFIG_AM43XX ) + val &= ~(AM437X_CTRL_USB2_PHY_PD | +AM437X_CTRL_USB2_OTG_PD ); + val |= (AM437X_CTRL_USB2_OTGVDET_EN | +AM437X_CTRL_USB2_OTGSESSEND_EN ); +#endif + }else { +#ifdef CONFIG_DRA7XX + val |=OMAP_CTRL_DEV_PHY_PD ; +#elif defined(CONFIG_AM43XX ) + val &= ~(AM437X_CTRL_USB2_OTGVDET_EN | +AM437X_CTRL_USB2_OTGSESSEND_EN ); + val |= (AM437X_CTRL_USB2_PHY_PD | +AM437X_CTRL_USB2_OTG_PD ); +#endif + } +writel (val, phy->usb2_phy_power); +} + +#ifndef CONFIG_AM43XX +void ti_usb3_phy_power (struct ti_usb_phy *phy,int on) +{ +u32 val; +u32 rate; + rate =get_sys_clk_freq (); + rate = rate/1000000 ; + +if (!phy->usb3_phy_power) +return ; + + val =readl (phy->usb3_phy_power); +if (on) { + val &= ~(OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_MASK | +OMAP_CTRL_USB3_PHY_PWRCTL_CLK_FREQ_MASK ); + val |= (OMAP_CTRL_USB3_PHY_TX_RX_POWERON ) << +OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_SHIFT ; + val |= rate << +OMAP_CTRL_USB3_PHY_PWRCTL_CLK_FREQ_SHIFT ; + }else { + val &= ~OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_MASK ; + val |=OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF << +OMAP_CTRL_USB3_PHY_PWRCTL_CLK_CMD_SHIFT ; + } +writel (val, phy->usb3_phy_power); +} +#endif + +/** +* ti_usb_phy_uboot_init - usb phy uboot initialization code +* @dev: struct ti_usb_phy_device containing initialization data +* +* Entry point for ti usb phy driver. This driver handles initialization +* of both usb2 phy and usb3 phy. Pointer to ti_usb_phy_device should be +* passed containing base address and other initialization data. +* Returns '0' on success and a negative value on failure. +* +* Generally called from board_usb_init() implemented in board file. +*/ +int ti_usb_phy_uboot_init (struct ti_usb_phy_device *dev) +{ +struct ti_usb_phy *phy; + + phy =devm_kzalloc (NULL ,sizeof (*phy),GFP_KERNEL ); +if (!phy) { +dev_err (NULL ,"unable to alloc mem for TI USB3 PHY\n" ); +return -ENOMEM ; + } + + phy->dpll_map = dpll_map_usb; + phy->index = dev->index; + phy->pll_ctrl_base = dev->pll_ctrl_base; + phy->usb2_phy_power = dev->usb2_phy_power; + phy->usb3_phy_power = dev->usb3_phy_power; + +#ifndef CONFIG_AM43XX +ti_usb3_dpll_program (phy); +ti_usb3_phy_power (phy,1 ); +#endif +ti_usb2_phy_power (phy,1 ); +mdelay (150 ); +list_add_tail (&phy->list, &ti_usb_phy_list); + +return 0 ; +} + +/** +* ti_usb_phy_uboot_exit - usb phy uboot cleanup code +* @index: index of this controller +* +* Performs cleanup of memory allocated in ti_usb_phy_uboot_init. +* index of _this_ controller should be passed and should match with +* the index passed in ti_usb_phy_device during init. +* +* Generally called from board file. +*/ +void ti_usb_phy_uboot_exit (int index) +{ +struct ti_usb_phy *phy =NULL ; + +list_for_each_entry (phy, &ti_usb_phy_list, list) { +if (phy->index != index) +continue ; + +ti_usb2_phy_power (phy,0 ); +#ifndef CONFIG_AM43XX +ti_usb3_phy_power (phy,0 ); +#endif +list_del (&phy->list); +kfree (phy); +break ; + } +}
include/ti-usb-phy-uboot.h new file +22 -0
@@ -0,0 +1,22 @@ +/* include/ti_usb_phy_uboot.h +* +* Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com +* +* USB2 and USB3 PHY uboot init +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __TI_USB_PHY_UBOOT_H_ +#define __TI_USB_PHY_UBOOT_H_ + +struct ti_usb_phy_device { +void *pll_ctrl_base; +void *usb2_phy_power; +void *usb3_phy_power; +int index; +}; + +int ti_usb_phy_uboot_init (struct ti_usb_phy_device *dev); +void ti_usb_phy_uboot_exit (int index); +#endif /* __TI_USB_PHY_UBOOT_H_ */
Signature · 1 line
1.7.9.5
PATCH v2 30/40 dwc3: flush the buffers before using it
In reply to Kishon Vijay Abraham IIn the linux kernel, non cacheable buffers are used. However in uboot since there are no APIs to allocate non cacheable memory, all the buffers should be flushed before using it.
--- drivers/usb/dwc3/core.c | 11 +++++++++-- drivers/usb/dwc3/ep0.c | 6 ++++++ drivers/usb/dwc3/gadget.c | 8 +++++++- drivers/usb/dwc3/io.h | 5 +++++ 4 files changed, 27 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +9 -2
@@ -157,8 +157,8 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) num =DWC3_NUM_INT (dwc->hwparams.hwparams1); dwc->num_event_buffers = num; - dwc->ev_buffs =devm_kzalloc (dwc->dev,sizeof (*dwc->ev_buffs) * num, -GFP_KERNEL ); + dwc->ev_buffs =memalign (CONFIG_SYS_CACHELINE_SIZE , +sizeof (*dwc->ev_buffs) * num);if (!dwc->ev_buffs)return -ENOMEM ;
@@ -769,11 +769,18 @@ void dwc3_uboot_exit(int index)void dwc3_uboot_handle_interrupt (int index) {struct dwc3 *dwc =NULL ; +int i; +struct dwc3_event_buffer *evt;list_for_each_entry (dwc, &dwc3_list, list) {if (dwc->index != index)continue ; +for (i =0 ; i < dwc->num_event_buffers; i++) { + evt = dwc->ev_buffs[i]; +dwc3_flush_cache ((int )evt->buf, evt->length); + } +dwc3_gadget_uboot_handle_interrupt (dwc);break ; }
drivers/usb/dwc3/ep0.c +6 -0
@@ -74,6 +74,9 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_ISP_IMI); +dwc3_flush_cache ((int )buf_dma, len); +dwc3_flush_cache ((int )trb,sizeof (*trb)); +memset (¶ms,0 ,sizeof (params)); params.param0 =upper_32_bits (dwc->ep0_trb_addr); params.param1 =lower_32_bits (dwc->ep0_trb_addr);
@@ -774,6 +777,8 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,if (!r)return ; +dwc3_flush_cache ((int )trb,sizeof (*trb)); + status =DWC3_TRB_SIZE_TRBSTS (trb->size);if (status ==DWC3_TRBSTS_SETUP_PENDING ) {dev_dbg (dwc->dev,"Setup Pending received" );
@@ -795,6 +800,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, transfer_size += (maxp - (transfer_size % maxp)); transferred =min_t (u32, ur->length, transfer_size - length); +dwc3_flush_cache ((int )dwc->ep0_bounce,DWC3_EP0_BOUNCE_SIZE );memcpy (ur->buf, dwc->ep0_bounce, transferred); }else { transferred = ur->length - length;
drivers/usb/dwc3/gadget.c +7 -1
@@ -244,6 +244,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,list_del (&req->list); req->trb =NULL ; +dwc3_flush_cache ((int )req->request.dma, req->request.length);if (req->request.status == -EINPROGRESS ) req->request.status = status;
@@ -769,6 +770,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, trb->ctrl |=DWC3_TRB_CTRL_SID_SOFN (req->request.stream_id); trb->ctrl |=DWC3_TRB_CTRL_HWO ; + +dwc3_flush_cache ((int )dma, length); +dwc3_flush_cache ((int )trb,sizeof (*trb)); }/*
@@ -1770,6 +1774,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, slot %=DWC3_TRB_NUM ; trb = &dep->trb_pool[slot]; +dwc3_flush_cache ((int )trb,sizeof (*trb)); ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, event, status);if (ret)
@@ -2583,7 +2588,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err1; } - dwc->setup_buf =kzalloc (DWC3_EP0_BOUNCE_SIZE ,GFP_KERNEL ); + dwc->setup_buf =memalign (CONFIG_SYS_CACHELINE_SIZE , +DWC3_EP0_BOUNCE_SIZE );if (!dwc->setup_buf) { ret = -ENOMEM ; goto err2;
drivers/usb/dwc3/io.h +5 -0
@@ -20,6 +20,7 @@#include <asm/io.h> +#define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZEstatic inline u32 dwc3_readl (void __iomem *base,u32 offset) {u32 offs = offset -DWC3_GLOBALS_REGS_START ;
@@ -47,4 +48,8 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) writel(value, base + offs); } +static inline void dwc3_flush_cache (int addr,int length) +{ +flush_dcache_range (addr, addr +ROUND (length,CACHELINE_SIZE )); +}#endif /* __DRIVERS_USB_DWC3_IO_H */
Signature · 1 line
1.7.9.5
PATCH v2 30/40 dwc3: flush the buffers before using it
Hi Kishon,
Quoted 91 lines
In the linux kernel, non cacheable buffers are used. However in uboot since there are no APIs to allocate non cacheable memory, all the buffers should be flushed before using it.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/usb/dwc3/core.c | 11 +++++++++-- drivers/usb/dwc3/ep0.c | 6 ++++++ drivers/usb/dwc3/gadget.c | 8 +++++++- drivers/usb/dwc3/io.h | 5 +++++ 4 files changed, 27 insertions(+), 3 deletions(-)drivers/usb/dwc3/core.c +9
-2@@ -157,8 +157,8 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) num = DWC3_NUM_INT(dwc->hwparams.hwparams1); dwc->num_event_buffers = num; - dwc->ev_buffs =devm_kzalloc (dwc->dev,sizeof (*dwc->ev_buffs) * num, -GFP_KERNEL ); + dwc->ev_buffs =memalign (CONFIG_SYS_CACHELINE_SIZE , +sizeof (*dwc->ev_buffs) * num);if (!dwc->ev_buffs)return -ENOMEM ;@@ -769,11 +769,18 @@ void dwc3_uboot_exit(int index)void dwc3_uboot_handle_interrupt (int index) {struct dwc3 *dwc =NULL ; +int i; +struct dwc3_event_buffer *evt;list_for_each_entry (dwc, &dwc3_list, list) {if (dwc->index != index)continue ; +for (i =0 ; i < dwc->num_event_buffers; i++) { + evt = dwc->ev_buffs[i]; +dwc3_flush_cache ((int )evt->buf, evt->length); + } +dwc3_gadget_uboot_handle_interrupt (dwc);break ; }drivers/usb/dwc3/ep0.c +0
-0@@ -74,6 +74,9 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc,u8 epnum,
dma_addr_tbuf_dma, |DWC3_TRB_CTRL_IOCdrivers/usb/dwc3/ep0.c +6
-0| DWC3_TRB_CTRL_ISP_IMI); +dwc3_flush_cache ((int )buf_dma, len); +dwc3_flush_cache ((int )trb,sizeof (*trb)); +memset (¶ms,0 ,sizeof (params)); params.param0 =upper_32_bits (dwc->ep0_trb_addr); params.param1 =lower_32_bits (dwc->ep0_trb_addr);@@ -774,6 +777,8 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, if (!r) return; +dwc3_flush_cache ((int )trb,sizeof (*trb)); + status =DWC3_TRB_SIZE_TRBSTS (trb->size);if (status ==DWC3_TRBSTS_SETUP_PENDING ) {dev_dbg (dwc->dev,"Setup Pending received" );@@ -795,6 +800,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, transfer_size += (maxp - (transfer_size % maxp)); transferred =min_t (u32, ur->length, transfer_size - length); +dwc3_flush_cache ((int )dwc->ep0_bounce,DWC3_EP0_BOUNCE_SIZE );memcpy (ur->buf, dwc->ep0_bounce, transferred); }else { transferred = ur->length - length;drivers/usb/dwc3/gadget.c +1
-0@@ -244,6 +244,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep,struct dwc3_request *req, list_del(&req->list); req->trb =NULL ; +dwc3_flush_cache ((int )req->request.dma, req->request.length);if (req->request.status == -EINPROGRESS ) req->request.status = status;
drivers/usb/dwc3/gadget.c static void dwc3_prepare_one_trb(struct dwc3_ep · line 775
Quoted 6 lines
drivers/usb/dwc3/gadget.c +3
-0@@ -769,6 +770,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, trb->ctrl |=DWC3_TRB_CTRL_SID_SOFN (req->request.stream_id); trb->ctrl |=DWC3_TRB_CTRL_HWO ; + +dwc3_flush_cache ((int )dma, length); +dwc3_flush_cache ((int )trb,sizeof (*trb));
My only concern is with sizeof(*trb), which is 16B.
On Exynos cache line size is 32B.
With this particular case we would flush one extra TRB struct to main memory.
Since we have per EP trb_pools aligned with memalign calls (and capable of storing up to 32 TRB requests) and perform one TRB transmission at a time, we can leave this code as it is.
Hence,
Quoted 42 lines
drivers/usb/dwc3/gadget.c +3
-1}/* @@ -1770,6 +1774,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, slot %= DWC3_TRB_NUM; trb = &dep->trb_pool[slot]; +dwc3_flush_cache ((int )trb,sizeof (*trb)); ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, event, status);if (ret)@@ -2583,7 +2588,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err1; } - dwc->setup_buf =kzalloc (DWC3_EP0_BOUNCE_SIZE ,GFP_KERNEL ); + dwc->setup_buf =memalign (CONFIG_SYS_CACHELINE_SIZE , +DWC3_EP0_BOUNCE_SIZE );if (!dwc->setup_buf) { ret = -ENOMEM ; goto err2;drivers/usb/dwc3/io.h +1
-0@@ -20,6 +20,7 @@#include <asm/io.h> +#define CACHELINE_SIZE
CONFIG_SYS_CACHELINE_SIZEstatic inline u32dwc3_readl(void __iomem *base, u32 offset){drivers/usb/dwc3/io.h +3
-0u32 offs = offset -DWC3_GLOBALS_REGS_START ;@@ -47,4 +48,8 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) writel(value, base + offs); } +static inline void dwc3_flush_cache (int addr,int length) +{ +flush_dcache_range (addr, addr +ROUND (length, CACHELINE_SIZE)); +}#endif /* __DRIVERS_USB_DWC3_IO_H */
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 31/40 usb: dwc3: ep0: preparation for implementing chained TRB
In reply to Kishon Vijay Abraham INo functional change. Modified few things so that there are no code duplication while implementing chained TRB.
--- drivers/usb/dwc3/ep0.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/usb/dwc3/ep0.c +12 -8
@@ -761,7 +761,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,struct usb_request *ur;struct dwc3_trb *trb;struct dwc3_ep *ep0; -u32 transferred; +unsigned transfer_size =0 ; +unsigned maxp; +void *buf; +u32 transferred =0 ;u32 status;u32 length;u8 epnum;
@@ -790,18 +793,19 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, } ur = &r->request; + buf = ur->buf; length = trb->size &DWC3_TRB_SIZE_MASK ; -if (dwc->ep0_bounced) { -unsigned transfer_size = ur->length; -unsigned maxp = ep0->endpoint.maxpacket; + maxp = ep0->endpoint.maxpacket; - transfer_size += (maxp - (transfer_size % maxp)); - transferred =min_t (u32, ur->length, - transfer_size - length); +if (dwc->ep0_bounced) { + transfer_size =roundup ((ur->length - transfer_size), + maxp); + transferred =min_t (u32, ur->length - transferred, + transfer_size - length);dwc3_flush_cache ((int )dwc->ep0_bounce,DWC3_EP0_BOUNCE_SIZE ); -memcpy (ur->buf, dwc->ep0_bounce, transferred); +memcpy (buf, dwc->ep0_bounce, transferred); }else { transferred = ur->length - length; }
Signature · 1 line
1.7.9.5
PATCH v2 32/40 usb: dwc3: Add chained TRB support for ep0
In reply to Kishon Vijay Abraham Idwc3 can do only max packet aligned transfers. So in case request length is not max packet aligned and is bigger than DWC3_EP0_BOUNCE_SIZE two chained TRBs is required to handle the transfer.
--- drivers/usb/dwc3/ep0.c | 72 +++++++++++++++++++++++++++++++++------------ drivers/usb/dwc3/gadget.c | 2 +- 2 files changed, 55 insertions(+), 19 deletions(-)
drivers/usb/dwc3/ep0.c +54 -18
@@ -48,7 +48,7 @@ static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) }static int dwc3_ep0_start_trans (struct dwc3 *dwc,u8 epnum,dma_addr_t buf_dma, -u32 len,u32 type) +u32 len,u32 type,unsigned chain) {struct dwc3_gadget_ep_cmd_params params;struct dwc3_trb *trb;
@@ -62,7 +62,10 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,return 0 ; } - trb = dwc->ep0_trb; + trb = &dwc->ep0_trb[dep->free_slot]; + +if (chain) + dep->free_slot++; trb->bpl =lower_32_bits (buf_dma); trb->bph =upper_32_bits (buf_dma);
@@ -70,13 +73,20 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, trb->ctrl = type; trb->ctrl |= (DWC3_TRB_CTRL_HWO - |DWC3_TRB_CTRL_LST - |DWC3_TRB_CTRL_IOC |DWC3_TRB_CTRL_ISP_IMI ); +if (chain) + trb->ctrl |=DWC3_TRB_CTRL_CHN ; +else + trb->ctrl |= (DWC3_TRB_CTRL_IOC + |DWC3_TRB_CTRL_LST ); +dwc3_flush_cache ((int )buf_dma, len);dwc3_flush_cache ((int )trb,sizeof (*trb)); +if (chain) +return 0 ; +memset (¶ms,0 ,sizeof (params)); params.param0 =upper_32_bits (dwc->ep0_trb_addr); params.param1 =lower_32_bits (dwc->ep0_trb_addr);
@@ -289,7 +299,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)int ret; ret =dwc3_ep0_start_trans (dwc,0 , dwc->ctrl_req_addr,8 , -DWC3_TRBCTL_CONTROL_SETUP ); +DWC3_TRBCTL_CONTROL_SETUP ,0 );WARN_ON (ret <0 ); }
@@ -800,6 +810,23 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, maxp = ep0->endpoint.maxpacket;if (dwc->ep0_bounced) { +/* +* Handle the first TRB before handling the bounce buffer if +* the request length is greater than the bounce buffer size. +*/ +if (ur->length >DWC3_EP0_BOUNCE_SIZE ) { + transfer_size = (ur->length / maxp) * maxp; + transferred = transfer_size - length; + buf = (u8 *)buf + transferred; + ur->actual += transferred; + + trb++; +dwc3_flush_cache ((int )trb,sizeof (*trb)); + length = trb->size &DWC3_TRB_SIZE_MASK ; + + ep0->free_slot =0 ; + } + transfer_size =roundup ((ur->length - transfer_size), maxp); transferred = min_t(u32, ur->length - transferred,
@@ -827,7 +854,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, ret =dwc3_ep0_start_trans (dwc, epnum, dwc->ctrl_req_addr,0 , -DWC3_TRBCTL_CONTROL_DATA ); +DWC3_TRBCTL_CONTROL_DATA ,0 );WARN_ON (ret <0 ); } }
@@ -908,11 +935,11 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,if (req->request.length ==0 ) { ret =dwc3_ep0_start_trans (dwc, dep->number, - dwc->ctrl_req_addr,0 , -DWC3_TRBCTL_CONTROL_DATA ); - }else if (!IS_ALIGNED (req->request.length, dep->endpoint.maxpacket) - && (dep->number ==0 )) { -u32 transfer_size; + dwc->ctrl_req_addr,0 , +DWC3_TRBCTL_CONTROL_DATA ,0 ); + }else if (!IS_ALIGNED (req->request.length, dep->endpoint.maxpacket) && + (dep->number ==0 )) { +u32 transfer_size =0 ;u32 maxpacket; ret = usb_gadget_map_request(&dwc->gadget, &req->request,
@@ -922,10 +949,18 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,return ; } -WARN_ON (req->request.length >DWC3_EP0_BOUNCE_SIZE ); - maxpacket = dep->endpoint.maxpacket; - transfer_size =roundup (req->request.length, maxpacket); +if (req->request.length >DWC3_EP0_BOUNCE_SIZE ) { + transfer_size = (req->request.length / maxpacket) * + maxpacket; + ret =dwc3_ep0_start_trans (dwc, dep->number, + req->request.dma, + transfer_size, +DWC3_TRBCTL_CONTROL_DATA ,1 ); + } + + transfer_size =roundup ((req->request.length - transfer_size), + maxpacket); dwc->ep0_bounced = true;
@@ -935,8 +970,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,* TRBs to handle the transfer. */ ret =dwc3_ep0_start_trans (dwc, dep->number, - dwc->ep0_bounce_addr, transfer_size, -DWC3_TRBCTL_CONTROL_DATA ); + dwc->ep0_bounce_addr, transfer_size, +DWC3_TRBCTL_CONTROL_DATA ,0 ); }else { ret =usb_gadget_map_request (&dwc->gadget, &req->request, dep->number);
@@ -946,7 +981,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, } ret =dwc3_ep0_start_trans (dwc, dep->number, req->request.dma, - req->request.length,DWC3_TRBCTL_CONTROL_DATA ); + req->request.length, +DWC3_TRBCTL_CONTROL_DATA ,0 ); }WARN_ON (ret <0 );
@@ -961,7 +997,7 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) : DWC3_TRBCTL_CONTROL_STATUS2;return dwc3_ep0_start_trans (dwc, dep->number, - dwc->ctrl_req_addr,0 , type); + dwc->ctrl_req_addr,0 , type,0 ); }static void __dwc3_ep0_do_control_status (struct dwc3 *dwc,struct dwc3_ep *dep)
drivers/usb/dwc3/gadget.c +1 -1
@@ -2580,7 +2580,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) goto err0; } - dwc->ep0_trb =dma_alloc_coherent (sizeof (*dwc->ep0_trb), + dwc->ep0_trb =dma_alloc_coherent (sizeof (*dwc->ep0_trb) *2 , (unsigned long *)&dwc->ep0_trb_addr);if (!dwc->ep0_trb) {dev_err (dwc->dev,"failed to allocate ep0 trb\n" );
Signature · 1 line
1.7.9.5
PATCH v2 33/40 usb: dwc3: Makefile: Make dwc3 driver compile in u-boot
In reply to Kishon Vijay Abraham INow that the entire dwc3 driver is adapted to compile with uboot build, modify the Makefiles so that the dwc3 driver can be built.
--- Makefile | 2 ++ drivers/usb/dwc3/Makefile | 35 +++-------------------------------- drivers/usb/gadget/udc/Makefile | 2 +- 3 files changed, 6 insertions(+), 33 deletions(-)
Makefile +2 -0
@@ -632,8 +632,10 @@ libs-y += drivers/spi/ libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ libs-y += drivers/serial/ +libs-y += drivers/usb/dwc3/ libs-y += drivers/usb/eth/ libs-y += drivers/usb/gadget/ +libs-y += drivers/usb/gadget/udc/ libs-y += drivers/usb/host/ libs-y += drivers/usb/musb/ libs-y += drivers/usb/musb-new/
drivers/usb/dwc3/Makefile +3 -32
@@ -1,37 +1,8 @@ -ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG -ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG - obj-$(CONFIG_USB_DWC3) += dwc3.o -dwc3-y := core.o debug.o - -ifneq ($(filter y,$(CONFIG_USB_DWC3_HOST) $(CONFIG_USB_DWC3_DUAL_ROLE)),) - dwc3-y += host.o -endif - -ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) $(CONFIG_USB_DWC3_DUAL_ROLE)),) - dwc3-y += gadget.o ep0.o -endif - -ifneq ($(CONFIG_DEBUG_FS),) - dwc3-y += debugfs.o -endif +dwc3-y := core.o -## -# Platform-specific glue layers go here -# -# NOTICE: Make sure your glue layer doesn't depend on anything -# which is arch-specific and that it compiles on all situations. -# -# We want to keep this requirement in order to be able to compile -# the entire driver (with all its glue layers) on several architectures -# and make sure it compiles fine. This will also help with allmodconfig -# and allyesconfig builds. -## +dwc3-y += gadget.o ep0.o obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o -obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o -obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o -obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o -obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o -obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_PHY_OMAP) += ti_usb_phy.o
drivers/usb/gadget/udc/Makefile +1 -1
@@ -1,4 +1,4 @@ # # USB peripheral controller drivers # -obj-$(CONFIG_USB_GADGET) += udc-core.o +obj-$(CONFIG_USB_DWC3_GADGET) += udc-core.o
Signature · 1 line
1.7.9.5
PATCH v2 34/40 usb: gadget: defer setting maxpacket till ->setup()
In reply to Kishon Vijay Abraham ITaken from linux kernel with commit
commit 765f5b830e547229bb752e7b232ee83e2b3d49d5
Author: Sebastian Andrzej Siewior <[email protected]> Date: Thu Jun 23 14:26:11 2011 +0200
usb: gadget: defer setting maxpacket till ->setup()
--- drivers/usb/gadget/composite.c | 4 +++- drivers/usb/gadget/ether.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/usb/gadget/composite.c +3 -1
@@ -283,7 +283,7 @@ static void device_qual(struct usb_composite_dev *cdev) qual->bDeviceSubClass = cdev->desc.bDeviceSubClass; qual->bDeviceProtocol = cdev->desc.bDeviceProtocol;/* ASSUME same EP0 fifo size at both speeds */ - qual->bMaxPacketSize0 = cdev->desc.bMaxPacketSize0; + qual->bMaxPacketSize0 = cdev->gadget->ep0->maxpacket; qual->bNumConfigurations =count_configs (cdev,USB_DT_DEVICE_QUALIFIER ); qual->bRESERVED =0 ; }
@@ -736,6 +736,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)case USB_DT_DEVICE : cdev->desc.bNumConfigurations =count_configs (cdev,USB_DT_DEVICE ); + cdev->desc.bMaxPacketSize0 = + cdev->gadget->ep0->maxpacket; value =min (w_length, (u16 )sizeof cdev->desc);memcpy (req->buf, &cdev->desc, value);break ;
drivers/usb/gadget/ether.c +1 -1
@@ -1249,6 +1249,7 @@ eth_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)switch (wValue >>8 ) {case USB_DT_DEVICE : + device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket; value =min (wLength, (u16 )sizeof device_desc);memcpy (req->buf, &device_desc, value);break ;
@@ -2133,7 +2134,6 @@ autoconf_fail:hs_subset_descriptors (); } - device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;usb_gadget_set_selfpowered (gadget);/* For now RNDIS is always a second config */
Signature · 1 line
1.7.9.5
PATCH v2 35/40 common: cmd_dfu: invoke board_usb_cleanup() for cleaning up
In reply to Kishon Vijay Abraham IInvoked board_usb_cleanup for cleaning up initialized USB. It will be invoked if the user enterts ctrl-C.
--- common/cmd_dfu.c | 1 + common/usb.c | 6 ++++++ 2 files changed, 7 insertions(+)
common/cmd_dfu.c +1 -0
@@ -68,6 +68,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } exit:g_dnl_unregister (); +board_usb_cleanup (controller_index,USB_INIT_DEVICE ); done:dfu_free_entities ();
common/usb.c +6 -0
@@ -1063,4 +1063,10 @@ int board_usb_init(int index, enum usb_init_type init) {return 0 ; } + +__weak +int board_usb_cleanup (int index,enum usb_init_type init) +{ +return 0 ; +}/* EOF */
Signature · 1 line
1.7.9.5
PATCH v2 36/40 board: ti: DRA7: added USB initializtion code
In reply to Kishon Vijay Abraham IImplemented board_usb_init(), board_usb_cleanup() and usb_gadget_handle_interrupts() in dra7xx board file that can be invoked by various gadget drivers.
--- arch/arm/include/asm/arch-omap5/omap.h | 12 ++++ board/ti/dra7xx/evm.c | 109 ++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+)
arch/arm/include/asm/arch-omap5/omap.h +12 -0
@@ -33,6 +33,18 @@#define CONTROL_ID_CODE CONTROL_CORE_ID_CODE#endif +#ifdef CONFIG_DRA7XX +#define DRA7_USB_OTG_SS1_BASE 0x48890000 +#define DRA7_USB_OTG_SS1_GLUE_BASE 0x48880000 +#define DRA7_USB3_PHY1_PLL_CTRL 0x4A084C00 +#define DRA7_USB3_PHY1_POWER 0x4A002370 +#define DRA7_USB2_PHY1_POWER 0x4A002300 + +#define DRA7_USB_OTG_SS2_BASE 0x488D0000 +#define DRA7_USB_OTG_SS2_GLUE_BASE 0x488C0000 +#define DRA7_USB2_PHY2_POWER 0x4A002E74 +#endif +/* To be verified */ #define OMAP5430_CONTROL_ID_CODE_ES1_0 0x0B94202F#define OMAP5430_CONTROL_ID_CODE_ES2_0 0x1B94202F
board/ti/dra7xx/evm.c +109 -0
126 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 37/40 include: configs: Enable DWC3 and DFU in DRA7xx
In reply to Kishon Vijay Abraham IEnabled dwc3, dwc3-omap and PHY for dwc3 are enabled. Also enabled support for DFU.
--- include/configs/dra7xx_evm.h | 63 +++++++++++++++++++++++++++++++++++++ include/configs/ti_omap5_common.h | 5 +++ 2 files changed, 68 insertions(+)
include/configs/dra7xx_evm.h +63 -0
@@ -43,6 +43,47 @@"uuid_disk=${uuid_gpt_disk};" \ "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}" +#define DFU_ALT_INFO_MMC \ + "dfu_alt_info_mmc=" \ + "boot part 0 1;" \ + "rootfs part 0 2;" \ + "MLO fat 0 1;" \ + "MLO.raw raw 0x100 0x100;" \ + "u-boot.img.raw raw 0x300 0x400;" \ + "spl-os-args.raw raw 0x80 0x80;" \ + "spl-os-image.raw raw 0x900 0x2000;" \ + "spl-os-args fat 0 1;" \ + "spl-os-image fat 0 1;" \ + "u-boot.img fat 0 1;" \ + "uEnv.txt fat 0 1\0" + +#define DFU_ALT_INFO_EMMC \ + "dfu_alt_info_emmc=" \ + "rawemmc raw 0 3751936;" \ + "boot part 1 1;" \ + "rootfs part 1 2;" \ + "MLO fat 1 1;" \ + "MLO.raw raw 0x100 0x100;" \ + "u-boot.img.raw raw 0x300 0x400;" \ + "spl-os-args.raw raw 0x80 0x80;" \ + "spl-os-image.raw raw 0x900 0x2000;" \ + "spl-os-args fat 1 1;" \ + "spl-os-image fat 1 1;" \ + "u-boot.img fat 1 1;" \ + "uEnv.txt fat 1 1\0" + +#define DFU_ALT_INFO_RAM \ + "dfu_alt_info_ram=" \ + "kernel ram 0x80200000 0x4000000;" \ + "fdt ram 0x80f80000 0x80000;" \ + "ramdisk ram 0x81000000 0x4000000\0" + +#define DFUARGS \ + "dfu_bufsiz=0x10000\0" \ + DFU_ALT_INFO_MMC \ + DFU_ALT_INFO_EMMC \ + DFU_ALT_INFO_RAM +#include <configs/ti_omap5_common.h> /* Enhance our eMMC support / experience. */
@@ -132,6 +173,28 @@#define CONFIG_OMAP_USB_PHY #define CONFIG_OMAP_USB2PHY2_HOST +/* USB GADGET */ +#define CONFIG_USB_DWC3_PHY_OMAP +#define CONFIG_USB_DWC3_OMAP +#define CONFIG_USB_DWC3 +#define CONFIG_USB_DWC3_GADGET + +#define CONFIG_USB_GADGET +#define CONFIG_USBDOWNLOAD_GADGET +#define CONFIG_USB_GADGET_VBUS_DRAW 2 +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments" +#define CONFIG_G_DNL_VENDOR_NUM 0x0403 +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00 +#define CONFIG_USB_GADGET_DUALSPEED + +/* USB Device Firmware Update support */ +#define CONFIG_DFU_FUNCTION +#define CONFIG_DFU_RAM +#define CONFIG_CMD_DFU + +#define CONFIG_DFU_MMC +#define CONFIG_DFU_RAM +/* SATA */ #define CONFIG_BOARD_LATE_INIT #define CONFIG_CMD_SCSI
include/configs/ti_omap5_common.h +5 -0
@@ -65,6 +65,10 @@#define PARTS_DEFAULT #endif +#ifndef DFUARGS +#define DFUARGS +#endif +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \
@@ -122,6 +126,7 @@"if test $fdtfile = undefined; then " \"echo WARNING: Could not determine device tree to use; fi; \0" \"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \ +DFUARGS \ #define CONFIG_BOOTCOMMAND \"run findfdt; " \
Signature · 1 line
1.7.9.5
PATCH v2 38/40 board: ti: AM43xx: added USB initializtion code
In reply to Kishon Vijay Abraham IImplemented board_usb_init(), board_usb_cleanup() and usb_gadget_handle_interrupts() in am43xx board file that can be invoked by various gadget drivers.
--- arch/arm/include/asm/arch-am33xx/hardware_am43xx.h | 9 ++ board/ti/am43xx/board.c | 108 ++++++++++++++++++++ 2 files changed, 117 insertions(+)
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h +9 -0
@@ -61,6 +61,15 @@/* RTC base address */ #define RTC_BASE 0x44E3E000 +/* USB OTG */ +#define USB_OTG_SS1_BASE 0x48390000 +#define USB_OTG_SS1_GLUE_BASE 0x48380000 +#define USB2_PHY1_POWER 0x44E10620 + +#define USB_OTG_SS2_BASE 0x483D0000 +#define USB_OTG_SS2_GLUE_BASE 0x483C0000 +#define USB2_PHY2_POWER 0x44E10628 +/* USB Clock Control */ #define PRM_PER_USB_OTG_SS0_CLKCTRL (CM_PER + 0x260)#define PRM_PER_USB_OTG_SS1_CLKCTRL (CM_PER + 0x268)
board/ti/am43xx/board.c +108 -0
126 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 39/40 include: configs: Enable DWC3 and DFU in AM43xx
In reply to Kishon Vijay Abraham IEnabled dwc3, dwc3-omap and PHY for dwc3 are enabled. Also enabled support for DFU.
--- include/configs/am43xx_evm.h | 58 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-)
include/configs/am43xx_evm.h +57 -1
@@ -108,6 +108,61 @@#define CONFIG_OMAP_USB_PHY #define CONFIG_AM437X_USB2PHY2_HOST +/* USB GADGET */ +#if !defined(CONFIG_SPL_BUILD ) || \ + (defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_USBETH_SUPPORT )) +#define CONFIG_USB_DWC3_PHY_OMAP +#define CONFIG_USB_DWC3_OMAP +#define CONFIG_USB_DWC3 +#define CONFIG_USB_DWC3_GADGET + +#define CONFIG_USB_GADGET +#define CONFIG_USBDOWNLOAD_GADGET +#define CONFIG_USB_GADGET_VBUS_DRAW 2 +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments" +#define CONFIG_G_DNL_VENDOR_NUM 0x0403 +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00 +#define CONFIG_USB_GADGET_DUALSPEED +#endif + +#ifndef CONFIG_SPL_BUILD +/* USB Device Firmware Update support */ +#define CONFIG_DFU_FUNCTION +#define CONFIG_DFU_RAM +#define CONFIG_CMD_DFU + +#define CONFIG_DFU_MMC +#define DFU_ALT_INFO_MMC \ + "dfu_alt_info_mmc=" \ + "boot part 0 1;" \ + "rootfs part 0 2;" \ + "MLO fat 0 1;" \ + "spl-os-args fat 0 1;" \ + "spl-os-image fat 0 1;" \ + "u-boot.img fat 0 1;" \ + "uEnv.txt fat 0 1\0" + +#define DFU_ALT_INFO_EMMC \ + "dfu_alt_info_emmc=" \ + "MLO raw 0x100 0x100 mmcpart 0;" \ + "u-boot.img raw 0x300 0x1000 mmcpart 0\0" + +#define CONFIG_DFU_RAM +#define DFU_ALT_INFO_RAM \ + "dfu_alt_info_ram=" \ + "kernel ram 0x80200000 0x4000000;" \ + "fdt ram 0x80f80000 0x80000;" \ + "ramdisk ram 0x81000000 0x4000000\0" + +#define DFUARGS \ + "dfu_bufsiz=0x10000\0" \ + DFU_ALT_INFO_MMC \ + DFU_ALT_INFO_EMMC \ + DFU_ALT_INFO_RAM +#else +#define DFUARGS +#endif +#ifdef CONFIG_QSPI_BOOT #define CONFIG_SYS_TEXT_BASE 0x30000000#undef CONFIG_ENV_IS_IN_FAT
@@ -238,7 +293,8 @@"if test $board_name = AM43__SK; then " \"setenv fdtfile am437x-sk-evm.dtb; fi; " \"if test $fdtfile = undefined; then " \ -"echo WARNING: Could not determine device tree; fi; \0" +"echo WARNING: Could not determine device tree; fi; \0" \ +DFUARGS \ #define CONFIG_BOOTCOMMAND \"run findfdt; " \
Signature · 1 line
1.7.9.5
PATCH v2 40/40 usb: modify usb_gadget_handle_interrupts to take controller index
In reply to Kishon Vijay Abraham ISince we support multiple dwc3 controllers to be existent at the same time, in order to handle the interrupts of a particular dwc3 controller usb_gadget_handle_interrutps should take controller index as an argument.
Hence the API of usb_gadget_handle_interrupts is modified to take controller index as an argument and made the corresponding changes to all the usb_gadget_handle_interrupts calls.
--- board/ti/am43xx/board.c | 6 +++--- board/ti/dra7xx/evm.c | 6 +++--- common/cmd_dfu.c | 2 +- common/cmd_fastboot.c | 2 +- common/cmd_usb_mass_storage.c | 2 +- drivers/usb/gadget/atmel_usba_udc.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 10 +++++----- drivers/usb/gadget/f_mass_storage.c | 2 +- drivers/usb/gadget/f_thor.c | 6 +++--- drivers/usb/gadget/fotg210.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 2 +- drivers/usb/gadget/s3c_udc_otg.c | 2 +- drivers/usb/musb-new/musb_uboot.c | 2 +- include/linux/usb/gadget.h | 2 +- 15 files changed, 25 insertions(+), 25 deletions(-)
board/ti/am43xx/board.c +3 -3
@@ -782,13 +782,13 @@ int board_usb_cleanup(int index, enum usb_init_type init)return 0 ; } -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {u32 status; - status =dwc3_omap_uboot_interrupt_status (0 ); + status =dwc3_omap_uboot_interrupt_status (index);if (status) -dwc3_uboot_handle_interrupt (0 ); +dwc3_uboot_handle_interrupt (index);return 0 ; }
board/ti/dra7xx/evm.c +3 -3
@@ -220,13 +220,13 @@ int board_usb_cleanup(int index, enum usb_init_type init)return 0 ; } -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {u32 status; - status =dwc3_omap_uboot_interrupt_status (0 ); + status =dwc3_omap_uboot_interrupt_status (index);if (status) -dwc3_uboot_handle_interrupt (0 ); +dwc3_uboot_handle_interrupt (index);return 0 ; }
common/cmd_dfu.c +1 -1
@@ -64,7 +64,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (ctrlc ()) goto exit; -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (controller_index); } exit:g_dnl_unregister ();
common/cmd_fastboot.c +1 -1
@@ -25,7 +25,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])break ;if (ctrlc ())break ; -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); }g_dnl_unregister ();
common/cmd_usb_mass_storage.c +1 -1
@@ -137,7 +137,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, }while (1 ) { -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (controller_index); rc =fsg_main_thread (NULL );if (rc) {
drivers/usb/gadget/atmel_usba_udc.c +1 -1
@@ -1199,7 +1199,7 @@ static struct usba_udc controller = { }, }; -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {struct usba_udc *udc = &controller;
drivers/usb/gadget/ci_udc.c +1 -1
@@ -741,7 +741,7 @@ void udc_irq(void) } } -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {u32 value;struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
drivers/usb/gadget/ether.c +5 -5
@@ -1908,7 +1908,7 @@ static int eth_stop(struct eth_dev *dev)/* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */ ts =get_timer (0 );while (get_timer (ts) < timeout) -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 );#endif rndis_uninit (dev->rndis_config);
@@ -2359,7 +2359,7 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)error ("The remote end did not respond in time." ); goto fail; } -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); } packet_received =0 ;
@@ -2427,7 +2427,7 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length)printf ("timeout sending packets to usb ethernet\n" );return -1 ; } -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); }if (rndis_pkt)free (rndis_pkt);
@@ -2442,7 +2442,7 @@ static int usb_eth_recv(struct eth_device *netdev) {struct eth_dev *dev = &l_ethdev; -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 );if (packet_received) {debug ("%s: packet received\n" , __func__);
@@ -2487,7 +2487,7 @@ void usb_eth_halt(struct eth_device *netdev)/* Clear pending interrupt */ if (dev->network_started) { -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); dev->network_started =0 ; }
drivers/usb/gadget/f_mass_storage.c +1 -1
@@ -689,7 +689,7 @@ static int sleep_thread(struct fsg_common *common) k =0 ; } -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); } common->thread_wakeup_needed =0 ;return rc;
drivers/usb/gadget/f_thor.c +3 -3
@@ -543,7 +543,7 @@ static int thor_rx_data(void) }while (!dev->rxdata) { -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 );if (ctrlc ())return -1 ; }
@@ -577,7 +577,7 @@ static void thor_tx_data(unsigned char *data, int len)/* Wait until tx interrupt received */ while (!dev->txdata) -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 ); dev->txdata =0 ; }
@@ -694,7 +694,7 @@ int thor_init(void)/* Wait for a device enumeration and configuration settings */ debug ("THOR enumeration/configuration setting....\n" );while (!dev->configuration_done) -usb_gadget_handle_interrupts (); +usb_gadget_handle_interrupts (0 );thor_set_dma (thor_rx_data_buf,strlen ("THOR" ));/* detect the download request from Host PC */
drivers/usb/gadget/fotg210.c +1 -1
@@ -832,7 +832,7 @@ static struct fotg210_chip controller = { }, }; -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {struct fotg210_chip *chip = &controller;struct fotg210_regs *regs = chip->regs;
drivers/usb/gadget/pxa25x_udc.c +1 -1
@@ -2041,7 +2041,7 @@ extern void udc_disconnect(void)/*-------------------------------------------------------------------------*/ extern int -usb_gadget_handle_interrupts (void ) +usb_gadget_handle_interrupts (int index) {return pxa25x_udc_irq (); }
drivers/usb/gadget/s3c_udc_otg.c +1 -1
@@ -833,7 +833,7 @@ int s3c_udc_probe(struct s3c_plat_otg_data *pdata)return retval; } -int usb_gadget_handle_interrupts () +int usb_gadget_handle_interrupts (int index) {u32 intr_status =readl (®->gintsts);u32 gintmsk =readl (®->gintmsk);
drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -162,7 +162,7 @@ int usb_lowlevel_stop(int index)#ifdef CONFIG_MUSB_GADGET static struct musb *gadget; -int usb_gadget_handle_interrupts (void ) +int usb_gadget_handle_interrupts (int index) {WATCHDOG_RESET ();if (!gadget || !gadget->isr)
include/linux/usb/gadget.h +1 -1
@@ -937,6 +937,6 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,extern void usb_ep_autoconfig_reset (struct usb_gadget *); -extern int usb_gadget_handle_interrupts (void ); +extern int usb_gadget_handle_interrupts (int index);#endif /* __LINUX_USB_GADGET_H */
Signature · 1 line
1.7.9.5