summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt43
-rw-r--r--Documentation/devicetree/bindings/phy/brcm-sata-phy.txt11
-rw-r--r--Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt7
-rw-r--r--Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/dwc2.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/maxim,max3421.txt26
-rw-r--r--Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt20
-rw-r--r--Documentation/devicetree/bindings/usb/mediatek,mtu3.txt19
-rw-r--r--Documentation/devicetree/bindings/usb/renesas_usb3.txt4
-rw-r--r--Documentation/devicetree/bindings/usb/renesas_usbhs.txt5
-rw-r--r--Documentation/devicetree/bindings/usb/usb-xhci.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/usb251xb.txt46
-rw-r--r--MAINTAINERS7
-rw-r--r--drivers/extcon/extcon-adc-jack.c2
-rw-r--r--drivers/extcon/extcon-arizona.c2
-rw-r--r--drivers/extcon/extcon-axp288.c2
-rw-r--r--drivers/extcon/extcon-gpio.c2
-rw-r--r--drivers/extcon/extcon-intel-cht-wc.c2
-rw-r--r--drivers/extcon/extcon-intel-int3496.c2
-rw-r--r--drivers/extcon/extcon-max14577.c4
-rw-r--r--drivers/extcon/extcon-max3355.c2
-rw-r--r--drivers/extcon/extcon-max77693.c2
-rw-r--r--drivers/extcon/extcon-max77843.c95
-rw-r--r--drivers/extcon/extcon-max8997.c2
-rw-r--r--drivers/extcon/extcon-qcom-spmi-misc.c2
-rw-r--r--drivers/extcon/extcon-rt8973a.c2
-rw-r--r--drivers/extcon/extcon-sm5502.c2
-rw-r--r--drivers/extcon/extcon-usb-gpio.c2
-rw-r--r--drivers/extcon/extcon-usbc-cros-ec.c2
-rw-r--r--drivers/extcon/extcon.c2
-rw-r--r--drivers/extcon/extcon.h2
-rw-r--r--drivers/pci/dwc/pci-dra7xx.c16
-rw-r--r--drivers/phy/allwinner/phy-sun4i-usb.c3
-rw-r--r--drivers/phy/broadcom/Kconfig13
-rw-r--r--drivers/phy/broadcom/Makefile3
-rw-r--r--drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c2
-rw-r--r--drivers/phy/broadcom/phy-brcm-sata.c74
-rw-r--r--drivers/phy/broadcom/phy-brcm-usb-init.c1017
-rw-r--r--drivers/phy/broadcom/phy-brcm-usb-init.h50
-rw-r--r--drivers/phy/broadcom/phy-brcm-usb.c459
-rw-r--r--drivers/phy/marvell/phy-mvebu-cp110-comphy.c1
-rw-r--r--drivers/phy/mediatek/phy-mtk-tphy.c39
-rw-r--r--drivers/phy/phy-core.c15
-rw-r--r--drivers/phy/qualcomm/phy-qcom-ufs-i.h5
-rw-r--r--drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c29
-rw-r--r--drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c29
-rw-r--r--drivers/phy/qualcomm/phy-qcom-ufs.c42
-rw-r--r--drivers/phy/renesas/phy-rcar-gen3-usb2.c72
-rw-r--r--drivers/phy/rockchip/phy-rockchip-inno-usb2.c2
-rw-r--r--drivers/phy/rockchip/phy-rockchip-typec.c217
-rw-r--r--drivers/phy/ti/phy-ti-pipe3.c101
-rw-r--r--drivers/power/supply/qcom_smbb.c2
-rw-r--r--drivers/scsi/ufs/ufs-qcom.c39
-rw-r--r--drivers/soc/bcm/brcmstb/common.c12
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c4
-rw-r--r--drivers/usb/Kconfig9
-rw-r--r--drivers/usb/atm/cxacru.c22
-rw-r--r--drivers/usb/atm/speedtch.c27
-rw-r--r--drivers/usb/atm/ueagle-atm.c1
-rw-r--r--drivers/usb/atm/usbatm.c16
-rw-r--r--drivers/usb/atm/usbatm.h16
-rw-r--r--drivers/usb/atm/xusbatm.c16
-rw-r--r--drivers/usb/c67x00/Makefile1
-rw-r--r--drivers/usb/c67x00/c67x00-drv.c16
-rw-r--r--drivers/usb/c67x00/c67x00-hcd.c16
-rw-r--r--drivers/usb/c67x00/c67x00-hcd.h16
-rw-r--r--drivers/usb/c67x00/c67x00-ll-hpi.c16
-rw-r--r--drivers/usb/c67x00/c67x00-sched.c18
-rw-r--r--drivers/usb/c67x00/c67x00.h16
-rw-r--r--drivers/usb/chipidea/Kconfig2
-rw-r--r--drivers/usb/chipidea/bits.h5
-rw-r--r--drivers/usb/chipidea/ci.h5
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c8
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.h8
-rw-r--r--drivers/usb/chipidea/ci_hdrc_msm.c8
-rw-r--r--drivers/usb/chipidea/ci_hdrc_pci.c5
-rw-r--r--drivers/usb/chipidea/ci_hdrc_tegra.c5
-rw-r--r--drivers/usb/chipidea/ci_hdrc_usb2.c5
-rw-r--r--drivers/usb/chipidea/ci_hdrc_zevio.c6
-rw-r--r--drivers/usb/chipidea/core.c5
-rw-r--r--drivers/usb/chipidea/host.c14
-rw-r--r--drivers/usb/chipidea/otg.c5
-rw-r--r--drivers/usb/chipidea/otg.h5
-rw-r--r--drivers/usb/chipidea/otg_fsm.c5
-rw-r--r--drivers/usb/chipidea/otg_fsm.h5
-rw-r--r--drivers/usb/chipidea/udc.c9
-rw-r--r--drivers/usb/chipidea/udc.h5
-rw-r--r--drivers/usb/chipidea/ulpi.c10
-rw-r--r--drivers/usb/chipidea/usbmisc_imx.c8
-rw-r--r--drivers/usb/class/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c15
-rw-r--r--drivers/usb/class/cdc-wdm.c1
-rw-r--r--drivers/usb/class/usblp.c17
-rw-r--r--drivers/usb/class/usbtmc.c15
-rw-r--r--drivers/usb/common/common.c5
-rw-r--r--drivers/usb/common/led.c6
-rw-r--r--drivers/usb/common/ulpi.c5
-rw-r--r--drivers/usb/common/usb-otg-fsm.c15
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/config.c2
-rw-r--r--drivers/usb/core/devices.c15
-rw-r--r--drivers/usb/core/devio.c29
-rw-r--r--drivers/usb/core/driver.c16
-rw-r--r--drivers/usb/core/endpoint.c2
-rw-r--r--drivers/usb/core/file.c2
-rw-r--r--drivers/usb/core/generic.c2
-rw-r--r--drivers/usb/core/hcd-pci.c15
-rw-r--r--drivers/usb/core/hcd.c19
-rw-r--r--drivers/usb/core/hub.c23
-rw-r--r--drivers/usb/core/hub.h10
-rw-r--r--drivers/usb/core/ledtrig-usbport.c5
-rw-r--r--drivers/usb/core/message.c53
-rw-r--r--drivers/usb/core/notify.c2
-rw-r--r--drivers/usb/core/of.c13
-rw-r--r--drivers/usb/core/otg_whitelist.h6
-rw-r--r--drivers/usb/core/port.c11
-rw-r--r--drivers/usb/core/quirks.c16
-rw-r--r--drivers/usb/core/sysfs.c5
-rw-r--r--drivers/usb/core/urb.c3
-rw-r--r--drivers/usb/core/usb-acpi.c6
-rw-r--r--drivers/usb/core/usb.c2
-rw-r--r--drivers/usb/core/usb.h3
-rw-r--r--drivers/usb/dwc2/core.c1
-rw-r--r--drivers/usb/dwc2/core.h5
-rw-r--r--drivers/usb/dwc2/core_intr.c1
-rw-r--r--drivers/usb/dwc2/debug.h10
-rw-r--r--drivers/usb/dwc2/debugfs.c10
-rw-r--r--drivers/usb/dwc2/gadget.c12
-rw-r--r--drivers/usb/dwc2/hcd.c13
-rw-r--r--drivers/usb/dwc2/hcd.h1
-rw-r--r--drivers/usb/dwc2/hcd_ddma.c1
-rw-r--r--drivers/usb/dwc2/hcd_intr.c1
-rw-r--r--drivers/usb/dwc2/hcd_queue.c1
-rw-r--r--drivers/usb/dwc2/hw.h1
-rw-r--r--drivers/usb/dwc2/params.c15
-rw-r--r--drivers/usb/dwc2/pci.c1
-rw-r--r--drivers/usb/dwc2/platform.c1
-rw-r--r--drivers/usb/dwc3/core.c74
-rw-r--r--drivers/usb/dwc3/core.h12
-rw-r--r--drivers/usb/dwc3/debug.h10
-rw-r--r--drivers/usb/dwc3/debugfs.c10
-rw-r--r--drivers/usb/dwc3/drd.c13
-rw-r--r--drivers/usb/dwc3/dwc3-exynos.c10
-rw-r--r--drivers/usb/dwc3/dwc3-keystone.c10
-rw-r--r--drivers/usb/dwc3/dwc3-of-simple.c39
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c10
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c39
-rw-r--r--drivers/usb/dwc3/dwc3-st.c6
-rw-r--r--drivers/usb/dwc3/ep0.c30
-rw-r--r--drivers/usb/dwc3/gadget.c72
-rw-r--r--drivers/usb/dwc3/gadget.h10
-rw-r--r--drivers/usb/dwc3/host.c10
-rw-r--r--drivers/usb/dwc3/io.h10
-rw-r--r--drivers/usb/dwc3/trace.c10
-rw-r--r--drivers/usb/dwc3/trace.h10
-rw-r--r--drivers/usb/dwc3/ulpi.c5
-rw-r--r--drivers/usb/early/Makefile1
-rw-r--r--drivers/usb/early/ehci-dbgp.c1
-rw-r--r--drivers/usb/early/xhci-dbc.c5
-rw-r--r--drivers/usb/early/xhci-dbc.h11
-rw-r--r--drivers/usb/gadget/composite.c13
-rw-r--r--drivers/usb/gadget/config.c6
-rw-r--r--drivers/usb/gadget/configfs.c1
-rw-r--r--drivers/usb/gadget/epautoconf.c6
-rw-r--r--drivers/usb/gadget/function/f_acm.c5
-rw-r--r--drivers/usb/gadget/function/f_ecm.c6
-rw-r--r--drivers/usb/gadget/function/f_eem.c6
-rw-r--r--drivers/usb/gadget/function/f_fs.c7
-rw-r--r--drivers/usb/gadget/function/f_hid.c6
-rw-r--r--drivers/usb/gadget/function/f_loopback.c6
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c1
-rw-r--r--drivers/usb/gadget/function/f_midi.c3
-rw-r--r--drivers/usb/gadget/function/f_ncm.c6
-rw-r--r--drivers/usb/gadget/function/f_obex.c6
-rw-r--r--drivers/usb/gadget/function/f_phonet.c7
-rw-r--r--drivers/usb/gadget/function/f_printer.c6
-rw-r--r--drivers/usb/gadget/function/f_rndis.c6
-rw-r--r--drivers/usb/gadget/function/f_serial.c5
-rw-r--r--drivers/usb/gadget/function/f_sourcesink.c6
-rw-r--r--drivers/usb/gadget/function/f_subset.c6
-rw-r--r--drivers/usb/gadget/function/f_tcm.c3
-rw-r--r--drivers/usb/gadget/function/f_uac1.c6
-rw-r--r--drivers/usb/gadget/function/f_uac1_legacy.c3
-rw-r--r--drivers/usb/gadget/function/f_uac2.c6
-rw-r--r--drivers/usb/gadget/function/f_uvc.c6
-rw-r--r--drivers/usb/gadget/function/f_uvc.h6
-rw-r--r--drivers/usb/gadget/function/rndis.c5
-rw-r--r--drivers/usb/gadget/function/rndis.h5
-rw-r--r--drivers/usb/gadget/function/storage_common.c6
-rw-r--r--drivers/usb/gadget/function/u_audio.c11
-rw-r--r--drivers/usb/gadget/function/u_audio.h12
-rw-r--r--drivers/usb/gadget/function/u_ecm.h5
-rw-r--r--drivers/usb/gadget/function/u_eem.h5
-rw-r--r--drivers/usb/gadget/function/u_ether.c6
-rw-r--r--drivers/usb/gadget/function/u_ether.h6
-rw-r--r--drivers/usb/gadget/function/u_ether_configfs.h5
-rw-r--r--drivers/usb/gadget/function/u_fs.h5
-rw-r--r--drivers/usb/gadget/function/u_gether.h5
-rw-r--r--drivers/usb/gadget/function/u_hid.h5
-rw-r--r--drivers/usb/gadget/function/u_midi.h5
-rw-r--r--drivers/usb/gadget/function/u_ncm.h5
-rw-r--r--drivers/usb/gadget/function/u_phonet.h5
-rw-r--r--drivers/usb/gadget/function/u_printer.h5
-rw-r--r--drivers/usb/gadget/function/u_rndis.h5
-rw-r--r--drivers/usb/gadget/function/u_serial.c6
-rw-r--r--drivers/usb/gadget/function/u_serial.h5
-rw-r--r--drivers/usb/gadget/function/u_tcm.h5
-rw-r--r--drivers/usb/gadget/function/u_uac1.h5
-rw-r--r--drivers/usb/gadget/function/u_uac1_legacy.c3
-rw-r--r--drivers/usb/gadget/function/u_uac1_legacy.h3
-rw-r--r--drivers/usb/gadget/function/u_uac2.h5
-rw-r--r--drivers/usb/gadget/function/u_uvc.h5
-rw-r--r--drivers/usb/gadget/function/uvc.h6
-rw-r--r--drivers/usb/gadget/function/uvc_configfs.c5
-rw-r--r--drivers/usb/gadget/function/uvc_configfs.h5
-rw-r--r--drivers/usb/gadget/function/uvc_queue.c6
-rw-r--r--drivers/usb/gadget/function/uvc_v4l2.c8
-rw-r--r--drivers/usb/gadget/function/uvc_v4l2.h7
-rw-r--r--drivers/usb/gadget/function/uvc_video.c6
-rw-r--r--drivers/usb/gadget/function/uvc_video.h5
-rw-r--r--drivers/usb/gadget/functions.c1
-rw-r--r--drivers/usb/gadget/legacy/acm_ms.c6
-rw-r--r--drivers/usb/gadget/legacy/audio.c3
-rw-r--r--drivers/usb/gadget/legacy/cdc2.c6
-rw-r--r--drivers/usb/gadget/legacy/dbgp.c1
-rw-r--r--drivers/usb/gadget/legacy/ether.c6
-rw-r--r--drivers/usb/gadget/legacy/g_ffs.c6
-rw-r--r--drivers/usb/gadget/legacy/gmidi.c4
-rw-r--r--drivers/usb/gadget/legacy/hid.c6
-rw-r--r--drivers/usb/gadget/legacy/inode.c6
-rw-r--r--drivers/usb/gadget/legacy/mass_storage.c6
-rw-r--r--drivers/usb/gadget/legacy/multi.c6
-rw-r--r--drivers/usb/gadget/legacy/ncm.c6
-rw-r--r--drivers/usb/gadget/legacy/nokia.c5
-rw-r--r--drivers/usb/gadget/legacy/printer.c6
-rw-r--r--drivers/usb/gadget/legacy/serial.c5
-rw-r--r--drivers/usb/gadget/legacy/tcm_usb_gadget.c2
-rw-r--r--drivers/usb/gadget/legacy/webcam.c6
-rw-r--r--drivers/usb/gadget/legacy/zero.c14
-rw-r--r--drivers/usb/gadget/u_f.c5
-rw-r--r--drivers/usb/gadget/u_f.h5
-rw-r--r--drivers/usb/gadget/u_os_desc.h5
-rw-r--r--drivers/usb/gadget/udc/amd5536udc.h6
-rw-r--r--drivers/usb/gadget/udc/amd5536udc_pci.c6
-rw-r--r--drivers/usb/gadget/udc/at91_udc.c6
-rw-r--r--drivers/usb/gadget/udc/at91_udc.h6
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c5
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.h5
-rw-r--r--drivers/usb/gadget/udc/bcm63xx_udc.c6
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc.h7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_cmd.c7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_cmd.h7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_core.c7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_dbg.c7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_dbg.h7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_ep.c7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_ep.h7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_pci.c7
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_udc.c7
-rw-r--r--drivers/usb/gadget/udc/core.c15
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c82
-rw-r--r--drivers/usb/gadget/udc/fotg210-udc.c5
-rw-r--r--drivers/usb/gadget/udc/fotg210.h6
-rw-r--r--drivers/usb/gadget/udc/fsl_mxc_udc.c6
-rw-r--r--drivers/usb/gadget/udc/fsl_qe_udc.c6
-rw-r--r--drivers/usb/gadget/udc/fsl_qe_udc.h6
-rw-r--r--drivers/usb/gadget/udc/fsl_udc_core.c6
-rw-r--r--drivers/usb/gadget/udc/fsl_usb2_udc.h6
-rw-r--r--drivers/usb/gadget/udc/fusb300_udc.c5
-rw-r--r--drivers/usb/gadget/udc/fusb300_udc.h5
-rw-r--r--drivers/usb/gadget/udc/goku_udc.c19
-rw-r--r--drivers/usb/gadget/udc/goku_udc.h5
-rw-r--r--drivers/usb/gadget/udc/gr_udc.c8
-rw-r--r--drivers/usb/gadget/udc/gr_udc.h6
-rw-r--r--drivers/usb/gadget/udc/lpc32xx_udc.c15
-rw-r--r--drivers/usb/gadget/udc/m66592-udc.c9
-rw-r--r--drivers/usb/gadget/udc/m66592-udc.h5
-rw-r--r--drivers/usb/gadget/udc/mv_u3d.h5
-rw-r--r--drivers/usb/gadget/udc/mv_u3d_core.c5
-rw-r--r--drivers/usb/gadget/udc/mv_udc.h6
-rw-r--r--drivers/usb/gadget/udc/mv_udc_core.c6
-rw-r--r--drivers/usb/gadget/udc/net2272.c15
-rw-r--r--drivers/usb/gadget/udc/net2272.h15
-rw-r--r--drivers/usb/gadget/udc/net2280.c6
-rw-r--r--drivers/usb/gadget/udc/net2280.h6
-rw-r--r--drivers/usb/gadget/udc/omap_udc.c6
-rw-r--r--drivers/usb/gadget/udc/pch_udc.c5
-rw-r--r--drivers/usb/gadget/udc/pxa25x_udc.c10
-rw-r--r--drivers/usb/gadget/udc/pxa25x_udc.h7
-rw-r--r--drivers/usb/gadget/udc/pxa27x_udc.c6
-rw-r--r--drivers/usb/gadget/udc/pxa27x_udc.h6
-rw-r--r--drivers/usb/gadget/udc/r8a66597-udc.c9
-rw-r--r--drivers/usb/gadget/udc/r8a66597-udc.h5
-rw-r--r--drivers/usb/gadget/udc/renesas_usb3.c80
-rw-r--r--drivers/usb/gadget/udc/s3c-hsudc.c7
-rw-r--r--drivers/usb/gadget/udc/s3c2410_udc.c6
-rw-r--r--drivers/usb/gadget/udc/s3c2410_udc.h6
-rw-r--r--drivers/usb/gadget/udc/snps_udc_core.c29
-rw-r--r--drivers/usb/gadget/udc/snps_udc_plat.c10
-rw-r--r--drivers/usb/gadget/udc/trace.c10
-rw-r--r--drivers/usb/gadget/udc/trace.h13
-rw-r--r--drivers/usb/gadget/udc/udc-xilinx.c7
-rw-r--r--drivers/usb/gadget/usbstring.c6
-rw-r--r--drivers/usb/host/Kconfig16
-rw-r--r--drivers/usb/host/Makefile5
-rw-r--r--drivers/usb/host/bcma-hcd.c3
-rw-r--r--drivers/usb/host/ehci-atmel.c8
-rw-r--r--drivers/usb/host/ehci-dbg.c12
-rw-r--r--drivers/usb/host/ehci-exynos.c7
-rw-r--r--drivers/usb/host/ehci-fsl.c15
-rw-r--r--drivers/usb/host/ehci-fsl.h15
-rw-r--r--drivers/usb/host/ehci-grlib.c15
-rw-r--r--drivers/usb/host/ehci-hcd.c17
-rw-r--r--drivers/usb/host/ehci-hub.c15
-rw-r--r--drivers/usb/host/ehci-mem.c15
-rw-r--r--drivers/usb/host/ehci-msm.c265
-rw-r--r--drivers/usb/host/ehci-mv.c6
-rw-r--r--drivers/usb/host/ehci-mxc.c15
-rw-r--r--drivers/usb/host/ehci-omap.c16
-rw-r--r--drivers/usb/host/ehci-orion.c5
-rw-r--r--drivers/usb/host/ehci-pci.c15
-rw-r--r--drivers/usb/host/ehci-platform.c38
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c6
-rw-r--r--drivers/usb/host/ehci-ppc-of.c1
-rw-r--r--drivers/usb/host/ehci-ps3.c14
-rw-r--r--drivers/usb/host/ehci-q.c15
-rw-r--r--drivers/usb/host/ehci-sched.c15
-rw-r--r--drivers/usb/host/ehci-sh.c5
-rw-r--r--drivers/usb/host/ehci-spear.c5
-rw-r--r--drivers/usb/host/ehci-st.c5
-rw-r--r--drivers/usb/host/ehci-sysfs.c15
-rw-r--r--drivers/usb/host/ehci-tegra.c12
-rw-r--r--drivers/usb/host/ehci-tilegx.c11
-rw-r--r--drivers/usb/host/ehci-timer.c11
-rw-r--r--drivers/usb/host/ehci-w90x900.c6
-rw-r--r--drivers/usb/host/ehci-xilinx-of.c16
-rw-r--r--drivers/usb/host/ehci.h15
-rw-r--r--drivers/usb/host/fhci-dbg.c6
-rw-r--r--drivers/usb/host/fhci-hcd.c6
-rw-r--r--drivers/usb/host/fhci-hub.c6
-rw-r--r--drivers/usb/host/fhci-mem.c6
-rw-r--r--drivers/usb/host/fhci-q.c6
-rw-r--r--drivers/usb/host/fhci-sched.c6
-rw-r--r--drivers/usb/host/fhci-tds.c6
-rw-r--r--drivers/usb/host/fhci.h6
-rw-r--r--drivers/usb/host/fotg210-hcd.c17
-rw-r--r--drivers/usb/host/fsl-mph-dr-of.c6
-rw-r--r--drivers/usb/host/hwa-hc.c16
-rw-r--r--drivers/usb/host/imx21-dbg.c15
-rw-r--r--drivers/usb/host/imx21-hcd.c15
-rw-r--r--drivers/usb/host/imx21-hcd.h15
-rw-r--r--drivers/usb/host/isp116x-hcd.c4
-rw-r--r--drivers/usb/host/isp1362-hcd.c5
-rw-r--r--drivers/usb/host/max3421-hcd.c81
-rw-r--r--drivers/usb/host/ohci-at91.c1
-rw-r--r--drivers/usb/host/ohci-da8xx.c5
-rw-r--r--drivers/usb/host/ohci-dbg.c1
-rw-r--r--drivers/usb/host/ohci-exynos.c7
-rw-r--r--drivers/usb/host/ohci-hcd.c3
-rw-r--r--drivers/usb/host/ohci-hub.c1
-rw-r--r--drivers/usb/host/ohci-mem.c1
-rw-r--r--drivers/usb/host/ohci-nxp.c6
-rw-r--r--drivers/usb/host/ohci-omap.c1
-rw-r--r--drivers/usb/host/ohci-pci.c1
-rw-r--r--drivers/usb/host/ohci-platform.c40
-rw-r--r--drivers/usb/host/ohci-ppc-of.c1
-rw-r--r--drivers/usb/host/ohci-ps3.c14
-rw-r--r--drivers/usb/host/ohci-pxa27x.c1
-rw-r--r--drivers/usb/host/ohci-q.c1
-rw-r--r--drivers/usb/host/ohci-s3c2410.c1
-rw-r--r--drivers/usb/host/ohci-sa1111.c26
-rw-r--r--drivers/usb/host/ohci-sm501.c1
-rw-r--r--drivers/usb/host/ohci-spear.c5
-rw-r--r--drivers/usb/host/ohci-st.c5
-rw-r--r--drivers/usb/host/ohci-tilegx.c11
-rw-r--r--drivers/usb/host/ohci-tmio.c5
-rw-r--r--drivers/usb/host/ohci.h1
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c17
-rw-r--r--drivers/usb/host/pci-quirks.c3
-rw-r--r--drivers/usb/host/r8a66597-hcd.c42
-rw-r--r--drivers/usb/host/r8a66597.h26
-rw-r--r--drivers/usb/host/sl811-hcd.c1
-rw-r--r--drivers/usb/host/sl811_cs.c1
-rw-r--r--drivers/usb/host/ssb-hcd.c3
-rw-r--r--drivers/usb/host/u132-hcd.c6
-rw-r--r--drivers/usb/host/uhci-hcd.c1
-rw-r--r--drivers/usb/host/whci/asl.c13
-rw-r--r--drivers/usb/host/whci/debug.c13
-rw-r--r--drivers/usb/host/whci/hcd.c13
-rw-r--r--drivers/usb/host/whci/hw.c13
-rw-r--r--drivers/usb/host/whci/init.c13
-rw-r--r--drivers/usb/host/whci/int.c13
-rw-r--r--drivers/usb/host/whci/pzl.c13
-rw-r--r--drivers/usb/host/whci/qset.c13
-rw-r--r--drivers/usb/host/whci/whcd.h15
-rw-r--r--drivers/usb/host/whci/whci-hc.h15
-rw-r--r--drivers/usb/host/whci/wusb.c13
-rw-r--r--drivers/usb/host/xhci-dbg.c14
-rw-r--r--drivers/usb/host/xhci-debugfs.c523
-rw-r--r--drivers/usb/host/xhci-debugfs.h134
-rw-r--r--drivers/usb/host/xhci-ext-caps.h14
-rw-r--r--drivers/usb/host/xhci-hub.c20
-rw-r--r--drivers/usb/host/xhci-mem.c24
-rw-r--r--drivers/usb/host/xhci-mtk-sch.c14
-rw-r--r--drivers/usb/host/xhci-mtk.c144
-rw-r--r--drivers/usb/host/xhci-mtk.h16
-rw-r--r--drivers/usb/host/xhci-mvebu.c5
-rw-r--r--drivers/usb/host/xhci-mvebu.h5
-rw-r--r--drivers/usb/host/xhci-pci.c14
-rw-r--r--drivers/usb/host/xhci-plat.c16
-rw-r--r--drivers/usb/host/xhci-plat.h5
-rw-r--r--drivers/usb/host/xhci-rcar.c5
-rw-r--r--drivers/usb/host/xhci-rcar.h5
-rw-r--r--drivers/usb/host/xhci-ring.c35
-rw-r--r--drivers/usb/host/xhci-tegra.c9
-rw-r--r--drivers/usb/host/xhci-trace.c5
-rw-r--r--drivers/usb/host/xhci-trace.h10
-rw-r--r--drivers/usb/host/xhci.c103
-rw-r--r--drivers/usb/host/xhci.h34
-rw-r--r--drivers/usb/image/Makefile1
-rw-r--r--drivers/usb/image/mdc800.c16
-rw-r--r--drivers/usb/image/microtek.c1
-rw-r--r--drivers/usb/isp1760/Makefile1
-rw-r--r--drivers/usb/isp1760/isp1760-core.c5
-rw-r--r--drivers/usb/isp1760/isp1760-core.h5
-rw-r--r--drivers/usb/isp1760/isp1760-hcd.c8
-rw-r--r--drivers/usb/isp1760/isp1760-regs.h5
-rw-r--r--drivers/usb/isp1760/isp1760-udc.c12
-rw-r--r--drivers/usb/isp1760/isp1760-udc.h5
-rw-r--r--drivers/usb/misc/Kconfig4
-rw-r--r--drivers/usb/misc/adutux.c8
-rw-r--r--drivers/usb/misc/appledisplay.c15
-rw-r--r--drivers/usb/misc/chaoskey.c10
-rw-r--r--drivers/usb/misc/cypress_cy7c63.c5
-rw-r--r--drivers/usb/misc/cytherm.c6
-rw-r--r--drivers/usb/misc/ehset.c10
-rw-r--r--drivers/usb/misc/emi26.c5
-rw-r--r--drivers/usb/misc/emi62.c5
-rw-r--r--drivers/usb/misc/ezusb.c5
-rw-r--r--drivers/usb/misc/ftdi-elan.c6
-rw-r--r--drivers/usb/misc/idmouse.c6
-rw-r--r--drivers/usb/misc/iowarrior.c1
-rw-r--r--drivers/usb/misc/isight_firmware.c5
-rw-r--r--drivers/usb/misc/ldusb.c6
-rw-r--r--drivers/usb/misc/legousbtower.c6
-rw-r--r--drivers/usb/misc/lvstest.c5
-rw-r--r--drivers/usb/misc/rio500.c15
-rw-r--r--drivers/usb/misc/rio500_usb.h19
-rw-r--r--drivers/usb/misc/sisusbvga/Makefile1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.h1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_con.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_init.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_init.h1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_struct.h1
-rw-r--r--drivers/usb/misc/trancevibrator.c15
-rw-r--r--drivers/usb/misc/usb251xb.c177
-rw-r--r--drivers/usb/misc/usb3503.c15
-rw-r--r--drivers/usb/misc/usb4604.c11
-rw-r--r--drivers/usb/misc/usb_u132.h6
-rw-r--r--drivers/usb/misc/usblcd.c1
-rw-r--r--drivers/usb/misc/usbsevseg.c6
-rw-r--r--drivers/usb/misc/usbtest.c11
-rw-r--r--drivers/usb/misc/uss720.c15
-rw-r--r--drivers/usb/misc/yurex.c6
-rw-r--r--drivers/usb/mon/Makefile1
-rw-r--r--drivers/usb/mon/mon_main.c1
-rw-r--r--drivers/usb/mtu3/mtu3.h59
-rw-r--r--drivers/usb/mtu3/mtu3_core.c72
-rw-r--r--drivers/usb/mtu3/mtu3_dr.c72
-rw-r--r--drivers/usb/mtu3/mtu3_dr.h17
-rw-r--r--drivers/usb/mtu3/mtu3_gadget.c14
-rw-r--r--drivers/usb/mtu3/mtu3_gadget_ep0.c27
-rw-r--r--drivers/usb/mtu3/mtu3_host.c89
-rw-r--r--drivers/usb/mtu3/mtu3_hw_regs.h24
-rw-r--r--drivers/usb/mtu3/mtu3_plat.c176
-rw-r--r--drivers/usb/mtu3/mtu3_qmu.c113
-rw-r--r--drivers/usb/mtu3/mtu3_qmu.h11
-rw-r--r--drivers/usb/musb/am35x.c42
-rw-r--r--drivers/usb/musb/blackfin.c16
-rw-r--r--drivers/usb/musb/blackfin.h8
-rw-r--r--drivers/usb/musb/cppi_dma.c1
-rw-r--r--drivers/usb/musb/da8xx.c47
-rw-r--r--drivers/usb/musb/davinci.c38
-rw-r--r--drivers/usb/musb/davinci.h6
-rw-r--r--drivers/usb/musb/jz4740.c10
-rw-r--r--drivers/usb/musb/musb_am335x.c1
-rw-r--r--drivers/usb/musb/musb_core.c34
-rw-r--r--drivers/usb/musb/musb_core.h28
-rw-r--r--drivers/usb/musb/musb_cppi41.c1
-rw-r--r--drivers/usb/musb/musb_debug.h27
-rw-r--r--drivers/usb/musb/musb_debugfs.c27
-rw-r--r--drivers/usb/musb/musb_dma.h27
-rw-r--r--drivers/usb/musb/musb_dsps.c35
-rw-r--r--drivers/usb/musb/musb_gadget.c27
-rw-r--r--drivers/usb/musb/musb_gadget.h27
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c27
-rw-r--r--drivers/usb/musb/musb_host.c27
-rw-r--r--drivers/usb/musb/musb_host.h27
-rw-r--r--drivers/usb/musb/musb_io.h27
-rw-r--r--drivers/usb/musb/musb_regs.h27
-rw-r--r--drivers/usb/musb/musb_trace.c10
-rw-r--r--drivers/usb/musb/musb_trace.h10
-rw-r--r--drivers/usb/musb/musb_virthub.c27
-rw-r--r--drivers/usb/musb/musbhsdma.c27
-rw-r--r--drivers/usb/musb/musbhsdma.h27
-rw-r--r--drivers/usb/musb/omap2430.c18
-rw-r--r--drivers/usb/musb/omap2430.h6
-rw-r--r--drivers/usb/musb/sunxi.c11
-rw-r--r--drivers/usb/musb/tusb6010.c25
-rw-r--r--drivers/usb/musb/tusb6010.h5
-rw-r--r--drivers/usb/musb/tusb6010_omap.c5
-rw-r--r--drivers/usb/musb/ux500.c15
-rw-r--r--drivers/usb/musb/ux500_dma.c14
-rw-r--r--drivers/usb/phy/Kconfig29
-rw-r--r--drivers/usb/phy/Makefile2
-rw-r--r--drivers/usb/phy/of.c6
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c16
-rw-r--r--drivers/usb/phy/phy-am335x-control.c1
-rw-r--r--drivers/usb/phy/phy-am335x.c1
-rw-r--r--drivers/usb/phy/phy-fsl-usb.c15
-rw-r--r--drivers/usb/phy/phy-fsl-usb.h18
-rw-r--r--drivers/usb/phy/phy-generic.c20
-rw-r--r--drivers/usb/phy/phy-gpio-vbus-usb.c5
-rw-r--r--drivers/usb/phy/phy-isp1301-omap.c26
-rw-r--r--drivers/usb/phy/phy-isp1301.c5
-rw-r--r--drivers/usb/phy/phy-keystone.c11
-rw-r--r--drivers/usb/phy/phy-msm-usb.c2085
-rw-r--r--drivers/usb/phy/phy-mv-usb.c23
-rw-r--r--drivers/usb/phy/phy-mv-usb.h6
-rw-r--r--drivers/usb/phy/phy-mxs-usb.c162
-rw-r--r--drivers/usb/phy/phy-omap-otg.c10
-rw-r--r--drivers/usb/phy/phy-qcom-8x16-usb.c366
-rw-r--r--drivers/usb/phy/phy-tahvo.c15
-rw-r--r--drivers/usb/phy/phy-tegra-usb.c11
-rw-r--r--drivers/usb/phy/phy-twl6030-usb.c15
-rw-r--r--drivers/usb/phy/phy-ulpi-viewport.c11
-rw-r--r--drivers/usb/phy/phy-ulpi.c15
-rw-r--r--drivers/usb/phy/phy.c6
-rw-r--r--drivers/usb/renesas_usbhs/common.c39
-rw-r--r--drivers/usb/renesas_usbhs/common.h11
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c11
-rw-r--r--drivers/usb/renesas_usbhs/fifo.h11
-rw-r--r--drivers/usb/renesas_usbhs/mod.c11
-rw-r--r--drivers/usb/renesas_usbhs/mod.h11
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c11
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c11
-rw-r--r--drivers/usb/renesas_usbhs/pipe.c11
-rw-r--r--drivers/usb/renesas_usbhs/pipe.h11
-rw-r--r--drivers/usb/renesas_usbhs/rcar2.c7
-rw-r--r--drivers/usb/renesas_usbhs/rcar2.h1
-rw-r--r--drivers/usb/renesas_usbhs/rcar3.c54
-rw-r--r--drivers/usb/renesas_usbhs/rcar3.h2
-rw-r--r--drivers/usb/serial/Makefile-keyspan_pda_fw1
-rw-r--r--drivers/usb/serial/aircable.c7
-rw-r--r--drivers/usb/serial/ark3116.c6
-rw-r--r--drivers/usb/serial/belkin_sa.c6
-rw-r--r--drivers/usb/serial/belkin_sa.h6
-rw-r--r--drivers/usb/serial/bus.c5
-rw-r--r--drivers/usb/serial/ch341.c7
-rw-r--r--drivers/usb/serial/console.c5
-rw-r--r--drivers/usb/serial/cp210x.c7
-rw-r--r--drivers/usb/serial/cyberjack.c6
-rw-r--r--drivers/usb/serial/cypress_m8.c6
-rw-r--r--drivers/usb/serial/digi_acceleport.c6
-rw-r--r--drivers/usb/serial/empeg.c7
-rw-r--r--drivers/usb/serial/f81232.c6
-rw-r--r--drivers/usb/serial/f81534.c96
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/serial/garmin_gps.c82
-rw-r--r--drivers/usb/serial/generic.c5
-rw-r--r--drivers/usb/serial/io_16654.h5
-rw-r--r--drivers/usb/serial/io_edgeport.c6
-rw-r--r--drivers/usb/serial/io_edgeport.h7
-rw-r--r--drivers/usb/serial/io_ionsp.h6
-rw-r--r--drivers/usb/serial/io_ti.c6
-rw-r--r--drivers/usb/serial/io_ti.h7
-rw-r--r--drivers/usb/serial/io_usbvend.h5
-rw-r--r--drivers/usb/serial/ipaq.c6
-rw-r--r--drivers/usb/serial/ipw.c6
-rw-r--r--drivers/usb/serial/ir-usb.c6
-rw-r--r--drivers/usb/serial/iuu_phoenix.c7
-rw-r--r--drivers/usb/serial/iuu_phoenix.h7
-rw-r--r--drivers/usb/serial/keyspan.c6
-rw-r--r--drivers/usb/serial/keyspan_pda.c6
-rw-r--r--drivers/usb/serial/kl5kusb105.c6
-rw-r--r--drivers/usb/serial/kobil_sct.c7
-rw-r--r--drivers/usb/serial/mct_u232.c6
-rw-r--r--drivers/usb/serial/mct_u232.h6
-rw-r--r--drivers/usb/serial/metro-usb.c44
-rw-r--r--drivers/usb/serial/mos7720.c7
-rw-r--r--drivers/usb/serial/mos7840.c15
-rw-r--r--drivers/usb/serial/mxuport.c6
-rw-r--r--drivers/usb/serial/navman.c7
-rw-r--r--drivers/usb/serial/omninet.c7
-rw-r--r--drivers/usb/serial/opticon.c7
-rw-r--r--drivers/usb/serial/option.c7
-rw-r--r--drivers/usb/serial/oti6858.c7
-rw-r--r--drivers/usb/serial/oti6858.h6
-rw-r--r--drivers/usb/serial/pl2303.c7
-rw-r--r--drivers/usb/serial/pl2303.h7
-rw-r--r--drivers/usb/serial/qcaux.c7
-rw-r--r--drivers/usb/serial/qcserial.c7
-rw-r--r--drivers/usb/serial/quatech2.c8
-rw-r--r--drivers/usb/serial/safe_serial.c6
-rw-r--r--drivers/usb/serial/sierra.c7
-rw-r--r--drivers/usb/serial/spcp8x5.c6
-rw-r--r--drivers/usb/serial/ssu100.c3
-rw-r--r--drivers/usb/serial/symbolserial.c7
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c6
-rw-r--r--drivers/usb/serial/upd78f0730.c5
-rw-r--r--drivers/usb/serial/usb-serial-simple.c7
-rw-r--r--drivers/usb/serial/usb-serial.c29
-rw-r--r--drivers/usb/serial/usb_debug.c11
-rw-r--r--drivers/usb/serial/usb_wwan.c7
-rw-r--r--drivers/usb/serial/visor.c7
-rw-r--r--drivers/usb/serial/visor.h6
-rw-r--r--drivers/usb/serial/whiteheat.c6
-rw-r--r--drivers/usb/serial/whiteheat.h6
-rw-r--r--drivers/usb/serial/wishbone-serial.c6
-rw-r--r--drivers/usb/serial/xsens_mt.c7
-rw-r--r--drivers/usb/storage/alauda.c15
-rw-r--r--drivers/usb/storage/cypress_atacb.c15
-rw-r--r--drivers/usb/storage/datafab.c15
-rw-r--r--drivers/usb/storage/debug.c15
-rw-r--r--drivers/usb/storage/debug.h15
-rw-r--r--drivers/usb/storage/ene_ub6250.c17
-rw-r--r--drivers/usb/storage/freecom.c15
-rw-r--r--drivers/usb/storage/initializers.c15
-rw-r--r--drivers/usb/storage/initializers.h15
-rw-r--r--drivers/usb/storage/isd200.c15
-rw-r--r--drivers/usb/storage/jumpshot.c15
-rw-r--r--drivers/usb/storage/karma.c15
-rw-r--r--drivers/usb/storage/onetouch.c19
-rw-r--r--drivers/usb/storage/option_ms.c19
-rw-r--r--drivers/usb/storage/protocol.c15
-rw-r--r--drivers/usb/storage/protocol.h15
-rw-r--r--drivers/usb/storage/realtek_cr.c14
-rw-r--r--drivers/usb/storage/scsiglue.c15
-rw-r--r--drivers/usb/storage/scsiglue.h15
-rw-r--r--drivers/usb/storage/sddr09.c15
-rw-r--r--drivers/usb/storage/sddr55.c16
-rw-r--r--drivers/usb/storage/shuttle_usbat.c15
-rw-r--r--drivers/usb/storage/transport.c15
-rw-r--r--drivers/usb/storage/transport.h15
-rw-r--r--drivers/usb/storage/uas.c4
-rw-r--r--drivers/usb/storage/unusual_alauda.h15
-rw-r--r--drivers/usb/storage/unusual_cypress.h15
-rw-r--r--drivers/usb/storage/unusual_datafab.h15
-rw-r--r--drivers/usb/storage/unusual_devs.h15
-rw-r--r--drivers/usb/storage/unusual_ene_ub6250.h18
-rw-r--r--drivers/usb/storage/unusual_freecom.h15
-rw-r--r--drivers/usb/storage/unusual_isd200.h15
-rw-r--r--drivers/usb/storage/unusual_jumpshot.h15
-rw-r--r--drivers/usb/storage/unusual_karma.h15
-rw-r--r--drivers/usb/storage/unusual_onetouch.h15
-rw-r--r--drivers/usb/storage/unusual_realtek.h14
-rw-r--r--drivers/usb/storage/unusual_sddr09.h15
-rw-r--r--drivers/usb/storage/unusual_sddr55.h15
-rw-r--r--drivers/usb/storage/unusual_uas.h15
-rw-r--r--drivers/usb/storage/unusual_usbat.h15
-rw-r--r--drivers/usb/storage/usb.c49
-rw-r--r--drivers/usb/storage/usb.h15
-rw-r--r--drivers/usb/storage/usual-tables.c15
-rw-r--r--drivers/usb/typec/Kconfig15
-rw-r--r--drivers/usb/typec/Makefile2
-rw-r--r--drivers/usb/typec/fusb302/Makefile1
-rw-r--r--drivers/usb/typec/fusb302/fusb302.c11
-rw-r--r--drivers/usb/typec/fusb302/fusb302_reg.h11
-rw-r--r--drivers/usb/typec/tcpm.c14
-rw-r--r--drivers/usb/typec/tps6598x.c473
-rw-r--r--drivers/usb/typec/typec.c5
-rw-r--r--drivers/usb/typec/typec_wcove.c599
-rw-r--r--drivers/usb/typec/ucsi/trace.c1
-rw-r--r--drivers/usb/typec/ucsi/ucsi.c5
-rw-r--r--drivers/usb/typec/ucsi/ucsi_acpi.c5
-rw-r--r--drivers/usb/usb-skeleton.c6
-rw-r--r--drivers/usb/usbip/stub.h16
-rw-r--r--drivers/usb/usbip/stub_dev.c16
-rw-r--r--drivers/usb/usbip/stub_main.c16
-rw-r--r--drivers/usb/usbip/stub_rx.c16
-rw-r--r--drivers/usb/usbip/stub_tx.c16
-rw-r--r--drivers/usb/usbip/usbip_common.c16
-rw-r--r--drivers/usb/usbip/usbip_common.h16
-rw-r--r--drivers/usb/usbip/usbip_event.c16
-rw-r--r--drivers/usb/usbip/vhci.h7
-rw-r--r--drivers/usb/usbip/vhci_hcd.c16
-rw-r--r--drivers/usb/usbip/vhci_rx.c16
-rw-r--r--drivers/usb/usbip/vhci_sysfs.c16
-rw-r--r--drivers/usb/usbip/vhci_tx.c16
-rw-r--r--drivers/usb/usbip/vudc.h16
-rw-r--r--drivers/usb/usbip/vudc_dev.c23
-rw-r--r--drivers/usb/usbip/vudc_main.c14
-rw-r--r--drivers/usb/usbip/vudc_rx.c14
-rw-r--r--drivers/usb/usbip/vudc_sysfs.c16
-rw-r--r--drivers/usb/usbip/vudc_transfer.c20
-rw-r--r--drivers/usb/usbip/vudc_tx.c14
-rw-r--r--drivers/usb/wusbcore/cbaf.c16
-rw-r--r--drivers/usb/wusbcore/crypto.c16
-rw-r--r--drivers/usb/wusbcore/dev-sysfs.c16
-rw-r--r--drivers/usb/wusbcore/devconnect.c16
-rw-r--r--drivers/usb/wusbcore/mmc.c16
-rw-r--r--drivers/usb/wusbcore/pal.c13
-rw-r--r--drivers/usb/wusbcore/reservation.c13
-rw-r--r--drivers/usb/wusbcore/rh.c16
-rw-r--r--drivers/usb/wusbcore/security.c25
-rw-r--r--drivers/usb/wusbcore/wa-hc.c16
-rw-r--r--drivers/usb/wusbcore/wa-hc.h16
-rw-r--r--drivers/usb/wusbcore/wa-nep.c16
-rw-r--r--drivers/usb/wusbcore/wa-rpipe.c16
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c17
-rw-r--r--drivers/usb/wusbcore/wusbhc.c16
-rw-r--r--drivers/usb/wusbcore/wusbhc.h16
-rw-r--r--include/dt-bindings/phy/phy.h1
-rw-r--r--include/linux/extcon-provider.h142
-rw-r--r--include/linux/extcon.h109
-rw-r--r--include/linux/mfd/max77843-private.h5
-rw-r--r--include/linux/mfd/palmas.h2
-rw-r--r--include/linux/phy/phy-qcom-ufs.h3
-rw-r--r--include/linux/phy/phy.h14
-rw-r--r--include/linux/soc/brcmstb/brcmstb.h17
-rw-r--r--include/linux/usb.h16
-rw-r--r--include/linux/usb/association.h1
-rw-r--r--include/linux/usb/audio-v2.h1
-rw-r--r--include/linux/usb/audio.h1
-rw-r--r--include/linux/usb/c67x00.h1
-rw-r--r--include/linux/usb/cdc-wdm.h1
-rw-r--r--include/linux/usb/cdc.h1
-rw-r--r--include/linux/usb/cdc_ncm.h1
-rw-r--r--include/linux/usb/composite.h1
-rw-r--r--include/linux/usb/ehci_def.h1
-rw-r--r--include/linux/usb/ehci_pdriver.h1
-rw-r--r--include/linux/usb/g_hid.h1
-rw-r--r--include/linux/usb/gadget.h6
-rw-r--r--include/linux/usb/gpio_vbus.h1
-rw-r--r--include/linux/usb/hcd.h1
-rw-r--r--include/linux/usb/input.h1
-rw-r--r--include/linux/usb/isp1301.h1
-rw-r--r--include/linux/usb/m66592.h1
-rw-r--r--include/linux/usb/msm_hsusb_hw.h77
-rw-r--r--include/linux/usb/musb-ux500.h1
-rw-r--r--include/linux/usb/net2280.h1
-rw-r--r--include/linux/usb/of.h1
-rw-r--r--include/linux/usb/ohci_pdriver.h1
-rw-r--r--include/linux/usb/otg-fsm.h1
-rw-r--r--include/linux/usb/phy_companion.h1
-rw-r--r--include/linux/usb/quirks.h6
-rw-r--r--include/linux/usb/r8a66597.h1
-rw-r--r--include/linux/usb/renesas_usbhs.h6
-rw-r--r--include/linux/usb/rndis_host.h1
-rw-r--r--include/linux/usb/samsung_usb_phy.h1
-rw-r--r--include/linux/usb/serial.h1
-rw-r--r--include/linux/usb/storage.h1
-rw-r--r--include/linux/usb/tegra_usb_phy.h1
-rw-r--r--include/linux/usb/tilegx.h1
-rw-r--r--include/linux/usb/ulpi.h1
-rw-r--r--include/linux/usb/usb338x.h1
-rw-r--r--include/linux/usb/usbnet.h1
-rw-r--r--include/linux/usb/wusb-wa.h1
-rw-r--r--include/linux/usb/wusb.h1
-rw-r--r--include/linux/usb/xhci-dbgp.h1
-rw-r--r--include/linux/usbdevice_fs.h1
-rw-r--r--include/uapi/linux/usb/ch9.h4
-rw-r--r--tools/usb/usbip/Makefile.am3
764 files changed, 6609 insertions, 9083 deletions
diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
new file mode 100644
index 000000000000..24a0d06acd1d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
@@ -0,0 +1,43 @@
1Broadcom STB USB PHY
2
3Required properties:
4 - compatible: brcm,brcmstb-usb-phy
5 - reg: two offset and length pairs.
6 The first pair specifies a manditory set of memory mapped
7 registers used for general control of the PHY.
8 The second pair specifies optional registers used by some of
9 the SoCs that support USB 3.x
10 - #phy-cells: Shall be 1 as it expects one argument for setting
11 the type of the PHY. Possible values are:
12 - PHY_TYPE_USB2 for USB1.1/2.0 PHY
13 - PHY_TYPE_USB3 for USB3.x PHY
14
15Optional Properties:
16- clocks : clock phandles.
17- clock-names: String, clock name.
18- brcm,ipp: Boolean, Invert Port Power.
19 Possible values are: 0 (Don't invert), 1 (Invert)
20- brcm,ioc: Boolean, Invert Over Current detection.
21 Possible values are: 0 (Don't invert), 1 (Invert)
22NOTE: one or both of the following two properties must be set
23- brcm,has-xhci: Boolean indicating the phy has an XHCI phy.
24- brcm,has-eohci: Boolean indicating the phy has an EHCI/OHCI phy.
25- dr_mode: String, PHY Device mode.
26 Possible values are: "host", "peripheral ", "drd" or "typec-pd"
27 If this property is not defined, the phy will default to "host" mode.
28
29Example:
30
31usbphy_0: usb-phy@f0470200 {
32 reg = <0xf0470200 0xb8>,
33 <0xf0471940 0x6c0>;
34 compatible = "brcm,brcmstb-usb-phy";
35 #phy-cells = <1>;
36 dr_mode = "host"
37 brcm,ioc = <1>;
38 brcm,ipp = <1>;
39 brcm,has-xhci;
40 brcm,has-eohci;
41 clocks = <&usb20>, <&usb30>;
42 clock-names = "sw_usb", "sw_usb3";
43};
diff --git a/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
index 97977cd29a98..0aced97d8092 100644
--- a/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
+++ b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
@@ -27,7 +27,16 @@ Sub-nodes optional properties:
27 This property is not applicable for "brcm,iproc-ns2-sata-phy", 27 This property is not applicable for "brcm,iproc-ns2-sata-phy",
28 "brcm,iproc-nsp-sata-phy" and "brcm,iproc-sr-sata-phy". 28 "brcm,iproc-nsp-sata-phy" and "brcm,iproc-sr-sata-phy".
29 29
30Example: 30- brcm,rxaeq-mode: string that indicates the desired RX equalizer
31 mode, possible values are:
32 "off" (equivalent to not specifying the property)
33 "auto"
34 "manual" (brcm,rxaeq-value is used in that case)
35
36- brcm,rxaeq-value: when 'rxaeq-mode' is set to "manual", provides the RX
37 equalizer value that should be used. Allowed range is 0..63.
38
39Example
31 sata-phy@f0458100 { 40 sata-phy@f0458100 {
32 compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3"; 41 compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3";
33 reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>; 42 reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>;
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
index 91da947ae9b6..eeb9e1874ea6 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
@@ -4,10 +4,13 @@ This file provides information on what the device node for the R-Car generation
42 USB PHY contains. 42 USB PHY contains.
5 5
6Required properties: 6Required properties:
7- compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. 7- compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC.
8 "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC.
9 "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
8 "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. 10 "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
9 "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC. 11 "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC.
10 "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 compatible device. 12 "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 or
13 RZ/G1 compatible device.
11 14
12 When compatible with the generic version, nodes must list the 15 When compatible with the generic version, nodes must list the
13 SoC-specific version corresponding to the platform first 16 SoC-specific version corresponding to the platform first
diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index ace9cce2704a..99b651b33110 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -8,6 +8,8 @@ Required properties:
8 SoC. 8 SoC.
9 "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796 9 "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796
10 SoC. 10 SoC.
11 "renesas,usb2-phy-r8a77995" if the device is a part of an
12 R8A77995 SoC.
11 "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device. 13 "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device.
12 14
13 When compatible with the generic version, nodes must list the 15 When compatible with the generic version, nodes must list the
diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
index fcf199b64d3d..e64d903bcbe8 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -19,6 +19,8 @@ Required properties:
19 configured in FS mode; 19 configured in FS mode;
20 - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs 20 - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs
21 configured in HS mode; 21 configured in HS mode;
22 - "st,stm32f7xx-hsotg": The DWC2 USB HS controller instance in STM32F7xx SoCs
23 configured in HS mode;
22- reg : Should contain 1 register range (address and length) 24- reg : Should contain 1 register range (address and length)
23- interrupts : Should contain 1 interrupt 25- interrupts : Should contain 1 interrupt
24- clocks: clock provider specifier 26- clocks: clock provider specifier
diff --git a/Documentation/devicetree/bindings/usb/maxim,max3421.txt b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
new file mode 100644
index 000000000000..8cdbe0c85188
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
@@ -0,0 +1,26 @@
1Maxim Integrated SPI-based USB 2.0 host controller MAX3421E
2
3Required properties:
4 - compatible: Should be "maxim,max3421"
5 - spi-max-frequency: maximum frequency for this device must not exceed 26 MHz.
6 - reg: chip select number to which this device is connected.
7 - maxim,vbus-en-pin: <GPOUTx ACTIVE_LEVEL>
8 GPOUTx is the number (1-8) of the GPOUT pin of MAX3421E to drive Vbus.
9 ACTIVE_LEVEL is 0 or 1.
10 - interrupts: the interrupt line description for the interrupt controller.
11 The driver configures MAX3421E for active low level triggered interrupts,
12 configure your interrupt line accordingly.
13
14Optional property:
15 - interrupt-parent: the phandle to the associated interrupt controller.
16
17Example:
18
19 usb@0 {
20 compatible = "maxim,max3421";
21 reg = <0>;
22 maxim,vbus-en-pin = <3 1>;
23 spi-max-frequency = <26000000>;
24 interrupt-parent = <&PIC>;
25 interrupts = <42>;
26 };
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
index 5611a2e4ddf0..30595964876a 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
@@ -26,10 +26,11 @@ Required properties:
26 - clocks : a list of phandle + clock-specifier pairs, one for each 26 - clocks : a list of phandle + clock-specifier pairs, one for each
27 entry in clock-names 27 entry in clock-names
28 - clock-names : must contain 28 - clock-names : must contain
29 "sys_ck": for clock of xHCI MAC 29 "sys_ck": controller clock used by normal mode,
30 "ref_ck": for reference clock of xHCI MAC 30 the following ones are optional:
31 "wakeup_deb_p0": for USB wakeup debounce clock of port0 31 "ref_ck": reference clock used by low power mode etc,
32 "wakeup_deb_p1": for USB wakeup debounce clock of port1 32 "mcu_ck": mcu_bus clock for register access,
33 "dma_ck": dma_bus clock for data transfer by DMA
33 34
34 - phys : a list of phandle + phy specifier pairs 35 - phys : a list of phandle + phy specifier pairs
35 36
@@ -38,6 +39,8 @@ Optional properties:
38 mode; 39 mode;
39 - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup 40 - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
40 control register, it depends on "mediatek,wakeup-src". 41 control register, it depends on "mediatek,wakeup-src".
42 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
43 bit1 for u3port1, ... etc;
41 - vbus-supply : reference to the VBUS regulator; 44 - vbus-supply : reference to the VBUS regulator;
42 - usb3-lpm-capable : supports USB3.0 LPM 45 - usb3-lpm-capable : supports USB3.0 LPM
43 - pinctrl-names : a pinctrl state named "default" must be defined 46 - pinctrl-names : a pinctrl state named "default" must be defined
@@ -55,9 +58,7 @@ usb30: usb@11270000 {
55 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, 58 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
56 <&pericfg CLK_PERI_USB0>, 59 <&pericfg CLK_PERI_USB0>,
57 <&pericfg CLK_PERI_USB1>; 60 <&pericfg CLK_PERI_USB1>;
58 clock-names = "sys_ck", "ref_ck", 61 clock-names = "sys_ck", "ref_ck";
59 "wakeup_deb_p0",
60 "wakeup_deb_p1";
61 phys = <&phy_port0 PHY_TYPE_USB3>, 62 phys = <&phy_port0 PHY_TYPE_USB3>,
62 <&phy_port1 PHY_TYPE_USB2>; 63 <&phy_port1 PHY_TYPE_USB2>;
63 vusb33-supply = <&mt6397_vusb_reg>; 64 vusb33-supply = <&mt6397_vusb_reg>;
@@ -89,9 +90,8 @@ Required properties:
89 90
90 - clocks : a list of phandle + clock-specifier pairs, one for each 91 - clocks : a list of phandle + clock-specifier pairs, one for each
91 entry in clock-names 92 entry in clock-names
92 - clock-names : must be 93 - clock-names : must contain "sys_ck", and the following ones are optional:
93 "sys_ck": for clock of xHCI MAC 94 "ref_ck", "mcu_ck" and "dma_ck"
94 "ref_ck": for reference clock of xHCI MAC
95 95
96Optional properties: 96Optional properties:
97 - vbus-supply : reference to the VBUS regulator; 97 - vbus-supply : reference to the VBUS regulator;
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index 49f54767cd21..b2271d8e6b50 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -14,9 +14,9 @@ Required properties:
14 - vusb33-supply : regulator of USB avdd3.3v 14 - vusb33-supply : regulator of USB avdd3.3v
15 - clocks : a list of phandle + clock-specifier pairs, one for each 15 - clocks : a list of phandle + clock-specifier pairs, one for each
16 entry in clock-names 16 entry in clock-names
17 - clock-names : must contain "sys_ck" and "ref_ck" for clock of controller; 17 - clock-names : must contain "sys_ck" for clock of controller,
18 "wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are 18 the following clocks are optional:
19 depends on "mediatek,enable-wakeup" 19 "ref_ck", "mcu_ck" and "dam_ck";
20 - phys : a list of phandle + phy specifier pairs 20 - phys : a list of phandle + phy specifier pairs
21 - dr_mode : should be one of "host", "peripheral" or "otg", 21 - dr_mode : should be one of "host", "peripheral" or "otg",
22 refer to usb/generic.txt 22 refer to usb/generic.txt
@@ -30,9 +30,10 @@ Optional properties:
30 when supports dual-role mode. 30 when supports dual-role mode.
31 - vbus-supply : reference to the VBUS regulator, needed when supports 31 - vbus-supply : reference to the VBUS regulator, needed when supports
32 dual-role mode. 32 dual-role mode.
33 - pinctl-names : a pinctrl state named "default" must be defined, 33 - pinctrl-names : a pinctrl state named "default" is optional, and need be
34 "id_float" and "id_ground" are optinal which depends on 34 defined if auto drd switch is enabled, that means the property dr_mode
35 "mediatek,enable-manual-drd" 35 is set as "otg", and meanwhile the property "mediatek,enable-manual-drd"
36 is not set.
36 - pinctrl-0 : pin control group 37 - pinctrl-0 : pin control group
37 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt 38 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
38 39
@@ -44,6 +45,8 @@ Optional properties:
44 - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode 45 - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode
45 - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup 46 - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
46 control register, it depends on "mediatek,enable-wakeup". 47 control register, it depends on "mediatek,enable-wakeup".
48 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
49 bit1 for u3port1, ... etc;
47 50
48Sub-nodes: 51Sub-nodes:
49The xhci should be added as subnode to mtu3 as shown in the following example 52The xhci should be added as subnode to mtu3 as shown in the following example
@@ -63,9 +66,7 @@ ssusb: usb@11271000 {
63 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, 66 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
64 <&pericfg CLK_PERI_USB0>, 67 <&pericfg CLK_PERI_USB0>,
65 <&pericfg CLK_PERI_USB1>; 68 <&pericfg CLK_PERI_USB1>;
66 clock-names = "sys_ck", "ref_ck", 69 clock-names = "sys_ck", "ref_ck";
67 "wakeup_deb_p0",
68 "wakeup_deb_p1";
69 vusb33-supply = <&mt6397_vusb_reg>; 70 vusb33-supply = <&mt6397_vusb_reg>;
70 vbus-supply = <&usb_p0_vbus>; 71 vbus-supply = <&usb_p0_vbus>;
71 extcon = <&extcon_usb>; 72 extcon = <&extcon_usb>;
diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
index e28025883b79..87a45e2f9b7f 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
@@ -15,6 +15,10 @@ Required properties:
15 - interrupts: Interrupt specifier for the USB3.0 Peripheral 15 - interrupts: Interrupt specifier for the USB3.0 Peripheral
16 - clocks: clock phandle and specifier pair 16 - clocks: clock phandle and specifier pair
17 17
18Optional properties:
19 - phys: phandle + phy specifier pair
20 - phy-names: must be "usb"
21
18Example of R-Car H3 ES1.x: 22Example of R-Car H3 ES1.x:
19 usb3_peri0: usb@ee020000 { 23 usb3_peri0: usb@ee020000 {
20 compatible = "renesas,r8a7795-usb3-peri", 24 compatible = "renesas,r8a7795-usb3-peri",
diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index 9e18e000339e..47394ab788e3 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -3,6 +3,8 @@ Renesas Electronics USBHS driver
3Required properties: 3Required properties:
4 - compatible: Must contain one or more of the following: 4 - compatible: Must contain one or more of the following:
5 5
6 - "renesas,usbhs-r8a7743" for r8a7743 (RZ/G1M) compatible device
7 - "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device
6 - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device 8 - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
7 - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device 9 - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
8 - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device 10 - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device
@@ -10,7 +12,8 @@ Required properties:
10 - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device 12 - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
11 - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device 13 - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
12 - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device 14 - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device
13 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatible device 15 - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device
16 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices
14 - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatible device 17 - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatible device
15 18
16 When compatible with the generic version, nodes must list the 19 When compatible with the generic version, nodes must list the
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60eeabe..ae6e484a8d7c 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,7 @@ Required properties:
26 26
27Optional properties: 27Optional properties:
28 - clocks: reference to a clock 28 - clocks: reference to a clock
29 - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
29 - usb3-lpm-capable: determines if platform is USB3 LPM capable 30 - usb3-lpm-capable: determines if platform is USB3 LPM capable
30 - quirk-broken-port-ped: set if the controller has broken port disable mechanism 31 - quirk-broken-port-ped: set if the controller has broken port disable mechanism
31 32
diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 3957d4edaa74..168ff819e827 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -1,16 +1,17 @@
1Microchip USB 2.0 Hi-Speed Hub Controller 1Microchip USB 2.0 Hi-Speed Hub Controller
2 2
3The device node for the configuration of a Microchip USB251xB/xBi USB 2.0 3The device node for the configuration of a Microchip USB251x/xBi USB 2.0
4Hi-Speed Controller. 4Hi-Speed Controller.
5 5
6Required properties : 6Required properties :
7 - compatible : Should be "microchip,usb251xb" or one of the specific types: 7 - compatible : Should be "microchip,usb251xb" or one of the specific types:
8 "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", 8 "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
9 "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" 9 "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi",
10 - reset-gpios : Should specify the gpio for hub reset 10 "microchip,usb2517", "microchip,usb2517i"
11 - reg : I2C address on the selected bus (default is <0x2C>) 11 - reg : I2C address on the selected bus (default is <0x2C>)
12 12
13Optional properties : 13Optional properties :
14 - reset-gpios : Should specify the gpio for hub reset
14 - skip-config : Skip Hub configuration, but only send the USB-Attach command 15 - skip-config : Skip Hub configuration, but only send the USB-Attach command
15 - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424) 16 - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424)
16 - product-id : Set USB Product ID of the hub (16 bit, default depends on type) 17 - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
@@ -19,29 +20,47 @@ Optional properties :
19 - manufacturer : Set USB Manufacturer string (max 31 characters long) 20 - manufacturer : Set USB Manufacturer string (max 31 characters long)
20 - product : Set USB Product string (max 31 characters long) 21 - product : Set USB Product string (max 31 characters long)
21 - serial : Set USB Serial string (max 31 characters long) 22 - serial : Set USB Serial string (max 31 characters long)
22 - {bus,self}-powered : selects between self- and bus-powered operation (default 23 - {bus,self}-powered : selects between self- and bus-powered operation
23 is self-powered) 24 (boolean, default is self-powered)
24 - disable-hi-speed : disable USB Hi-Speed support 25 - disable-hi-speed : disable USB Hi-Speed support (boolean)
25 - {multi,single}-tt : selects between multi- and single-transaction-translator 26 - {multi,single}-tt : selects between multi- and single-transaction-translator
26 (default is multi-tt) 27 (boolean, default is multi-tt)
27 - disable-eop : disable End of Packet generation in full-speed mode 28 - disable-eop : disable End of Packet generation in full-speed mode (boolean)
28 - {ganged,individual}-sensing : select over-current sense type in self-powered 29 - {ganged,individual}-sensing : select over-current sense type in self-powered
29 mode (default is individual) 30 mode (boolean, default is individual)
30 - {ganged,individual}-port-switching : select port power switching mode 31 - {ganged,individual}-port-switching : select port power switching mode
31 (default is individual) 32 (boolean, default is individual)
32 - dynamic-power-switching : enable auto-switching from self- to bus-powered 33 - dynamic-power-switching : enable auto-switching from self- to bus-powered
33 operation if the local power source is removed or unavailable 34 operation if the local power source is removed or unavailable (boolean)
34 - oc-delay-us : Delay time (in microseconds) for filtering the over-current 35 - oc-delay-us : Delay time (in microseconds) for filtering the over-current
35 sense inputs. Valid values are 100, 4000, 8000 (default) and 16000. If 36 sense inputs. Valid values are 100, 4000, 8000 (default) and 16000. If
36 an invalid value is given, the default is used instead. 37 an invalid value is given, the default is used instead.
37 - compound-device : indicate the hub is part of a compound device 38 - compound-device : indicate the hub is part of a compound device (boolean)
38 - port-mapping-mode : enable port mapping mode 39 - port-mapping-mode : enable port mapping mode (boolean)
40 - led-{usb,speed}-mode : led usb/speed indication mode selection
41 (boolean, default is speed mode)
39 - string-support : enable string descriptor support (required for manufacturer, 42 - string-support : enable string descriptor support (required for manufacturer,
40 product and serial string configuration) 43 product and serial string configuration)
41 - non-removable-ports : Should specify the ports which have a non-removable 44 - non-removable-ports : Should specify the ports which have a non-removable
42 device connected. 45 device connected.
43 - sp-disabled-ports : Specifies the ports which will be self-power disabled 46 - sp-disabled-ports : Specifies the ports which will be self-power disabled
44 - bp-disabled-ports : Specifies the ports which will be bus-power disabled 47 - bp-disabled-ports : Specifies the ports which will be bus-power disabled
48 - sp-max-total-current-microamp: Specifies max current consumed by the hub
49 from VBUS when operating in self-powered hub. It includes the hub
50 silicon along with all associated circuitry including a permanently
51 attached peripheral (range: 0 - 100000 uA, default 1000 uA)
52 - bp-max-total-current-microamp: Specifies max current consumed by the hub
53 from VBUS when operating in self-powered hub. It includes the hub
54 silicon along with all associated circuitry including a permanently
55 attached peripheral (range: 0 - 510000 uA, default 100000 uA)
56 - sp-max-removable-current-microamp: Specifies max current consumed by the hub
57 from VBUS when operating in self-powered hub. It includes the hub
58 silicon along with all associated circuitry excluding a permanently
59 attached peripheral (range: 0 - 100000 uA, default 1000 uA)
60 - bp-max-removable-current-microamp: Specifies max current consumed by the hub
61 from VBUS when operating in self-powered hub. It includes the hub
62 silicon along with all associated circuitry excluding a permanently
63 attached peripheral (range: 0 - 510000 uA, default 100000 uA)
45 - power-on-time-ms : Specifies the time it takes from the time the host 64 - power-on-time-ms : Specifies the time it takes from the time the host
46 initiates the power-on sequence to a port until the port has adequate 65 initiates the power-on sequence to a port until the port has adequate
47 power. The value is given in ms in a 0 - 510 range (default is 100ms). 66 power. The value is given in ms in a 0 - 510 range (default is 100ms).
@@ -56,7 +75,6 @@ Examples:
56 usb2514b@2c { 75 usb2514b@2c {
57 compatible = "microchip,usb2514b"; 76 compatible = "microchip,usb2514b";
58 reg = <0x2c>; 77 reg = <0x2c>;
59 reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
60 vendor-id = /bits/ 16 <0x0000>; 78 vendor-id = /bits/ 16 <0x0000>;
61 product-id = /bits/ 16 <0x0000>; 79 product-id = /bits/ 16 <0x0000>;
62 string-support; 80 string-support;
diff --git a/MAINTAINERS b/MAINTAINERS
index ee5d9d2aabb1..650aa0e0e9d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2896,6 +2896,13 @@ S: Supported
2896F: drivers/gpio/gpio-brcmstb.c 2896F: drivers/gpio/gpio-brcmstb.c
2897F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt 2897F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt
2898 2898
2899BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
2900M: Al Cooper <alcooperx@gmail.com>
2901L: linux-kernel@vger.kernel.org
2902L: bcm-kernel-feedback-list@broadcom.com
2903S: Maintained
2904F: drivers/phy/broadcom/phy-brcm-usb*
2905
2899BROADCOM GENET ETHERNET DRIVER 2906BROADCOM GENET ETHERNET DRIVER
2900M: Florian Fainelli <f.fainelli@gmail.com> 2907M: Florian Fainelli <f.fainelli@gmail.com>
2901L: netdev@vger.kernel.org 2908L: netdev@vger.kernel.org
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index 6f6537ab0a79..3877d86c746a 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -26,7 +26,7 @@
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/iio/consumer.h> 27#include <linux/iio/consumer.h>
28#include <linux/extcon/extcon-adc-jack.h> 28#include <linux/extcon/extcon-adc-jack.h>
29#include <linux/extcon.h> 29#include <linux/extcon-provider.h>
30 30
31/** 31/**
32 * struct adc_jack_data - internal data for adc_jack device driver 32 * struct adc_jack_data - internal data for adc_jack device driver
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index f84da4a17724..da0e9bc4262f 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -27,7 +27,7 @@
27#include <linux/pm_runtime.h> 27#include <linux/pm_runtime.h>
28#include <linux/property.h> 28#include <linux/property.h>
29#include <linux/regulator/consumer.h> 29#include <linux/regulator/consumer.h>
30#include <linux/extcon.h> 30#include <linux/extcon-provider.h>
31 31
32#include <sound/soc.h> 32#include <sound/soc.h>
33 33
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index f4fd03e58e37..981fba56bc18 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -22,7 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/property.h> 23#include <linux/property.h>
24#include <linux/notifier.h> 24#include <linux/notifier.h>
25#include <linux/extcon.h> 25#include <linux/extcon-provider.h>
26#include <linux/regmap.h> 26#include <linux/regmap.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/gpio/consumer.h> 28#include <linux/gpio/consumer.h>
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index ebed22f22d75..ab770adcca7e 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -17,7 +17,7 @@
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 */ 18 */
19 19
20#include <linux/extcon.h> 20#include <linux/extcon-provider.h>
21#include <linux/extcon/extcon-gpio.h> 21#include <linux/extcon/extcon-gpio.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/gpio/consumer.h> 23#include <linux/gpio/consumer.h>
diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index 91a0023074af..7c4bc8c44c3f 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -15,7 +15,7 @@
15 * more details. 15 * more details.
16 */ 16 */
17 17
18#include <linux/extcon.h> 18#include <linux/extcon-provider.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/mfd/intel_soc_pmic.h> 21#include <linux/mfd/intel_soc_pmic.h>
diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index 1a45e745717d..c8691b5a9cb0 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21#include <linux/acpi.h> 21#include <linux/acpi.h>
22#include <linux/extcon.h> 22#include <linux/extcon-provider.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/module.h> 25#include <linux/module.h>
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index f6414b7fa5bc..b871836da8a4 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -23,7 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/mfd/max14577.h> 24#include <linux/mfd/max14577.h>
25#include <linux/mfd/max14577-private.h> 25#include <linux/mfd/max14577-private.h>
26#include <linux/extcon.h> 26#include <linux/extcon-provider.h>
27 27
28#define DELAY_MS_DEFAULT 17000 /* unit: millisecond */ 28#define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
29 29
@@ -204,8 +204,8 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
204static int max14577_muic_set_path(struct max14577_muic_info *info, 204static int max14577_muic_set_path(struct max14577_muic_info *info,
205 u8 val, bool attached) 205 u8 val, bool attached)
206{ 206{
207 int ret = 0;
208 u8 ctrl1, ctrl2 = 0; 207 u8 ctrl1, ctrl2 = 0;
208 int ret;
209 209
210 /* Set open state to path before changing hw path */ 210 /* Set open state to path before changing hw path */
211 ret = max14577_update_reg(info->max14577->regmap, 211 ret = max14577_update_reg(info->max14577->regmap,
diff --git a/drivers/extcon/extcon-max3355.c b/drivers/extcon/extcon-max3355.c
index 533e16a952b8..0aa410836f4e 100644
--- a/drivers/extcon/extcon-max3355.c
+++ b/drivers/extcon/extcon-max3355.c
@@ -9,7 +9,7 @@
9 * may be copied, distributed, and modified under those terms. 9 * may be copied, distributed, and modified under those terms.
10 */ 10 */
11 11
12#include <linux/extcon.h> 12#include <linux/extcon-provider.h>
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/gpio/consumer.h> 14#include <linux/gpio/consumer.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 7a5856809047..643411066ad9 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -26,7 +26,7 @@
26#include <linux/mfd/max77693.h> 26#include <linux/mfd/max77693.h>
27#include <linux/mfd/max77693-common.h> 27#include <linux/mfd/max77693-common.h>
28#include <linux/mfd/max77693-private.h> 28#include <linux/mfd/max77693-private.h>
29#include <linux/extcon.h> 29#include <linux/extcon-provider.h>
30#include <linux/regmap.h> 30#include <linux/regmap.h>
31#include <linux/irqdomain.h> 31#include <linux/irqdomain.h>
32 32
diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index 6e722d552cf1..c9fcd6cd41cb 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -11,7 +11,7 @@
11 * (at your option) any later version. 11 * (at your option) any later version.
12 */ 12 */
13 13
14#include <linux/extcon.h> 14#include <linux/extcon-provider.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
@@ -80,7 +80,7 @@ enum max77843_muic_accessory_type {
80 MAX77843_MUIC_ADC_REMOTE_S12_BUTTON, 80 MAX77843_MUIC_ADC_REMOTE_S12_BUTTON,
81 MAX77843_MUIC_ADC_RESERVED_ACC_1, 81 MAX77843_MUIC_ADC_RESERVED_ACC_1,
82 MAX77843_MUIC_ADC_RESERVED_ACC_2, 82 MAX77843_MUIC_ADC_RESERVED_ACC_2,
83 MAX77843_MUIC_ADC_RESERVED_ACC_3, 83 MAX77843_MUIC_ADC_RESERVED_ACC_3, /* SmartDock */
84 MAX77843_MUIC_ADC_RESERVED_ACC_4, 84 MAX77843_MUIC_ADC_RESERVED_ACC_4,
85 MAX77843_MUIC_ADC_RESERVED_ACC_5, 85 MAX77843_MUIC_ADC_RESERVED_ACC_5,
86 MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2, 86 MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2,
@@ -119,6 +119,7 @@ enum max77843_muic_charger_type {
119 MAX77843_MUIC_CHG_SPECIAL_BIAS, 119 MAX77843_MUIC_CHG_SPECIAL_BIAS,
120 MAX77843_MUIC_CHG_RESERVED, 120 MAX77843_MUIC_CHG_RESERVED,
121 MAX77843_MUIC_CHG_GND, 121 MAX77843_MUIC_CHG_GND,
122 MAX77843_MUIC_CHG_DOCK,
122}; 123};
123 124
124static const unsigned int max77843_extcon_cable[] = { 125static const unsigned int max77843_extcon_cable[] = {
@@ -130,6 +131,7 @@ static const unsigned int max77843_extcon_cable[] = {
130 EXTCON_CHG_USB_FAST, 131 EXTCON_CHG_USB_FAST,
131 EXTCON_CHG_USB_SLOW, 132 EXTCON_CHG_USB_SLOW,
132 EXTCON_DISP_MHL, 133 EXTCON_DISP_MHL,
134 EXTCON_DOCK,
133 EXTCON_JIG, 135 EXTCON_JIG,
134 EXTCON_NONE, 136 EXTCON_NONE,
135}; 137};
@@ -200,7 +202,7 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = {
200}; 202};
201 203
202static int max77843_muic_set_path(struct max77843_muic_info *info, 204static int max77843_muic_set_path(struct max77843_muic_info *info,
203 u8 val, bool attached) 205 u8 val, bool attached, bool nobccomp)
204{ 206{
205 struct max77693_dev *max77843 = info->max77843; 207 struct max77693_dev *max77843 = info->max77843;
206 int ret = 0; 208 int ret = 0;
@@ -210,10 +212,16 @@ static int max77843_muic_set_path(struct max77843_muic_info *info,
210 ctrl1 = val; 212 ctrl1 = val;
211 else 213 else
212 ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN; 214 ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN;
215 if (nobccomp) {
216 /* Disable BC1.2 protocol and force manual switch control */
217 ctrl1 |= MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK;
218 }
213 219
214 ret = regmap_update_bits(max77843->regmap_muic, 220 ret = regmap_update_bits(max77843->regmap_muic,
215 MAX77843_MUIC_REG_CONTROL1, 221 MAX77843_MUIC_REG_CONTROL1,
216 MAX77843_MUIC_CONTROL1_COM_SW, ctrl1); 222 MAX77843_MUIC_CONTROL1_COM_SW |
223 MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK,
224 ctrl1);
217 if (ret < 0) { 225 if (ret < 0) {
218 dev_err(info->dev, "Cannot switch MUIC port\n"); 226 dev_err(info->dev, "Cannot switch MUIC port\n");
219 return ret; 227 return ret;
@@ -240,6 +248,21 @@ static int max77843_muic_set_path(struct max77843_muic_info *info,
240 return 0; 248 return 0;
241} 249}
242 250
251static void max77843_charger_set_otg_vbus(struct max77843_muic_info *info,
252 bool on)
253{
254 struct max77693_dev *max77843 = info->max77843;
255 unsigned int cnfg00;
256
257 if (on)
258 cnfg00 = MAX77843_CHG_OTG_MASK | MAX77843_CHG_BOOST_MASK;
259 else
260 cnfg00 = MAX77843_CHG_ENABLE | MAX77843_CHG_BUCK_MASK;
261
262 regmap_update_bits(max77843->regmap_chg, MAX77843_CHG_REG_CHG_CNFG_00,
263 MAX77843_CHG_MODE_MASK, cnfg00);
264}
265
243static int max77843_muic_get_cable_type(struct max77843_muic_info *info, 266static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
244 enum max77843_muic_cable_group group, bool *attached) 267 enum max77843_muic_cable_group group, bool *attached)
245{ 268{
@@ -288,6 +311,19 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
288 break; 311 break;
289 } 312 }
290 313
314 if (adc == MAX77843_MUIC_ADC_RESERVED_ACC_3) { /* SmartDock */
315 if (chg_type == MAX77843_MUIC_CHG_NONE) {
316 *attached = false;
317 cable_type = info->prev_chg_type;
318 info->prev_chg_type = MAX77843_MUIC_CHG_NONE;
319 } else {
320 *attached = true;
321 cable_type = MAX77843_MUIC_CHG_DOCK;
322 info->prev_chg_type = MAX77843_MUIC_CHG_DOCK;
323 }
324 break;
325 }
326
291 if (chg_type == MAX77843_MUIC_CHG_NONE) { 327 if (chg_type == MAX77843_MUIC_CHG_NONE) {
292 *attached = false; 328 *attached = false;
293 cable_type = info->prev_chg_type; 329 cable_type = info->prev_chg_type;
@@ -350,17 +386,18 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info)
350 case MAX77843_MUIC_GND_USB_HOST_VB: 386 case MAX77843_MUIC_GND_USB_HOST_VB:
351 ret = max77843_muic_set_path(info, 387 ret = max77843_muic_set_path(info,
352 MAX77843_MUIC_CONTROL1_SW_USB, 388 MAX77843_MUIC_CONTROL1_SW_USB,
353 attached); 389 attached, false);
354 if (ret < 0) 390 if (ret < 0)
355 return ret; 391 return ret;
356 392
357 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); 393 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
394 max77843_charger_set_otg_vbus(info, attached);
358 break; 395 break;
359 case MAX77843_MUIC_GND_MHL_VB: 396 case MAX77843_MUIC_GND_MHL_VB:
360 case MAX77843_MUIC_GND_MHL: 397 case MAX77843_MUIC_GND_MHL:
361 ret = max77843_muic_set_path(info, 398 ret = max77843_muic_set_path(info,
362 MAX77843_MUIC_CONTROL1_SW_OPEN, 399 MAX77843_MUIC_CONTROL1_SW_OPEN,
363 attached); 400 attached, false);
364 if (ret < 0) 401 if (ret < 0)
365 return ret; 402 return ret;
366 403
@@ -396,7 +433,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
396 return -EINVAL; 433 return -EINVAL;
397 } 434 }
398 435
399 ret = max77843_muic_set_path(info, path, attached); 436 ret = max77843_muic_set_path(info, path, attached, false);
400 if (ret < 0) 437 if (ret < 0)
401 return ret; 438 return ret;
402 439
@@ -405,6 +442,26 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info,
405 return 0; 442 return 0;
406} 443}
407 444
445static int max77843_muic_dock_handler(struct max77843_muic_info *info,
446 bool attached)
447{
448 int ret;
449
450 dev_dbg(info->dev, "external connector is %s (adc: 0x10)\n",
451 attached ? "attached" : "detached");
452
453 ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB,
454 attached, attached);
455 if (ret < 0)
456 return ret;
457
458 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
459 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
460 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached);
461
462 return 0;
463}
464
408static int max77843_muic_adc_handler(struct max77843_muic_info *info) 465static int max77843_muic_adc_handler(struct max77843_muic_info *info)
409{ 466{
410 int ret, cable_type; 467 int ret, cable_type;
@@ -419,6 +476,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
419 info->prev_cable_type); 476 info->prev_cable_type);
420 477
421 switch (cable_type) { 478 switch (cable_type) {
479 case MAX77843_MUIC_ADC_RESERVED_ACC_3: /* SmartDock */
480 ret = max77843_muic_dock_handler(info, attached);
481 if (ret < 0)
482 return ret;
483 break;
422 case MAX77843_MUIC_ADC_GROUND: 484 case MAX77843_MUIC_ADC_GROUND:
423 ret = max77843_muic_adc_gnd_handler(info); 485 ret = max77843_muic_adc_gnd_handler(info);
424 if (ret < 0) 486 if (ret < 0)
@@ -446,7 +508,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info)
446 case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON: 508 case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON:
447 case MAX77843_MUIC_ADC_RESERVED_ACC_1: 509 case MAX77843_MUIC_ADC_RESERVED_ACC_1:
448 case MAX77843_MUIC_ADC_RESERVED_ACC_2: 510 case MAX77843_MUIC_ADC_RESERVED_ACC_2:
449 case MAX77843_MUIC_ADC_RESERVED_ACC_3:
450 case MAX77843_MUIC_ADC_RESERVED_ACC_4: 511 case MAX77843_MUIC_ADC_RESERVED_ACC_4:
451 case MAX77843_MUIC_ADC_RESERVED_ACC_5: 512 case MAX77843_MUIC_ADC_RESERVED_ACC_5:
452 case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2: 513 case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2:
@@ -490,7 +551,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
490 case MAX77843_MUIC_CHG_USB: 551 case MAX77843_MUIC_CHG_USB:
491 ret = max77843_muic_set_path(info, 552 ret = max77843_muic_set_path(info,
492 MAX77843_MUIC_CONTROL1_SW_USB, 553 MAX77843_MUIC_CONTROL1_SW_USB,
493 attached); 554 attached, false);
494 if (ret < 0) 555 if (ret < 0)
495 return ret; 556 return ret;
496 557
@@ -501,7 +562,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
501 case MAX77843_MUIC_CHG_DOWNSTREAM: 562 case MAX77843_MUIC_CHG_DOWNSTREAM:
502 ret = max77843_muic_set_path(info, 563 ret = max77843_muic_set_path(info,
503 MAX77843_MUIC_CONTROL1_SW_OPEN, 564 MAX77843_MUIC_CONTROL1_SW_OPEN,
504 attached); 565 attached, false);
505 if (ret < 0) 566 if (ret < 0)
506 return ret; 567 return ret;
507 568
@@ -511,7 +572,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
511 case MAX77843_MUIC_CHG_DEDICATED: 572 case MAX77843_MUIC_CHG_DEDICATED:
512 ret = max77843_muic_set_path(info, 573 ret = max77843_muic_set_path(info,
513 MAX77843_MUIC_CONTROL1_SW_OPEN, 574 MAX77843_MUIC_CONTROL1_SW_OPEN,
514 attached); 575 attached, false);
515 if (ret < 0) 576 if (ret < 0)
516 return ret; 577 return ret;
517 578
@@ -521,7 +582,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
521 case MAX77843_MUIC_CHG_SPECIAL_500MA: 582 case MAX77843_MUIC_CHG_SPECIAL_500MA:
522 ret = max77843_muic_set_path(info, 583 ret = max77843_muic_set_path(info,
523 MAX77843_MUIC_CONTROL1_SW_OPEN, 584 MAX77843_MUIC_CONTROL1_SW_OPEN,
524 attached); 585 attached, false);
525 if (ret < 0) 586 if (ret < 0)
526 return ret; 587 return ret;
527 588
@@ -531,7 +592,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
531 case MAX77843_MUIC_CHG_SPECIAL_1A: 592 case MAX77843_MUIC_CHG_SPECIAL_1A:
532 ret = max77843_muic_set_path(info, 593 ret = max77843_muic_set_path(info,
533 MAX77843_MUIC_CONTROL1_SW_OPEN, 594 MAX77843_MUIC_CONTROL1_SW_OPEN,
534 attached); 595 attached, false);
535 if (ret < 0) 596 if (ret < 0)
536 return ret; 597 return ret;
537 598
@@ -550,6 +611,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
550 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, 611 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
551 false); 612 false);
552 break; 613 break;
614 case MAX77843_MUIC_CHG_DOCK:
615 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, attached);
616 break;
553 case MAX77843_MUIC_CHG_NONE: 617 case MAX77843_MUIC_CHG_NONE:
554 break; 618 break;
555 default: 619 default:
@@ -558,7 +622,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info)
558 attached ? "attached" : "detached", chg_type); 622 attached ? "attached" : "detached", chg_type);
559 623
560 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, 624 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN,
561 attached); 625 attached, false);
562 return -EINVAL; 626 return -EINVAL;
563 } 627 }
564 628
@@ -798,7 +862,8 @@ static int max77843_muic_probe(struct platform_device *pdev)
798 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); 862 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS);
799 863
800 /* Set initial path for UART */ 864 /* Set initial path for UART */
801 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true); 865 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true,
866 false);
802 867
803 /* Check revision number of MUIC device */ 868 /* Check revision number of MUIC device */
804 ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); 869 ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id);
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 4a0612fb9c07..8152790d72e1 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -25,7 +25,7 @@
25#include <linux/kobject.h> 25#include <linux/kobject.h>
26#include <linux/mfd/max8997.h> 26#include <linux/mfd/max8997.h>
27#include <linux/mfd/max8997-private.h> 27#include <linux/mfd/max8997-private.h>
28#include <linux/extcon.h> 28#include <linux/extcon-provider.h>
29#include <linux/irqdomain.h> 29#include <linux/irqdomain.h>
30 30
31#define DEV_NAME "max8997-muic" 31#define DEV_NAME "max8997-muic"
diff --git a/drivers/extcon/extcon-qcom-spmi-misc.c b/drivers/extcon/extcon-qcom-spmi-misc.c
index b8cde096a808..660bbf163bf5 100644
--- a/drivers/extcon/extcon-qcom-spmi-misc.c
+++ b/drivers/extcon/extcon-qcom-spmi-misc.c
@@ -15,7 +15,7 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include <linux/extcon.h> 18#include <linux/extcon-provider.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c
index eaa355e7d9e4..e059bd5f2041 100644
--- a/drivers/extcon/extcon-rt8973a.c
+++ b/drivers/extcon/extcon-rt8973a.c
@@ -20,7 +20,7 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/extcon.h> 23#include <linux/extcon-provider.h>
24 24
25#include "extcon-rt8973a.h" 25#include "extcon-rt8973a.h"
26 26
diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
index 106ef0297b53..0cfb5a3efdf6 100644
--- a/drivers/extcon/extcon-sm5502.c
+++ b/drivers/extcon/extcon-sm5502.c
@@ -19,7 +19,7 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regmap.h> 20#include <linux/regmap.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/extcon.h> 22#include <linux/extcon-provider.h>
23 23
24#include "extcon-sm5502.h" 24#include "extcon-sm5502.h"
25 25
diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b05b7aa..53762864a9f7 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -14,7 +14,7 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#include <linux/extcon.h> 17#include <linux/extcon-provider.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/gpio/consumer.h> 19#include <linux/gpio/consumer.h>
20#include <linux/init.h> 20#include <linux/init.h>
diff --git a/drivers/extcon/extcon-usbc-cros-ec.c b/drivers/extcon/extcon-usbc-cros-ec.c
index 598956f1dcae..6187f731b29d 100644
--- a/drivers/extcon/extcon-usbc-cros-ec.c
+++ b/drivers/extcon/extcon-usbc-cros-ec.c
@@ -14,7 +14,7 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#include <linux/extcon.h> 17#include <linux/extcon-provider.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/mfd/cros_ec.h> 19#include <linux/mfd/cros_ec.h>
20#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 35e9fb885486..cb38c2747684 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -36,7 +36,7 @@
36 36
37#define SUPPORTED_CABLE_MAX 32 37#define SUPPORTED_CABLE_MAX 32
38 38
39struct __extcon_info { 39static const struct __extcon_info {
40 unsigned int type; 40 unsigned int type;
41 unsigned int id; 41 unsigned int id;
42 const char *name; 42 const char *name;
diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h
index 61358479bfcc..93b5e0306966 100644
--- a/drivers/extcon/extcon.h
+++ b/drivers/extcon/extcon.h
@@ -2,7 +2,7 @@
2#ifndef __LINUX_EXTCON_INTERNAL_H__ 2#ifndef __LINUX_EXTCON_INTERNAL_H__
3#define __LINUX_EXTCON_INTERNAL_H__ 3#define __LINUX_EXTCON_INTERNAL_H__
4 4
5#include <linux/extcon.h> 5#include <linux/extcon-provider.h>
6 6
7/** 7/**
8 * struct extcon_dev - An extcon device represents one external connector. 8 * struct extcon_dev - An extcon device represents one external connector.
diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
index 34427a6a15af..362607f727ee 100644
--- a/drivers/pci/dwc/pci-dra7xx.c
+++ b/drivers/pci/dwc/pci-dra7xx.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/device.h>
14#include <linux/err.h> 15#include <linux/err.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/irq.h> 17#include <linux/irq.h>
@@ -594,6 +595,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
594 int i; 595 int i;
595 int phy_count; 596 int phy_count;
596 struct phy **phy; 597 struct phy **phy;
598 struct device_link **link;
597 void __iomem *base; 599 void __iomem *base;
598 struct resource *res; 600 struct resource *res;
599 struct dw_pcie *pci; 601 struct dw_pcie *pci;
@@ -649,11 +651,21 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
649 if (!phy) 651 if (!phy)
650 return -ENOMEM; 652 return -ENOMEM;
651 653
654 link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
655 if (!link)
656 return -ENOMEM;
657
652 for (i = 0; i < phy_count; i++) { 658 for (i = 0; i < phy_count; i++) {
653 snprintf(name, sizeof(name), "pcie-phy%d", i); 659 snprintf(name, sizeof(name), "pcie-phy%d", i);
654 phy[i] = devm_phy_get(dev, name); 660 phy[i] = devm_phy_get(dev, name);
655 if (IS_ERR(phy[i])) 661 if (IS_ERR(phy[i]))
656 return PTR_ERR(phy[i]); 662 return PTR_ERR(phy[i]);
663
664 link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
665 if (!link[i]) {
666 ret = -EINVAL;
667 goto err_link;
668 }
657 } 669 }
658 670
659 dra7xx->base = base; 671 dra7xx->base = base;
@@ -732,6 +744,10 @@ err_get_sync:
732 pm_runtime_disable(dev); 744 pm_runtime_disable(dev);
733 dra7xx_pcie_disable_phy(dra7xx); 745 dra7xx_pcie_disable_phy(dra7xx);
734 746
747err_link:
748 while (--i >= 0)
749 device_link_del(link[i]);
750
735 return ret; 751 return ret;
736} 752}
737 753
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 1161e11fb3cf..aa857be692cf 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -24,7 +24,7 @@
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/extcon.h> 27#include <linux/extcon-provider.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -926,6 +926,7 @@ static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = {
926 .phyctl_offset = REG_PHYCTL_A33, 926 .phyctl_offset = REG_PHYCTL_A33,
927 .dedicated_clocks = true, 927 .dedicated_clocks = true,
928 .enable_pmu_unk1 = true, 928 .enable_pmu_unk1 = true,
929 .phy0_dual_route = true,
929}; 930};
930 931
931static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = { 932static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 64fc59c3ae6d..97d27b0d5cc7 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -67,3 +67,16 @@ config PHY_BRCM_SATA
67 help 67 help
68 Enable this to support the Broadcom SATA PHY. 68 Enable this to support the Broadcom SATA PHY.
69 If unsure, say N. 69 If unsure, say N.
70
71config PHY_BRCM_USB
72 tristate "Broadcom STB USB PHY driver"
73 depends on ARCH_BRCMSTB
74 depends on OF
75 select GENERIC_PHY
76 select SOC_BRCMSTB
77 default ARCH_BRCMSTB
78 help
79 Enable this to support the Broadcom STB USB PHY.
80 This driver is required by the USB XHCI, EHCI and OHCI
81 drivers.
82 If unsure, say N.
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index fdd9ec8fd70b..13e000c1a43a 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -6,3 +6,6 @@ obj-$(CONFIG_PHY_BCM_NS_USB3) += phy-bcm-ns-usb3.o
6obj-$(CONFIG_PHY_NS2_PCIE) += phy-bcm-ns2-pcie.o 6obj-$(CONFIG_PHY_NS2_PCIE) += phy-bcm-ns2-pcie.o
7obj-$(CONFIG_PHY_NS2_USB_DRD) += phy-bcm-ns2-usbdrd.o 7obj-$(CONFIG_PHY_NS2_USB_DRD) += phy-bcm-ns2-usbdrd.o
8obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o 8obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o
9obj-$(CONFIG_PHY_BRCM_USB) += phy-brcm-usb-dvr.o
10
11phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o
diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
index d099a0c8cee5..7ceea5ae2704 100644
--- a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
+++ b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/extcon.h> 15#include <linux/extcon-provider.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/gpio/consumer.h> 17#include <linux/gpio/consumer.h>
18#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/phy/broadcom/phy-brcm-sata.c b/drivers/phy/broadcom/phy-brcm-sata.c
index 9d7f74fe3d7c..3f953db70288 100644
--- a/drivers/phy/broadcom/phy-brcm-sata.c
+++ b/drivers/phy/broadcom/phy-brcm-sata.c
@@ -49,11 +49,29 @@ enum brcm_sata_phy_version {
49 BRCM_SATA_PHY_IPROC_SR, 49 BRCM_SATA_PHY_IPROC_SR,
50}; 50};
51 51
52enum brcm_sata_phy_rxaeq_mode {
53 RXAEQ_MODE_OFF = 0,
54 RXAEQ_MODE_AUTO,
55 RXAEQ_MODE_MANUAL,
56};
57
58static enum brcm_sata_phy_rxaeq_mode rxaeq_to_val(const char *m)
59{
60 if (!strcmp(m, "auto"))
61 return RXAEQ_MODE_AUTO;
62 else if (!strcmp(m, "manual"))
63 return RXAEQ_MODE_MANUAL;
64 else
65 return RXAEQ_MODE_OFF;
66}
67
52struct brcm_sata_port { 68struct brcm_sata_port {
53 int portnum; 69 int portnum;
54 struct phy *phy; 70 struct phy *phy;
55 struct brcm_sata_phy *phy_priv; 71 struct brcm_sata_phy *phy_priv;
56 bool ssc_en; 72 bool ssc_en;
73 enum brcm_sata_phy_rxaeq_mode rxaeq_mode;
74 u32 rxaeq_val;
57}; 75};
58 76
59struct brcm_sata_phy { 77struct brcm_sata_phy {
@@ -93,6 +111,15 @@ enum sata_phy_regs {
93 TX_ACTRL0 = 0x80, 111 TX_ACTRL0 = 0x80,
94 TX_ACTRL0_TXPOL_FLIP = BIT(6), 112 TX_ACTRL0_TXPOL_FLIP = BIT(6),
95 113
114 AEQRX_REG_BANK_0 = 0xd0,
115 AEQ_CONTROL1 = 0x81,
116 AEQ_CONTROL1_ENABLE = BIT(2),
117 AEQ_CONTROL1_FREEZE = BIT(3),
118 AEQ_FRC_EQ = 0x83,
119 AEQ_FRC_EQ_FORCE = BIT(0),
120 AEQ_FRC_EQ_FORCE_VAL = BIT(1),
121 AEQRX_REG_BANK_1 = 0xe0,
122
96 OOB_REG_BANK = 0x150, 123 OOB_REG_BANK = 0x150,
97 OOB1_REG_BANK = 0x160, 124 OOB1_REG_BANK = 0x160,
98 OOB_CTRL1 = 0x80, 125 OOB_CTRL1 = 0x80,
@@ -190,7 +217,7 @@ static u32 brcm_sata_phy_rd(void __iomem *pcb_base, u32 bank, u32 ofs)
190#define STB_FMAX_VAL_DEFAULT 0x3df 217#define STB_FMAX_VAL_DEFAULT 0x3df
191#define STB_FMAX_VAL_SSC 0x83 218#define STB_FMAX_VAL_SSC 0x83
192 219
193static int brcm_stb_sata_init(struct brcm_sata_port *port) 220static void brcm_stb_sata_ssc_init(struct brcm_sata_port *port)
194{ 221{
195 void __iomem *base = brcm_sata_pcb_base(port); 222 void __iomem *base = brcm_sata_pcb_base(port);
196 struct brcm_sata_phy *priv = port->phy_priv; 223 struct brcm_sata_phy *priv = port->phy_priv;
@@ -215,10 +242,47 @@ static int brcm_stb_sata_init(struct brcm_sata_port *port)
215 242
216 brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3, 243 brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3,
217 ~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp); 244 ~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp);
245}
246
247#define AEQ_FRC_EQ_VAL_SHIFT 2
248#define AEQ_FRC_EQ_VAL_MASK 0x3f
249
250static int brcm_stb_sata_rxaeq_init(struct brcm_sata_port *port)
251{
252 void __iomem *base = brcm_sata_pcb_base(port);
253 u32 tmp = 0, reg = 0;
254
255 switch (port->rxaeq_mode) {
256 case RXAEQ_MODE_OFF:
257 return 0;
258
259 case RXAEQ_MODE_AUTO:
260 reg = AEQ_CONTROL1;
261 tmp = AEQ_CONTROL1_ENABLE | AEQ_CONTROL1_FREEZE;
262 break;
263
264 case RXAEQ_MODE_MANUAL:
265 reg = AEQ_FRC_EQ;
266 tmp = AEQ_FRC_EQ_FORCE | AEQ_FRC_EQ_FORCE_VAL;
267 if (port->rxaeq_val > AEQ_FRC_EQ_VAL_MASK)
268 return -EINVAL;
269 tmp |= port->rxaeq_val << AEQ_FRC_EQ_VAL_SHIFT;
270 break;
271 }
272
273 brcm_sata_phy_wr(base, AEQRX_REG_BANK_0, reg, ~tmp, tmp);
274 brcm_sata_phy_wr(base, AEQRX_REG_BANK_1, reg, ~tmp, tmp);
218 275
219 return 0; 276 return 0;
220} 277}
221 278
279static int brcm_stb_sata_init(struct brcm_sata_port *port)
280{
281 brcm_stb_sata_ssc_init(port);
282
283 return brcm_stb_sata_rxaeq_init(port);
284}
285
222/* NS2 SATA PLL1 defaults were characterized by H/W group */ 286/* NS2 SATA PLL1 defaults were characterized by H/W group */
223#define NS2_PLL1_ACTRL2_MAGIC 0x1df8 287#define NS2_PLL1_ACTRL2_MAGIC 0x1df8
224#define NS2_PLL1_ACTRL3_MAGIC 0x2b00 288#define NS2_PLL1_ACTRL3_MAGIC 0x2b00
@@ -463,6 +527,7 @@ MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match);
463 527
464static int brcm_sata_phy_probe(struct platform_device *pdev) 528static int brcm_sata_phy_probe(struct platform_device *pdev)
465{ 529{
530 const char *rxaeq_mode;
466 struct device *dev = &pdev->dev; 531 struct device *dev = &pdev->dev;
467 struct device_node *dn = dev->of_node, *child; 532 struct device_node *dn = dev->of_node, *child;
468 const struct of_device_id *of_id; 533 const struct of_device_id *of_id;
@@ -525,6 +590,13 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
525 port->portnum = id; 590 port->portnum = id;
526 port->phy_priv = priv; 591 port->phy_priv = priv;
527 port->phy = devm_phy_create(dev, child, &phy_ops); 592 port->phy = devm_phy_create(dev, child, &phy_ops);
593 port->rxaeq_mode = RXAEQ_MODE_OFF;
594 if (!of_property_read_string(child, "brcm,rxaeq-mode",
595 &rxaeq_mode))
596 port->rxaeq_mode = rxaeq_to_val(rxaeq_mode);
597 if (port->rxaeq_mode == RXAEQ_MODE_MANUAL)
598 of_property_read_u32(child, "brcm,rxaeq-value",
599 &port->rxaeq_val);
528 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); 600 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc");
529 if (IS_ERR(port->phy)) { 601 if (IS_ERR(port->phy)) {
530 dev_err(dev, "failed to create PHY\n"); 602 dev_err(dev, "failed to create PHY\n");
diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c
new file mode 100644
index 000000000000..1e7ce0b6f299
--- /dev/null
+++ b/drivers/phy/broadcom/phy-brcm-usb-init.c
@@ -0,0 +1,1017 @@
1/*
2 * phy-brcm-usb-init.c - Broadcom USB Phy chip specific init functions
3 *
4 * Copyright (C) 2014-2017 Broadcom
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16/*
17 * This module contains USB PHY initialization for power up and S3 resume
18 */
19
20#include <linux/delay.h>
21#include <linux/io.h>
22
23#include <linux/soc/brcmstb/brcmstb.h>
24#include "phy-brcm-usb-init.h"
25
26#define PHY_PORTS 2
27#define PHY_PORT_SELECT_0 0
28#define PHY_PORT_SELECT_1 0x1000
29
30/* Register definitions for the USB CTRL block */
31#define USB_CTRL_SETUP 0x00
32#define USB_CTRL_SETUP_IOC_MASK 0x00000010
33#define USB_CTRL_SETUP_IPP_MASK 0x00000020
34#define USB_CTRL_SETUP_BABO_MASK 0x00000001
35#define USB_CTRL_SETUP_FNHW_MASK 0x00000002
36#define USB_CTRL_SETUP_FNBO_MASK 0x00000004
37#define USB_CTRL_SETUP_WABO_MASK 0x00000008
38#define USB_CTRL_SETUP_SCB_CLIENT_SWAP_MASK 0x00002000 /* option */
39#define USB_CTRL_SETUP_SCB1_EN_MASK 0x00004000 /* option */
40#define USB_CTRL_SETUP_SCB2_EN_MASK 0x00008000 /* option */
41#define USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK 0X00020000 /* option */
42#define USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK 0x00010000 /* option */
43#define USB_CTRL_SETUP_STRAP_IPP_SEL_MASK 0x02000000 /* option */
44#define USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK 0x04000000 /* option */
45#define USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK 0x08000000 /* opt */
46#define USB_CTRL_SETUP_OC3_DISABLE_MASK 0xc0000000 /* option */
47#define USB_CTRL_PLL_CTL 0x04
48#define USB_CTRL_PLL_CTL_PLL_SUSPEND_EN_MASK 0x08000000
49#define USB_CTRL_PLL_CTL_PLL_RESETB_MASK 0x40000000
50#define USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK 0x80000000 /* option */
51#define USB_CTRL_EBRIDGE 0x0c
52#define USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK 0x00020000 /* option */
53#define USB_CTRL_MDIO 0x14
54#define USB_CTRL_MDIO2 0x18
55#define USB_CTRL_UTMI_CTL_1 0x2c
56#define USB_CTRL_UTMI_CTL_1_POWER_UP_FSM_EN_MASK 0x00000800
57#define USB_CTRL_UTMI_CTL_1_POWER_UP_FSM_EN_P1_MASK 0x08000000
58#define USB_CTRL_USB_PM 0x34
59#define USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK 0x00800000 /* option */
60#define USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK 0x00400000 /* option */
61#define USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK 0x40000000 /* option */
62#define USB_CTRL_USB_PM_USB_PWRDN_MASK 0x80000000 /* option */
63#define USB_CTRL_USB_PM_SOFT_RESET_MASK 0x40000000 /* option */
64#define USB_CTRL_USB_PM_USB20_HC_RESETB_MASK 0x30000000 /* option */
65#define USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK 0x00300000 /* option */
66#define USB_CTRL_USB30_CTL1 0x60
67#define USB_CTRL_USB30_CTL1_PHY3_PLL_SEQ_START_MASK 0x00000010
68#define USB_CTRL_USB30_CTL1_PHY3_RESETB_MASK 0x00010000
69#define USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK 0x00020000 /* option */
70#define USB_CTRL_USB30_CTL1_USB3_IOC_MASK 0x10000000 /* option */
71#define USB_CTRL_USB30_CTL1_USB3_IPP_MASK 0x20000000 /* option */
72#define USB_CTRL_USB30_PCTL 0x70
73#define USB_CTRL_USB30_PCTL_PHY3_SOFT_RESETB_MASK 0x00000002
74#define USB_CTRL_USB30_PCTL_PHY3_SOFT_RESETB_P1_MASK 0x00020000
75#define USB_CTRL_USB_DEVICE_CTL1 0x90
76#define USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK 0x00000003 /* option */
77
78/* Register definitions for the XHCI EC block */
79#define USB_XHCI_EC_IRAADR 0x658
80#define USB_XHCI_EC_IRADAT 0x65c
81
82enum brcm_family_type {
83 BRCM_FAMILY_3390A0,
84 BRCM_FAMILY_7250B0,
85 BRCM_FAMILY_7271A0,
86 BRCM_FAMILY_7364A0,
87 BRCM_FAMILY_7366C0,
88 BRCM_FAMILY_74371A0,
89 BRCM_FAMILY_7439B0,
90 BRCM_FAMILY_7445D0,
91 BRCM_FAMILY_7260A0,
92 BRCM_FAMILY_7278A0,
93 BRCM_FAMILY_COUNT,
94};
95
96#define USB_BRCM_FAMILY(chip) \
97 [BRCM_FAMILY_##chip] = __stringify(chip)
98
99static const char *family_names[BRCM_FAMILY_COUNT] = {
100 USB_BRCM_FAMILY(3390A0),
101 USB_BRCM_FAMILY(7250B0),
102 USB_BRCM_FAMILY(7271A0),
103 USB_BRCM_FAMILY(7364A0),
104 USB_BRCM_FAMILY(7366C0),
105 USB_BRCM_FAMILY(74371A0),
106 USB_BRCM_FAMILY(7439B0),
107 USB_BRCM_FAMILY(7445D0),
108 USB_BRCM_FAMILY(7260A0),
109 USB_BRCM_FAMILY(7278A0),
110};
111
112enum {
113 USB_CTRL_SETUP_SCB1_EN_SELECTOR,
114 USB_CTRL_SETUP_SCB2_EN_SELECTOR,
115 USB_CTRL_SETUP_SS_EHCI64BIT_EN_SELECTOR,
116 USB_CTRL_SETUP_STRAP_IPP_SEL_SELECTOR,
117 USB_CTRL_SETUP_OC3_DISABLE_SELECTOR,
118 USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_SELECTOR,
119 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_SELECTOR,
120 USB_CTRL_USB_PM_BDC_SOFT_RESETB_SELECTOR,
121 USB_CTRL_USB_PM_XHC_SOFT_RESETB_SELECTOR,
122 USB_CTRL_USB_PM_USB_PWRDN_SELECTOR,
123 USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_SELECTOR,
124 USB_CTRL_USB30_CTL1_USB3_IOC_SELECTOR,
125 USB_CTRL_USB30_CTL1_USB3_IPP_SELECTOR,
126 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_SELECTOR,
127 USB_CTRL_USB_PM_SOFT_RESET_SELECTOR,
128 USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_SELECTOR,
129 USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_SELECTOR,
130 USB_CTRL_USB_PM_USB20_HC_RESETB_SELECTOR,
131 USB_CTRL_SETUP_ENDIAN_SELECTOR,
132 USB_CTRL_SELECTOR_COUNT,
133};
134
135#define USB_CTRL_REG(base, reg) ((void *)base + USB_CTRL_##reg)
136#define USB_XHCI_EC_REG(base, reg) ((void *)base + USB_XHCI_EC_##reg)
137#define USB_CTRL_MASK(reg, field) \
138 USB_CTRL_##reg##_##field##_MASK
139#define USB_CTRL_MASK_FAMILY(params, reg, field) \
140 (params->usb_reg_bits_map[USB_CTRL_##reg##_##field##_SELECTOR])
141
142#define USB_CTRL_SET_FAMILY(params, reg, field) \
143 usb_ctrl_set_family(params, USB_CTRL_##reg, \
144 USB_CTRL_##reg##_##field##_SELECTOR)
145#define USB_CTRL_UNSET_FAMILY(params, reg, field) \
146 usb_ctrl_unset_family(params, USB_CTRL_##reg, \
147 USB_CTRL_##reg##_##field##_SELECTOR)
148
149#define USB_CTRL_SET(base, reg, field) \
150 usb_ctrl_set(USB_CTRL_REG(base, reg), \
151 USB_CTRL_##reg##_##field##_MASK)
152#define USB_CTRL_UNSET(base, reg, field) \
153 usb_ctrl_unset(USB_CTRL_REG(base, reg), \
154 USB_CTRL_##reg##_##field##_MASK)
155
156#define MDIO_USB2 0
157#define MDIO_USB3 BIT(31)
158
159#define USB_CTRL_SETUP_ENDIAN_BITS ( \
160 USB_CTRL_MASK(SETUP, BABO) | \
161 USB_CTRL_MASK(SETUP, FNHW) | \
162 USB_CTRL_MASK(SETUP, FNBO) | \
163 USB_CTRL_MASK(SETUP, WABO))
164
165#ifdef __LITTLE_ENDIAN
166#define ENDIAN_SETTINGS ( \
167 USB_CTRL_MASK(SETUP, BABO) | \
168 USB_CTRL_MASK(SETUP, FNHW))
169#else
170#define ENDIAN_SETTINGS ( \
171 USB_CTRL_MASK(SETUP, FNHW) | \
172 USB_CTRL_MASK(SETUP, FNBO) | \
173 USB_CTRL_MASK(SETUP, WABO))
174#endif
175
176struct id_to_type {
177 u32 id;
178 int type;
179};
180
181static const struct id_to_type id_to_type_table[] = {
182 { 0x33900000, BRCM_FAMILY_3390A0 },
183 { 0x72500010, BRCM_FAMILY_7250B0 },
184 { 0x72600000, BRCM_FAMILY_7260A0 },
185 { 0x72680000, BRCM_FAMILY_7271A0 },
186 { 0x72710000, BRCM_FAMILY_7271A0 },
187 { 0x73640000, BRCM_FAMILY_7364A0 },
188 { 0x73660020, BRCM_FAMILY_7366C0 },
189 { 0x07437100, BRCM_FAMILY_74371A0 },
190 { 0x74390010, BRCM_FAMILY_7439B0 },
191 { 0x74450030, BRCM_FAMILY_7445D0 },
192 { 0x72780000, BRCM_FAMILY_7278A0 },
193 { 0, BRCM_FAMILY_7271A0 }, /* default */
194};
195
196static const u32
197usb_reg_bits_map_table[BRCM_FAMILY_COUNT][USB_CTRL_SELECTOR_COUNT] = {
198 /* 3390B0 */
199 [BRCM_FAMILY_3390A0] = {
200 USB_CTRL_SETUP_SCB1_EN_MASK,
201 USB_CTRL_SETUP_SCB2_EN_MASK,
202 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
203 USB_CTRL_SETUP_STRAP_IPP_SEL_MASK,
204 USB_CTRL_SETUP_OC3_DISABLE_MASK,
205 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
206 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
207 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
208 USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK,
209 USB_CTRL_USB_PM_USB_PWRDN_MASK,
210 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
211 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
212 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
213 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK,
214 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
215 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
216 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
217 USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK,
218 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
219 },
220 /* 7250b0 */
221 [BRCM_FAMILY_7250B0] = {
222 USB_CTRL_SETUP_SCB1_EN_MASK,
223 USB_CTRL_SETUP_SCB2_EN_MASK,
224 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
225 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */
226 USB_CTRL_SETUP_OC3_DISABLE_MASK,
227 USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK,
228 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
229 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
230 USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK,
231 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */
232 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
233 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
234 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
235 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */
236 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
237 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
238 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
239 USB_CTRL_USB_PM_USB20_HC_RESETB_MASK,
240 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
241 },
242 /* 7271a0 */
243 [BRCM_FAMILY_7271A0] = {
244 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */
245 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */
246 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
247 USB_CTRL_SETUP_STRAP_IPP_SEL_MASK,
248 USB_CTRL_SETUP_OC3_DISABLE_MASK,
249 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
250 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
251 USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK,
252 USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK,
253 USB_CTRL_USB_PM_USB_PWRDN_MASK,
254 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
255 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
256 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
257 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK,
258 USB_CTRL_USB_PM_SOFT_RESET_MASK,
259 USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK,
260 USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK,
261 USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK,
262 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
263 },
264 /* 7364a0 */
265 [BRCM_FAMILY_7364A0] = {
266 USB_CTRL_SETUP_SCB1_EN_MASK,
267 USB_CTRL_SETUP_SCB2_EN_MASK,
268 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
269 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */
270 USB_CTRL_SETUP_OC3_DISABLE_MASK,
271 USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK,
272 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
273 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
274 USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK,
275 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */
276 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
277 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
278 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
279 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */
280 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
281 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
282 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
283 USB_CTRL_USB_PM_USB20_HC_RESETB_MASK,
284 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
285 },
286 /* 7366c0 */
287 [BRCM_FAMILY_7366C0] = {
288 USB_CTRL_SETUP_SCB1_EN_MASK,
289 USB_CTRL_SETUP_SCB2_EN_MASK,
290 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
291 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */
292 USB_CTRL_SETUP_OC3_DISABLE_MASK,
293 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
294 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
295 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
296 USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK,
297 USB_CTRL_USB_PM_USB_PWRDN_MASK,
298 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
299 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
300 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
301 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */
302 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
303 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
304 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
305 USB_CTRL_USB_PM_USB20_HC_RESETB_MASK,
306 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
307 },
308 /* 74371A0 */
309 [BRCM_FAMILY_74371A0] = {
310 USB_CTRL_SETUP_SCB1_EN_MASK,
311 USB_CTRL_SETUP_SCB2_EN_MASK,
312 USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK,
313 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */
314 0, /* USB_CTRL_SETUP_OC3_DISABLE_MASK */
315 USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK,
316 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */
317 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
318 0, /* USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK */
319 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */
320 USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK,
321 USB_CTRL_USB30_CTL1_USB3_IOC_MASK,
322 USB_CTRL_USB30_CTL1_USB3_IPP_MASK,
323 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */
324 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
325 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
326 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
327 0, /* USB_CTRL_USB_PM_USB20_HC_RESETB_MASK */
328 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
329 },
330 /* 7439B0 */
331 [BRCM_FAMILY_7439B0] = {
332 USB_CTRL_SETUP_SCB1_EN_MASK,
333 USB_CTRL_SETUP_SCB2_EN_MASK,
334 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
335 USB_CTRL_SETUP_STRAP_IPP_SEL_MASK,
336 USB_CTRL_SETUP_OC3_DISABLE_MASK,
337 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
338 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */
339 USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK,
340 USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK,
341 USB_CTRL_USB_PM_USB_PWRDN_MASK,
342 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
343 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
344 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
345 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK,
346 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
347 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
348 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
349 USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK,
350 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
351 },
352 /* 7445d0 */
353 [BRCM_FAMILY_7445D0] = {
354 USB_CTRL_SETUP_SCB1_EN_MASK,
355 USB_CTRL_SETUP_SCB2_EN_MASK,
356 USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK,
357 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */
358 USB_CTRL_SETUP_OC3_DISABLE_MASK,
359 USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK,
360 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */
361 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */
362 0, /* USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK */
363 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */
364 USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK,
365 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
366 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
367 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */
368 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */
369 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
370 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
371 USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK,
372 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
373 },
374 /* 7260a0 */
375 [BRCM_FAMILY_7260A0] = {
376 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */
377 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */
378 USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK,
379 USB_CTRL_SETUP_STRAP_IPP_SEL_MASK,
380 USB_CTRL_SETUP_OC3_DISABLE_MASK,
381 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
382 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
383 USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK,
384 USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK,
385 USB_CTRL_USB_PM_USB_PWRDN_MASK,
386 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
387 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
388 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
389 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK,
390 USB_CTRL_USB_PM_SOFT_RESET_MASK,
391 USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK,
392 USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK,
393 USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK,
394 ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */
395 },
396 /* 7278a0 */
397 [BRCM_FAMILY_7278A0] = {
398 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */
399 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */
400 0, /*USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK */
401 USB_CTRL_SETUP_STRAP_IPP_SEL_MASK,
402 USB_CTRL_SETUP_OC3_DISABLE_MASK,
403 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */
404 USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK,
405 USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK,
406 USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK,
407 USB_CTRL_USB_PM_USB_PWRDN_MASK,
408 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */
409 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */
410 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */
411 USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK,
412 USB_CTRL_USB_PM_SOFT_RESET_MASK,
413 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */
414 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */
415 0, /* USB_CTRL_USB_PM_USB20_HC_RESETB_MASK */
416 0, /* USB_CTRL_SETUP ENDIAN bits */
417 },
418};
419
420static inline u32 brcmusb_readl(void __iomem *addr)
421{
422 return readl(addr);
423}
424
425static inline void brcmusb_writel(u32 val, void __iomem *addr)
426{
427 writel(val, addr);
428}
429
430static inline
431void usb_ctrl_unset_family(struct brcm_usb_init_params *params,
432 u32 reg_offset, u32 field)
433{
434 u32 mask;
435 void *reg;
436
437 mask = params->usb_reg_bits_map[field];
438 reg = params->ctrl_regs + reg_offset;
439 brcmusb_writel(brcmusb_readl(reg) & ~mask, reg);
440};
441
442static inline
443void usb_ctrl_set_family(struct brcm_usb_init_params *params,
444 u32 reg_offset, u32 field)
445{
446 u32 mask;
447 void *reg;
448
449 mask = params->usb_reg_bits_map[field];
450 reg = params->ctrl_regs + reg_offset;
451 brcmusb_writel(brcmusb_readl(reg) | mask, reg);
452};
453
454static inline void usb_ctrl_set(void __iomem *reg, u32 field)
455{
456 u32 value;
457
458 value = brcmusb_readl(reg);
459 brcmusb_writel(value | field, reg);
460}
461
462static inline void usb_ctrl_unset(void __iomem *reg, u32 field)
463{
464 u32 value;
465
466 value = brcmusb_readl(reg);
467 brcmusb_writel(value & ~field, reg);
468}
469
470static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode)
471{
472 u32 data;
473
474 data = (reg << 16) | mode;
475 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
476 data |= (1 << 24);
477 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
478 data &= ~(1 << 24);
479 /* wait for the 60MHz parallel to serial shifter */
480 usleep_range(10, 20);
481 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
482 /* wait for the 60MHz parallel to serial shifter */
483 usleep_range(10, 20);
484
485 return brcmusb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff;
486}
487
488static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg,
489 u32 val, int mode)
490{
491 u32 data;
492
493 data = (reg << 16) | val | mode;
494 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
495 data |= (1 << 25);
496 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
497 data &= ~(1 << 25);
498
499 /* wait for the 60MHz parallel to serial shifter */
500 usleep_range(10, 20);
501 brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
502 /* wait for the 60MHz parallel to serial shifter */
503 usleep_range(10, 20);
504}
505
506static void brcmusb_usb_phy_ldo_fix(void __iomem *ctrl_base)
507{
508 /* first disable FSM but also leave it that way */
509 /* to allow normal suspend/resume */
510 USB_CTRL_UNSET(ctrl_base, UTMI_CTL_1, POWER_UP_FSM_EN);
511 USB_CTRL_UNSET(ctrl_base, UTMI_CTL_1, POWER_UP_FSM_EN_P1);
512
513 /* reset USB 2.0 PLL */
514 USB_CTRL_UNSET(ctrl_base, PLL_CTL, PLL_RESETB);
515 /* PLL reset period */
516 udelay(1);
517 USB_CTRL_SET(ctrl_base, PLL_CTL, PLL_RESETB);
518 /* Give PLL enough time to lock */
519 usleep_range(1000, 2000);
520}
521
522static void brcmusb_usb2_eye_fix(void __iomem *ctrl_base)
523{
524 /* Increase USB 2.0 TX level to meet spec requirement */
525 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x80a0, MDIO_USB2);
526 brcmusb_usb_mdio_write(ctrl_base, 0x0a, 0xc6a0, MDIO_USB2);
527}
528
529static void brcmusb_usb3_pll_fix(void __iomem *ctrl_base)
530{
531 /* Set correct window for PLL lock detect */
532 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3);
533 brcmusb_usb_mdio_write(ctrl_base, 0x07, 0x1503, MDIO_USB3);
534}
535
536static void brcmusb_usb3_enable_pipe_reset(void __iomem *ctrl_base)
537{
538 u32 val;
539
540 /* Re-enable USB 3.0 pipe reset */
541 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3);
542 val = brcmusb_usb_mdio_read(ctrl_base, 0x0f, MDIO_USB3) | 0x200;
543 brcmusb_usb_mdio_write(ctrl_base, 0x0f, val, MDIO_USB3);
544}
545
546static void brcmusb_usb3_enable_sigdet(void __iomem *ctrl_base)
547{
548 u32 val, ofs;
549 int ii;
550
551 ofs = 0;
552 for (ii = 0; ii < PHY_PORTS; ++ii) {
553 /* Set correct default for sigdet */
554 brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8080 + ofs),
555 MDIO_USB3);
556 val = brcmusb_usb_mdio_read(ctrl_base, 0x05, MDIO_USB3);
557 val = (val & ~0x800f) | 0x800d;
558 brcmusb_usb_mdio_write(ctrl_base, 0x05, val, MDIO_USB3);
559 ofs = PHY_PORT_SELECT_1;
560 }
561}
562
563static void brcmusb_usb3_enable_skip_align(void __iomem *ctrl_base)
564{
565 u32 val, ofs;
566 int ii;
567
568 ofs = 0;
569 for (ii = 0; ii < PHY_PORTS; ++ii) {
570 /* Set correct default for SKIP align */
571 brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8060 + ofs),
572 MDIO_USB3);
573 val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0x200;
574 brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3);
575 ofs = PHY_PORT_SELECT_1;
576 }
577}
578
579static void brcmusb_usb3_unfreeze_aeq(void __iomem *ctrl_base)
580{
581 u32 val, ofs;
582 int ii;
583
584 ofs = 0;
585 for (ii = 0; ii < PHY_PORTS; ++ii) {
586 /* Let EQ freeze after TSEQ */
587 brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x80e0 + ofs),
588 MDIO_USB3);
589 val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3);
590 val &= ~0x0008;
591 brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3);
592 ofs = PHY_PORT_SELECT_1;
593 }
594}
595
596static void brcmusb_usb3_pll_54mhz(struct brcm_usb_init_params *params)
597{
598 u32 ofs;
599 int ii;
600 void __iomem *ctrl_base = params->ctrl_regs;
601
602 /*
603 * On newer B53 based SoC's, the reference clock for the
604 * 3.0 PLL has been changed from 50MHz to 54MHz so the
605 * PLL needs to be reprogrammed.
606 * See SWLINUX-4006.
607 *
608 * On the 7364C0, the reference clock for the
609 * 3.0 PLL has been changed from 50MHz to 54MHz to
610 * work around a MOCA issue.
611 * See SWLINUX-4169.
612 */
613 switch (params->selected_family) {
614 case BRCM_FAMILY_3390A0:
615 case BRCM_FAMILY_7250B0:
616 case BRCM_FAMILY_7366C0:
617 case BRCM_FAMILY_74371A0:
618 case BRCM_FAMILY_7439B0:
619 case BRCM_FAMILY_7445D0:
620 case BRCM_FAMILY_7260A0:
621 return;
622 case BRCM_FAMILY_7364A0:
623 if (BRCM_REV(params->family_id) < 0x20)
624 return;
625 break;
626 }
627
628 /* set USB 3.0 PLL to accept 54Mhz reference clock */
629 USB_CTRL_UNSET(ctrl_base, USB30_CTL1, PHY3_PLL_SEQ_START);
630
631 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3);
632 brcmusb_usb_mdio_write(ctrl_base, 0x10, 0x5784, MDIO_USB3);
633 brcmusb_usb_mdio_write(ctrl_base, 0x11, 0x01d0, MDIO_USB3);
634 brcmusb_usb_mdio_write(ctrl_base, 0x12, 0x1DE8, MDIO_USB3);
635 brcmusb_usb_mdio_write(ctrl_base, 0x13, 0xAA80, MDIO_USB3);
636 brcmusb_usb_mdio_write(ctrl_base, 0x14, 0x8826, MDIO_USB3);
637 brcmusb_usb_mdio_write(ctrl_base, 0x15, 0x0044, MDIO_USB3);
638 brcmusb_usb_mdio_write(ctrl_base, 0x16, 0x8000, MDIO_USB3);
639 brcmusb_usb_mdio_write(ctrl_base, 0x17, 0x0851, MDIO_USB3);
640 brcmusb_usb_mdio_write(ctrl_base, 0x18, 0x0000, MDIO_USB3);
641
642 /* both ports */
643 ofs = 0;
644 for (ii = 0; ii < PHY_PORTS; ++ii) {
645 brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8040 + ofs),
646 MDIO_USB3);
647 brcmusb_usb_mdio_write(ctrl_base, 0x03, 0x0090, MDIO_USB3);
648 brcmusb_usb_mdio_write(ctrl_base, 0x04, 0x0134, MDIO_USB3);
649 brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8020 + ofs),
650 MDIO_USB3);
651 brcmusb_usb_mdio_write(ctrl_base, 0x01, 0x00e2, MDIO_USB3);
652 ofs = PHY_PORT_SELECT_1;
653 }
654
655 /* restart PLL sequence */
656 USB_CTRL_SET(ctrl_base, USB30_CTL1, PHY3_PLL_SEQ_START);
657 /* Give PLL enough time to lock */
658 usleep_range(1000, 2000);
659}
660
661static void brcmusb_usb3_ssc_enable(void __iomem *ctrl_base)
662{
663 u32 val;
664
665 /* Enable USB 3.0 TX spread spectrum */
666 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8040, MDIO_USB3);
667 val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0xf;
668 brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3);
669
670 /* Currently, USB 3.0 SSC is enabled via port 0 MDIO registers,
671 * which should have been adequate. However, due to a bug in the
672 * USB 3.0 PHY, it must be enabled via both ports (HWUSB3DVT-26).
673 */
674 brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x9040, MDIO_USB3);
675 val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0xf;
676 brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3);
677}
678
679static void brcmusb_usb3_phy_workarounds(struct brcm_usb_init_params *params)
680{
681 void __iomem *ctrl_base = params->ctrl_regs;
682
683 brcmusb_usb3_pll_fix(ctrl_base);
684 brcmusb_usb3_pll_54mhz(params);
685 brcmusb_usb3_ssc_enable(ctrl_base);
686 brcmusb_usb3_enable_pipe_reset(ctrl_base);
687 brcmusb_usb3_enable_sigdet(ctrl_base);
688 brcmusb_usb3_enable_skip_align(ctrl_base);
689 brcmusb_usb3_unfreeze_aeq(ctrl_base);
690}
691
692static void brcmusb_memc_fix(struct brcm_usb_init_params *params)
693{
694 u32 prid;
695
696 if (params->selected_family != BRCM_FAMILY_7445D0)
697 return;
698 /*
699 * This is a workaround for HW7445-1869 where a DMA write ends up
700 * doing a read pre-fetch after the end of the DMA buffer. This
701 * causes a problem when the DMA buffer is at the end of physical
702 * memory, causing the pre-fetch read to access non-existent memory,
703 * and the chip bondout has MEMC2 disabled. When the pre-fetch read
704 * tries to use the disabled MEMC2, it hangs the bus. The workaround
705 * is to disable MEMC2 access in the usb controller which avoids
706 * the hang.
707 */
708
709 prid = params->product_id & 0xfffff000;
710 switch (prid) {
711 case 0x72520000:
712 case 0x74480000:
713 case 0x74490000:
714 case 0x07252000:
715 case 0x07448000:
716 case 0x07449000:
717 USB_CTRL_UNSET_FAMILY(params, SETUP, SCB2_EN);
718 }
719}
720
721static void brcmusb_usb3_otp_fix(struct brcm_usb_init_params *params)
722{
723 void __iomem *xhci_ec_base = params->xhci_ec_regs;
724 u32 val;
725
726 if (params->family_id != 0x74371000 || xhci_ec_base == 0)
727 return;
728 brcmusb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR));
729 val = brcmusb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
730
731 /* set cfg_pick_ss_lock */
732 val |= (1 << 27);
733 brcmusb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
734
735 /* Reset USB 3.0 PHY for workaround to take effect */
736 USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB);
737 USB_CTRL_SET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB);
738}
739
740static void brcmusb_xhci_soft_reset(struct brcm_usb_init_params *params,
741 int on_off)
742{
743 /* Assert reset */
744 if (on_off) {
745 if (USB_CTRL_MASK_FAMILY(params, USB_PM, XHC_SOFT_RESETB))
746 USB_CTRL_UNSET_FAMILY(params, USB_PM, XHC_SOFT_RESETB);
747 else
748 USB_CTRL_UNSET_FAMILY(params,
749 USB30_CTL1, XHC_SOFT_RESETB);
750 } else { /* De-assert reset */
751 if (USB_CTRL_MASK_FAMILY(params, USB_PM, XHC_SOFT_RESETB))
752 USB_CTRL_SET_FAMILY(params, USB_PM, XHC_SOFT_RESETB);
753 else
754 USB_CTRL_SET_FAMILY(params, USB30_CTL1,
755 XHC_SOFT_RESETB);
756 }
757}
758
759/*
760 * Return the best map table family. The order is:
761 * - exact match of chip and major rev
762 * - exact match of chip and closest older major rev
763 * - default chip/rev.
764 * NOTE: The minor rev is always ignored.
765 */
766static enum brcm_family_type brcmusb_get_family_type(
767 struct brcm_usb_init_params *params)
768{
769 int last_type = -1;
770 u32 last_family = 0;
771 u32 family_no_major;
772 unsigned int x;
773 u32 family;
774
775 family = params->family_id & 0xfffffff0;
776 family_no_major = params->family_id & 0xffffff00;
777 for (x = 0; id_to_type_table[x].id; x++) {
778 if (family == id_to_type_table[x].id)
779 return id_to_type_table[x].type;
780 if (family_no_major == (id_to_type_table[x].id & 0xffffff00))
781 if (family > id_to_type_table[x].id &&
782 last_family < id_to_type_table[x].id) {
783 last_family = id_to_type_table[x].id;
784 last_type = id_to_type_table[x].type;
785 }
786 }
787
788 /* If no match, return the default family */
789 if (last_type == -1)
790 return id_to_type_table[x].type;
791 return last_type;
792}
793
794void brcm_usb_init_ipp(struct brcm_usb_init_params *params)
795{
796 void __iomem *ctrl = params->ctrl_regs;
797 u32 reg;
798 u32 orig_reg;
799
800 /* Starting with the 7445d0, there are no longer separate 3.0
801 * versions of IOC and IPP.
802 */
803 if (USB_CTRL_MASK_FAMILY(params, USB30_CTL1, USB3_IOC)) {
804 if (params->ioc)
805 USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IOC);
806 if (params->ipp == 1)
807 USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IPP);
808 }
809
810 reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
811 orig_reg = reg;
812 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL))
813 /* Never use the strap, it's going away. */
814 reg &= ~(USB_CTRL_MASK_FAMILY(params,
815 SETUP,
816 STRAP_CC_DRD_MODE_ENABLE_SEL));
817 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL))
818 if (params->ipp != 2)
819 /* override ipp strap pin (if it exits) */
820 reg &= ~(USB_CTRL_MASK_FAMILY(params, SETUP,
821 STRAP_IPP_SEL));
822
823 /* Override the default OC and PP polarity */
824 reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC));
825 if (params->ioc)
826 reg |= USB_CTRL_MASK(SETUP, IOC);
827 if (params->ipp == 1 && ((reg & USB_CTRL_MASK(SETUP, IPP)) == 0))
828 reg |= USB_CTRL_MASK(SETUP, IPP);
829 brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
830
831 /*
832 * If we're changing IPP, make sure power is off long enough
833 * to turn off any connected devices.
834 */
835 if (reg != orig_reg)
836 msleep(50);
837}
838
839int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params)
840{
841 void __iomem *ctrl = params->ctrl_regs;
842 u32 reg = 0;
843
844 if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
845 reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
846 reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
847 PORT_MODE);
848 }
849 return reg;
850}
851
852void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params,
853 int mode)
854{
855 void __iomem *ctrl = params->ctrl_regs;
856 u32 reg;
857
858 if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
859 reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
860 reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
861 PORT_MODE);
862 reg |= mode;
863 brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
864 }
865}
866
867void brcm_usb_init_common(struct brcm_usb_init_params *params)
868{
869 u32 reg;
870 void __iomem *ctrl = params->ctrl_regs;
871
872 /* Take USB out of power down */
873 if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) {
874 USB_CTRL_UNSET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN);
875 /* 1 millisecond - for USB clocks to settle down */
876 usleep_range(1000, 2000);
877 }
878
879 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN)) {
880 USB_CTRL_UNSET_FAMILY(params, USB_PM, USB_PWRDN);
881 /* 1 millisecond - for USB clocks to settle down */
882 usleep_range(1000, 2000);
883 }
884
885 if (params->selected_family != BRCM_FAMILY_74371A0 &&
886 (BRCM_ID(params->family_id) != 0x7364))
887 /*
888 * HW7439-637: 7439a0 and its derivatives do not have large
889 * enough descriptor storage for this.
890 */
891 USB_CTRL_SET_FAMILY(params, SETUP, SS_EHCI64BIT_EN);
892
893 /* Block auto PLL suspend by USB2 PHY (Sasi) */
894 USB_CTRL_SET(ctrl, PLL_CTL, PLL_SUSPEND_EN);
895
896 reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
897 if (params->selected_family == BRCM_FAMILY_7364A0)
898 /* Suppress overcurrent indication from USB30 ports for A0 */
899 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, OC3_DISABLE);
900
901 brcmusb_usb_phy_ldo_fix(ctrl);
902 brcmusb_usb2_eye_fix(ctrl);
903
904 /*
905 * Make sure the the second and third memory controller
906 * interfaces are enabled if they exist.
907 */
908 if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN))
909 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN);
910 if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN))
911 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN);
912 brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
913
914 brcmusb_memc_fix(params);
915
916 if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
917 reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
918 reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
919 PORT_MODE);
920 reg |= params->mode;
921 brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
922 }
923 if (USB_CTRL_MASK_FAMILY(params, USB_PM, BDC_SOFT_RESETB)) {
924 switch (params->mode) {
925 case USB_CTLR_MODE_HOST:
926 USB_CTRL_UNSET_FAMILY(params, USB_PM, BDC_SOFT_RESETB);
927 break;
928 default:
929 USB_CTRL_SET_FAMILY(params, USB_PM, BDC_SOFT_RESETB);
930 break;
931 }
932 }
933 if (USB_CTRL_MASK_FAMILY(params, SETUP, CC_DRD_MODE_ENABLE)) {
934 if (params->mode == USB_CTLR_MODE_TYPEC_PD)
935 USB_CTRL_SET_FAMILY(params, SETUP, CC_DRD_MODE_ENABLE);
936 else
937 USB_CTRL_UNSET_FAMILY(params, SETUP,
938 CC_DRD_MODE_ENABLE);
939 }
940}
941
942void brcm_usb_init_eohci(struct brcm_usb_init_params *params)
943{
944 u32 reg;
945 void __iomem *ctrl = params->ctrl_regs;
946
947 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB))
948 USB_CTRL_SET_FAMILY(params, USB_PM, USB20_HC_RESETB);
949
950 if (params->selected_family == BRCM_FAMILY_7366C0)
951 /*
952 * Don't enable this so the memory controller doesn't read
953 * into memory holes. NOTE: This bit is low true on 7366C0.
954 */
955 USB_CTRL_SET_FAMILY(params, EBRIDGE, ESTOP_SCB_REQ);
956
957 /* Setup the endian bits */
958 reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
959 reg &= ~USB_CTRL_SETUP_ENDIAN_BITS;
960 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, ENDIAN);
961 brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
962}
963
964void brcm_usb_init_xhci(struct brcm_usb_init_params *params)
965{
966 void __iomem *ctrl = params->ctrl_regs;
967
968 if (BRCM_ID(params->family_id) == 0x7366) {
969 /*
970 * The PHY3_SOFT_RESETB bits default to the wrong state.
971 */
972 USB_CTRL_SET(ctrl, USB30_PCTL, PHY3_SOFT_RESETB);
973 USB_CTRL_SET(ctrl, USB30_PCTL, PHY3_SOFT_RESETB_P1);
974 }
975
976 /*
977 * Kick start USB3 PHY
978 * Make sure it's low to insure a rising edge.
979 */
980 USB_CTRL_UNSET(ctrl, USB30_CTL1, PHY3_PLL_SEQ_START);
981 USB_CTRL_SET(ctrl, USB30_CTL1, PHY3_PLL_SEQ_START);
982
983 brcmusb_usb3_phy_workarounds(params);
984 brcmusb_xhci_soft_reset(params, 0);
985 brcmusb_usb3_otp_fix(params);
986}
987
988void brcm_usb_uninit_common(struct brcm_usb_init_params *params)
989{
990 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN))
991 USB_CTRL_SET_FAMILY(params, USB_PM, USB_PWRDN);
992
993 if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN))
994 USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN);
995}
996
997void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params)
998{
999 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB))
1000 USB_CTRL_UNSET_FAMILY(params, USB_PM, USB20_HC_RESETB);
1001}
1002
1003void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params)
1004{
1005 brcmusb_xhci_soft_reset(params, 1);
1006}
1007
1008void brcm_usb_set_family_map(struct brcm_usb_init_params *params)
1009{
1010 int fam;
1011
1012 fam = brcmusb_get_family_type(params);
1013 params->selected_family = fam;
1014 params->usb_reg_bits_map =
1015 &usb_reg_bits_map_table[fam][0];
1016 params->family_name = family_names[fam];
1017}
diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h
new file mode 100644
index 000000000000..bb77b863885e
--- /dev/null
+++ b/drivers/phy/broadcom/phy-brcm-usb-init.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2014-2017 Broadcom
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef _USB_BRCM_COMMON_INIT_H
15#define _USB_BRCM_COMMON_INIT_H
16
17#define USB_CTLR_MODE_HOST 0
18#define USB_CTLR_MODE_DEVICE 1
19#define USB_CTLR_MODE_DRD 2
20#define USB_CTLR_MODE_TYPEC_PD 3
21
22struct brcm_usb_init_params;
23
24struct brcm_usb_init_params {
25 void __iomem *ctrl_regs;
26 void __iomem *xhci_ec_regs;
27 int ioc;
28 int ipp;
29 int mode;
30 u32 family_id;
31 u32 product_id;
32 int selected_family;
33 const char *family_name;
34 const u32 *usb_reg_bits_map;
35};
36
37void brcm_usb_set_family_map(struct brcm_usb_init_params *params);
38int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params);
39void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params,
40 int mode);
41
42void brcm_usb_init_ipp(struct brcm_usb_init_params *ini);
43void brcm_usb_init_common(struct brcm_usb_init_params *ini);
44void brcm_usb_init_eohci(struct brcm_usb_init_params *ini);
45void brcm_usb_init_xhci(struct brcm_usb_init_params *ini);
46void brcm_usb_uninit_common(struct brcm_usb_init_params *ini);
47void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini);
48void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini);
49
50#endif /* _USB_BRCM_COMMON_INIT_H */
diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
new file mode 100644
index 000000000000..195b98139e5f
--- /dev/null
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -0,0 +1,459 @@
1/*
2 * phy-brcm-usb.c - Broadcom USB Phy Driver
3 *
4 * Copyright (C) 2015-2017 Broadcom
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/clk.h>
17#include <linux/delay.h>
18#include <linux/err.h>
19#include <linux/io.h>
20#include <linux/module.h>
21#include <linux/of.h>
22#include <linux/phy/phy.h>
23#include <linux/platform_device.h>
24#include <linux/interrupt.h>
25#include <linux/soc/brcmstb/brcmstb.h>
26#include <dt-bindings/phy/phy.h>
27
28#include "phy-brcm-usb-init.h"
29
30static DEFINE_MUTEX(sysfs_lock);
31
32enum brcm_usb_phy_id {
33 BRCM_USB_PHY_2_0 = 0,
34 BRCM_USB_PHY_3_0,
35 BRCM_USB_PHY_ID_MAX
36};
37
38struct value_to_name_map {
39 int value;
40 const char *name;
41};
42
43static struct value_to_name_map brcm_dr_mode_to_name[] = {
44 { USB_CTLR_MODE_HOST, "host" },
45 { USB_CTLR_MODE_DEVICE, "peripheral" },
46 { USB_CTLR_MODE_DRD, "drd" },
47 { USB_CTLR_MODE_TYPEC_PD, "typec-pd" }
48};
49
50static struct value_to_name_map brcm_dual_mode_to_name[] = {
51 { 0, "host" },
52 { 1, "device" },
53 { 2, "auto" },
54};
55
56struct brcm_usb_phy {
57 struct phy *phy;
58 unsigned int id;
59 bool inited;
60};
61
62struct brcm_usb_phy_data {
63 struct brcm_usb_init_params ini;
64 bool has_eohci;
65 bool has_xhci;
66 struct clk *usb_20_clk;
67 struct clk *usb_30_clk;
68 struct mutex mutex; /* serialize phy init */
69 int init_count;
70 struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX];
71};
72
73static int brcm_usb_phy_init(struct phy *gphy)
74{
75 struct brcm_usb_phy *phy = phy_get_drvdata(gphy);
76 struct brcm_usb_phy_data *priv =
77 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
78
79 /*
80 * Use a lock to make sure a second caller waits until
81 * the base phy is inited before using it.
82 */
83 mutex_lock(&priv->mutex);
84 if (priv->init_count++ == 0) {
85 clk_enable(priv->usb_20_clk);
86 clk_enable(priv->usb_30_clk);
87 brcm_usb_init_common(&priv->ini);
88 }
89 mutex_unlock(&priv->mutex);
90 if (phy->id == BRCM_USB_PHY_2_0)
91 brcm_usb_init_eohci(&priv->ini);
92 else if (phy->id == BRCM_USB_PHY_3_0)
93 brcm_usb_init_xhci(&priv->ini);
94 phy->inited = true;
95 dev_dbg(&gphy->dev, "INIT, id: %d, total: %d\n", phy->id,
96 priv->init_count);
97
98 return 0;
99}
100
101static int brcm_usb_phy_exit(struct phy *gphy)
102{
103 struct brcm_usb_phy *phy = phy_get_drvdata(gphy);
104 struct brcm_usb_phy_data *priv =
105 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
106
107 dev_dbg(&gphy->dev, "EXIT\n");
108 if (phy->id == BRCM_USB_PHY_2_0)
109 brcm_usb_uninit_eohci(&priv->ini);
110 if (phy->id == BRCM_USB_PHY_3_0)
111 brcm_usb_uninit_xhci(&priv->ini);
112
113 /* If both xhci and eohci are gone, reset everything else */
114 mutex_lock(&priv->mutex);
115 if (--priv->init_count == 0) {
116 brcm_usb_uninit_common(&priv->ini);
117 clk_disable(priv->usb_20_clk);
118 clk_disable(priv->usb_30_clk);
119 }
120 mutex_unlock(&priv->mutex);
121 phy->inited = false;
122 return 0;
123}
124
125static struct phy_ops brcm_usb_phy_ops = {
126 .init = brcm_usb_phy_init,
127 .exit = brcm_usb_phy_exit,
128 .owner = THIS_MODULE,
129};
130
131static struct phy *brcm_usb_phy_xlate(struct device *dev,
132 struct of_phandle_args *args)
133{
134 struct brcm_usb_phy_data *data = dev_get_drvdata(dev);
135
136 /*
137 * values 0 and 1 are for backward compatibility with
138 * device tree nodes from older bootloaders.
139 */
140 switch (args->args[0]) {
141 case 0:
142 case PHY_TYPE_USB2:
143 if (data->phys[BRCM_USB_PHY_2_0].phy)
144 return data->phys[BRCM_USB_PHY_2_0].phy;
145 dev_warn(dev, "Error, 2.0 Phy not found\n");
146 break;
147 case 1:
148 case PHY_TYPE_USB3:
149 if (data->phys[BRCM_USB_PHY_3_0].phy)
150 return data->phys[BRCM_USB_PHY_3_0].phy;
151 dev_warn(dev, "Error, 3.0 Phy not found\n");
152 break;
153 }
154 return ERR_PTR(-ENODEV);
155}
156
157static int name_to_value(struct value_to_name_map *table, int count,
158 const char *name, int *value)
159{
160 int x;
161
162 *value = 0;
163 for (x = 0; x < count; x++) {
164 if (sysfs_streq(name, table[x].name)) {
165 *value = x;
166 return 0;
167 }
168 }
169 return -EINVAL;
170}
171
172static const char *value_to_name(struct value_to_name_map *table, int count,
173 int value)
174{
175 if (value >= count)
176 return "unknown";
177 return table[value].name;
178}
179
180static ssize_t dr_mode_show(struct device *dev,
181 struct device_attribute *attr,
182 char *buf)
183{
184 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
185
186 return sprintf(buf, "%s\n",
187 value_to_name(&brcm_dr_mode_to_name[0],
188 ARRAY_SIZE(brcm_dr_mode_to_name),
189 priv->ini.mode));
190}
191static DEVICE_ATTR_RO(dr_mode);
192
193static ssize_t dual_select_store(struct device *dev,
194 struct device_attribute *attr,
195 const char *buf, size_t len)
196{
197 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
198 int value;
199 int res;
200
201 mutex_lock(&sysfs_lock);
202 res = name_to_value(&brcm_dual_mode_to_name[0],
203 ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value);
204 if (!res) {
205 brcm_usb_init_set_dual_select(&priv->ini, value);
206 res = len;
207 }
208 mutex_unlock(&sysfs_lock);
209 return res;
210}
211
212static ssize_t dual_select_show(struct device *dev,
213 struct device_attribute *attr,
214 char *buf)
215{
216 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
217 int value;
218
219 mutex_lock(&sysfs_lock);
220 value = brcm_usb_init_get_dual_select(&priv->ini);
221 mutex_unlock(&sysfs_lock);
222 return sprintf(buf, "%s\n",
223 value_to_name(&brcm_dual_mode_to_name[0],
224 ARRAY_SIZE(brcm_dual_mode_to_name),
225 value));
226}
227static DEVICE_ATTR_RW(dual_select);
228
229static struct attribute *brcm_usb_phy_attrs[] = {
230 &dev_attr_dr_mode.attr,
231 &dev_attr_dual_select.attr,
232 NULL
233};
234
235static const struct attribute_group brcm_usb_phy_group = {
236 .attrs = brcm_usb_phy_attrs,
237};
238
239static int brcm_usb_phy_dvr_init(struct device *dev,
240 struct brcm_usb_phy_data *priv,
241 struct device_node *dn)
242{
243 struct phy *gphy;
244 int err;
245
246 priv->usb_20_clk = of_clk_get_by_name(dn, "sw_usb");
247 if (IS_ERR(priv->usb_20_clk)) {
248 dev_info(dev, "Clock not found in Device Tree\n");
249 priv->usb_20_clk = NULL;
250 }
251 err = clk_prepare_enable(priv->usb_20_clk);
252 if (err)
253 return err;
254
255 if (priv->has_eohci) {
256 gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops);
257 if (IS_ERR(gphy)) {
258 dev_err(dev, "failed to create EHCI/OHCI PHY\n");
259 return PTR_ERR(gphy);
260 }
261 priv->phys[BRCM_USB_PHY_2_0].phy = gphy;
262 priv->phys[BRCM_USB_PHY_2_0].id = BRCM_USB_PHY_2_0;
263 phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_2_0]);
264 }
265
266 if (priv->has_xhci) {
267 gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops);
268 if (IS_ERR(gphy)) {
269 dev_err(dev, "failed to create XHCI PHY\n");
270 return PTR_ERR(gphy);
271 }
272 priv->phys[BRCM_USB_PHY_3_0].phy = gphy;
273 priv->phys[BRCM_USB_PHY_3_0].id = BRCM_USB_PHY_3_0;
274 phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_3_0]);
275
276 priv->usb_30_clk = of_clk_get_by_name(dn, "sw_usb3");
277 if (IS_ERR(priv->usb_30_clk)) {
278 dev_info(dev,
279 "USB3.0 clock not found in Device Tree\n");
280 priv->usb_30_clk = NULL;
281 }
282 err = clk_prepare_enable(priv->usb_30_clk);
283 if (err)
284 return err;
285 }
286 return 0;
287}
288
289static int brcm_usb_phy_probe(struct platform_device *pdev)
290{
291 struct resource *res;
292 struct device *dev = &pdev->dev;
293 struct brcm_usb_phy_data *priv;
294 struct phy_provider *phy_provider;
295 struct device_node *dn = pdev->dev.of_node;
296 int err;
297 const char *mode;
298
299 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
300 if (!priv)
301 return -ENOMEM;
302 platform_set_drvdata(pdev, priv);
303
304 priv->ini.family_id = brcmstb_get_family_id();
305 priv->ini.product_id = brcmstb_get_product_id();
306 brcm_usb_set_family_map(&priv->ini);
307 dev_dbg(dev, "Best mapping table is for %s\n",
308 priv->ini.family_name);
309 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
310 if (!res) {
311 dev_err(dev, "can't get USB_CTRL base address\n");
312 return -EINVAL;
313 }
314 priv->ini.ctrl_regs = devm_ioremap_resource(dev, res);
315 if (IS_ERR(priv->ini.ctrl_regs)) {
316 dev_err(dev, "can't map CTRL register space\n");
317 return -EINVAL;
318 }
319
320 /* The XHCI EC registers are optional */
321 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
322 if (res) {
323 priv->ini.xhci_ec_regs =
324 devm_ioremap_resource(dev, res);
325 if (IS_ERR(priv->ini.xhci_ec_regs)) {
326 dev_err(dev, "can't map XHCI EC register space\n");
327 return -EINVAL;
328 }
329 }
330
331 of_property_read_u32(dn, "brcm,ipp", &priv->ini.ipp);
332 of_property_read_u32(dn, "brcm,ioc", &priv->ini.ioc);
333
334 priv->ini.mode = USB_CTLR_MODE_HOST;
335 err = of_property_read_string(dn, "dr_mode", &mode);
336 if (err == 0) {
337 name_to_value(&brcm_dr_mode_to_name[0],
338 ARRAY_SIZE(brcm_dr_mode_to_name),
339 mode, &priv->ini.mode);
340 }
341 if (of_property_read_bool(dn, "brcm,has_xhci"))
342 priv->has_xhci = true;
343 if (of_property_read_bool(dn, "brcm,has_eohci"))
344 priv->has_eohci = true;
345
346 err = brcm_usb_phy_dvr_init(dev, priv, dn);
347 if (err)
348 return err;
349
350 mutex_init(&priv->mutex);
351
352 /* make sure invert settings are correct */
353 brcm_usb_init_ipp(&priv->ini);
354
355 /*
356 * Create sysfs entries for mode.
357 * Remove "dual_select" attribute if not in dual mode
358 */
359 if (priv->ini.mode != USB_CTLR_MODE_DRD)
360 brcm_usb_phy_attrs[1] = NULL;
361 err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group);
362 if (err)
363 dev_warn(dev, "Error creating sysfs attributes\n");
364
365 /* start with everything off */
366 if (priv->has_xhci)
367 brcm_usb_uninit_xhci(&priv->ini);
368 if (priv->has_eohci)
369 brcm_usb_uninit_eohci(&priv->ini);
370 brcm_usb_uninit_common(&priv->ini);
371 clk_disable(priv->usb_20_clk);
372 clk_disable(priv->usb_30_clk);
373
374 phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate);
375 if (IS_ERR(phy_provider))
376 return PTR_ERR(phy_provider);
377
378 return 0;
379}
380
381#ifdef CONFIG_PM_SLEEP
382static int brcm_usb_phy_suspend(struct device *dev)
383{
384 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
385
386 if (priv->init_count) {
387 clk_disable(priv->usb_20_clk);
388 clk_disable(priv->usb_30_clk);
389 }
390 return 0;
391}
392
393static int brcm_usb_phy_resume(struct device *dev)
394{
395 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
396
397 clk_enable(priv->usb_20_clk);
398 clk_enable(priv->usb_30_clk);
399 brcm_usb_init_ipp(&priv->ini);
400
401 /*
402 * Initialize anything that was previously initialized.
403 * Uninitialize anything that wasn't previously initialized.
404 */
405 if (priv->init_count) {
406 brcm_usb_init_common(&priv->ini);
407 if (priv->phys[BRCM_USB_PHY_2_0].inited) {
408 brcm_usb_init_eohci(&priv->ini);
409 } else if (priv->has_eohci) {
410 brcm_usb_uninit_eohci(&priv->ini);
411 clk_disable(priv->usb_20_clk);
412 }
413 if (priv->phys[BRCM_USB_PHY_3_0].inited) {
414 brcm_usb_init_xhci(&priv->ini);
415 } else if (priv->has_xhci) {
416 brcm_usb_uninit_xhci(&priv->ini);
417 clk_disable(priv->usb_30_clk);
418 }
419 } else {
420 if (priv->has_xhci)
421 brcm_usb_uninit_xhci(&priv->ini);
422 if (priv->has_eohci)
423 brcm_usb_uninit_eohci(&priv->ini);
424 brcm_usb_uninit_common(&priv->ini);
425 clk_disable(priv->usb_20_clk);
426 clk_disable(priv->usb_30_clk);
427 }
428
429 return 0;
430}
431#endif /* CONFIG_PM_SLEEP */
432
433static const struct dev_pm_ops brcm_usb_phy_pm_ops = {
434 SET_LATE_SYSTEM_SLEEP_PM_OPS(brcm_usb_phy_suspend, brcm_usb_phy_resume)
435};
436
437static const struct of_device_id brcm_usb_dt_ids[] = {
438 { .compatible = "brcm,brcmstb-usb-phy" },
439 { /* sentinel */ }
440};
441
442MODULE_DEVICE_TABLE(of, brcm_usb_dt_ids);
443
444static struct platform_driver brcm_usb_driver = {
445 .probe = brcm_usb_phy_probe,
446 .driver = {
447 .name = "brcmstb-usb-phy",
448 .owner = THIS_MODULE,
449 .pm = &brcm_usb_phy_pm_ops,
450 .of_match_table = brcm_usb_dt_ids,
451 },
452};
453
454module_platform_driver(brcm_usb_driver);
455
456MODULE_ALIAS("platform:brcmstb-usb-phy");
457MODULE_AUTHOR("Al Cooper <acooper@broadcom.com>");
458MODULE_DESCRIPTION("BRCM USB PHY driver");
459MODULE_LICENSE("GPL v2");
diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
index 89c887ea5557..a0d522154cdf 100644
--- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
+++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
@@ -154,7 +154,6 @@ struct mvebu_comphy_priv {
154 void __iomem *base; 154 void __iomem *base;
155 struct regmap *regmap; 155 struct regmap *regmap;
156 struct device *dev; 156 struct device *dev;
157 int modes[MVEBU_COMPHY_LANES];
158}; 157};
159 158
160struct mvebu_comphy_lane { 159struct mvebu_comphy_lane {
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 721a2a1c97ef..402385f2562a 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -96,9 +96,11 @@
96 96
97#define U3P_U2PHYDTM1 0x06C 97#define U3P_U2PHYDTM1 0x06C
98#define P2C_RG_UART_EN BIT(16) 98#define P2C_RG_UART_EN BIT(16)
99#define P2C_FORCE_IDDIG BIT(9)
99#define P2C_RG_VBUSVALID BIT(5) 100#define P2C_RG_VBUSVALID BIT(5)
100#define P2C_RG_SESSEND BIT(4) 101#define P2C_RG_SESSEND BIT(4)
101#define P2C_RG_AVALID BIT(2) 102#define P2C_RG_AVALID BIT(2)
103#define P2C_RG_IDDIG BIT(1)
102 104
103#define U3P_U3_CHIP_GPIO_CTLD 0x0c 105#define U3P_U3_CHIP_GPIO_CTLD 0x0c
104#define P3C_REG_IP_SW_RST BIT(31) 106#define P3C_REG_IP_SW_RST BIT(31)
@@ -585,6 +587,31 @@ static void u2_phy_instance_exit(struct mtk_tphy *tphy,
585 } 587 }
586} 588}
587 589
590static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
591 struct mtk_phy_instance *instance,
592 enum phy_mode mode)
593{
594 struct u2phy_banks *u2_banks = &instance->u2_banks;
595 u32 tmp;
596
597 tmp = readl(u2_banks->com + U3P_U2PHYDTM1);
598 switch (mode) {
599 case PHY_MODE_USB_DEVICE:
600 tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG;
601 break;
602 case PHY_MODE_USB_HOST:
603 tmp |= P2C_FORCE_IDDIG;
604 tmp &= ~P2C_RG_IDDIG;
605 break;
606 case PHY_MODE_USB_OTG:
607 tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG);
608 break;
609 default:
610 return;
611 }
612 writel(tmp, u2_banks->com + U3P_U2PHYDTM1);
613}
614
588static void pcie_phy_instance_init(struct mtk_tphy *tphy, 615static void pcie_phy_instance_init(struct mtk_tphy *tphy,
589 struct mtk_phy_instance *instance) 616 struct mtk_phy_instance *instance)
590{ 617{
@@ -881,6 +908,17 @@ static int mtk_phy_exit(struct phy *phy)
881 return 0; 908 return 0;
882} 909}
883 910
911static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode)
912{
913 struct mtk_phy_instance *instance = phy_get_drvdata(phy);
914 struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);
915
916 if (instance->type == PHY_TYPE_USB2)
917 u2_phy_instance_set_mode(tphy, instance, mode);
918
919 return 0;
920}
921
884static struct phy *mtk_phy_xlate(struct device *dev, 922static struct phy *mtk_phy_xlate(struct device *dev,
885 struct of_phandle_args *args) 923 struct of_phandle_args *args)
886{ 924{
@@ -931,6 +969,7 @@ static const struct phy_ops mtk_tphy_ops = {
931 .exit = mtk_phy_exit, 969 .exit = mtk_phy_exit,
932 .power_on = mtk_phy_power_on, 970 .power_on = mtk_phy_power_on,
933 .power_off = mtk_phy_power_off, 971 .power_off = mtk_phy_power_off,
972 .set_mode = mtk_phy_set_mode,
934 .owner = THIS_MODULE, 973 .owner = THIS_MODULE,
935}; 974};
936 975
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a268f4d6f3e9..b4964b067aec 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -372,6 +372,21 @@ int phy_reset(struct phy *phy)
372} 372}
373EXPORT_SYMBOL_GPL(phy_reset); 373EXPORT_SYMBOL_GPL(phy_reset);
374 374
375int phy_calibrate(struct phy *phy)
376{
377 int ret;
378
379 if (!phy || !phy->ops->calibrate)
380 return 0;
381
382 mutex_lock(&phy->mutex);
383 ret = phy->ops->calibrate(phy);
384 mutex_unlock(&phy->mutex);
385
386 return ret;
387}
388EXPORT_SYMBOL_GPL(phy_calibrate);
389
375/** 390/**
376 * _of_phy_get() - lookup and obtain a reference to a phy by phandle 391 * _of_phy_get() - lookup and obtain a reference to a phy by phandle
377 * @np: device_node for which to get the phy 392 * @np: device_node for which to get the phy
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
index 13b02b7de30b..822c83b8efcd 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
@@ -114,14 +114,16 @@ struct ufs_qcom_phy {
114 struct ufs_qcom_phy_calibration *cached_regs; 114 struct ufs_qcom_phy_calibration *cached_regs;
115 int cached_regs_table_size; 115 int cached_regs_table_size;
116 bool is_powered_on; 116 bool is_powered_on;
117 bool is_started;
117 struct ufs_qcom_phy_specific_ops *phy_spec_ops; 118 struct ufs_qcom_phy_specific_ops *phy_spec_ops;
119
120 enum phy_mode mode;
118}; 121};
119 122
120/** 123/**
121 * struct ufs_qcom_phy_specific_ops - set of pointers to functions which have a 124 * struct ufs_qcom_phy_specific_ops - set of pointers to functions which have a
122 * specific implementation per phy. Each UFS phy, should implement 125 * specific implementation per phy. Each UFS phy, should implement
123 * those functions according to its spec and requirements 126 * those functions according to its spec and requirements
124 * @calibrate_phy: pointer to a function that calibrate the phy
125 * @start_serdes: pointer to a function that starts the serdes 127 * @start_serdes: pointer to a function that starts the serdes
126 * @is_physical_coding_sublayer_ready: pointer to a function that 128 * @is_physical_coding_sublayer_ready: pointer to a function that
127 * checks pcs readiness. returns 0 for success and non-zero for error. 129 * checks pcs readiness. returns 0 for success and non-zero for error.
@@ -130,7 +132,6 @@ struct ufs_qcom_phy {
130 * and writes to QSERDES_RX_SIGDET_CNTRL attribute 132 * and writes to QSERDES_RX_SIGDET_CNTRL attribute
131 */ 133 */
132struct ufs_qcom_phy_specific_ops { 134struct ufs_qcom_phy_specific_ops {
133 int (*calibrate_phy)(struct ufs_qcom_phy *phy, bool is_rate_B);
134 void (*start_serdes)(struct ufs_qcom_phy *phy); 135 void (*start_serdes)(struct ufs_qcom_phy *phy);
135 int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy); 136 int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy);
136 void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val); 137 void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
index 12a1b498dc4b..ba1895b76a5d 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
@@ -44,7 +44,19 @@ void ufs_qcom_phy_qmp_14nm_advertise_quirks(struct ufs_qcom_phy *phy_common)
44 44
45static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy) 45static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy)
46{ 46{
47 return 0; 47 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
48 bool is_rate_B = false;
49 int ret;
50
51 if (phy_common->mode == PHY_MODE_UFS_HS_B)
52 is_rate_B = true;
53
54 ret = ufs_qcom_phy_qmp_14nm_phy_calibrate(phy_common, is_rate_B);
55 if (!ret)
56 /* phy calibrated, but yet to be started */
57 phy_common->is_started = false;
58
59 return ret;
48} 60}
49 61
50static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy) 62static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
@@ -53,6 +65,19 @@ static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
53} 65}
54 66
55static 67static
68int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
69{
70 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
71
72 phy_common->mode = PHY_MODE_INVALID;
73
74 if (mode > 0)
75 phy_common->mode = mode;
76
77 return 0;
78}
79
80static
56void ufs_qcom_phy_qmp_14nm_power_control(struct ufs_qcom_phy *phy, bool val) 81void ufs_qcom_phy_qmp_14nm_power_control(struct ufs_qcom_phy *phy, bool val)
57{ 82{
58 writel_relaxed(val ? 0x1 : 0x0, phy->mmio + UFS_PHY_POWER_DOWN_CONTROL); 83 writel_relaxed(val ? 0x1 : 0x0, phy->mmio + UFS_PHY_POWER_DOWN_CONTROL);
@@ -102,11 +127,11 @@ static const struct phy_ops ufs_qcom_phy_qmp_14nm_phy_ops = {
102 .exit = ufs_qcom_phy_qmp_14nm_exit, 127 .exit = ufs_qcom_phy_qmp_14nm_exit,
103 .power_on = ufs_qcom_phy_power_on, 128 .power_on = ufs_qcom_phy_power_on,
104 .power_off = ufs_qcom_phy_power_off, 129 .power_off = ufs_qcom_phy_power_off,
130 .set_mode = ufs_qcom_phy_qmp_14nm_set_mode,
105 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
106}; 132};
107 133
108static struct ufs_qcom_phy_specific_ops phy_14nm_ops = { 134static struct ufs_qcom_phy_specific_ops phy_14nm_ops = {
109 .calibrate_phy = ufs_qcom_phy_qmp_14nm_phy_calibrate,
110 .start_serdes = ufs_qcom_phy_qmp_14nm_start_serdes, 135 .start_serdes = ufs_qcom_phy_qmp_14nm_start_serdes,
111 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready, 136 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready,
112 .set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable, 137 .set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
index 4f68acb58b73..49f435c71147 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
@@ -63,7 +63,19 @@ void ufs_qcom_phy_qmp_20nm_advertise_quirks(struct ufs_qcom_phy *phy_common)
63 63
64static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy) 64static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
65{ 65{
66 return 0; 66 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
67 bool is_rate_B = false;
68 int ret;
69
70 if (phy_common->mode == PHY_MODE_UFS_HS_B)
71 is_rate_B = true;
72
73 ret = ufs_qcom_phy_qmp_20nm_phy_calibrate(phy_common, is_rate_B);
74 if (!ret)
75 /* phy calibrated, but yet to be started */
76 phy_common->is_started = false;
77
78 return ret;
67} 79}
68 80
69static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy) 81static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
@@ -72,6 +84,19 @@ static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
72} 84}
73 85
74static 86static
87int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
88{
89 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
90
91 phy_common->mode = PHY_MODE_INVALID;
92
93 if (mode > 0)
94 phy_common->mode = mode;
95
96 return 0;
97}
98
99static
75void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, bool val) 100void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, bool val)
76{ 101{
77 bool hibern8_exit_after_pwr_collapse = phy->quirks & 102 bool hibern8_exit_after_pwr_collapse = phy->quirks &
@@ -160,11 +185,11 @@ static const struct phy_ops ufs_qcom_phy_qmp_20nm_phy_ops = {
160 .exit = ufs_qcom_phy_qmp_20nm_exit, 185 .exit = ufs_qcom_phy_qmp_20nm_exit,
161 .power_on = ufs_qcom_phy_power_on, 186 .power_on = ufs_qcom_phy_power_on,
162 .power_off = ufs_qcom_phy_power_off, 187 .power_off = ufs_qcom_phy_power_off,
188 .set_mode = ufs_qcom_phy_qmp_20nm_set_mode,
163 .owner = THIS_MODULE, 189 .owner = THIS_MODULE,
164}; 190};
165 191
166static struct ufs_qcom_phy_specific_ops phy_20nm_ops = { 192static struct ufs_qcom_phy_specific_ops phy_20nm_ops = {
167 .calibrate_phy = ufs_qcom_phy_qmp_20nm_phy_calibrate,
168 .start_serdes = ufs_qcom_phy_qmp_20nm_start_serdes, 193 .start_serdes = ufs_qcom_phy_qmp_20nm_start_serdes,
169 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready, 194 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready,
170 .set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable, 195 .set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c
index 43865ef340e2..c5ff4525edef 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs.c
@@ -518,9 +518,8 @@ void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
518 } 518 }
519} 519}
520 520
521int ufs_qcom_phy_start_serdes(struct phy *generic_phy) 521static int ufs_qcom_phy_start_serdes(struct ufs_qcom_phy *ufs_qcom_phy)
522{ 522{
523 struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
524 int ret = 0; 523 int ret = 0;
525 524
526 if (!ufs_qcom_phy->phy_spec_ops->start_serdes) { 525 if (!ufs_qcom_phy->phy_spec_ops->start_serdes) {
@@ -533,7 +532,6 @@ int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
533 532
534 return ret; 533 return ret;
535} 534}
536EXPORT_SYMBOL_GPL(ufs_qcom_phy_start_serdes);
537 535
538int ufs_qcom_phy_set_tx_lane_enable(struct phy *generic_phy, u32 tx_lanes) 536int ufs_qcom_phy_set_tx_lane_enable(struct phy *generic_phy, u32 tx_lanes)
539{ 537{
@@ -564,31 +562,8 @@ void ufs_qcom_phy_save_controller_version(struct phy *generic_phy,
564} 562}
565EXPORT_SYMBOL_GPL(ufs_qcom_phy_save_controller_version); 563EXPORT_SYMBOL_GPL(ufs_qcom_phy_save_controller_version);
566 564
567int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, bool is_rate_B) 565static int ufs_qcom_phy_is_pcs_ready(struct ufs_qcom_phy *ufs_qcom_phy)
568{
569 struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
570 int ret = 0;
571
572 if (!ufs_qcom_phy->phy_spec_ops->calibrate_phy) {
573 dev_err(ufs_qcom_phy->dev, "%s: calibrate_phy() callback is not supported\n",
574 __func__);
575 ret = -ENOTSUPP;
576 } else {
577 ret = ufs_qcom_phy->phy_spec_ops->
578 calibrate_phy(ufs_qcom_phy, is_rate_B);
579 if (ret)
580 dev_err(ufs_qcom_phy->dev, "%s: calibrate_phy() failed %d\n",
581 __func__, ret);
582 }
583
584 return ret;
585}
586EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy);
587
588int ufs_qcom_phy_is_pcs_ready(struct phy *generic_phy)
589{ 566{
590 struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
591
592 if (!ufs_qcom_phy->phy_spec_ops->is_physical_coding_sublayer_ready) { 567 if (!ufs_qcom_phy->phy_spec_ops->is_physical_coding_sublayer_ready) {
593 dev_err(ufs_qcom_phy->dev, "%s: is_physical_coding_sublayer_ready() callback is not supported\n", 568 dev_err(ufs_qcom_phy->dev, "%s: is_physical_coding_sublayer_ready() callback is not supported\n",
594 __func__); 569 __func__);
@@ -598,7 +573,6 @@ int ufs_qcom_phy_is_pcs_ready(struct phy *generic_phy)
598 return ufs_qcom_phy->phy_spec_ops-> 573 return ufs_qcom_phy->phy_spec_ops->
599 is_physical_coding_sublayer_ready(ufs_qcom_phy); 574 is_physical_coding_sublayer_ready(ufs_qcom_phy);
600} 575}
601EXPORT_SYMBOL_GPL(ufs_qcom_phy_is_pcs_ready);
602 576
603int ufs_qcom_phy_power_on(struct phy *generic_phy) 577int ufs_qcom_phy_power_on(struct phy *generic_phy)
604{ 578{
@@ -609,6 +583,18 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
609 if (phy_common->is_powered_on) 583 if (phy_common->is_powered_on)
610 return 0; 584 return 0;
611 585
586 if (!phy_common->is_started) {
587 err = ufs_qcom_phy_start_serdes(phy_common);
588 if (err)
589 return err;
590
591 err = ufs_qcom_phy_is_pcs_ready(phy_common);
592 if (err)
593 return err;
594
595 phy_common->is_started = true;
596 }
597
612 err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy); 598 err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy);
613 if (err) { 599 if (err) {
614 dev_err(dev, "%s enable vdda_phy failed, err=%d\n", 600 dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 54c34298a000..9c90e7d67e0a 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Renesas R-Car Gen3 for USB2.0 PHY driver 2 * Renesas R-Car Gen3 for USB2.0 PHY driver
3 * 3 *
4 * Copyright (C) 2015 Renesas Electronics Corporation 4 * Copyright (C) 2015-2017 Renesas Electronics Corporation
5 * 5 *
6 * This is based on the phy-rcar-gen2 driver: 6 * This is based on the phy-rcar-gen2 driver:
7 * Copyright (C) 2014 Renesas Solutions Corp. 7 * Copyright (C) 2014 Renesas Solutions Corp.
@@ -12,16 +12,18 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#include <linux/extcon.h> 15#include <linux/extcon-provider.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/of_address.h> 20#include <linux/of_address.h>
21#include <linux/of_device.h>
21#include <linux/phy/phy.h> 22#include <linux/phy/phy.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
24#include <linux/regulator/consumer.h> 25#include <linux/regulator/consumer.h>
26#include <linux/usb/of.h>
25#include <linux/workqueue.h> 27#include <linux/workqueue.h>
26 28
27/******* USB2.0 Host registers (original offset is +0x200) *******/ 29/******* USB2.0 Host registers (original offset is +0x200) *******/
@@ -79,6 +81,8 @@
79#define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ 81#define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
80#define USB2_ADPCTRL_DRVVBUS BIT(4) 82#define USB2_ADPCTRL_DRVVBUS BIT(4)
81 83
84#define RCAR_GEN3_PHY_HAS_DEDICATED_PINS 1
85
82struct rcar_gen3_chan { 86struct rcar_gen3_chan {
83 void __iomem *base; 87 void __iomem *base;
84 struct extcon_dev *extcon; 88 struct extcon_dev *extcon;
@@ -86,7 +90,7 @@ struct rcar_gen3_chan {
86 struct regulator *vbus; 90 struct regulator *vbus;
87 struct work_struct work; 91 struct work_struct work;
88 bool extcon_host; 92 bool extcon_host;
89 bool has_otg; 93 bool has_otg_pins;
90}; 94};
91 95
92static void rcar_gen3_phy_usb2_work(struct work_struct *work) 96static void rcar_gen3_phy_usb2_work(struct work_struct *work)
@@ -218,33 +222,40 @@ static bool rcar_gen3_is_host(struct rcar_gen3_chan *ch)
218 return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI); 222 return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI);
219} 223}
220 224
225static enum phy_mode rcar_gen3_get_phy_mode(struct rcar_gen3_chan *ch)
226{
227 if (rcar_gen3_is_host(ch))
228 return PHY_MODE_USB_HOST;
229
230 return PHY_MODE_USB_DEVICE;
231}
232
221static ssize_t role_store(struct device *dev, struct device_attribute *attr, 233static ssize_t role_store(struct device *dev, struct device_attribute *attr,
222 const char *buf, size_t count) 234 const char *buf, size_t count)
223{ 235{
224 struct rcar_gen3_chan *ch = dev_get_drvdata(dev); 236 struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
225 bool is_b_device, is_host, new_mode_is_host; 237 bool is_b_device;
238 enum phy_mode cur_mode, new_mode;
226 239
227 if (!ch->has_otg || !ch->phy->init_count) 240 if (!ch->has_otg_pins || !ch->phy->init_count)
228 return -EIO; 241 return -EIO;
229 242
230 /*
231 * is_b_device: true is B-Device. false is A-Device.
232 * If {new_mode_}is_host: true is Host mode. false is Peripheral mode.
233 */
234 is_b_device = rcar_gen3_check_id(ch);
235 is_host = rcar_gen3_is_host(ch);
236 if (!strncmp(buf, "host", strlen("host"))) 243 if (!strncmp(buf, "host", strlen("host")))
237 new_mode_is_host = true; 244 new_mode = PHY_MODE_USB_HOST;
238 else if (!strncmp(buf, "peripheral", strlen("peripheral"))) 245 else if (!strncmp(buf, "peripheral", strlen("peripheral")))
239 new_mode_is_host = false; 246 new_mode = PHY_MODE_USB_DEVICE;
240 else 247 else
241 return -EINVAL; 248 return -EINVAL;
242 249
250 /* is_b_device: true is B-Device. false is A-Device. */
251 is_b_device = rcar_gen3_check_id(ch);
252 cur_mode = rcar_gen3_get_phy_mode(ch);
253
243 /* If current and new mode is the same, this returns the error */ 254 /* If current and new mode is the same, this returns the error */
244 if (is_host == new_mode_is_host) 255 if (cur_mode == new_mode)
245 return -EINVAL; 256 return -EINVAL;
246 257
247 if (new_mode_is_host) { /* And is_host must be false */ 258 if (new_mode == PHY_MODE_USB_HOST) { /* And is_host must be false */
248 if (!is_b_device) /* A-Peripheral */ 259 if (!is_b_device) /* A-Peripheral */
249 rcar_gen3_init_from_a_peri_to_a_host(ch); 260 rcar_gen3_init_from_a_peri_to_a_host(ch);
250 else /* B-Peripheral */ 261 else /* B-Peripheral */
@@ -264,7 +275,7 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr,
264{ 275{
265 struct rcar_gen3_chan *ch = dev_get_drvdata(dev); 276 struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
266 277
267 if (!ch->has_otg || !ch->phy->init_count) 278 if (!ch->has_otg_pins || !ch->phy->init_count)
268 return -EIO; 279 return -EIO;
269 280
270 return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" : 281 return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
@@ -303,7 +314,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
303 writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET); 314 writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET);
304 315
305 /* Initialize otg part */ 316 /* Initialize otg part */
306 if (channel->has_otg) 317 if (channel->has_otg_pins)
307 rcar_gen3_init_otg(channel); 318 rcar_gen3_init_otg(channel);
308 319
309 return 0; 320 return 0;
@@ -377,9 +388,17 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
377} 388}
378 389
379static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { 390static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
380 { .compatible = "renesas,usb2-phy-r8a7795" }, 391 {
381 { .compatible = "renesas,usb2-phy-r8a7796" }, 392 .compatible = "renesas,usb2-phy-r8a7795",
382 { .compatible = "renesas,rcar-gen3-usb2-phy" }, 393 .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
394 },
395 {
396 .compatible = "renesas,usb2-phy-r8a7796",
397 .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS,
398 },
399 {
400 .compatible = "renesas,rcar-gen3-usb2-phy",
401 },
383 { } 402 { }
384}; 403};
385MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); 404MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table);
@@ -415,14 +434,17 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
415 /* call request_irq for OTG */ 434 /* call request_irq for OTG */
416 irq = platform_get_irq(pdev, 0); 435 irq = platform_get_irq(pdev, 0);
417 if (irq >= 0) { 436 if (irq >= 0) {
418 int ret;
419
420 INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work); 437 INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
421 irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq, 438 irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
422 IRQF_SHARED, dev_name(dev), channel); 439 IRQF_SHARED, dev_name(dev), channel);
423 if (irq < 0) 440 if (irq < 0)
424 dev_err(dev, "No irq handler (%d)\n", irq); 441 dev_err(dev, "No irq handler (%d)\n", irq);
425 channel->has_otg = true; 442 }
443
444 if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) {
445 int ret;
446
447 channel->has_otg_pins = (uintptr_t)of_device_get_match_data(dev);
426 channel->extcon = devm_extcon_dev_allocate(dev, 448 channel->extcon = devm_extcon_dev_allocate(dev,
427 rcar_gen3_phy_cable); 449 rcar_gen3_phy_cable);
428 if (IS_ERR(channel->extcon)) 450 if (IS_ERR(channel->extcon))
@@ -464,7 +486,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
464 dev_err(dev, "Failed to register PHY provider\n"); 486 dev_err(dev, "Failed to register PHY provider\n");
465 ret = PTR_ERR(provider); 487 ret = PTR_ERR(provider);
466 goto error; 488 goto error;
467 } else if (channel->has_otg) { 489 } else if (channel->has_otg_pins) {
468 int ret; 490 int ret;
469 491
470 ret = device_create_file(dev, &dev_attr_role); 492 ret = device_create_file(dev, &dev_attr_role);
@@ -484,7 +506,7 @@ static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
484{ 506{
485 struct rcar_gen3_chan *channel = platform_get_drvdata(pdev); 507 struct rcar_gen3_chan *channel = platform_get_drvdata(pdev);
486 508
487 if (channel->has_otg) 509 if (channel->has_otg_pins)
488 device_remove_file(&pdev->dev, &dev_attr_role); 510 device_remove_file(&pdev->dev, &dev_attr_role);
489 511
490 pm_runtime_disable(&pdev->dev); 512 pm_runtime_disable(&pdev->dev);
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index ee7ce5ee53f9..5049dac79bd0 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -17,7 +17,7 @@
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/clk-provider.h> 18#include <linux/clk-provider.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/extcon.h> 20#include <linux/extcon-provider.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/gpio/consumer.h> 23#include <linux/gpio/consumer.h>
diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index a958c9bced01..ee85fa0ca4b0 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -102,9 +102,40 @@
102#define CMN_PLL1_SS_CTRL1 (0xb8 << 2) 102#define CMN_PLL1_SS_CTRL1 (0xb8 << 2)
103#define CMN_PLL1_SS_CTRL2 (0xb9 << 2) 103#define CMN_PLL1_SS_CTRL2 (0xb9 << 2)
104#define CMN_RXCAL_OVRD (0xd1 << 2) 104#define CMN_RXCAL_OVRD (0xd1 << 2)
105
105#define CMN_TXPUCAL_CTRL (0xe0 << 2) 106#define CMN_TXPUCAL_CTRL (0xe0 << 2)
106#define CMN_TXPUCAL_OVRD (0xe1 << 2) 107#define CMN_TXPUCAL_OVRD (0xe1 << 2)
108#define CMN_TXPDCAL_CTRL (0xf0 << 2)
107#define CMN_TXPDCAL_OVRD (0xf1 << 2) 109#define CMN_TXPDCAL_OVRD (0xf1 << 2)
110
111/* For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL */
112#define CMN_TXPXCAL_START BIT(15)
113#define CMN_TXPXCAL_DONE BIT(14)
114#define CMN_TXPXCAL_NO_RESPONSE BIT(13)
115#define CMN_TXPXCAL_CURRENT_RESPONSE BIT(12)
116
117#define CMN_TXPU_ADJ_CTRL (0x108 << 2)
118#define CMN_TXPD_ADJ_CTRL (0x10c << 2)
119
120/*
121 * For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL,
122 * CMN_TXPU_ADJ_CTRL, CMN_TXPDCAL_CTRL
123 *
124 * NOTE: some of these registers are documented to be 2's complement
125 * signed numbers, but then documented to be always positive. Weird.
126 * In such a case, using CMN_CALIB_CODE_POS() avoids the unnecessary
127 * sign extension.
128 */
129#define CMN_CALIB_CODE_WIDTH 7
130#define CMN_CALIB_CODE_OFFSET 0
131#define CMN_CALIB_CODE_MASK GENMASK(CMN_CALIB_CODE_WIDTH, 0)
132#define CMN_CALIB_CODE(x) \
133 sign_extend32((x) >> CMN_CALIB_CODE_OFFSET, CMN_CALIB_CODE_WIDTH)
134
135#define CMN_CALIB_CODE_POS_MASK GENMASK(CMN_CALIB_CODE_WIDTH - 1, 0)
136#define CMN_CALIB_CODE_POS(x) \
137 (((x) >> CMN_CALIB_CODE_OFFSET) & CMN_CALIB_CODE_POS_MASK)
138
108#define CMN_DIAG_PLL0_FBH_OVRD (0x1c0 << 2) 139#define CMN_DIAG_PLL0_FBH_OVRD (0x1c0 << 2)
109#define CMN_DIAG_PLL0_FBL_OVRD (0x1c1 << 2) 140#define CMN_DIAG_PLL0_FBL_OVRD (0x1c1 << 2)
110#define CMN_DIAG_PLL0_OVRD (0x1c2 << 2) 141#define CMN_DIAG_PLL0_OVRD (0x1c2 << 2)
@@ -138,6 +169,15 @@
138#define TX_TXCC_MGNFS_MULT_101(n) ((0x4055 | ((n) << 9)) << 2) 169#define TX_TXCC_MGNFS_MULT_101(n) ((0x4055 | ((n) << 9)) << 2)
139#define TX_TXCC_MGNFS_MULT_110(n) ((0x4056 | ((n) << 9)) << 2) 170#define TX_TXCC_MGNFS_MULT_110(n) ((0x4056 | ((n) << 9)) << 2)
140#define TX_TXCC_MGNFS_MULT_111(n) ((0x4057 | ((n) << 9)) << 2) 171#define TX_TXCC_MGNFS_MULT_111(n) ((0x4057 | ((n) << 9)) << 2)
172#define TX_TXCC_MGNLS_MULT_000(n) ((0x4058 | ((n) << 9)) << 2)
173#define TX_TXCC_MGNLS_MULT_001(n) ((0x4059 | ((n) << 9)) << 2)
174#define TX_TXCC_MGNLS_MULT_010(n) ((0x405a | ((n) << 9)) << 2)
175#define TX_TXCC_MGNLS_MULT_011(n) ((0x405b | ((n) << 9)) << 2)
176#define TX_TXCC_MGNLS_MULT_100(n) ((0x405c | ((n) << 9)) << 2)
177#define TX_TXCC_MGNLS_MULT_101(n) ((0x405d | ((n) << 9)) << 2)
178#define TX_TXCC_MGNLS_MULT_110(n) ((0x405e | ((n) << 9)) << 2)
179#define TX_TXCC_MGNLS_MULT_111(n) ((0x405f | ((n) << 9)) << 2)
180
141#define XCVR_DIAG_PLLDRC_CTRL(n) ((0x40e0 | ((n) << 9)) << 2) 181#define XCVR_DIAG_PLLDRC_CTRL(n) ((0x40e0 | ((n) << 9)) << 2)
142#define XCVR_DIAG_BIDI_CTRL(n) ((0x40e8 | ((n) << 9)) << 2) 182#define XCVR_DIAG_BIDI_CTRL(n) ((0x40e8 | ((n) << 9)) << 2)
143#define XCVR_DIAG_LANE_FCM_EN_MGN(n) ((0x40f2 | ((n) << 9)) << 2) 183#define XCVR_DIAG_LANE_FCM_EN_MGN(n) ((0x40f2 | ((n) << 9)) << 2)
@@ -150,10 +190,63 @@
150#define TX_RCVDET_ST_TMR(n) ((0x4123 | ((n) << 9)) << 2) 190#define TX_RCVDET_ST_TMR(n) ((0x4123 | ((n) << 9)) << 2)
151#define TX_DIAG_TX_DRV(n) ((0x41e1 | ((n) << 9)) << 2) 191#define TX_DIAG_TX_DRV(n) ((0x41e1 | ((n) << 9)) << 2)
152#define TX_DIAG_BGREF_PREDRV_DELAY (0x41e7 << 2) 192#define TX_DIAG_BGREF_PREDRV_DELAY (0x41e7 << 2)
193
194/* Use this for "n" in macros like "_MULT_XXX" to target the aux channel */
195#define AUX_CH_LANE 8
196
153#define TX_ANA_CTRL_REG_1 (0x5020 << 2) 197#define TX_ANA_CTRL_REG_1 (0x5020 << 2)
198
199#define TXDA_DP_AUX_EN BIT(15)
200#define AUXDA_SE_EN BIT(14)
201#define TXDA_CAL_LATCH_EN BIT(13)
202#define AUXDA_POLARITY BIT(12)
203#define TXDA_DRV_POWER_ISOLATION_EN BIT(11)
204#define TXDA_DRV_POWER_EN_PH_2_N BIT(10)
205#define TXDA_DRV_POWER_EN_PH_1_N BIT(9)
206#define TXDA_BGREF_EN BIT(8)
207#define TXDA_DRV_LDO_EN BIT(7)
208#define TXDA_DECAP_EN_DEL BIT(6)
209#define TXDA_DECAP_EN BIT(5)
210#define TXDA_UPHY_SUPPLY_EN_DEL BIT(4)
211#define TXDA_UPHY_SUPPLY_EN BIT(3)
212#define TXDA_LOW_LEAKAGE_EN BIT(2)
213#define TXDA_DRV_IDLE_LOWI_EN BIT(1)
214#define TXDA_DRV_CMN_MODE_EN BIT(0)
215
154#define TX_ANA_CTRL_REG_2 (0x5021 << 2) 216#define TX_ANA_CTRL_REG_2 (0x5021 << 2)
217
218#define AUXDA_DEBOUNCING_CLK BIT(15)
219#define TXDA_LPBK_RECOVERED_CLK_EN BIT(14)
220#define TXDA_LPBK_ISI_GEN_EN BIT(13)
221#define TXDA_LPBK_SERIAL_EN BIT(12)
222#define TXDA_LPBK_LINE_EN BIT(11)
223#define TXDA_DRV_LDO_REDC_SINKIQ BIT(10)
224#define XCVR_DECAP_EN_DEL BIT(9)
225#define XCVR_DECAP_EN BIT(8)
226#define TXDA_MPHY_ENABLE_HS_NT BIT(7)
227#define TXDA_MPHY_SA_MODE BIT(6)
228#define TXDA_DRV_LDO_RBYR_FB_EN BIT(5)
229#define TXDA_DRV_RST_PULL_DOWN BIT(4)
230#define TXDA_DRV_LDO_BG_FB_EN BIT(3)
231#define TXDA_DRV_LDO_BG_REF_EN BIT(2)
232#define TXDA_DRV_PREDRV_EN_DEL BIT(1)
233#define TXDA_DRV_PREDRV_EN BIT(0)
234
155#define TXDA_COEFF_CALC_CTRL (0x5022 << 2) 235#define TXDA_COEFF_CALC_CTRL (0x5022 << 2)
236
237#define TX_HIGH_Z BIT(6)
238#define TX_VMARGIN_OFFSET 3
239#define TX_VMARGIN_MASK 0x7
240#define LOW_POWER_SWING_EN BIT(2)
241#define TX_FCM_DRV_MAIN_EN BIT(1)
242#define TX_FCM_FULL_MARGIN BIT(0)
243
156#define TX_DIG_CTRL_REG_2 (0x5024 << 2) 244#define TX_DIG_CTRL_REG_2 (0x5024 << 2)
245
246#define TX_HIGH_Z_TM_EN BIT(15)
247#define TX_RESCAL_CODE_OFFSET 0
248#define TX_RESCAL_CODE_MASK 0x3f
249
157#define TXDA_CYA_AUXDA_CYA (0x5025 << 2) 250#define TXDA_CYA_AUXDA_CYA (0x5025 << 2)
158#define TX_ANA_CTRL_REG_3 (0x5026 << 2) 251#define TX_ANA_CTRL_REG_3 (0x5026 << 2)
159#define TX_ANA_CTRL_REG_4 (0x5027 << 2) 252#define TX_ANA_CTRL_REG_4 (0x5027 << 2)
@@ -456,54 +549,72 @@ static void tcphy_dp_aux_set_flip(struct rockchip_typec_phy *tcphy)
456 */ 549 */
457 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1); 550 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
458 if (!tcphy->flip) 551 if (!tcphy->flip)
459 tx_ana_ctrl_reg_1 |= BIT(12); 552 tx_ana_ctrl_reg_1 |= AUXDA_POLARITY;
460 else 553 else
461 tx_ana_ctrl_reg_1 &= ~BIT(12); 554 tx_ana_ctrl_reg_1 &= ~AUXDA_POLARITY;
462 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 555 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
463} 556}
464 557
465static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy) 558static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
466{ 559{
560 u16 val;
467 u16 tx_ana_ctrl_reg_1; 561 u16 tx_ana_ctrl_reg_1;
468 u16 rdata, rdata2, val; 562 u16 tx_ana_ctrl_reg_2;
469 563 s32 pu_calib_code, pd_calib_code;
470 /* disable txda_cal_latch_en for rewrite the calibration values */ 564 s32 pu_adj, pd_adj;
471 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1); 565 u16 calib;
472 tx_ana_ctrl_reg_1 &= ~BIT(13);
473 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
474 566
475 /* 567 /*
476 * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and 568 * Calculate calibration code as per docs: use an average of the
477 * write it to TX_DIG_CTRL_REG_2[6:0], and delay 1ms to make sure it 569 * pull down and pull up. Then add in adjustments.
478 * works.
479 */ 570 */
480 rdata = readl(tcphy->base + TX_DIG_CTRL_REG_2); 571 val = readl(tcphy->base + CMN_TXPUCAL_CTRL);
481 rdata = rdata & 0xffc0; 572 pu_calib_code = CMN_CALIB_CODE_POS(val);
573 val = readl(tcphy->base + CMN_TXPDCAL_CTRL);
574 pd_calib_code = CMN_CALIB_CODE_POS(val);
575 val = readl(tcphy->base + CMN_TXPU_ADJ_CTRL);
576 pu_adj = CMN_CALIB_CODE(val);
577 val = readl(tcphy->base + CMN_TXPD_ADJ_CTRL);
578 pd_adj = CMN_CALIB_CODE(val);
579 calib = (pu_calib_code + pd_calib_code) / 2 + pu_adj + pd_adj;
482 580
483 rdata2 = readl(tcphy->base + CMN_TXPUCAL_CTRL); 581 /* disable txda_cal_latch_en for rewrite the calibration values */
484 rdata2 = rdata2 & 0x3f; 582 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);
583 tx_ana_ctrl_reg_1 &= ~TXDA_CAL_LATCH_EN;
584 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
485 585
486 val = rdata | rdata2; 586 /* write the calibration, then delay 10 ms as sample in docs */
587 val = readl(tcphy->base + TX_DIG_CTRL_REG_2);
588 val &= ~(TX_RESCAL_CODE_MASK << TX_RESCAL_CODE_OFFSET);
589 val |= calib << TX_RESCAL_CODE_OFFSET;
487 writel(val, tcphy->base + TX_DIG_CTRL_REG_2); 590 writel(val, tcphy->base + TX_DIG_CTRL_REG_2);
488 usleep_range(1000, 1050); 591 usleep_range(10000, 10050);
489 592
490 /* 593 /*
491 * Enable signal for latch that sample and holds calibration values. 594 * Enable signal for latch that sample and holds calibration values.
492 * Activate this signal for 1 clock cycle to sample new calibration 595 * Activate this signal for 1 clock cycle to sample new calibration
493 * values. 596 * values.
494 */ 597 */
495 tx_ana_ctrl_reg_1 |= BIT(13); 598 tx_ana_ctrl_reg_1 |= TXDA_CAL_LATCH_EN;
496 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 599 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
497 usleep_range(150, 200); 600 usleep_range(150, 200);
498 601
499 /* set TX Voltage Level and TX Deemphasis to 0 */ 602 /* set TX Voltage Level and TX Deemphasis to 0 */
500 writel(0, tcphy->base + PHY_DP_TX_CTL); 603 writel(0, tcphy->base + PHY_DP_TX_CTL);
604
501 /* re-enable decap */ 605 /* re-enable decap */
502 writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2); 606 tx_ana_ctrl_reg_2 = XCVR_DECAP_EN;
503 writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2); 607 writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2);
504 tx_ana_ctrl_reg_1 |= BIT(3); 608 udelay(1);
609 tx_ana_ctrl_reg_2 |= XCVR_DECAP_EN_DEL;
610 writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2);
611
612 writel(0, tcphy->base + TX_ANA_CTRL_REG_3);
613
614 tx_ana_ctrl_reg_1 |= TXDA_UPHY_SUPPLY_EN;
505 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 615 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
506 tx_ana_ctrl_reg_1 |= BIT(4); 616 udelay(1);
617 tx_ana_ctrl_reg_1 |= TXDA_UPHY_SUPPLY_EN_DEL;
507 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 618 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
508 619
509 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 620 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
@@ -515,44 +626,66 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)
515 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4); 626 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4);
516 627
517 /* re-enables Bandgap reference for LDO */ 628 /* re-enables Bandgap reference for LDO */
518 tx_ana_ctrl_reg_1 |= BIT(7); 629 tx_ana_ctrl_reg_1 |= TXDA_DRV_LDO_EN;
519 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 630 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
520 tx_ana_ctrl_reg_1 |= BIT(8); 631 udelay(5);
632 tx_ana_ctrl_reg_1 |= TXDA_BGREF_EN;
521 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 633 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
522 634
523 /* 635 /*
524 * re-enables the transmitter pre-driver, driver data selection MUX, 636 * re-enables the transmitter pre-driver, driver data selection MUX,
525 * and receiver detect circuits. 637 * and receiver detect circuits.
526 */ 638 */
527 writel(0x301, tcphy->base + TX_ANA_CTRL_REG_2); 639 tx_ana_ctrl_reg_2 |= TXDA_DRV_PREDRV_EN;
528 writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2); 640 writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2);
641 udelay(1);
642 tx_ana_ctrl_reg_2 |= TXDA_DRV_PREDRV_EN_DEL;
643 writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2);
529 644
530 /* 645 /*
531 * Do some magic undocumented stuff, some of which appears to 646 * Do all the undocumented magic:
532 * undo the "re-enables Bandgap reference for LDO" above. 647 * - Turn on TXDA_DP_AUX_EN, whatever that is, even though sample
648 * never shows this going on.
649 * - Turn on TXDA_DECAP_EN (and TXDA_DECAP_EN_DEL) even though
650 * docs say for aux it's always 0.
651 * - Turn off the LDO and BGREF, which we just spent time turning
652 * on above (???).
653 *
654 * Without this magic, things seem worse.
533 */ 655 */
534 tx_ana_ctrl_reg_1 |= BIT(15); 656 tx_ana_ctrl_reg_1 |= TXDA_DP_AUX_EN;
535 tx_ana_ctrl_reg_1 &= ~BIT(8); 657 tx_ana_ctrl_reg_1 |= TXDA_DECAP_EN;
536 tx_ana_ctrl_reg_1 &= ~BIT(7); 658 tx_ana_ctrl_reg_1 &= ~TXDA_DRV_LDO_EN;
537 tx_ana_ctrl_reg_1 |= BIT(6); 659 tx_ana_ctrl_reg_1 &= ~TXDA_BGREF_EN;
538 tx_ana_ctrl_reg_1 |= BIT(5); 660 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
661 udelay(1);
662 tx_ana_ctrl_reg_1 |= TXDA_DECAP_EN_DEL;
539 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 663 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);
540
541 writel(0, tcphy->base + TX_ANA_CTRL_REG_3);
542 writel(0, tcphy->base + TX_ANA_CTRL_REG_4);
543 writel(0, tcphy->base + TX_ANA_CTRL_REG_5);
544 664
545 /* 665 /*
546 * Controls low_power_swing_en, don't set the voltage swing of the 666 * Undo the work we did to set the LDO voltage.
547 * driver to 400mv. The values below are peak to peak (differential) 667 * This doesn't seem to help nor hurt, but it kinda goes with the
548 * values. 668 * undocumented magic above.
549 */ 669 */
670 writel(0, tcphy->base + TX_ANA_CTRL_REG_4);
671
672 /* Don't set voltage swing to 400 mV peak to peak (differential) */
550 writel(0, tcphy->base + TXDA_COEFF_CALC_CTRL); 673 writel(0, tcphy->base + TXDA_COEFF_CALC_CTRL);
674
675 /* Init TXDA_CYA_AUXDA_CYA for unknown magic reasons */
551 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA); 676 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA);
552 677
553 /* Controls tx_high_z_tm_en */ 678 /*
679 * More undocumented magic, presumably the goal of which is to
680 * make the "auxda_source_aux_oen" be ignored and instead to decide
681 * about "high impedance state" based on what software puts in the
682 * register TXDA_COEFF_CALC_CTRL (see TX_HIGH_Z). Since we only
683 * program that register once and we don't set the bit TX_HIGH_Z,
684 * presumably the goal here is that we should never put the analog
685 * driver in high impedance state.
686 */
554 val = readl(tcphy->base + TX_DIG_CTRL_REG_2); 687 val = readl(tcphy->base + TX_DIG_CTRL_REG_2);
555 val |= BIT(15); 688 val |= TX_HIGH_Z_TM_EN;
556 writel(val, tcphy->base + TX_DIG_CTRL_REG_2); 689 writel(val, tcphy->base + TX_DIG_CTRL_REG_2);
557} 690}
558 691
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 0e564f32749f..68ce4a082b9b 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -68,6 +68,40 @@
68#define PCIE_PCS_MASK 0xFF0000 68#define PCIE_PCS_MASK 0xFF0000
69#define PCIE_PCS_DELAY_COUNT_SHIFT 0x10 69#define PCIE_PCS_DELAY_COUNT_SHIFT 0x10
70 70
71#define PCIEPHYRX_ANA_PROGRAMMABILITY 0x0000000C
72#define INTERFACE_MASK GENMASK(31, 27)
73#define INTERFACE_SHIFT 27
74#define LOSD_MASK GENMASK(17, 14)
75#define LOSD_SHIFT 14
76#define MEM_PLLDIV GENMASK(6, 5)
77
78#define PCIEPHYRX_TRIM 0x0000001C
79#define MEM_DLL_TRIM_SEL GENMASK(31, 30)
80#define MEM_DLL_TRIM_SHIFT 30
81
82#define PCIEPHYRX_DLL 0x00000024
83#define MEM_DLL_PHINT_RATE GENMASK(31, 30)
84
85#define PCIEPHYRX_DIGITAL_MODES 0x00000028
86#define MEM_CDR_FASTLOCK BIT(23)
87#define MEM_CDR_LBW GENMASK(22, 21)
88#define MEM_CDR_STEPCNT GENMASK(20, 19)
89#define MEM_CDR_STL_MASK GENMASK(18, 16)
90#define MEM_CDR_STL_SHIFT 16
91#define MEM_CDR_THR_MASK GENMASK(15, 13)
92#define MEM_CDR_THR_SHIFT 13
93#define MEM_CDR_THR_MODE BIT(12)
94#define MEM_CDR_CDR_2NDO_SDM_MODE BIT(11)
95#define MEM_OVRD_HS_RATE BIT(26)
96
97#define PCIEPHYRX_EQUALIZER 0x00000038
98#define MEM_EQLEV GENMASK(31, 16)
99#define MEM_EQFTC GENMASK(15, 11)
100#define MEM_EQCTL GENMASK(10, 7)
101#define MEM_EQCTL_SHIFT 7
102#define MEM_OVRD_EQLEV BIT(2)
103#define MEM_OVRD_EQFTC BIT(1)
104
71/* 105/*
72 * This is an Empirical value that works, need to confirm the actual 106 * This is an Empirical value that works, need to confirm the actual
73 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status 107 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
@@ -91,6 +125,8 @@ struct pipe3_dpll_map {
91 125
92struct ti_pipe3 { 126struct ti_pipe3 {
93 void __iomem *pll_ctrl_base; 127 void __iomem *pll_ctrl_base;
128 void __iomem *phy_rx;
129 void __iomem *phy_tx;
94 struct device *dev; 130 struct device *dev;
95 struct device *control_dev; 131 struct device *control_dev;
96 struct clk *wkupclk; 132 struct clk *wkupclk;
@@ -261,6 +297,37 @@ static int ti_pipe3_dpll_program(struct ti_pipe3 *phy)
261 return ti_pipe3_dpll_wait_lock(phy); 297 return ti_pipe3_dpll_wait_lock(phy);
262} 298}
263 299
300static void ti_pipe3_calibrate(struct ti_pipe3 *phy)
301{
302 u32 val;
303
304 val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY);
305 val &= ~(INTERFACE_MASK | LOSD_MASK | MEM_PLLDIV);
306 val = (0x1 << INTERFACE_SHIFT | 0xA << LOSD_SHIFT);
307 ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY, val);
308
309 val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES);
310 val &= ~(MEM_CDR_STEPCNT | MEM_CDR_STL_MASK | MEM_CDR_THR_MASK |
311 MEM_CDR_CDR_2NDO_SDM_MODE | MEM_OVRD_HS_RATE);
312 val |= (MEM_CDR_FASTLOCK | MEM_CDR_LBW | 0x3 << MEM_CDR_STL_SHIFT |
313 0x1 << MEM_CDR_THR_SHIFT | MEM_CDR_THR_MODE);
314 ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES, val);
315
316 val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_TRIM);
317 val &= ~MEM_DLL_TRIM_SEL;
318 val |= 0x2 << MEM_DLL_TRIM_SHIFT;
319 ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_TRIM, val);
320
321 val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DLL);
322 val |= MEM_DLL_PHINT_RATE;
323 ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DLL, val);
324
325 val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_EQUALIZER);
326 val &= ~(MEM_EQLEV | MEM_EQCTL | MEM_OVRD_EQLEV | MEM_OVRD_EQFTC);
327 val |= MEM_EQFTC | 0x1 << MEM_EQCTL_SHIFT;
328 ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_EQUALIZER, val);
329}
330
264static int ti_pipe3_init(struct phy *x) 331static int ti_pipe3_init(struct phy *x)
265{ 332{
266 struct ti_pipe3 *phy = phy_get_drvdata(x); 333 struct ti_pipe3 *phy = phy_get_drvdata(x);
@@ -282,7 +349,12 @@ static int ti_pipe3_init(struct phy *x)
282 val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT; 349 val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
283 ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg, 350 ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg,
284 PCIE_PCS_MASK, val); 351 PCIE_PCS_MASK, val);
285 return ret; 352 if (ret)
353 return ret;
354
355 ti_pipe3_calibrate(phy);
356
357 return 0;
286 } 358 }
287 359
288 /* Bring it out of IDLE if it is IDLE */ 360 /* Bring it out of IDLE if it is IDLE */
@@ -513,6 +585,29 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
513 return 0; 585 return 0;
514} 586}
515 587
588static int ti_pipe3_get_tx_rx_base(struct ti_pipe3 *phy)
589{
590 struct resource *res;
591 struct device *dev = phy->dev;
592 struct device_node *node = dev->of_node;
593 struct platform_device *pdev = to_platform_device(dev);
594
595 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
596 return 0;
597
598 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
599 "phy_rx");
600 phy->phy_rx = devm_ioremap_resource(dev, res);
601 if (IS_ERR(phy->phy_rx))
602 return PTR_ERR(phy->phy_rx);
603
604 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
605 "phy_tx");
606 phy->phy_tx = devm_ioremap_resource(dev, res);
607
608 return PTR_ERR_OR_ZERO(phy->phy_tx);
609}
610
516static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy) 611static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
517{ 612{
518 struct resource *res; 613 struct resource *res;
@@ -559,6 +654,10 @@ static int ti_pipe3_probe(struct platform_device *pdev)
559 if (ret) 654 if (ret)
560 return ret; 655 return ret;
561 656
657 ret = ti_pipe3_get_tx_rx_base(phy);
658 if (ret)
659 return ret;
660
562 ret = ti_pipe3_get_sysctrl(phy); 661 ret = ti_pipe3_get_sysctrl(phy);
563 if (ret) 662 if (ret)
564 return ret; 663 return ret;
diff --git a/drivers/power/supply/qcom_smbb.c b/drivers/power/supply/qcom_smbb.c
index f6a0d245731d..11de691b9a71 100644
--- a/drivers/power/supply/qcom_smbb.c
+++ b/drivers/power/supply/qcom_smbb.c
@@ -34,7 +34,7 @@
34#include <linux/power_supply.h> 34#include <linux/power_supply.h>
35#include <linux/regmap.h> 35#include <linux/regmap.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/extcon.h> 37#include <linux/extcon-provider.h>
38#include <linux/regulator/driver.h> 38#include <linux/regulator/driver.h>
39 39
40#define SMBB_CHG_VMAX 0x040 40#define SMBB_CHG_VMAX 0x040
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index c87d770b519a..890eafeb8ad4 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -273,15 +273,18 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
273 bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B) 273 bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
274 ? true : false; 274 ? true : false;
275 275
276 if (is_rate_B)
277 phy_set_mode(phy, PHY_MODE_UFS_HS_B);
278
276 /* Assert PHY reset and apply PHY calibration values */ 279 /* Assert PHY reset and apply PHY calibration values */
277 ufs_qcom_assert_reset(hba); 280 ufs_qcom_assert_reset(hba);
278 /* provide 1ms delay to let the reset pulse propagate */ 281 /* provide 1ms delay to let the reset pulse propagate */
279 usleep_range(1000, 1100); 282 usleep_range(1000, 1100);
280 283
281 ret = ufs_qcom_phy_calibrate_phy(phy, is_rate_B); 284 /* phy initialization - calibrate the phy */
282 285 ret = phy_init(phy);
283 if (ret) { 286 if (ret) {
284 dev_err(hba->dev, "%s: ufs_qcom_phy_calibrate_phy() failed, ret = %d\n", 287 dev_err(hba->dev, "%s: phy init failed, ret = %d\n",
285 __func__, ret); 288 __func__, ret);
286 goto out; 289 goto out;
287 } 290 }
@@ -294,21 +297,22 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
294 * voltage, current to settle down before starting serdes. 297 * voltage, current to settle down before starting serdes.
295 */ 298 */
296 usleep_range(1000, 1100); 299 usleep_range(1000, 1100);
297 ret = ufs_qcom_phy_start_serdes(phy); 300
301 /* power on phy - start serdes and phy's power and clocks */
302 ret = phy_power_on(phy);
298 if (ret) { 303 if (ret) {
299 dev_err(hba->dev, "%s: ufs_qcom_phy_start_serdes() failed, ret = %d\n", 304 dev_err(hba->dev, "%s: phy power on failed, ret = %d\n",
300 __func__, ret); 305 __func__, ret);
301 goto out; 306 goto out_disable_phy;
302 } 307 }
303 308
304 ret = ufs_qcom_phy_is_pcs_ready(phy);
305 if (ret)
306 dev_err(hba->dev,
307 "%s: is_physical_coding_sublayer_ready() failed, ret = %d\n",
308 __func__, ret);
309
310 ufs_qcom_select_unipro_mode(host); 309 ufs_qcom_select_unipro_mode(host);
311 310
311 return 0;
312
313out_disable_phy:
314 ufs_qcom_assert_reset(hba);
315 phy_exit(phy);
312out: 316out:
313 return ret; 317 return ret;
314} 318}
@@ -1273,14 +1277,9 @@ static int ufs_qcom_init(struct ufs_hba *hba)
1273 ufs_qcom_phy_save_controller_version(host->generic_phy, 1277 ufs_qcom_phy_save_controller_version(host->generic_phy,
1274 host->hw_ver.major, host->hw_ver.minor, host->hw_ver.step); 1278 host->hw_ver.major, host->hw_ver.minor, host->hw_ver.step);
1275 1279
1276 phy_init(host->generic_phy);
1277 err = phy_power_on(host->generic_phy);
1278 if (err)
1279 goto out_unregister_bus;
1280
1281 err = ufs_qcom_init_lane_clks(host); 1280 err = ufs_qcom_init_lane_clks(host);
1282 if (err) 1281 if (err)
1283 goto out_disable_phy; 1282 goto out_variant_clear;
1284 1283
1285 ufs_qcom_set_caps(hba); 1284 ufs_qcom_set_caps(hba);
1286 ufs_qcom_advertise_quirks(hba); 1285 ufs_qcom_advertise_quirks(hba);
@@ -1301,10 +1300,6 @@ static int ufs_qcom_init(struct ufs_hba *hba)
1301 1300
1302 goto out; 1301 goto out;
1303 1302
1304out_disable_phy:
1305 phy_power_off(host->generic_phy);
1306out_unregister_bus:
1307 phy_exit(host->generic_phy);
1308out_variant_clear: 1303out_variant_clear:
1309 ufshcd_set_variant(hba, NULL); 1304 ufshcd_set_variant(hba, NULL);
1310out: 1305out:
diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index 22e98a90468c..a71730da6385 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
40 return of_match_node(brcmstb_machine_match, root) != NULL; 40 return of_match_node(brcmstb_machine_match, root) != NULL;
41} 41}
42 42
43u32 brcmstb_get_family_id(void)
44{
45 return family_id;
46}
47EXPORT_SYMBOL(brcmstb_get_family_id);
48
49u32 brcmstb_get_product_id(void)
50{
51 return product_id;
52}
53EXPORT_SYMBOL(brcmstb_get_product_id);
54
43static const struct of_device_id sun_top_ctrl_match[] = { 55static const struct of_device_id sun_top_ctrl_match[] = {
44 { .compatible = "brcm,bcm7125-sun-top-ctrl", }, 56 { .compatible = "brcm,bcm7125-sun-top-ctrl", },
45 { .compatible = "brcm,bcm7346-sun-top-ctrl", }, 57 { .compatible = "brcm,bcm7346-sun-top-ctrl", },
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 5975d47dfa71..197f5a914e8f 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -2457,7 +2457,7 @@ int hfa384x_drvr_start(struct hfa384x *hw)
2457 * ok 2457 * ok
2458 */ 2458 */
2459 result = 2459 result =
2460 usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in, &status); 2460 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in, &status);
2461 if (result < 0) { 2461 if (result < 0) {
2462 netdev_err(hw->wlandev->netdev, "Cannot get bulk in endpoint status.\n"); 2462 netdev_err(hw->wlandev->netdev, "Cannot get bulk in endpoint status.\n");
2463 goto done; 2463 goto done;
@@ -2466,7 +2466,7 @@ int hfa384x_drvr_start(struct hfa384x *hw)
2466 netdev_err(hw->wlandev->netdev, "Failed to reset bulk in endpoint.\n"); 2466 netdev_err(hw->wlandev->netdev, "Failed to reset bulk in endpoint.\n");
2467 2467
2468 result = 2468 result =
2469 usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out, &status); 2469 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out, &status);
2470 if (result < 0) { 2470 if (result < 0) {
2471 netdev_err(hw->wlandev->netdev, "Cannot get bulk out endpoint status.\n"); 2471 netdev_err(hw->wlandev->netdev, "Cannot get bulk out endpoint status.\n");
2472 goto done; 2472 goto done;
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 939a63bca82f..f699abab1787 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -77,11 +77,12 @@ config USB_PCI
77 depends on PCI 77 depends on PCI
78 default y 78 default y
79 ---help--- 79 ---help---
80 A lot of embeded system SOC (e.g. freescale T2080) have both 80 Many embedded system SOCs (e.g. freescale T2080) have both
81 PCI and USB modules. But USB module is controlled by registers 81 PCI and USB modules with the USB module directly controlled by
82 directly, it have no relationship with PCI module. 82 registers and having no relationship to the PCI module.
83 83
84 When say N here it will not build PCI related code in USB driver. 84 If you have such a device you may say N here and PCI related code
85 will not be built in the USB driver.
85 86
86if USB 87if USB
87 88
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 5160a4a966b3..6470d259b7d8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************** 2/******************************************************************************
2 * cxacru.c - driver for USB ADSL modems based on 3 * cxacru.c - driver for USB ADSL modems based on
3 * Conexant AccessRunner chipset 4 * Conexant AccessRunner chipset
@@ -6,21 +7,6 @@
6 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru) 7 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru)
7 * Copyright (C) 2007 Simon Arlott 8 * Copyright (C) 2007 Simon Arlott
8 * Copyright (C) 2009 Simon Arlott 9 * Copyright (C) 2009 Simon Arlott
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program; if not, write to the Free Software Foundation, Inc., 59
22 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 ******************************************************************************/ 10 ******************************************************************************/
25 11
26/* 12/*
@@ -424,6 +410,7 @@ static ssize_t cxacru_sysfs_store_adsl_state(struct device *dev,
424 case CXPOLL_STOPPING: 410 case CXPOLL_STOPPING:
425 /* abort stop request */ 411 /* abort stop request */
426 instance->poll_state = CXPOLL_POLLING; 412 instance->poll_state = CXPOLL_POLLING;
413 /* fall through */
427 case CXPOLL_POLLING: 414 case CXPOLL_POLLING:
428 case CXPOLL_SHUTDOWN: 415 case CXPOLL_SHUTDOWN:
429 /* don't start polling */ 416 /* don't start polling */
@@ -570,10 +557,8 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
570{ 557{
571 struct timer_list timer; 558 struct timer_list timer;
572 559
573 init_timer(&timer); 560 setup_timer(&timer, cxacru_timeout_kill, (unsigned long)urb);
574 timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT); 561 timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
575 timer.data = (unsigned long) urb;
576 timer.function = cxacru_timeout_kill;
577 add_timer(&timer); 562 add_timer(&timer);
578 wait_for_completion(done); 563 wait_for_completion(done);
579 del_timer_sync(&timer); 564 del_timer_sync(&timer);
@@ -797,6 +782,7 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
797 case CXPOLL_STOPPING: 782 case CXPOLL_STOPPING:
798 /* abort stop request */ 783 /* abort stop request */
799 instance->poll_state = CXPOLL_POLLING; 784 instance->poll_state = CXPOLL_POLLING;
785 /* fall through */
800 case CXPOLL_POLLING: 786 case CXPOLL_POLLING:
801 case CXPOLL_SHUTDOWN: 787 case CXPOLL_SHUTDOWN:
802 /* don't start polling */ 788 /* don't start polling */
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 3676adb40d89..5a5e8c0aaa39 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************** 2/******************************************************************************
2 * speedtch.c - Alcatel SpeedTouch USB xDSL modem driver 3 * speedtch.c - Alcatel SpeedTouch USB xDSL modem driver
3 * 4 *
@@ -6,21 +7,6 @@
6 * Copyright (C) 2004, David Woodhouse 7 * Copyright (C) 2004, David Woodhouse
7 * 8 *
8 * Based on "modem_run.c", copyright (C) 2001, Benoit Papillault 9 * Based on "modem_run.c", copyright (C) 2001, Benoit Papillault
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program; if not, write to the Free Software Foundation, Inc., 59
22 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 ******************************************************************************/ 10 ******************************************************************************/
25 11
26#include <asm/page.h> 12#include <asm/page.h>
@@ -874,16 +860,13 @@ static int speedtch_bind(struct usbatm_data *usbatm,
874 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 860 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
875 861
876 INIT_WORK(&instance->status_check_work, speedtch_check_status); 862 INIT_WORK(&instance->status_check_work, speedtch_check_status);
877 init_timer(&instance->status_check_timer); 863 setup_timer(&instance->status_check_timer, speedtch_status_poll,
878 864 (unsigned long)instance);
879 instance->status_check_timer.function = speedtch_status_poll;
880 instance->status_check_timer.data = (unsigned long)instance;
881 instance->last_status = 0xff; 865 instance->last_status = 0xff;
882 instance->poll_delay = MIN_POLL_DELAY; 866 instance->poll_delay = MIN_POLL_DELAY;
883 867
884 init_timer(&instance->resubmit_timer); 868 setup_timer(&instance->resubmit_timer, speedtch_resubmit_int,
885 instance->resubmit_timer.function = speedtch_resubmit_int; 869 (unsigned long)instance);
886 instance->resubmit_timer.data = (unsigned long)instance;
887 870
888 instance->int_urb = usb_alloc_urb(0, GFP_KERNEL); 871 instance->int_urb = usb_alloc_urb(0, GFP_KERNEL);
889 872
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index ba7616395db2..ab75690044bb 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/*- 2/*-
2 * Copyright (c) 2003, 2004 3 * Copyright (c) 2003, 2004
3 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 4 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 8607af758bbd..044264aa1f96 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************** 2/******************************************************************************
2 * usbatm.c - Generic USB xDSL driver core 3 * usbatm.c - Generic USB xDSL driver core
3 * 4 *
4 * Copyright (C) 2001, Alcatel 5 * Copyright (C) 2001, Alcatel
5 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas 6 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
6 * Copyright (C) 2004, David Woodhouse, Roman Kagan 7 * Copyright (C) 2004, David Woodhouse, Roman Kagan
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 ******************************************************************************/ 8 ******************************************************************************/
23 9
24/* 10/*
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index f3eecd967a8a..d3bdc4cc47aa 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************** 2/******************************************************************************
2 * usbatm.h - Generic USB xDSL driver core 3 * usbatm.h - Generic USB xDSL driver core
3 * 4 *
4 * Copyright (C) 2001, Alcatel 5 * Copyright (C) 2001, Alcatel
5 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas 6 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
6 * Copyright (C) 2004, David Woodhouse 7 * Copyright (C) 2004, David Woodhouse
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 ******************************************************************************/ 8 ******************************************************************************/
23 9
24#ifndef _USBATM_H_ 10#ifndef _USBATM_H_
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index c73c1ec3005e..ffc9810070a3 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -1,22 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/****************************************************************************** 2/******************************************************************************
2 * xusbatm.c - dumb usbatm-based driver for modems initialized in userspace 3 * xusbatm.c - dumb usbatm-based driver for modems initialized in userspace
3 * 4 *
4 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru) 5 * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59
18 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 ******************************************************************************/ 6 ******************************************************************************/
21 7
22#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/usb/c67x00/Makefile b/drivers/usb/c67x00/Makefile
index da5f314a5de0..0cde62d06e5d 100644
--- a/drivers/usb/c67x00/Makefile
+++ b/drivers/usb/c67x00/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for Cypress C67X00 USB Controller 3# Makefile for Cypress C67X00 USB Controller
3# 4#
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
index 5796c8820514..53838e7d4eef 100644
--- a/drivers/usb/c67x00/c67x00-drv.c
+++ b/drivers/usb/c67x00/c67x00-drv.c
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00-drv.c: Cypress C67X00 USB Common infrastructure 3 * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24/* 10/*
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c
index 30d3f346686e..c39eee17c0e4 100644
--- a/drivers/usb/c67x00/c67x00-hcd.c
+++ b/drivers/usb/c67x00/c67x00-hcd.c
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver 3 * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24#include <linux/device.h> 10#include <linux/device.h>
diff --git a/drivers/usb/c67x00/c67x00-hcd.h b/drivers/usb/c67x00/c67x00-hcd.h
index cf8a455a6403..3b181d4c7a03 100644
--- a/drivers/usb/c67x00/c67x00-hcd.h
+++ b/drivers/usb/c67x00/c67x00-hcd.h
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00-hcd.h: Cypress C67X00 USB HCD 3 * c67x00-hcd.h: Cypress C67X00 USB HCD
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24#ifndef _USB_C67X00_HCD_H 10#ifndef _USB_C67X00_HCD_H
diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c
index b58151841e10..e1fe3603140a 100644
--- a/drivers/usb/c67x00/c67x00-ll-hpi.c
+++ b/drivers/usb/c67x00/c67x00-ll-hpi.c
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00-ll-hpi.c: Cypress C67X00 USB Low level interface using HPI 3 * c67x00-ll-hpi.c: Cypress C67X00 USB Low level interface using HPI
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24#include <asm/byteorder.h> 10#include <asm/byteorder.h>
diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c
index 7311ed61e99a..633c52de3bb3 100644
--- a/drivers/usb/c67x00/c67x00-sched.c
+++ b/drivers/usb/c67x00/c67x00-sched.c
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00-sched.c: Cypress C67X00 USB Host Controller Driver - TD scheduling 3 * c67x00-sched.c: Cypress C67X00 USB Host Controller Driver - TD scheduling
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24#include <linux/kthread.h> 10#include <linux/kthread.h>
@@ -966,13 +952,11 @@ static void c67x00_handle_successful_td(struct c67x00_hcd *c67x00,
966static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td) 952static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td)
967{ 953{
968 struct urb *urb = td->urb; 954 struct urb *urb = td->urb;
969 struct c67x00_urb_priv *urbp;
970 int cnt; 955 int cnt;
971 956
972 if (!urb) 957 if (!urb)
973 return; 958 return;
974 959
975 urbp = urb->hcpriv;
976 cnt = td->privdata; 960 cnt = td->privdata;
977 961
978 if (td->status & TD_ERROR_MASK) 962 if (td->status & TD_ERROR_MASK)
diff --git a/drivers/usb/c67x00/c67x00.h b/drivers/usb/c67x00/c67x00.h
index a26e9ded0f32..7ce10928b037 100644
--- a/drivers/usb/c67x00/c67x00.h
+++ b/drivers/usb/c67x00/c67x00.h
@@ -1,24 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * c67x00.h: Cypress C67X00 USB register and field definitions 3 * c67x00.h: Cypress C67X00 USB register and field definitions
3 * 4 *
4 * Copyright (C) 2006-2008 Barco N.V. 5 * Copyright (C) 2006-2008 Barco N.V.
5 * Derived from the Cypress cy7c67200/300 ezusb linux driver and 6 * Derived from the Cypress cy7c67200/300 ezusb linux driver and
6 * based on multiple host controller drivers inside the linux kernel. 7 * based on multiple host controller drivers inside the linux kernel.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */ 8 */
23 9
24#ifndef _USB_C67X00_H 10#ifndef _USB_C67X00_H
diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 51f4157bbecf..785f0ed037f7 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -9,7 +9,7 @@ config USB_CHIPIDEA
9 Dual-role switch (ID, OTG FSM, sysfs), Host-only, and 9 Dual-role switch (ID, OTG FSM, sysfs), Host-only, and
10 Peripheral-only. 10 Peripheral-only.
11 11
12 When compiled dynamically, the module will be called ci-hdrc.ko. 12 When compiled dynamically, the module will be called ci_hdrc.ko.
13 13
14if USB_CHIPIDEA 14if USB_CHIPIDEA
15 15
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index e462f55c8b99..98da99510be7 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * bits.h - register bits of the ChipIdea USB IP core 3 * bits.h - register bits of the ChipIdea USB IP core
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef __DRIVERS_USB_CHIPIDEA_BITS_H 10#ifndef __DRIVERS_USB_CHIPIDEA_BITS_H
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 6743f85b1b7a..98b7cb3d0064 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ci.h - common structures, functions, and macros of the ChipIdea driver 3 * ci.h - common structures, functions, and macros of the ChipIdea driver
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef __DRIVERS_USB_CHIPIDEA_CI_H 10#ifndef __DRIVERS_USB_CHIPIDEA_CI_H
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 5f4a8157fad8..3b45c25f296e 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -1,14 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2012 Freescale Semiconductor, Inc. 3 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Copyright (C) 2012 Marek Vasut <marex@denx.de> 4 * Copyright (C) 2012 Marek Vasut <marex@denx.de>
4 * on behalf of DENX Software Engineering GmbH 5 * on behalf of DENX Software Engineering GmbH
5 *
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
9 *
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
12 */ 6 */
13 7
14#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h
index d666c9f036ba..204275f47573 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.h
+++ b/drivers/usb/chipidea/ci_hdrc_imx.h
@@ -1,12 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2012 Freescale Semiconductor, Inc. 3 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */ 4 */
11 5
12#ifndef __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H 6#ifndef __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c
index bb626120296f..3593ce0ec641 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -1,9 +1,5 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. 1// SPDX-License-Identifier: GPL-2.0
2 * 2/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 */
7 3
8#include <linux/module.h> 4#include <linux/module.h>
9#include <linux/platform_device.h> 5#include <linux/platform_device.h>
diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c
index 39414e4b2d81..49a61549cee6 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ci_hdrc_pci.c - MIPS USB IP core family device controller 3 * ci_hdrc_pci.c - MIPS USB IP core family device controller
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/platform_device.h> 10#include <linux/platform_device.h>
diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
index bfcee2702d50..7b65a1040d2c 100644
--- a/drivers/usb/chipidea/ci_hdrc_tegra.c
+++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
@@ -1,9 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2016, NVIDIA Corporation 3 * Copyright (c) 2016, NVIDIA Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 */ 4 */
8 5
9#include <linux/clk.h> 6#include <linux/clk.h>
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 99425db9ba62..c044fba463e4 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Marvell Technology Group Ltd. 3 * Copyright (C) 2014 Marvell Technology Group Ltd.
3 * 4 *
4 * Antoine Tenart <antoine.tenart@free-electrons.com> 5 * Antoine Tenart <antoine.tenart@free-electrons.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */ 6 */
10 7
11#include <linux/clk.h> 8#include <linux/clk.h>
diff --git a/drivers/usb/chipidea/ci_hdrc_zevio.c b/drivers/usb/chipidea/ci_hdrc_zevio.c
index 1264de505527..e1634da4a4b1 100644
--- a/drivers/usb/chipidea/ci_hdrc_zevio.c
+++ b/drivers/usb/chipidea/ci_hdrc_zevio.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au> 3 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2, as
6 * published by the Free Software Foundation.
7 *
8 * Based off drivers/usb/chipidea/ci_hdrc_msm.c 5 * Based off drivers/usb/chipidea/ci_hdrc_msm.c
9 *
10 */ 6 */
11 7
12#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 43ea5fb87b9a..dd2dd9391bb7 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * core.c - ChipIdea USB IP core family device controller 3 * core.c - ChipIdea USB IP core family device controller
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13/* 10/*
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 18cb8e46262d..19d60ed7e41f 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -1,22 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * host.c - ChipIdea USB host controller driver 3 * host.c - ChipIdea USB host controller driver
3 * 4 *
4 * Copyright (c) 2012 Intel Corporation 5 * Copyright (c) 2012 Intel Corporation
5 * 6 *
6 * Author: Alexander Shishkin 7 * Author: Alexander Shishkin
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 8 */
21 9
22#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 10236fe71522..db4ceffcf2a6 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * otg.c - ChipIdea USB IP core OTG driver 3 * otg.c - ChipIdea USB IP core OTG driver
3 * 4 *
4 * Copyright (C) 2013 Freescale Semiconductor, Inc. 5 * Copyright (C) 2013 Freescale Semiconductor, Inc.
5 * 6 *
6 * Author: Peter Chen 7 * Author: Peter Chen
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13/* 10/*
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
index 9ecb598e48f0..7e7428e48bfa 100644
--- a/drivers/usb/chipidea/otg.h
+++ b/drivers/usb/chipidea/otg.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2013-2014 Freescale Semiconductor, Inc. 3 * Copyright (C) 2013-2014 Freescale Semiconductor, Inc.
3 * 4 *
4 * Author: Peter Chen 5 * Author: Peter Chen
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H 8#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 5ea0246f650d..9e2d300060bc 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * otg_fsm.c - ChipIdea USB IP core OTG FSM driver 3 * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
3 * 4 *
4 * Copyright (C) 2014 Freescale Semiconductor, Inc. 5 * Copyright (C) 2014 Freescale Semiconductor, Inc.
5 * 6 *
6 * Author: Jun Li 7 * Author: Jun Li
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13/* 10/*
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
index 6366fe398ba6..2b49d29bf2fb 100644
--- a/drivers/usb/chipidea/otg_fsm.h
+++ b/drivers/usb/chipidea/otg_fsm.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Freescale Semiconductor, Inc. 3 * Copyright (C) 2014 Freescale Semiconductor, Inc.
3 * 4 *
4 * Author: Jun Li 5 * Author: Jun Li
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H 8#ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index fe8a90543ea3..9852ec5e6e01 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * udc.c - ChipIdea UDC driver 3 * udc.c - ChipIdea UDC driver
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/delay.h> 10#include <linux/delay.h>
@@ -1526,6 +1523,10 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
1526 gadget_ready = 1; 1523 gadget_ready = 1;
1527 spin_unlock_irqrestore(&ci->lock, flags); 1524 spin_unlock_irqrestore(&ci->lock, flags);
1528 1525
1526 if (ci->usb_phy)
1527 usb_phy_set_charger_state(ci->usb_phy, is_active ?
1528 USB_CHARGER_PRESENT : USB_CHARGER_ABSENT);
1529
1529 if (gadget_ready) { 1530 if (gadget_ready) {
1530 if (is_active) { 1531 if (is_active) {
1531 pm_runtime_get_sync(&_gadget->dev); 1532 pm_runtime_get_sync(&_gadget->dev);
diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h
index 2ecd1174d66c..e023735d94b7 100644
--- a/drivers/usb/chipidea/udc.h
+++ b/drivers/usb/chipidea/udc.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * udc.h - ChipIdea UDC structures 3 * udc.h - ChipIdea UDC structures
3 * 4 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 * 6 *
6 * Author: David Lopo 7 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef __DRIVERS_USB_CHIPIDEA_UDC_H 10#ifndef __DRIVERS_USB_CHIPIDEA_UDC_H
diff --git a/drivers/usb/chipidea/ulpi.c b/drivers/usb/chipidea/ulpi.c
index 1219583dc1b2..6da42dcd2888 100644
--- a/drivers/usb/chipidea/ulpi.c
+++ b/drivers/usb/chipidea/ulpi.c
@@ -1,14 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2016 Linaro Ltd. 3 * Copyright (c) 2016 Linaro Ltd.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */ 4 */
13 5
14#include <linux/device.h> 6#include <linux/device.h>
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 9f4a0185dd60..8cdf0af156c6 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -1,12 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2012 Freescale Semiconductor, Inc. 3 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */ 4 */
11 5
12#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile
index 32e85277b5cf..5d393a28f7f2 100644
--- a/drivers/usb/class/Makefile
+++ b/drivers/usb/class/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for USB Class drivers 3# Makefile for USB Class drivers
3# (one step up from the misc category) 4# (one step up from the misc category)
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 18c923a4c16e..8e0636c963a7 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * cdc-acm.c 3 * cdc-acm.c
3 * 4 *
@@ -12,20 +13,6 @@
12 * USB Abstract Control Model driver for USB modems and ISDN adapters 13 * USB Abstract Control Model driver for USB modems and ISDN adapters
13 * 14 *
14 * Sponsored by SuSE 15 * Sponsored by SuSE
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */ 16 */
30 17
31#undef DEBUG 18#undef DEBUG
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index fbaa2a90d25d..6c181a625daf 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * cdc-wdm.c 3 * cdc-wdm.c
3 * 4 *
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index fb87c17ed6fa..c454885ef4a0 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * usblp.c 3 * usblp.c
3 * 4 *
@@ -31,22 +32,6 @@
31 * none - Maintained in Linux kernel after v0.13 32 * none - Maintained in Linux kernel after v0.13
32 */ 33 */
33 34
34/*
35 * This program is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version.
39 *
40 * This program is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details.
44 *
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48 */
49
50#include <linux/module.h> 35#include <linux/module.h>
51#include <linux/kernel.h> 36#include <linux/kernel.h>
52#include <linux/sched/signal.h> 37#include <linux/sched/signal.h>
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 6ebfabfa0dc7..0b8b0f3bdd2f 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1,22 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/** 2/**
2 * drivers/usb/class/usbtmc.c - USB Test & Measurement class driver 3 * drivers/usb/class/usbtmc.c - USB Test & Measurement class driver
3 * 4 *
4 * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany 5 * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
5 * Copyright (C) 2008 Novell, Inc. 6 * Copyright (C) 2008 Novell, Inc.
6 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * The GNU General Public License is available at
19 * http://www.gnu.org/copyleft/gpl.html.
20 */ 8 */
21 9
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -1343,6 +1331,7 @@ static void usbtmc_interrupt(struct urb *urb)
1343 case -EOVERFLOW: 1331 case -EOVERFLOW:
1344 dev_err(dev, "overflow with length %d, actual length is %d\n", 1332 dev_err(dev, "overflow with length %d, actual length is %d\n",
1345 data->iin_wMaxPacketSize, urb->actual_length); 1333 data->iin_wMaxPacketSize, urb->actual_length);
1334 /* fall through */
1346 case -ECONNRESET: 1335 case -ECONNRESET:
1347 case -ENOENT: 1336 case -ENOENT:
1348 case -ESHUTDOWN: 1337 case -ESHUTDOWN:
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 552ff7ac5a6b..50a2362ed3ea 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Provides code common for host and device side USB. 3 * Provides code common for host and device side USB.
3 * 4 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, version 2.
7 *
8 * If either host side (ie. CONFIG_USB=y) or device side USB stack 5 * If either host side (ie. CONFIG_USB=y) or device side USB stack
9 * (ie. CONFIG_USB_GADGET=y) is compiled in the kernel, this module is 6 * (ie. CONFIG_USB_GADGET=y) is compiled in the kernel, this module is
10 * compiled-in as well. Otherwise, if either of the two stacks is 7 * compiled-in as well. Otherwise, if either of the two stacks is
diff --git a/drivers/usb/common/led.c b/drivers/usb/common/led.c
index df23da00a901..7bd81166b77d 100644
--- a/drivers/usb/common/led.c
+++ b/drivers/usb/common/led.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * LED Triggers for USB Activity 3 * LED Triggers for USB Activity
3 * 4 *
4 * Copyright 2014 Michal Sojka <sojka@merica.cz> 5 * Copyright 2014 Michal Sojka <sojka@merica.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */ 6 */
11 7
12#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 4aa5195db8ea..8b351444cc40 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * ulpi.c - USB ULPI PHY bus 3 * ulpi.c - USB ULPI PHY bus
3 * 4 *
4 * Copyright (C) 2015 Intel Corporation 5 * Copyright (C) 2015 Intel Corporation
5 * 6 *
6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 7 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/ulpi/interface.h> 10#include <linux/ulpi/interface.h>
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index b8fe31e409a5..3740cf95560e 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * OTG Finite State Machine from OTG spec 3 * OTG Finite State Machine from OTG spec
3 * 4 *
@@ -5,20 +6,6 @@
5 * 6 *
6 * Author: Li Yang <LeoLi@freescale.com> 7 * Author: Li Yang <LeoLi@freescale.com>
7 * Jerry Huang <Chang-Ming.Huang@freescale.com> 8 * Jerry Huang <Chang-Ming.Huang@freescale.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 9 */
23 10
24#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index b64568cf572c..77eef8acff94 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * DMA memory management for framework level HCD code (hc_driver) 3 * DMA memory management for framework level HCD code (hc_driver)
3 * 4 *
@@ -5,7 +6,6 @@
5 * and should work with all USB controllers, regardless of bus type. 6 * and should work with all USB controllers, regardless of bus type.
6 * 7 *
7 * Released under the GPLv2 only. 8 * Released under the GPLv2 only.
8 * SPDX-License-Identifier: GPL-2.0
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 883549ee946c..da8acd980fc6 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Released under the GPLv2 only. 3 * Released under the GPLv2 only.
3 * SPDX-License-Identifier: GPL-2.0
4 */ 4 */
5 5
6#include <linux/usb.h> 6#include <linux/usb.h>
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 55dea2e7828f..c2cf62b7043a 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * devices.c 3 * devices.c
3 * (C) Copyright 1999 Randy Dunlap. 4 * (C) Copyright 1999 Randy Dunlap.
@@ -5,20 +6,6 @@
5 * (proc file per device) 6 * (proc file per device)
6 * (C) Copyright 1999 Deti Fliegl (new USB architecture) 7 * (C) Copyright 1999 Deti Fliegl (new USB architecture)
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 ************************************************************* 9 *************************************************************
23 * 10 *
24 * <mountpoint>/devices contains USB topology, device, config, class, 11 * <mountpoint>/devices contains USB topology, device, config, class,
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 4ae667d8c238..705c573d0257 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/*****************************************************************************/ 2/*****************************************************************************/
2 3
3/* 4/*
@@ -5,20 +6,6 @@
5 * 6 *
6 * Copyright (C) 1999-2000 Thomas Sailer (sailer@ife.ee.ethz.ch) 7 * Copyright (C) 1999-2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * This file implements the usbfs/x/y files, where 9 * This file implements the usbfs/x/y files, where
23 * x is the bus number and y the device number. 10 * x is the bus number and y the device number.
24 * 11 *
@@ -1833,6 +1820,18 @@ static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg)
1833 return 0; 1820 return 0;
1834} 1821}
1835 1822
1823static void compute_isochronous_actual_length(struct urb *urb)
1824{
1825 unsigned int i;
1826
1827 if (urb->number_of_packets > 0) {
1828 urb->actual_length = 0;
1829 for (i = 0; i < urb->number_of_packets; i++)
1830 urb->actual_length +=
1831 urb->iso_frame_desc[i].actual_length;
1832 }
1833}
1834
1836static int processcompl(struct async *as, void __user * __user *arg) 1835static int processcompl(struct async *as, void __user * __user *arg)
1837{ 1836{
1838 struct urb *urb = as->urb; 1837 struct urb *urb = as->urb;
@@ -1840,6 +1839,7 @@ static int processcompl(struct async *as, void __user * __user *arg)
1840 void __user *addr = as->userurb; 1839 void __user *addr = as->userurb;
1841 unsigned int i; 1840 unsigned int i;
1842 1841
1842 compute_isochronous_actual_length(urb);
1843 if (as->userbuffer && urb->actual_length) { 1843 if (as->userbuffer && urb->actual_length) {
1844 if (copy_urb_data_to_user(as->userbuffer, urb)) 1844 if (copy_urb_data_to_user(as->userbuffer, urb))
1845 goto err_out; 1845 goto err_out;
@@ -2008,6 +2008,7 @@ static int processcompl_compat(struct async *as, void __user * __user *arg)
2008 void __user *addr = as->userurb; 2008 void __user *addr = as->userurb;
2009 unsigned int i; 2009 unsigned int i;
2010 2010
2011 compute_isochronous_actual_length(urb);
2011 if (as->userbuffer && urb->actual_length) { 2012 if (as->userbuffer && urb->actual_length) {
2012 if (copy_urb_data_to_user(as->userbuffer, urb)) 2013 if (copy_urb_data_to_user(as->userbuffer, urb))
2013 return -EFAULT; 2014 return -EFAULT;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index eb87a259d55c..64262a9a8829 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/driver.c - most of the driver model stuff for usb 3 * drivers/usb/driver.c - most of the driver model stuff for usb
3 * 4 *
@@ -16,7 +17,6 @@
16 * (C) Copyright Greg Kroah-Hartman 2002-2003 17 * (C) Copyright Greg Kroah-Hartman 2002-2003
17 * 18 *
18 * Released under the GPLv2 only. 19 * Released under the GPLv2 only.
19 * SPDX-License-Identifier: GPL-2.0
20 * 20 *
21 * NOTE! This is not actually a driver at all, rather this is 21 * NOTE! This is not actually a driver at all, rather this is
22 * just a collection of helper routines that implement the 22 * just a collection of helper routines that implement the
@@ -1340,8 +1340,8 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1340 int err; 1340 int err;
1341 u16 devstat; 1341 u16 devstat;
1342 1342
1343 err = usb_get_status(udev, USB_RECIP_DEVICE, 0, 1343 err = usb_get_std_status(udev, USB_RECIP_DEVICE, 0,
1344 &devstat); 1344 &devstat);
1345 if (err) { 1345 if (err) {
1346 dev_err(&udev->dev, 1346 dev_err(&udev->dev,
1347 "Failed to suspend device, error %d\n", 1347 "Failed to suspend device, error %d\n",
@@ -1461,6 +1461,7 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
1461int usb_suspend(struct device *dev, pm_message_t msg) 1461int usb_suspend(struct device *dev, pm_message_t msg)
1462{ 1462{
1463 struct usb_device *udev = to_usb_device(dev); 1463 struct usb_device *udev = to_usb_device(dev);
1464 int r;
1464 1465
1465 unbind_no_pm_drivers_interfaces(udev); 1466 unbind_no_pm_drivers_interfaces(udev);
1466 1467
@@ -1469,7 +1470,14 @@ int usb_suspend(struct device *dev, pm_message_t msg)
1469 * so we may still need to unbind and rebind upon resume 1470 * so we may still need to unbind and rebind upon resume
1470 */ 1471 */
1471 choose_wakeup(udev, msg); 1472 choose_wakeup(udev, msg);
1472 return usb_suspend_both(udev, msg); 1473 r = usb_suspend_both(udev, msg);
1474 if (r)
1475 return r;
1476
1477 if (udev->quirks & USB_QUIRK_DISCONNECT_SUSPEND)
1478 usb_port_disable(udev);
1479
1480 return 0;
1473} 1481}
1474 1482
1475/* The device lock is held by the PM core */ 1483/* The device lock is held by the PM core */
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index a60bc830a056..1c2c04079676 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/core/endpoint.c 3 * drivers/usb/core/endpoint.c
3 * 4 *
@@ -6,7 +7,6 @@
6 * (C) Copyright 2006 Novell Inc. 7 * (C) Copyright 2006 Novell Inc.
7 * 8 *
8 * Released under the GPLv2 only. 9 * Released under the GPLv2 only.
9 * SPDX-License-Identifier: GPL-2.0
10 * 10 *
11 * Endpoint sysfs stuff 11 * Endpoint sysfs stuff
12 */ 12 */
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 87ad6b6bfee8..65de6f73b672 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/core/file.c 3 * drivers/usb/core/file.c
3 * 4 *
@@ -14,7 +15,6 @@
14 * (C) Copyright Greg Kroah-Hartman 2002-2003 15 * (C) Copyright Greg Kroah-Hartman 2002-2003
15 * 16 *
16 * Released under the GPLv2 only. 17 * Released under the GPLv2 only.
17 * SPDX-License-Identifier: GPL-2.0
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index bd3e0c5a6db2..83c14dda6300 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/generic.c - generic driver for USB devices (not interfaces) 3 * drivers/usb/generic.c - generic driver for USB devices (not interfaces)
3 * 4 *
@@ -16,7 +17,6 @@
16 * (C) Copyright Greg Kroah-Hartman 2002-2003 17 * (C) Copyright Greg Kroah-Hartman 2002-2003
17 * 18 *
18 * Released under the GPLv2 only. 19 * Released under the GPLv2 only.
19 * SPDX-License-Identifier: GPL-2.0
20 */ 20 */
21 21
22#include <linux/usb.h> 22#include <linux/usb.h>
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index ea829ad798c0..66fe1b78d952 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * (C) Copyright David Brownell 2000-2002 3 * (C) Copyright David Brownell 2000-2002
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#include <linux/kernel.h> 6#include <linux/kernel.h>
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 75ad6718858c..19b5c4afeef2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * (C) Copyright Linus Torvalds 1999 3 * (C) Copyright Linus Torvalds 1999
3 * (C) Copyright Johannes Erdfelt 1999-2001 4 * (C) Copyright Johannes Erdfelt 1999-2001
@@ -6,20 +7,6 @@
6 * (C) Copyright Deti Fliegl 1999 7 * (C) Copyright Deti Fliegl 1999
7 * (C) Copyright Randy Dunlap 2000 8 * (C) Copyright Randy Dunlap 2000
8 * (C) Copyright David Brownell 2000-2002 9 * (C) Copyright David Brownell 2000-2002
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 10 */
24 11
25#include <linux/bcd.h> 12#include <linux/bcd.h>
@@ -2558,9 +2545,7 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
2558 hcd->self.bus_name = bus_name; 2545 hcd->self.bus_name = bus_name;
2559 hcd->self.uses_dma = (sysdev->dma_mask != NULL); 2546 hcd->self.uses_dma = (sysdev->dma_mask != NULL);
2560 2547
2561 init_timer(&hcd->rh_timer); 2548 setup_timer(&hcd->rh_timer, rh_timer_func, (unsigned long)hcd);
2562 hcd->rh_timer.function = rh_timer_func;
2563 hcd->rh_timer.data = (unsigned long) hcd;
2564#ifdef CONFIG_PM 2549#ifdef CONFIG_PM
2565 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2550 INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
2566#endif 2551#endif
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e9ce6bb0b22d..7ccdd3d4db84 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB hub driver. 3 * USB hub driver.
3 * 4 *
@@ -7,7 +8,6 @@
7 * (C) Copyright 2001 Brad Hards (bhards@bigpond.net.au) 8 * (C) Copyright 2001 Brad Hards (bhards@bigpond.net.au)
8 * 9 *
9 * Released under the GPLv2 only. 10 * Released under the GPLv2 only.
10 * SPDX-License-Identifier: GPL-2.0
11 */ 11 */
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -1482,7 +1482,7 @@ static int hub_configure(struct usb_hub *hub,
1482 /* power budgeting mostly matters with bus-powered hubs, 1482 /* power budgeting mostly matters with bus-powered hubs,
1483 * and battery-powered root hubs (may provide just 8 mA). 1483 * and battery-powered root hubs (may provide just 8 mA).
1484 */ 1484 */
1485 ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); 1485 ret = usb_get_std_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);
1486 if (ret) { 1486 if (ret) {
1487 message = "can't get hub status"; 1487 message = "can't get hub status";
1488 goto fail; 1488 goto fail;
@@ -3279,7 +3279,7 @@ static int finish_port_resume(struct usb_device *udev)
3279 */ 3279 */
3280 if (status == 0) { 3280 if (status == 0) {
3281 devstatus = 0; 3281 devstatus = 0;
3282 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); 3282 status = usb_get_std_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
3283 3283
3284 /* If a normal resume failed, try doing a reset-resume */ 3284 /* If a normal resume failed, try doing a reset-resume */
3285 if (status && !udev->reset_resume && udev->persist_enabled) { 3285 if (status && !udev->reset_resume && udev->persist_enabled) {
@@ -3303,7 +3303,7 @@ static int finish_port_resume(struct usb_device *udev)
3303 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) 3303 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
3304 status = usb_disable_remote_wakeup(udev); 3304 status = usb_disable_remote_wakeup(udev);
3305 } else { 3305 } else {
3306 status = usb_get_status(udev, USB_RECIP_INTERFACE, 0, 3306 status = usb_get_std_status(udev, USB_RECIP_INTERFACE, 0,
3307 &devstatus); 3307 &devstatus);
3308 if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP 3308 if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
3309 | USB_INTRF_STAT_FUNC_RW)) 3309 | USB_INTRF_STAT_FUNC_RW))
@@ -4183,6 +4183,19 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
4183 return ret; 4183 return ret;
4184} 4184}
4185 4185
4186/*
4187 * usb_port_disable - disable a usb device's upstream port
4188 * @udev: device to disable
4189 * Context: @udev locked, must be able to sleep.
4190 *
4191 * Disables a USB device that isn't in active use.
4192 */
4193int usb_port_disable(struct usb_device *udev)
4194{
4195 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
4196
4197 return hub_port_disable(hub, udev->portnum, 0);
4198}
4186 4199
4187/* USB 2.0 spec, 7.1.7.3 / fig 7-29: 4200/* USB 2.0 spec, 7.1.7.3 / fig 7-29:
4188 * 4201 *
@@ -4853,7 +4866,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4853 && udev->bus_mA <= unit_load) { 4866 && udev->bus_mA <= unit_load) {
4854 u16 devstat; 4867 u16 devstat;
4855 4868
4856 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, 4869 status = usb_get_std_status(udev, USB_RECIP_DEVICE, 0,
4857 &devstat); 4870 &devstat);
4858 if (status) { 4871 if (status) {
4859 dev_dbg(&udev->dev, "get status %d ?\n", status); 4872 dev_dbg(&udev->dev, "get status %d ?\n", status);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 34c1a7e22aae..2a700ccc868c 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * usb hub driver head file 3 * usb hub driver head file
3 * 4 *
@@ -8,15 +9,6 @@
8 * Copyright (C) 2012 Intel Corp (tianyu.lan@intel.com) 9 * Copyright (C) 2012 Intel Corp (tianyu.lan@intel.com)
9 * 10 *
10 * move struct usb_hub to this file. 11 * move struct usb_hub to this file.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 */ 12 */
21 13
22#include <linux/usb.h> 14#include <linux/usb.h>
diff --git a/drivers/usb/core/ledtrig-usbport.c b/drivers/usb/core/ledtrig-usbport.c
index 1af877942110..9dbb429cd471 100644
--- a/drivers/usb/core/ledtrig-usbport.c
+++ b/drivers/usb/core/ledtrig-usbport.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB port LED trigger 3 * USB port LED trigger
3 * 4 *
4 * Copyright (C) 2016 Rafał Miłecki <rafal@milecki.pl> 5 * Copyright (C) 2016 Rafał Miłecki <rafal@milecki.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/device.h> 8#include <linux/device.h>
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 371a07d874a3..77001bcfc504 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1,8 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * message.c - synchronous message handling 3 * message.c - synchronous message handling
3 * 4 *
4 * Released under the GPLv2 only. 5 * Released under the GPLv2 only.
5 * SPDX-License-Identifier: GPL-2.0
6 */ 6 */
7 7
8#include <linux/pci.h> /* for scatterlist macros */ 8#include <linux/pci.h> /* for scatterlist macros */
@@ -918,7 +918,8 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
918/** 918/**
919 * usb_get_status - issues a GET_STATUS call 919 * usb_get_status - issues a GET_STATUS call
920 * @dev: the device whose status is being checked 920 * @dev: the device whose status is being checked
921 * @type: USB_RECIP_*; for device, interface, or endpoint 921 * @recip: USB_RECIP_*; for device, interface, or endpoint
922 * @type: USB_STATUS_TYPE_*; for standard or PTM status types
922 * @target: zero (for device), else interface or endpoint number 923 * @target: zero (for device), else interface or endpoint number
923 * @data: pointer to two bytes of bitmap data 924 * @data: pointer to two bytes of bitmap data
924 * Context: !in_interrupt () 925 * Context: !in_interrupt ()
@@ -937,24 +938,58 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
937 * Returns 0 and the status value in *@data (in host byte order) on success, 938 * Returns 0 and the status value in *@data (in host byte order) on success,
938 * or else the status code from the underlying usb_control_msg() call. 939 * or else the status code from the underlying usb_control_msg() call.
939 */ 940 */
940int usb_get_status(struct usb_device *dev, int type, int target, void *data) 941int usb_get_status(struct usb_device *dev, int recip, int type, int target,
942 void *data)
941{ 943{
942 int ret; 944 int ret;
943 __le16 *status = kmalloc(sizeof(*status), GFP_KERNEL); 945 void *status;
946 int length;
947
948 switch (type) {
949 case USB_STATUS_TYPE_STANDARD:
950 length = 2;
951 break;
952 case USB_STATUS_TYPE_PTM:
953 if (recip != USB_RECIP_DEVICE)
954 return -EINVAL;
944 955
956 length = 4;
957 break;
958 default:
959 return -EINVAL;
960 }
961
962 status = kmalloc(length, GFP_KERNEL);
945 if (!status) 963 if (!status)
946 return -ENOMEM; 964 return -ENOMEM;
947 965
948 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 966 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
949 USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status, 967 USB_REQ_GET_STATUS, USB_DIR_IN | recip, USB_STATUS_TYPE_STANDARD,
950 sizeof(*status), USB_CTRL_GET_TIMEOUT); 968 target, status, length, USB_CTRL_GET_TIMEOUT);
951 969
952 if (ret == 2) { 970 switch (ret) {
953 *(u16 *) data = le16_to_cpu(*status); 971 case 4:
972 if (type != USB_STATUS_TYPE_PTM) {
973 ret = -EIO;
974 break;
975 }
976
977 *(u32 *) data = le32_to_cpu(*(__le32 *) status);
978 ret = 0;
979 break;
980 case 2:
981 if (type != USB_STATUS_TYPE_STANDARD) {
982 ret = -EIO;
983 break;
984 }
985
986 *(u16 *) data = le16_to_cpu(*(__le16 *) status);
954 ret = 0; 987 ret = 0;
955 } else if (ret >= 0) { 988 break;
989 default:
956 ret = -EIO; 990 ret = -EIO;
957 } 991 }
992
958 kfree(status); 993 kfree(status);
959 return ret; 994 return ret;
960} 995}
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c
index b12a463a3e22..ab474b11523e 100644
--- a/drivers/usb/core/notify.c
+++ b/drivers/usb/core/notify.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * All the USB notify logic 3 * All the USB notify logic
3 * 4 *
@@ -7,7 +8,6 @@
7 * but fixed up to not be so broken. 8 * but fixed up to not be so broken.
8 * 9 *
9 * Released under the GPLv2 only. 10 * Released under the GPLv2 only.
10 * SPDX-License-Identifier: GPL-2.0
11 */ 11 */
12 12
13 13
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index 3863bb1ce8c5..2be968353257 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * of.c The helpers for hcd device tree support 3 * of.c The helpers for hcd device tree support
3 * 4 *
4 * Copyright (C) 2016 Freescale Semiconductor, Inc. 5 * Copyright (C) 2016 Freescale Semiconductor, Inc.
5 * Author: Peter Chen <peter.chen@freescale.com> 6 * Author: Peter Chen <peter.chen@freescale.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19 8
20#include <linux/of.h> 9#include <linux/of.h>
diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
index 085049d37d7a..2ae90158ded7 100644
--- a/drivers/usb/core/otg_whitelist.h
+++ b/drivers/usb/core/otg_whitelist.h
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * drivers/usb/core/otg_whitelist.h 3 * drivers/usb/core/otg_whitelist.h
3 * 4 *
4 * Copyright (C) 2004 Texas Instruments 5 * Copyright (C) 2004 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12/* 8/*
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 460c855be0d0..1a01e9ad3804 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * usb port device code 3 * usb port device code
3 * 4 *
4 * Copyright (C) 2012 Intel Corp 5 * Copyright (C) 2012 Intel Corp
5 * 6 *
6 * Author: Lan Tianyu <tianyu.lan@intel.com> 7 * Author: Lan Tianyu <tianyu.lan@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 */ 8 */
18 9
19#include <linux/slab.h> 10#include <linux/slab.h>
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index a6aaf2f193a4..f1dbab6f798f 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -1,14 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB device quirk handling logic and table 3 * USB device quirk handling logic and table
3 * 4 *
4 * Copyright (c) 2007 Oliver Neukum 5 * Copyright (c) 2007 Oliver Neukum
5 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, version 2.
10 *
11 *
12 */ 7 */
13 8
14#include <linux/usb.h> 9#include <linux/usb.h>
@@ -203,6 +198,12 @@ static const struct usb_device_id usb_quirk_list[] = {
203 { USB_DEVICE(0x10d6, 0x2200), .driver_info = 198 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
204 USB_QUIRK_STRING_FETCH_255 }, 199 USB_QUIRK_STRING_FETCH_255 },
205 200
201 /* Huawei 4G LTE module */
202 { USB_DEVICE(0x12d1, 0x15bb), .driver_info =
203 USB_QUIRK_DISCONNECT_SUSPEND },
204 { USB_DEVICE(0x12d1, 0x15c3), .driver_info =
205 USB_QUIRK_DISCONNECT_SUSPEND },
206
206 /* SKYMEDI USB_DRIVE */ 207 /* SKYMEDI USB_DRIVE */
207 { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME }, 208 { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
208 209
@@ -221,6 +222,9 @@ static const struct usb_device_id usb_quirk_list[] = {
221 /* Corsair Strafe RGB */ 222 /* Corsair Strafe RGB */
222 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, 223 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
223 224
225 /* Corsair K70 LUX */
226 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
227
224 /* MIDI keyboard WORLDE MINI */ 228 /* MIDI keyboard WORLDE MINI */
225 { USB_DEVICE(0x1c75, 0x0204), .driver_info = 229 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
226 USB_QUIRK_CONFIG_INTF_STRINGS }, 230 USB_QUIRK_CONFIG_INTF_STRINGS },
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 58d59c5f8592..27bb34043053 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/core/sysfs.c 3 * drivers/usb/core/sysfs.c
3 * 4 *
@@ -8,7 +9,6 @@
8 * All of the sysfs file attributes for usb devices and interfaces. 9 * All of the sysfs file attributes for usb devices and interfaces.
9 * 10 *
10 * Released under the GPLv2 only. 11 * Released under the GPLv2 only.
11 * SPDX-License-Identifier: GPL-2.0
12 */ 12 */
13 13
14 14
@@ -654,7 +654,8 @@ static int add_power_attributes(struct device *dev)
654 if (udev->usb2_hw_lpm_capable == 1) 654 if (udev->usb2_hw_lpm_capable == 1)
655 rc = sysfs_merge_group(&dev->kobj, 655 rc = sysfs_merge_group(&dev->kobj,
656 &usb2_hardware_lpm_attr_group); 656 &usb2_hardware_lpm_attr_group);
657 if (udev->speed == USB_SPEED_SUPER && 657 if ((udev->speed == USB_SPEED_SUPER ||
658 udev->speed == USB_SPEED_SUPER_PLUS) &&
658 udev->lpm_capable == 1) 659 udev->lpm_capable == 1)
659 rc = sysfs_merge_group(&dev->kobj, 660 rc = sysfs_merge_group(&dev->kobj,
660 &usb3_hardware_lpm_attr_group); 661 &usb3_hardware_lpm_attr_group);
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 47903d510955..f501af0b3079 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Released under the GPLv2 only. 3 * Released under the GPLv2 only.
3 * SPDX-License-Identifier: GPL-2.0
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -492,6 +492,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
492 if ((urb->interval < 6) 492 if ((urb->interval < 6)
493 && (xfertype == USB_ENDPOINT_XFER_INT)) 493 && (xfertype == USB_ENDPOINT_XFER_INT))
494 return -EINVAL; 494 return -EINVAL;
495 /* fall through */
495 default: 496 default:
496 if (urb->interval <= 0) 497 if (urb->interval <= 0)
497 return -EINVAL; 498 return -EINVAL;
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index ef9cf4a21afe..84da17460568 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB-ACPI glue code 3 * USB-ACPI glue code
3 * 4 *
4 * Copyright 2012 Red Hat <mjg@redhat.com> 5 * Copyright 2012 Red Hat <mjg@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, version 2.
9 *
10 */ 6 */
11#include <linux/module.h> 7#include <linux/module.h>
12#include <linux/usb.h> 8#include <linux/usb.h>
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 17681d5638ac..845286f08ab0 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/core/usb.c 3 * drivers/usb/core/usb.c
3 * 4 *
@@ -13,7 +14,6 @@
13 * (C) Copyright Greg Kroah-Hartman 2002-2003 14 * (C) Copyright Greg Kroah-Hartman 2002-2003
14 * 15 *
15 * Released under the GPLv2 only. 16 * Released under the GPLv2 only.
16 * SPDX-License-Identifier: GPL-2.0
17 * 17 *
18 * NOTE! This is not actually a driver at all, rather this is 18 * NOTE! This is not actually a driver at all, rather this is
19 * just a collection of helper routines that implement the 19 * just a collection of helper routines that implement the
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index dc6949248823..2bee08d084ae 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Released under the GPLv2 only. 3 * Released under the GPLv2 only.
3 * SPDX-License-Identifier: GPL-2.0
4 */ 4 */
5 5
6#include <linux/pm.h> 6#include <linux/pm.h>
@@ -73,6 +73,7 @@ extern void usb_hub_cleanup(void);
73extern int usb_major_init(void); 73extern int usb_major_init(void);
74extern void usb_major_cleanup(void); 74extern void usb_major_cleanup(void);
75extern int usb_device_supports_lpm(struct usb_device *udev); 75extern int usb_device_supports_lpm(struct usb_device *udev);
76extern int usb_port_disable(struct usb_device *udev);
76 77
77#ifdef CONFIG_PM 78#ifdef CONFIG_PM
78 79
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 1b6612c2cdda..82a7d98c3436 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * core.c - DesignWare HS OTG Controller common routines 3 * core.c - DesignWare HS OTG Controller common routines
3 * 4 *
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 8367d4f985c1..f66c94130cac 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * core.h - DesignWare HS OTG Controller common declarations 3 * core.h - DesignWare HS OTG Controller common declarations
3 * 4 *
@@ -395,6 +396,9 @@ enum dwc2_ep0_state {
395 * (default when phy_type is UTMI+ or ULPI) 396 * (default when phy_type is UTMI+ or ULPI)
396 * 1 - 6 MHz 397 * 1 - 6 MHz
397 * (default when phy_type is Full Speed) 398 * (default when phy_type is Full Speed)
399 * @oc_disable: Flag to disable overcurrent condition.
400 * 0 - Allow overcurrent condition to get detected
401 * 1 - Disable overcurrent condtion to get detected
398 * @ts_dline: Enable Term Select Dline pulsing 402 * @ts_dline: Enable Term Select Dline pulsing
399 * 0 - No (default) 403 * 0 - No (default)
400 * 1 - Yes 404 * 1 - Yes
@@ -492,6 +496,7 @@ struct dwc2_core_params {
492 bool dma_desc_fs_enable; 496 bool dma_desc_fs_enable;
493 bool host_support_fs_ls_low_power; 497 bool host_support_fs_ls_low_power;
494 bool host_ls_low_power_phy_clk; 498 bool host_ls_low_power_phy_clk;
499 bool oc_disable;
495 500
496 u8 host_channels; 501 u8 host_channels;
497 u16 host_rx_fifo_size; 502 u16 host_rx_fifo_size;
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index b8bcb007c92a..ab3fa1630853 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * core_intr.c - DesignWare HS OTG Controller common interrupt handling 3 * core_intr.c - DesignWare HS OTG Controller common interrupt handling
3 * 4 *
diff --git a/drivers/usb/dwc2/debug.h b/drivers/usb/dwc2/debug.h
index 8222783e6822..6f23219c13cb 100644
--- a/drivers/usb/dwc2/debug.h
+++ b/drivers/usb/dwc2/debug.h
@@ -1,17 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * debug.h - Designware USB2 DRD controller debug header 3 * debug.h - Designware USB2 DRD controller debug header
3 * 4 *
4 * Copyright (C) 2015 Intel Corporation 5 * Copyright (C) 2015 Intel Corporation
5 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com> 6 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */ 7 */
16 8
17#include "core.h" 9#include "core.h"
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index 794b959a7c8c..f4650a88be78 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -1,17 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * debugfs.c - Designware USB2 DRD controller debugfs 3 * debugfs.c - Designware USB2 DRD controller debugfs
3 * 4 *
4 * Copyright (C) 2015 Intel Corporation 5 * Copyright (C) 2015 Intel Corporation
5 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com> 6 * Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */ 7 */
16 8
17#include <linux/spinlock.h> 9#include <linux/spinlock.h>
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0d8e09ccb59c..88529d092503 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com 4 * http://www.samsung.com
@@ -8,10 +9,6 @@
8 * http://armlinux.simtec.co.uk/ 9 * http://armlinux.simtec.co.uk/
9 * 10 *
10 * S3C USB2.0 High-speed / OtG driver 11 * S3C USB2.0 High-speed / OtG driver
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */ 12 */
16 13
17#include <linux/kernel.h> 14#include <linux/kernel.h>
@@ -3202,6 +3199,8 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)
3202 3199
3203 call_gadget(hsotg, disconnect); 3200 call_gadget(hsotg, disconnect);
3204 hsotg->lx_state = DWC2_L3; 3201 hsotg->lx_state = DWC2_L3;
3202
3203 usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED);
3205} 3204}
3206 3205
3207/** 3206/**
@@ -4004,6 +4003,11 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)
4004 return -EINVAL; 4003 return -EINVAL;
4005 } 4004 }
4006 4005
4006 if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) {
4007 dev_err(hsotg->dev, "%s: called in host mode?\n", __func__);
4008 return -EINVAL;
4009 }
4010
4007 epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); 4011 epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index);
4008 4012
4009 spin_lock_irqsave(&hsotg->lock, flags); 4013 spin_lock_irqsave(&hsotg->lock, flags);
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index c2631145f404..69eb40cd1b47 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hcd.c - DesignWare HS OTG Controller host-mode routines 3 * hcd.c - DesignWare HS OTG Controller host-mode routines
3 * 4 *
@@ -213,6 +214,11 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
213 usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL); 214 usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL);
214 if (hsotg->params.phy_ulpi_ddr) 215 if (hsotg->params.phy_ulpi_ddr)
215 usbcfg |= GUSBCFG_DDRSEL; 216 usbcfg |= GUSBCFG_DDRSEL;
217
218 /* Set external VBUS indicator as needed. */
219 if (hsotg->params.oc_disable)
220 usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
221 GUSBCFG_INDICATORPASSTHROUGH);
216 break; 222 break;
217 case DWC2_PHY_TYPE_PARAM_UTMI: 223 case DWC2_PHY_TYPE_PARAM_UTMI:
218 /* UTMI+ interface */ 224 /* UTMI+ interface */
@@ -3277,7 +3283,6 @@ static void dwc2_conn_id_status_change(struct work_struct *work)
3277 dwc2_core_init(hsotg, false); 3283 dwc2_core_init(hsotg, false);
3278 dwc2_enable_global_interrupts(hsotg); 3284 dwc2_enable_global_interrupts(hsotg);
3279 spin_lock_irqsave(&hsotg->lock, flags); 3285 spin_lock_irqsave(&hsotg->lock, flags);
3280 dwc2_hsotg_disconnect(hsotg);
3281 dwc2_hsotg_core_init_disconnected(hsotg, false); 3286 dwc2_hsotg_core_init_disconnected(hsotg, false);
3282 spin_unlock_irqrestore(&hsotg->lock, flags); 3287 spin_unlock_irqrestore(&hsotg->lock, flags);
3283 dwc2_hsotg_core_connect(hsotg); 3288 dwc2_hsotg_core_connect(hsotg);
@@ -3296,8 +3301,12 @@ host:
3296 if (count > 250) 3301 if (count > 250)
3297 dev_err(hsotg->dev, 3302 dev_err(hsotg->dev,
3298 "Connection id status change timed out\n"); 3303 "Connection id status change timed out\n");
3299 hsotg->op_state = OTG_STATE_A_HOST;
3300 3304
3305 spin_lock_irqsave(&hsotg->lock, flags);
3306 dwc2_hsotg_disconnect(hsotg);
3307 spin_unlock_irqrestore(&hsotg->lock, flags);
3308
3309 hsotg->op_state = OTG_STATE_A_HOST;
3301 /* Initialize the Core for Host mode */ 3310 /* Initialize the Core for Host mode */
3302 dwc2_core_init(hsotg, false); 3311 dwc2_core_init(hsotg, false);
3303 dwc2_enable_global_interrupts(hsotg); 3312 dwc2_enable_global_interrupts(hsotg);
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index 11c3c145b793..78e9e01051b5 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hcd.h - DesignWare HS OTG Controller host-mode declarations 3 * hcd.h - DesignWare HS OTG Controller host-mode declarations
3 * 4 *
diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
index b8bdf545c3a7..28c8898b3b66 100644
--- a/drivers/usb/dwc2/hcd_ddma.c
+++ b/drivers/usb/dwc2/hcd_ddma.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hcd_ddma.c - DesignWare HS OTG Controller descriptor DMA routines 3 * hcd_ddma.c - DesignWare HS OTG Controller descriptor DMA routines
3 * 4 *
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 28a8210710b1..916d991b96b8 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hcd_intr.c - DesignWare HS OTG Controller host-mode interrupt handling 3 * hcd_intr.c - DesignWare HS OTG Controller host-mode interrupt handling
3 * 4 *
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index 3ae8b1bbaa55..f472de238ac2 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hcd_queue.c - DesignWare HS OTG Controller host queuing routines 3 * hcd_queue.c - DesignWare HS OTG Controller host queuing routines
3 * 4 *
diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
index 4592012c4743..2c906d8ee465 100644
--- a/drivers/usb/dwc2/hw.h
+++ b/drivers/usb/dwc2/hw.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * hw.h - DesignWare HS OTG Controller hardware definitions 3 * hw.h - DesignWare HS OTG Controller hardware definitions
3 * 4 *
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a3ffe97170ff..ef73af6e03a9 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * Copyright (C) 2004-2016 Synopsys, Inc. 3 * Copyright (C) 2004-2016 Synopsys, Inc.
3 * 4 *
@@ -136,6 +137,15 @@ static void dwc2_set_stm32f4x9_fsotg_params(struct dwc2_hsotg *hsotg)
136 p->activate_stm_fs_transceiver = true; 137 p->activate_stm_fs_transceiver = true;
137} 138}
138 139
140static void dwc2_set_stm32f7xx_hsotg_params(struct dwc2_hsotg *hsotg)
141{
142 struct dwc2_core_params *p = &hsotg->params;
143
144 p->host_rx_fifo_size = 622;
145 p->host_nperio_tx_fifo_size = 128;
146 p->host_perio_tx_fifo_size = 256;
147}
148
139const struct of_device_id dwc2_of_match_table[] = { 149const struct of_device_id dwc2_of_match_table[] = {
140 { .compatible = "brcm,bcm2835-usb", .data = dwc2_set_bcm_params }, 150 { .compatible = "brcm,bcm2835-usb", .data = dwc2_set_bcm_params },
141 { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params }, 151 { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params },
@@ -154,6 +164,8 @@ const struct of_device_id dwc2_of_match_table[] = {
154 { .compatible = "st,stm32f4x9-fsotg", 164 { .compatible = "st,stm32f4x9-fsotg",
155 .data = dwc2_set_stm32f4x9_fsotg_params }, 165 .data = dwc2_set_stm32f4x9_fsotg_params },
156 { .compatible = "st,stm32f4x9-hsotg" }, 166 { .compatible = "st,stm32f4x9-hsotg" },
167 { .compatible = "st,stm32f7xx-hsotg",
168 .data = dwc2_set_stm32f7xx_hsotg_params },
157 {}, 169 {},
158}; 170};
159MODULE_DEVICE_TABLE(of, dwc2_of_match_table); 171MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
@@ -335,6 +347,9 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
335 num); 347 num);
336 } 348 }
337 } 349 }
350
351 if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
352 p->oc_disable = true;
338} 353}
339 354
340static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg) 355static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index fdeb8c7bf30a..3ecc951a1aea 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * pci.c - DesignWare HS OTG Controller PCI driver 3 * pci.c - DesignWare HS OTG Controller PCI driver
3 * 4 *
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index daf0d37acb37..3e26550d13dd 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * platform.c - DesignWare HS OTG Controller platform driver 3 * platform.c - DesignWare HS OTG Controller platform driver
3 * 4 *
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 03474d3575ab..07832509584f 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * core.c - DesignWare USB3 DRD Controller Core file 3 * core.c - DesignWare USB3 DRD Controller Core file
3 * 4 *
@@ -5,18 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */ 9 */
21 10
22#include <linux/version.h> 11#include <linux/version.h>
@@ -156,9 +145,8 @@ static void __dwc3_set_mode(struct work_struct *work)
156 } else { 145 } else {
157 if (dwc->usb2_phy) 146 if (dwc->usb2_phy)
158 otg_set_vbus(dwc->usb2_phy->otg, true); 147 otg_set_vbus(dwc->usb2_phy->otg, true);
159 if (dwc->usb2_generic_phy) 148 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
160 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); 149 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
161
162 } 150 }
163 break; 151 break;
164 case DWC3_GCTL_PRTCAP_DEVICE: 152 case DWC3_GCTL_PRTCAP_DEVICE:
@@ -166,8 +154,8 @@ static void __dwc3_set_mode(struct work_struct *work)
166 154
167 if (dwc->usb2_phy) 155 if (dwc->usb2_phy)
168 otg_set_vbus(dwc->usb2_phy->otg, false); 156 otg_set_vbus(dwc->usb2_phy->otg, false);
169 if (dwc->usb2_generic_phy) 157 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE);
170 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); 158 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE);
171 159
172 ret = dwc3_gadget_init(dwc); 160 ret = dwc3_gadget_init(dwc);
173 if (ret) 161 if (ret)
@@ -927,12 +915,13 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
927 915
928 switch (dwc->dr_mode) { 916 switch (dwc->dr_mode) {
929 case USB_DR_MODE_PERIPHERAL: 917 case USB_DR_MODE_PERIPHERAL:
918 dwc->current_dr_role = DWC3_GCTL_PRTCAP_DEVICE;
930 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); 919 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
931 920
932 if (dwc->usb2_phy) 921 if (dwc->usb2_phy)
933 otg_set_vbus(dwc->usb2_phy->otg, false); 922 otg_set_vbus(dwc->usb2_phy->otg, false);
934 if (dwc->usb2_generic_phy) 923 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE);
935 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE); 924 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE);
936 925
937 ret = dwc3_gadget_init(dwc); 926 ret = dwc3_gadget_init(dwc);
938 if (ret) { 927 if (ret) {
@@ -942,12 +931,13 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
942 } 931 }
943 break; 932 break;
944 case USB_DR_MODE_HOST: 933 case USB_DR_MODE_HOST:
934 dwc->current_dr_role = DWC3_GCTL_PRTCAP_HOST;
945 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); 935 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
946 936
947 if (dwc->usb2_phy) 937 if (dwc->usb2_phy)
948 otg_set_vbus(dwc->usb2_phy->otg, true); 938 otg_set_vbus(dwc->usb2_phy->otg, true);
949 if (dwc->usb2_generic_phy) 939 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
950 phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); 940 phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
951 941
952 ret = dwc3_host_init(dwc); 942 ret = dwc3_host_init(dwc);
953 if (ret) { 943 if (ret) {
@@ -1293,21 +1283,19 @@ static int dwc3_suspend_common(struct dwc3 *dwc)
1293{ 1283{
1294 unsigned long flags; 1284 unsigned long flags;
1295 1285
1296 switch (dwc->dr_mode) { 1286 switch (dwc->current_dr_role) {
1297 case USB_DR_MODE_PERIPHERAL: 1287 case DWC3_GCTL_PRTCAP_DEVICE:
1298 case USB_DR_MODE_OTG:
1299 spin_lock_irqsave(&dwc->lock, flags); 1288 spin_lock_irqsave(&dwc->lock, flags);
1300 dwc3_gadget_suspend(dwc); 1289 dwc3_gadget_suspend(dwc);
1301 spin_unlock_irqrestore(&dwc->lock, flags); 1290 spin_unlock_irqrestore(&dwc->lock, flags);
1291 dwc3_core_exit(dwc);
1302 break; 1292 break;
1303 case USB_DR_MODE_HOST: 1293 case DWC3_GCTL_PRTCAP_HOST:
1304 default: 1294 default:
1305 /* do nothing */ 1295 /* do nothing */
1306 break; 1296 break;
1307 } 1297 }
1308 1298
1309 dwc3_core_exit(dwc);
1310
1311 return 0; 1299 return 0;
1312} 1300}
1313 1301
@@ -1316,18 +1304,17 @@ static int dwc3_resume_common(struct dwc3 *dwc)
1316 unsigned long flags; 1304 unsigned long flags;
1317 int ret; 1305 int ret;
1318 1306
1319 ret = dwc3_core_init(dwc); 1307 switch (dwc->current_dr_role) {
1320 if (ret) 1308 case DWC3_GCTL_PRTCAP_DEVICE:
1321 return ret; 1309 ret = dwc3_core_init(dwc);
1310 if (ret)
1311 return ret;
1322 1312
1323 switch (dwc->dr_mode) {
1324 case USB_DR_MODE_PERIPHERAL:
1325 case USB_DR_MODE_OTG:
1326 spin_lock_irqsave(&dwc->lock, flags); 1313 spin_lock_irqsave(&dwc->lock, flags);
1327 dwc3_gadget_resume(dwc); 1314 dwc3_gadget_resume(dwc);
1328 spin_unlock_irqrestore(&dwc->lock, flags); 1315 spin_unlock_irqrestore(&dwc->lock, flags);
1329 /* FALLTHROUGH */ 1316 break;
1330 case USB_DR_MODE_HOST: 1317 case DWC3_GCTL_PRTCAP_HOST:
1331 default: 1318 default:
1332 /* do nothing */ 1319 /* do nothing */
1333 break; 1320 break;
@@ -1338,7 +1325,7 @@ static int dwc3_resume_common(struct dwc3 *dwc)
1338 1325
1339static int dwc3_runtime_checks(struct dwc3 *dwc) 1326static int dwc3_runtime_checks(struct dwc3 *dwc)
1340{ 1327{
1341 switch (dwc->dr_mode) { 1328 switch (dwc->current_dr_role) {
1342 case USB_DR_MODE_PERIPHERAL: 1329 case USB_DR_MODE_PERIPHERAL:
1343 case USB_DR_MODE_OTG: 1330 case USB_DR_MODE_OTG:
1344 if (dwc->connected) 1331 if (dwc->connected)
@@ -1381,19 +1368,17 @@ static int dwc3_runtime_resume(struct device *dev)
1381 if (ret) 1368 if (ret)
1382 return ret; 1369 return ret;
1383 1370
1384 switch (dwc->dr_mode) { 1371 switch (dwc->current_dr_role) {
1385 case USB_DR_MODE_PERIPHERAL: 1372 case DWC3_GCTL_PRTCAP_DEVICE:
1386 case USB_DR_MODE_OTG:
1387 dwc3_gadget_process_pending_events(dwc); 1373 dwc3_gadget_process_pending_events(dwc);
1388 break; 1374 break;
1389 case USB_DR_MODE_HOST: 1375 case DWC3_GCTL_PRTCAP_HOST:
1390 default: 1376 default:
1391 /* do nothing */ 1377 /* do nothing */
1392 break; 1378 break;
1393 } 1379 }
1394 1380
1395 pm_runtime_mark_last_busy(dev); 1381 pm_runtime_mark_last_busy(dev);
1396 pm_runtime_put(dev);
1397 1382
1398 return 0; 1383 return 0;
1399} 1384}
@@ -1402,13 +1387,12 @@ static int dwc3_runtime_idle(struct device *dev)
1402{ 1387{
1403 struct dwc3 *dwc = dev_get_drvdata(dev); 1388 struct dwc3 *dwc = dev_get_drvdata(dev);
1404 1389
1405 switch (dwc->dr_mode) { 1390 switch (dwc->current_dr_role) {
1406 case USB_DR_MODE_PERIPHERAL: 1391 case DWC3_GCTL_PRTCAP_DEVICE:
1407 case USB_DR_MODE_OTG:
1408 if (dwc3_runtime_checks(dwc)) 1392 if (dwc3_runtime_checks(dwc))
1409 return -EBUSY; 1393 return -EBUSY;
1410 break; 1394 break;
1411 case USB_DR_MODE_HOST: 1395 case DWC3_GCTL_PRTCAP_HOST:
1412 default: 1396 default:
1413 /* do nothing */ 1397 /* do nothing */
1414 break; 1398 break;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index ea910acb4bb0..4a4a4c98508c 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * core.h - DesignWare USB3 DRD Core Header 3 * core.h - DesignWare USB3 DRD Core Header
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#ifndef __DRIVERS_USB_DWC3_CORE_H 11#ifndef __DRIVERS_USB_DWC3_CORE_H
@@ -529,6 +521,7 @@ struct dwc3_event_buffer {
529 * @number: endpoint number (1 - 15) 521 * @number: endpoint number (1 - 15)
530 * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK 522 * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK
531 * @resource_index: Resource transfer index 523 * @resource_index: Resource transfer index
524 * @frame_number: set to the frame number we want this transfer to start (ISOC)
532 * @interval: the interval on which the ISOC transfer is started 525 * @interval: the interval on which the ISOC transfer is started
533 * @allocated_requests: number of requests allocated 526 * @allocated_requests: number of requests allocated
534 * @queued_requests: number of requests queued for transfer 527 * @queued_requests: number of requests queued for transfer
@@ -581,6 +574,7 @@ struct dwc3_ep {
581 u8 resource_index; 574 u8 resource_index;
582 u32 allocated_requests; 575 u32 allocated_requests;
583 u32 queued_requests; 576 u32 queued_requests;
577 u32 frame_number;
584 u32 interval; 578 u32 interval;
585 579
586 char name[20]; 580 char name[20];
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
index 5e9c070ec874..368f8e59219a 100644
--- a/drivers/usb/dwc3/debug.h
+++ b/drivers/usb/dwc3/debug.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * debug.h - DesignWare USB3 DRD Controller Debug Header 3 * debug.h - DesignWare USB3 DRD Controller Debug Header
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#ifndef __DWC3_DEBUG_H 11#ifndef __DWC3_DEBUG_H
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 4e09be80e59f..00e65530c81e 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * debugfs.c - DesignWare USB3 DRD Controller DebugFS file 3 * debugfs.c - DesignWare USB3 DRD Controller DebugFS file
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 2765c51c7ef5..cc8ab9a8e9d2 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -1,21 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * drd.c - DesignWare USB3 DRD Controller Dual-role support 3 * drd.c - DesignWare USB3 DRD Controller Dual-role support
3 * 4 *
4 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Authors: Roger Quadros <rogerq@ti.com> 7 * Authors: Roger Quadros <rogerq@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 8 */
20 9
21#include <linux/extcon.h> 10#include <linux/extcon.h>
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index e089df72f766..a94fb1ba8f2c 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * dwc3-exynos.c - Samsung EXYNOS DWC3 Specific Glue layer 3 * dwc3-exynos.c - Samsung EXYNOS DWC3 Specific Glue layer
3 * 4 *
@@ -5,15 +6,6 @@
5 * http://www.samsung.com 6 * http://www.samsung.com
6 * 7 *
7 * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> 8 * Author: Anton Tikhomirov <av.tikhomirov@samsung.com>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c
index d2ed9523e77c..193a9a88222a 100644
--- a/drivers/usb/dwc3/dwc3-keystone.c
+++ b/drivers/usb/dwc3/dwc3-keystone.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * dwc3-keystone.c - Keystone Specific Glue layer 3 * dwc3-keystone.c - Keystone Specific Glue layer
3 * 4 *
4 * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Author: WingMan Kwok <w-kwok2@ti.com> 7 * Author: WingMan Kwok <w-kwok2@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index a26d1fde0f5e..c4a4d7bd2766 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * dwc3-of-simple.c - OF glue layer for simple integrations 3 * dwc3-of-simple.c - OF glue layer for simple integrations
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Author: Felipe Balbi <balbi@ti.com> 7 * Author: Felipe Balbi <balbi@ti.com>
7 * 8 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * This is a combination of the old dwc3-qcom.c by Ivan T. Ivanov 9 * This is a combination of the old dwc3-qcom.c by Ivan T. Ivanov
18 * <iivanov@mm-sol.com> and the original patch adding support for Xilinx' SoC 10 * <iivanov@mm-sol.com> and the original patch adding support for Xilinx' SoC
19 * by Subbaraya Sundeep Bhatta <subbaraya.sundeep.bhatta@xilinx.com> 11 * by Subbaraya Sundeep Bhatta <subbaraya.sundeep.bhatta@xilinx.com>
@@ -28,11 +20,13 @@
28#include <linux/of.h> 20#include <linux/of.h>
29#include <linux/of_platform.h> 21#include <linux/of_platform.h>
30#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
23#include <linux/reset.h>
31 24
32struct dwc3_of_simple { 25struct dwc3_of_simple {
33 struct device *dev; 26 struct device *dev;
34 struct clk **clks; 27 struct clk **clks;
35 int num_clocks; 28 int num_clocks;
29 struct reset_control *resets;
36}; 30};
37 31
38static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count) 32static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count)
@@ -95,10 +89,21 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
95 platform_set_drvdata(pdev, simple); 89 platform_set_drvdata(pdev, simple);
96 simple->dev = dev; 90 simple->dev = dev;
97 91
92 simple->resets = of_reset_control_array_get_optional_exclusive(np);
93 if (IS_ERR(simple->resets)) {
94 ret = PTR_ERR(simple->resets);
95 dev_err(dev, "failed to get device resets, err=%d\n", ret);
96 return ret;
97 }
98
99 ret = reset_control_deassert(simple->resets);
100 if (ret)
101 goto err_resetc_put;
102
98 ret = dwc3_of_simple_clk_init(simple, of_count_phandle_with_args(np, 103 ret = dwc3_of_simple_clk_init(simple, of_count_phandle_with_args(np,
99 "clocks", "#clock-cells")); 104 "clocks", "#clock-cells"));
100 if (ret) 105 if (ret)
101 return ret; 106 goto err_resetc_assert;
102 107
103 ret = of_platform_populate(np, NULL, NULL, dev); 108 ret = of_platform_populate(np, NULL, NULL, dev);
104 if (ret) { 109 if (ret) {
@@ -107,7 +112,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
107 clk_put(simple->clks[i]); 112 clk_put(simple->clks[i]);
108 } 113 }
109 114
110 return ret; 115 goto err_resetc_assert;
111 } 116 }
112 117
113 pm_runtime_set_active(dev); 118 pm_runtime_set_active(dev);
@@ -115,6 +120,13 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
115 pm_runtime_get_sync(dev); 120 pm_runtime_get_sync(dev);
116 121
117 return 0; 122 return 0;
123
124err_resetc_assert:
125 reset_control_assert(simple->resets);
126
127err_resetc_put:
128 reset_control_put(simple->resets);
129 return ret;
118} 130}
119 131
120static int dwc3_of_simple_remove(struct platform_device *pdev) 132static int dwc3_of_simple_remove(struct platform_device *pdev)
@@ -123,12 +135,15 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
123 struct device *dev = &pdev->dev; 135 struct device *dev = &pdev->dev;
124 int i; 136 int i;
125 137
138 of_platform_depopulate(dev);
139
126 for (i = 0; i < simple->num_clocks; i++) { 140 for (i = 0; i < simple->num_clocks; i++) {
127 clk_disable_unprepare(simple->clks[i]); 141 clk_disable_unprepare(simple->clks[i]);
128 clk_put(simple->clks[i]); 142 clk_put(simple->clks[i]);
129 } 143 }
130 144
131 of_platform_depopulate(dev); 145 reset_control_assert(simple->resets);
146 reset_control_put(simple->resets);
132 147
133 pm_runtime_put_sync(dev); 148 pm_runtime_put_sync(dev);
134 pm_runtime_disable(dev); 149 pm_runtime_disable(dev);
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 3530795bbb8f..a4719e853b85 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * dwc3-omap.c - OMAP Specific Glue layer 3 * dwc3-omap.c - OMAP Specific Glue layer
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 54343fbd85ee..3ba11136ebf0 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * dwc3-pci.c - PCI Specific glue layer 3 * dwc3-pci.c - PCI Specific glue layer
3 * 4 *
@@ -5,21 +6,13 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/kernel.h> 11#include <linux/kernel.h>
20#include <linux/module.h> 12#include <linux/module.h>
21#include <linux/slab.h> 13#include <linux/slab.h>
22#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/workqueue.h>
23#include <linux/pm_runtime.h> 16#include <linux/pm_runtime.h>
24#include <linux/platform_device.h> 17#include <linux/platform_device.h>
25#include <linux/gpio/consumer.h> 18#include <linux/gpio/consumer.h>
@@ -61,6 +54,7 @@ struct dwc3_pci {
61 guid_t guid; 54 guid_t guid;
62 55
63 unsigned int has_dsm_for_pm:1; 56 unsigned int has_dsm_for_pm:1;
57 struct work_struct wakeup_work;
64}; 58};
65 59
66static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; 60static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
@@ -174,6 +168,22 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
174 return 0; 168 return 0;
175} 169}
176 170
171#ifdef CONFIG_PM
172static void dwc3_pci_resume_work(struct work_struct *work)
173{
174 struct dwc3_pci *dwc = container_of(work, struct dwc3_pci, wakeup_work);
175 struct platform_device *dwc3 = dwc->dwc3;
176 int ret;
177
178 ret = pm_runtime_get_sync(&dwc3->dev);
179 if (ret)
180 return;
181
182 pm_runtime_mark_last_busy(&dwc3->dev);
183 pm_runtime_put_sync_autosuspend(&dwc3->dev);
184}
185#endif
186
177static int dwc3_pci_probe(struct pci_dev *pci, 187static int dwc3_pci_probe(struct pci_dev *pci,
178 const struct pci_device_id *id) 188 const struct pci_device_id *id)
179{ 189{
@@ -232,6 +242,9 @@ static int dwc3_pci_probe(struct pci_dev *pci,
232 device_init_wakeup(dev, true); 242 device_init_wakeup(dev, true);
233 pci_set_drvdata(pci, dwc); 243 pci_set_drvdata(pci, dwc);
234 pm_runtime_put(dev); 244 pm_runtime_put(dev);
245#ifdef CONFIG_PM
246 INIT_WORK(&dwc->wakeup_work, dwc3_pci_resume_work);
247#endif
235 248
236 return 0; 249 return 0;
237err: 250err:
@@ -243,6 +256,9 @@ static void dwc3_pci_remove(struct pci_dev *pci)
243{ 256{
244 struct dwc3_pci *dwc = pci_get_drvdata(pci); 257 struct dwc3_pci *dwc = pci_get_drvdata(pci);
245 258
259#ifdef CONFIG_PM
260 cancel_work_sync(&dwc->wakeup_work);
261#endif
246 device_init_wakeup(&pci->dev, false); 262 device_init_wakeup(&pci->dev, false);
247 pm_runtime_get(&pci->dev); 263 pm_runtime_get(&pci->dev);
248 platform_device_unregister(dwc->dwc3); 264 platform_device_unregister(dwc->dwc3);
@@ -318,14 +334,15 @@ static int dwc3_pci_runtime_suspend(struct device *dev)
318static int dwc3_pci_runtime_resume(struct device *dev) 334static int dwc3_pci_runtime_resume(struct device *dev)
319{ 335{
320 struct dwc3_pci *dwc = dev_get_drvdata(dev); 336 struct dwc3_pci *dwc = dev_get_drvdata(dev);
321 struct platform_device *dwc3 = dwc->dwc3;
322 int ret; 337 int ret;
323 338
324 ret = dwc3_pci_dsm(dwc, PCI_INTEL_BXT_STATE_D0); 339 ret = dwc3_pci_dsm(dwc, PCI_INTEL_BXT_STATE_D0);
325 if (ret) 340 if (ret)
326 return ret; 341 return ret;
327 342
328 return pm_runtime_get(&dwc3->dev); 343 queue_work(pm_wq, &dwc->wakeup_work);
344
345 return 0;
329} 346}
330#endif /* CONFIG_PM */ 347#endif /* CONFIG_PM */
331 348
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 505676fd3ba4..16081383c401 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/** 2/**
2 * dwc3-st.c Support for dwc3 platform devices on ST Microelectronics platforms 3 * dwc3-st.c Support for dwc3 platform devices on ST Microelectronics platforms
3 * 4 *
@@ -10,11 +11,6 @@
10 * Contributors: Aymen Bouattay <aymen.bouattay@st.com> 11 * Contributors: Aymen Bouattay <aymen.bouattay@st.com>
11 * Peter Griffin <peter.griffin@linaro.org> 12 * Peter Griffin <peter.griffin@linaro.org>
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * Inspired by dwc3-omap.c and dwc3-exynos.c. 14 * Inspired by dwc3-omap.c and dwc3-exynos.c.
19 */ 15 */
20 16
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 75e6cb044eb2..fd3e7ad2eb0e 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling 3 * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -487,14 +479,10 @@ static int dwc3_ep0_handle_device(struct dwc3 *dwc,
487static int dwc3_ep0_handle_intf(struct dwc3 *dwc, 479static int dwc3_ep0_handle_intf(struct dwc3 *dwc,
488 struct usb_ctrlrequest *ctrl, int set) 480 struct usb_ctrlrequest *ctrl, int set)
489{ 481{
490 enum usb_device_state state;
491 u32 wValue; 482 u32 wValue;
492 u32 wIndex;
493 int ret = 0; 483 int ret = 0;
494 484
495 wValue = le16_to_cpu(ctrl->wValue); 485 wValue = le16_to_cpu(ctrl->wValue);
496 wIndex = le16_to_cpu(ctrl->wIndex);
497 state = dwc->gadget.state;
498 486
499 switch (wValue) { 487 switch (wValue) {
500 case USB_INTRF_FUNC_SUSPEND: 488 case USB_INTRF_FUNC_SUSPEND:
@@ -517,14 +505,10 @@ static int dwc3_ep0_handle_endpoint(struct dwc3 *dwc,
517 struct usb_ctrlrequest *ctrl, int set) 505 struct usb_ctrlrequest *ctrl, int set)
518{ 506{
519 struct dwc3_ep *dep; 507 struct dwc3_ep *dep;
520 enum usb_device_state state;
521 u32 wValue; 508 u32 wValue;
522 u32 wIndex;
523 int ret; 509 int ret;
524 510
525 wValue = le16_to_cpu(ctrl->wValue); 511 wValue = le16_to_cpu(ctrl->wValue);
526 wIndex = le16_to_cpu(ctrl->wIndex);
527 state = dwc->gadget.state;
528 512
529 switch (wValue) { 513 switch (wValue) {
530 case USB_ENDPOINT_HALT: 514 case USB_ENDPOINT_HALT:
@@ -551,10 +535,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
551{ 535{
552 u32 recip; 536 u32 recip;
553 int ret; 537 int ret;
554 enum usb_device_state state;
555 538
556 recip = ctrl->bRequestType & USB_RECIP_MASK; 539 recip = ctrl->bRequestType & USB_RECIP_MASK;
557 state = dwc->gadget.state;
558 540
559 switch (recip) { 541 switch (recip) {
560 case USB_RECIP_DEVICE: 542 case USB_RECIP_DEVICE:
@@ -712,12 +694,10 @@ static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
712 struct dwc3_ep *dep; 694 struct dwc3_ep *dep;
713 enum usb_device_state state = dwc->gadget.state; 695 enum usb_device_state state = dwc->gadget.state;
714 u16 wLength; 696 u16 wLength;
715 u16 wValue;
716 697
717 if (state == USB_STATE_DEFAULT) 698 if (state == USB_STATE_DEFAULT)
718 return -EINVAL; 699 return -EINVAL;
719 700
720 wValue = le16_to_cpu(ctrl->wValue);
721 wLength = le16_to_cpu(ctrl->wLength); 701 wLength = le16_to_cpu(ctrl->wLength);
722 702
723 if (wLength != 6) { 703 if (wLength != 6) {
@@ -842,9 +822,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
842 struct usb_request *ur; 822 struct usb_request *ur;
843 struct dwc3_trb *trb; 823 struct dwc3_trb *trb;
844 struct dwc3_ep *ep0; 824 struct dwc3_ep *ep0;
845 unsigned maxp;
846 unsigned remaining_ur_length;
847 void *buf;
848 u32 transferred = 0; 825 u32 transferred = 0;
849 u32 status; 826 u32 status;
850 u32 length; 827 u32 length;
@@ -871,11 +848,8 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
871 } 848 }
872 849
873 ur = &r->request; 850 ur = &r->request;
874 buf = ur->buf;
875 remaining_ur_length = ur->length;
876 851
877 length = trb->size & DWC3_TRB_SIZE_MASK; 852 length = trb->size & DWC3_TRB_SIZE_MASK;
878 maxp = ep0->endpoint.maxpacket;
879 transferred = ur->length - length; 853 transferred = ur->length - length;
880 ur->actual += transferred; 854 ur->actual += transferred;
881 855
@@ -1001,7 +975,6 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1001 } else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) && 975 } else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
1002 req->request.length && req->request.zero) { 976 req->request.length && req->request.zero) {
1003 u32 maxpacket; 977 u32 maxpacket;
1004 u32 rem;
1005 978
1006 ret = usb_gadget_map_request_by_dev(dwc->sysdev, 979 ret = usb_gadget_map_request_by_dev(dwc->sysdev,
1007 &req->request, dep->number); 980 &req->request, dep->number);
@@ -1009,7 +982,6 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
1009 return; 982 return;
1010 983
1011 maxpacket = dep->endpoint.maxpacket; 984 maxpacket = dep->endpoint.maxpacket;
1012 rem = req->request.length % maxpacket;
1013 985
1014 /* prepare normal TRB */ 986 /* prepare normal TRB */
1015 dwc3_ep0_prepare_one_trb(dep, req->request.dma, 987 dwc3_ep0_prepare_one_trb(dep, req->request.dma,
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index f064f1549333..981fd986cf82 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link 3 * gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -1151,9 +1143,6 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep)
1151 1143
1152 BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); 1144 BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM);
1153 1145
1154 if (!dwc3_calc_trbs_left(dep))
1155 return;
1156
1157 /* 1146 /*
1158 * We can get in a situation where there's a request in the started list 1147 * We can get in a situation where there's a request in the started list
1159 * but there weren't enough TRBs to fully kick it in the first time 1148 * but there weren't enough TRBs to fully kick it in the first time
@@ -1194,7 +1183,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep)
1194 } 1183 }
1195} 1184}
1196 1185
1197static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param) 1186static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
1198{ 1187{
1199 struct dwc3_gadget_ep_cmd_params params; 1188 struct dwc3_gadget_ep_cmd_params params;
1200 struct dwc3_request *req; 1189 struct dwc3_request *req;
@@ -1202,6 +1191,9 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param)
1202 int ret; 1191 int ret;
1203 u32 cmd; 1192 u32 cmd;
1204 1193
1194 if (!dwc3_calc_trbs_left(dep))
1195 return 0;
1196
1205 starting = !(dep->flags & DWC3_EP_BUSY); 1197 starting = !(dep->flags & DWC3_EP_BUSY);
1206 1198
1207 dwc3_prepare_trbs(dep); 1199 dwc3_prepare_trbs(dep);
@@ -1216,8 +1208,10 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param)
1216 if (starting) { 1208 if (starting) {
1217 params.param0 = upper_32_bits(req->trb_dma); 1209 params.param0 = upper_32_bits(req->trb_dma);
1218 params.param1 = lower_32_bits(req->trb_dma); 1210 params.param1 = lower_32_bits(req->trb_dma);
1219 cmd = DWC3_DEPCMD_STARTTRANSFER | 1211 cmd = DWC3_DEPCMD_STARTTRANSFER;
1220 DWC3_DEPCMD_PARAM(cmd_param); 1212
1213 if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
1214 cmd |= DWC3_DEPCMD_PARAM(dep->frame_number);
1221 } else { 1215 } else {
1222 cmd = DWC3_DEPCMD_UPDATETRANSFER | 1216 cmd = DWC3_DEPCMD_UPDATETRANSFER |
1223 DWC3_DEPCMD_PARAM(dep->resource_index); 1217 DWC3_DEPCMD_PARAM(dep->resource_index);
@@ -1258,8 +1252,6 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
1258static void __dwc3_gadget_start_isoc(struct dwc3 *dwc, 1252static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
1259 struct dwc3_ep *dep, u32 cur_uf) 1253 struct dwc3_ep *dep, u32 cur_uf)
1260{ 1254{
1261 u32 uf;
1262
1263 if (list_empty(&dep->pending_list)) { 1255 if (list_empty(&dep->pending_list)) {
1264 dev_info(dwc->dev, "%s: ran out of requests\n", 1256 dev_info(dwc->dev, "%s: ran out of requests\n",
1265 dep->name); 1257 dep->name);
@@ -1271,9 +1263,8 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
1271 * Schedule the first trb for one interval in the future or at 1263 * Schedule the first trb for one interval in the future or at
1272 * least 4 microframes. 1264 * least 4 microframes.
1273 */ 1265 */
1274 uf = cur_uf + max_t(u32, 4, dep->interval); 1266 dep->frame_number = cur_uf + max_t(u32, 4, dep->interval);
1275 1267 __dwc3_gadget_kick_transfer(dep);
1276 __dwc3_gadget_kick_transfer(dep, uf);
1277} 1268}
1278 1269
1279static void dwc3_gadget_start_isoc(struct dwc3 *dwc, 1270static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
@@ -1290,7 +1281,6 @@ static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
1290static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) 1281static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
1291{ 1282{
1292 struct dwc3 *dwc = dep->dwc; 1283 struct dwc3 *dwc = dep->dwc;
1293 int ret = 0;
1294 1284
1295 if (!dep->endpoint.desc) { 1285 if (!dep->endpoint.desc) {
1296 dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n", 1286 dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
@@ -1337,24 +1327,14 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
1337 } 1327 }
1338 1328
1339 if ((dep->flags & DWC3_EP_BUSY) && 1329 if ((dep->flags & DWC3_EP_BUSY) &&
1340 !(dep->flags & DWC3_EP_MISSED_ISOC)) { 1330 !(dep->flags & DWC3_EP_MISSED_ISOC))
1341 WARN_ON_ONCE(!dep->resource_index); 1331 goto out;
1342 ret = __dwc3_gadget_kick_transfer(dep,
1343 dep->resource_index);
1344 }
1345
1346 goto out;
1347 }
1348 1332
1349 if (!dwc3_calc_trbs_left(dep))
1350 return 0; 1333 return 0;
1334 }
1351 1335
1352 ret = __dwc3_gadget_kick_transfer(dep, 0);
1353out: 1336out:
1354 if (ret == -EBUSY) 1337 return __dwc3_gadget_kick_transfer(dep);
1355 ret = 0;
1356
1357 return ret;
1358} 1338}
1359 1339
1360static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, 1340static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
@@ -2347,7 +2327,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
2347 req->request.actual = length - req->remaining; 2327 req->request.actual = length - req->remaining;
2348 2328
2349 if ((req->request.actual < length) && req->num_pending_sgs) 2329 if ((req->request.actual < length) && req->num_pending_sgs)
2350 return __dwc3_gadget_kick_transfer(dep, 0); 2330 return __dwc3_gadget_kick_transfer(dep);
2351 2331
2352 dwc3_gadget_giveback(dep, req, status); 2332 dwc3_gadget_giveback(dep, req, status);
2353 2333
@@ -2440,13 +2420,8 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc,
2440 if (!dep->endpoint.desc) 2420 if (!dep->endpoint.desc)
2441 return; 2421 return;
2442 2422
2443 if (!usb_endpoint_xfer_isoc(dep->endpoint.desc)) { 2423 if (!usb_endpoint_xfer_isoc(dep->endpoint.desc))
2444 int ret; 2424 __dwc3_gadget_kick_transfer(dep);
2445
2446 ret = __dwc3_gadget_kick_transfer(dep, 0);
2447 if (!ret || ret == -EBUSY)
2448 return;
2449 }
2450} 2425}
2451 2426
2452static void dwc3_endpoint_interrupt(struct dwc3 *dwc, 2427static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
@@ -2487,15 +2462,10 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
2487 dwc3_endpoint_transfer_complete(dwc, dep, event); 2462 dwc3_endpoint_transfer_complete(dwc, dep, event);
2488 break; 2463 break;
2489 case DWC3_DEPEVT_XFERNOTREADY: 2464 case DWC3_DEPEVT_XFERNOTREADY:
2490 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { 2465 if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
2491 dwc3_gadget_start_isoc(dwc, dep, event); 2466 dwc3_gadget_start_isoc(dwc, dep, event);
2492 } else { 2467 else
2493 int ret; 2468 __dwc3_gadget_kick_transfer(dep);
2494
2495 ret = __dwc3_gadget_kick_transfer(dep, 0);
2496 if (!ret || ret == -EBUSY)
2497 return;
2498 }
2499 2469
2500 break; 2470 break;
2501 case DWC3_DEPEVT_STREAMEVT: 2471 case DWC3_DEPEVT_STREAMEVT:
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 4a3227543255..578aa856f986 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * gadget.h - DesignWare USB3 DRD Gadget Header 3 * gadget.h - DesignWare USB3 DRD Gadget Header
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#ifndef __DRIVERS_USB_DWC3_GADGET_H 11#ifndef __DRIVERS_USB_DWC3_GADGET_H
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 76f0b0df37c1..1a3878a3be78 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * host.c - DesignWare USB3 DRD Controller Host Glue 3 * host.c - DesignWare USB3 DRD Controller Host Glue
3 * 4 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#include <linux/platform_device.h> 10#include <linux/platform_device.h>
diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h
index c69b06696824..70acdf94a0bf 100644
--- a/drivers/usb/dwc3/io.h
+++ b/drivers/usb/dwc3/io.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * io.h - DesignWare USB3 DRD IO Header 3 * io.h - DesignWare USB3 DRD IO Header
3 * 4 *
@@ -5,15 +6,6 @@
5 * 6 *
6 * Authors: Felipe Balbi <balbi@ti.com>, 7 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de> 8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 9 */
18 10
19#ifndef __DRIVERS_USB_DWC3_IO_H 11#ifndef __DRIVERS_USB_DWC3_IO_H
diff --git a/drivers/usb/dwc3/trace.c b/drivers/usb/dwc3/trace.c
index 6cd166412ad0..f8886f3f3c9e 100644
--- a/drivers/usb/dwc3/trace.c
+++ b/drivers/usb/dwc3/trace.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * trace.c - DesignWare USB3 DRD Controller Trace Support 3 * trace.c - DesignWare USB3 DRD Controller Trace Support
3 * 4 *
4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Author: Felipe Balbi <balbi@ti.com> 7 * Author: Felipe Balbi <balbi@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#define CREATE_TRACE_POINTS 10#define CREATE_TRACE_POINTS
diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
index 6504b116da04..a9dd5c64e6c7 100644
--- a/drivers/usb/dwc3/trace.h
+++ b/drivers/usb/dwc3/trace.h
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * trace.h - DesignWare USB3 DRD Controller Trace Support 3 * trace.h - DesignWare USB3 DRD Controller Trace Support
3 * 4 *
4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Author: Felipe Balbi <balbi@ti.com> 7 * Author: Felipe Balbi <balbi@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#undef TRACE_SYSTEM 10#undef TRACE_SYSTEM
diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c
index e87ce8e9edee..f62b5f3c2d67 100644
--- a/drivers/usb/dwc3/ulpi.c
+++ b/drivers/usb/dwc3/ulpi.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * ulpi.c - DesignWare USB3 Controller's ULPI PHY interface 3 * ulpi.c - DesignWare USB3 Controller's ULPI PHY interface
3 * 4 *
4 * Copyright (C) 2015 Intel Corporation 5 * Copyright (C) 2015 Intel Corporation
5 * 6 *
6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 7 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/ulpi/regs.h> 10#include <linux/ulpi/regs.h>
diff --git a/drivers/usb/early/Makefile b/drivers/usb/early/Makefile
index fcde2286da1c..7b77b49d3b8c 100644
--- a/drivers/usb/early/Makefile
+++ b/drivers/usb/early/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for early USB devices 3# Makefile for early USB devices
3# 4#
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
index e2654443e8eb..d633c2abe5a4 100644
--- a/drivers/usb/early/ehci-dbgp.c
+++ b/drivers/usb/early/ehci-dbgp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Standalone EHCI usb debug driver 3 * Standalone EHCI usb debug driver
3 * 4 *
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 12fe70beae69..8a700b45b9a9 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * xhci-dbc.c - xHCI debug capability early driver 3 * xhci-dbc.c - xHCI debug capability early driver
3 * 4 *
4 * Copyright (C) 2016 Intel Corporation 5 * Copyright (C) 2016 Intel Corporation
5 * 6 *
6 * Author: Lu Baolu <baolu.lu@linux.intel.com> 7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ 10#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
diff --git a/drivers/usb/early/xhci-dbc.h b/drivers/usb/early/xhci-dbc.h
index 2df0f6e613fe..673686eeddd7 100644
--- a/drivers/usb/early/xhci-dbc.h
+++ b/drivers/usb/early/xhci-dbc.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xhci-dbc.h - xHCI debug capability early driver 3 * xhci-dbc.h - xHCI debug capability early driver
3 * 4 *
4 * Copyright (C) 2016 Intel Corporation 5 * Copyright (C) 2016 Intel Corporation
5 * 6 *
6 * Author: Lu Baolu <baolu.lu@linux.intel.com> 7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef __LINUX_XHCI_DBC_H 10#ifndef __LINUX_XHCI_DBC_H
@@ -90,8 +87,8 @@ struct xdbc_context {
90 87
91#define XDBC_INFO_CONTEXT_SIZE 48 88#define XDBC_INFO_CONTEXT_SIZE 48
92#define XDBC_MAX_STRING_LENGTH 64 89#define XDBC_MAX_STRING_LENGTH 64
93#define XDBC_STRING_MANUFACTURER "Linux" 90#define XDBC_STRING_MANUFACTURER "Linux Foundation"
94#define XDBC_STRING_PRODUCT "Remote GDB" 91#define XDBC_STRING_PRODUCT "Linux USB GDB Target"
95#define XDBC_STRING_SERIAL "0001" 92#define XDBC_STRING_SERIAL "0001"
96 93
97struct xdbc_strings { 94struct xdbc_strings {
@@ -103,7 +100,7 @@ struct xdbc_strings {
103 100
104#define XDBC_PROTOCOL 1 /* GNU Remote Debug Command Set */ 101#define XDBC_PROTOCOL 1 /* GNU Remote Debug Command Set */
105#define XDBC_VENDOR_ID 0x1d6b /* Linux Foundation 0x1d6b */ 102#define XDBC_VENDOR_ID 0x1d6b /* Linux Foundation 0x1d6b */
106#define XDBC_PRODUCT_ID 0x0004 /* __le16 idProduct; device 0004 */ 103#define XDBC_PRODUCT_ID 0x0011 /* __le16 idProduct; device 0011 */
107#define XDBC_DEVICE_REV 0x0010 /* 0.10 */ 104#define XDBC_DEVICE_REV 0x0010 /* 0.10 */
108 105
109/* 106/*
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 5d061b3d8224..eec14e6ed20b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * composite.c - infrastructure for Composite USB Gadgets 3 * composite.c - infrastructure for Composite USB Gadgets
3 * 4 *
4 * Copyright (C) 2006-2008 David Brownell 5 * Copyright (C) 2006-2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12/* #define VERBOSE_DEBUG */ 8/* #define VERBOSE_DEBUG */
@@ -170,20 +166,20 @@ int config_ep_by_speed(struct usb_gadget *g,
170 want_comp_desc = 1; 166 want_comp_desc = 1;
171 break; 167 break;
172 } 168 }
173 /* else: Fall trough */ 169 /* fall through */
174 case USB_SPEED_SUPER: 170 case USB_SPEED_SUPER:
175 if (gadget_is_superspeed(g)) { 171 if (gadget_is_superspeed(g)) {
176 speed_desc = f->ss_descriptors; 172 speed_desc = f->ss_descriptors;
177 want_comp_desc = 1; 173 want_comp_desc = 1;
178 break; 174 break;
179 } 175 }
180 /* else: Fall trough */ 176 /* fall through */
181 case USB_SPEED_HIGH: 177 case USB_SPEED_HIGH:
182 if (gadget_is_dualspeed(g)) { 178 if (gadget_is_dualspeed(g)) {
183 speed_desc = f->hs_descriptors; 179 speed_desc = f->hs_descriptors;
184 break; 180 break;
185 } 181 }
186 /* else: fall through */ 182 /* fall through */
187 default: 183 default:
188 speed_desc = f->fs_descriptors; 184 speed_desc = f->fs_descriptors;
189 } 185 }
@@ -224,6 +220,7 @@ ep_found:
224 case USB_ENDPOINT_XFER_ISOC: 220 case USB_ENDPOINT_XFER_ISOC:
225 /* mult: bits 1:0 of bmAttributes */ 221 /* mult: bits 1:0 of bmAttributes */
226 _ep->mult = (comp_desc->bmAttributes & 0x3) + 1; 222 _ep->mult = (comp_desc->bmAttributes & 0x3) + 1;
223 /* fall through */
227 case USB_ENDPOINT_XFER_BULK: 224 case USB_ENDPOINT_XFER_BULK:
228 case USB_ENDPOINT_XFER_INT: 225 case USB_ENDPOINT_XFER_INT:
229 _ep->maxburst = comp_desc->bMaxBurst + 1; 226 _ep->maxburst = comp_desc->bMaxBurst + 1;
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 17a6077b89a4..2d115353424c 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * usb/gadget/config.c -- simplify building config descriptors 3 * usb/gadget/config.c -- simplify building config descriptors
3 * 4 *
4 * Copyright (C) 2003 David Brownell 5 * Copyright (C) 2003 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#include <linux/errno.h> 8#include <linux/errno.h>
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index aeb9f3c40521..4ddf063b9f47 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/configfs.h> 2#include <linux/configfs.h>
2#include <linux/module.h> 3#include <linux/module.h>
3#include <linux/slab.h> 4#include <linux/slab.h>
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 30fdab0ae383..71b15c65b90f 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * epautoconf.c -- endpoint autoconfiguration for usb gadget drivers 3 * epautoconf.c -- endpoint autoconfiguration for usb gadget drivers
3 * 4 *
4 * Copyright (C) 2004 David Brownell 5 * Copyright (C) 2004 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 5e3828d9dac7..7140bf3c74fa 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_acm.c -- USB CDC serial (ACM) function driver 3 * f_acm.c -- USB CDC serial (ACM) function driver
3 * 4 *
@@ -6,10 +7,6 @@
6 * Copyright (C) 2008 by Nokia Corporation 7 * Copyright (C) 2008 by Nokia Corporation
7 * Copyright (C) 2009 by Samsung Electronics 8 * Copyright (C) 2009 by Samsung Electronics
8 * Author: Michal Nazarewicz (mina86@mina86.com) 9 * Author: Michal Nazarewicz (mina86@mina86.com)
9 *
10 * This software is distributed under the terms of the GNU General
11 * Public License ("GPL") as published by the Free Software Foundation,
12 * either version 2 of that License or (at your option) any later version.
13 */ 10 */
14 11
15/* #define VERBOSE_DEBUG */ 12/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index 4c488d15b6f6..b322ca20cd98 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_ecm.c -- USB CDC Ethernet (ECM) link function driver 3 * f_ecm.c -- USB CDC Ethernet (ECM) link function driver
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2008 Nokia Corporation 6 * Copyright (C) 2008 Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* #define VERBOSE_DEBUG */ 9/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index 007ec6e4a5d4..def3a450a340 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_eem.c -- USB CDC Ethernet (EEM) link function driver 3 * f_eem.c -- USB CDC Ethernet (EEM) link function driver
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2008 Nokia Corporation 6 * Copyright (C) 2008 Nokia Corporation
6 * Copyright (C) 2009 EF Johnson Technologies 7 * Copyright (C) 2009 EF Johnson Technologies
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 8b342587f8ad..b1001c3f43fb 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_fs.c -- user mode file system API for USB composite function controllers 3 * f_fs.c -- user mode file system API for USB composite function controllers
3 * 4 *
@@ -7,11 +8,6 @@
7 * Based on inode.c (GadgetFS) which was: 8 * Based on inode.c (GadgetFS) which was:
8 * Copyright (C) 2003-2004 David Brownell 9 * Copyright (C) 2003-2004 David Brownell
9 * Copyright (C) 2003 Agilent Technologies 10 * Copyright (C) 2003 Agilent Technologies
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */ 11 */
16 12
17 13
@@ -3677,6 +3673,7 @@ static void ffs_closed(struct ffs_data *ffs)
3677 goto done; 3673 goto done;
3678 3674
3679 ffs_obj->desc_ready = false; 3675 ffs_obj->desc_ready = false;
3676 ffs_obj->ffs_data = NULL;
3680 3677
3681 if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags) && 3678 if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags) &&
3682 ffs_obj->ffs_closed_callback) 3679 ffs_obj->ffs_closed_callback)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index d8e359ef6eb1..52576f1b57f1 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_hid.c -- USB HID function driver 3 * f_hid.c -- USB HID function driver
3 * 4 *
4 * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com> 5 * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
index e70093835e14..ed3b054a0a2e 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_loopback.c - USB peripheral loopback configuration driver 3 * f_loopback.c - USB peripheral loopback configuration driver
3 * 4 *
4 * Copyright (C) 2003-2008 David Brownell 5 * Copyright (C) 2003-2008 David Brownell
5 * Copyright (C) 2008 by Nokia Corporation 6 * Copyright (C) 2008 by Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* #define VERBOSE_DEBUG */ 9/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 5153e29870c3..697224237976 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * f_mass_storage.c -- Mass Storage USB Composite Function 3 * f_mass_storage.c -- Mass Storage USB Composite Function
3 * 4 *
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index 5d3d7941d2c2..5ea713a975c7 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_midi.c -- USB MIDI class function driver 3 * f_midi.c -- USB MIDI class function driver
3 * 4 *
@@ -15,8 +16,6 @@
15 * and drivers/usb/gadget/midi.c, 16 * and drivers/usb/gadget/midi.c,
16 * Copyright (C) 2006 Thumtronics Pty Ltd. 17 * Copyright (C) 2006 Thumtronics Pty Ltd.
17 * Ben Williamson <ben.williamson@greyinnovation.com> 18 * Ben Williamson <ben.williamson@greyinnovation.com>
18 *
19 * Licensed under the GPL-2 or later.
20 */ 19 */
21 20
22#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 45b334ceaf2e..87d4e7767f96 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_ncm.c -- USB CDC Network (NCM) link function driver 3 * f_ncm.c -- USB CDC Network (NCM) link function driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * 9 *
9 * Copyright (C) 2003-2005,2008 David Brownell 10 * Copyright (C) 2003-2005,2008 David Brownell
10 * Copyright (C) 2008 Nokia Corporation 11 * Copyright (C) 2008 Nokia Corporation
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c
index d43e86cea74f..082f948aa7fd 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_obex.c -- USB CDC OBEX function driver 3 * f_obex.c -- USB CDC OBEX function driver
3 * 4 *
@@ -5,11 +6,6 @@
5 * Contact: Felipe Balbi <felipe.balbi@nokia.com> 6 * Contact: Felipe Balbi <felipe.balbi@nokia.com>
6 * 7 *
7 * Based on f_acm.c by Al Borchers and David Brownell. 8 * Based on f_acm.c by Al Borchers and David Brownell.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15/* #define VERBOSE_DEBUG */ 11/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
index 9c4c58e4a1a2..2d867b1ffb47 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * f_phonet.c -- USB CDC Phonet function 3 * f_phonet.c -- USB CDC Phonet function
3 * 4 *
4 * Copyright (C) 2007-2008 Nokia Corporation. All rights reserved. 5 * Copyright (C) 2007-2008 Nokia Corporation. All rights reserved.
5 * 6 *
6 * Author: Rémi Denis-Courmont 7 * Author: Rémi Denis-Courmont
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/mm.h> 10#include <linux/mm.h>
@@ -215,6 +212,7 @@ static void pn_tx_complete(struct usb_ep *ep, struct usb_request *req)
215 case -ESHUTDOWN: /* disconnected */ 212 case -ESHUTDOWN: /* disconnected */
216 case -ECONNRESET: /* disabled */ 213 case -ECONNRESET: /* disabled */
217 dev->stats.tx_aborted_errors++; 214 dev->stats.tx_aborted_errors++;
215 /* fall through */
218 default: 216 default:
219 dev->stats.tx_errors++; 217 dev->stats.tx_errors++;
220 } 218 }
@@ -362,6 +360,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req)
362 /* Do resubmit in these cases: */ 360 /* Do resubmit in these cases: */
363 case -EOVERFLOW: /* request buffer overflow */ 361 case -EOVERFLOW: /* request buffer overflow */
364 dev->stats.rx_over_errors++; 362 dev->stats.rx_over_errors++;
363 /* fall through */
365 default: 364 default:
366 dev->stats.rx_errors++; 365 dev->stats.rx_errors++;
367 break; 366 break;
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index ea0da35a44e2..587575453f48 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_printer.c - USB printer function driver 3 * f_printer.c - USB printer function driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * 9 *
9 * Copyright (C) 2003-2005 David Brownell 10 * Copyright (C) 2003-2005 David Brownell
10 * Copyright (C) 2006 Craig W. Nadler 11 * Copyright (C) 2006 Craig W. Nadler
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index c7c5b3ce1d98..9c5bf92c4617 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_rndis.c -- RNDIS link function driver 3 * f_rndis.c -- RNDIS link function driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * Copyright (C) 2008 Nokia Corporation 7 * Copyright (C) 2008 Nokia Corporation
7 * Copyright (C) 2009 Samsung Electronics 8 * Copyright (C) 2009 Samsung Electronics
8 * Author: Michal Nazarewicz (mina86@mina86.com) 9 * Author: Michal Nazarewicz (mina86@mina86.com)
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16/* #define VERBOSE_DEBUG */ 12/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c
index cb00ada21d9c..a41fb83e353e 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_serial.c - generic USB serial function driver 3 * f_serial.c - generic USB serial function driver
3 * 4 *
4 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) 5 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com)
5 * Copyright (C) 2008 by David Brownell 6 * Copyright (C) 2008 by David Brownell
6 * Copyright (C) 2008 by Nokia Corporation 7 * Copyright (C) 2008 by Nokia Corporation
7 *
8 * This software is distributed under the terms of the GNU General
9 * Public License ("GPL") as published by the Free Software Foundation,
10 * either version 2 of that License or (at your option) any later version.
11 */ 8 */
12 9
13#include <linux/slab.h> 10#include <linux/slab.h>
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 8784fa12ea2c..39757dd04744 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_sourcesink.c - USB peripheral source/sink configuration driver 3 * f_sourcesink.c - USB peripheral source/sink configuration driver
3 * 4 *
4 * Copyright (C) 2003-2008 David Brownell 5 * Copyright (C) 2003-2008 David Brownell
5 * Copyright (C) 2008 by Nokia Corporation 6 * Copyright (C) 2008 by Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* #define VERBOSE_DEBUG */ 9/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c
index 434b983f3b4c..a52d17a69977 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_subset.c -- "CDC Subset" Ethernet link function driver 3 * f_subset.c -- "CDC Subset" Ethernet link function driver
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2008 Nokia Corporation 6 * Copyright (C) 2008 Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/slab.h> 9#include <linux/slab.h>
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index a82e2bd5ea34..28cb53de51b8 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1,10 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Target based USB-Gadget 2/* Target based USB-Gadget
2 * 3 *
3 * UAS protocol handling, target callbacks, configfs handling, 4 * UAS protocol handling, target callbacks, configfs handling,
4 * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling. 5 * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling.
5 * 6 *
6 * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de> 7 * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de>
7 * License: GPLv2 as published by FSF.
8 */ 8 */
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
@@ -1145,6 +1145,7 @@ static int usbg_submit_command(struct f_uas *fu,
1145 default: 1145 default:
1146 pr_debug_once("Unsupported prio_attr: %02x.\n", 1146 pr_debug_once("Unsupported prio_attr: %02x.\n",
1147 cmd_iu->prio_attr); 1147 cmd_iu->prio_attr);
1148 /* fall through */
1148 case UAS_SIMPLE_TAG: 1149 case UAS_SIMPLE_TAG:
1149 cmd->prio_attr = TCM_SIMPLE_TAG; 1150 cmd->prio_attr = TCM_SIMPLE_TAG;
1150 break; 1151 break;
diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
index 29efbedc91f9..91e3f3e6bf78 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_uac1.c -- USB Audio Class 1.0 Function (using u_audio API) 3 * f_uac1.c -- USB Audio Class 1.0 Function (using u_audio API)
3 * 4 *
@@ -10,11 +11,6 @@
10 * This file is based on f_uac1.c which is 11 * This file is based on f_uac1.c which is
11 * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> 12 * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org>
12 * Copyright (C) 2008 Analog Devices, Inc 13 * Copyright (C) 2008 Analog Devices, Inc
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 */ 14 */
19 15
20#include <linux/usb/audio.h> 16#include <linux/usb/audio.h>
diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/gadget/function/f_uac1_legacy.c
index 5d229e72912e..8bd6f6e8d24a 100644
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_audio.c -- USB Audio class function driver 3 * f_audio.c -- USB Audio class function driver
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (C) 2008 Analog Devices, Inc 6 * Copyright (C) 2008 Analog Devices, Inc
6 * 7 *
7 * Enter bugs at http://blackfin.uclinux.org/ 8 * Enter bugs at http://blackfin.uclinux.org/
8 *
9 * Licensed under the GPL-2 or later.
10 */ 9 */
11 10
12#include <linux/slab.h> 11#include <linux/slab.h>
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index f05c3f3e6103..9dc33a70db33 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_uac2.c -- USB Audio Class 2.0 Function 3 * f_uac2.c -- USB Audio Class 2.0 Function
3 * 4 *
4 * Copyright (C) 2011 5 * Copyright (C) 2011
5 * Yadwinder Singh (yadi.brar01@gmail.com) 6 * Yadwinder Singh (yadi.brar01@gmail.com)
6 * Jaswinder Singh (jaswinder.singh@linaro.org) 7 * Jaswinder Singh (jaswinder.singh@linaro.org)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#include <linux/usb/audio.h> 10#include <linux/usb/audio.h>
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index f8a1881609a2..439eba660e95 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * uvc_gadget.c -- USB Video Class Gadget driver 3 * uvc_gadget.c -- USB Video Class Gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/f_uvc.h b/drivers/usb/gadget/function/f_uvc.h
index d0a73bdcbba1..81defe4557fe 100644
--- a/drivers/usb/gadget/function/f_uvc.h
+++ b/drivers/usb/gadget/function/f_uvc.h
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * f_uvc.h -- USB Video Class Gadget driver 3 * f_uvc.h -- USB Video Class Gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#ifndef _F_UVC_H_ 9#ifndef _F_UVC_H_
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index d6341045c631..51dd3e90b06c 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * RNDIS MSG parser 3 * RNDIS MSG parser
3 * 4 *
4 * Authors: Benedikt Spranger, Pengutronix 5 * Authors: Benedikt Spranger, Pengutronix
5 * Robert Schwebel, Pengutronix 6 * Robert Schwebel, Pengutronix
6 * 7 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This software was originally developed in conformance with 8 * This software was originally developed in conformance with
12 * Microsoft's Remote NDIS Specification License Agreement. 9 * Microsoft's Remote NDIS Specification License Agreement.
13 * 10 *
diff --git a/drivers/usb/gadget/function/rndis.h b/drivers/usb/gadget/function/rndis.h
index 21e0430ffb98..c7e3a70ce6c1 100644
--- a/drivers/usb/gadget/function/rndis.h
+++ b/drivers/usb/gadget/function/rndis.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * RNDIS Definitions for Remote NDIS 3 * RNDIS Definitions for Remote NDIS
3 * 4 *
4 * Authors: Benedikt Spranger, Pengutronix 5 * Authors: Benedikt Spranger, Pengutronix
5 * Robert Schwebel, Pengutronix 6 * Robert Schwebel, Pengutronix
6 * 7 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This software was originally developed in conformance with 8 * This software was originally developed in conformance with
12 * Microsoft's Remote NDIS Specification License Agreement. 9 * Microsoft's Remote NDIS Specification License Agreement.
13 */ 10 */
diff --git a/drivers/usb/gadget/function/storage_common.c b/drivers/usb/gadget/function/storage_common.c
index 8fbf6861690d..f7e6c42558eb 100644
--- a/drivers/usb/gadget/function/storage_common.c
+++ b/drivers/usb/gadget/function/storage_common.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * storage_common.c -- Common definitions for mass storage functionality 3 * storage_common.c -- Common definitions for mass storage functionality
3 * 4 *
4 * Copyright (C) 2003-2008 Alan Stern 5 * Copyright (C) 2003-2008 Alan Stern
5 * Copyeight (C) 2009 Samsung Electronics 6 * Copyeight (C) 2009 Samsung Electronics
6 * Author: Michal Nazarewicz (mina86@mina86.com) 7 * Author: Michal Nazarewicz (mina86@mina86.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14/* 10/*
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 3971bbab88bd..a72295c953bb 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_audio.c -- interface to USB gadget "ALSA sound card" utilities 3 * u_audio.c -- interface to USB gadget "ALSA sound card" utilities
3 * 4 *
@@ -9,16 +10,6 @@
9 * Copyright (C) 2011 10 * Copyright (C) 2011
10 * Yadwinder Singh (yadi.brar01@gmail.com) 11 * Yadwinder Singh (yadi.brar01@gmail.com)
11 * Jaswinder Singh (jaswinder.singh@linaro.org) 12 * Jaswinder Singh (jaswinder.singh@linaro.org)
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 */ 13 */
23 14
24#include <linux/module.h> 15#include <linux/module.h>
diff --git a/drivers/usb/gadget/function/u_audio.h b/drivers/usb/gadget/function/u_audio.h
index 07e13784cbb8..81d3d4ed6dfb 100644
--- a/drivers/usb/gadget/function/u_audio.h
+++ b/drivers/usb/gadget/function/u_audio.h
@@ -1,19 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_audio.h -- interface to USB gadget "ALSA sound card" utilities 3 * u_audio.h -- interface to USB gadget "ALSA sound card" utilities
3 * 4 *
4 * Copyright (C) 2016 5 * Copyright (C) 2016
5 * Author: Ruslan Bilovol <ruslan.bilovol@gmail.com> 6 * Author: Ruslan Bilovol <ruslan.bilovol@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 7 */
18 8
19#ifndef __U_AUDIO_H 9#ifndef __U_AUDIO_H
diff --git a/drivers/usb/gadget/function/u_ecm.h b/drivers/usb/gadget/function/u_ecm.h
index 262cc03cc2c0..050aa672ee7f 100644
--- a/drivers/usb/gadget/function/u_ecm.h
+++ b/drivers/usb/gadget/function/u_ecm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_ecm.h 3 * u_ecm.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_ECM_H 13#ifndef U_ECM_H
diff --git a/drivers/usb/gadget/function/u_eem.h b/drivers/usb/gadget/function/u_eem.h
index e3ae97874c4f..de3828d3e8f0 100644
--- a/drivers/usb/gadget/function/u_eem.h
+++ b/drivers/usb/gadget/function/u_eem.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_eem.h 3 * u_eem.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_EEM_H 13#ifndef U_EEM_H
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index bdbc3fdc7c4f..6fcda62f55ea 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_ether.c -- Ethernet-over-USB link layer utilities for Gadget stack 3 * u_ether.c -- Ethernet-over-USB link layer utilities for Gadget stack
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger 6 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
6 * Copyright (C) 2008 Nokia Corporation 7 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14/* #define VERBOSE_DEBUG */ 10/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/function/u_ether.h b/drivers/usb/gadget/function/u_ether.h
index c77145bd6b5b..332307d54292 100644
--- a/drivers/usb/gadget/function/u_ether.h
+++ b/drivers/usb/gadget/function/u_ether.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_ether.h -- interface to USB gadget "ethernet link" utilities 3 * u_ether.h -- interface to USB gadget "ethernet link" utilities
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger 6 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
6 * Copyright (C) 2008 Nokia Corporation 7 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#ifndef __U_ETHER_H 10#ifndef __U_ETHER_H
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h b/drivers/usb/gadget/function/u_ether_configfs.h
index e4c3f84af4c3..cd33cee4d78b 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_ether_configfs.h 3 * u_ether_configfs.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef __U_ETHER_CONFIGFS_H 13#ifndef __U_ETHER_CONFIGFS_H
diff --git a/drivers/usb/gadget/function/u_fs.h b/drivers/usb/gadget/function/u_fs.h
index 79f70ebf85dc..c3aba4dfa958 100644
--- a/drivers/usb/gadget/function/u_fs.h
+++ b/drivers/usb/gadget/function/u_fs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_fs.h 3 * u_fs.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_FFS_H 13#ifndef U_FFS_H
diff --git a/drivers/usb/gadget/function/u_gether.h b/drivers/usb/gadget/function/u_gether.h
index d4078426ba5d..5b7e2eb90336 100644
--- a/drivers/usb/gadget/function/u_gether.h
+++ b/drivers/usb/gadget/function/u_gether.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_gether.h 3 * u_gether.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_GETHER_H 13#ifndef U_GETHER_H
diff --git a/drivers/usb/gadget/function/u_hid.h b/drivers/usb/gadget/function/u_hid.h
index aaa0e368a159..2f5ca4bfa7ff 100644
--- a/drivers/usb/gadget/function/u_hid.h
+++ b/drivers/usb/gadget/function/u_hid.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_hid.h 3 * u_hid.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_HID_H 13#ifndef U_HID_H
diff --git a/drivers/usb/gadget/function/u_midi.h b/drivers/usb/gadget/function/u_midi.h
index 22510189758e..5599aa5fc977 100644
--- a/drivers/usb/gadget/function/u_midi.h
+++ b/drivers/usb/gadget/function/u_midi.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_midi.h 3 * u_midi.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_MIDI_H 13#ifndef U_MIDI_H
diff --git a/drivers/usb/gadget/function/u_ncm.h b/drivers/usb/gadget/function/u_ncm.h
index ce0f3a78ca13..67324f983343 100644
--- a/drivers/usb/gadget/function/u_ncm.h
+++ b/drivers/usb/gadget/function/u_ncm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_ncm.h 3 * u_ncm.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_NCM_H 13#ifndef U_NCM_H
diff --git a/drivers/usb/gadget/function/u_phonet.h b/drivers/usb/gadget/function/u_phonet.h
index 98ced18779ea..12fb613f85d1 100644
--- a/drivers/usb/gadget/function/u_phonet.h
+++ b/drivers/usb/gadget/function/u_phonet.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_phonet.h - interface to Phonet 3 * u_phonet.h - interface to Phonet
3 * 4 *
4 * Copyright (C) 2007-2008 by Nokia Corporation 5 * Copyright (C) 2007-2008 by Nokia Corporation
5 *
6 * This software is distributed under the terms of the GNU General
7 * Public License ("GPL") as published by the Free Software Foundation,
8 * either version 2 of that License or (at your option) any later version.
9 */ 6 */
10 7
11#ifndef __U_PHONET_H 8#ifndef __U_PHONET_H
diff --git a/drivers/usb/gadget/function/u_printer.h b/drivers/usb/gadget/function/u_printer.h
index 8d30b7577f87..6088ff744194 100644
--- a/drivers/usb/gadget/function/u_printer.h
+++ b/drivers/usb/gadget/function/u_printer.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_printer.h 3 * u_printer.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_PRINTER_H 13#ifndef U_PRINTER_H
diff --git a/drivers/usb/gadget/function/u_rndis.h b/drivers/usb/gadget/function/u_rndis.h
index efdb7ac381d9..d65fb4ebac3c 100644
--- a/drivers/usb/gadget/function/u_rndis.h
+++ b/drivers/usb/gadget/function/u_rndis.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_rndis.h 3 * u_rndis.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_RNDIS_H 13#ifndef U_RNDIS_H
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 4176216d54be..4d653d2960d4 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_serial.c - utilities for USB gadget "serial port"/TTY support 3 * u_serial.c - utilities for USB gadget "serial port"/TTY support
3 * 4 *
@@ -9,10 +10,6 @@
9 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) 10 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
10 * Copyright (C) 2000 Peter Berger (pberger@brimson.com) 11 * Copyright (C) 2000 Peter Berger (pberger@brimson.com)
11 * Copyright (C) 2000 Al Borchers (alborchers@steinerpoint.com) 12 * Copyright (C) 2000 Al Borchers (alborchers@steinerpoint.com)
12 *
13 * This software is distributed under the terms of the GNU General
14 * Public License ("GPL") as published by the Free Software Foundation,
15 * either version 2 of that License or (at your option) any later version.
16 */ 13 */
17 14
18/* #define VERBOSE_DEBUG */ 15/* #define VERBOSE_DEBUG */
@@ -1078,6 +1075,7 @@ static void gs_complete_out(struct usb_ep *ep, struct usb_request *req)
1078 default: 1075 default:
1079 pr_warn("%s: unexpected %s status %d\n", 1076 pr_warn("%s: unexpected %s status %d\n",
1080 __func__, ep->name, req->status); 1077 __func__, ep->name, req->status);
1078 /* fall through */
1081 case 0: 1079 case 0:
1082 /* normal completion */ 1080 /* normal completion */
1083 spin_lock(&info->con_lock); 1081 spin_lock(&info->con_lock);
diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h
index c20210c0babd..9acaac1cbb75 100644
--- a/drivers/usb/gadget/function/u_serial.h
+++ b/drivers/usb/gadget/function/u_serial.h
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_serial.h - interface to USB gadget "serial port"/TTY utilities 3 * u_serial.h - interface to USB gadget "serial port"/TTY utilities
3 * 4 *
4 * Copyright (C) 2008 David Brownell 5 * Copyright (C) 2008 David Brownell
5 * Copyright (C) 2008 by Nokia Corporation 6 * Copyright (C) 2008 by Nokia Corporation
6 *
7 * This software is distributed under the terms of the GNU General
8 * Public License ("GPL") as published by the Free Software Foundation,
9 * either version 2 of that License or (at your option) any later version.
10 */ 7 */
11 8
12#ifndef __U_SERIAL_H 9#ifndef __U_SERIAL_H
diff --git a/drivers/usb/gadget/function/u_tcm.h b/drivers/usb/gadget/function/u_tcm.h
index 0bd751e0483f..3f7ccecb0f9b 100644
--- a/drivers/usb/gadget/function/u_tcm.h
+++ b/drivers/usb/gadget/function/u_tcm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_tcm.h 3 * u_tcm.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_TCM_H 13#ifndef U_TCM_H
diff --git a/drivers/usb/gadget/function/u_uac1.h b/drivers/usb/gadget/function/u_uac1.h
index 6f188fd8633f..6f1a9d73defe 100644
--- a/drivers/usb/gadget/function/u_uac1.h
+++ b/drivers/usb/gadget/function/u_uac1.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_uac1.h - Utility definitions for UAC1 function 3 * u_uac1.h - Utility definitions for UAC1 function
3 * 4 *
4 * Copyright (C) 2016 Ruslan Bilovol <ruslan.bilovol@gmail.com> 5 * Copyright (C) 2016 Ruslan Bilovol <ruslan.bilovol@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#ifndef __U_UAC1_H 8#ifndef __U_UAC1_H
diff --git a/drivers/usb/gadget/function/u_uac1_legacy.c b/drivers/usb/gadget/function/u_uac1_legacy.c
index fa4684a1c54c..cbc868d117af 100644
--- a/drivers/usb/gadget/function/u_uac1_legacy.c
+++ b/drivers/usb/gadget/function/u_uac1_legacy.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_uac1.c -- ALSA audio utilities for Gadget stack 3 * u_uac1.c -- ALSA audio utilities for Gadget stack
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (C) 2008 Analog Devices, Inc 6 * Copyright (C) 2008 Analog Devices, Inc
6 * 7 *
7 * Enter bugs at http://blackfin.uclinux.org/ 8 * Enter bugs at http://blackfin.uclinux.org/
8 *
9 * Licensed under the GPL-2 or later.
10 */ 9 */
11 10
12#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/u_uac1_legacy.h b/drivers/usb/gadget/function/u_uac1_legacy.h
index d715b1af56a4..dd69e408a3d9 100644
--- a/drivers/usb/gadget/function/u_uac1_legacy.h
+++ b/drivers/usb/gadget/function/u_uac1_legacy.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities 3 * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (C) 2008 Analog Devices, Inc 6 * Copyright (C) 2008 Analog Devices, Inc
6 * 7 *
7 * Enter bugs at http://blackfin.uclinux.org/ 8 * Enter bugs at http://blackfin.uclinux.org/
8 *
9 * Licensed under the GPL-2 or later.
10 */ 9 */
11 10
12#ifndef __U_UAC1_LEGACY_H 11#ifndef __U_UAC1_LEGACY_H
diff --git a/drivers/usb/gadget/function/u_uac2.h b/drivers/usb/gadget/function/u_uac2.h
index 19eeb83538a5..8362ee572e1e 100644
--- a/drivers/usb/gadget/function/u_uac2.h
+++ b/drivers/usb/gadget/function/u_uac2.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_uac2.h 3 * u_uac2.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_UAC2_H 13#ifndef U_UAC2_H
diff --git a/drivers/usb/gadget/function/u_uvc.h b/drivers/usb/gadget/function/u_uvc.h
index 4676b60a5063..d00d3ded71c0 100644
--- a/drivers/usb/gadget/function/u_uvc.h
+++ b/drivers/usb/gadget/function/u_uvc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_uvc.h 3 * u_uvc.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef U_UVC_H 13#ifndef U_UVC_H
diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
index 11d70dead32b..a64e07e61f8c 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * uvc_gadget.h -- USB Video Class Gadget driver 3 * uvc_gadget.h -- USB Video Class Gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#ifndef _UVC_GADGET_H_ 9#ifndef _UVC_GADGET_H_
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index 844cb738bafd..d2ad1442769a 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uvc_configfs.c 3 * uvc_configfs.c
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15#include "u_uvc.h" 12#include "u_uvc.h"
16#include "uvc_configfs.h" 13#include "uvc_configfs.h"
diff --git a/drivers/usb/gadget/function/uvc_configfs.h b/drivers/usb/gadget/function/uvc_configfs.h
index 085e67be7c71..8549c0b27b9d 100644
--- a/drivers/usb/gadget/function/uvc_configfs.h
+++ b/drivers/usb/gadget/function/uvc_configfs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uvc_configfs.h 3 * uvc_configfs.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15#ifndef UVC_CONFIGFS_H 12#ifndef UVC_CONFIGFS_H
16#define UVC_CONFIGFS_H 13#define UVC_CONFIGFS_H
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
index 6377e9fee6e5..278d50ff1eea 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * uvc_queue.c -- USB Video Class driver - Buffers management 3 * uvc_queue.c -- USB Video Class driver - Buffers management
3 * 4 *
4 * Copyright (C) 2005-2010 5 * Copyright (C) 2005-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/atomic.h> 9#include <linux/atomic.h>
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 3e22b45687d3..f3069db6f08e 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * uvc_v4l2.c -- USB Video Class Gadget driver 3 * uvc_v4l2.c -- USB Video Class Gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -354,7 +350,7 @@ static unsigned long uvcg_v4l2_get_unmapped_area(struct file *file,
354} 350}
355#endif 351#endif
356 352
357struct v4l2_file_operations uvc_v4l2_fops = { 353const struct v4l2_file_operations uvc_v4l2_fops = {
358 .owner = THIS_MODULE, 354 .owner = THIS_MODULE,
359 .open = uvc_v4l2_open, 355 .open = uvc_v4l2_open,
360 .release = uvc_v4l2_release, 356 .release = uvc_v4l2_release,
diff --git a/drivers/usb/gadget/function/uvc_v4l2.h b/drivers/usb/gadget/function/uvc_v4l2.h
index 2683b92fda65..a75e9c397446 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.h
+++ b/drivers/usb/gadget/function/uvc_v4l2.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uvc_v4l2.h -- USB Video Class Gadget driver 3 * uvc_v4l2.h -- USB Video Class Gadget driver
3 * 4 *
@@ -7,16 +8,12 @@
7 * Copyright (c) 2013 Samsung Electronics Co., Ltd. 8 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
8 * http://www.samsung.com 9 * http://www.samsung.com
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef __UVC_V4L2_H__ 13#ifndef __UVC_V4L2_H__
17#define __UVC_V4L2_H__ 14#define __UVC_V4L2_H__
18 15
19extern const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops; 16extern const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops;
20extern struct v4l2_file_operations uvc_v4l2_fops; 17extern const struct v4l2_file_operations uvc_v4l2_fops;
21 18
22#endif /* __UVC_V4L2_H__ */ 19#endif /* __UVC_V4L2_H__ */
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 0f01c04d7cbd..d3567b90343a 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * uvc_video.c -- USB Video Class Gadget driver 3 * uvc_video.c -- USB Video Class Gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/function/uvc_video.h b/drivers/usb/gadget/function/uvc_video.h
index ef00f06fa00b..6c20aa75f966 100644
--- a/drivers/usb/gadget/function/uvc_video.h
+++ b/drivers/usb/gadget/function/uvc_video.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * uvc_video.h -- USB Video Class Gadget driver 3 * uvc_video.h -- USB Video Class Gadget driver
3 * 4 *
@@ -7,10 +8,6 @@
7 * Copyright (c) 2013 Samsung Electronics Co., Ltd. 8 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
8 * http://www.samsung.com 9 * http://www.samsung.com
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15#ifndef __UVC_VIDEO_H__ 12#ifndef __UVC_VIDEO_H__
16#define __UVC_VIDEO_H__ 13#define __UVC_VIDEO_H__
diff --git a/drivers/usb/gadget/functions.c b/drivers/usb/gadget/functions.c
index b13f839e7368..203361a64212 100644
--- a/drivers/usb/gadget/functions.c
+++ b/drivers/usb/gadget/functions.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2#include <linux/slab.h> 3#include <linux/slab.h>
3#include <linux/module.h> 4#include <linux/module.h>
diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c
index c39de65a448b..af16672d5118 100644
--- a/drivers/usb/gadget/legacy/acm_ms.c
+++ b/drivers/usb/gadget/legacy/acm_ms.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * acm_ms.c -- Composite driver, with ACM and mass storage support 3 * acm_ms.c -- Composite driver, with ACM and mass storage support
3 * 4 *
@@ -7,11 +8,6 @@
7 * Modified: Klaus Schwarzkopf <schwarzkopf@sensortherm.de> 8 * Modified: Klaus Schwarzkopf <schwarzkopf@sensortherm.de>
8 * 9 *
9 * Heavily based on multi.c and cdc2.c 10 * Heavily based on multi.c and cdc2.c
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */ 11 */
16 12
17#include <linux/kernel.h> 13#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c
index 1f5cdbe162df..7b11dce98b94 100644
--- a/drivers/usb/gadget/legacy/audio.c
+++ b/drivers/usb/gadget/legacy/audio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * audio.c -- Audio gadget driver 3 * audio.c -- Audio gadget driver
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (C) 2008 Analog Devices, Inc 6 * Copyright (C) 2008 Analog Devices, Inc
6 * 7 *
7 * Enter bugs at http://blackfin.uclinux.org/ 8 * Enter bugs at http://blackfin.uclinux.org/
8 *
9 * Licensed under the GPL-2 or later.
10 */ 9 */
11 10
12/* #define VERBOSE_DEBUG */ 11/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c
index 51c08682de84..da1c37933ca1 100644
--- a/drivers/usb/gadget/legacy/cdc2.c
+++ b/drivers/usb/gadget/legacy/cdc2.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * cdc2.c -- CDC Composite driver, with ECM and ACM support 3 * cdc2.c -- CDC Composite driver, with ECM and ACM support
3 * 4 *
4 * Copyright (C) 2008 David Brownell 5 * Copyright (C) 2008 David Brownell
5 * Copyright (C) 2008 Nokia Corporation 6 * Copyright (C) 2008 Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 99ca3dabc4f3..e1d566c9918a 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dbgp.c -- EHCI Debug Port device gadget 3 * dbgp.c -- EHCI Debug Port device gadget
3 * 4 *
diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c
index 25a2c2e48592..30313b233680 100644
--- a/drivers/usb/gadget/legacy/ether.c
+++ b/drivers/usb/gadget/legacy/ether.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * ether.c -- Ethernet gadget driver, with CDC and non-CDC options 3 * ether.c -- Ethernet gadget driver, with CDC and non-CDC options
3 * 4 *
4 * Copyright (C) 2003-2005,2008 David Brownell 5 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger 6 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
6 * Copyright (C) 2008 Nokia Corporation 7 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14/* #define VERBOSE_DEBUG */ 10/* #define VERBOSE_DEBUG */
diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c
index 6da7316f8e87..b640ed3fcf70 100644
--- a/drivers/usb/gadget/legacy/g_ffs.c
+++ b/drivers/usb/gadget/legacy/g_ffs.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * g_ffs.c -- user mode file system API for USB composite function controllers 3 * g_ffs.c -- user mode file system API for USB composite function controllers
3 * 4 *
4 * Copyright (C) 2010 Samsung Electronics 5 * Copyright (C) 2010 Samsung Electronics
5 * Author: Michal Nazarewicz <mina86@mina86.com> 6 * Author: Michal Nazarewicz <mina86@mina86.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#define pr_fmt(fmt) "g_ffs: " fmt 9#define pr_fmt(fmt) "g_ffs: " fmt
diff --git a/drivers/usb/gadget/legacy/gmidi.c b/drivers/usb/gadget/legacy/gmidi.c
index 0bf39c3ccdb1..9eea2d18f2bf 100644
--- a/drivers/usb/gadget/legacy/gmidi.c
+++ b/drivers/usb/gadget/legacy/gmidi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * gmidi.c -- USB MIDI Gadget Driver 3 * gmidi.c -- USB MIDI Gadget Driver
3 * 4 *
@@ -5,9 +6,6 @@
5 * Developed for Thumtronics by Grey Innovation 6 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com> 7 * Ben Williamson <ben.williamson@greyinnovation.com>
7 * 8 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This code is based in part on: 9 * This code is based in part on:
12 * 10 *
13 * Gadget Zero driver, Copyright (C) 2003-2004 David Brownell. 11 * Gadget Zero driver, Copyright (C) 2003-2004 David Brownell.
diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index a71a884f79fc..c4eda7fe7ab4 100644
--- a/drivers/usb/gadget/legacy/hid.c
+++ b/drivers/usb/gadget/legacy/hid.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * hid.c -- HID Composite driver 3 * hid.c -- HID Composite driver
3 * 4 *
4 * Based on multi.c 5 * Based on multi.c
5 * 6 *
6 * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com> 7 * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14 10
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 5c28bee327e1..9343ec436485 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * inode.c -- user mode filesystem api for usb gadget controllers 3 * inode.c -- user mode filesystem api for usb gadget controllers
3 * 4 *
4 * Copyright (C) 2003-2004 David Brownell 5 * Copyright (C) 2003-2004 David Brownell
5 * Copyright (C) 2003 Agilent Technologies 6 * Copyright (C) 2003 Agilent Technologies
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13 9
diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c
index fcba59782f26..ef3d25259b0e 100644
--- a/drivers/usb/gadget/legacy/mass_storage.c
+++ b/drivers/usb/gadget/legacy/mass_storage.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * mass_storage.c -- Mass Storage USB Gadget 3 * mass_storage.c -- Mass Storage USB Gadget
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 2009 Samsung Electronics 6 * Copyright (C) 2009 Samsung Electronics
6 * Author: Michal Nazarewicz <mina86@mina86.com> 7 * Author: Michal Nazarewicz <mina86@mina86.com>
7 * All rights reserved. 8 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15 11
diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c
index a70a406580ea..50515f9e1022 100644
--- a/drivers/usb/gadget/legacy/multi.c
+++ b/drivers/usb/gadget/legacy/multi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * multi.c -- Multifunction Composite driver 3 * multi.c -- Multifunction Composite driver
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 2008 Nokia Corporation 6 * Copyright (C) 2008 Nokia Corporation
6 * Copyright (C) 2009 Samsung Electronics 7 * Copyright (C) 2009 Samsung Electronics
7 * Author: Michal Nazarewicz (mina86@mina86.com) 8 * Author: Michal Nazarewicz (mina86@mina86.com)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15 11
diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c
index 0aba68253e3d..fcee1ee0bf66 100644
--- a/drivers/usb/gadget/legacy/ncm.c
+++ b/drivers/usb/gadget/legacy/ncm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * ncm.c -- NCM gadget driver 3 * ncm.c -- NCM gadget driver
3 * 4 *
@@ -9,11 +10,6 @@
9 * Copyright (C) 2003-2005,2008 David Brownell 10 * Copyright (C) 2003-2005,2008 David Brownell
10 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger 11 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
11 * Copyright (C) 2008 Nokia Corporation 12 * Copyright (C) 2008 Nokia Corporation
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 */ 13 */
18 14
19/* #define DEBUG */ 15/* #define DEBUG */
diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
index b1e535f4022e..978c1a34a932 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * nokia.c -- Nokia Composite Gadget Driver 3 * nokia.c -- Nokia Composite Gadget Driver
3 * 4 *
@@ -9,10 +10,6 @@
9 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) 10 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com)
10 * Copyright (C) 2008 by David Brownell 11 * Copyright (C) 2008 by David Brownell
11 * Copyright (C) 2008 by Nokia Corporation 12 * Copyright (C) 2008 by Nokia Corporation
12 *
13 * This software is distributed under the terms of the GNU General
14 * Public License ("GPL") as published by the Free Software Foundation,
15 * version 2 of that License.
16 */ 13 */
17 14
18#include <linux/kernel.h> 15#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c
index 4c9cfff34a03..57858f0c2b6c 100644
--- a/drivers/usb/gadget/legacy/printer.c
+++ b/drivers/usb/gadget/legacy/printer.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * printer.c -- Printer gadget driver 3 * printer.c -- Printer gadget driver
3 * 4 *
4 * Copyright (C) 2003-2005 David Brownell 5 * Copyright (C) 2003-2005 David Brownell
5 * Copyright (C) 2006 Craig W. Nadler 6 * Copyright (C) 2006 Craig W. Nadler
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c
index 9d89adce756d..de30d7628eef 100644
--- a/drivers/usb/gadget/legacy/serial.c
+++ b/drivers/usb/gadget/legacy/serial.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * serial.c -- USB gadget serial driver 3 * serial.c -- USB gadget serial driver
3 * 4 *
4 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) 5 * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com)
5 * Copyright (C) 2008 by David Brownell 6 * Copyright (C) 2008 by David Brownell
6 * Copyright (C) 2008 by Nokia Corporation 7 * Copyright (C) 2008 by Nokia Corporation
7 *
8 * This software is distributed under the terms of the GNU General
9 * Public License ("GPL") as published by the Free Software Foundation,
10 * either version 2 of that License or (at your option) any later version.
11 */ 8 */
12 9
13#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 0b0bb98319cd..682bf99dcf76 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -1,10 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Target based USB-Gadget 2/* Target based USB-Gadget
2 * 3 *
3 * UAS protocol handling, target callbacks, configfs handling, 4 * UAS protocol handling, target callbacks, configfs handling,
4 * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling. 5 * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling.
5 * 6 *
6 * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de> 7 * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de>
7 * License: GPLv2 as published by FSF.
8 */ 8 */
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
index 82c13fce9232..6b86568c9157 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * webcam.c -- USB webcam gadget driver 3 * webcam.c -- USB webcam gadget driver
3 * 4 *
4 * Copyright (C) 2009-2010 5 * Copyright (C) 2009-2010
5 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
index d02e2ce73ea5..6e84b44c8a3b 100644
--- a/drivers/usb/gadget/legacy/zero.c
+++ b/drivers/usb/gadget/legacy/zero.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * zero.c -- Gadget Zero, for USB development 3 * zero.c -- Gadget Zero, for USB development
3 * 4 *
4 * Copyright (C) 2003-2008 David Brownell 5 * Copyright (C) 2003-2008 David Brownell
5 * Copyright (C) 2008 by Nokia Corporation 6 * Copyright (C) 2008 by Nokia Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* 9/*
@@ -154,10 +150,11 @@ static struct usb_gadget_strings *dev_strings[] = {
154/*-------------------------------------------------------------------------*/ 150/*-------------------------------------------------------------------------*/
155 151
156static struct timer_list autoresume_timer; 152static struct timer_list autoresume_timer;
153static struct usb_composite_dev *autoresume_cdev;
157 154
158static void zero_autoresume(unsigned long _c) 155static void zero_autoresume(struct timer_list *unused)
159{ 156{
160 struct usb_composite_dev *cdev = (void *)_c; 157 struct usb_composite_dev *cdev = autoresume_cdev;
161 struct usb_gadget *g = cdev->gadget; 158 struct usb_gadget *g = cdev->gadget;
162 159
163 /* unconfigured devices can't issue wakeups */ 160 /* unconfigured devices can't issue wakeups */
@@ -282,7 +279,8 @@ static int zero_bind(struct usb_composite_dev *cdev)
282 device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; 279 device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
283 device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id; 280 device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id;
284 281
285 setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); 282 autoresume_cdev = cdev;
283 timer_setup(&autoresume_timer, zero_autoresume, 0);
286 284
287 func_inst_ss = usb_get_function_instance("SourceSink"); 285 func_inst_ss = usb_get_function_instance("SourceSink");
288 if (IS_ERR(func_inst_ss)) 286 if (IS_ERR(func_inst_ss))
diff --git a/drivers/usb/gadget/u_f.c b/drivers/usb/gadget/u_f.c
index 18839732c840..dbaa46eee853 100644
--- a/drivers/usb/gadget/u_f.c
+++ b/drivers/usb/gadget/u_f.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_f.c -- USB function utilities for Gadget stack 3 * u_f.c -- USB function utilities for Gadget stack
3 * 4 *
@@ -5,10 +6,6 @@
5 * http://www.samsung.com 6 * http://www.samsung.com
6 * 7 *
7 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 8 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */ 9 */
13 10
14#include "u_f.h" 11#include "u_f.h"
diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
index 7d53a4773d1a..c3fbef2bb5db 100644
--- a/drivers/usb/gadget/u_f.h
+++ b/drivers/usb/gadget/u_f.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_f.h 3 * u_f.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef __U_F_H__ 13#ifndef __U_F_H__
diff --git a/drivers/usb/gadget/u_os_desc.h b/drivers/usb/gadget/u_os_desc.h
index 947b7ddff691..8acd21779ac8 100644
--- a/drivers/usb/gadget/u_os_desc.h
+++ b/drivers/usb/gadget/u_os_desc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * u_os_desc.h 3 * u_os_desc.h
3 * 4 *
@@ -7,10 +8,6 @@
7 * http://www.samsung.com 8 * http://www.samsung.com
8 * 9 *
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef __U_OS_DESC_H__ 13#ifndef __U_OS_DESC_H__
diff --git a/drivers/usb/gadget/udc/amd5536udc.h b/drivers/usb/gadget/udc/amd5536udc.h
index 4fe22d432af2..dfdef6a28904 100644
--- a/drivers/usb/gadget/udc/amd5536udc.h
+++ b/drivers/usb/gadget/udc/amd5536udc.h
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * amd5536.h -- header for AMD 5536 UDC high/full speed USB device controller 3 * amd5536.h -- header for AMD 5536 UDC high/full speed USB device controller
3 * 4 *
4 * Copyright (C) 2007 AMD (http://www.amd.com) 5 * Copyright (C) 2007 AMD (http://www.amd.com)
5 * Author: Thomas Dahlmann 6 * Author: Thomas Dahlmann
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#ifndef AMD5536UDC_H 9#ifndef AMD5536UDC_H
diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c
index 57a13f080a79..57b6f66331cf 100644
--- a/drivers/usb/gadget/udc/amd5536udc_pci.c
+++ b/drivers/usb/gadget/udc/amd5536udc_pci.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * amd5536udc_pci.c -- AMD 5536 UDC high/full speed USB device controller 3 * amd5536udc_pci.c -- AMD 5536 UDC high/full speed USB device controller
3 * 4 *
4 * Copyright (C) 2005-2007 AMD (http://www.amd.com) 5 * Copyright (C) 2005-2007 AMD (http://www.amd.com)
5 * Author: Thomas Dahlmann 6 * Author: Thomas Dahlmann
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* 9/*
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index 8bc78418d40e..bfe278294e88 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * at91_udc -- driver for at91-series USB peripheral controller 3 * at91_udc -- driver for at91-series USB peripheral controller
3 * 4 *
4 * Copyright (C) 2004 by Thomas Rathbone 5 * Copyright (C) 2004 by Thomas Rathbone
5 * Copyright (C) 2005 by HP Labs 6 * Copyright (C) 2005 by HP Labs
6 * Copyright (C) 2005 by David Brownell 7 * Copyright (C) 2005 by David Brownell
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#undef VERBOSE_DEBUG 10#undef VERBOSE_DEBUG
diff --git a/drivers/usb/gadget/udc/at91_udc.h b/drivers/usb/gadget/udc/at91_udc.h
index 9bbe72764f31..fd58c5b81826 100644
--- a/drivers/usb/gadget/udc/at91_udc.h
+++ b/drivers/usb/gadget/udc/at91_udc.h
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2004 by Thomas Rathbone, HP Labs 3 * Copyright (C) 2004 by Thomas Rathbone, HP Labs
3 * Copyright (C) 2005 by Ivan Kokshaysky 4 * Copyright (C) 2005 by Ivan Kokshaysky
4 * Copyright (C) 2006 by SAN People 5 * Copyright (C) 2006 by SAN People
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#ifndef AT91_UDC_H 8#ifndef AT91_UDC_H
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index a884c022df7a..075eaaa8a408 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the Atmel USBA high speed USB device controller 3 * Driver for the Atmel USBA high speed USB device controller
3 * 4 *
4 * Copyright (C) 2005-2007 Atmel Corporation 5 * Copyright (C) 2005-2007 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10#include <linux/clk.h> 7#include <linux/clk.h>
11#include <linux/clk/at91_pmc.h> 8#include <linux/clk/at91_pmc.h>
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index f8ebe0389bd4..860a00a6fdd0 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the Atmel USBA high speed USB device controller 3 * Driver for the Atmel USBA high speed USB device controller
3 * 4 *
4 * Copyright (C) 2005-2007 Atmel Corporation 5 * Copyright (C) 2005-2007 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10#ifndef __LINUX_USB_GADGET_USBA_UDC_H__ 7#ifndef __LINUX_USB_GADGET_USBA_UDC_H__
11#define __LINUX_USB_GADGET_USBA_UDC_H__ 8#define __LINUX_USB_GADGET_USBA_UDC_H__
diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
index f78503203f42..29f254793592 100644
--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
+++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bcm63xx_udc.c -- BCM63xx UDC high/full speed USB device controller 3 * bcm63xx_udc.c -- BCM63xx UDC high/full speed USB device controller
3 * 4 *
4 * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com> 5 * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
5 * Copyright (C) 2012 Broadcom Corporation 6 * Copyright (C) 2012 Broadcom Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/bitops.h> 9#include <linux/bitops.h>
diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 6df0352cdc50..6e1e881dc51e 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc.h - header for the BRCM BDC USB3.0 device controller 3 * bdc.h - header for the BRCM BDC USB3.0 device controller
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14 9
15#ifndef __LINUX_BDC_H__ 10#ifndef __LINUX_BDC_H__
diff --git a/drivers/usb/gadget/udc/bdc/bdc_cmd.c b/drivers/usb/gadget/udc/bdc/bdc_cmd.c
index 6e920f1dce02..6305bf2c8b59 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_cmd.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_cmd.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_cmd.c - BRCM BDC USB3.0 device controller 3 * bdc_cmd.c - BRCM BDC USB3.0 device controller
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
15#include <linux/slab.h> 10#include <linux/slab.h>
diff --git a/drivers/usb/gadget/udc/bdc/bdc_cmd.h b/drivers/usb/gadget/udc/bdc/bdc_cmd.h
index 61d0e3bf9853..29cc988a671a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_cmd.h
+++ b/drivers/usb/gadget/udc/bdc/bdc_cmd.h
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_cmd.h - header for the BDC debug functions 3 * bdc_cmd.h - header for the BDC debug functions
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14#ifndef __LINUX_BDC_CMD_H__ 9#ifndef __LINUX_BDC_CMD_H__
15#define __LINUX_BDC_CMD_H__ 10#define __LINUX_BDC_CMD_H__
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 7a8af4b916cf..d39f070acbd7 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_core.c - BRCM BDC USB3.0 device controller core operations 3 * bdc_core.c - BRCM BDC USB3.0 device controller core operations
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14#include <linux/module.h> 9#include <linux/module.h>
15#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index ac98f6f681b7..7ba7448ad743 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_dbg.c - BRCM BDC USB3.0 device controller debug functions 3 * bdc_dbg.c - BRCM BDC USB3.0 device controller debug functions
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14 9
15#include "bdc.h" 10#include "bdc.h"
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.h b/drivers/usb/gadget/udc/bdc/bdc_dbg.h
index 338a6c701315..373d5abffbb8 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.h
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.h
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_dbg.h - header for the BDC debug functions 3 * bdc_dbg.h - header for the BDC debug functions
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14#ifndef __LINUX_BDC_DBG_H__ 9#ifndef __LINUX_BDC_DBG_H__
15#define __LINUX_BDC_DBG_H__ 10#define __LINUX_BDC_DBG_H__
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index bfd8f7ade935..f40d4c13cfa4 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_ep.c - BRCM BDC USB3.0 device controller endpoint related functions 3 * bdc_ep.c - BRCM BDC USB3.0 device controller endpoint related functions
3 * 4 *
@@ -6,12 +7,6 @@
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 * 8 *
8 * Based on drivers under drivers/usb/ 9 * Based on drivers under drivers/usb/
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */ 10 */
16#include <linux/module.h> 11#include <linux/module.h>
17#include <linux/pci.h> 12#include <linux/pci.h>
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.h b/drivers/usb/gadget/udc/bdc/bdc_ep.h
index 8a6b36cbf2ea..a37ff8033b4f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.h
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.h
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_ep.h - header for the BDC debug functions 3 * bdc_ep.h - header for the BDC debug functions
3 * 4 *
4 * Copyright (C) 2014 Broadcom Corporation 5 * Copyright (C) 2014 Broadcom Corporation
5 * 6 *
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14#ifndef __LINUX_BDC_EP_H__ 9#ifndef __LINUX_BDC_EP_H__
15#define __LINUX_BDC_EP_H__ 10#define __LINUX_BDC_EP_H__
diff --git a/drivers/usb/gadget/udc/bdc/bdc_pci.c b/drivers/usb/gadget/udc/bdc/bdc_pci.c
index 02968842b359..1e940f054cb8 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_pci.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_pci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_pci.c - BRCM BDC USB3.0 device controller PCI interface file. 3 * bdc_pci.c - BRCM BDC USB3.0 device controller PCI interface file.
3 * 4 *
@@ -6,12 +7,6 @@
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 * 8 *
8 * Based on drivers under drivers/usb/ 9 * Based on drivers under drivers/usb/
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */ 10 */
16 11
17#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/udc/bdc/bdc_udc.c b/drivers/usb/gadget/udc/bdc/bdc_udc.c
index c84346146456..7bfd58c846f7 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_udc.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bdc_udc.c - BRCM BDC USB3.0 device controller gagdet ops 3 * bdc_udc.c - BRCM BDC USB3.0 device controller gagdet ops
3 * 4 *
@@ -6,12 +7,6 @@
6 * Author: Ashwini Pahuja 7 * Author: Ashwini Pahuja
7 * 8 *
8 * Based on drivers under drivers/usb/gadget/udc/ 9 * Based on drivers under drivers/usb/gadget/udc/
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */ 10 */
16#include <linux/module.h> 11#include <linux/module.h>
17#include <linux/pci.h> 12#include <linux/pci.h>
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index d41d07aae0ce..61422d624ad0 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * udc.c - Core UDC Framework 3 * udc.c - Core UDC Framework
3 * 4 *
4 * Copyright (C) 2010 Texas Instruments 5 * Copyright (C) 2010 Texas Instruments
5 * Author: Felipe Balbi <balbi@ti.com> 6 * Author: Felipe Balbi <balbi@ti.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19 8
20#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -912,7 +901,7 @@ int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
912 return 0; 901 return 0;
913 902
914 type = usb_endpoint_type(desc); 903 type = usb_endpoint_type(desc);
915 max = 0x7ff & usb_endpoint_maxp(desc); 904 max = usb_endpoint_maxp(desc);
916 905
917 if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in) 906 if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
918 return 0; 907 return 0;
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index f04e91ef9e7c..4f1b1809472c 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * dummy_hcd.c -- Dummy/Loopback USB host and device emulator driver. 3 * dummy_hcd.c -- Dummy/Loopback USB host and device emulator driver.
3 * 4 *
@@ -5,11 +6,6 @@
5 * 6 *
6 * Copyright (C) 2003 David Brownell 7 * Copyright (C) 2003 David Brownell
7 * Copyright (C) 2003-2005 Alan Stern 8 * Copyright (C) 2003-2005 Alan Stern
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15 11
@@ -23,6 +19,8 @@
23 * 19 *
24 * Having this all in one kernel can help some stages of development, 20 * Having this all in one kernel can help some stages of development,
25 * bypassing some hardware (and driver) issues. UML could help too. 21 * bypassing some hardware (and driver) issues. UML could help too.
22 *
23 * Note: The emulation does not include isochronous transfers!
26 */ 24 */
27 25
28#include <linux/module.h> 26#include <linux/module.h>
@@ -137,6 +135,9 @@ static const struct {
137 .caps = _caps, \ 135 .caps = _caps, \
138 } 136 }
139 137
138/* we don't provide isochronous endpoints since we don't support them */
139#define TYPE_BULK_OR_INT (USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT)
140
140 /* everyone has ep0 */ 141 /* everyone has ep0 */
141 EP_INFO(ep0name, 142 EP_INFO(ep0name,
142 USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), 143 USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)),
@@ -145,64 +146,72 @@ static const struct {
145 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), 146 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)),
146 EP_INFO("ep2out-bulk", 147 EP_INFO("ep2out-bulk",
147 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), 148 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)),
149/*
148 EP_INFO("ep3in-iso", 150 EP_INFO("ep3in-iso",
149 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), 151 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)),
150 EP_INFO("ep4out-iso", 152 EP_INFO("ep4out-iso",
151 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), 153 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)),
154*/
152 EP_INFO("ep5in-int", 155 EP_INFO("ep5in-int",
153 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), 156 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)),
154 EP_INFO("ep6in-bulk", 157 EP_INFO("ep6in-bulk",
155 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), 158 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)),
156 EP_INFO("ep7out-bulk", 159 EP_INFO("ep7out-bulk",
157 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), 160 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)),
161/*
158 EP_INFO("ep8in-iso", 162 EP_INFO("ep8in-iso",
159 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), 163 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)),
160 EP_INFO("ep9out-iso", 164 EP_INFO("ep9out-iso",
161 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), 165 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)),
166*/
162 EP_INFO("ep10in-int", 167 EP_INFO("ep10in-int",
163 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), 168 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)),
164 EP_INFO("ep11in-bulk", 169 EP_INFO("ep11in-bulk",
165 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), 170 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)),
166 EP_INFO("ep12out-bulk", 171 EP_INFO("ep12out-bulk",
167 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), 172 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)),
173/*
168 EP_INFO("ep13in-iso", 174 EP_INFO("ep13in-iso",
169 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), 175 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)),
170 EP_INFO("ep14out-iso", 176 EP_INFO("ep14out-iso",
171 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), 177 USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)),
178*/
172 EP_INFO("ep15in-int", 179 EP_INFO("ep15in-int",
173 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), 180 USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)),
181
174 /* or like sa1100: two fixed function endpoints */ 182 /* or like sa1100: two fixed function endpoints */
175 EP_INFO("ep1out-bulk", 183 EP_INFO("ep1out-bulk",
176 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), 184 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)),
177 EP_INFO("ep2in-bulk", 185 EP_INFO("ep2in-bulk",
178 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), 186 USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)),
187
179 /* and now some generic EPs so we have enough in multi config */ 188 /* and now some generic EPs so we have enough in multi config */
180 EP_INFO("ep3out", 189 EP_INFO("ep3out",
181 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 190 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
182 EP_INFO("ep4in", 191 EP_INFO("ep4in",
183 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), 192 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)),
184 EP_INFO("ep5out", 193 EP_INFO("ep5out",
185 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 194 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
186 EP_INFO("ep6out", 195 EP_INFO("ep6out",
187 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 196 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
188 EP_INFO("ep7in", 197 EP_INFO("ep7in",
189 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), 198 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)),
190 EP_INFO("ep8out", 199 EP_INFO("ep8out",
191 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 200 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
192 EP_INFO("ep9in", 201 EP_INFO("ep9in",
193 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), 202 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)),
194 EP_INFO("ep10out", 203 EP_INFO("ep10out",
195 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 204 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
196 EP_INFO("ep11out", 205 EP_INFO("ep11out",
197 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 206 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
198 EP_INFO("ep12in", 207 EP_INFO("ep12in",
199 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), 208 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)),
200 EP_INFO("ep13out", 209 EP_INFO("ep13out",
201 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 210 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
202 EP_INFO("ep14in", 211 EP_INFO("ep14in",
203 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), 212 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_IN)),
204 EP_INFO("ep15out", 213 EP_INFO("ep15out",
205 USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), 214 USB_EP_CAPS(TYPE_BULK_OR_INT, USB_EP_CAPS_DIR_OUT)),
206 215
207#undef EP_INFO 216#undef EP_INFO
208}; 217};
@@ -556,10 +565,12 @@ static int dummy_enable(struct usb_ep *_ep,
556 if (max <= 1024) 565 if (max <= 1024)
557 break; 566 break;
558 /* save a return statement */ 567 /* save a return statement */
568 /* fall through */
559 case USB_SPEED_FULL: 569 case USB_SPEED_FULL:
560 if (max <= 64) 570 if (max <= 64)
561 break; 571 break;
562 /* save a return statement */ 572 /* save a return statement */
573 /* fall through */
563 default: 574 default:
564 if (max <= 8) 575 if (max <= 8)
565 break; 576 break;
@@ -577,6 +588,7 @@ static int dummy_enable(struct usb_ep *_ep,
577 if (max <= 1024) 588 if (max <= 1024)
578 break; 589 break;
579 /* save a return statement */ 590 /* save a return statement */
591 /* fall through */
580 case USB_SPEED_FULL: 592 case USB_SPEED_FULL:
581 if (max <= 1023) 593 if (max <= 1023)
582 break; 594 break;
@@ -1769,6 +1781,7 @@ static void dummy_timer(unsigned long _dum_hcd)
1769 int i; 1781 int i;
1770 1782
1771 /* simplistic model for one frame's bandwidth */ 1783 /* simplistic model for one frame's bandwidth */
1784 /* FIXME: account for transaction and packet overhead */
1772 switch (dum->gadget.speed) { 1785 switch (dum->gadget.speed) {
1773 case USB_SPEED_LOW: 1786 case USB_SPEED_LOW:
1774 total = 8/*bytes*/ * 12/*packets*/; 1787 total = 8/*bytes*/ * 12/*packets*/;
@@ -1813,7 +1826,6 @@ restart:
1813 struct dummy_request *req; 1826 struct dummy_request *req;
1814 u8 address; 1827 u8 address;
1815 struct dummy_ep *ep = NULL; 1828 struct dummy_ep *ep = NULL;
1816 int type;
1817 int status = -EINPROGRESS; 1829 int status = -EINPROGRESS;
1818 1830
1819 /* stop when we reach URBs queued after the timer interrupt */ 1831 /* stop when we reach URBs queued after the timer interrupt */
@@ -1825,14 +1837,10 @@ restart:
1825 goto return_urb; 1837 goto return_urb;
1826 else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) 1838 else if (dum_hcd->rh_state != DUMMY_RH_RUNNING)
1827 continue; 1839 continue;
1828 type = usb_pipetype(urb->pipe);
1829 1840
1830 /* used up this frame's non-periodic bandwidth? 1841 /* Used up this frame's bandwidth? */
1831 * FIXME there's infinite bandwidth for control and 1842 if (total <= 0)
1832 * periodic transfers ... unrealistic. 1843 break;
1833 */
1834 if (total <= 0 && type == PIPE_BULK)
1835 continue;
1836 1844
1837 /* find the gadget's ep for this request (if configured) */ 1845 /* find the gadget's ep for this request (if configured) */
1838 address = usb_pipeendpoint (urb->pipe); 1846 address = usb_pipeendpoint (urb->pipe);
@@ -1930,13 +1938,17 @@ restart:
1930 limit = total; 1938 limit = total;
1931 switch (usb_pipetype(urb->pipe)) { 1939 switch (usb_pipetype(urb->pipe)) {
1932 case PIPE_ISOCHRONOUS: 1940 case PIPE_ISOCHRONOUS:
1933 /* FIXME is it urb->interval since the last xfer? 1941 /*
1934 * use urb->iso_frame_desc[i]. 1942 * We don't support isochronous. But if we did,
1935 * complete whether or not ep has requests queued. 1943 * here are some of the issues we'd have to face:
1936 * report random errors, to debug drivers. 1944 *
1945 * Is it urb->interval since the last xfer?
1946 * Use urb->iso_frame_desc[i].
1947 * Complete whether or not ep has requests queued.
1948 * Report random errors, to debug drivers.
1937 */ 1949 */
1938 limit = max(limit, periodic_bytes(dum, ep)); 1950 limit = max(limit, periodic_bytes(dum, ep));
1939 status = -ENOSYS; 1951 status = -EINVAL; /* fail all xfers */
1940 break; 1952 break;
1941 1953
1942 case PIPE_INTERRUPT: 1954 case PIPE_INTERRUPT:
@@ -2433,9 +2445,7 @@ static DEVICE_ATTR_RO(urbs);
2433 2445
2434static int dummy_start_ss(struct dummy_hcd *dum_hcd) 2446static int dummy_start_ss(struct dummy_hcd *dum_hcd)
2435{ 2447{
2436 init_timer(&dum_hcd->timer); 2448 setup_timer(&dum_hcd->timer, dummy_timer, (unsigned long)dum_hcd);
2437 dum_hcd->timer.function = dummy_timer;
2438 dum_hcd->timer.data = (unsigned long)dum_hcd;
2439 dum_hcd->rh_state = DUMMY_RH_RUNNING; 2449 dum_hcd->rh_state = DUMMY_RH_RUNNING;
2440 dum_hcd->stream_en_ep = 0; 2450 dum_hcd->stream_en_ep = 0;
2441 INIT_LIST_HEAD(&dum_hcd->urbp_list); 2451 INIT_LIST_HEAD(&dum_hcd->urbp_list);
@@ -2464,9 +2474,7 @@ static int dummy_start(struct usb_hcd *hcd)
2464 return dummy_start_ss(dum_hcd); 2474 return dummy_start_ss(dum_hcd);
2465 2475
2466 spin_lock_init(&dum_hcd->dum->lock); 2476 spin_lock_init(&dum_hcd->dum->lock);
2467 init_timer(&dum_hcd->timer); 2477 setup_timer(&dum_hcd->timer, dummy_timer, (unsigned long)dum_hcd);
2468 dum_hcd->timer.function = dummy_timer;
2469 dum_hcd->timer.data = (unsigned long)dum_hcd;
2470 dum_hcd->rh_state = DUMMY_RH_RUNNING; 2478 dum_hcd->rh_state = DUMMY_RH_RUNNING;
2471 2479
2472 INIT_LIST_HEAD(&dum_hcd->urbp_list); 2480 INIT_LIST_HEAD(&dum_hcd->urbp_list);
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
index 78d0204e3e20..53a48f561458 100644
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ b/drivers/usb/gadget/udc/fotg210-udc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * FOTG210 UDC Driver supports Bulk transfer so far 3 * FOTG210 UDC Driver supports Bulk transfer so far
3 * 4 *
4 * Copyright (C) 2013 Faraday Technology Corporation 5 * Copyright (C) 2013 Faraday Technology Corporation
5 * 6 *
6 * Author : Yuan-Hsin Chen <yhchen@faraday-tech.com> 7 * Author : Yuan-Hsin Chen <yhchen@faraday-tech.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
diff --git a/drivers/usb/gadget/udc/fotg210.h b/drivers/usb/gadget/udc/fotg210.h
index bbf991bcbe7c..08c32957503b 100644
--- a/drivers/usb/gadget/udc/fotg210.h
+++ b/drivers/usb/gadget/udc/fotg210.h
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Faraday FOTG210 USB OTG controller 3 * Faraday FOTG210 USB OTG controller
3 * 4 *
4 * Copyright (C) 2013 Faraday Technology Corporation 5 * Copyright (C) 2013 Faraday Technology Corporation
5 * Author: Yuan-Hsin Chen <yhchen@faraday-tech.com> 6 * Author: Yuan-Hsin Chen <yhchen@faraday-tech.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/udc/fsl_mxc_udc.c b/drivers/usb/gadget/udc/fsl_mxc_udc.c
index f16e149c5b3e..f29cf5c6160c 100644
--- a/drivers/usb/gadget/udc/fsl_mxc_udc.c
+++ b/drivers/usb/gadget/udc/fsl_mxc_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2009 3 * Copyright (C) 2009
3 * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> 4 * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
@@ -5,11 +6,6 @@
5 * Description: 6 * Description:
6 * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c 7 * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c
7 * driver to function correctly on these systems. 8 * driver to function correctly on these systems.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */ 9 */
14#include <linux/clk.h> 10#include <linux/clk.h>
15#include <linux/delay.h> 11#include <linux/delay.h>
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
index a3e72d690eef..2707be628298 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * driver/usb/gadget/fsl_qe_udc.c 3 * driver/usb/gadget/fsl_qe_udc.c
3 * 4 *
@@ -11,11 +12,6 @@
11 * Freescle QE/CPM USB Pheripheral Controller Driver 12 * Freescle QE/CPM USB Pheripheral Controller Driver
12 * The controller can be found on MPC8360, MPC8272, and etc. 13 * The controller can be found on MPC8360, MPC8272, and etc.
13 * MPC8360 Rev 1.1 may need QE mircocode update 14 * MPC8360 Rev 1.1 may need QE mircocode update
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */ 15 */
20 16
21#undef USB_TRACE 17#undef USB_TRACE
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.h b/drivers/usb/gadget/udc/fsl_qe_udc.h
index 7026919fc901..2c537a904ee7 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.h
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * drivers/usb/gadget/qe_udc.h 3 * drivers/usb/gadget/qe_udc.h
3 * 4 *
@@ -8,11 +9,6 @@
8 * 9 *
9 * Description: 10 * Description:
10 * Freescale USB device/endpoint management registers 11 * Freescale USB device/endpoint management registers
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 */ 12 */
17 13
18#ifndef __FSL_QE_UDC_H 14#ifndef __FSL_QE_UDC_H
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 6f2f71c054be..d606d4f13098 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2004-2007,2011-2012 Freescale Semiconductor, Inc. 3 * Copyright (C) 2004-2007,2011-2012 Freescale Semiconductor, Inc.
3 * All rights reserved. 4 * All rights reserved.
@@ -10,11 +11,6 @@
10 * This can be found on MPC8349E/MPC8313E/MPC5121E cpus. 11 * This can be found on MPC8349E/MPC8313E/MPC5121E cpus.
11 * The driver is previously named as mpc_udc. Based on bare board 12 * The driver is previously named as mpc_udc. Based on bare board
12 * code from Dave Liu and Shlomi Gridish. 13 * code from Dave Liu and Shlomi Gridish.
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
18 */ 14 */
19 15
20#undef VERBOSE 16#undef VERBOSE
diff --git a/drivers/usb/gadget/udc/fsl_usb2_udc.h b/drivers/usb/gadget/udc/fsl_usb2_udc.h
index e92b8408b6f6..4ba651ae9048 100644
--- a/drivers/usb/gadget/udc/fsl_usb2_udc.h
+++ b/drivers/usb/gadget/udc/fsl_usb2_udc.h
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2004,2012 Freescale Semiconductor, Inc 3 * Copyright (C) 2004,2012 Freescale Semiconductor, Inc
3 * All rights reserved. 4 * All rights reserved.
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * Freescale USB device/endpoint management registers 6 * Freescale USB device/endpoint management registers
11 */ 7 */
12#ifndef __FSL_USB2_UDC_H 8#ifndef __FSL_USB2_UDC_H
diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
index e0c1b0099265..263804d154a7 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Fusb300 UDC (USB gadget) 3 * Fusb300 UDC (USB gadget)
3 * 4 *
4 * Copyright (C) 2010 Faraday Technology Corp. 5 * Copyright (C) 2010 Faraday Technology Corp.
5 * 6 *
6 * Author : Yuan-hsin Chen <yhchen@faraday-tech.com> 7 * Author : Yuan-hsin Chen <yhchen@faraday-tech.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
13#include <linux/err.h> 10#include <linux/err.h>
diff --git a/drivers/usb/gadget/udc/fusb300_udc.h b/drivers/usb/gadget/udc/fusb300_udc.h
index ad39f892d200..eb3d6d379ba7 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.h
+++ b/drivers/usb/gadget/udc/fusb300_udc.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Fusb300 UDC (USB gadget) 3 * Fusb300 UDC (USB gadget)
3 * 4 *
4 * Copyright (C) 2010 Faraday Technology Corp. 5 * Copyright (C) 2010 Faraday Technology Corp.
5 * 6 *
6 * Author : Yuan-hsin Chen <yhchen@faraday-tech.com> 7 * Author : Yuan-hsin Chen <yhchen@faraday-tech.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13 10
diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index 8433c22900dc..4504d0b202db 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Toshiba TC86C001 ("Goku-S") USB Device Controller driver 3 * Toshiba TC86C001 ("Goku-S") USB Device Controller driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * by Stuart Lynne, Tom Rushworth, and Bruce Balden 6 * by Stuart Lynne, Tom Rushworth, and Bruce Balden
6 * Copyright (C) 2002 Toshiba Corporation 7 * Copyright (C) 2002 Toshiba Corporation
7 * Copyright (C) 2003 MontaVista Software (source@mvista.com) 8 * Copyright (C) 2003 MontaVista Software (source@mvista.com)
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */ 9 */
13 10
14/* 11/*
@@ -127,11 +124,15 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
127 mode = 0; 124 mode = 0;
128 max = get_unaligned_le16(&desc->wMaxPacketSize); 125 max = get_unaligned_le16(&desc->wMaxPacketSize);
129 switch (max) { 126 switch (max) {
130 case 64: mode++; 127 case 64:
131 case 32: mode++; 128 mode++; /* fall through */
132 case 16: mode++; 129 case 32:
133 case 8: mode <<= 3; 130 mode++; /* fall through */
134 break; 131 case 16:
132 mode++; /* fall through */
133 case 8:
134 mode <<= 3;
135 break;
135 default: 136 default:
136 return -EINVAL; 137 return -EINVAL;
137 } 138 }
diff --git a/drivers/usb/gadget/udc/goku_udc.h b/drivers/usb/gadget/udc/goku_udc.h
index 86d2adafe149..26601bf4e7a9 100644
--- a/drivers/usb/gadget/udc/goku_udc.h
+++ b/drivers/usb/gadget/udc/goku_udc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Toshiba TC86C001 ("Goku-S") USB Device Controller driver 3 * Toshiba TC86C001 ("Goku-S") USB Device Controller driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * by Stuart Lynne, Tom Rushworth, and Bruce Balden 6 * by Stuart Lynne, Tom Rushworth, and Bruce Balden
6 * Copyright (C) 2002 Toshiba Corporation 7 * Copyright (C) 2002 Toshiba Corporation
7 * Copyright (C) 2003 MontaVista Software (source@mvista.com) 8 * Copyright (C) 2003 MontaVista Software (source@mvista.com)
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */ 9 */
13 10
14/* 11/*
diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 0b59fa50aa30..b3fb1bbdb854 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Peripheral Controller driver for Aeroflex Gaisler GRUSBDC. 3 * USB Peripheral Controller driver for Aeroflex Gaisler GRUSBDC.
3 * 4 *
@@ -9,11 +10,6 @@
9 * Full documentation of the GRUSBDC core can be found here: 10 * Full documentation of the GRUSBDC core can be found here:
10 * http://www.gaisler.com/products/grlib/grip.pdf 11 * http://www.gaisler.com/products/grlib/grip.pdf
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * Contributors: 13 * Contributors:
18 * - Andreas Larsson <andreas@gaisler.com> 14 * - Andreas Larsson <andreas@gaisler.com>
19 * - Marko Isomaki 15 * - Marko Isomaki
@@ -1538,7 +1534,7 @@ static int gr_ep_enable(struct usb_ep *_ep,
1538 * Bits 10-0 set the max payload. 12-11 set the number of 1534 * Bits 10-0 set the max payload. 12-11 set the number of
1539 * additional transactions. 1535 * additional transactions.
1540 */ 1536 */
1541 max = 0x7ff & usb_endpoint_maxp(desc); 1537 max = usb_endpoint_maxp(desc);
1542 nt = usb_endpoint_maxp_mult(desc) - 1; 1538 nt = usb_endpoint_maxp_mult(desc) - 1;
1543 buffer_size = GR_BUFFER_SIZE(epctrl); 1539 buffer_size = GR_BUFFER_SIZE(epctrl);
1544 if (nt && (mode == 0 || mode == 2)) { 1540 if (nt && (mode == 0 || mode == 2)) {
diff --git a/drivers/usb/gadget/udc/gr_udc.h b/drivers/usb/gadget/udc/gr_udc.h
index 4297c4e8021f..3e913268c8c5 100644
--- a/drivers/usb/gadget/udc/gr_udc.h
+++ b/drivers/usb/gadget/udc/gr_udc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Peripheral Controller driver for Aeroflex Gaisler GRUSBDC. 3 * USB Peripheral Controller driver for Aeroflex Gaisler GRUSBDC.
3 * 4 *
@@ -9,11 +10,6 @@
9 * Full documentation of the GRUSBDC core can be found here: 10 * Full documentation of the GRUSBDC core can be found here:
10 * http://www.gaisler.com/products/grlib/grip.pdf 11 * http://www.gaisler.com/products/grlib/grip.pdf
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * Contributors: 13 * Contributors:
18 * - Andreas Larsson <andreas@gaisler.com> 14 * - Andreas Larsson <andreas@gaisler.com>
19 * - Marko Isomaki 15 * - Marko Isomaki
diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
index 8f32b5ee7734..b0781771704e 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Gadget driver for LPC32xx 3 * USB Gadget driver for LPC32xx
3 * 4 *
@@ -12,20 +13,6 @@
12 * 13 *
13 * Note: This driver is based on original work done by Mike James for 14 * Note: This driver is based on original work done by Mike James for
14 * the LPC3180. 15 * the LPC3180.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */ 16 */
30 17
31#include <linux/clk.h> 18#include <linux/clk.h>
diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c
index 46ce7bc15f2b..f19e6282a688 100644
--- a/drivers/usb/gadget/udc/m66592-udc.c
+++ b/drivers/usb/gadget/udc/m66592-udc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * M66592 UDC (USB gadget) 3 * M66592 UDC (USB gadget)
3 * 4 *
4 * Copyright (C) 2006-2007 Renesas Solutions Corp. 5 * Copyright (C) 2006-2007 Renesas Solutions Corp.
5 * 6 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 7 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13#include <linux/module.h> 10#include <linux/module.h>
@@ -1592,9 +1589,7 @@ static int m66592_probe(struct platform_device *pdev)
1592 m66592->gadget.max_speed = USB_SPEED_HIGH; 1589 m66592->gadget.max_speed = USB_SPEED_HIGH;
1593 m66592->gadget.name = udc_name; 1590 m66592->gadget.name = udc_name;
1594 1591
1595 init_timer(&m66592->timer); 1592 setup_timer(&m66592->timer, m66592_timer, (unsigned long)m66592);
1596 m66592->timer.function = m66592_timer;
1597 m66592->timer.data = (unsigned long)m66592;
1598 m66592->reg = reg; 1593 m66592->reg = reg;
1599 1594
1600 ret = request_irq(ires->start, m66592_irq, IRQF_SHARED, 1595 ret = request_irq(ires->start, m66592_irq, IRQF_SHARED,
diff --git a/drivers/usb/gadget/udc/m66592-udc.h b/drivers/usb/gadget/udc/m66592-udc.h
index 96d49d7bfb6b..01a64685b8a3 100644
--- a/drivers/usb/gadget/udc/m66592-udc.h
+++ b/drivers/usb/gadget/udc/m66592-udc.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * M66592 UDC (USB gadget) 3 * M66592 UDC (USB gadget)
3 * 4 *
4 * Copyright (C) 2006-2007 Renesas Solutions Corp. 5 * Copyright (C) 2006-2007 Renesas Solutions Corp.
5 * 6 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 7 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13#ifndef __M66592_UDC_H__ 10#ifndef __M66592_UDC_H__
diff --git a/drivers/usb/gadget/udc/mv_u3d.h b/drivers/usb/gadget/udc/mv_u3d.h
index e32a787ac373..982625b7197a 100644
--- a/drivers/usb/gadget/udc/mv_u3d.h
+++ b/drivers/usb/gadget/udc/mv_u3d.h
@@ -1,9 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 */ 4 */
8 5
9#ifndef __MV_U3D_H 6#ifndef __MV_U3D_H
diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
index 772049afe166..35e02a8d0091 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -1,9 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 */ 4 */
8 5
9#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
index be77f207dbaf..b3f759c0962c 100644
--- a/drivers/usb/gadget/udc/mv_udc.h
+++ b/drivers/usb/gadget/udc/mv_udc.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */ 4 */
9 5
10#ifndef __MV_UDC_H 6#ifndef __MV_UDC_H
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 4103bf7cf52a..95f52232493b 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 * Author: Chao Xie <chao.xie@marvell.com> 4 * Author: Chao Xie <chao.xie@marvell.com>
4 * Neil Zhang <zhangwm@marvell.com> 5 * Neil Zhang <zhangwm@marvell.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */ 6 */
11 7
12#include <linux/module.h> 8#include <linux/module.h>
diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 8f85a51bd2b3..660878a19505 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for PLX NET2272 USB device controller 3 * Driver for PLX NET2272 USB device controller
3 * 4 *
4 * Copyright (C) 2005-2006 PLX Technology, Inc. 5 * Copyright (C) 2005-2006 PLX Technology, Inc.
5 * Copyright (C) 2006-2011 Analog Devices, Inc. 6 * Copyright (C) 2006-2011 Analog Devices, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 7 */
21 8
22#include <linux/delay.h> 9#include <linux/delay.h>
diff --git a/drivers/usb/gadget/udc/net2272.h b/drivers/usb/gadget/udc/net2272.h
index 69bc9c3c6ce4..8e644627992d 100644
--- a/drivers/usb/gadget/udc/net2272.h
+++ b/drivers/usb/gadget/udc/net2272.h
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * PLX NET2272 high/full speed USB device controller 3 * PLX NET2272 high/full speed USB device controller
3 * 4 *
4 * Copyright (C) 2005-2006 PLX Technology, Inc. 5 * Copyright (C) 2005-2006 PLX Technology, Inc.
5 * Copyright (C) 2006-2011 Analog Devices, Inc. 6 * Copyright (C) 2006-2011 Analog Devices, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 7 */
21 8
22#ifndef __NET2272_H__ 9#ifndef __NET2272_H__
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index f608c1f85e61..318246d8b2e2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for the PLX NET2280 USB device controller. 3 * Driver for the PLX NET2280 USB device controller.
3 * Specs and errata are available from <http://www.plxtech.com>. 4 * Specs and errata are available from <http://www.plxtech.com>.
@@ -31,11 +32,6 @@
31 * 32 *
32 * Modified Ricardo Ribalda Qtechnology AS to provide compatibility 33 * Modified Ricardo Ribalda Qtechnology AS to provide compatibility
33 * with usb 338x chip. Based on PLX driver 34 * with usb 338x chip. Based on PLX driver
34 *
35 * This program is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version.
39 */ 35 */
40 36
41#include <linux/module.h> 37#include <linux/module.h>
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index 1088c3745999..b65a797544d7 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * NetChip 2280 high/full speed USB device controller. 3 * NetChip 2280 high/full speed USB device controller.
3 * Unlike many such controllers, this one talks PCI. 4 * Unlike many such controllers, this one talks PCI.
@@ -7,11 +8,6 @@
7 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com) 8 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
8 * Copyright (C) 2003 David Brownell 9 * Copyright (C) 2003 David Brownell
9 * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS 10 * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */ 11 */
16 12
17#include <linux/usb/net2280.h> 13#include <linux/usb/net2280.h>
diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c
index f05ba6825bfe..fc7f810baef7 100644
--- a/drivers/usb/gadget/udc/omap_udc.c
+++ b/drivers/usb/gadget/udc/omap_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * omap_udc.c -- for OMAP full speed udc; most chips support OTG. 3 * omap_udc.c -- for OMAP full speed udc; most chips support OTG.
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 2004-2005 David Brownell 6 * Copyright (C) 2004-2005 David Brownell
6 * 7 *
7 * OMAP2 & DMA support by Kyungmin Park <kyungmin.park@samsung.com> 8 * OMAP2 & DMA support by Kyungmin Park <kyungmin.park@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15#undef DEBUG 11#undef DEBUG
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 84dcbcd756f0..afaea11ec771 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1,9 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. 3 * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 */ 4 */
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 5#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9#include <linux/kernel.h> 6#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index a238da906115..8f135d9fa245 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Intel PXA25x and IXP4xx on-chip full speed USB device controllers 3 * Intel PXA25x and IXP4xx on-chip full speed USB device controllers
3 * 4 *
@@ -6,11 +7,6 @@
6 * Copyright (C) 2003 Benedikt Spranger, Pengutronix 7 * Copyright (C) 2003 Benedikt Spranger, Pengutronix
7 * Copyright (C) 2003 David Brownell 8 * Copyright (C) 2003 David Brownell
8 * Copyright (C) 2003 Joshua Wise 9 * Copyright (C) 2003 Joshua Wise
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */ 10 */
15 11
16/* #define VERBOSE_DEBUG */ 12/* #define VERBOSE_DEBUG */
@@ -2417,9 +2413,7 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
2417 gpio_direction_output(dev->mach->gpio_pullup, 0); 2413 gpio_direction_output(dev->mach->gpio_pullup, 0);
2418 } 2414 }
2419 2415
2420 init_timer(&dev->timer); 2416 setup_timer(&dev->timer, udc_watchdog, (unsigned long)dev);
2421 dev->timer.function = udc_watchdog;
2422 dev->timer.data = (unsigned long) dev;
2423 2417
2424 the_controller = dev; 2418 the_controller = dev;
2425 platform_set_drvdata(pdev, dev); 2419 platform_set_drvdata(pdev, dev);
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.h b/drivers/usb/gadget/udc/pxa25x_udc.h
index a458bec2536d..ccc6b921f067 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.h
+++ b/drivers/usb/gadget/udc/pxa25x_udc.h
@@ -1,14 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Intel PXA25x on-chip full speed USB device controller 3 * Intel PXA25x on-chip full speed USB device controller
3 * 4 *
4 * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix 5 * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
5 * Copyright (C) 2003 David Brownell 6 * Copyright (C) 2003 David Brownell
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 7 */
13 8
14#ifndef __LINUX_USB_GADGET_PXA25X_H 9#ifndef __LINUX_USB_GADGET_PXA25X_H
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index d48e239660c3..be2761f1b3f5 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Handles the Intel 27x USB Device Controller (UDC) 3 * Handles the Intel 27x USB Device Controller (UDC)
3 * 4 *
4 * Inspired by original driver by Frank Becker, David Brownell, and others. 5 * Inspired by original driver by Frank Becker, David Brownell, and others.
5 * Copyright (C) 2008 Robert Jarzmik 6 * Copyright (C) 2008 Robert Jarzmik
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12#include <linux/module.h> 8#include <linux/module.h>
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h
index cea2cb79b30c..1128d39a4255 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.h
+++ b/drivers/usb/gadget/udc/pxa27x_udc.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * linux/drivers/usb/gadget/pxa27x_udc.h 3 * linux/drivers/usb/gadget/pxa27x_udc.h
3 * Intel PXA27x on-chip full speed USB device controller 4 * Intel PXA27x on-chip full speed USB device controller
4 * 5 *
5 * Inspired by original driver by Frank Becker, David Brownell, and others. 6 * Inspired by original driver by Frank Becker, David Brownell, and others.
6 * Copyright (C) 2008 Robert Jarzmik 7 * Copyright (C) 2008 Robert Jarzmik
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#ifndef __LINUX_USB_GADGET_PXA27X_H 10#ifndef __LINUX_USB_GADGET_PXA27X_H
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 118ad70f1af0..143122ed3c66 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * R8A66597 UDC (USB gadget) 3 * R8A66597 UDC (USB gadget)
3 * 4 *
4 * Copyright (C) 2006-2009 Renesas Solutions Corp. 5 * Copyright (C) 2006-2009 Renesas Solutions Corp.
5 * 6 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 7 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13#include <linux/module.h> 10#include <linux/module.h>
@@ -1877,9 +1874,7 @@ static int r8a66597_probe(struct platform_device *pdev)
1877 r8a66597->gadget.max_speed = USB_SPEED_HIGH; 1874 r8a66597->gadget.max_speed = USB_SPEED_HIGH;
1878 r8a66597->gadget.name = udc_name; 1875 r8a66597->gadget.name = udc_name;
1879 1876
1880 init_timer(&r8a66597->timer); 1877 setup_timer(&r8a66597->timer, r8a66597_timer, (unsigned long)r8a66597);
1881 r8a66597->timer.function = r8a66597_timer;
1882 r8a66597->timer.data = (unsigned long)r8a66597;
1883 r8a66597->reg = reg; 1878 r8a66597->reg = reg;
1884 1879
1885 if (r8a66597->pdata->on_chip) { 1880 if (r8a66597->pdata->on_chip) {
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.h b/drivers/usb/gadget/udc/r8a66597-udc.h
index 45c4b2df1785..9a115caba661 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.h
+++ b/drivers/usb/gadget/udc/r8a66597-udc.h
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * R8A66597 UDC 3 * R8A66597 UDC
3 * 4 *
4 * Copyright (C) 2007-2009 Renesas Solutions Corp. 5 * Copyright (C) 2007-2009 Renesas Solutions Corp.
5 * 6 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 7 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 */ 8 */
12 9
13#ifndef __R8A66597_H__ 10#ifndef __R8A66597_H__
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 63a206122058..bc37f40baacf 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1,22 +1,20 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Renesas USB3.0 Peripheral driver (USB gadget) 3 * Renesas USB3.0 Peripheral driver (USB gadget)
3 * 4 *
4 * Copyright (C) 2015 Renesas Electronics Corporation 5 * Copyright (C) 2015-2017 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 */ 6 */
10 7
11#include <linux/debugfs.h> 8#include <linux/debugfs.h>
12#include <linux/delay.h> 9#include <linux/delay.h>
13#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
14#include <linux/err.h> 11#include <linux/err.h>
15#include <linux/extcon.h> 12#include <linux/extcon-provider.h>
16#include <linux/interrupt.h> 13#include <linux/interrupt.h>
17#include <linux/io.h> 14#include <linux/io.h>
18#include <linux/module.h> 15#include <linux/module.h>
19#include <linux/of_device.h> 16#include <linux/of_device.h>
17#include <linux/phy/phy.h>
20#include <linux/platform_device.h> 18#include <linux/platform_device.h>
21#include <linux/pm_runtime.h> 19#include <linux/pm_runtime.h>
22#include <linux/sizes.h> 20#include <linux/sizes.h>
@@ -334,6 +332,7 @@ struct renesas_usb3 {
334 struct usb_gadget_driver *driver; 332 struct usb_gadget_driver *driver;
335 struct extcon_dev *extcon; 333 struct extcon_dev *extcon;
336 struct work_struct extcon_work; 334 struct work_struct extcon_work;
335 struct phy *phy;
337 336
338 struct renesas_usb3_ep *usb3_ep; 337 struct renesas_usb3_ep *usb3_ep;
339 int num_usb3_eps; 338 int num_usb3_eps;
@@ -2056,7 +2055,7 @@ static u32 usb3_calc_rammap_val(struct renesas_usb3_ep *usb3_ep,
2056 const struct usb_endpoint_descriptor *desc) 2055 const struct usb_endpoint_descriptor *desc)
2057{ 2056{
2058 int i; 2057 int i;
2059 const u32 max_packet_array[] = {8, 16, 32, 64, 512}; 2058 static const u32 max_packet_array[] = {8, 16, 32, 64, 512};
2060 u32 mpkt = PN_RAMMAP_MPKT(1024); 2059 u32 mpkt = PN_RAMMAP_MPKT(1024);
2061 2060
2062 for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) { 2061 for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) {
@@ -2239,7 +2238,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
2239 /* hook up the driver */ 2238 /* hook up the driver */
2240 usb3->driver = driver; 2239 usb3->driver = driver;
2241 2240
2242 pm_runtime_enable(usb3_to_dev(usb3)); 2241 if (usb3->phy)
2242 phy_init(usb3->phy);
2243
2243 pm_runtime_get_sync(usb3_to_dev(usb3)); 2244 pm_runtime_get_sync(usb3_to_dev(usb3));
2244 2245
2245 renesas_usb3_init_controller(usb3); 2246 renesas_usb3_init_controller(usb3);
@@ -2256,8 +2257,10 @@ static int renesas_usb3_stop(struct usb_gadget *gadget)
2256 usb3->driver = NULL; 2257 usb3->driver = NULL;
2257 renesas_usb3_stop_controller(usb3); 2258 renesas_usb3_stop_controller(usb3);
2258 2259
2260 if (usb3->phy)
2261 phy_exit(usb3->phy);
2262
2259 pm_runtime_put(usb3_to_dev(usb3)); 2263 pm_runtime_put(usb3_to_dev(usb3));
2260 pm_runtime_disable(usb3_to_dev(usb3));
2261 2264
2262 return 0; 2265 return 0;
2263} 2266}
@@ -2405,6 +2408,9 @@ static int renesas_usb3_remove(struct platform_device *pdev)
2405 renesas_usb3_dma_free_prd(usb3, &pdev->dev); 2408 renesas_usb3_dma_free_prd(usb3, &pdev->dev);
2406 2409
2407 __renesas_usb3_ep_free_request(usb3->ep0_req); 2410 __renesas_usb3_ep_free_request(usb3->ep0_req);
2411 if (usb3->phy)
2412 phy_put(usb3->phy);
2413 pm_runtime_disable(usb3_to_dev(usb3));
2408 2414
2409 return 0; 2415 return 0;
2410} 2416}
@@ -2560,20 +2566,15 @@ static int renesas_usb3_probe(struct platform_device *pdev)
2560{ 2566{
2561 struct renesas_usb3 *usb3; 2567 struct renesas_usb3 *usb3;
2562 struct resource *res; 2568 struct resource *res;
2563 const struct of_device_id *match;
2564 int irq, ret; 2569 int irq, ret;
2565 const struct renesas_usb3_priv *priv; 2570 const struct renesas_usb3_priv *priv;
2566 const struct soc_device_attribute *attr; 2571 const struct soc_device_attribute *attr;
2567 2572
2568 match = of_match_node(usb3_of_match, pdev->dev.of_node);
2569 if (!match)
2570 return -ENODEV;
2571
2572 attr = soc_device_match(renesas_usb3_quirks_match); 2573 attr = soc_device_match(renesas_usb3_quirks_match);
2573 if (attr) 2574 if (attr)
2574 priv = attr->data; 2575 priv = attr->data;
2575 else 2576 else
2576 priv = match->data; 2577 priv = of_device_get_match_data(&pdev->dev);
2577 2578
2578 irq = platform_get_irq(pdev, 0); 2579 irq = platform_get_irq(pdev, 0);
2579 if (irq < 0) { 2580 if (irq < 0) {
@@ -2635,11 +2636,20 @@ static int renesas_usb3_probe(struct platform_device *pdev)
2635 if (ret < 0) 2636 if (ret < 0)
2636 goto err_dev_create; 2637 goto err_dev_create;
2637 2638
2639 /*
2640 * This is an optional. So, if this driver cannot get a phy,
2641 * this driver will not handle a phy anymore.
2642 */
2643 usb3->phy = devm_phy_get(&pdev->dev, "usb");
2644 if (IS_ERR(usb3->phy))
2645 usb3->phy = NULL;
2646
2638 usb3->workaround_for_vbus = priv->workaround_for_vbus; 2647 usb3->workaround_for_vbus = priv->workaround_for_vbus;
2639 2648
2640 renesas_usb3_debugfs_init(usb3, &pdev->dev); 2649 renesas_usb3_debugfs_init(usb3, &pdev->dev);
2641 2650
2642 dev_info(&pdev->dev, "probed\n"); 2651 dev_info(&pdev->dev, "probed%s\n", usb3->phy ? " with phy" : "");
2652 pm_runtime_enable(usb3_to_dev(usb3));
2643 2653
2644 return 0; 2654 return 0;
2645 2655
@@ -2655,11 +2665,49 @@ err_alloc_prd:
2655 return ret; 2665 return ret;
2656} 2666}
2657 2667
2668#ifdef CONFIG_PM_SLEEP
2669static int renesas_usb3_suspend(struct device *dev)
2670{
2671 struct renesas_usb3 *usb3 = dev_get_drvdata(dev);
2672
2673 /* Not started */
2674 if (!usb3->driver)
2675 return 0;
2676
2677 renesas_usb3_stop_controller(usb3);
2678 if (usb3->phy)
2679 phy_exit(usb3->phy);
2680 pm_runtime_put(dev);
2681
2682 return 0;
2683}
2684
2685static int renesas_usb3_resume(struct device *dev)
2686{
2687 struct renesas_usb3 *usb3 = dev_get_drvdata(dev);
2688
2689 /* Not started */
2690 if (!usb3->driver)
2691 return 0;
2692
2693 if (usb3->phy)
2694 phy_init(usb3->phy);
2695 pm_runtime_get_sync(dev);
2696 renesas_usb3_init_controller(usb3);
2697
2698 return 0;
2699}
2700#endif
2701
2702static SIMPLE_DEV_PM_OPS(renesas_usb3_pm_ops, renesas_usb3_suspend,
2703 renesas_usb3_resume);
2704
2658static struct platform_driver renesas_usb3_driver = { 2705static struct platform_driver renesas_usb3_driver = {
2659 .probe = renesas_usb3_probe, 2706 .probe = renesas_usb3_probe,
2660 .remove = renesas_usb3_remove, 2707 .remove = renesas_usb3_remove,
2661 .driver = { 2708 .driver = {
2662 .name = (char *)udc_name, 2709 .name = (char *)udc_name,
2710 .pm = &renesas_usb3_pm_ops,
2663 .of_match_table = of_match_ptr(usb3_of_match), 2711 .of_match_table = of_match_ptr(usb3_of_match),
2664 }, 2712 },
2665}; 2713};
diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c
index 42587b738a1f..31c7c5587cf9 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* linux/drivers/usb/gadget/s3c-hsudc.c 2/* linux/drivers/usb/gadget/s3c-hsudc.c
2 * 3 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd. 4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
@@ -8,11 +9,7 @@
8 * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints. 9 * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints.
9 * Each endpoint can be configured as either in or out endpoint. Endpoints 10 * Each endpoint can be configured as either in or out endpoint. Endpoints
10 * can be configured for Bulk or Interrupt transfer mode. 11 * can be configured for Bulk or Interrupt transfer mode.
11 * 12 */
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15*/
16 13
17#include <linux/kernel.h> 14#include <linux/kernel.h>
18#include <linux/module.h> 15#include <linux/module.h>
diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index 394abd5d65c0..f154f49e98c8 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * linux/drivers/usb/gadget/s3c2410_udc.c 3 * linux/drivers/usb/gadget/s3c2410_udc.c
3 * 4 *
@@ -5,11 +6,6 @@
5 * 6 *
6 * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard 7 * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard
7 * Additional cleanups by Ben Dooks <ben-linux@fluff.org> 8 * Additional cleanups by Ben Dooks <ben-linux@fluff.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */ 9 */
14 10
15#define pr_fmt(fmt) "s3c2410_udc: " fmt 11#define pr_fmt(fmt) "s3c2410_udc: " fmt
diff --git a/drivers/usb/gadget/udc/s3c2410_udc.h b/drivers/usb/gadget/udc/s3c2410_udc.h
index 93bf225f1969..bdcaa8dd300f 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.h
+++ b/drivers/usb/gadget/udc/s3c2410_udc.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * linux/drivers/usb/gadget/s3c2410_udc.h 3 * linux/drivers/usb/gadget/s3c2410_udc.h
3 * Samsung on-chip full speed USB device controllers 4 * Samsung on-chip full speed USB device controllers
4 * 5 *
5 * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard 6 * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard
6 * Additional cleanups by Ben Dooks <ben-linux@fluff.org> 7 * Additional cleanups by Ben Dooks <ben-linux@fluff.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */ 8 */
13 9
14#ifndef _S3C2410_UDC_H 10#ifndef _S3C2410_UDC_H
diff --git a/drivers/usb/gadget/udc/snps_udc_core.c b/drivers/usb/gadget/udc/snps_udc_core.c
index 38a165dbf924..d4da47f4f6f4 100644
--- a/drivers/usb/gadget/udc/snps_udc_core.c
+++ b/drivers/usb/gadget/udc/snps_udc_core.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * amd5536.c -- AMD 5536 UDC high/full speed USB device controller 3 * amd5536.c -- AMD 5536 UDC high/full speed USB device controller
3 * 4 *
4 * Copyright (C) 2005-2007 AMD (http://www.amd.com) 5 * Copyright (C) 2005-2007 AMD (http://www.amd.com)
5 * Author: Thomas Dahlmann 6 * Author: Thomas Dahlmann
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13/* 9/*
@@ -1733,7 +1729,7 @@ static void udc_soft_reset(struct udc *dev)
1733} 1729}
1734 1730
1735/* RDE timer callback to set RDE bit */ 1731/* RDE timer callback to set RDE bit */
1736static void udc_timer_function(unsigned long v) 1732static void udc_timer_function(struct timer_list *unused)
1737{ 1733{
1738 u32 tmp; 1734 u32 tmp;
1739 1735
@@ -1813,7 +1809,7 @@ static void udc_handle_halt_state(struct udc_ep *ep)
1813} 1809}
1814 1810
1815/* Stall timer callback to poll S bit and set it again after */ 1811/* Stall timer callback to poll S bit and set it again after */
1816static void udc_pollstall_timer_function(unsigned long v) 1812static void udc_pollstall_timer_function(struct timer_list *unused)
1817{ 1813{
1818 struct udc_ep *ep; 1814 struct udc_ep *ep;
1819 int halted = 0; 1815 int halted = 0;
@@ -3067,14 +3063,12 @@ void udc_remove(struct udc *dev)
3067 stop_timer++; 3063 stop_timer++;
3068 if (timer_pending(&udc_timer)) 3064 if (timer_pending(&udc_timer))
3069 wait_for_completion(&on_exit); 3065 wait_for_completion(&on_exit);
3070 if (udc_timer.data) 3066 del_timer_sync(&udc_timer);
3071 del_timer_sync(&udc_timer);
3072 /* remove pollstall timer */ 3067 /* remove pollstall timer */
3073 stop_pollstall_timer++; 3068 stop_pollstall_timer++;
3074 if (timer_pending(&udc_pollstall_timer)) 3069 if (timer_pending(&udc_pollstall_timer))
3075 wait_for_completion(&on_pollstall_exit); 3070 wait_for_completion(&on_pollstall_exit);
3076 if (udc_pollstall_timer.data) 3071 del_timer_sync(&udc_pollstall_timer);
3077 del_timer_sync(&udc_pollstall_timer);
3078 udc = NULL; 3072 udc = NULL;
3079} 3073}
3080EXPORT_SYMBOL_GPL(udc_remove); 3074EXPORT_SYMBOL_GPL(udc_remove);
@@ -3164,10 +3158,6 @@ int udc_probe(struct udc *dev)
3164 u32 reg; 3158 u32 reg;
3165 int retval; 3159 int retval;
3166 3160
3167 /* mark timer as not initialized */
3168 udc_timer.data = 0;
3169 udc_pollstall_timer.data = 0;
3170
3171 /* device struct setup */ 3161 /* device struct setup */
3172 dev->gadget.ops = &udc_ops; 3162 dev->gadget.ops = &udc_ops;
3173 3163
@@ -3207,13 +3197,8 @@ int udc_probe(struct udc *dev)
3207 goto finished; 3197 goto finished;
3208 3198
3209 /* timer init */ 3199 /* timer init */
3210 init_timer(&udc_timer); 3200 timer_setup(&udc_timer, udc_timer_function, 0);
3211 udc_timer.function = udc_timer_function; 3201 timer_setup(&udc_pollstall_timer, udc_pollstall_timer_function, 0);
3212 udc_timer.data = 1;
3213 /* timer pollstall init */
3214 init_timer(&udc_pollstall_timer);
3215 udc_pollstall_timer.function = udc_pollstall_timer_function;
3216 udc_pollstall_timer.data = 1;
3217 3202
3218 /* set SD */ 3203 /* set SD */
3219 reg = readl(&dev->regs->ctl); 3204 reg = readl(&dev->regs->ctl);
diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
index e8a5fdaee37d..32f1d3e90c26 100644
--- a/drivers/usb/gadget/udc/snps_udc_plat.c
+++ b/drivers/usb/gadget/udc/snps_udc_plat.c
@@ -1,16 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * snps_udc_plat.c - Synopsys UDC Platform Driver 3 * snps_udc_plat.c - Synopsys UDC Platform Driver
3 * 4 *
4 * Copyright (C) 2016 Broadcom 5 * Copyright (C) 2016 Broadcom
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */ 6 */
15 7
16#include <linux/extcon.h> 8#include <linux/extcon.h>
diff --git a/drivers/usb/gadget/udc/trace.c b/drivers/usb/gadget/udc/trace.c
index 8c551ab91ad8..7430624c0bd7 100644
--- a/drivers/usb/gadget/udc/trace.c
+++ b/drivers/usb/gadget/udc/trace.c
@@ -1,17 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * trace.c - USB Gadget Framework Trace Support 3 * trace.c - USB Gadget Framework Trace Support
3 * 4 *
4 * Copyright (C) 2016 Intel Corporation 5 * Copyright (C) 2016 Intel Corporation
5 * Author: Felipe Balbi <felipe.balbi@linux.intel.com> 6 * Author: Felipe Balbi <felipe.balbi@linux.intel.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */ 7 */
16 8
17#define CREATE_TRACE_POINTS 9#define CREATE_TRACE_POINTS
diff --git a/drivers/usb/gadget/udc/trace.h b/drivers/usb/gadget/udc/trace.h
index da29874b5366..f07ddb3f4bb9 100644
--- a/drivers/usb/gadget/udc/trace.h
+++ b/drivers/usb/gadget/udc/trace.h
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * udc.c - Core UDC Framework 3 * udc.c - Core UDC Framework
3 * 4 *
4 * Copyright (C) 2016 Intel Corporation 5 * Copyright (C) 2016 Intel Corporation
5 * Author: Felipe Balbi <felipe.balbi@linux.intel.com> 6 * Author: Felipe Balbi <felipe.balbi@linux.intel.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19 8
20#undef TRACE_SYSTEM 9#undef TRACE_SYSTEM
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index de207a90571e..7da2b9ce8cb3 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Xilinx USB peripheral controller driver 3 * Xilinx USB peripheral controller driver
3 * 4 *
@@ -8,12 +9,6 @@
8 * 9 *
9 * Some parts of this driver code is based on the driver for at91-series 10 * Some parts of this driver code is based on the driver for at91-series
10 * USB peripheral controller (at91_udc.c). 11 * USB peripheral controller (at91_udc.c).
11 *
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation;
15 * either version 2 of the License, or (at your option) any
16 * later version.
17 */ 12 */
18 13
19#include <linux/delay.h> 14#include <linux/delay.h>
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index 73a4dfba0edb..566ab261e8b7 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: LGPL-2.1+
1/* 2/*
2 * Copyright (C) 2003 David Brownell 3 * Copyright (C) 2003 David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
8 */ 4 */
9 5
10#include <linux/errno.h> 6#include <linux/errno.h>
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index fa5692dec832..b80a94e632af 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -45,12 +45,12 @@ config USB_XHCI_PLATFORM
45 If unsure, say N. 45 If unsure, say N.
46 46
47config USB_XHCI_MTK 47config USB_XHCI_MTK
48 tristate "xHCI support for Mediatek MT65xx/MT7621" 48 tristate "xHCI support for MediaTek SoCs"
49 select MFD_SYSCON 49 select MFD_SYSCON
50 depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || COMPILE_TEST 50 depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || COMPILE_TEST
51 ---help--- 51 ---help---
52 Say 'Y' to enable the support for the xHCI host controller 52 Say 'Y' to enable the support for the xHCI host controller
53 found in Mediatek MT65xx SoCs. 53 found in MediaTek SoCs.
54 If unsure, say N. 54 If unsure, say N.
55 55
56config USB_XHCI_MVEBU 56config USB_XHCI_MVEBU
@@ -222,18 +222,6 @@ config USB_EHCI_HCD_AT91
222 Enables support for the on-chip EHCI controller on 222 Enables support for the on-chip EHCI controller on
223 Atmel chips. 223 Atmel chips.
224 224
225config USB_EHCI_MSM
226 tristate "Support for Qualcomm QSD/MSM on-chip EHCI USB controller"
227 depends on ARCH_QCOM
228 select USB_EHCI_ROOT_HUB_TT
229 ---help---
230 Enables support for the USB Host controller present on the
231 Qualcomm chipsets. Root Hub has inbuilt TT.
232 This driver depends on OTG driver for PHY initialization,
233 clock management, powering up VBUS, and power management.
234 This driver is not supported on boards like trout which
235 has an external PHY.
236
237config USB_EHCI_TEGRA 225config USB_EHCI_TEGRA
238 tristate "NVIDIA Tegra HCD support" 226 tristate "NVIDIA Tegra HCD support"
239 depends on ARCH_TEGRA 227 depends on ARCH_TEGRA
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 4ab2689c8952..32b036e2ffef 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -26,6 +26,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), )
26 xhci-plat-hcd-y += xhci-rcar.o 26 xhci-plat-hcd-y += xhci-rcar.o
27endif 27endif
28 28
29ifneq ($(CONFIG_DEBUG_FS),)
30 xhci-hcd-y += xhci-debugfs.o
31endif
32
29obj-$(CONFIG_USB_WHCI_HCD) += whci/ 33obj-$(CONFIG_USB_WHCI_HCD) += whci/
30 34
31obj-$(CONFIG_USB_PCI) += pci-quirks.o 35obj-$(CONFIG_USB_PCI) += pci-quirks.o
@@ -40,7 +44,6 @@ obj-$(CONFIG_USB_EHCI_HCD_SPEAR) += ehci-spear.o
40obj-$(CONFIG_USB_EHCI_HCD_STI) += ehci-st.o 44obj-$(CONFIG_USB_EHCI_HCD_STI) += ehci-st.o
41obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o 45obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
42obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o 46obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
43obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
44obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o 47obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o
45obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o 48obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o
46 49
diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index 5f425c89faf1..2400a826397a 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Broadcom specific Advanced Microcontroller Bus 3 * Broadcom specific Advanced Microcontroller Bus
3 * Broadcom USB-core driver (BCMA bus glue) 4 * Broadcom USB-core driver (BCMA bus glue)
@@ -16,8 +17,6 @@
16 * 17 *
17 * Derived from the USBcore related parts of Broadcom-SB 18 * Derived from the USBcore related parts of Broadcom-SB
18 * Copyright 2005-2011 Broadcom Corporation 19 * Copyright 2005-2011 Broadcom Corporation
19 *
20 * Licensed under the GNU/GPL. See COPYING for details.
21 */ 20 */
22#include <linux/bcma/bcma.h> 21#include <linux/bcma/bcma.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 7440722bfbf0..3ba140ceaf52 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for EHCI UHP on Atmel chips 3 * Driver for EHCI UHP on Atmel chips
3 * 4 *
@@ -5,10 +6,6 @@
5 * Nicolas Ferre <nicolas.ferre@atmel.com> 6 * Nicolas Ferre <nicolas.ferre@atmel.com>
6 * 7 *
7 * Based on various ehci-*.c drivers 8 * Based on various ehci-*.c drivers
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of this archive for
11 * more details.
12 */ 9 */
13 10
14#include <linux/clk.h> 11#include <linux/clk.h>
@@ -205,7 +202,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct device *dev)
205 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd); 202 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
206 203
207 atmel_start_clock(atmel_ehci); 204 atmel_start_clock(atmel_ehci);
208 return ehci_resume(hcd, false); 205 ehci_resume(hcd, false);
206 return 0;
209} 207}
210 208
211#ifdef CONFIG_OF 209#ifdef CONFIG_OF
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index cbb9b8e12c3c..19f00424f53e 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -1,16 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001-2002 by David Brownell 3 * Copyright (c) 2001-2002 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 */ 4 */
15 5
16/* this file is part of ehci-hcd.c */ 6/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 26b641100639..d9145a8f35d2 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * SAMSUNG EXYNOS USB HOST EHCI Controller 3 * SAMSUNG EXYNOS USB HOST EHCI Controller
3 * 4 *
4 * Copyright (C) 2011 Samsung Electronics Co.Ltd 5 * Copyright (C) 2011 Samsung Electronics Co.Ltd
5 * Author: Jingoo Han <jg1.han@samsung.com> 6 * Author: Jingoo Han <jg1.han@samsung.com>
6 * Author: Joonyoung Shim <jy0922.shim@samsung.com> 7 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */ 8 */
14 9
15#include <linux/clk.h> 10#include <linux/clk.h>
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index d025cc06dda7..c5094cb88cd5 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2005-2009 MontaVista Software, Inc. 3 * Copyright 2005-2009 MontaVista Software, Inc.
3 * Copyright 2008,2012,2015 Freescale Semiconductor, Inc. 4 * Copyright 2008,2012,2015 Freescale Semiconductor, Inc.
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * Ported to 834x by Randy Vinson <rvinson@mvista.com> using code provided 6 * Ported to 834x by Randy Vinson <rvinson@mvista.com> using code provided
20 * by Hunter Wu. 7 * by Hunter Wu.
21 * Power Management support by Dave Liu <daveliu@freescale.com>, 8 * Power Management support by Dave Liu <daveliu@freescale.com>,
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index 1a8a60a57cf2..cbc422032e50 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* Copyright (C) 2005-2010,2012 Freescale Semiconductor, Inc. 2/* Copyright (C) 2005-2010,2012 Freescale Semiconductor, Inc.
2 * Copyright (c) 2005 MontaVista Software 3 * Copyright (c) 2005 MontaVista Software
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18#ifndef _EHCI_FSL_H 5#ifndef _EHCI_FSL_H
19#define _EHCI_FSL_H 6#define _EHCI_FSL_H
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 21650044b09e..656b8c08efc8 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Aeroflex Gaisler GRLIB GRUSBHC EHCI host controller 3 * Driver for Aeroflex Gaisler GRLIB GRUSBHC EHCI host controller
3 * 4 *
@@ -9,20 +10,6 @@
9 * (c) Valentine Barshak <vbarshak@ru.mvista.com> 10 * (c) Valentine Barshak <vbarshak@ru.mvista.com>
10 * and in turn based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> 11 * and in turn based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de>
11 * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> 12 * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com>
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 13 */
27 14
28#include <linux/err.h> 15#include <linux/err.h>
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 6e834b83a104..7f0737449df7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Enhanced Host Controller Interface (EHCI) driver for USB. 3 * Enhanced Host Controller Interface (EHCI) driver for USB.
3 * 4 *
4 * Maintainer: Alan Stern <stern@rowland.harvard.edu> 5 * Maintainer: Alan Stern <stern@rowland.harvard.edu>
5 * 6 *
6 * Copyright (c) 2000-2004 by David Brownell 7 * Copyright (c) 2000-2004 by David Brownell
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 8 */
22 9
23#include <linux/module.h> 10#include <linux/module.h>
@@ -1012,7 +999,7 @@ idle_timeout:
1012 qh_destroy(ehci, qh); 999 qh_destroy(ehci, qh);
1013 break; 1000 break;
1014 } 1001 }
1015 /* else FALL THROUGH */ 1002 /* fall through */
1016 default: 1003 default:
1017 /* caller was supposed to have unlinked any requests; 1004 /* caller was supposed to have unlinked any requests;
1018 * that's not our job. just leak this memory. 1005 * that's not our job. just leak this memory.
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index df169c8e7225..facafdf8fb95 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2001-2004 by David Brownell 3 * Copyright (C) 2001-2004 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19/* this file is part of ehci-hcd.c */ 6/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 9b7e63977215..21307d862af6 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001 by David Brownell 3 * Copyright (c) 2001 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19/* this file is part of ehci-hcd.c */ 6/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
deleted file mode 100644
index 2f8d3af811ce..000000000000
--- a/drivers/usb/host/ehci-msm.c
+++ /dev/null
@@ -1,265 +0,0 @@
1/* ehci-msm.c - HSUSB Host Controller Driver Implementation
2 *
3 * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
4 *
5 * Partly derived from ehci-fsl.c and ehci-hcd.c
6 * Copyright (c) 2000-2004 by David Brownell
7 * Copyright (c) 2005 MontaVista Software
8 *
9 * All source code in this file is licensed under the following license except
10 * where indicated.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published
14 * by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * See the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, you can find it at http://www.fsf.org
23 */
24
25#include <linux/clk.h>
26#include <linux/err.h>
27#include <linux/io.h>
28#include <linux/kernel.h>
29#include <linux/module.h>
30#include <linux/platform_device.h>
31#include <linux/pm_runtime.h>
32#include <linux/usb/otg.h>
33#include <linux/usb/msm_hsusb_hw.h>
34#include <linux/usb.h>
35#include <linux/usb/hcd.h>
36#include <linux/acpi.h>
37
38#include "ehci.h"
39
40#define MSM_USB_BASE (hcd->regs)
41
42#define DRIVER_DESC "Qualcomm On-Chip EHCI Host Controller"
43
44static const char hcd_name[] = "ehci-msm";
45static struct hc_driver __read_mostly msm_hc_driver;
46
47static int ehci_msm_reset(struct usb_hcd *hcd)
48{
49 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
50 int retval;
51
52 ehci->caps = USB_CAPLENGTH;
53 hcd->has_tt = 1;
54
55 retval = ehci_setup(hcd);
56 if (retval)
57 return retval;
58
59 /* select ULPI phy and clear other status/control bits in PORTSC */
60 writel(PORTSC_PTS_ULPI, USB_PORTSC);
61 /* bursts of unspecified length. */
62 writel(0, USB_AHBBURST);
63 /* Use the AHB transactor, allow posted data writes */
64 writel(0x8, USB_AHBMODE);
65 /* Disable streaming mode and select host mode */
66 writel(0x13, USB_USBMODE);
67 /* Disable ULPI_TX_PKT_EN_CLR_FIX which is valid only for HSIC */
68 writel(readl(USB_GENCONFIG_2) & ~ULPI_TX_PKT_EN_CLR_FIX, USB_GENCONFIG_2);
69
70 return 0;
71}
72
73static int ehci_msm_probe(struct platform_device *pdev)
74{
75 struct usb_hcd *hcd;
76 struct resource *res;
77 struct usb_phy *phy;
78 int ret;
79
80 dev_dbg(&pdev->dev, "ehci_msm proble\n");
81
82 hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev));
83 if (!hcd) {
84 dev_err(&pdev->dev, "Unable to create HCD\n");
85 return -ENOMEM;
86 }
87
88 ret = platform_get_irq(pdev, 0);
89 if (ret < 0) {
90 dev_err(&pdev->dev, "Unable to get IRQ resource\n");
91 goto put_hcd;
92 }
93 hcd->irq = ret;
94
95 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
96 if (!res) {
97 dev_err(&pdev->dev, "Unable to get memory resource\n");
98 ret = -ENODEV;
99 goto put_hcd;
100 }
101
102 hcd->rsrc_start = res->start;
103 hcd->rsrc_len = resource_size(res);
104 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
105 if (!hcd->regs) {
106 dev_err(&pdev->dev, "ioremap failed\n");
107 ret = -ENOMEM;
108 goto put_hcd;
109 }
110
111 /*
112 * If there is an OTG driver, let it take care of PHY initialization,
113 * clock management, powering up VBUS, mapping of registers address
114 * space and power management.
115 */
116 if (pdev->dev.of_node)
117 phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0);
118 else
119 phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
120
121 if (IS_ERR(phy)) {
122 if (PTR_ERR(phy) == -EPROBE_DEFER) {
123 dev_err(&pdev->dev, "unable to find transceiver\n");
124 ret = -EPROBE_DEFER;
125 goto put_hcd;
126 }
127 phy = NULL;
128 }
129
130 hcd->usb_phy = phy;
131 device_init_wakeup(&pdev->dev, 1);
132
133 if (phy && phy->otg) {
134 /*
135 * MSM OTG driver takes care of adding the HCD and
136 * placing hardware into low power mode via runtime PM.
137 */
138 ret = otg_set_host(phy->otg, &hcd->self);
139 if (ret < 0) {
140 dev_err(&pdev->dev, "unable to register with transceiver\n");
141 goto put_hcd;
142 }
143
144 pm_runtime_no_callbacks(&pdev->dev);
145 pm_runtime_enable(&pdev->dev);
146 } else {
147 ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
148 if (ret)
149 goto put_hcd;
150 }
151
152 return 0;
153
154put_hcd:
155 usb_put_hcd(hcd);
156
157 return ret;
158}
159
160static int ehci_msm_remove(struct platform_device *pdev)
161{
162 struct usb_hcd *hcd = platform_get_drvdata(pdev);
163
164 device_init_wakeup(&pdev->dev, 0);
165 pm_runtime_disable(&pdev->dev);
166 pm_runtime_set_suspended(&pdev->dev);
167
168 if (hcd->usb_phy && hcd->usb_phy->otg)
169 otg_set_host(hcd->usb_phy->otg, NULL);
170 else
171 usb_remove_hcd(hcd);
172
173 usb_put_hcd(hcd);
174
175 return 0;
176}
177
178#ifdef CONFIG_PM
179static int ehci_msm_pm_suspend(struct device *dev)
180{
181 struct usb_hcd *hcd = dev_get_drvdata(dev);
182 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
183 bool do_wakeup = device_may_wakeup(dev);
184
185 dev_dbg(dev, "ehci-msm PM suspend\n");
186
187 /* Only call ehci_suspend if ehci_setup has been done */
188 if (ehci->sbrn)
189 return ehci_suspend(hcd, do_wakeup);
190
191 return 0;
192}
193
194static int ehci_msm_pm_resume(struct device *dev)
195{
196 struct usb_hcd *hcd = dev_get_drvdata(dev);
197 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
198
199 dev_dbg(dev, "ehci-msm PM resume\n");
200
201 /* Only call ehci_resume if ehci_setup has been done */
202 if (ehci->sbrn)
203 ehci_resume(hcd, false);
204
205 return 0;
206}
207
208#else
209#define ehci_msm_pm_suspend NULL
210#define ehci_msm_pm_resume NULL
211#endif
212
213static const struct dev_pm_ops ehci_msm_dev_pm_ops = {
214 .suspend = ehci_msm_pm_suspend,
215 .resume = ehci_msm_pm_resume,
216};
217
218static const struct acpi_device_id msm_ehci_acpi_ids[] = {
219 { "QCOM8040", 0 },
220 { }
221};
222MODULE_DEVICE_TABLE(acpi, msm_ehci_acpi_ids);
223
224static const struct of_device_id msm_ehci_dt_match[] = {
225 { .compatible = "qcom,ehci-host", },
226 {}
227};
228MODULE_DEVICE_TABLE(of, msm_ehci_dt_match);
229
230static struct platform_driver ehci_msm_driver = {
231 .probe = ehci_msm_probe,
232 .remove = ehci_msm_remove,
233 .shutdown = usb_hcd_platform_shutdown,
234 .driver = {
235 .name = "msm_hsusb_host",
236 .pm = &ehci_msm_dev_pm_ops,
237 .of_match_table = msm_ehci_dt_match,
238 .acpi_match_table = ACPI_PTR(msm_ehci_acpi_ids),
239 },
240};
241
242static const struct ehci_driver_overrides msm_overrides __initconst = {
243 .reset = ehci_msm_reset,
244};
245
246static int __init ehci_msm_init(void)
247{
248 if (usb_disabled())
249 return -ENODEV;
250
251 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
252 ehci_init_driver(&msm_hc_driver, &msm_overrides);
253 return platform_driver_register(&ehci_msm_driver);
254}
255module_init(ehci_msm_init);
256
257static void __exit ehci_msm_cleanup(void)
258{
259 platform_driver_unregister(&ehci_msm_driver);
260}
261module_exit(ehci_msm_cleanup);
262
263MODULE_DESCRIPTION(DRIVER_DESC);
264MODULE_ALIAS("platform:msm-ehci");
265MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 849806a75f1c..de764459e05a 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 * Author: Chao Xie <chao.xie@marvell.com> 4 * Author: Chao Xie <chao.xie@marvell.com>
4 * Neil Zhang <zhangwm@marvell.com> 5 * Neil Zhang <zhangwm@marvell.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */ 6 */
11 7
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index c7a9b31eeaef..c9f91e6c72b6 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -1,20 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix 3 * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
3 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> 4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 5 */
19 6
20#include <linux/kernel.h> 7#include <linux/kernel.h>
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 4d308533bc83..854b146a457d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * ehci-omap.c - driver for USBHOST on OMAP3/4 processors 3 * ehci-omap.c - driver for USBHOST on OMAP3/4 processors
3 * 4 *
@@ -14,21 +15,6 @@
14 * Contact: Felipe Balbi <felipe.balbi@nokia.com> 15 * Contact: Felipe Balbi <felipe.balbi@nokia.com>
15 * 16 *
16 * Based on "ehci-fsl.c" and "ehci-au1xxx.c" ehci glue layers 17 * Based on "ehci-fsl.c" and "ehci-au1xxx.c" ehci glue layers
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 *
32 */ 18 */
33 19
34#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 1aec87ec68df..1ad72647a069 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/host/ehci-orion.c 3 * drivers/usb/host/ehci-orion.c
3 * 4 *
4 * Tzachi Perelstein <tzachi@marvell.com> 5 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */ 6 */
10 7
11#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 93326974ff4b..fe9422d3bcdc 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * EHCI HCD (Host Controller Driver) PCI Bus Glue. 3 * EHCI HCD (Host Controller Driver) PCI Bus Glue.
3 * 4 *
4 * Copyright (c) 2000-2004 by David Brownell 5 * Copyright (c) 2000-2004 by David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 6 */
20 7
21#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index f1908ea9fbd8..b065a960adc2 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Generic platform ehci driver 3 * Generic platform ehci driver
3 * 4 *
@@ -16,8 +17,6 @@
16 * Copyright 2000-2002 David Brownell 17 * Copyright 2000-2002 David Brownell
17 * Copyright 1999 Linus Torvalds 18 * Copyright 1999 Linus Torvalds
18 * Copyright 1999 Gregory P. Smith 19 * Copyright 1999 Gregory P. Smith
19 *
20 * Licensed under the GNU/GPL. See COPYING for details.
21 */ 20 */
22#include <linux/acpi.h> 21#include <linux/acpi.h>
23#include <linux/clk.h> 22#include <linux/clk.h>
@@ -40,12 +39,11 @@
40 39
41#define DRIVER_DESC "EHCI generic platform driver" 40#define DRIVER_DESC "EHCI generic platform driver"
42#define EHCI_MAX_CLKS 4 41#define EHCI_MAX_CLKS 4
43#define EHCI_MAX_RSTS 4
44#define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) 42#define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
45 43
46struct ehci_platform_priv { 44struct ehci_platform_priv {
47 struct clk *clks[EHCI_MAX_CLKS]; 45 struct clk *clks[EHCI_MAX_CLKS];
48 struct reset_control *rsts[EHCI_MAX_RSTS]; 46 struct reset_control *rsts;
49 struct phy **phys; 47 struct phy **phys;
50 int num_phys; 48 int num_phys;
51 bool reset_on_resume; 49 bool reset_on_resume;
@@ -151,7 +149,7 @@ static int ehci_platform_probe(struct platform_device *dev)
151 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); 149 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
152 struct ehci_platform_priv *priv; 150 struct ehci_platform_priv *priv;
153 struct ehci_hcd *ehci; 151 struct ehci_hcd *ehci;
154 int err, irq, phy_num, clk = 0, rst; 152 int err, irq, phy_num, clk = 0;
155 153
156 if (usb_disabled()) 154 if (usb_disabled())
157 return -ENODEV; 155 return -ENODEV;
@@ -239,22 +237,16 @@ static int ehci_platform_probe(struct platform_device *dev)
239 } 237 }
240 } 238 }
241 239
242 for (rst = 0; rst < EHCI_MAX_RSTS; rst++) { 240 priv->rsts = devm_reset_control_array_get_optional_shared(&dev->dev);
243 priv->rsts[rst] = devm_reset_control_get_shared_by_index( 241 if (IS_ERR(priv->rsts)) {
244 &dev->dev, rst); 242 err = PTR_ERR(priv->rsts);
245 if (IS_ERR(priv->rsts[rst])) { 243 goto err_put_clks;
246 err = PTR_ERR(priv->rsts[rst]);
247 if (err == -EPROBE_DEFER)
248 goto err_reset;
249 priv->rsts[rst] = NULL;
250 break;
251 }
252
253 err = reset_control_deassert(priv->rsts[rst]);
254 if (err)
255 goto err_reset;
256 } 244 }
257 245
246 err = reset_control_deassert(priv->rsts);
247 if (err)
248 goto err_put_clks;
249
258 if (pdata->big_endian_desc) 250 if (pdata->big_endian_desc)
259 ehci->big_endian_desc = 1; 251 ehci->big_endian_desc = 1;
260 if (pdata->big_endian_mmio) 252 if (pdata->big_endian_mmio)
@@ -310,8 +302,7 @@ err_power:
310 if (pdata->power_off) 302 if (pdata->power_off)
311 pdata->power_off(dev); 303 pdata->power_off(dev);
312err_reset: 304err_reset:
313 while (--rst >= 0) 305 reset_control_assert(priv->rsts);
314 reset_control_assert(priv->rsts[rst]);
315err_put_clks: 306err_put_clks:
316 while (--clk >= 0) 307 while (--clk >= 0)
317 clk_put(priv->clks[clk]); 308 clk_put(priv->clks[clk]);
@@ -329,15 +320,14 @@ static int ehci_platform_remove(struct platform_device *dev)
329 struct usb_hcd *hcd = platform_get_drvdata(dev); 320 struct usb_hcd *hcd = platform_get_drvdata(dev);
330 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); 321 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
331 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); 322 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
332 int clk, rst; 323 int clk;
333 324
334 usb_remove_hcd(hcd); 325 usb_remove_hcd(hcd);
335 326
336 if (pdata->power_off) 327 if (pdata->power_off)
337 pdata->power_off(dev); 328 pdata->power_off(dev);
338 329
339 for (rst = 0; rst < EHCI_MAX_RSTS && priv->rsts[rst]; rst++) 330 reset_control_assert(priv->rsts);
340 reset_control_assert(priv->rsts[rst]);
341 331
342 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) 332 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++)
343 clk_put(priv->clks[clk]); 333 clk_put(priv->clks[clk]);
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 342816a7f8b1..46e160370d6e 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * PMC MSP EHCI (Host Controller Driver) for USB. 3 * PMC MSP EHCI (Host Controller Driver) for USB.
3 * 4 *
4 * (C) Copyright 2006-2010 PMC-Sierra Inc 5 * (C) Copyright 2006-2010 PMC-Sierra Inc
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 */ 6 */
11 7
12/* includes */ 8/* includes */
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 1a10c8d542ca..576f7d79ad4e 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * EHCI HCD (Host Controller Driver) for USB. 3 * EHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 7934ff9b35e1..8c733492d8fe 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * PS3 EHCI Host Controller driver 3 * PS3 EHCI Host Controller driver
3 * 4 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc. 5 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp. 6 * Copyright 2006 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 7 */
20 8
21#include <asm/firmware.h> 9#include <asm/firmware.h>
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 8f3f055c05fa..88158324dcae 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2001-2004 by David Brownell 3 * Copyright (C) 2001-2004 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19/* this file is part of ehci-hcd.c */ 6/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 6bc6304672bc..e56db44708bc 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1,20 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001-2004 by David Brownell 3 * Copyright (c) 2001-2004 by David Brownell
3 * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers 4 * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 5 */
19 6
20/* this file is part of ehci-hcd.c */ 7/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 5caf88d679e4..a9ee767952c1 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SuperH EHCI host controller driver 3 * SuperH EHCI host controller driver
3 * 4 *
4 * Copyright (C) 2010 Paul Mundt 5 * Copyright (C) 2010 Paul Mundt
5 * 6 *
6 * Based on ohci-sh.c and ehci-atmel.c. 7 * Based on ohci-sh.c and ehci-atmel.c.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */ 8 */
12#include <linux/platform_device.h> 9#include <linux/platform_device.h>
13#include <linux/clk.h> 10#include <linux/clk.h>
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 1f25c7985f5b..add796c78561 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* Driver for EHCI HCD on SPEAr SOC 3* Driver for EHCI HCD on SPEAr SOC
3* 4*
@@ -5,10 +6,6 @@
5* Deepak Sikri <deepak.sikri@st.com> 6* Deepak Sikri <deepak.sikri@st.com>
6* 7*
7* Based on various ehci-*.c drivers 8* Based on various ehci-*.c drivers
8*
9* This file is subject to the terms and conditions of the GNU General Public
10* License. See the file COPYING in the main directory of this archive for
11* more details.
12*/ 9*/
13 10
14#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index be4a2788fc58..3c1362ab70be 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ST EHCI driver 3 * ST EHCI driver
3 * 4 *
@@ -6,10 +7,6 @@
6 * Author: Peter Griffin <peter.griffin@linaro.org> 7 * Author: Peter Griffin <peter.griffin@linaro.org>
7 * 8 *
8 * Derived from ehci-platform.c 9 * Derived from ehci-platform.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */ 10 */
14 11
15#include <linux/clk.h> 12#include <linux/clk.h>
diff --git a/drivers/usb/host/ehci-sysfs.c b/drivers/usb/host/ehci-sysfs.c
index 5216f2b09d63..71fb61dd4a87 100644
--- a/drivers/usb/host/ehci-sysfs.c
+++ b/drivers/usb/host/ehci-sysfs.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2007 by Alan Stern 3 * Copyright (C) 2007 by Alan Stern
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19/* this file is part of ehci-hcd.c */ 6/* this file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 9a3d7db5be57..c809f7d2f08f 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -1,19 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs 3 * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
3 * 4 *
4 * Copyright (C) 2010 Google, Inc. 5 * Copyright (C) 2010 Google, Inc.
5 * Copyright (C) 2009 - 2013 NVIDIA Corporation 6 * Copyright (C) 2009 - 2013 NVIDIA Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 */ 7 */
18 8
19#include <linux/clk.h> 9#include <linux/clk.h>
diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index bdb93b6a356f..610ed437ed2c 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -1,15 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2012 Tilera Corporation. All Rights Reserved. 3 * Copyright 2012 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */ 4 */
14 5
15/* 6/*
diff --git a/drivers/usb/host/ehci-timer.c b/drivers/usb/host/ehci-timer.c
index 0b6cdb723192..4fcebda4b79d 100644
--- a/drivers/usb/host/ehci-timer.c
+++ b/drivers/usb/host/ehci-timer.c
@@ -1,15 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2012 by Alan Stern 3 * Copyright (C) 2012 by Alan Stern
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */ 4 */
14 5
15/* This file is part of ehci-hcd.c */ 6/* This file is part of ehci-hcd.c */
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
index 63b9d0c67963..6d77ace1697b 100644
--- a/drivers/usb/host/ehci-w90x900.c
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/driver/usb/host/ehci-w90x900.c 3 * linux/driver/usb/host/ehci-w90x900.c
3 * 4 *
4 * Copyright (c) 2008 Nuvoton technology corporation. 5 * Copyright (c) 2008 Nuvoton technology corporation.
5 * 6 *
6 * Wan ZongShun <mcuos.com@gmail.com> 7 * Wan ZongShun <mcuos.com@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation;version 2 of the License.
11 *
12 */ 8 */
13 9
14#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index f54480850bb8..d2a27578e440 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * EHCI HCD (Host Controller Driver) for USB. 3 * EHCI HCD (Host Controller Driver) for USB.
3 * 4 *
@@ -8,21 +9,6 @@
8 * Based on "ehci-ppc-of.c" by Valentine Barshak <vbarshak@ru.mvista.com> 9 * Based on "ehci-ppc-of.c" by Valentine Barshak <vbarshak@ru.mvista.com>
9 * and "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> 10 * and "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de>
10 * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> 11 * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 */ 12 */
27 13
28#include <linux/err.h> 14#include <linux/err.h>
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index a8e36170d8b8..c8e9a48e1d51 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001-2002 by David Brownell 3 * Copyright (c) 2001-2002 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#ifndef __LINUX_EHCI_HCD_H 6#ifndef __LINUX_EHCI_HCD_H
diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c
index b58e7a60913a..fafa91189e45 100644
--- a/drivers/usb/host/fhci-dbg.c
+++ b/drivers/usb/host/fhci-dbg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 55a0ae6f2d74..48fe9e6c2465 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/usb/host/fhci-hub.c b/drivers/usb/host/fhci-hub.c
index 60d55eb3de0d..c359dcdb9b13 100644
--- a/drivers/usb/host/fhci-hub.c
+++ b/drivers/usb/host/fhci-hub.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci-mem.c b/drivers/usb/host/fhci-mem.c
index b0b88f57a5ac..658aedc6adc1 100644
--- a/drivers/usb/host/fhci-mem.c
+++ b/drivers/usb/host/fhci-mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci-q.c b/drivers/usb/host/fhci-q.c
index 03be7494a476..669c240523fe 100644
--- a/drivers/usb/host/fhci-q.c
+++ b/drivers/usb/host/fhci-q.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 2f162faabbca..3d12cdd5f999 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index f82ad5df1b0d..3a4e8f616751 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 3fc82c1c3c73..e7ec41d62410 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Freescale QUICC Engine USB Host Controller Driver 3 * Freescale QUICC Engine USB Host Controller Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Peter Barada <peterb@logicpd.com> 9 * Peter Barada <peterb@logicpd.com>
9 * Copyright (c) MontaVista Software, Inc. 2008. 10 * Copyright (c) MontaVista Software, Inc. 2008.
10 * Anton Vorontsov <avorontsov@ru.mvista.com> 11 * Anton Vorontsov <avorontsov@ru.mvista.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */ 12 */
17 13
18#ifndef __FHCI_H 14#ifndef __FHCI_H
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 457cc6525abd..62fc955085a1 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* Faraday FOTG210 EHCI-like driver 2/* Faraday FOTG210 EHCI-like driver
2 * 3 *
3 * Copyright (c) 2013 Faraday Technology Corporation 4 * Copyright (c) 2013 Faraday Technology Corporation
@@ -7,20 +8,6 @@
7 * Po-Yu Chuang <ratbert.chuang@gmail.com> 8 * Po-Yu Chuang <ratbert.chuang@gmail.com>
8 * 9 *
9 * Most of code borrowed from the Linux-3.7 EHCI driver 10 * Most of code borrowed from the Linux-3.7 EHCI driver
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 11 */
25#include <linux/module.h> 12#include <linux/module.h>
26#include <linux/device.h> 13#include <linux/device.h>
@@ -5449,7 +5436,7 @@ idle_timeout:
5449 qh_destroy(fotg210, qh); 5436 qh_destroy(fotg210, qh);
5450 break; 5437 break;
5451 } 5438 }
5452 /* else FALL THROUGH */ 5439 /* fall through */
5453 default: 5440 default:
5454 /* caller was supposed to have unlinked any requests; 5441 /* caller was supposed to have unlinked any requests;
5455 * that's not our job. just leak this memory. 5442 * that's not our job. just leak this memory.
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index ba557cdba8ef..677f9d592109 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Setup platform devices needed by the Freescale multi-port host 3 * Setup platform devices needed by the Freescale multi-port host
3 * and/or dual-role USB controller modules based on the description 4 * and/or dual-role USB controller modules based on the description
4 * in flat device tree. 5 * in flat device tree.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */ 6 */
11 7
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index da3b18038d23..684d6f074c3a 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Host Wire Adapter: 3 * Host Wire Adapter:
3 * Driver glue, HWA-specific functions, bridges to WAHC and WUSBHC 4 * Driver glue, HWA-specific functions, bridges to WAHC and WUSBHC
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * The HWA driver is a simple layer that forwards requests to the WAHC 9 * The HWA driver is a simple layer that forwards requests to the WAHC
24 * (Wire Adater Host Controller) or WUSBHC (Wireless USB Host 10 * (Wire Adater Host Controller) or WUSBHC (Wireless USB Host
25 * Controller) layers. 11 * Controller) layers.
diff --git a/drivers/usb/host/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c
index 4f320d050da7..b964f9a51d87 100644
--- a/drivers/usb/host/imx21-dbg.c
+++ b/drivers/usb/host/imx21-dbg.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2009 by Martin Fuzzey 3 * Copyright (c) 2009 by Martin Fuzzey
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19/* this file is part of imx21-hcd.c */ 6/* this file is part of imx21-hcd.c */
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index 39ae7fb64b6f..3a8bbfe43a8e 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Host Controller Driver for IMX21 3 * USB Host Controller Driver for IMX21
3 * 4 *
@@ -5,20 +6,6 @@
5 * Copyright (C) 2009 Martin Fuzzey 6 * Copyright (C) 2009 Martin Fuzzey
6 * Originally written by Jay Monkman <jtm@lopingdog.com> 7 * Originally written by Jay Monkman <jtm@lopingdog.com>
7 * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey 8 * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 9 */
23 10
24 11
diff --git a/drivers/usb/host/imx21-hcd.h b/drivers/usb/host/imx21-hcd.h
index 05122f8a6983..7b9cf0a38d6e 100644
--- a/drivers/usb/host/imx21-hcd.h
+++ b/drivers/usb/host/imx21-hcd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Macros and prototypes for i.MX21 3 * Macros and prototypes for i.MX21
3 * 4 *
@@ -5,20 +6,6 @@
5 * Copyright (C) 2009 Martin Fuzzey 6 * Copyright (C) 2009 Martin Fuzzey
6 * Originally written by Jay Monkman <jtm@lopingdog.com> 7 * Originally written by Jay Monkman <jtm@lopingdog.com>
7 * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey 8 * Ported to 2.6.30, debugged and enhanced by Martin Fuzzey
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 9 */
23 10
24#ifndef __LINUX_IMX21_HCD_H__ 11#ifndef __LINUX_IMX21_HCD_H__
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 73fec38754f9..5f9234b9cf7b 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ISP116x HCD (Host Controller Driver) for USB. 3 * ISP116x HCD (Host Controller Driver) for USB.
3 * 4 *
@@ -1018,6 +1019,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
1018 spin_lock_irqsave(&isp116x->lock, flags); 1019 spin_lock_irqsave(&isp116x->lock, flags);
1019 isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_OCIC); 1020 isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_OCIC);
1020 spin_unlock_irqrestore(&isp116x->lock, flags); 1021 spin_unlock_irqrestore(&isp116x->lock, flags);
1022 /* fall through */
1021 case C_HUB_LOCAL_POWER: 1023 case C_HUB_LOCAL_POWER:
1022 DBG("C_HUB_LOCAL_POWER\n"); 1024 DBG("C_HUB_LOCAL_POWER\n");
1023 break; 1025 break;
@@ -1433,8 +1435,10 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd)
1433 isp116x_write_reg32(isp116x, HCCONTROL, 1435 isp116x_write_reg32(isp116x, HCCONTROL,
1434 (val & ~HCCONTROL_HCFS) | 1436 (val & ~HCCONTROL_HCFS) |
1435 HCCONTROL_USB_RESET); 1437 HCCONTROL_USB_RESET);
1438 /* fall through */
1436 case HCCONTROL_USB_RESET: 1439 case HCCONTROL_USB_RESET:
1437 ret = -EBUSY; 1440 ret = -EBUSY;
1441 /* fall through */
1438 default: /* HCCONTROL_USB_SUSPEND */ 1442 default: /* HCCONTROL_USB_SUSPEND */
1439 spin_unlock_irqrestore(&isp116x->lock, flags); 1443 spin_unlock_irqrestore(&isp116x->lock, flags);
1440 break; 1444 break;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 9b7e307e2d54..b21c386e6a46 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ISP1362 HCD (Host Controller Driver) for USB. 3 * ISP1362 HCD (Host Controller Driver) for USB.
3 * 4 *
@@ -712,7 +713,7 @@ static inline void enable_istl_transfers(struct isp1362_hcd *isp1362_hcd, int fl
712static int submit_req(struct isp1362_hcd *isp1362_hcd, struct urb *urb, 713static int submit_req(struct isp1362_hcd *isp1362_hcd, struct urb *urb,
713 struct isp1362_ep *ep, struct isp1362_ep_queue *epq) 714 struct isp1362_ep *ep, struct isp1362_ep_queue *epq)
714{ 715{
715 int index = epq->free_ptd; 716 int index;
716 717
717 prepare_ptd(isp1362_hcd, urb, ep, epq, 0); 718 prepare_ptd(isp1362_hcd, urb, ep, epq, 0);
718 index = claim_ptd_buffers(epq, ep, ep->length); 719 index = claim_ptd_buffers(epq, ep, ep->length);
@@ -1578,6 +1579,7 @@ static int isp1362_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1578 spin_lock_irqsave(&isp1362_hcd->lock, flags); 1579 spin_lock_irqsave(&isp1362_hcd->lock, flags);
1579 isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_OCIC); 1580 isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_OCIC);
1580 spin_unlock_irqrestore(&isp1362_hcd->lock, flags); 1581 spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
1582 break;
1581 case C_HUB_LOCAL_POWER: 1583 case C_HUB_LOCAL_POWER:
1582 DBG(0, "C_HUB_LOCAL_POWER\n"); 1584 DBG(0, "C_HUB_LOCAL_POWER\n");
1583 break; 1585 break;
@@ -2251,7 +2253,6 @@ static int isp1362_mem_config(struct usb_hcd *hcd)
2251 return -ENOMEM; 2253 return -ENOMEM;
2252 } 2254 }
2253 2255
2254 total = istl_size + intl_size + atl_size;
2255 spin_lock_irqsave(&isp1362_hcd->lock, flags); 2256 spin_lock_irqsave(&isp1362_hcd->lock, flags);
2256 2257
2257 for (i = 0; i < 2; i++) { 2258 for (i = 0; i < 2; i++) {
diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 0ece9a9341e5..afa321ab55fc 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MAX3421 Host Controller driver for USB. 3 * MAX3421 Host Controller driver for USB.
3 * 4 *
@@ -60,6 +61,7 @@
60#include <linux/spi/spi.h> 61#include <linux/spi/spi.h>
61#include <linux/usb.h> 62#include <linux/usb.h>
62#include <linux/usb/hcd.h> 63#include <linux/usb/hcd.h>
64#include <linux/of.h>
63 65
64#include <linux/platform_data/max3421-hcd.h> 66#include <linux/platform_data/max3421-hcd.h>
65 67
@@ -85,6 +87,8 @@
85 USB_PORT_STAT_C_OVERCURRENT | \ 87 USB_PORT_STAT_C_OVERCURRENT | \
86 USB_PORT_STAT_C_RESET) << 16) 88 USB_PORT_STAT_C_RESET) << 16)
87 89
90#define MAX3421_GPOUT_COUNT 8
91
88enum max3421_rh_state { 92enum max3421_rh_state {
89 MAX3421_RH_RESET, 93 MAX3421_RH_RESET,
90 MAX3421_RH_SUSPENDED, 94 MAX3421_RH_SUSPENDED,
@@ -1672,7 +1676,7 @@ max3421_gpout_set_value(struct usb_hcd *hcd, u8 pin_number, u8 value)
1672 u8 mask, idx; 1676 u8 mask, idx;
1673 1677
1674 --pin_number; 1678 --pin_number;
1675 if (pin_number > 7) 1679 if (pin_number >= MAX3421_GPOUT_COUNT)
1676 return; 1680 return;
1677 1681
1678 mask = 1u << (pin_number % 4); 1682 mask = 1u << (pin_number % 4);
@@ -1696,10 +1700,10 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index,
1696 unsigned long flags; 1700 unsigned long flags;
1697 int retval = 0; 1701 int retval = 0;
1698 1702
1699 spin_lock_irqsave(&max3421_hcd->lock, flags);
1700
1701 pdata = spi->dev.platform_data; 1703 pdata = spi->dev.platform_data;
1702 1704
1705 spin_lock_irqsave(&max3421_hcd->lock, flags);
1706
1703 switch (type_req) { 1707 switch (type_req) {
1704 case ClearHubFeature: 1708 case ClearHubFeature:
1705 break; 1709 break;
@@ -1832,10 +1836,34 @@ static const struct hc_driver max3421_hcd_desc = {
1832}; 1836};
1833 1837
1834static int 1838static int
1839max3421_of_vbus_en_pin(struct device *dev, struct max3421_hcd_platform_data *pdata)
1840{
1841 int retval;
1842 uint32_t value[2];
1843
1844 if (!pdata)
1845 return -EINVAL;
1846
1847 retval = of_property_read_u32_array(dev->of_node, "maxim,vbus-en-pin", value, 2);
1848 if (retval) {
1849 dev_err(dev, "device tree node property 'maxim,vbus-en-pin' is missing\n");
1850 return retval;
1851 }
1852 dev_info(dev, "property 'maxim,vbus-en-pin' value is <%d %d>\n", value[0], value[1]);
1853
1854 pdata->vbus_gpout = value[0];
1855 pdata->vbus_active_level = value[1];
1856
1857 return 0;
1858}
1859
1860static int
1835max3421_probe(struct spi_device *spi) 1861max3421_probe(struct spi_device *spi)
1836{ 1862{
1863 struct device *dev = &spi->dev;
1837 struct max3421_hcd *max3421_hcd; 1864 struct max3421_hcd *max3421_hcd;
1838 struct usb_hcd *hcd = NULL; 1865 struct usb_hcd *hcd = NULL;
1866 struct max3421_hcd_platform_data *pdata = NULL;
1839 int retval = -ENOMEM; 1867 int retval = -ENOMEM;
1840 1868
1841 if (spi_setup(spi) < 0) { 1869 if (spi_setup(spi) < 0) {
@@ -1843,6 +1871,41 @@ max3421_probe(struct spi_device *spi)
1843 return -EFAULT; 1871 return -EFAULT;
1844 } 1872 }
1845 1873
1874 if (!spi->irq) {
1875 dev_err(dev, "Failed to get SPI IRQ");
1876 return -EFAULT;
1877 }
1878
1879 if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
1880 pdata = devm_kzalloc(&spi->dev, sizeof(*pdata), GFP_KERNEL);
1881 if (!pdata) {
1882 retval = -ENOMEM;
1883 goto error;
1884 }
1885 retval = max3421_of_vbus_en_pin(dev, pdata);
1886 if (retval)
1887 goto error;
1888
1889 spi->dev.platform_data = pdata;
1890 }
1891
1892 pdata = spi->dev.platform_data;
1893 if (!pdata) {
1894 dev_err(&spi->dev, "driver configuration data is not provided\n");
1895 retval = -EFAULT;
1896 goto error;
1897 }
1898 if (pdata->vbus_active_level > 1) {
1899 dev_err(&spi->dev, "vbus active level value %d is out of range (0/1)\n", pdata->vbus_active_level);
1900 retval = -EINVAL;
1901 goto error;
1902 }
1903 if (pdata->vbus_gpout < 1 || pdata->vbus_gpout > MAX3421_GPOUT_COUNT) {
1904 dev_err(&spi->dev, "vbus gpout value %d is out of range (1..8)\n", pdata->vbus_gpout);
1905 retval = -EINVAL;
1906 goto error;
1907 }
1908
1846 hcd = usb_create_hcd(&max3421_hcd_desc, &spi->dev, 1909 hcd = usb_create_hcd(&max3421_hcd_desc, &spi->dev,
1847 dev_name(&spi->dev)); 1910 dev_name(&spi->dev));
1848 if (!hcd) { 1911 if (!hcd) {
@@ -1885,6 +1948,11 @@ max3421_probe(struct spi_device *spi)
1885 return 0; 1948 return 0;
1886 1949
1887error: 1950error:
1951 if (IS_ENABLED(CONFIG_OF) && dev->of_node && pdata) {
1952 devm_kfree(&spi->dev, pdata);
1953 spi->dev.platform_data = NULL;
1954 }
1955
1888 if (hcd) { 1956 if (hcd) {
1889 kfree(max3421_hcd->tx); 1957 kfree(max3421_hcd->tx);
1890 kfree(max3421_hcd->rx); 1958 kfree(max3421_hcd->rx);
@@ -1929,11 +1997,18 @@ max3421_remove(struct spi_device *spi)
1929 return 0; 1997 return 0;
1930} 1998}
1931 1999
2000static const struct of_device_id max3421_of_match_table[] = {
2001 { .compatible = "maxim,max3421", },
2002 {},
2003};
2004MODULE_DEVICE_TABLE(of, max3421_of_match_table);
2005
1932static struct spi_driver max3421_driver = { 2006static struct spi_driver max3421_driver = {
1933 .probe = max3421_probe, 2007 .probe = max3421_probe,
1934 .remove = max3421_remove, 2008 .remove = max3421_remove,
1935 .driver = { 2009 .driver = {
1936 .name = "max3421-hcd", 2010 .name = "max3421-hcd",
2011 .of_match_table = of_match_ptr(max3421_of_match_table),
1937 }, 2012 },
1938}; 2013};
1939 2014
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 5302f988e7e6..5ad9e9bdc8ee 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 05da2cb59612..0c507a0cfe1f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Derived from: ohci-omap.c and ohci-s3c2410.c 7 * Derived from: ohci-omap.c and ohci-s3c2410.c
7 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com> 8 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 */ 9 */
13 10
14#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index c3eded317495..ac7d4ac34b02 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 6865b919403f..a39fae41bc70 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -1,14 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * SAMSUNG EXYNOS USB HOST OHCI Controller 3 * SAMSUNG EXYNOS USB HOST OHCI Controller
3 * 4 *
4 * Copyright (C) 2011 Samsung Electronics Co.Ltd 5 * Copyright (C) 2011 Samsung Electronics Co.Ltd
5 * Author: Jingoo Han <jg1.han@samsung.com> 6 * Author: Jingoo Han <jg1.han@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */ 7 */
13 8
14#include <linux/clk.h> 9#include <linux/clk.h>
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index c86f89babd57..10887e09e9bc 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Open Host Controller Interface (OHCI) driver for USB. 3 * Open Host Controller Interface (OHCI) driver for USB.
3 * 4 *
@@ -382,7 +383,7 @@ sanitize:
382 ed_free (ohci, ed); 383 ed_free (ohci, ed);
383 break; 384 break;
384 } 385 }
385 /* else FALL THROUGH */ 386 /* fall through */
386 default: 387 default:
387 /* caller was supposed to have unlinked any requests; 388 /* caller was supposed to have unlinked any requests;
388 * that's not our job. can't recover; must leak ed. 389 * that's not our job. can't recover; must leak ed.
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 248eb7702463..fb7aaa3b9d06 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index ed8a762b8670..b3da3f12e5b1 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index 6df8e2ed40fd..f5f532601092 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * driver for NXP USB Host devices 3 * driver for NXP USB Host devices
3 * 4 *
@@ -13,10 +14,7 @@
13 * NOTE: This driver does not have suspend/resume functionality 14 * NOTE: This driver does not have suspend/resume functionality
14 * This driver is intended for engineering development purposes only 15 * This driver is intended for engineering development purposes only
15 * 16 *
16 * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under 17 * 2005-2006 (c) MontaVista Software, Inc.
17 * the terms of the GNU General Public License version 2. This program
18 * is licensed "as is" without any warranty of any kind, whether express
19 * or implied.
20 */ 18 */
21#include <linux/clk.h> 19#include <linux/clk.h>
22#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 91393ec7d850..0201c49bc4fc 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index a84aebe9b0a9..fbcd34911025 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 61fe2b985070..1e6c954f4b3f 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Generic platform ohci driver 3 * Generic platform ohci driver
3 * 4 *
@@ -11,8 +12,6 @@
11 * Copyright 2000-2002 David Brownell 12 * Copyright 2000-2002 David Brownell
12 * Copyright 1999 Linus Torvalds 13 * Copyright 1999 Linus Torvalds
13 * Copyright 1999 Gregory P. Smith 14 * Copyright 1999 Gregory P. Smith
14 *
15 * Licensed under the GNU/GPL. See COPYING for details.
16 */ 15 */
17 16
18#include <linux/clk.h> 17#include <linux/clk.h>
@@ -34,12 +33,11 @@
34 33
35#define DRIVER_DESC "OHCI generic platform driver" 34#define DRIVER_DESC "OHCI generic platform driver"
36#define OHCI_MAX_CLKS 3 35#define OHCI_MAX_CLKS 3
37#define OHCI_MAX_RESETS 2
38#define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv) 36#define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv)
39 37
40struct ohci_platform_priv { 38struct ohci_platform_priv {
41 struct clk *clks[OHCI_MAX_CLKS]; 39 struct clk *clks[OHCI_MAX_CLKS];
42 struct reset_control *resets[OHCI_MAX_RESETS]; 40 struct reset_control *resets;
43 struct phy **phys; 41 struct phy **phys;
44 int num_phys; 42 int num_phys;
45}; 43};
@@ -119,7 +117,7 @@ static int ohci_platform_probe(struct platform_device *dev)
119 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); 117 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
120 struct ohci_platform_priv *priv; 118 struct ohci_platform_priv *priv;
121 struct ohci_hcd *ohci; 119 struct ohci_hcd *ohci;
122 int err, irq, phy_num, clk = 0, rst = 0; 120 int err, irq, phy_num, clk = 0;
123 121
124 if (usb_disabled()) 122 if (usb_disabled())
125 return -ENODEV; 123 return -ENODEV;
@@ -204,21 +202,17 @@ static int ohci_platform_probe(struct platform_device *dev)
204 break; 202 break;
205 } 203 }
206 } 204 }
207 for (rst = 0; rst < OHCI_MAX_RESETS; rst++) { 205
208 priv->resets[rst] = 206 priv->resets = devm_reset_control_array_get_optional_shared(
209 devm_reset_control_get_shared_by_index( 207 &dev->dev);
210 &dev->dev, rst); 208 if (IS_ERR(priv->resets)) {
211 if (IS_ERR(priv->resets[rst])) { 209 err = PTR_ERR(priv->resets);
212 err = PTR_ERR(priv->resets[rst]); 210 goto err_put_clks;
213 if (err == -EPROBE_DEFER)
214 goto err_reset;
215 priv->resets[rst] = NULL;
216 break;
217 }
218 err = reset_control_deassert(priv->resets[rst]);
219 if (err)
220 goto err_reset;
221 } 211 }
212
213 err = reset_control_deassert(priv->resets);
214 if (err)
215 goto err_put_clks;
222 } 216 }
223 217
224 if (pdata->big_endian_desc) 218 if (pdata->big_endian_desc)
@@ -279,8 +273,7 @@ err_power:
279 pdata->power_off(dev); 273 pdata->power_off(dev);
280err_reset: 274err_reset:
281 pm_runtime_disable(&dev->dev); 275 pm_runtime_disable(&dev->dev);
282 while (--rst >= 0) 276 reset_control_assert(priv->resets);
283 reset_control_assert(priv->resets[rst]);
284err_put_clks: 277err_put_clks:
285 while (--clk >= 0) 278 while (--clk >= 0)
286 clk_put(priv->clks[clk]); 279 clk_put(priv->clks[clk]);
@@ -298,7 +291,7 @@ static int ohci_platform_remove(struct platform_device *dev)
298 struct usb_hcd *hcd = platform_get_drvdata(dev); 291 struct usb_hcd *hcd = platform_get_drvdata(dev);
299 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); 292 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
300 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); 293 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
301 int clk, rst; 294 int clk;
302 295
303 pm_runtime_get_sync(&dev->dev); 296 pm_runtime_get_sync(&dev->dev);
304 usb_remove_hcd(hcd); 297 usb_remove_hcd(hcd);
@@ -306,8 +299,7 @@ static int ohci_platform_remove(struct platform_device *dev)
306 if (pdata->power_off) 299 if (pdata->power_off)
307 pdata->power_off(dev); 300 pdata->power_off(dev);
308 301
309 for (rst = 0; rst < OHCI_MAX_RESETS && priv->resets[rst]; rst++) 302 reset_control_assert(priv->resets);
310 reset_control_assert(priv->resets[rst]);
311 303
312 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) 304 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++)
313 clk_put(priv->clks[clk]); 305 clk_put(priv->clks[clk]);
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 4f87a5c61b08..76a9b40b08f1 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
index 71d8bc4c27f6..20a23d795adf 100644
--- a/drivers/usb/host/ohci-ps3.c
+++ b/drivers/usb/host/ohci-ps3.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * PS3 OHCI Host Controller driver 3 * PS3 OHCI Host Controller driver
3 * 4 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc. 5 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp. 6 * Copyright 2006 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 7 */
20 8
21#include <asm/firmware.h> 9#include <asm/firmware.h>
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 21c010ffb03c..3e2474959735 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 641fed609911..b2ec8c399363 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index b006b93126f7..4511e27e9da8 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 3a9ea32508df..ebec9a7699e3 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
@@ -42,7 +43,7 @@
42#if 0 43#if 0
43static void dump_hci_status(struct usb_hcd *hcd, const char *label) 44static void dump_hci_status(struct usb_hcd *hcd, const char *label)
44{ 45{
45 unsigned long status = sa1111_readl(hcd->regs + USB_STATUS); 46 unsigned long status = readl_relaxed(hcd->regs + USB_STATUS);
46 47
47 printk(KERN_DEBUG "%s USB_STATUS = { %s%s%s%s%s}\n", label, 48 printk(KERN_DEBUG "%s USB_STATUS = { %s%s%s%s%s}\n", label,
48 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""), 49 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
@@ -134,7 +135,7 @@ static int sa1111_start_hc(struct sa1111_dev *dev)
134 * Configure the power sense and control lines. Place the USB 135 * Configure the power sense and control lines. Place the USB
135 * host controller in reset. 136 * host controller in reset.
136 */ 137 */
137 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 138 writel_relaxed(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
138 dev->mapbase + USB_RESET); 139 dev->mapbase + USB_RESET);
139 140
140 /* 141 /*
@@ -144,7 +145,7 @@ static int sa1111_start_hc(struct sa1111_dev *dev)
144 ret = sa1111_enable_device(dev); 145 ret = sa1111_enable_device(dev);
145 if (ret == 0) { 146 if (ret == 0) {
146 udelay(11); 147 udelay(11);
147 sa1111_writel(usb_rst, dev->mapbase + USB_RESET); 148 writel_relaxed(usb_rst, dev->mapbase + USB_RESET);
148 } 149 }
149 150
150 return ret; 151 return ret;
@@ -159,8 +160,8 @@ static void sa1111_stop_hc(struct sa1111_dev *dev)
159 /* 160 /*
160 * Put the USB host controller into reset. 161 * Put the USB host controller into reset.
161 */ 162 */
162 usb_rst = sa1111_readl(dev->mapbase + USB_RESET); 163 usb_rst = readl_relaxed(dev->mapbase + USB_RESET);
163 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 164 writel_relaxed(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
164 dev->mapbase + USB_RESET); 165 dev->mapbase + USB_RESET);
165 166
166 /* 167 /*
@@ -178,7 +179,7 @@ static void sa1111_stop_hc(struct sa1111_dev *dev)
178static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev) 179static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
179{ 180{
180 struct usb_hcd *hcd; 181 struct usb_hcd *hcd;
181 int ret; 182 int ret, irq;
182 183
183 if (usb_disabled()) 184 if (usb_disabled())
184 return -ENODEV; 185 return -ENODEV;
@@ -196,6 +197,12 @@ static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
196 hcd->rsrc_start = dev->res.start; 197 hcd->rsrc_start = dev->res.start;
197 hcd->rsrc_len = resource_size(&dev->res); 198 hcd->rsrc_len = resource_size(&dev->res);
198 199
200 irq = sa1111_get_irq(dev, 1);
201 if (irq <= 0) {
202 ret = irq ? : -ENXIO;
203 goto err1;
204 }
205
199 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 206 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
200 dev_dbg(&dev->dev, "request_mem_region failed\n"); 207 dev_dbg(&dev->dev, "request_mem_region failed\n");
201 ret = -EBUSY; 208 ret = -EBUSY;
@@ -208,7 +215,7 @@ static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
208 if (ret) 215 if (ret)
209 goto err2; 216 goto err2;
210 217
211 ret = usb_add_hcd(hcd, dev->irq[1], 0); 218 ret = usb_add_hcd(hcd, irq, 0);
212 if (ret == 0) { 219 if (ret == 0) {
213 device_wakeup_enable(hcd->self.controller); 220 device_wakeup_enable(hcd->self.controller);
214 return ret; 221 return ret;
@@ -241,8 +248,9 @@ static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev)
241 return 0; 248 return 0;
242} 249}
243 250
244static void ohci_hcd_sa1111_shutdown(struct sa1111_dev *dev) 251static void ohci_hcd_sa1111_shutdown(struct device *_dev)
245{ 252{
253 struct sa1111_dev *dev = to_sa1111_device(_dev);
246 struct usb_hcd *hcd = sa1111_get_drvdata(dev); 254 struct usb_hcd *hcd = sa1111_get_drvdata(dev);
247 255
248 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 256 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
@@ -255,9 +263,9 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = {
255 .drv = { 263 .drv = {
256 .name = "sa1111-ohci", 264 .name = "sa1111-ohci",
257 .owner = THIS_MODULE, 265 .owner = THIS_MODULE,
266 .shutdown = ohci_hcd_sa1111_shutdown,
258 }, 267 },
259 .devid = SA1111_DEVID_USB, 268 .devid = SA1111_DEVID_USB,
260 .probe = ohci_hcd_sa1111_probe, 269 .probe = ohci_hcd_sa1111_probe,
261 .remove = ohci_hcd_sa1111_remove, 270 .remove = ohci_hcd_sa1111_remove,
262 .shutdown = ohci_hcd_sa1111_shutdown,
263}; 271};
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index d4e0f7cd96fa..c9233cddf9a2 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 56478ed2f932..69fa04697793 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* OHCI HCD (Host Controller Driver) for USB. 3* OHCI HCD (Host Controller Driver) for USB.
3* 4*
@@ -5,10 +6,6 @@
5* Deepak Sikri<deepak.sikri@st.com> 6* Deepak Sikri<deepak.sikri@st.com>
6* 7*
7* Based on various ohci-*.c drivers 8* Based on various ohci-*.c drivers
8*
9* This file is licensed under the terms of the GNU General Public
10* License version 2. This program is licensed "as is" without any
11* warranty of any kind, whether express or implied.
12*/ 9*/
13 10
14#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index 02816a1515a1..992807c9850a 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ST OHCI driver 3 * ST OHCI driver
3 * 4 *
@@ -6,10 +7,6 @@
6 * Author: Peter Griffin <peter.griffin@linaro.org> 7 * Author: Peter Griffin <peter.griffin@linaro.org>
7 * 8 *
8 * Derived from ohci-platform.c 9 * Derived from ohci-platform.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */ 10 */
14 11
15#include <linux/clk.h> 12#include <linux/clk.h>
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index e1b208da460a..d21ca3ce9a30 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -1,15 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2012 Tilera Corporation. All Rights Reserved. 3 * Copyright 2012 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */ 4 */
14 5
15/* 6/*
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 16d081a093bb..a631dbb369d7 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * OHCI HCD(Host Controller Driver) for USB. 3 * OHCI HCD(Host Controller Driver) for USB.
3 * 4 *
@@ -18,10 +19,6 @@
18 * Written from sparse documentation from Toshiba and Sharp's driver 19 * Written from sparse documentation from Toshiba and Sharp's driver
19 * for the 2.4 kernel, 20 * for the 2.4 kernel,
20 * usb-ohci-tc6393.c(C) Copyright 2004 Lineo Solutions, Inc. 21 * usb-ohci-tc6393.c(C) Copyright 2004 Lineo Solutions, Inc.
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License version 2 as
24 * published by the Free Software Foundation.
25 */ 22 */
26 23
27/*#include <linux/fs.h> 24/*#include <linux/fs.h>
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 12742d002d2d..508a803139dd 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * OHCI HCD (Host Controller Driver) for USB. 3 * OHCI HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index ed20fb34c897..0bf7759aae78 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2008 Rodolfo Giometti <giometti@linux.it> 3 * Copyright (c) 2008 Rodolfo Giometti <giometti@linux.it>
3 * Copyright (c) 2008 Eurotech S.p.A. <info@eurtech.it> 4 * Copyright (c) 2008 Eurotech S.p.A. <info@eurtech.it>
4 * 5 *
5 * This code is *strongly* based on EHCI-HCD code by David Brownell since 6 * This code is *strongly* based on EHCI-HCD code by David Brownell since
6 * the chip is a quasi-EHCI compatible. 7 * the chip is a quasi-EHCI compatible.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 8 */
22 9
23#include <linux/module.h> 10#include <linux/module.h>
@@ -3040,7 +3027,7 @@ idle_timeout:
3040 qh_put(qh); 3027 qh_put(qh);
3041 break; 3028 break;
3042 } 3029 }
3043 /* else FALL THROUGH */ 3030 /* fall through */
3044 default: 3031 default:
3045nogood: 3032nogood:
3046 /* caller was supposed to have unlinked any requests; 3033 /* caller was supposed to have unlinked any requests;
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 6dda3623a276..161536717025 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file contains code to reset and initialize USB host controllers. 3 * This file contains code to reset and initialize USB host controllers.
3 * Some of it includes work-arounds for PCI hardware and BIOS quirks. 4 * Some of it includes work-arounds for PCI hardware and BIOS quirks.
@@ -841,7 +842,7 @@ static void quirk_usb_disable_ehci(struct pci_dev *pdev)
841 ehci_bios_handoff(pdev, op_reg_base, cap, offset); 842 ehci_bios_handoff(pdev, op_reg_base, cap, offset);
842 break; 843 break;
843 case 0: /* Illegal reserved cap, set cap=0 so we exit */ 844 case 0: /* Illegal reserved cap, set cap=0 so we exit */
844 cap = 0; /* then fallthrough... */ 845 cap = 0; /* fall through */
845 default: 846 default:
846 dev_warn(&pdev->dev, 847 dev_warn(&pdev->dev,
847 "EHCI: unrecognized capability %02x\n", 848 "EHCI: unrecognized capability %02x\n",
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 5e5fc9d7d533..f3d9ba420a97 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * R8A66597 HCD (Host Controller Driver) 3 * R8A66597 HCD (Host Controller Driver)
3 * 4 *
@@ -7,20 +8,6 @@
7 * Portions Copyright (C) 1999 Roman Weissgaerber 8 * Portions Copyright (C) 1999 Roman Weissgaerber
8 * 9 *
9 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 10 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 */ 11 */
25 12
26#include <linux/module.h> 13#include <linux/module.h>
@@ -1273,7 +1260,7 @@ static void set_td_timer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
1273 break; 1260 break;
1274 } 1261 }
1275 1262
1276 mod_timer(&r8a66597->td_timer[td->pipenum], 1263 mod_timer(&r8a66597->timers[td->pipenum].td,
1277 jiffies + msecs_to_jiffies(time)); 1264 jiffies + msecs_to_jiffies(time));
1278 } 1265 }
1279} 1266}
@@ -1733,9 +1720,10 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port)
1733 } 1720 }
1734} 1721}
1735 1722
1736static void r8a66597_interval_timer(unsigned long _r8a66597) 1723static void r8a66597_interval_timer(struct timer_list *t)
1737{ 1724{
1738 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; 1725 struct r8a66597_timers *timers = from_timer(timers, t, interval);
1726 struct r8a66597 *r8a66597 = timers->r8a66597;
1739 unsigned long flags; 1727 unsigned long flags;
1740 u16 pipenum; 1728 u16 pipenum;
1741 struct r8a66597_td *td; 1729 struct r8a66597_td *td;
@@ -1745,7 +1733,7 @@ static void r8a66597_interval_timer(unsigned long _r8a66597)
1745 for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { 1733 for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) {
1746 if (!(r8a66597->interval_map & (1 << pipenum))) 1734 if (!(r8a66597->interval_map & (1 << pipenum)))
1747 continue; 1735 continue;
1748 if (timer_pending(&r8a66597->interval_timer[pipenum])) 1736 if (timer_pending(&r8a66597->timers[pipenum].interval))
1749 continue; 1737 continue;
1750 1738
1751 td = r8a66597_get_td(r8a66597, pipenum); 1739 td = r8a66597_get_td(r8a66597, pipenum);
@@ -1756,9 +1744,10 @@ static void r8a66597_interval_timer(unsigned long _r8a66597)
1756 spin_unlock_irqrestore(&r8a66597->lock, flags); 1744 spin_unlock_irqrestore(&r8a66597->lock, flags);
1757} 1745}
1758 1746
1759static void r8a66597_td_timer(unsigned long _r8a66597) 1747static void r8a66597_td_timer(struct timer_list *t)
1760{ 1748{
1761 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; 1749 struct r8a66597_timers *timers = from_timer(timers, t, td);
1750 struct r8a66597 *r8a66597 = timers->r8a66597;
1762 unsigned long flags; 1751 unsigned long flags;
1763 u16 pipenum; 1752 u16 pipenum;
1764 struct r8a66597_td *td, *new_td = NULL; 1753 struct r8a66597_td *td, *new_td = NULL;
@@ -1768,7 +1757,7 @@ static void r8a66597_td_timer(unsigned long _r8a66597)
1768 for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { 1757 for (pipenum = 0; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) {
1769 if (!(r8a66597->timeout_map & (1 << pipenum))) 1758 if (!(r8a66597->timeout_map & (1 << pipenum)))
1770 continue; 1759 continue;
1771 if (timer_pending(&r8a66597->td_timer[pipenum])) 1760 if (timer_pending(&r8a66597->timers[pipenum].td))
1772 continue; 1761 continue;
1773 1762
1774 td = r8a66597_get_td(r8a66597, pipenum); 1763 td = r8a66597_get_td(r8a66597, pipenum);
@@ -1942,7 +1931,7 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd,
1942 if (request) { 1931 if (request) {
1943 if (td->pipe->info.timer_interval) { 1932 if (td->pipe->info.timer_interval) {
1944 r8a66597->interval_map |= 1 << td->pipenum; 1933 r8a66597->interval_map |= 1 << td->pipenum;
1945 mod_timer(&r8a66597->interval_timer[td->pipenum], 1934 mod_timer(&r8a66597->timers[td->pipenum].interval,
1946 jiffies + msecs_to_jiffies( 1935 jiffies + msecs_to_jiffies(
1947 td->pipe->info.timer_interval)); 1936 td->pipe->info.timer_interval));
1948 } else { 1937 } else {
@@ -2495,11 +2484,10 @@ static int r8a66597_probe(struct platform_device *pdev)
2495 2484
2496 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) { 2485 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) {
2497 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]); 2486 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]);
2498 setup_timer(&r8a66597->td_timer[i], r8a66597_td_timer, 2487 r8a66597->timers[i].r8a66597 = r8a66597;
2499 (unsigned long)r8a66597); 2488 timer_setup(&r8a66597->timers[i].td, r8a66597_td_timer, 0);
2500 setup_timer(&r8a66597->interval_timer[i], 2489 timer_setup(&r8a66597->timers[i].interval,
2501 r8a66597_interval_timer, 2490 r8a66597_interval_timer, 0);
2502 (unsigned long)r8a66597);
2503 } 2491 }
2504 INIT_LIST_HEAD(&r8a66597->child_device); 2492 INIT_LIST_HEAD(&r8a66597->child_device);
2505 2493
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index 672cea307abb..51973a923526 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * R8A66597 HCD (Host Controller Driver) 3 * R8A66597 HCD (Host Controller Driver)
3 * 4 *
@@ -7,20 +8,6 @@
7 * Portions Copyright (C) 1999 Roman Weissgaerber 8 * Portions Copyright (C) 1999 Roman Weissgaerber
8 * 9 *
9 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> 10 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 */ 11 */
25 12
26#ifndef __R8A66597_H__ 13#ifndef __R8A66597_H__
@@ -107,6 +94,14 @@ struct r8a66597_root_hub {
107 struct r8a66597_device *dev; 94 struct r8a66597_device *dev;
108}; 95};
109 96
97struct r8a66597;
98
99struct r8a66597_timers {
100 struct timer_list td;
101 struct timer_list interval;
102 struct r8a66597 *r8a66597;
103};
104
110struct r8a66597 { 105struct r8a66597 {
111 spinlock_t lock; 106 spinlock_t lock;
112 void __iomem *reg; 107 void __iomem *reg;
@@ -117,8 +112,7 @@ struct r8a66597 {
117 struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; 112 struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE];
118 113
119 struct timer_list rh_timer; 114 struct timer_list rh_timer;
120 struct timer_list td_timer[R8A66597_MAX_NUM_PIPE]; 115 struct r8a66597_timers timers[R8A66597_MAX_NUM_PIPE];
121 struct timer_list interval_timer[R8A66597_MAX_NUM_PIPE];
122 116
123 unsigned short address_map; 117 unsigned short address_map;
124 unsigned short timeout_map; 118 unsigned short timeout_map;
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 24ad1d6cec25..601fb00603cc 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * SL811HS HCD (Host Controller Driver) for USB. 3 * SL811HS HCD (Host Controller Driver) for USB.
3 * 4 *
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 88a9bffe93df..72136373ffab 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * PCMCIA driver for SL811HS (as found in REX-CFU1U) 3 * PCMCIA driver for SL811HS (as found in REX-CFU1U)
3 * Filename: sl811_cs.c 4 * Filename: sl811_cs.c
diff --git a/drivers/usb/host/ssb-hcd.c b/drivers/usb/host/ssb-hcd.c
index 62b6b7804c66..016987764afb 100644
--- a/drivers/usb/host/ssb-hcd.c
+++ b/drivers/usb/host/ssb-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Sonics Silicon Backplane 3 * Sonics Silicon Backplane
3 * Broadcom USB-core driver (SSB bus glue) 4 * Broadcom USB-core driver (SSB bus glue)
@@ -15,8 +16,6 @@
15 * 16 *
16 * Derived from the USBcore related parts of Broadcom-SB 17 * Derived from the USBcore related parts of Broadcom-SB
17 * Copyright 2005-2011 Broadcom Corporation 18 * Copyright 2005-2011 Broadcom Corporation
18 *
19 * Licensed under the GNU/GPL. See COPYING for details.
20 */ 19 */
21#include <linux/ssb/ssb.h> 20#include <linux/ssb/ssb.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index c38855aed62c..032b8652910a 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* Host Controller Driver for the Elan Digital Systems U132 adapter 3* Host Controller Driver for the Elan Digital Systems U132 adapter
3* 4*
@@ -7,11 +8,6 @@
7* Author and Maintainer - Tony Olech - Elan Digital Systems 8* Author and Maintainer - Tony Olech - Elan Digital Systems
8* tony.olech@elandigitalsystems.com 9* tony.olech@elandigitalsystems.com
9* 10*
10* This program is free software;you can redistribute it and/or
11* modify it under the terms of the GNU General Public License as
12* published by the Free Software Foundation, version 2.
13*
14*
15* This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 11* This driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
16* based on various USB host drivers in the 2.6.15 linux kernel 12* based on various USB host drivers in the 2.6.15 linux kernel
17* with constant reference to the 3rd Edition of Linux Device Drivers 13* with constant reference to the 3rd Edition of Linux Device Drivers
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index c3267a78c94e..babeefd84ffd 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Universal Host Controller Interface driver for USB. 3 * Universal Host Controller Interface driver for USB.
3 * 4 *
diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c
index 773249306031..c5ac9efb076a 100644
--- a/drivers/usb/host/whci/asl.c
+++ b/drivers/usb/host/whci/asl.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) asynchronous schedule management. 3 * Wireless Host Controller (WHC) asynchronous schedule management.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/gfp.h> 8#include <linux/gfp.h>
diff --git a/drivers/usb/host/whci/debug.c b/drivers/usb/host/whci/debug.c
index 774b89d28fae..f154e5791bfd 100644
--- a/drivers/usb/host/whci/debug.c
+++ b/drivers/usb/host/whci/debug.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) debug. 3 * Wireless Host Controller (WHC) debug.
3 * 4 *
4 * Copyright (C) 2008 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/slab.h> 7#include <linux/slab.h>
19#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c
index cf84269c3e6d..8af9dcfea127 100644
--- a/drivers/usb/host/whci/hcd.c
+++ b/drivers/usb/host/whci/hcd.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) driver. 3 * Wireless Host Controller (WHC) driver.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/init.h> 8#include <linux/init.h>
diff --git a/drivers/usb/host/whci/hw.c b/drivers/usb/host/whci/hw.c
index 6afa2e379160..22b3b7f7419d 100644
--- a/drivers/usb/host/whci/hw.c
+++ b/drivers/usb/host/whci/hw.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) hardware access helpers. 3 * Wireless Host Controller (WHC) hardware access helpers.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/dma-mapping.h> 8#include <linux/dma-mapping.h>
diff --git a/drivers/usb/host/whci/init.c b/drivers/usb/host/whci/init.c
index ad8eb575c30a..82416973f773 100644
--- a/drivers/usb/host/whci/init.c
+++ b/drivers/usb/host/whci/init.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) initialization. 3 * Wireless Host Controller (WHC) initialization.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/gfp.h> 8#include <linux/gfp.h>
diff --git a/drivers/usb/host/whci/int.c b/drivers/usb/host/whci/int.c
index 0c086b2790d1..7e4ad1b8f3e3 100644
--- a/drivers/usb/host/whci/int.c
+++ b/drivers/usb/host/whci/int.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) interrupt handling. 3 * Wireless Host Controller (WHC) interrupt handling.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/uwb/umc.h> 8#include <linux/uwb/umc.h>
diff --git a/drivers/usb/host/whci/pzl.c b/drivers/usb/host/whci/pzl.c
index 33c5580b4d25..bb84366f7bd3 100644
--- a/drivers/usb/host/whci/pzl.c
+++ b/drivers/usb/host/whci/pzl.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) periodic schedule management. 3 * Wireless Host Controller (WHC) periodic schedule management.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/gfp.h> 8#include <linux/gfp.h>
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index c0e6812426b3..925166a207aa 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) qset management. 3 * Wireless Host Controller (WHC) qset management.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/dma-mapping.h> 8#include <linux/dma-mapping.h>
diff --git a/drivers/usb/host/whci/whcd.h b/drivers/usb/host/whci/whcd.h
index c80c7d93bc4a..139476997e7c 100644
--- a/drivers/usb/host/whci/whcd.h
+++ b/drivers/usb/host/whci/whcd.h
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) private header. 3 * Wireless Host Controller (WHC) private header.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */ 6 */
20#ifndef __WHCD_H 7#ifndef __WHCD_H
21#define __WHCD_H 8#define __WHCD_H
diff --git a/drivers/usb/host/whci/whci-hc.h b/drivers/usb/host/whci/whci-hc.h
index 4d4cbc0730bf..5a86a57a80cc 100644
--- a/drivers/usb/host/whci/whci-hc.h
+++ b/drivers/usb/host/whci/whci-hc.h
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) data structures. 3 * Wireless Host Controller (WHC) data structures.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */ 6 */
20#ifndef _WHCI_WHCI_HC_H 7#ifndef _WHCI_WHCI_HC_H
21#define _WHCI_WHCI_HC_H 8#define _WHCI_WHCI_HC_H
diff --git a/drivers/usb/host/whci/wusb.c b/drivers/usb/host/whci/wusb.c
index 8d2762682869..8a4d805ff63a 100644
--- a/drivers/usb/host/whci/wusb.c
+++ b/drivers/usb/host/whci/wusb.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless Host Controller (WHC) WUSB operations. 3 * Wireless Host Controller (WHC) WUSB operations.
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/uwb/umc.h> 8#include <linux/uwb/umc.h>
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index 2c83b37ae8f2..584d7b9a3683 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23#include "xhci.h" 11#include "xhci.h"
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
new file mode 100644
index 000000000000..4f7895dbcf88
--- /dev/null
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -0,0 +1,523 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * xhci-debugfs.c - xHCI debugfs interface
4 *
5 * Copyright (C) 2017 Intel Corporation
6 *
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
8 */
9
10#include <linux/slab.h>
11
12#include "xhci.h"
13#include "xhci-debugfs.h"
14
15static const struct debugfs_reg32 xhci_cap_regs[] = {
16 dump_register(CAPLENGTH),
17 dump_register(HCSPARAMS1),
18 dump_register(HCSPARAMS2),
19 dump_register(HCSPARAMS3),
20 dump_register(HCCPARAMS1),
21 dump_register(DOORBELLOFF),
22 dump_register(RUNTIMEOFF),
23 dump_register(HCCPARAMS2),
24};
25
26static const struct debugfs_reg32 xhci_op_regs[] = {
27 dump_register(USBCMD),
28 dump_register(USBSTS),
29 dump_register(PAGESIZE),
30 dump_register(DNCTRL),
31 dump_register(CRCR),
32 dump_register(DCBAAP_LOW),
33 dump_register(DCBAAP_HIGH),
34 dump_register(CONFIG),
35};
36
37static const struct debugfs_reg32 xhci_runtime_regs[] = {
38 dump_register(MFINDEX),
39 dump_register(IR0_IMAN),
40 dump_register(IR0_IMOD),
41 dump_register(IR0_ERSTSZ),
42 dump_register(IR0_ERSTBA_LOW),
43 dump_register(IR0_ERSTBA_HIGH),
44 dump_register(IR0_ERDP_LOW),
45 dump_register(IR0_ERDP_HIGH),
46};
47
48static const struct debugfs_reg32 xhci_extcap_legsup[] = {
49 dump_register(EXTCAP_USBLEGSUP),
50 dump_register(EXTCAP_USBLEGCTLSTS),
51};
52
53static const struct debugfs_reg32 xhci_extcap_protocol[] = {
54 dump_register(EXTCAP_REVISION),
55 dump_register(EXTCAP_NAME),
56 dump_register(EXTCAP_PORTINFO),
57 dump_register(EXTCAP_PORTTYPE),
58 dump_register(EXTCAP_MANTISSA1),
59 dump_register(EXTCAP_MANTISSA2),
60 dump_register(EXTCAP_MANTISSA3),
61 dump_register(EXTCAP_MANTISSA4),
62 dump_register(EXTCAP_MANTISSA5),
63 dump_register(EXTCAP_MANTISSA6),
64};
65
66static const struct debugfs_reg32 xhci_extcap_dbc[] = {
67 dump_register(EXTCAP_DBC_CAPABILITY),
68 dump_register(EXTCAP_DBC_DOORBELL),
69 dump_register(EXTCAP_DBC_ERSTSIZE),
70 dump_register(EXTCAP_DBC_ERST_LOW),
71 dump_register(EXTCAP_DBC_ERST_HIGH),
72 dump_register(EXTCAP_DBC_ERDP_LOW),
73 dump_register(EXTCAP_DBC_ERDP_HIGH),
74 dump_register(EXTCAP_DBC_CONTROL),
75 dump_register(EXTCAP_DBC_STATUS),
76 dump_register(EXTCAP_DBC_PORTSC),
77 dump_register(EXTCAP_DBC_CONT_LOW),
78 dump_register(EXTCAP_DBC_CONT_HIGH),
79 dump_register(EXTCAP_DBC_DEVINFO1),
80 dump_register(EXTCAP_DBC_DEVINFO2),
81};
82
83static struct dentry *xhci_debugfs_root;
84
85static struct xhci_regset *xhci_debugfs_alloc_regset(struct xhci_hcd *xhci)
86{
87 struct xhci_regset *regset;
88
89 regset = kzalloc(sizeof(*regset), GFP_KERNEL);
90 if (!regset)
91 return NULL;
92
93 /*
94 * The allocation and free of regset are executed in order.
95 * We needn't a lock here.
96 */
97 INIT_LIST_HEAD(&regset->list);
98 list_add_tail(&regset->list, &xhci->regset_list);
99
100 return regset;
101}
102
103static void xhci_debugfs_free_regset(struct xhci_regset *regset)
104{
105 if (!regset)
106 return;
107
108 list_del(&regset->list);
109 kfree(regset);
110}
111
112static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base,
113 const struct debugfs_reg32 *regs,
114 size_t nregs, struct dentry *parent,
115 const char *fmt, ...)
116{
117 struct xhci_regset *rgs;
118 va_list args;
119 struct debugfs_regset32 *regset;
120 struct usb_hcd *hcd = xhci_to_hcd(xhci);
121
122 rgs = xhci_debugfs_alloc_regset(xhci);
123 if (!rgs)
124 return;
125
126 va_start(args, fmt);
127 vsnprintf(rgs->name, sizeof(rgs->name), fmt, args);
128 va_end(args);
129
130 regset = &rgs->regset;
131 regset->regs = regs;
132 regset->nregs = nregs;
133 regset->base = hcd->regs + base;
134
135 debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset);
136}
137
138static void xhci_debugfs_extcap_regset(struct xhci_hcd *xhci, int cap_id,
139 const struct debugfs_reg32 *regs,
140 size_t n, const char *cap_name)
141{
142 u32 offset;
143 int index = 0;
144 size_t psic, nregs = n;
145 void __iomem *base = &xhci->cap_regs->hc_capbase;
146
147 offset = xhci_find_next_ext_cap(base, 0, cap_id);
148 while (offset) {
149 if (cap_id == XHCI_EXT_CAPS_PROTOCOL) {
150 psic = XHCI_EXT_PORT_PSIC(readl(base + offset + 8));
151 nregs = min(4 + psic, n);
152 }
153
154 xhci_debugfs_regset(xhci, offset, regs, nregs,
155 xhci->debugfs_root, "%s:%02d",
156 cap_name, index);
157 offset = xhci_find_next_ext_cap(base, offset, cap_id);
158 index++;
159 }
160}
161
162static int xhci_ring_enqueue_show(struct seq_file *s, void *unused)
163{
164 dma_addr_t dma;
165 struct xhci_ring *ring = s->private;
166
167 dma = xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
168 seq_printf(s, "%pad\n", &dma);
169
170 return 0;
171}
172
173static int xhci_ring_dequeue_show(struct seq_file *s, void *unused)
174{
175 dma_addr_t dma;
176 struct xhci_ring *ring = s->private;
177
178 dma = xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
179 seq_printf(s, "%pad\n", &dma);
180
181 return 0;
182}
183
184static int xhci_ring_cycle_show(struct seq_file *s, void *unused)
185{
186 struct xhci_ring *ring = s->private;
187
188 seq_printf(s, "%d\n", ring->cycle_state);
189
190 return 0;
191}
192
193static void xhci_ring_dump_segment(struct seq_file *s,
194 struct xhci_segment *seg)
195{
196 int i;
197 dma_addr_t dma;
198 union xhci_trb *trb;
199
200 for (i = 0; i < TRBS_PER_SEGMENT; i++) {
201 trb = &seg->trbs[i];
202 dma = seg->dma + i * sizeof(*trb);
203 seq_printf(s, "%pad: %s\n", &dma,
204 xhci_decode_trb(trb->generic.field[0],
205 trb->generic.field[1],
206 trb->generic.field[2],
207 trb->generic.field[3]));
208 }
209}
210
211static int xhci_ring_trb_show(struct seq_file *s, void *unused)
212{
213 int i;
214 struct xhci_ring *ring = s->private;
215 struct xhci_segment *seg = ring->first_seg;
216
217 for (i = 0; i < ring->num_segs; i++) {
218 xhci_ring_dump_segment(s, seg);
219 seg = seg->next;
220 }
221
222 return 0;
223}
224
225static struct xhci_file_map ring_files[] = {
226 {"enqueue", xhci_ring_enqueue_show, },
227 {"dequeue", xhci_ring_dequeue_show, },
228 {"cycle", xhci_ring_cycle_show, },
229 {"trbs", xhci_ring_trb_show, },
230};
231
232static int xhci_ring_open(struct inode *inode, struct file *file)
233{
234 int i;
235 struct xhci_file_map *f_map;
236 const char *file_name = file_dentry(file)->d_iname;
237
238 for (i = 0; i < ARRAY_SIZE(ring_files); i++) {
239 f_map = &ring_files[i];
240
241 if (strcmp(f_map->name, file_name) == 0)
242 break;
243 }
244
245 return single_open(file, f_map->show, inode->i_private);
246}
247
248static const struct file_operations xhci_ring_fops = {
249 .open = xhci_ring_open,
250 .read = seq_read,
251 .llseek = seq_lseek,
252 .release = single_release,
253};
254
255static int xhci_slot_context_show(struct seq_file *s, void *unused)
256{
257 struct xhci_hcd *xhci;
258 struct xhci_slot_ctx *slot_ctx;
259 struct xhci_slot_priv *priv = s->private;
260 struct xhci_virt_device *dev = priv->dev;
261
262 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
263 slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
264 seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
265 xhci_decode_slot_context(slot_ctx->dev_info,
266 slot_ctx->dev_info2,
267 slot_ctx->tt_info,
268 slot_ctx->dev_state));
269
270 return 0;
271}
272
273static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
274{
275 int dci;
276 dma_addr_t dma;
277 struct xhci_hcd *xhci;
278 struct xhci_ep_ctx *ep_ctx;
279 struct xhci_slot_priv *priv = s->private;
280 struct xhci_virt_device *dev = priv->dev;
281
282 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
283
284 for (dci = 1; dci < 32; dci++) {
285 ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci);
286 dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params);
287 seq_printf(s, "%pad: %s\n", &dma,
288 xhci_decode_ep_context(ep_ctx->ep_info,
289 ep_ctx->ep_info2,
290 ep_ctx->deq,
291 ep_ctx->tx_info));
292 }
293
294 return 0;
295}
296
297static int xhci_device_name_show(struct seq_file *s, void *unused)
298{
299 struct xhci_slot_priv *priv = s->private;
300 struct xhci_virt_device *dev = priv->dev;
301
302 seq_printf(s, "%s\n", dev_name(&dev->udev->dev));
303
304 return 0;
305}
306
307static struct xhci_file_map context_files[] = {
308 {"name", xhci_device_name_show, },
309 {"slot-context", xhci_slot_context_show, },
310 {"ep-context", xhci_endpoint_context_show, },
311};
312
313static int xhci_context_open(struct inode *inode, struct file *file)
314{
315 int i;
316 struct xhci_file_map *f_map;
317 const char *file_name = file_dentry(file)->d_iname;
318
319 for (i = 0; i < ARRAY_SIZE(context_files); i++) {
320 f_map = &context_files[i];
321
322 if (strcmp(f_map->name, file_name) == 0)
323 break;
324 }
325
326 return single_open(file, f_map->show, inode->i_private);
327}
328
329static const struct file_operations xhci_context_fops = {
330 .open = xhci_context_open,
331 .read = seq_read,
332 .llseek = seq_lseek,
333 .release = single_release,
334};
335
336static void xhci_debugfs_create_files(struct xhci_hcd *xhci,
337 struct xhci_file_map *files,
338 size_t nentries, void *data,
339 struct dentry *parent,
340 const struct file_operations *fops)
341{
342 int i;
343
344 for (i = 0; i < nentries; i++)
345 debugfs_create_file(files[i].name, 0444, parent, data, fops);
346}
347
348static struct dentry *xhci_debugfs_create_ring_dir(struct xhci_hcd *xhci,
349 struct xhci_ring *ring,
350 const char *name,
351 struct dentry *parent)
352{
353 struct dentry *dir;
354
355 dir = debugfs_create_dir(name, parent);
356 xhci_debugfs_create_files(xhci, ring_files, ARRAY_SIZE(ring_files),
357 ring, dir, &xhci_ring_fops);
358
359 return dir;
360}
361
362static void xhci_debugfs_create_context_files(struct xhci_hcd *xhci,
363 struct dentry *parent,
364 int slot_id)
365{
366 struct xhci_virt_device *dev = xhci->devs[slot_id];
367
368 xhci_debugfs_create_files(xhci, context_files,
369 ARRAY_SIZE(context_files),
370 dev->debugfs_private,
371 parent, &xhci_context_fops);
372}
373
374void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
375 struct xhci_virt_device *dev,
376 int ep_index)
377{
378 struct xhci_ep_priv *epriv;
379 struct xhci_slot_priv *spriv = dev->debugfs_private;
380
381 if (spriv->eps[ep_index])
382 return;
383
384 epriv = kzalloc(sizeof(*epriv), GFP_KERNEL);
385 if (!epriv)
386 return;
387
388 snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index);
389 epriv->root = xhci_debugfs_create_ring_dir(xhci,
390 dev->eps[ep_index].new_ring,
391 epriv->name,
392 spriv->root);
393 spriv->eps[ep_index] = epriv;
394}
395
396void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
397 struct xhci_virt_device *dev,
398 int ep_index)
399{
400 struct xhci_ep_priv *epriv;
401 struct xhci_slot_priv *spriv = dev->debugfs_private;
402
403 if (!spriv || !spriv->eps[ep_index])
404 return;
405
406 epriv = spriv->eps[ep_index];
407 debugfs_remove_recursive(epriv->root);
408 spriv->eps[ep_index] = NULL;
409 kfree(epriv);
410}
411
412void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id)
413{
414 struct xhci_slot_priv *priv;
415 struct xhci_virt_device *dev = xhci->devs[slot_id];
416
417 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
418 if (!priv)
419 return;
420
421 snprintf(priv->name, sizeof(priv->name), "%02d", slot_id);
422 priv->root = debugfs_create_dir(priv->name, xhci->debugfs_slots);
423 priv->dev = dev;
424 dev->debugfs_private = priv;
425
426 xhci_debugfs_create_ring_dir(xhci, dev->eps[0].ring,
427 "ep00", priv->root);
428
429 xhci_debugfs_create_context_files(xhci, priv->root, slot_id);
430}
431
432void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id)
433{
434 int i;
435 struct xhci_slot_priv *priv;
436 struct xhci_virt_device *dev = xhci->devs[slot_id];
437
438 if (!dev || !dev->debugfs_private)
439 return;
440
441 priv = dev->debugfs_private;
442
443 debugfs_remove_recursive(priv->root);
444
445 for (i = 0; i < 31; i++)
446 kfree(priv->eps[i]);
447
448 kfree(priv);
449 dev->debugfs_private = NULL;
450}
451
452void xhci_debugfs_init(struct xhci_hcd *xhci)
453{
454 struct device *dev = xhci_to_hcd(xhci)->self.controller;
455
456 xhci->debugfs_root = debugfs_create_dir(dev_name(dev),
457 xhci_debugfs_root);
458
459 INIT_LIST_HEAD(&xhci->regset_list);
460
461 xhci_debugfs_regset(xhci,
462 0,
463 xhci_cap_regs, ARRAY_SIZE(xhci_cap_regs),
464 xhci->debugfs_root, "reg-cap");
465
466 xhci_debugfs_regset(xhci,
467 HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)),
468 xhci_op_regs, ARRAY_SIZE(xhci_op_regs),
469 xhci->debugfs_root, "reg-op");
470
471 xhci_debugfs_regset(xhci,
472 readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK,
473 xhci_runtime_regs, ARRAY_SIZE(xhci_runtime_regs),
474 xhci->debugfs_root, "reg-runtime");
475
476 xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_LEGACY,
477 xhci_extcap_legsup,
478 ARRAY_SIZE(xhci_extcap_legsup),
479 "reg-ext-legsup");
480
481 xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_PROTOCOL,
482 xhci_extcap_protocol,
483 ARRAY_SIZE(xhci_extcap_protocol),
484 "reg-ext-protocol");
485
486 xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_DEBUG,
487 xhci_extcap_dbc,
488 ARRAY_SIZE(xhci_extcap_dbc),
489 "reg-ext-dbc");
490
491 xhci_debugfs_create_ring_dir(xhci, xhci->cmd_ring,
492 "command-ring",
493 xhci->debugfs_root);
494
495 xhci_debugfs_create_ring_dir(xhci, xhci->event_ring,
496 "event-ring",
497 xhci->debugfs_root);
498
499 xhci->debugfs_slots = debugfs_create_dir("devices", xhci->debugfs_root);
500}
501
502void xhci_debugfs_exit(struct xhci_hcd *xhci)
503{
504 struct xhci_regset *rgs, *tmp;
505
506 debugfs_remove_recursive(xhci->debugfs_root);
507 xhci->debugfs_root = NULL;
508 xhci->debugfs_slots = NULL;
509
510 list_for_each_entry_safe(rgs, tmp, &xhci->regset_list, list)
511 xhci_debugfs_free_regset(rgs);
512}
513
514void __init xhci_debugfs_create_root(void)
515{
516 xhci_debugfs_root = debugfs_create_dir("xhci", usb_debug_root);
517}
518
519void __exit xhci_debugfs_remove_root(void)
520{
521 debugfs_remove_recursive(xhci_debugfs_root);
522 xhci_debugfs_root = NULL;
523}
diff --git a/drivers/usb/host/xhci-debugfs.h b/drivers/usb/host/xhci-debugfs.h
new file mode 100644
index 000000000000..ac5bc40f5c3a
--- /dev/null
+++ b/drivers/usb/host/xhci-debugfs.h
@@ -0,0 +1,134 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * xhci-debugfs.h - xHCI debugfs interface
4 *
5 * Copyright (C) 2017 Intel Corporation
6 *
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
8 */
9
10#ifndef __LINUX_XHCI_DEBUGFS_H
11#define __LINUX_XHCI_DEBUGFS_H
12
13#include <linux/debugfs.h>
14
15#define DEBUGFS_NAMELEN 32
16
17#define REG_CAPLENGTH 0x00
18#define REG_HCSPARAMS1 0x04
19#define REG_HCSPARAMS2 0x08
20#define REG_HCSPARAMS3 0x0c
21#define REG_HCCPARAMS1 0x10
22#define REG_DOORBELLOFF 0x14
23#define REG_RUNTIMEOFF 0x18
24#define REG_HCCPARAMS2 0x1c
25
26#define REG_USBCMD 0x00
27#define REG_USBSTS 0x04
28#define REG_PAGESIZE 0x08
29#define REG_DNCTRL 0x14
30#define REG_CRCR 0x18
31#define REG_DCBAAP_LOW 0x30
32#define REG_DCBAAP_HIGH 0x34
33#define REG_CONFIG 0x38
34
35#define REG_MFINDEX 0x00
36#define REG_IR0_IMAN 0x20
37#define REG_IR0_IMOD 0x24
38#define REG_IR0_ERSTSZ 0x28
39#define REG_IR0_ERSTBA_LOW 0x30
40#define REG_IR0_ERSTBA_HIGH 0x34
41#define REG_IR0_ERDP_LOW 0x38
42#define REG_IR0_ERDP_HIGH 0x3c
43
44#define REG_EXTCAP_USBLEGSUP 0x00
45#define REG_EXTCAP_USBLEGCTLSTS 0x04
46
47#define REG_EXTCAP_REVISION 0x00
48#define REG_EXTCAP_NAME 0x04
49#define REG_EXTCAP_PORTINFO 0x08
50#define REG_EXTCAP_PORTTYPE 0x0c
51#define REG_EXTCAP_MANTISSA1 0x10
52#define REG_EXTCAP_MANTISSA2 0x14
53#define REG_EXTCAP_MANTISSA3 0x18
54#define REG_EXTCAP_MANTISSA4 0x1c
55#define REG_EXTCAP_MANTISSA5 0x20
56#define REG_EXTCAP_MANTISSA6 0x24
57
58#define REG_EXTCAP_DBC_CAPABILITY 0x00
59#define REG_EXTCAP_DBC_DOORBELL 0x04
60#define REG_EXTCAP_DBC_ERSTSIZE 0x08
61#define REG_EXTCAP_DBC_ERST_LOW 0x10
62#define REG_EXTCAP_DBC_ERST_HIGH 0x14
63#define REG_EXTCAP_DBC_ERDP_LOW 0x18
64#define REG_EXTCAP_DBC_ERDP_HIGH 0x1c
65#define REG_EXTCAP_DBC_CONTROL 0x20
66#define REG_EXTCAP_DBC_STATUS 0x24
67#define REG_EXTCAP_DBC_PORTSC 0x28
68#define REG_EXTCAP_DBC_CONT_LOW 0x30
69#define REG_EXTCAP_DBC_CONT_HIGH 0x34
70#define REG_EXTCAP_DBC_DEVINFO1 0x38
71#define REG_EXTCAP_DBC_DEVINFO2 0x3c
72
73#define dump_register(nm) \
74{ \
75 .name = __stringify(nm), \
76 .offset = REG_ ##nm, \
77}
78
79struct xhci_regset {
80 char name[DEBUGFS_NAMELEN];
81 struct debugfs_regset32 regset;
82 size_t nregs;
83 struct dentry *parent;
84 struct list_head list;
85};
86
87struct xhci_file_map {
88 const char *name;
89 int (*show)(struct seq_file *s, void *unused);
90};
91
92struct xhci_ep_priv {
93 char name[DEBUGFS_NAMELEN];
94 struct dentry *root;
95};
96
97struct xhci_slot_priv {
98 char name[DEBUGFS_NAMELEN];
99 struct dentry *root;
100 struct xhci_ep_priv *eps[31];
101 struct xhci_virt_device *dev;
102};
103
104#ifdef CONFIG_DEBUG_FS
105void xhci_debugfs_init(struct xhci_hcd *xhci);
106void xhci_debugfs_exit(struct xhci_hcd *xhci);
107void __init xhci_debugfs_create_root(void);
108void __exit xhci_debugfs_remove_root(void);
109void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id);
110void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id);
111void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
112 struct xhci_virt_device *virt_dev,
113 int ep_index);
114void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
115 struct xhci_virt_device *virt_dev,
116 int ep_index);
117#else
118static inline void xhci_debugfs_init(struct xhci_hcd *xhci) { }
119static inline void xhci_debugfs_exit(struct xhci_hcd *xhci) { }
120static inline void __init xhci_debugfs_create_root(void) { }
121static inline void __exit xhci_debugfs_remove_root(void) { }
122static inline void xhci_debugfs_create_slot(struct xhci_hcd *x, int s) { }
123static inline void xhci_debugfs_remove_slot(struct xhci_hcd *x, int s) { }
124static inline void
125xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
126 struct xhci_virt_device *virt_dev,
127 int ep_index) { }
128static inline void
129xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
130 struct xhci_virt_device *virt_dev,
131 int ep_index) { }
132#endif /* CONFIG_DEBUG_FS */
133
134#endif /* __LINUX_XHCI_DEBUGFS_H */
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index 28deea584884..bf7316e130d3 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22/* Up to 16 ms to halt an HC */ 10/* Up to 16 ms to halt an HC */
23#define XHCI_MAX_HALT_USEC (16*1000) 11#define XHCI_MAX_HALT_USEC (16*1000)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a2336deb5e36..2a90229be7a6 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23 11
@@ -634,7 +622,10 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
634 xhci_dbg(xhci, "Disable all slots\n"); 622 xhci_dbg(xhci, "Disable all slots\n");
635 spin_unlock_irqrestore(&xhci->lock, *flags); 623 spin_unlock_irqrestore(&xhci->lock, *flags);
636 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { 624 for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
637 retval = xhci_disable_slot(xhci, NULL, i); 625 if (!xhci->devs[i])
626 continue;
627
628 retval = xhci_disable_slot(xhci, i);
638 if (retval) 629 if (retval)
639 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", 630 xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n",
640 i, retval); 631 i, retval);
@@ -1374,6 +1365,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1374 break; 1365 break;
1375 case USB_PORT_FEAT_C_SUSPEND: 1366 case USB_PORT_FEAT_C_SUSPEND:
1376 bus_state->port_c_suspend &= ~(1 << wIndex); 1367 bus_state->port_c_suspend &= ~(1 << wIndex);
1368 /* fall through */
1377 case USB_PORT_FEAT_C_RESET: 1369 case USB_PORT_FEAT_C_RESET:
1378 case USB_PORT_FEAT_C_BH_PORT_RESET: 1370 case USB_PORT_FEAT_C_BH_PORT_RESET:
1379 case USB_PORT_FEAT_C_CONNECTION: 1371 case USB_PORT_FEAT_C_CONNECTION:
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2a82c927ded2..e1fba4688509 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23#include <linux/usb.h> 11#include <linux/usb.h>
@@ -28,6 +16,7 @@
28 16
29#include "xhci.h" 17#include "xhci.h"
30#include "xhci-trace.h" 18#include "xhci-trace.h"
19#include "xhci-debugfs.h"
31 20
32/* 21/*
33 * Allocates a generic ring segment from the ring pool, sets the dma address, 22 * Allocates a generic ring segment from the ring pool, sets the dma address,
@@ -465,8 +454,6 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
465 return 0; 454 return 0;
466} 455}
467 456
468#define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
469
470static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, 457static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
471 int type, gfp_t flags) 458 int type, gfp_t flags)
472{ 459{
@@ -801,8 +788,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
801static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, 788static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
802 struct xhci_virt_ep *ep) 789 struct xhci_virt_ep *ep)
803{ 790{
804 setup_timer(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog, 791 timer_setup(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
805 (unsigned long)ep); 792 0);
806 ep->xhci = xhci; 793 ep->xhci = xhci;
807} 794}
808 795
@@ -961,6 +948,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
961 } 948 }
962 } 949 }
963 /* we are now at a leaf device */ 950 /* we are now at a leaf device */
951 xhci_debugfs_remove_slot(xhci, slot_id);
964 xhci_free_virt_device(xhci, slot_id); 952 xhci_free_virt_device(xhci, slot_id);
965} 953}
966 954
@@ -1311,6 +1299,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1311 * since it uses the same rules as low speed interrupt 1299 * since it uses the same rules as low speed interrupt
1312 * endpoints. 1300 * endpoints.
1313 */ 1301 */
1302 /* fall through */
1314 1303
1315 case USB_SPEED_LOW: 1304 case USB_SPEED_LOW:
1316 if (usb_endpoint_xfer_int(&ep->desc) || 1305 if (usb_endpoint_xfer_int(&ep->desc) ||
@@ -1496,7 +1485,6 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1496 ep_ctx->tx_info = cpu_to_le32(EP_MAX_ESIT_PAYLOAD_LO(max_esit_payload) | 1485 ep_ctx->tx_info = cpu_to_le32(EP_MAX_ESIT_PAYLOAD_LO(max_esit_payload) |
1497 EP_AVG_TRB_LENGTH(avg_trb_len)); 1486 EP_AVG_TRB_LENGTH(avg_trb_len));
1498 1487
1499 /* FIXME Debug endpoint context */
1500 return 0; 1488 return 0;
1501} 1489}
1502 1490
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 6e7ddf6cafae..eea7360a18fc 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2015 MediaTek Inc. 3 * Copyright (c) 2015 MediaTek Inc.
3 * Author: 4 * Author:
4 * Zhigang.Wei <zhigang.wei@mediatek.com> 5 * Zhigang.Wei <zhigang.wei@mediatek.com>
5 * Chunfeng.Yun <chunfeng.yun@mediatek.com> 6 * Chunfeng.Yun <chunfeng.yun@mediatek.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */ 7 */
17 8
18#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -287,12 +278,13 @@ static bool need_bw_sch(struct usb_host_endpoint *ep,
287 278
288int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk) 279int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk)
289{ 280{
281 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
290 struct mu3h_sch_bw_info *sch_array; 282 struct mu3h_sch_bw_info *sch_array;
291 int num_usb_bus; 283 int num_usb_bus;
292 int i; 284 int i;
293 285
294 /* ss IN and OUT are separated */ 286 /* ss IN and OUT are separated */
295 num_usb_bus = mtk->num_u3_ports * 2 + mtk->num_u2_ports; 287 num_usb_bus = xhci->num_usb3_ports * 2 + xhci->num_usb2_ports;
296 288
297 sch_array = kcalloc(num_usb_bus, sizeof(*sch_array), GFP_KERNEL); 289 sch_array = kcalloc(num_usb_bus, sizeof(*sch_array), GFP_KERNEL);
298 if (sch_array == NULL) 290 if (sch_array == NULL)
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8fb60657ed4f..b62a1d23244b 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MediaTek xHCI Host Controller Driver 3 * MediaTek xHCI Host Controller Driver
3 * 4 *
4 * Copyright (c) 2015 MediaTek Inc. 5 * Copyright (c) 2015 MediaTek Inc.
5 * Author: 6 * Author:
6 * Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include <linux/clk.h> 10#include <linux/clk.h>
@@ -43,6 +34,7 @@
43 34
44/* ip_pw_sts1 register */ 35/* ip_pw_sts1 register */
45#define STS1_IP_SLEEP_STS BIT(30) 36#define STS1_IP_SLEEP_STS BIT(30)
37#define STS1_U3_MAC_RST BIT(16)
46#define STS1_XHCI_RST BIT(11) 38#define STS1_XHCI_RST BIT(11)
47#define STS1_SYS125_RST BIT(10) 39#define STS1_SYS125_RST BIT(10)
48#define STS1_REF_RST BIT(8) 40#define STS1_REF_RST BIT(8)
@@ -91,6 +83,7 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
91{ 83{
92 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; 84 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs;
93 u32 value, check_val; 85 u32 value, check_val;
86 int u3_ports_disabed = 0;
94 int ret; 87 int ret;
95 int i; 88 int i;
96 89
@@ -102,8 +95,13 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
102 value &= ~CTRL1_IP_HOST_PDN; 95 value &= ~CTRL1_IP_HOST_PDN;
103 writel(value, &ippc->ip_pw_ctr1); 96 writel(value, &ippc->ip_pw_ctr1);
104 97
105 /* power on and enable all u3 ports */ 98 /* power on and enable u3 ports except skipped ones */
106 for (i = 0; i < mtk->num_u3_ports; i++) { 99 for (i = 0; i < mtk->num_u3_ports; i++) {
100 if ((0x1 << i) & mtk->u3p_dis_msk) {
101 u3_ports_disabed++;
102 continue;
103 }
104
107 value = readl(&ippc->u3_ctrl_p[i]); 105 value = readl(&ippc->u3_ctrl_p[i]);
108 value &= ~(CTRL_U3_PORT_PDN | CTRL_U3_PORT_DIS); 106 value &= ~(CTRL_U3_PORT_PDN | CTRL_U3_PORT_DIS);
109 value |= CTRL_U3_PORT_HOST_SEL; 107 value |= CTRL_U3_PORT_HOST_SEL;
@@ -125,6 +123,9 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
125 check_val = STS1_SYSPLL_STABLE | STS1_REF_RST | 123 check_val = STS1_SYSPLL_STABLE | STS1_REF_RST |
126 STS1_SYS125_RST | STS1_XHCI_RST; 124 STS1_SYS125_RST | STS1_XHCI_RST;
127 125
126 if (mtk->num_u3_ports > u3_ports_disabed)
127 check_val |= STS1_U3_MAC_RST;
128
128 ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, 129 ret = readl_poll_timeout(&ippc->ip_pw_sts1, value,
129 (check_val == (value & check_val)), 100, 20000); 130 (check_val == (value & check_val)), 100, 20000);
130 if (ret) { 131 if (ret) {
@@ -145,8 +146,11 @@ static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk)
145 if (!mtk->has_ippc) 146 if (!mtk->has_ippc)
146 return 0; 147 return 0;
147 148
148 /* power down all u3 ports */ 149 /* power down u3 ports except skipped ones */
149 for (i = 0; i < mtk->num_u3_ports; i++) { 150 for (i = 0; i < mtk->num_u3_ports; i++) {
151 if ((0x1 << i) & mtk->u3p_dis_msk)
152 continue;
153
150 value = readl(&ippc->u3_ctrl_p[i]); 154 value = readl(&ippc->u3_ctrl_p[i]);
151 value |= CTRL_U3_PORT_PDN; 155 value |= CTRL_U3_PORT_PDN;
152 writel(value, &ippc->u3_ctrl_p[i]); 156 writel(value, &ippc->u3_ctrl_p[i]);
@@ -208,6 +212,41 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
208 return xhci_mtk_host_enable(mtk); 212 return xhci_mtk_host_enable(mtk);
209} 213}
210 214
215/* ignore the error if the clock does not exist */
216static struct clk *optional_clk_get(struct device *dev, const char *id)
217{
218 struct clk *opt_clk;
219
220 opt_clk = devm_clk_get(dev, id);
221 /* ignore error number except EPROBE_DEFER */
222 if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
223 opt_clk = NULL;
224
225 return opt_clk;
226}
227
228static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
229{
230 struct device *dev = mtk->dev;
231
232 mtk->sys_clk = devm_clk_get(dev, "sys_ck");
233 if (IS_ERR(mtk->sys_clk)) {
234 dev_err(dev, "fail to get sys_ck\n");
235 return PTR_ERR(mtk->sys_clk);
236 }
237
238 mtk->ref_clk = optional_clk_get(dev, "ref_ck");
239 if (IS_ERR(mtk->ref_clk))
240 return PTR_ERR(mtk->ref_clk);
241
242 mtk->mcu_clk = optional_clk_get(dev, "mcu_ck");
243 if (IS_ERR(mtk->mcu_clk))
244 return PTR_ERR(mtk->mcu_clk);
245
246 mtk->dma_clk = optional_clk_get(dev, "dma_ck");
247 return PTR_ERR_OR_ZERO(mtk->dma_clk);
248}
249
211static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) 250static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
212{ 251{
213 int ret; 252 int ret;
@@ -224,37 +263,34 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
224 goto sys_clk_err; 263 goto sys_clk_err;
225 } 264 }
226 265
227 if (mtk->wakeup_src) { 266 ret = clk_prepare_enable(mtk->mcu_clk);
228 ret = clk_prepare_enable(mtk->wk_deb_p0); 267 if (ret) {
229 if (ret) { 268 dev_err(mtk->dev, "failed to enable mcu_clk\n");
230 dev_err(mtk->dev, "failed to enable wk_deb_p0\n"); 269 goto mcu_clk_err;
231 goto usb_p0_err; 270 }
232 }
233 271
234 ret = clk_prepare_enable(mtk->wk_deb_p1); 272 ret = clk_prepare_enable(mtk->dma_clk);
235 if (ret) { 273 if (ret) {
236 dev_err(mtk->dev, "failed to enable wk_deb_p1\n"); 274 dev_err(mtk->dev, "failed to enable dma_clk\n");
237 goto usb_p1_err; 275 goto dma_clk_err;
238 }
239 } 276 }
277
240 return 0; 278 return 0;
241 279
242usb_p1_err: 280dma_clk_err:
243 clk_disable_unprepare(mtk->wk_deb_p0); 281 clk_disable_unprepare(mtk->mcu_clk);
244usb_p0_err: 282mcu_clk_err:
245 clk_disable_unprepare(mtk->sys_clk); 283 clk_disable_unprepare(mtk->sys_clk);
246sys_clk_err: 284sys_clk_err:
247 clk_disable_unprepare(mtk->ref_clk); 285 clk_disable_unprepare(mtk->ref_clk);
248ref_clk_err: 286ref_clk_err:
249 return -EINVAL; 287 return ret;
250} 288}
251 289
252static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) 290static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
253{ 291{
254 if (mtk->wakeup_src) { 292 clk_disable_unprepare(mtk->dma_clk);
255 clk_disable_unprepare(mtk->wk_deb_p1); 293 clk_disable_unprepare(mtk->mcu_clk);
256 clk_disable_unprepare(mtk->wk_deb_p0);
257 }
258 clk_disable_unprepare(mtk->sys_clk); 294 clk_disable_unprepare(mtk->sys_clk);
259 clk_disable_unprepare(mtk->ref_clk); 295 clk_disable_unprepare(mtk->ref_clk);
260} 296}
@@ -358,18 +394,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk,
358 if (!mtk->wakeup_src) 394 if (!mtk->wakeup_src)
359 return 0; 395 return 0;
360 396
361 mtk->wk_deb_p0 = devm_clk_get(dev, "wakeup_deb_p0");
362 if (IS_ERR(mtk->wk_deb_p0)) {
363 dev_err(dev, "fail to get wakeup_deb_p0\n");
364 return PTR_ERR(mtk->wk_deb_p0);
365 }
366
367 mtk->wk_deb_p1 = devm_clk_get(dev, "wakeup_deb_p1");
368 if (IS_ERR(mtk->wk_deb_p1)) {
369 dev_err(dev, "fail to get wakeup_deb_p1\n");
370 return PTR_ERR(mtk->wk_deb_p1);
371 }
372
373 mtk->pericfg = syscon_regmap_lookup_by_phandle(dn, 397 mtk->pericfg = syscon_regmap_lookup_by_phandle(dn,
374 "mediatek,syscon-wakeup"); 398 "mediatek,syscon-wakeup");
375 if (IS_ERR(mtk->pericfg)) { 399 if (IS_ERR(mtk->pericfg)) {
@@ -492,7 +516,6 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
492/* called during probe() after chip reset completes */ 516/* called during probe() after chip reset completes */
493static int xhci_mtk_setup(struct usb_hcd *hcd) 517static int xhci_mtk_setup(struct usb_hcd *hcd)
494{ 518{
495 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
496 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); 519 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
497 int ret; 520 int ret;
498 521
@@ -507,8 +530,6 @@ static int xhci_mtk_setup(struct usb_hcd *hcd)
507 return ret; 530 return ret;
508 531
509 if (usb_hcd_is_primary_hcd(hcd)) { 532 if (usb_hcd_is_primary_hcd(hcd)) {
510 mtk->num_u3_ports = xhci->num_usb3_ports;
511 mtk->num_u2_ports = xhci->num_usb2_ports;
512 ret = xhci_mtk_sch_init(mtk); 533 ret = xhci_mtk_sch_init(mtk);
513 if (ret) 534 if (ret)
514 return ret; 535 return ret;
@@ -552,26 +573,14 @@ static int xhci_mtk_probe(struct platform_device *pdev)
552 return PTR_ERR(mtk->vusb33); 573 return PTR_ERR(mtk->vusb33);
553 } 574 }
554 575
555 mtk->sys_clk = devm_clk_get(dev, "sys_ck"); 576 ret = xhci_mtk_clks_get(mtk);
556 if (IS_ERR(mtk->sys_clk)) { 577 if (ret)
557 dev_err(dev, "fail to get sys_ck\n"); 578 return ret;
558 return PTR_ERR(mtk->sys_clk);
559 }
560
561 /*
562 * reference clock is usually a "fixed-clock", make it optional
563 * for backward compatibility and ignore the error if it does
564 * not exist.
565 */
566 mtk->ref_clk = devm_clk_get(dev, "ref_ck");
567 if (IS_ERR(mtk->ref_clk)) {
568 if (PTR_ERR(mtk->ref_clk) == -EPROBE_DEFER)
569 return -EPROBE_DEFER;
570
571 mtk->ref_clk = NULL;
572 }
573 579
574 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); 580 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
581 /* optional property, ignore the error if it does not exist */
582 of_property_read_u32(node, "mediatek,u3p-dis-msk",
583 &mtk->u3p_dis_msk);
575 584
576 ret = usb_wakeup_of_property_parse(mtk, node); 585 ret = usb_wakeup_of_property_parse(mtk, node);
577 if (ret) 586 if (ret)
@@ -606,15 +615,10 @@ static int xhci_mtk_probe(struct platform_device *pdev)
606 } 615 }
607 616
608 /* Initialize dma_mask and coherent_dma_mask to 32-bits */ 617 /* Initialize dma_mask and coherent_dma_mask to 32-bits */
609 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); 618 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
610 if (ret) 619 if (ret)
611 goto disable_clk; 620 goto disable_clk;
612 621
613 if (!dev->dma_mask)
614 dev->dma_mask = &dev->coherent_dma_mask;
615 else
616 dma_set_mask(dev, DMA_BIT_MASK(32));
617
618 hcd = usb_create_hcd(driver, dev, dev_name(dev)); 622 hcd = usb_create_hcd(driver, dev, dev_name(dev));
619 if (!hcd) { 623 if (!hcd) {
620 ret = -ENOMEM; 624 ret = -ENOMEM;
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 3aa5e1d25064..6b74ce5b7564 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2015 MediaTek Inc. 3 * Copyright (c) 2015 MediaTek Inc.
3 * Author: 4 * Author:
4 * Zhigang.Wei <zhigang.wei@mediatek.com> 5 * Zhigang.Wei <zhigang.wei@mediatek.com>
5 * Chunfeng.Yun <chunfeng.yun@mediatek.com> 6 * Chunfeng.Yun <chunfeng.yun@mediatek.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */ 7 */
17 8
18#ifndef _XHCI_MTK_H_ 9#ifndef _XHCI_MTK_H_
@@ -121,12 +112,13 @@ struct xhci_hcd_mtk {
121 bool has_ippc; 112 bool has_ippc;
122 int num_u2_ports; 113 int num_u2_ports;
123 int num_u3_ports; 114 int num_u3_ports;
115 int u3p_dis_msk;
124 struct regulator *vusb33; 116 struct regulator *vusb33;
125 struct regulator *vbus; 117 struct regulator *vbus;
126 struct clk *sys_clk; /* sys and mac clock */ 118 struct clk *sys_clk; /* sys and mac clock */
127 struct clk *ref_clk; 119 struct clk *ref_clk;
128 struct clk *wk_deb_p0; /* port0's wakeup debounce clock */ 120 struct clk *mcu_clk;
129 struct clk *wk_deb_p1; 121 struct clk *dma_clk;
130 struct regmap *pericfg; 122 struct regmap *pericfg;
131 struct phy **phys; 123 struct phy **phys;
132 int num_phys; 124 int num_phys;
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 85908a3ecb8f..32e158568788 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Marvell 3 * Copyright (C) 2014 Marvell
3 * Author: Gregory CLEMENT <gregory.clement@free-electrons.com> 4 * Author: Gregory CLEMENT <gregory.clement@free-electrons.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 */ 5 */
9 6
10#include <linux/io.h> 7#include <linux/io.h>
diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h
index 301fc984cae6..09791df2cec0 100644
--- a/drivers/usb/host/xhci-mvebu.h
+++ b/drivers/usb/host/xhci-mvebu.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Marvell 3 * Copyright (C) 2014 Marvell
3 * 4 *
4 * Gregory Clement <gregory.clement@free-electrons.com> 5 * Gregory Clement <gregory.clement@free-electrons.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */ 6 */
10 7
11#ifndef __LINUX_XHCI_MVEBU_H 8#ifndef __LINUX_XHCI_MVEBU_H
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 76f392954733..7ef1274ef7f7 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver PCI Bus Glue. 3 * xHCI host controller driver PCI Bus Glue.
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23#include <linux/pci.h> 11#include <linux/pci.h>
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 1cb6eaef4ae1..09f164f8cf8c 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xhci-plat.c - xHCI host controller driver platform Bus Glue. 3 * xhci-plat.c - xHCI host controller driver platform Bus Glue.
3 * 4 *
@@ -5,10 +6,6 @@
5 * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> 6 * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
6 * 7 *
7 * A lot of code borrowed from the Linux xHCI driver. 8 * A lot of code borrowed from the Linux xHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */ 9 */
13 10
14#include <linux/clk.h> 11#include <linux/clk.h>
@@ -16,6 +13,7 @@
16#include <linux/module.h> 13#include <linux/module.h>
17#include <linux/pci.h> 14#include <linux/pci.h>
18#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h>
19#include <linux/platform_device.h> 17#include <linux/platform_device.h>
20#include <linux/usb/phy.h> 18#include <linux/usb/phy.h>
21#include <linux/slab.h> 19#include <linux/slab.h>
@@ -152,7 +150,7 @@ MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
152 150
153static int xhci_plat_probe(struct platform_device *pdev) 151static int xhci_plat_probe(struct platform_device *pdev)
154{ 152{
155 const struct of_device_id *match; 153 const struct xhci_plat_priv *priv_match;
156 const struct hc_driver *driver; 154 const struct hc_driver *driver;
157 struct device *sysdev; 155 struct device *sysdev;
158 struct xhci_hcd *xhci; 156 struct xhci_hcd *xhci;
@@ -242,9 +240,8 @@ static int xhci_plat_probe(struct platform_device *pdev)
242 } 240 }
243 241
244 xhci = hcd_to_xhci(hcd); 242 xhci = hcd_to_xhci(hcd);
245 match = of_match_node(usb_xhci_of_match, pdev->dev.of_node); 243 priv_match = of_device_get_match_data(&pdev->dev);
246 if (match) { 244 if (priv_match) {
247 const struct xhci_plat_priv *priv_match = match->data;
248 struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); 245 struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
249 246
250 /* Just copy data for now */ 247 /* Just copy data for now */
@@ -263,6 +260,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
263 goto disable_clk; 260 goto disable_clk;
264 } 261 }
265 262
263 if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
264 xhci->quirks |= XHCI_HW_LPM_DISABLE;
265
266 if (device_property_read_bool(sysdev, "usb3-lpm-capable")) 266 if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
267 xhci->quirks |= XHCI_LPM_SUPPORT; 267 xhci->quirks |= XHCI_LPM_SUPPORT;
268 268
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index 29b227895b07..ae29f22ff5bd 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xhci-plat.h - xHCI host controller driver platform Bus Glue. 3 * xhci-plat.h - xHCI host controller driver platform Bus Glue.
3 * 4 *
4 * Copyright (C) 2015 Renesas Electronics Corporation 5 * Copyright (C) 2015 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#ifndef _XHCI_PLAT_H 8#ifndef _XHCI_PLAT_H
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index 198bc188ab25..f0b559660007 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver for R-Car SoCs 3 * xHCI host controller driver for R-Car SoCs
3 * 4 *
4 * Copyright (C) 2014 Renesas Electronics Corporation 5 * Copyright (C) 2014 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/firmware.h> 8#include <linux/firmware.h>
diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h
index d247951147a1..804b6ab4246f 100644
--- a/drivers/usb/host/xhci-rcar.h
+++ b/drivers/usb/host/xhci-rcar.h
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/host/xhci-rcar.h 3 * drivers/usb/host/xhci-rcar.h
3 * 4 *
4 * Copyright (C) 2014 Renesas Electronics Corporation 5 * Copyright (C) 2014 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#ifndef _XHCI_RCAR_H 8#ifndef _XHCI_RCAR_H
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 82c746e2d85c..c239c688076c 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23/* 11/*
@@ -171,13 +159,13 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring)
171 if (ring->type == TYPE_EVENT) { 159 if (ring->type == TYPE_EVENT) {
172 if (!last_trb_on_seg(ring->deq_seg, ring->dequeue)) { 160 if (!last_trb_on_seg(ring->deq_seg, ring->dequeue)) {
173 ring->dequeue++; 161 ring->dequeue++;
174 return; 162 goto out;
175 } 163 }
176 if (last_trb_on_ring(ring, ring->deq_seg, ring->dequeue)) 164 if (last_trb_on_ring(ring, ring->deq_seg, ring->dequeue))
177 ring->cycle_state ^= 1; 165 ring->cycle_state ^= 1;
178 ring->deq_seg = ring->deq_seg->next; 166 ring->deq_seg = ring->deq_seg->next;
179 ring->dequeue = ring->deq_seg->trbs; 167 ring->dequeue = ring->deq_seg->trbs;
180 return; 168 goto out;
181 } 169 }
182 170
183 /* All other rings have link trbs */ 171 /* All other rings have link trbs */
@@ -190,6 +178,7 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring)
190 ring->dequeue = ring->deq_seg->trbs; 178 ring->dequeue = ring->deq_seg->trbs;
191 } 179 }
192 180
181out:
193 trace_xhci_inc_deq(ring); 182 trace_xhci_inc_deq(ring);
194 183
195 return; 184 return;
@@ -946,15 +935,12 @@ void xhci_hc_died(struct xhci_hcd *xhci)
946 * Instead we use a combination of that flag and checking if a new timer is 935 * Instead we use a combination of that flag and checking if a new timer is
947 * pending. 936 * pending.
948 */ 937 */
949void xhci_stop_endpoint_command_watchdog(unsigned long arg) 938void xhci_stop_endpoint_command_watchdog(struct timer_list *t)
950{ 939{
951 struct xhci_hcd *xhci; 940 struct xhci_virt_ep *ep = from_timer(ep, t, stop_cmd_timer);
952 struct xhci_virt_ep *ep; 941 struct xhci_hcd *xhci = ep->xhci;
953 unsigned long flags; 942 unsigned long flags;
954 943
955 ep = (struct xhci_virt_ep *) arg;
956 xhci = ep->xhci;
957
958 spin_lock_irqsave(&xhci->lock, flags); 944 spin_lock_irqsave(&xhci->lock, flags);
959 945
960 /* bail out if cmd completed but raced with stop ep watchdog timer.*/ 946 /* bail out if cmd completed but raced with stop ep watchdog timer.*/
@@ -1680,9 +1666,14 @@ static void handle_port_status(struct xhci_hcd *xhci,
1680 bus_state->resume_done[faked_port_index] = jiffies + 1666 bus_state->resume_done[faked_port_index] = jiffies +
1681 msecs_to_jiffies(USB_RESUME_TIMEOUT); 1667 msecs_to_jiffies(USB_RESUME_TIMEOUT);
1682 set_bit(faked_port_index, &bus_state->resuming_ports); 1668 set_bit(faked_port_index, &bus_state->resuming_ports);
1669 /* Do the rest in GetPortStatus after resume time delay.
1670 * Avoid polling roothub status before that so that a
1671 * usb device auto-resume latency around ~40ms.
1672 */
1673 set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1683 mod_timer(&hcd->rh_timer, 1674 mod_timer(&hcd->rh_timer,
1684 bus_state->resume_done[faked_port_index]); 1675 bus_state->resume_done[faked_port_index]);
1685 /* Do the rest in GetPortStatus */ 1676 bogus_port_status = true;
1686 } 1677 }
1687 } 1678 }
1688 1679
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 74436f8ca538..2c076ea80522 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * NVIDIA Tegra xHCI host controller driver 3 * NVIDIA Tegra xHCI host controller driver
3 * 4 *
4 * Copyright (C) 2014 NVIDIA Corporation 5 * Copyright (C) 2014 NVIDIA Corporation
5 * Copyright (C) 2014 Google, Inc. 6 * Copyright (C) 2014 Google, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/clk.h> 9#include <linux/clk.h>
@@ -771,7 +768,7 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
771 struct device *dev = tegra->dev; 768 struct device *dev = tegra->dev;
772 const struct firmware *fw; 769 const struct firmware *fw;
773 unsigned long timeout; 770 unsigned long timeout;
774 time_t timestamp; 771 time64_t timestamp;
775 struct tm time; 772 struct tm time;
776 u64 address; 773 u64 address;
777 u32 value; 774 u32 value;
@@ -877,7 +874,7 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
877 } 874 }
878 875
879 timestamp = le32_to_cpu(header->fwimg_created_time); 876 timestamp = le32_to_cpu(header->fwimg_created_time);
880 time_to_tm(timestamp, 0, &time); 877 time64_to_tm(timestamp, 0, &time);
881 878
882 dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n", 879 dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n",
883 time.tm_year + 1900, time.tm_mon + 1, time.tm_mday, 880 time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
diff --git a/drivers/usb/host/xhci-trace.c b/drivers/usb/host/xhci-trace.c
index 367b630bdb3c..d0070814d1ea 100644
--- a/drivers/usb/host/xhci-trace.c
+++ b/drivers/usb/host/xhci-trace.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Author: Xenia Ragiadakou 7 * Author: Xenia Ragiadakou
7 * Email : burzalodowa@gmail.com 8 * Email : burzalodowa@gmail.com
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */ 9 */
13 10
14#define CREATE_TRACE_POINTS 11#define CREATE_TRACE_POINTS
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index f20753b99624..a3b57c781db1 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Author: Xenia Ragiadakou 7 * Author: Xenia Ragiadakou
7 * Email : burzalodowa@gmail.com 8 * Email : burzalodowa@gmail.com
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */ 9 */
13 10
14#undef TRACE_SYSTEM 11#undef TRACE_SYSTEM
@@ -388,6 +385,11 @@ DEFINE_EVENT(xhci_log_slot_ctx, xhci_handle_cmd_set_deq,
388 TP_ARGS(ctx) 385 TP_ARGS(ctx)
389); 386);
390 387
388DEFINE_EVENT(xhci_log_slot_ctx, xhci_configure_endpoint,
389 TP_PROTO(struct xhci_slot_ctx *ctx),
390 TP_ARGS(ctx)
391);
392
391DECLARE_EVENT_CLASS(xhci_log_ring, 393DECLARE_EVENT_CLASS(xhci_log_ring,
392 TP_PROTO(struct xhci_ring *ring), 394 TP_PROTO(struct xhci_ring *ring),
393 TP_ARGS(ring), 395 TP_ARGS(ring),
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 51535ba2bcd4..327ba8b8a98b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * xHCI host controller driver 3 * xHCI host controller driver
3 * 4 *
@@ -5,19 +6,6 @@
5 * 6 *
6 * Author: Sarah Sharp 7 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver. 8 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 9 */
22 10
23#include <linux/pci.h> 11#include <linux/pci.h>
@@ -32,6 +20,7 @@
32#include "xhci.h" 20#include "xhci.h"
33#include "xhci-trace.h" 21#include "xhci-trace.h"
34#include "xhci-mtk.h" 22#include "xhci-mtk.h"
23#include "xhci-debugfs.h"
35 24
36#define DRIVER_AUTHOR "Sarah Sharp" 25#define DRIVER_AUTHOR "Sarah Sharp"
37#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver" 26#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
@@ -632,6 +621,9 @@ int xhci_run(struct usb_hcd *hcd)
632 } 621 }
633 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 622 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
634 "Finished xhci_run for USB2 roothub"); 623 "Finished xhci_run for USB2 roothub");
624
625 xhci_debugfs_init(xhci);
626
635 return 0; 627 return 0;
636} 628}
637EXPORT_SYMBOL_GPL(xhci_run); 629EXPORT_SYMBOL_GPL(xhci_run);
@@ -660,6 +652,8 @@ static void xhci_stop(struct usb_hcd *hcd)
660 return; 652 return;
661 } 653 }
662 654
655 xhci_debugfs_exit(xhci);
656
663 spin_lock_irq(&xhci->lock); 657 spin_lock_irq(&xhci->lock);
664 xhci->xhc_state |= XHCI_STATE_HALTED; 658 xhci->xhc_state |= XHCI_STATE_HALTED;
665 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 659 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
@@ -1600,6 +1594,8 @@ static int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1600 ctrl_ctx->add_flags &= cpu_to_le32(~drop_flag); 1594 ctrl_ctx->add_flags &= cpu_to_le32(~drop_flag);
1601 new_add_flags = le32_to_cpu(ctrl_ctx->add_flags); 1595 new_add_flags = le32_to_cpu(ctrl_ctx->add_flags);
1602 1596
1597 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index);
1598
1603 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep); 1599 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
1604 1600
1605 if (xhci->quirks & XHCI_MTK_HOST) 1601 if (xhci->quirks & XHCI_MTK_HOST)
@@ -1723,6 +1719,8 @@ static int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1723 /* Store the usb_device pointer for later use */ 1719 /* Store the usb_device pointer for later use */
1724 ep->hcpriv = udev; 1720 ep->hcpriv = udev;
1725 1721
1722 xhci_debugfs_create_endpoint(xhci, virt_dev, ep_index);
1723
1726 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n", 1724 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n",
1727 (unsigned int) ep->desc.bEndpointAddress, 1725 (unsigned int) ep->desc.bEndpointAddress,
1728 udev->slot_id, 1726 udev->slot_id,
@@ -2555,6 +2553,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
2555 unsigned long flags; 2553 unsigned long flags;
2556 struct xhci_input_control_ctx *ctrl_ctx; 2554 struct xhci_input_control_ctx *ctrl_ctx;
2557 struct xhci_virt_device *virt_dev; 2555 struct xhci_virt_device *virt_dev;
2556 struct xhci_slot_ctx *slot_ctx;
2558 2557
2559 if (!command) 2558 if (!command)
2560 return -EINVAL; 2559 return -EINVAL;
@@ -2593,6 +2592,9 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
2593 return -ENOMEM; 2592 return -ENOMEM;
2594 } 2593 }
2595 2594
2595 slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx);
2596 trace_xhci_configure_endpoint(slot_ctx);
2597
2596 if (!ctx_change) 2598 if (!ctx_change)
2597 ret = xhci_queue_configure_endpoint(xhci, command, 2599 ret = xhci_queue_configure_endpoint(xhci, command,
2598 command->in_ctx->dma, 2600 command->in_ctx->dma,
@@ -2773,6 +2775,7 @@ static void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2773 /* Free any rings allocated for added endpoints */ 2775 /* Free any rings allocated for added endpoints */
2774 for (i = 0; i < 31; i++) { 2776 for (i = 0; i < 31; i++) {
2775 if (virt_dev->eps[i].new_ring) { 2777 if (virt_dev->eps[i].new_ring) {
2778 xhci_debugfs_remove_endpoint(xhci, virt_dev, i);
2776 xhci_ring_free(xhci, virt_dev->eps[i].new_ring); 2779 xhci_ring_free(xhci, virt_dev->eps[i].new_ring);
2777 virt_dev->eps[i].new_ring = NULL; 2780 virt_dev->eps[i].new_ring = NULL;
2778 } 2781 }
@@ -3488,6 +3491,7 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd,
3488 } 3491 }
3489 3492
3490 if (ep->ring) { 3493 if (ep->ring) {
3494 xhci_debugfs_remove_endpoint(xhci, virt_dev, i);
3491 xhci_free_endpoint_ring(xhci, virt_dev, i); 3495 xhci_free_endpoint_ring(xhci, virt_dev, i);
3492 last_freed_endpoint = i; 3496 last_freed_endpoint = i;
3493 } 3497 }
@@ -3520,11 +3524,8 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3520 struct xhci_virt_device *virt_dev; 3524 struct xhci_virt_device *virt_dev;
3521 struct xhci_slot_ctx *slot_ctx; 3525 struct xhci_slot_ctx *slot_ctx;
3522 int i, ret; 3526 int i, ret;
3523 struct xhci_command *command;
3524 3527
3525 command = xhci_alloc_command(xhci, false, false, GFP_KERNEL); 3528 xhci_debugfs_remove_slot(xhci, udev->slot_id);
3526 if (!command)
3527 return;
3528 3529
3529#ifndef CONFIG_USB_DEFAULT_PERSIST 3530#ifndef CONFIG_USB_DEFAULT_PERSIST
3530 /* 3531 /*
@@ -3540,10 +3541,8 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3540 /* If the host is halted due to driver unload, we still need to free the 3541 /* If the host is halted due to driver unload, we still need to free the
3541 * device. 3542 * device.
3542 */ 3543 */
3543 if (ret <= 0 && ret != -ENODEV) { 3544 if (ret <= 0 && ret != -ENODEV)
3544 kfree(command);
3545 return; 3545 return;
3546 }
3547 3546
3548 virt_dev = xhci->devs[udev->slot_id]; 3547 virt_dev = xhci->devs[udev->slot_id];
3549 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); 3548 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
@@ -3555,26 +3554,19 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3555 del_timer_sync(&virt_dev->eps[i].stop_cmd_timer); 3554 del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
3556 } 3555 }
3557 3556
3558 xhci_disable_slot(xhci, command, udev->slot_id); 3557 ret = xhci_disable_slot(xhci, udev->slot_id);
3559 /* 3558 if (ret)
3560 * Event command completion handler will free any data structures 3559 xhci_free_virt_device(xhci, udev->slot_id);
3561 * associated with the slot. XXX Can free sleep?
3562 */
3563} 3560}
3564 3561
3565int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command, 3562int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
3566 u32 slot_id)
3567{ 3563{
3564 struct xhci_command *command;
3568 unsigned long flags; 3565 unsigned long flags;
3569 u32 state; 3566 u32 state;
3570 int ret = 0; 3567 int ret = 0;
3571 struct xhci_virt_device *virt_dev;
3572 3568
3573 virt_dev = xhci->devs[slot_id]; 3569 command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
3574 if (!virt_dev)
3575 return -EINVAL;
3576 if (!command)
3577 command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
3578 if (!command) 3570 if (!command)
3579 return -ENOMEM; 3571 return -ENOMEM;
3580 3572
@@ -3583,17 +3575,16 @@ int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command,
3583 state = readl(&xhci->op_regs->status); 3575 state = readl(&xhci->op_regs->status);
3584 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) || 3576 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
3585 (xhci->xhc_state & XHCI_STATE_HALTED)) { 3577 (xhci->xhc_state & XHCI_STATE_HALTED)) {
3586 xhci_free_virt_device(xhci, slot_id);
3587 spin_unlock_irqrestore(&xhci->lock, flags); 3578 spin_unlock_irqrestore(&xhci->lock, flags);
3588 kfree(command); 3579 kfree(command);
3589 return ret; 3580 return -ENODEV;
3590 } 3581 }
3591 3582
3592 ret = xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT, 3583 ret = xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT,
3593 slot_id); 3584 slot_id);
3594 if (ret) { 3585 if (ret) {
3595 spin_unlock_irqrestore(&xhci->lock, flags); 3586 spin_unlock_irqrestore(&xhci->lock, flags);
3596 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); 3587 kfree(command);
3597 return ret; 3588 return ret;
3598 } 3589 }
3599 xhci_ring_cmd_db(xhci); 3590 xhci_ring_cmd_db(xhci);
@@ -3641,13 +3632,10 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3641 if (!command) 3632 if (!command)
3642 return 0; 3633 return 0;
3643 3634
3644 /* xhci->slot_id and xhci->addr_dev are not thread-safe */
3645 mutex_lock(&xhci->mutex);
3646 spin_lock_irqsave(&xhci->lock, flags); 3635 spin_lock_irqsave(&xhci->lock, flags);
3647 ret = xhci_queue_slot_control(xhci, command, TRB_ENABLE_SLOT, 0); 3636 ret = xhci_queue_slot_control(xhci, command, TRB_ENABLE_SLOT, 0);
3648 if (ret) { 3637 if (ret) {
3649 spin_unlock_irqrestore(&xhci->lock, flags); 3638 spin_unlock_irqrestore(&xhci->lock, flags);
3650 mutex_unlock(&xhci->mutex);
3651 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); 3639 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
3652 xhci_free_command(xhci, command); 3640 xhci_free_command(xhci, command);
3653 return 0; 3641 return 0;
@@ -3657,7 +3645,6 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3657 3645
3658 wait_for_completion(command->completion); 3646 wait_for_completion(command->completion);
3659 slot_id = command->slot_id; 3647 slot_id = command->slot_id;
3660 mutex_unlock(&xhci->mutex);
3661 3648
3662 if (!slot_id || command->status != COMP_SUCCESS) { 3649 if (!slot_id || command->status != COMP_SUCCESS) {
3663 xhci_err(xhci, "Error while assigning device slot ID\n"); 3650 xhci_err(xhci, "Error while assigning device slot ID\n");
@@ -3668,6 +3655,8 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3668 return 0; 3655 return 0;
3669 } 3656 }
3670 3657
3658 xhci_free_command(xhci, command);
3659
3671 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { 3660 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) {
3672 spin_lock_irqsave(&xhci->lock, flags); 3661 spin_lock_irqsave(&xhci->lock, flags);
3673 ret = xhci_reserve_host_control_ep_resources(xhci); 3662 ret = xhci_reserve_host_control_ep_resources(xhci);
@@ -3694,6 +3683,8 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3694 3683
3695 udev->slot_id = slot_id; 3684 udev->slot_id = slot_id;
3696 3685
3686 xhci_debugfs_create_slot(xhci, slot_id);
3687
3697#ifndef CONFIG_USB_DEFAULT_PERSIST 3688#ifndef CONFIG_USB_DEFAULT_PERSIST
3698 /* 3689 /*
3699 * If resetting upon resume, we can't put the controller into runtime 3690 * If resetting upon resume, we can't put the controller into runtime
@@ -3703,18 +3694,16 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
3703 pm_runtime_get_noresume(hcd->self.controller); 3694 pm_runtime_get_noresume(hcd->self.controller);
3704#endif 3695#endif
3705 3696
3706
3707 xhci_free_command(xhci, command);
3708 /* Is this a LS or FS device under a HS hub? */ 3697 /* Is this a LS or FS device under a HS hub? */
3709 /* Hub or peripherial? */ 3698 /* Hub or peripherial? */
3710 return 1; 3699 return 1;
3711 3700
3712disable_slot: 3701disable_slot:
3713 /* Disable slot, if we can do it without mem alloc */ 3702 ret = xhci_disable_slot(xhci, udev->slot_id);
3714 kfree(command->completion); 3703 if (ret)
3715 command->completion = NULL; 3704 xhci_free_virt_device(xhci, udev->slot_id);
3716 command->status = 0; 3705
3717 return xhci_disable_slot(xhci, command, udev->slot_id); 3706 return 0;
3718} 3707}
3719 3708
3720/* 3709/*
@@ -3838,8 +3827,14 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3838 break; 3827 break;
3839 case COMP_USB_TRANSACTION_ERROR: 3828 case COMP_USB_TRANSACTION_ERROR:
3840 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act); 3829 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
3841 ret = -EPROTO; 3830
3842 break; 3831 mutex_unlock(&xhci->mutex);
3832 ret = xhci_disable_slot(xhci, udev->slot_id);
3833 if (!ret)
3834 xhci_alloc_dev(hcd, udev);
3835 kfree(command->completion);
3836 kfree(command);
3837 return -EPROTO;
3843 case COMP_INCOMPATIBLE_DEVICE_ERROR: 3838 case COMP_INCOMPATIBLE_DEVICE_ERROR:
3844 dev_warn(&udev->dev, 3839 dev_warn(&udev->dev,
3845 "ERROR: Incompatible device for setup %s command\n", act); 3840 "ERROR: Incompatible device for setup %s command\n", act);
@@ -4088,7 +4083,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4088 xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", 4083 xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
4089 enable ? "enable" : "disable", port_num + 1); 4084 enable ? "enable" : "disable", port_num + 1);
4090 4085
4091 if (enable) { 4086 if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
4092 /* Host supports BESL timeout instead of HIRD */ 4087 /* Host supports BESL timeout instead of HIRD */
4093 if (udev->usb2_hw_lpm_besl_capable) { 4088 if (udev->usb2_hw_lpm_besl_capable) {
4094 /* if device doesn't have a preferred BESL value use a 4089 /* if device doesn't have a preferred BESL value use a
@@ -4287,6 +4282,7 @@ static unsigned long long xhci_calculate_intel_u1_timeout(
4287 break; 4282 break;
4288 } 4283 }
4289 /* Otherwise the calculation is the same as isoc eps */ 4284 /* Otherwise the calculation is the same as isoc eps */
4285 /* fall through */
4290 case USB_ENDPOINT_XFER_ISOC: 4286 case USB_ENDPOINT_XFER_ISOC:
4291 timeout_ns = xhci_service_interval_to_ns(desc); 4287 timeout_ns = xhci_service_interval_to_ns(desc);
4292 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns * 105, 100); 4288 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns * 105, 100);
@@ -5005,6 +5001,8 @@ static int __init xhci_hcd_init(void)
5005 if (usb_disabled()) 5001 if (usb_disabled())
5006 return -ENODEV; 5002 return -ENODEV;
5007 5003
5004 xhci_debugfs_create_root();
5005
5008 return 0; 5006 return 0;
5009} 5007}
5010 5008
@@ -5012,7 +5010,10 @@ static int __init xhci_hcd_init(void)
5012 * If an init function is provided, an exit function must also be provided 5010 * If an init function is provided, an exit function must also be provided
5013 * to allow module unload. 5011 * to allow module unload.
5014 */ 5012 */
5015static void __exit xhci_hcd_fini(void) { } 5013static void __exit xhci_hcd_fini(void)
5014{
5015 xhci_debugfs_remove_root();
5016}
5016 5017
5017module_init(xhci_hcd_init); 5018module_init(xhci_hcd_init);
5018module_exit(xhci_hcd_fini); 5019module_exit(xhci_hcd_fini);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 2b48aa4f6b76..99a014a920d3 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2/* 3/*
3 * xHCI host controller driver 4 * xHCI host controller driver
@@ -6,19 +7,6 @@
6 * 7 *
7 * Author: Sarah Sharp 8 * Author: Sarah Sharp
8 * Some code borrowed from the Linux EHCI driver. 9 * Some code borrowed from the Linux EHCI driver.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 10 */
23 11
24#ifndef __LINUX_XHCI_HCD_H 12#ifndef __LINUX_XHCI_HCD_H
@@ -131,6 +119,8 @@ struct xhci_cap_regs {
131/* Extended Capabilities pointer from PCI base - section 5.3.6 */ 119/* Extended Capabilities pointer from PCI base - section 5.3.6 */
132#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p) 120#define HCC_EXT_CAPS(p) XHCI_HCC_EXT_CAPS(p)
133 121
122#define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
123
134/* db_off bitmask - bits 0:1 reserved */ 124/* db_off bitmask - bits 0:1 reserved */
135#define DBOFF_MASK (~0x3) 125#define DBOFF_MASK (~0x3)
136 126
@@ -1007,6 +997,8 @@ struct xhci_virt_device {
1007 struct xhci_tt_bw_info *tt_info; 997 struct xhci_tt_bw_info *tt_info;
1008 /* The current max exit latency for the enabled USB3 link states. */ 998 /* The current max exit latency for the enabled USB3 link states. */
1009 u16 current_mel; 999 u16 current_mel;
1000 /* Used for the debugfs interfaces. */
1001 void *debugfs_private;
1010}; 1002};
1011 1003
1012/* 1004/*
@@ -1830,6 +1822,7 @@ struct xhci_hcd {
1830#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) 1822#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
1831/* Reserved. It was XHCI_U2_DISABLE_WAKE */ 1823/* Reserved. It was XHCI_U2_DISABLE_WAKE */
1832#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) 1824#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28)
1825#define XHCI_HW_LPM_DISABLE (1 << 29)
1833 1826
1834 unsigned int num_active_eps; 1827 unsigned int num_active_eps;
1835 unsigned int limit_active_eps; 1828 unsigned int limit_active_eps;
@@ -1859,6 +1852,10 @@ struct xhci_hcd {
1859/* Compliance Mode Timer Triggered every 2 seconds */ 1852/* Compliance Mode Timer Triggered every 2 seconds */
1860#define COMP_MODE_RCVRY_MSECS 2000 1853#define COMP_MODE_RCVRY_MSECS 2000
1861 1854
1855 struct dentry *debugfs_root;
1856 struct dentry *debugfs_slots;
1857 struct list_head regset_list;
1858
1862 /* platform-specific data -- must come last */ 1859 /* platform-specific data -- must come last */
1863 unsigned long priv[0] __aligned(sizeof(s64)); 1860 unsigned long priv[0] __aligned(sizeof(s64));
1864}; 1861};
@@ -2012,8 +2009,7 @@ int xhci_run(struct usb_hcd *hcd);
2012int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); 2009int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
2013void xhci_init_driver(struct hc_driver *drv, 2010void xhci_init_driver(struct hc_driver *drv,
2014 const struct xhci_driver_overrides *over); 2011 const struct xhci_driver_overrides *over);
2015int xhci_disable_slot(struct xhci_hcd *xhci, 2012int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
2016 struct xhci_command *command, u32 slot_id);
2017 2013
2018int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup); 2014int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup);
2019int xhci_resume(struct xhci_hcd *xhci, bool hibernated); 2015int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
@@ -2068,7 +2064,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
2068 struct xhci_dequeue_state *deq_state); 2064 struct xhci_dequeue_state *deq_state);
2069void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int ep_index, 2065void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int ep_index,
2070 unsigned int stream_id, struct xhci_td *td); 2066 unsigned int stream_id, struct xhci_td *td);
2071void xhci_stop_endpoint_command_watchdog(unsigned long arg); 2067void xhci_stop_endpoint_command_watchdog(struct timer_list *t);
2072void xhci_handle_command_timeout(struct work_struct *work); 2068void xhci_handle_command_timeout(struct work_struct *work);
2073 2069
2074void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 2070void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
@@ -2107,6 +2103,7 @@ struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container
2107struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, 2103struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
2108 unsigned int slot_id, unsigned int ep_index, 2104 unsigned int slot_id, unsigned int ep_index,
2109 unsigned int stream_id); 2105 unsigned int stream_id);
2106
2110static inline struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, 2107static inline struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci,
2111 struct urb *urb) 2108 struct urb *urb)
2112{ 2109{
@@ -2442,11 +2439,12 @@ static inline const char *xhci_decode_portsc(u32 portsc)
2442 static char str[256]; 2439 static char str[256];
2443 int ret; 2440 int ret;
2444 2441
2445 ret = sprintf(str, "%s %s %s Link:%s ", 2442 ret = sprintf(str, "%s %s %s Link:%s PortSpeed:%d ",
2446 portsc & PORT_POWER ? "Powered" : "Powered-off", 2443 portsc & PORT_POWER ? "Powered" : "Powered-off",
2447 portsc & PORT_CONNECT ? "Connected" : "Not-connected", 2444 portsc & PORT_CONNECT ? "Connected" : "Not-connected",
2448 portsc & PORT_PE ? "Enabled" : "Disabled", 2445 portsc & PORT_PE ? "Enabled" : "Disabled",
2449 xhci_portsc_link_state_string(portsc)); 2446 xhci_portsc_link_state_string(portsc),
2447 DEV_PORT_SPEED(portsc));
2450 2448
2451 if (portsc & PORT_OC) 2449 if (portsc & PORT_OC)
2452 ret += sprintf(str + ret, "OverCurrent "); 2450 ret += sprintf(str + ret, "OverCurrent ");
diff --git a/drivers/usb/image/Makefile b/drivers/usb/image/Makefile
index 4148ae306352..8997c81ba86b 100644
--- a/drivers/usb/image/Makefile
+++ b/drivers/usb/image/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for USB Image drivers 3# Makefile for USB Image drivers
3# 4#
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index e92540a21b6b..2388674042a9 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * copyright (C) 1999/2000 by Henning Zabel <henning@uni-paderborn.de> 3 * copyright (C) 1999/2000 by Henning Zabel <henning@uni-paderborn.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19 6
@@ -893,6 +880,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s
893 return -EIO; 880 return -EIO;
894 } 881 }
895 mdc800->pic_len=-1; 882 mdc800->pic_len=-1;
883 /* fall through */
896 884
897 case 0x09: /* Download Thumbnail */ 885 case 0x09: /* Download Thumbnail */
898 mdc800->download_left=answersize+64; 886 mdc800->download_left=answersize+64;
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 0b21ba757bba..9f2f563c82ed 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Driver for Microtek Scanmaker X6 USB scanner, and possibly others. 2/* Driver for Microtek Scanmaker X6 USB scanner, and possibly others.
2 * 3 *
3 * (C) Copyright 2000 John Fremlin <vii@penguinpowered.com> 4 * (C) Copyright 2000 John Fremlin <vii@penguinpowered.com>
diff --git a/drivers/usb/isp1760/Makefile b/drivers/usb/isp1760/Makefile
index 2b741074ad2b..9bb09e8290c4 100644
--- a/drivers/usb/isp1760/Makefile
+++ b/drivers/usb/isp1760/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1isp1760-y := isp1760-core.o isp1760-if.o 2isp1760-y := isp1760-core.o isp1760-if.o
2isp1760-$(CONFIG_USB_ISP1760_HCD) += isp1760-hcd.o 3isp1760-$(CONFIG_USB_ISP1760_HCD) += isp1760-hcd.o
3isp1760-$(CONFIG_USB_ISP1761_UDC) += isp1760-udc.o 4isp1760-$(CONFIG_USB_ISP1761_UDC) += isp1760-udc.o
diff --git a/drivers/usb/isp1760/isp1760-core.c b/drivers/usb/isp1760/isp1760-core.c
index bfa402cf3a27..05d22589b5cc 100644
--- a/drivers/usb/isp1760/isp1760-core.c
+++ b/drivers/usb/isp1760/isp1760-core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the NXP ISP1760 chip 3 * Driver for the NXP ISP1760 chip
3 * 4 *
@@ -7,10 +8,6 @@
7 * Contacts: 8 * Contacts:
8 * Sebastian Siewior <bigeasy@linutronix.de> 9 * Sebastian Siewior <bigeasy@linutronix.de>
9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * version 2 as published by the Free Software Foundation.
14 */ 11 */
15 12
16#include <linux/delay.h> 13#include <linux/delay.h>
diff --git a/drivers/usb/isp1760/isp1760-core.h b/drivers/usb/isp1760/isp1760-core.h
index c70f8368a794..97cb4d7a3e1c 100644
--- a/drivers/usb/isp1760/isp1760-core.h
+++ b/drivers/usb/isp1760/isp1760-core.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the NXP ISP1760 chip 3 * Driver for the NXP ISP1760 chip
3 * 4 *
@@ -7,10 +8,6 @@
7 * Contacts: 8 * Contacts:
8 * Sebastian Siewior <bigeasy@linutronix.de> 9 * Sebastian Siewior <bigeasy@linutronix.de>
9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * version 2 as published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef _ISP1760_CORE_H_ 13#ifndef _ISP1760_CORE_H_
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index bb4d6d959871..42672d6ec525 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -1259,10 +1259,11 @@ leave:
1259#define SLOT_TIMEOUT 300 1259#define SLOT_TIMEOUT 300
1260#define SLOT_CHECK_PERIOD 200 1260#define SLOT_CHECK_PERIOD 200
1261static struct timer_list errata2_timer; 1261static struct timer_list errata2_timer;
1262static struct usb_hcd *errata2_timer_hcd;
1262 1263
1263static void errata2_function(unsigned long data) 1264static void errata2_function(struct timer_list *unused)
1264{ 1265{
1265 struct usb_hcd *hcd = (struct usb_hcd *) data; 1266 struct usb_hcd *hcd = errata2_timer_hcd;
1266 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1267 struct isp1760_hcd *priv = hcd_to_priv(hcd);
1267 int slot; 1268 int slot;
1268 struct ptd ptd; 1269 struct ptd ptd;
@@ -1334,7 +1335,8 @@ static int isp1760_run(struct usb_hcd *hcd)
1334 if (retval) 1335 if (retval)
1335 return retval; 1336 return retval;
1336 1337
1337 setup_timer(&errata2_timer, errata2_function, (unsigned long)hcd); 1338 errata2_timer_hcd = hcd;
1339 timer_setup(&errata2_timer, errata2_function, 0);
1338 errata2_timer.expires = jiffies + msecs_to_jiffies(SLOT_CHECK_PERIOD); 1340 errata2_timer.expires = jiffies + msecs_to_jiffies(SLOT_CHECK_PERIOD);
1339 add_timer(&errata2_timer); 1341 add_timer(&errata2_timer);
1340 1342
diff --git a/drivers/usb/isp1760/isp1760-regs.h b/drivers/usb/isp1760/isp1760-regs.h
index b67095c9a9d4..1f00c3850cf7 100644
--- a/drivers/usb/isp1760/isp1760-regs.h
+++ b/drivers/usb/isp1760/isp1760-regs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the NXP ISP1760 chip 3 * Driver for the NXP ISP1760 chip
3 * 4 *
@@ -7,10 +8,6 @@
7 * Contacts: 8 * Contacts:
8 * Sebastian Siewior <bigeasy@linutronix.de> 9 * Sebastian Siewior <bigeasy@linutronix.de>
9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * version 2 as published by the Free Software Foundation.
14 */ 11 */
15 12
16#ifndef _ISP1760_REGS_H_ 13#ifndef _ISP1760_REGS_H_
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
index 69400f3da886..bac4ef5d9512 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the NXP ISP1761 device controller 3 * Driver for the NXP ISP1761 device controller
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Contacts: 7 * Contacts:
7 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 8 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */ 9 */
13 10
14#include <linux/interrupt.h> 11#include <linux/interrupt.h>
@@ -1331,9 +1328,9 @@ static irqreturn_t isp1760_udc_irq(int irq, void *dev)
1331 return status ? IRQ_HANDLED : IRQ_NONE; 1328 return status ? IRQ_HANDLED : IRQ_NONE;
1332} 1329}
1333 1330
1334static void isp1760_udc_vbus_poll(unsigned long data) 1331static void isp1760_udc_vbus_poll(struct timer_list *t)
1335{ 1332{
1336 struct isp1760_udc *udc = (struct isp1760_udc *)data; 1333 struct isp1760_udc *udc = from_timer(udc, t, vbus_timer);
1337 unsigned long flags; 1334 unsigned long flags;
1338 1335
1339 spin_lock_irqsave(&udc->lock, flags); 1336 spin_lock_irqsave(&udc->lock, flags);
@@ -1452,8 +1449,7 @@ int isp1760_udc_register(struct isp1760_device *isp, int irq,
1452 udc->regs = isp->regs; 1449 udc->regs = isp->regs;
1453 1450
1454 spin_lock_init(&udc->lock); 1451 spin_lock_init(&udc->lock);
1455 setup_timer(&udc->vbus_timer, isp1760_udc_vbus_poll, 1452 timer_setup(&udc->vbus_timer, isp1760_udc_vbus_poll, 0);
1456 (unsigned long)udc);
1457 1453
1458 ret = isp1760_udc_init(udc); 1454 ret = isp1760_udc_init(udc);
1459 if (ret < 0) 1455 if (ret < 0)
diff --git a/drivers/usb/isp1760/isp1760-udc.h b/drivers/usb/isp1760/isp1760-udc.h
index 26899ed81145..2d0b88747701 100644
--- a/drivers/usb/isp1760/isp1760-udc.h
+++ b/drivers/usb/isp1760/isp1760-udc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for the NXP ISP1761 device controller 3 * Driver for the NXP ISP1761 device controller
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Contacts: 7 * Contacts:
7 * Laurent Pinchart <laurent.pinchart@ideasonboard.com> 8 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */ 9 */
13 10
14#ifndef _ISP1760_UDC_H_ 11#ifndef _ISP1760_UDC_H_
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 0f9f25db9163..68d2f2cd17dd 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -238,8 +238,8 @@ config USB_HUB_USB251XB
238 depends on I2C 238 depends on I2C
239 help 239 help
240 This option enables support for configuration via SMBus of the 240 This option enables support for configuration via SMBus of the
241 Microchip USB251xB/xBi USB 2.0 Hub Controller series. 241 Microchip USB251x/xBi USB 2.0 Hub Controller series. Configuration
242 Configuration parameters may be set in devicetree or platform data. 242 parameters may be set in devicetree or platform data.
243 Say Y or M here if you need to configure such a device via SMBus. 243 Say Y or M here if you need to configure such a device via SMBus.
244 244
245config USB_HSIC_USB3503 245config USB_HSIC_USB3503
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 1c0ada75c35d..4b8712733fc7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * adutux - driver for ADU devices from Ontrak Control Systems 3 * adutux - driver for ADU devices from Ontrak Control Systems
3 * This is an experimental driver. Use at your own risk. 4 * This is an experimental driver. Use at your own risk.
@@ -5,11 +6,6 @@
5 * 6 *
6 * Copyright (c) 2003 John Homppi (SCO, leave this notice here) 7 * Copyright (c) 2003 John Homppi (SCO, leave this notice here)
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * derived from the Lego USB Tower driver 0.56: 9 * derived from the Lego USB Tower driver 0.56:
14 * Copyright (c) 2003 David Glance <davidgsf@sourceforge.net> 10 * Copyright (c) 2003 David Glance <davidgsf@sourceforge.net>
15 * 2001 Juergen Stuber <stuber@loria.fr> 11 * 2001 Juergen Stuber <stuber@loria.fr>
@@ -761,13 +757,11 @@ error:
761static void adu_disconnect(struct usb_interface *interface) 757static void adu_disconnect(struct usb_interface *interface)
762{ 758{
763 struct adu_device *dev; 759 struct adu_device *dev;
764 int minor;
765 760
766 dev = usb_get_intfdata(interface); 761 dev = usb_get_intfdata(interface);
767 762
768 mutex_lock(&dev->mtx); /* not interruptible */ 763 mutex_lock(&dev->mtx); /* not interruptible */
769 dev->udev = NULL; /* poison */ 764 dev->udev = NULL; /* poison */
770 minor = dev->minor;
771 usb_deregister_dev(interface, &adu_class); 765 usb_deregister_dev(interface, &adu_class);
772 mutex_unlock(&dev->mtx); 766 mutex_unlock(&dev->mtx);
773 767
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 8efdc500e790..b3eb8b989bd4 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Apple Cinema Display driver 3 * Apple Cinema Display driver
3 * 4 *
4 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) 5 * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
5 * 6 *
6 * Thanks to Caskey L. Dickson for his work with acdctl. 7 * Thanks to Caskey L. Dickson for his work with acdctl.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */ 8 */
22 9
23#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index abec6e604a62..b6a1b9331aa0 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * chaoskey - driver for ChaosKey device from Altus Metrum. 3 * chaoskey - driver for ChaosKey device from Altus Metrum.
3 * 4 *
@@ -11,15 +12,6 @@
11 * bit stream. 12 * bit stream.
12 * 13 *
13 * Copyright © 2015 Keith Packard <keithp@keithp.com> 14 * Copyright © 2015 Keith Packard <keithp@keithp.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; version 2 of the License.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 */ 15 */
24 16
25#include <linux/module.h> 17#include <linux/module.h>
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
index 5c93a888c40e..bf4d2778907e 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* cypress_cy7c63.c 3* cypress_cy7c63.c
3* 4*
@@ -23,10 +24,6 @@
23* 24*
24* For up-to-date information please visit: 25* For up-to-date information please visit:
25* http://www.obock.de/kernel/cypress 26* http://www.obock.de/kernel/cypress
26*
27* This program is free software; you can redistribute it and/or
28* modify it under the terms of the GNU General Public License as
29* published by the Free Software Foundation, version 2.
30*/ 27*/
31 28
32#include <linux/module.h> 29#include <linux/module.h>
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 63207c42acf6..66be86077292 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* -*- linux-c -*- 2/* -*- linux-c -*-
2 * Cypress USB Thermometer driver 3 * Cypress USB Thermometer driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * This driver works with Elektor magazine USB Interface as published in 7 * This driver works with Elektor magazine USB Interface as published in
7 * issue #291. It should also work with the original starter kit/demo board 8 * issue #291. It should also work with the original starter kit/demo board
8 * from Cypress. 9 * from Cypress.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation, version 2.
13 *
14 */ 10 */
15 11
16 12
diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c
index c31b4a33e6bb..7895d61e733b 100644
--- a/drivers/usb/misc/ehset.c
+++ b/drivers/usb/misc/ehset.c
@@ -1,14 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */ 4 */
13 5
14#include <linux/kernel.h> 6#include <linux/kernel.h>
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index 8950fa5e973d..24d841850e05 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Emagic EMI 2|6 usb audio interface firmware loader. 3 * Emagic EMI 2|6 usb audio interface firmware loader.
3 * Copyright (C) 2002 4 * Copyright (C) 2002
4 * Tapio Laxström (tapio.laxstrom@iptime.fi) 5 * Tapio Laxström (tapio.laxstrom@iptime.fi)
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, as published by
8 * the Free Software Foundation, version 2.
9 *
10 * emi26.c,v 1.13 2002/03/08 13:10:26 tapio Exp 7 * emi26.c,v 1.13 2002/03/08 13:10:26 tapio Exp
11 */ 8 */
12#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index 1d9be4431b72..3eea60437f56 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Emagic EMI 2|6 usb audio interface firmware loader. 3 * Emagic EMI 2|6 usb audio interface firmware loader.
3 * Copyright (C) 2002 4 * Copyright (C) 2002
4 * Tapio Laxström (tapio.laxstrom@iptime.fi) 5 * Tapio Laxström (tapio.laxstrom@iptime.fi)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, as published by
8 * the Free Software Foundation, version 2.
9 */ 6 */
10#include <linux/kernel.h> 7#include <linux/kernel.h>
11#include <linux/errno.h> 8#include <linux/errno.h>
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
index 837208f14f86..f058d8029761 100644
--- a/drivers/usb/misc/ezusb.c
+++ b/drivers/usb/misc/ezusb.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * EZ-USB specific functions used by some of the USB to Serial drivers. 3 * EZ-USB specific functions used by some of the USB to Serial drivers.
3 * 4 *
4 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 424ff12f3b51..76c718ac8c78 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB FTDI client driver for Elan Digital Systems's Uxxx adapters 3 * USB FTDI client driver for Elan Digital Systems's Uxxx adapters
3 * 4 *
@@ -7,11 +8,6 @@
7 * Author and Maintainer - Tony Olech - Elan Digital Systems 8 * Author and Maintainer - Tony Olech - Elan Digital Systems
8 * tony.olech@elandigitalsystems.com 9 * tony.olech@elandigitalsystems.com
9 * 10 *
10 * This program is free software;you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation, version 2.
13 *
14 *
15 * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 11 * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
16 * based on various USB client drivers in the 2.6.15 linux kernel 12 * based on various USB client drivers in the 2.6.15 linux kernel
17 * with constant reference to the 3rd Edition of Linux Device Drivers 13 * with constant reference to the 3rd Edition of Linux Device Drivers
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 39d8fedfaf3b..20b0f91a5d9b 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* Siemens ID Mouse driver v0.6 2/* Siemens ID Mouse driver v0.6
2 3
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License, or (at your option) any later version.
7
8 Copyright (C) 2004-5 by Florian 'Floe' Echtler <echtler@fs.tum.de> 4 Copyright (C) 2004-5 by Florian 'Floe' Echtler <echtler@fs.tum.de>
9 and Andreas 'ad' Deresch <aderesch@fs.tum.de> 5 and Andreas 'ad' Deresch <aderesch@fs.tum.de>
10 6
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index be5881303681..ad3109490c0f 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Native support for the I/O-Warrior USB devices 3 * Native support for the I/O-Warrior USB devices
3 * 4 *
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c
index 1c61830e96f9..4d30095d6ad2 100644
--- a/drivers/usb/misc/isight_firmware.c
+++ b/drivers/usb/misc/isight_firmware.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for loading USB isight firmware 3 * Driver for loading USB isight firmware
3 * 4 *
4 * Copyright (C) 2008 Matthew Garrett <mjg@redhat.com> 5 * Copyright (C) 2008 Matthew Garrett <mjg@redhat.com>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, version 2.
9 *
10 * The USB isight cameras in recent Apples are roughly compatible with the USB 7 * The USB isight cameras in recent Apples are roughly compatible with the USB
11 * video class specification, and can be driven by uvcvideo. However, they 8 * video class specification, and can be driven by uvcvideo. However, they
12 * need firmware to be loaded beforehand. After firmware loading, the device 9 * need firmware to be loaded beforehand. After firmware loading, the device
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 680bddb3ce05..5c1a3b852453 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/** 2/**
2 * Generic USB driver for report based interrupt in/out devices 3 * Generic USB driver for report based interrupt in/out devices
3 * like LD Didactic's USB devices. LD Didactic's USB devices are 4 * like LD Didactic's USB devices. LD Didactic's USB devices are
@@ -12,11 +13,6 @@
12 * 13 *
13 * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de> 14 * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de>
14 * 15 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * Derived from Lego USB Tower driver 16 * Derived from Lego USB Tower driver
21 * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net> 17 * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net>
22 * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net> 18 * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 5628f678ab59..c5be6e9e24a5 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * LEGO USB Tower driver 3 * LEGO USB Tower driver
3 * 4 *
4 * Copyright (C) 2003 David Glance <davidgsf@sourceforge.net> 5 * Copyright (C) 2003 David Glance <davidgsf@sourceforge.net>
5 * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net> 6 * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
6 * 7 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * derived from USB Skeleton driver - 0.5 8 * derived from USB Skeleton driver - 0.5
13 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) 9 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
14 * 10 *
diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
index ddddd6387f66..e5c03c6d16e9 100644
--- a/drivers/usb/misc/lvstest.c
+++ b/drivers/usb/misc/lvstest.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/usb/misc/lvstest.c 3 * drivers/usb/misc/lvstest.c
3 * 4 *
@@ -5,10 +6,6 @@
5 * 6 *
6 * Copyright (C) 2014 ST Microelectronics 7 * Copyright (C) 2014 ST Microelectronics
7 * Pratyush Anand <pratyush.anand@gmail.com> 8 * Pratyush Anand <pratyush.anand@gmail.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */ 9 */
13 10
14#include <linux/init.h> 11#include <linux/init.h>
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index ddfebb144aaa..7b9adeb3e7aa 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* -*- linux-c -*- */ 2/* -*- linux-c -*- */
2 3
3/* 4/*
@@ -6,20 +7,6 @@
6 * Cesar Miquel (miquel@df.uba.ar) 7 * Cesar Miquel (miquel@df.uba.ar)
7 * 8 *
8 * based on hp_scanner.c by David E. Nelson (dnelson@jump.net) 9 * based on hp_scanner.c by David E. Nelson (dnelson@jump.net)
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * 10 *
24 * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee). 11 * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee).
25 * 12 *
diff --git a/drivers/usb/misc/rio500_usb.h b/drivers/usb/misc/rio500_usb.h
index 359abc98e706..6db7a5863496 100644
--- a/drivers/usb/misc/rio500_usb.h
+++ b/drivers/usb/misc/rio500_usb.h
@@ -1,25 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* ---------------------------------------------------------------------- 2/* ----------------------------------------------------------------------
2
3 Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar) 3 Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar)
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 ---------------------------------------------------------------------- */ 4 ---------------------------------------------------------------------- */
20 5
21
22
23#define RIO_SEND_COMMAND 0x1 6#define RIO_SEND_COMMAND 0x1
24#define RIO_RECV_COMMAND 0x2 7#define RIO_RECV_COMMAND 0x2
25 8
diff --git a/drivers/usb/misc/sisusbvga/Makefile b/drivers/usb/misc/sisusbvga/Makefile
index 3142476ccc8e..6ed3a638261a 100644
--- a/drivers/usb/misc/sisusbvga/Makefile
+++ b/drivers/usb/misc/sisusbvga/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for the sisusb driver (if driver is inside kernel tree). 3# Makefile for the sisusb driver (if driver is inside kernel tree).
3# 4#
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 30774e0aeadd..3e65bdc2615c 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles 3 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles
3 * 4 *
diff --git a/drivers/usb/misc/sisusbvga/sisusb.h b/drivers/usb/misc/sisusbvga/sisusb.h
index 55492a5930bd..20f03ad0ea16 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.h
+++ b/drivers/usb/misc/sisusbvga/sisusb.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * sisusb - usb kernel driver for Net2280/SiS315 based USB2VGA dongles 3 * sisusb - usb kernel driver for Net2280/SiS315 based USB2VGA dongles
3 * 4 *
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c
index f019d80ca9e4..73f7bde78e11 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles 3 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles
3 * 4 *
diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.c b/drivers/usb/misc/sisusbvga/sisusb_init.c
index bf0032ca35ed..6a30e8bd9221 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_init.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_init.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
1/* 2/*
2 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles 3 * sisusb - usb kernel driver for SiS315(E) based USB2VGA dongles
3 * 4 *
diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.h b/drivers/usb/misc/sisusbvga/sisusb_init.h
index e79a616f0d26..1782c759c4ad 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_init.h
+++ b/drivers/usb/misc/sisusbvga/sisusb_init.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* $XFree86$ */ 2/* $XFree86$ */
2/* $XdotOrg$ */ 3/* $XdotOrg$ */
3/* 4/*
diff --git a/drivers/usb/misc/sisusbvga/sisusb_struct.h b/drivers/usb/misc/sisusbvga/sisusb_struct.h
index 1c4240e802c1..706d77090e00 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_struct.h
+++ b/drivers/usb/misc/sisusbvga/sisusb_struct.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1/* 2/*
2 * General structure definitions for universal mode switching modules 3 * General structure definitions for universal mode switching modules
3 * 4 *
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 1862ed15ce28..d83af2a332e4 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * PlayStation 2 Trance Vibrator driver 3 * PlayStation 2 Trance Vibrator driver
3 * 4 *
4 * Copyright (C) 2006 Sam Hocevar <sam@zoy.org> 5 * Copyright (C) 2006 Sam Hocevar <sam@zoy.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 6 */
20 7
21/* Standard include files */ 8/* Standard include files */
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 135c91c434bf..a6efb9a72939 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Microchip USB251xB USB 2.0 Hi-Speed Hub Controller 3 * Driver for Microchip USB251xB USB 2.0 Hi-Speed Hub Controller
3 * Configuration via SMBus. 4 * Configuration via SMBus.
@@ -7,25 +8,14 @@
7 * This work is based on the USB3503 driver by Dongjin Kim and 8 * This work is based on the USB3503 driver by Dongjin Kim and
8 * a not-accepted patch by Fabien Lahoudere, see: 9 * a not-accepted patch by Fabien Lahoudere, see:
9 * https://patchwork.kernel.org/patch/9257715/ 10 * https://patchwork.kernel.org/patch/9257715/
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 */ 11 */
21 12
22#include <linux/delay.h> 13#include <linux/delay.h>
23#include <linux/gpio.h> 14#include <linux/gpio/consumer.h>
24#include <linux/i2c.h> 15#include <linux/i2c.h>
25#include <linux/module.h> 16#include <linux/module.h>
26#include <linux/nls.h> 17#include <linux/nls.h>
27#include <linux/of_device.h> 18#include <linux/of_device.h>
28#include <linux/of_gpio.h>
29#include <linux/slab.h> 19#include <linux/slab.h>
30 20
31/* Internal Register Set Addresses & Default Values acc. to DS00001692C */ 21/* Internal Register Set Addresses & Default Values acc. to DS00001692C */
@@ -38,6 +28,7 @@
38#define USB251XB_DEF_PRODUCT_ID_12 0x2512 /* USB2512B/12Bi */ 28#define USB251XB_DEF_PRODUCT_ID_12 0x2512 /* USB2512B/12Bi */
39#define USB251XB_DEF_PRODUCT_ID_13 0x2513 /* USB2513B/13Bi */ 29#define USB251XB_DEF_PRODUCT_ID_13 0x2513 /* USB2513B/13Bi */
40#define USB251XB_DEF_PRODUCT_ID_14 0x2514 /* USB2514B/14Bi */ 30#define USB251XB_DEF_PRODUCT_ID_14 0x2514 /* USB2514B/14Bi */
31#define USB251XB_DEF_PRODUCT_ID_17 0x2517 /* USB2517/17i */
41 32
42#define USB251XB_ADDR_DEVICE_ID_LSB 0x04 33#define USB251XB_ADDR_DEVICE_ID_LSB 0x04
43#define USB251XB_ADDR_DEVICE_ID_MSB 0x05 34#define USB251XB_ADDR_DEVICE_ID_MSB 0x05
@@ -82,7 +73,7 @@
82 73
83#define USB251XB_ADDR_PRODUCT_STRING_LEN 0x14 74#define USB251XB_ADDR_PRODUCT_STRING_LEN 0x14
84#define USB251XB_ADDR_PRODUCT_STRING 0x54 75#define USB251XB_ADDR_PRODUCT_STRING 0x54
85#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi" 76#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi/7i"
86 77
87#define USB251XB_ADDR_SERIAL_STRING_LEN 0x15 78#define USB251XB_ADDR_SERIAL_STRING_LEN 0x15
88#define USB251XB_ADDR_SERIAL_STRING 0x92 79#define USB251XB_ADDR_SERIAL_STRING 0x92
@@ -93,8 +84,10 @@
93 84
94#define USB251XB_ADDR_BOOST_UP 0xF6 85#define USB251XB_ADDR_BOOST_UP 0xF6
95#define USB251XB_DEF_BOOST_UP 0x00 86#define USB251XB_DEF_BOOST_UP 0x00
96#define USB251XB_ADDR_BOOST_X 0xF8 87#define USB251XB_ADDR_BOOST_57 0xF7
97#define USB251XB_DEF_BOOST_X 0x00 88#define USB251XB_DEF_BOOST_57 0x00
89#define USB251XB_ADDR_BOOST_14 0xF8
90#define USB251XB_DEF_BOOST_14 0x00
98 91
99#define USB251XB_ADDR_PORT_SWAP 0xFA 92#define USB251XB_ADDR_PORT_SWAP 0xFA
100#define USB251XB_DEF_PORT_SWAP 0x00 93#define USB251XB_DEF_PORT_SWAP 0x00
@@ -102,7 +95,11 @@
102#define USB251XB_ADDR_PORT_MAP_12 0xFB 95#define USB251XB_ADDR_PORT_MAP_12 0xFB
103#define USB251XB_DEF_PORT_MAP_12 0x00 96#define USB251XB_DEF_PORT_MAP_12 0x00
104#define USB251XB_ADDR_PORT_MAP_34 0xFC 97#define USB251XB_ADDR_PORT_MAP_34 0xFC
105#define USB251XB_DEF_PORT_MAP_34 0x00 /* USB2513B/i & USB2514B/i only */ 98#define USB251XB_DEF_PORT_MAP_34 0x00 /* USB251{3B/i,4B/i,7/i} only */
99#define USB251XB_ADDR_PORT_MAP_56 0xFD
100#define USB251XB_DEF_PORT_MAP_56 0x00 /* USB2517/i only */
101#define USB251XB_ADDR_PORT_MAP_7 0xFE
102#define USB251XB_DEF_PORT_MAP_7 0x00 /* USB2517/i only */
106 103
107#define USB251XB_ADDR_STATUS_COMMAND 0xFF 104#define USB251XB_ADDR_STATUS_COMMAND 0xFF
108#define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04 105#define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04
@@ -119,7 +116,7 @@ struct usb251xb {
119 struct device *dev; 116 struct device *dev;
120 struct i2c_client *i2c; 117 struct i2c_client *i2c;
121 u8 skip_config; 118 u8 skip_config;
122 int gpio_reset; 119 struct gpio_desc *gpio_reset;
123 u16 vendor_id; 120 u16 vendor_id;
124 u16 product_id; 121 u16 product_id;
125 u16 device_id; 122 u16 device_id;
@@ -143,57 +140,97 @@ struct usb251xb {
143 char serial[USB251XB_STRING_BUFSIZE]; 140 char serial[USB251XB_STRING_BUFSIZE];
144 u8 bat_charge_en; 141 u8 bat_charge_en;
145 u8 boost_up; 142 u8 boost_up;
146 u8 boost_x; 143 u8 boost_57;
144 u8 boost_14;
147 u8 port_swap; 145 u8 port_swap;
148 u8 port_map12; 146 u8 port_map12;
149 u8 port_map34; 147 u8 port_map34;
148 u8 port_map56;
149 u8 port_map7;
150 u8 status; 150 u8 status;
151}; 151};
152 152
153struct usb251xb_data { 153struct usb251xb_data {
154 u16 product_id; 154 u16 product_id;
155 u8 port_cnt;
156 bool led_support;
157 bool bat_support;
155 char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */ 158 char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */
156}; 159};
157 160
158static const struct usb251xb_data usb2512b_data = { 161static const struct usb251xb_data usb2512b_data = {
159 .product_id = 0x2512, 162 .product_id = 0x2512,
163 .port_cnt = 2,
164 .led_support = false,
165 .bat_support = true,
160 .product_str = "USB2512B", 166 .product_str = "USB2512B",
161}; 167};
162 168
163static const struct usb251xb_data usb2512bi_data = { 169static const struct usb251xb_data usb2512bi_data = {
164 .product_id = 0x2512, 170 .product_id = 0x2512,
171 .port_cnt = 2,
172 .led_support = false,
173 .bat_support = true,
165 .product_str = "USB2512Bi", 174 .product_str = "USB2512Bi",
166}; 175};
167 176
168static const struct usb251xb_data usb2513b_data = { 177static const struct usb251xb_data usb2513b_data = {
169 .product_id = 0x2513, 178 .product_id = 0x2513,
179 .port_cnt = 3,
180 .led_support = false,
181 .bat_support = true,
170 .product_str = "USB2513B", 182 .product_str = "USB2513B",
171}; 183};
172 184
173static const struct usb251xb_data usb2513bi_data = { 185static const struct usb251xb_data usb2513bi_data = {
174 .product_id = 0x2513, 186 .product_id = 0x2513,
187 .port_cnt = 3,
188 .led_support = false,
189 .bat_support = true,
175 .product_str = "USB2513Bi", 190 .product_str = "USB2513Bi",
176}; 191};
177 192
178static const struct usb251xb_data usb2514b_data = { 193static const struct usb251xb_data usb2514b_data = {
179 .product_id = 0x2514, 194 .product_id = 0x2514,
195 .port_cnt = 4,
196 .led_support = false,
197 .bat_support = true,
180 .product_str = "USB2514B", 198 .product_str = "USB2514B",
181}; 199};
182 200
183static const struct usb251xb_data usb2514bi_data = { 201static const struct usb251xb_data usb2514bi_data = {
184 .product_id = 0x2514, 202 .product_id = 0x2514,
203 .port_cnt = 4,
204 .led_support = false,
205 .bat_support = true,
185 .product_str = "USB2514Bi", 206 .product_str = "USB2514Bi",
186}; 207};
187 208
209static const struct usb251xb_data usb2517_data = {
210 .product_id = 0x2517,
211 .port_cnt = 7,
212 .led_support = true,
213 .bat_support = false,
214 .product_str = "USB2517",
215};
216
217static const struct usb251xb_data usb2517i_data = {
218 .product_id = 0x2517,
219 .port_cnt = 7,
220 .led_support = true,
221 .bat_support = false,
222 .product_str = "USB2517i",
223};
224
188static void usb251xb_reset(struct usb251xb *hub, int state) 225static void usb251xb_reset(struct usb251xb *hub, int state)
189{ 226{
190 if (!gpio_is_valid(hub->gpio_reset)) 227 if (!hub->gpio_reset)
191 return; 228 return;
192 229
193 gpio_set_value_cansleep(hub->gpio_reset, state); 230 gpiod_set_value_cansleep(hub->gpio_reset, state);
194 231
195 /* wait for hub recovery/stabilization */ 232 /* wait for hub recovery/stabilization */
196 if (state) 233 if (!state)
197 usleep_range(500, 750); /* >=500us at power on */ 234 usleep_range(500, 750); /* >=500us at power on */
198 else 235 else
199 usleep_range(1, 10); /* >=1us at power down */ 236 usleep_range(1, 10); /* >=1us at power down */
@@ -212,7 +249,7 @@ static int usb251xb_connect(struct usb251xb *hub)
212 i2c_wb[0] = 0x01; 249 i2c_wb[0] = 0x01;
213 i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH; 250 i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH;
214 251
215 usb251xb_reset(hub, 1); 252 usb251xb_reset(hub, 0);
216 253
217 err = i2c_smbus_write_i2c_block_data(hub->i2c, 254 err = i2c_smbus_write_i2c_block_data(hub->i2c,
218 USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb); 255 USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb);
@@ -253,13 +290,16 @@ static int usb251xb_connect(struct usb251xb *hub)
253 USB251XB_STRING_BUFSIZE); 290 USB251XB_STRING_BUFSIZE);
254 i2c_wb[USB251XB_ADDR_BATTERY_CHARGING_ENABLE] = hub->bat_charge_en; 291 i2c_wb[USB251XB_ADDR_BATTERY_CHARGING_ENABLE] = hub->bat_charge_en;
255 i2c_wb[USB251XB_ADDR_BOOST_UP] = hub->boost_up; 292 i2c_wb[USB251XB_ADDR_BOOST_UP] = hub->boost_up;
256 i2c_wb[USB251XB_ADDR_BOOST_X] = hub->boost_x; 293 i2c_wb[USB251XB_ADDR_BOOST_57] = hub->boost_57;
294 i2c_wb[USB251XB_ADDR_BOOST_14] = hub->boost_14;
257 i2c_wb[USB251XB_ADDR_PORT_SWAP] = hub->port_swap; 295 i2c_wb[USB251XB_ADDR_PORT_SWAP] = hub->port_swap;
258 i2c_wb[USB251XB_ADDR_PORT_MAP_12] = hub->port_map12; 296 i2c_wb[USB251XB_ADDR_PORT_MAP_12] = hub->port_map12;
259 i2c_wb[USB251XB_ADDR_PORT_MAP_34] = hub->port_map34; 297 i2c_wb[USB251XB_ADDR_PORT_MAP_34] = hub->port_map34;
298 i2c_wb[USB251XB_ADDR_PORT_MAP_56] = hub->port_map56;
299 i2c_wb[USB251XB_ADDR_PORT_MAP_7] = hub->port_map7;
260 i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH; 300 i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH;
261 301
262 usb251xb_reset(hub, 1); 302 usb251xb_reset(hub, 0);
263 303
264 /* write registers */ 304 /* write registers */
265 for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) { 305 for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) {
@@ -297,7 +337,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
297 struct device *dev = hub->dev; 337 struct device *dev = hub->dev;
298 struct device_node *np = dev->of_node; 338 struct device_node *np = dev->of_node;
299 int len, err, i; 339 int len, err, i;
300 u32 *property_u32 = NULL; 340 u32 property_u32 = 0;
301 const u32 *cproperty_u32; 341 const u32 *cproperty_u32;
302 const char *cproperty_char; 342 const char *cproperty_char;
303 char str[USB251XB_STRING_BUFSIZE / 2]; 343 char str[USB251XB_STRING_BUFSIZE / 2];
@@ -312,19 +352,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
312 else 352 else
313 hub->skip_config = 0; 353 hub->skip_config = 0;
314 354
315 hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0); 355 hub->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
316 if (hub->gpio_reset == -EPROBE_DEFER) 356 if (PTR_ERR(hub->gpio_reset) == -EPROBE_DEFER) {
317 return -EPROBE_DEFER; 357 return -EPROBE_DEFER;
318 if (gpio_is_valid(hub->gpio_reset)) { 358 } else if (IS_ERR(hub->gpio_reset)) {
319 err = devm_gpio_request_one(dev, hub->gpio_reset, 359 err = PTR_ERR(hub->gpio_reset);
320 GPIOF_OUT_INIT_LOW, 360 dev_err(dev, "unable to request GPIO reset pin (%d)\n", err);
321 "usb251xb reset"); 361 return err;
322 if (err) {
323 dev_err(dev,
324 "unable to request GPIO %d as reset pin (%d)\n",
325 hub->gpio_reset, err);
326 return err;
327 }
328 } 362 }
329 363
330 if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1)) 364 if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1))
@@ -374,16 +408,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
374 if (of_get_property(np, "dynamic-power-switching", NULL)) 408 if (of_get_property(np, "dynamic-power-switching", NULL))
375 hub->conf_data2 |= BIT(7); 409 hub->conf_data2 |= BIT(7);
376 410
377 if (!of_property_read_u32(np, "oc-delay-us", property_u32)) { 411 if (!of_property_read_u32(np, "oc-delay-us", &property_u32)) {
378 if (*property_u32 == 100) { 412 if (property_u32 == 100) {
379 /* 100 us*/ 413 /* 100 us*/
380 hub->conf_data2 &= ~BIT(5); 414 hub->conf_data2 &= ~BIT(5);
381 hub->conf_data2 &= ~BIT(4); 415 hub->conf_data2 &= ~BIT(4);
382 } else if (*property_u32 == 4000) { 416 } else if (property_u32 == 4000) {
383 /* 4 ms */ 417 /* 4 ms */
384 hub->conf_data2 &= ~BIT(5); 418 hub->conf_data2 &= ~BIT(5);
385 hub->conf_data2 |= BIT(4); 419 hub->conf_data2 |= BIT(4);
386 } else if (*property_u32 == 16000) { 420 } else if (property_u32 == 16000) {
387 /* 16 ms */ 421 /* 16 ms */
388 hub->conf_data2 |= BIT(5); 422 hub->conf_data2 |= BIT(5);
389 hub->conf_data2 |= BIT(4); 423 hub->conf_data2 |= BIT(4);
@@ -401,6 +435,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
401 if (of_get_property(np, "port-mapping-mode", NULL)) 435 if (of_get_property(np, "port-mapping-mode", NULL))
402 hub->conf_data3 |= BIT(3); 436 hub->conf_data3 |= BIT(3);
403 437
438 if (data->led_support && of_get_property(np, "led-usb-mode", NULL))
439 hub->conf_data3 &= ~BIT(1);
440
404 if (of_get_property(np, "string-support", NULL)) 441 if (of_get_property(np, "string-support", NULL))
405 hub->conf_data3 |= BIT(0); 442 hub->conf_data3 |= BIT(0);
406 443
@@ -410,8 +447,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
410 for (i = 0; i < len / sizeof(u32); i++) { 447 for (i = 0; i < len / sizeof(u32); i++) {
411 u32 port = be32_to_cpu(cproperty_u32[i]); 448 u32 port = be32_to_cpu(cproperty_u32[i]);
412 449
413 if ((port >= 1) && (port <= 4)) 450 if ((port >= 1) && (port <= data->port_cnt))
414 hub->non_rem_dev |= BIT(port); 451 hub->non_rem_dev |= BIT(port);
452 else
453 dev_warn(dev, "NRD port %u doesn't exist\n",
454 port);
415 } 455 }
416 } 456 }
417 457
@@ -421,8 +461,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
421 for (i = 0; i < len / sizeof(u32); i++) { 461 for (i = 0; i < len / sizeof(u32); i++) {
422 u32 port = be32_to_cpu(cproperty_u32[i]); 462 u32 port = be32_to_cpu(cproperty_u32[i]);
423 463
424 if ((port >= 1) && (port <= 4)) 464 if ((port >= 1) && (port <= data->port_cnt))
425 hub->port_disable_sp |= BIT(port); 465 hub->port_disable_sp |= BIT(port);
466 else
467 dev_warn(dev, "PDS port %u doesn't exist\n",
468 port);
426 } 469 }
427 } 470 }
428 471
@@ -432,14 +475,37 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
432 for (i = 0; i < len / sizeof(u32); i++) { 475 for (i = 0; i < len / sizeof(u32); i++) {
433 u32 port = be32_to_cpu(cproperty_u32[i]); 476 u32 port = be32_to_cpu(cproperty_u32[i]);
434 477
435 if ((port >= 1) && (port <= 4)) 478 if ((port >= 1) && (port <= data->port_cnt))
436 hub->port_disable_bp |= BIT(port); 479 hub->port_disable_bp |= BIT(port);
480 else
481 dev_warn(dev, "PDB port %u doesn't exist\n",
482 port);
437 } 483 }
438 } 484 }
439 485
486 hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
487 if (!of_property_read_u32(np, "sp-max-total-current-microamp",
488 &property_u32))
489 hub->max_power_sp = min_t(u8, property_u32 / 2000, 50);
490
491 hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
492 if (!of_property_read_u32(np, "bp-max-total-current-microamp",
493 &property_u32))
494 hub->max_power_bp = min_t(u8, property_u32 / 2000, 255);
495
496 hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
497 if (!of_property_read_u32(np, "sp-max-removable-current-microamp",
498 &property_u32))
499 hub->max_current_sp = min_t(u8, property_u32 / 2000, 50);
500
501 hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
502 if (!of_property_read_u32(np, "bp-max-removable-current-microamp",
503 &property_u32))
504 hub->max_current_bp = min_t(u8, property_u32 / 2000, 255);
505
440 hub->power_on_time = USB251XB_DEF_POWER_ON_TIME; 506 hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
441 if (!of_property_read_u32(np, "power-on-time-ms", property_u32)) 507 if (!of_property_read_u32(np, "power-on-time-ms", &property_u32))
442 hub->power_on_time = min_t(u8, *property_u32 / 2, 255); 508 hub->power_on_time = min_t(u8, property_u32 / 2, 255);
443 509
444 if (of_property_read_u16_array(np, "language-id", &hub->lang_id, 1)) 510 if (of_property_read_u16_array(np, "language-id", &hub->lang_id, 1))
445 hub->lang_id = USB251XB_DEF_LANGUAGE_ID; 511 hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
@@ -476,16 +542,15 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
476 /* The following parameters are currently not exposed to devicetree, but 542 /* The following parameters are currently not exposed to devicetree, but
477 * may be as soon as needed. 543 * may be as soon as needed.
478 */ 544 */
479 hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
480 hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
481 hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
482 hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
483 hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE; 545 hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
484 hub->boost_up = USB251XB_DEF_BOOST_UP; 546 hub->boost_up = USB251XB_DEF_BOOST_UP;
485 hub->boost_x = USB251XB_DEF_BOOST_X; 547 hub->boost_57 = USB251XB_DEF_BOOST_57;
548 hub->boost_14 = USB251XB_DEF_BOOST_14;
486 hub->port_swap = USB251XB_DEF_PORT_SWAP; 549 hub->port_swap = USB251XB_DEF_PORT_SWAP;
487 hub->port_map12 = USB251XB_DEF_PORT_MAP_12; 550 hub->port_map12 = USB251XB_DEF_PORT_MAP_12;
488 hub->port_map34 = USB251XB_DEF_PORT_MAP_34; 551 hub->port_map34 = USB251XB_DEF_PORT_MAP_34;
552 hub->port_map56 = USB251XB_DEF_PORT_MAP_56;
553 hub->port_map7 = USB251XB_DEF_PORT_MAP_7;
489 554
490 return 0; 555 return 0;
491} 556}
@@ -510,6 +575,12 @@ static const struct of_device_id usb251xb_of_match[] = {
510 .compatible = "microchip,usb2514bi", 575 .compatible = "microchip,usb2514bi",
511 .data = &usb2514bi_data, 576 .data = &usb2514bi_data,
512 }, { 577 }, {
578 .compatible = "microchip,usb2517",
579 .data = &usb2517_data,
580 }, {
581 .compatible = "microchip,usb2517i",
582 .data = &usb2517i_data,
583 }, {
513 /* sentinel */ 584 /* sentinel */
514 } 585 }
515}; 586};
@@ -573,6 +644,8 @@ static const struct i2c_device_id usb251xb_id[] = {
573 { "usb2513bi", 0 }, 644 { "usb2513bi", 0 },
574 { "usb2514b", 0 }, 645 { "usb2514b", 0 },
575 { "usb2514bi", 0 }, 646 { "usb2514bi", 0 },
647 { "usb2517", 0 },
648 { "usb2517i", 0 },
576 { /* sentinel */ } 649 { /* sentinel */ }
577}; 650};
578MODULE_DEVICE_TABLE(i2c, usb251xb_id); 651MODULE_DEVICE_TABLE(i2c, usb251xb_id);
@@ -589,5 +662,5 @@ static struct i2c_driver usb251xb_i2c_driver = {
589module_i2c_driver(usb251xb_i2c_driver); 662module_i2c_driver(usb251xb_i2c_driver);
590 663
591MODULE_AUTHOR("Richard Leitner <richard.leitner@skidata.com>"); 664MODULE_AUTHOR("Richard Leitner <richard.leitner@skidata.com>");
592MODULE_DESCRIPTION("USB251xB/xBi USB 2.0 Hub Controller Driver"); 665MODULE_DESCRIPTION("USB251x/xBi USB 2.0 Hub Controller Driver");
593MODULE_LICENSE("GPL"); 666MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index 8e7737d7ac0a..465dbf68b463 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -1,21 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SMSC USB3503 USB 2.0 hub controller driver 3 * Driver for SMSC USB3503 USB 2.0 hub controller driver
3 * 4 *
4 * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com) 5 * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 6 */
20 7
21#include <linux/clk.h> 8#include <linux/clk.h>
diff --git a/drivers/usb/misc/usb4604.c b/drivers/usb/misc/usb4604.c
index e9f37fb746ac..1b4de651e697 100644
--- a/drivers/usb/misc/usb4604.c
+++ b/drivers/usb/misc/usb4604.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SMSC USB4604 USB HSIC 4-port 2.0 hub controller driver 3 * Driver for SMSC USB4604 USB HSIC 4-port 2.0 hub controller driver
3 * Based on usb3503 driver 4 * Based on usb3503 driver
4 * 5 *
5 * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com) 6 * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com)
6 * Copyright (c) 2016 Linaro Ltd. 7 * Copyright (c) 2016 Linaro Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */ 8 */
18 9
19#include <linux/i2c.h> 10#include <linux/i2c.h>
diff --git a/drivers/usb/misc/usb_u132.h b/drivers/usb/misc/usb_u132.h
index dc2e5a31caec..4bf77736914f 100644
--- a/drivers/usb/misc/usb_u132.h
+++ b/drivers/usb/misc/usb_u132.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2* Common Header File for the Elan Digital Systems U132 adapter 3* Common Header File for the Elan Digital Systems U132 adapter
3* this file should be included by both the "ftdi-u132" and 4* this file should be included by both the "ftdi-u132" and
@@ -9,11 +10,6 @@
9* Author and Maintainer - Tony Olech - Elan Digital Systems 10* Author and Maintainer - Tony Olech - Elan Digital Systems
10*(tony.olech@elandigitalsystems.com) 11*(tony.olech@elandigitalsystems.com)
11* 12*
12* This program is free software;you can redistribute it and/or
13* modify it under the terms of the GNU General Public License as
14* published by the Free Software Foundation, version 2.
15*
16*
17* The driver was written by Tony Olech(tony.olech@elandigitalsystems.com) 13* The driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
18* based on various USB client drivers in the 2.6.15 linux kernel 14* based on various USB client drivers in the 2.6.15 linux kernel
19* with constant reference to the 3rd Edition of Linux Device Drivers 15* with constant reference to the 3rd Edition of Linux Device Drivers
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 0f5ad896c7e3..9ba4a4e68d91 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/***************************************************************************** 2/*****************************************************************************
2 * USBLCD Kernel Driver * 3 * USBLCD Kernel Driver *
3 * Version 1.05 * 4 * Version 1.05 *
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index 3f6a28045b53..12f7e94695a2 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB 7 Segment Driver 3 * USB 7 Segment Driver
3 * 4 *
4 * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> 5 * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com>
5 * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) 6 * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 5ad74750e8a4..aedc9a7f149e 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/init.h> 4#include <linux/init.h>
@@ -1023,7 +1024,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
1023 /* FIXME fetch strings from at least the device descriptor */ 1024 /* FIXME fetch strings from at least the device descriptor */
1024 1025
1025 /* [9.4.5] get_status always works */ 1026 /* [9.4.5] get_status always works */
1026 retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); 1027 retval = usb_get_std_status(udev, USB_RECIP_DEVICE, 0, dev->buf);
1027 if (retval) { 1028 if (retval) {
1028 dev_err(&iface->dev, "get dev status --> %d\n", retval); 1029 dev_err(&iface->dev, "get dev status --> %d\n", retval);
1029 return retval; 1030 return retval;
@@ -1033,7 +1034,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
1033 * the device's remote wakeup feature ... if we can, test that here 1034 * the device's remote wakeup feature ... if we can, test that here
1034 */ 1035 */
1035 1036
1036 retval = usb_get_status(udev, USB_RECIP_INTERFACE, 1037 retval = usb_get_std_status(udev, USB_RECIP_INTERFACE,
1037 iface->altsetting[0].desc.bInterfaceNumber, dev->buf); 1038 iface->altsetting[0].desc.bInterfaceNumber, dev->buf);
1038 if (retval) { 1039 if (retval) {
1039 dev_err(&iface->dev, "get interface status --> %d\n", retval); 1040 dev_err(&iface->dev, "get interface status --> %d\n", retval);
@@ -1622,7 +1623,7 @@ static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1622 u16 status; 1623 u16 status;
1623 1624
1624 /* shouldn't look or act halted */ 1625 /* shouldn't look or act halted */
1625 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1626 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1626 if (retval < 0) { 1627 if (retval < 0) {
1627 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", 1628 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
1628 ep, retval); 1629 ep, retval);
@@ -1644,7 +1645,7 @@ static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1644 u16 status; 1645 u16 status;
1645 1646
1646 /* should look and act halted */ 1647 /* should look and act halted */
1647 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); 1648 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1648 if (retval < 0) { 1649 if (retval < 0) {
1649 ERROR(tdev, "ep %02x couldn't get halt status, %d\n", 1650 ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
1650 ep, retval); 1651 ep, retval);
@@ -1917,7 +1918,7 @@ static struct urb *iso_alloc_urb(
1917 1918
1918 if (bytes < 0 || !desc) 1919 if (bytes < 0 || !desc)
1919 return NULL; 1920 return NULL;
1920 maxp = 0x7ff & usb_endpoint_maxp(desc); 1921 maxp = usb_endpoint_maxp(desc);
1921 maxp *= usb_endpoint_maxp_mult(desc); 1922 maxp *= usb_endpoint_maxp_mult(desc);
1922 packets = DIV_ROUND_UP(bytes, maxp); 1923 packets = DIV_ROUND_UP(bytes, maxp);
1923 1924
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 8a13b2fcf3e1..263c97fec708 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/*****************************************************************************/ 2/*****************************************************************************/
2 3
3/* 4/*
@@ -6,20 +7,6 @@
6 * Copyright (C) 1999, 2005, 2010 7 * Copyright (C) 1999, 2005, 2010
7 * Thomas Sailer (t.sailer@alumni.ethz.ch) 8 * Thomas Sailer (t.sailer@alumni.ethz.ch)
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * Based on parport_pc.c 10 * Based on parport_pc.c
24 * 11 *
25 * History: 12 * History:
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 58abdf28620a..8abb6cbbd98a 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for Meywa-Denki & KAYAC YUREX 3 * Driver for Meywa-Denki & KAYAC YUREX
3 * 4 *
4 * Copyright (C) 2010 Tomoki Sekiyama (tomoki.sekiyama@gmail.com) 5 * Copyright (C) 2010 Tomoki Sekiyama (tomoki.sekiyama@gmail.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 */ 6 */
11 7
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile
index 8ed24ab08698..09f43e89633c 100644
--- a/drivers/usb/mon/Makefile
+++ b/drivers/usb/mon/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# 2#
2# Makefile for USB monitor 3# Makefile for USB monitor
3# 4#
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index 46847340b819..9812d102a005 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * The USB Monitor, inspired by Dave Harding's USBMon. 3 * The USB Monitor, inspired by Dave Harding's USBMon.
3 * 4 *
diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
index b26fffc58446..3c888d942a9f 100644
--- a/drivers/usb/mtu3/mtu3.h
+++ b/drivers/usb/mtu3/mtu3.h
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3.h - MediaTek USB3 DRD header 3 * mtu3.h - MediaTek USB3 DRD header
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#ifndef __MTU3_H__ 10#ifndef __MTU3_H__
@@ -46,6 +37,9 @@ struct mtu3_request;
46#define MU3D_EP_RXCR1(epnum) (U3D_RX1CSR1 + (((epnum) - 1) * 0x10)) 37#define MU3D_EP_RXCR1(epnum) (U3D_RX1CSR1 + (((epnum) - 1) * 0x10))
47#define MU3D_EP_RXCR2(epnum) (U3D_RX1CSR2 + (((epnum) - 1) * 0x10)) 38#define MU3D_EP_RXCR2(epnum) (U3D_RX1CSR2 + (((epnum) - 1) * 0x10))
48 39
40#define USB_QMU_TQHIAR(epnum) (U3D_TXQHIAR1 + (((epnum) - 1) * 0x4))
41#define USB_QMU_RQHIAR(epnum) (U3D_RXQHIAR1 + (((epnum) - 1) * 0x4))
42
49#define USB_QMU_RQCSR(epnum) (U3D_RXQCSR1 + (((epnum) - 1) * 0x10)) 43#define USB_QMU_RQCSR(epnum) (U3D_RXQCSR1 + (((epnum) - 1) * 0x10))
50#define USB_QMU_RQSAR(epnum) (U3D_RXQSAR1 + (((epnum) - 1) * 0x10)) 44#define USB_QMU_RQSAR(epnum) (U3D_RXQSAR1 + (((epnum) - 1) * 0x10))
51#define USB_QMU_RQCPR(epnum) (U3D_RXQCPR1 + (((epnum) - 1) * 0x10)) 45#define USB_QMU_RQCPR(epnum) (U3D_RXQCPR1 + (((epnum) - 1) * 0x10))
@@ -91,6 +85,7 @@ enum mtu3_speed {
91 MTU3_SPEED_FULL = 1, 85 MTU3_SPEED_FULL = 1,
92 MTU3_SPEED_HIGH = 3, 86 MTU3_SPEED_HIGH = 3,
93 MTU3_SPEED_SUPER = 4, 87 MTU3_SPEED_SUPER = 4,
88 MTU3_SPEED_SUPER_PLUS = 5,
94}; 89};
95 90
96/** 91/**
@@ -112,6 +107,19 @@ enum mtu3_g_ep0_state {
112}; 107};
113 108
114/** 109/**
110 * MTU3_DR_FORCE_NONE: automatically switch host and periperal mode
111 * by IDPIN signal.
112 * MTU3_DR_FORCE_HOST: force to enter host mode and override OTG
113 * IDPIN signal.
114 * MTU3_DR_FORCE_DEVICE: force to enter peripheral mode.
115 */
116enum mtu3_dr_force_mode {
117 MTU3_DR_FORCE_NONE = 0,
118 MTU3_DR_FORCE_HOST,
119 MTU3_DR_FORCE_DEVICE,
120};
121
122/**
115 * @base: the base address of fifo 123 * @base: the base address of fifo
116 * @limit: the bitmap size in bits 124 * @limit: the bitmap size in bits
117 * @bitmap: fifo bitmap in unit of @MTU3_EP_FIFO_UNIT 125 * @bitmap: fifo bitmap in unit of @MTU3_EP_FIFO_UNIT
@@ -138,23 +146,33 @@ struct mtu3_fifo_info {
138 * Checksum value is calculated over the 16 bytes of the GPD by default; 146 * Checksum value is calculated over the 16 bytes of the GPD by default;
139 * @data_buf_len (RX ONLY): This value indicates the length of 147 * @data_buf_len (RX ONLY): This value indicates the length of
140 * the assigned data buffer 148 * the assigned data buffer
149 * @tx_ext_addr (TX ONLY): [3:0] are 4 extension bits of @buffer,
150 * [7:4] are 4 extension bits of @next_gpd
141 * @next_gpd: Physical address of the next GPD 151 * @next_gpd: Physical address of the next GPD
142 * @buffer: Physical address of the data buffer 152 * @buffer: Physical address of the data buffer
143 * @buf_len: 153 * @buf_len:
144 * (TX): This value indicates the length of the assigned data buffer 154 * (TX): This value indicates the length of the assigned data buffer
145 * (RX): The total length of data received 155 * (RX): The total length of data received
146 * @ext_len: reserved 156 * @ext_len: reserved
157 * @rx_ext_addr(RX ONLY): [3:0] are 4 extension bits of @buffer,
158 * [7:4] are 4 extension bits of @next_gpd
147 * @ext_flag: 159 * @ext_flag:
148 * bit5 (TX ONLY): Zero Length Packet (ZLP), 160 * bit5 (TX ONLY): Zero Length Packet (ZLP),
149 */ 161 */
150struct qmu_gpd { 162struct qmu_gpd {
151 __u8 flag; 163 __u8 flag;
152 __u8 chksum; 164 __u8 chksum;
153 __le16 data_buf_len; 165 union {
166 __le16 data_buf_len;
167 __le16 tx_ext_addr;
168 };
154 __le32 next_gpd; 169 __le32 next_gpd;
155 __le32 buffer; 170 __le32 buffer;
156 __le16 buf_len; 171 __le16 buf_len;
157 __u8 ext_len; 172 union {
173 __u8 ext_len;
174 __u8 rx_ext_addr;
175 };
158 __u8 ext_flag; 176 __u8 ext_flag;
159} __packed; 177} __packed;
160 178
@@ -183,7 +201,6 @@ struct mtu3_gpd_ring {
183* xHCI driver initialization, it's necessary for system bootup 201* xHCI driver initialization, it's necessary for system bootup
184* as device. 202* as device.
185* @is_u3_drd: whether port0 supports usb3.0 dual-role device or not 203* @is_u3_drd: whether port0 supports usb3.0 dual-role device or not
186* @id_*: used to maually switch between host and device modes by idpin
187* @manual_drd_enabled: it's true when supports dual-role device by debugfs 204* @manual_drd_enabled: it's true when supports dual-role device by debugfs
188* to switch host/device modes depending on user input. 205* to switch host/device modes depending on user input.
189*/ 206*/
@@ -194,10 +211,6 @@ struct otg_switch_mtk {
194 struct notifier_block id_nb; 211 struct notifier_block id_nb;
195 struct delayed_work extcon_reg_dwork; 212 struct delayed_work extcon_reg_dwork;
196 bool is_u3_drd; 213 bool is_u3_drd;
197 /* dual-role switch by debugfs */
198 struct pinctrl *id_pinctrl;
199 struct pinctrl_state *id_float;
200 struct pinctrl_state *id_ground;
201 bool manual_drd_enabled; 214 bool manual_drd_enabled;
202}; 215};
203 216
@@ -206,14 +219,17 @@ struct otg_switch_mtk {
206 * @ippc_base: register base address of IP Power and Clock interface (IPPC) 219 * @ippc_base: register base address of IP Power and Clock interface (IPPC)
207 * @vusb33: usb3.3V shared by device/host IP 220 * @vusb33: usb3.3V shared by device/host IP
208 * @sys_clk: system clock of mtu3, shared by device/host IP 221 * @sys_clk: system clock of mtu3, shared by device/host IP
222 * @ref_clk: reference clock
223 * @mcu_clk: mcu_bus_ck clock for AHB bus etc
224 * @dma_clk: dma_bus_ck clock for AXI bus etc
209 * @dr_mode: works in which mode: 225 * @dr_mode: works in which mode:
210 * host only, device only or dual-role mode 226 * host only, device only or dual-role mode
211 * @u2_ports: number of usb2.0 host ports 227 * @u2_ports: number of usb2.0 host ports
212 * @u3_ports: number of usb3.0 host ports 228 * @u3_ports: number of usb3.0 host ports
229 * @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to
230 * disable u3port0, bit1==1 to disable u3port1,... etc
213 * @dbgfs_root: only used when supports manual dual-role switch via debugfs 231 * @dbgfs_root: only used when supports manual dual-role switch via debugfs
214 * @wakeup_en: it's true when supports remote wakeup in host mode 232 * @wakeup_en: it's true when supports remote wakeup in host mode
215 * @wk_deb_p0: port0's wakeup debounce clock
216 * @wk_deb_p1: it's optional, and depends on port1 is supported or not
217 */ 233 */
218struct ssusb_mtk { 234struct ssusb_mtk {
219 struct device *dev; 235 struct device *dev;
@@ -226,17 +242,18 @@ struct ssusb_mtk {
226 struct regulator *vusb33; 242 struct regulator *vusb33;
227 struct clk *sys_clk; 243 struct clk *sys_clk;
228 struct clk *ref_clk; 244 struct clk *ref_clk;
245 struct clk *mcu_clk;
246 struct clk *dma_clk;
229 /* otg */ 247 /* otg */
230 struct otg_switch_mtk otg_switch; 248 struct otg_switch_mtk otg_switch;
231 enum usb_dr_mode dr_mode; 249 enum usb_dr_mode dr_mode;
232 bool is_host; 250 bool is_host;
233 int u2_ports; 251 int u2_ports;
234 int u3_ports; 252 int u3_ports;
253 int u3p_dis_msk;
235 struct dentry *dbgfs_root; 254 struct dentry *dbgfs_root;
236 /* usb wakeup for host mode */ 255 /* usb wakeup for host mode */
237 bool wakeup_en; 256 bool wakeup_en;
238 struct clk *wk_deb_p0;
239 struct clk *wk_deb_p1;
240 struct regmap *pericfg; 257 struct regmap *pericfg;
241}; 258};
242 259
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 99c65b0788ff..b1b99a8f6a7a 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_core.c - hardware access layer and gadget init/exit of 3 * mtu3_core.c - hardware access layer and gadget init/exit of
3 * MediaTek usb3 Dual-Role Controller Driver 4 * MediaTek usb3 Dual-Role Controller Driver
@@ -5,18 +6,9 @@
5 * Copyright (C) 2016 MediaTek Inc. 6 * Copyright (C) 2016 MediaTek Inc.
6 * 7 *
7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 8 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 */ 9 */
19 10
11#include <linux/dma-mapping.h>
20#include <linux/kernel.h> 12#include <linux/kernel.h>
21#include <linux/module.h> 13#include <linux/module.h>
22#include <linux/of_address.h> 14#include <linux/of_address.h>
@@ -114,7 +106,9 @@ static int mtu3_device_enable(struct mtu3 *mtu)
114 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), 106 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0),
115 (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | 107 (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN |
116 SSUSB_U2_PORT_HOST_SEL)); 108 SSUSB_U2_PORT_HOST_SEL));
117 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); 109
110 if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
111 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
118 112
119 return ssusb_check_clocks(mtu->ssusb, check_clk); 113 return ssusb_check_clocks(mtu->ssusb, check_clk);
120} 114}
@@ -129,7 +123,10 @@ static void mtu3_device_disable(struct mtu3 *mtu)
129 123
130 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), 124 mtu3_setbits(ibase, SSUSB_U2_CTRL(0),
131 SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN); 125 SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN);
132 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); 126
127 if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
128 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
129
133 mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); 130 mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
134} 131}
135 132
@@ -236,7 +233,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set)
236 233
237void mtu3_dev_on_off(struct mtu3 *mtu, int is_on) 234void mtu3_dev_on_off(struct mtu3 *mtu, int is_on)
238{ 235{
239 if (mtu->is_u3_ip && (mtu->max_speed == USB_SPEED_SUPER)) 236 if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER)
240 mtu3_ss_func_set(mtu, is_on); 237 mtu3_ss_func_set(mtu, is_on);
241 else 238 else
242 mtu3_hs_softconn_set(mtu, is_on); 239 mtu3_hs_softconn_set(mtu, is_on);
@@ -546,6 +543,9 @@ static void mtu3_set_speed(struct mtu3 *mtu)
546 mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); 543 mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN);
547 /* HS/FS detected by HW */ 544 /* HS/FS detected by HW */
548 mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); 545 mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE);
546 } else if (mtu->max_speed == USB_SPEED_SUPER) {
547 mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0),
548 SSUSB_U3_PORT_SSP_SPEED);
549 } 549 }
550 550
551 dev_info(mtu->dev, "max_speed: %s\n", 551 dev_info(mtu->dev, "max_speed: %s\n",
@@ -623,6 +623,10 @@ static irqreturn_t mtu3_link_isr(struct mtu3 *mtu)
623 udev_speed = USB_SPEED_SUPER; 623 udev_speed = USB_SPEED_SUPER;
624 maxpkt = 512; 624 maxpkt = 512;
625 break; 625 break;
626 case MTU3_SPEED_SUPER_PLUS:
627 udev_speed = USB_SPEED_SUPER_PLUS;
628 maxpkt = 512;
629 break;
626 default: 630 default:
627 udev_speed = USB_SPEED_UNKNOWN; 631 udev_speed = USB_SPEED_UNKNOWN;
628 break; 632 break;
@@ -759,7 +763,31 @@ static void mtu3_hw_exit(struct mtu3 *mtu)
759 mtu3_mem_free(mtu); 763 mtu3_mem_free(mtu);
760} 764}
761 765
762/*-------------------------------------------------------------------------*/ 766/**
767 * we set 32-bit DMA mask by default, here check whether the controller
768 * supports 36-bit DMA or not, if it does, set 36-bit DMA mask.
769 */
770static int mtu3_set_dma_mask(struct mtu3 *mtu)
771{
772 struct device *dev = mtu->dev;
773 bool is_36bit = false;
774 int ret = 0;
775 u32 value;
776
777 value = mtu3_readl(mtu->mac_base, U3D_MISC_CTRL);
778 if (value & DMA_ADDR_36BIT) {
779 is_36bit = true;
780 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(36));
781 /* If set 36-bit DMA mask fails, fall back to 32-bit DMA mask */
782 if (ret) {
783 is_36bit = false;
784 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
785 }
786 }
787 dev_info(dev, "dma mask: %s bits\n", is_36bit ? "36" : "32");
788
789 return ret;
790}
763 791
764int ssusb_gadget_init(struct ssusb_mtk *ssusb) 792int ssusb_gadget_init(struct ssusb_mtk *ssusb)
765{ 793{
@@ -774,9 +802,9 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
774 return -ENOMEM; 802 return -ENOMEM;
775 803
776 mtu->irq = platform_get_irq(pdev, 0); 804 mtu->irq = platform_get_irq(pdev, 0);
777 if (mtu->irq <= 0) { 805 if (mtu->irq < 0) {
778 dev_err(dev, "fail to get irq number\n"); 806 dev_err(dev, "fail to get irq number\n");
779 return -ENODEV; 807 return mtu->irq;
780 } 808 }
781 dev_info(dev, "irq %d\n", mtu->irq); 809 dev_info(dev, "irq %d\n", mtu->irq);
782 810
@@ -800,14 +828,15 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
800 case USB_SPEED_FULL: 828 case USB_SPEED_FULL:
801 case USB_SPEED_HIGH: 829 case USB_SPEED_HIGH:
802 case USB_SPEED_SUPER: 830 case USB_SPEED_SUPER:
831 case USB_SPEED_SUPER_PLUS:
803 break; 832 break;
804 default: 833 default:
805 dev_err(dev, "invalid max_speed: %s\n", 834 dev_err(dev, "invalid max_speed: %s\n",
806 usb_speed_string(mtu->max_speed)); 835 usb_speed_string(mtu->max_speed));
807 /* fall through */ 836 /* fall through */
808 case USB_SPEED_UNKNOWN: 837 case USB_SPEED_UNKNOWN:
809 /* default as SS */ 838 /* default as SSP */
810 mtu->max_speed = USB_SPEED_SUPER; 839 mtu->max_speed = USB_SPEED_SUPER_PLUS;
811 break; 840 break;
812 } 841 }
813 842
@@ -820,6 +849,12 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
820 return ret; 849 return ret;
821 } 850 }
822 851
852 ret = mtu3_set_dma_mask(mtu);
853 if (ret) {
854 dev_err(dev, "mtu3 set dma_mask failed:%d\n", ret);
855 goto dma_mask_err;
856 }
857
823 ret = devm_request_irq(dev, mtu->irq, mtu3_irq, 0, dev_name(dev), mtu); 858 ret = devm_request_irq(dev, mtu->irq, mtu3_irq, 0, dev_name(dev), mtu);
824 if (ret) { 859 if (ret) {
825 dev_err(dev, "request irq %d failed!\n", mtu->irq); 860 dev_err(dev, "request irq %d failed!\n", mtu->irq);
@@ -845,6 +880,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
845gadget_err: 880gadget_err:
846 device_init_wakeup(dev, false); 881 device_init_wakeup(dev, false);
847 882
883dma_mask_err:
848irq_err: 884irq_err:
849 mtu3_hw_exit(mtu); 885 mtu3_hw_exit(mtu);
850 ssusb->u3d = NULL; 886 ssusb->u3d = NULL;
diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
index 560256115b23..db7562d99b95 100644
--- a/drivers/usb/mtu3/mtu3_dr.c
+++ b/drivers/usb/mtu3/mtu3_dr.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_dr.c - dual role switch and host glue layer 3 * mtu3_dr.c - dual role switch and host glue layer
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include <linux/debugfs.h> 10#include <linux/debugfs.h>
@@ -261,21 +252,22 @@ static void extcon_register_dwork(struct work_struct *work)
261 * depending on user input. 252 * depending on user input.
262 * This is useful in special cases, such as uses TYPE-A receptacle but also 253 * This is useful in special cases, such as uses TYPE-A receptacle but also
263 * wants to support dual-role mode. 254 * wants to support dual-role mode.
264 * It generates cable state changes by pulling up/down IDPIN and
265 * notifies driver to switch mode by "extcon-usb-gpio".
266 * NOTE: when use MICRO receptacle, should not enable this interface.
267 */ 255 */
268static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host) 256static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host)
269{ 257{
270 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; 258 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
271 259
272 if (to_host) 260 if (to_host) {
273 pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_ground); 261 ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_HOST);
274 else 262 ssusb_set_mailbox(otg_sx, MTU3_VBUS_OFF);
275 pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_float); 263 ssusb_set_mailbox(otg_sx, MTU3_ID_GROUND);
264 } else {
265 ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_DEVICE);
266 ssusb_set_mailbox(otg_sx, MTU3_ID_FLOAT);
267 ssusb_set_mailbox(otg_sx, MTU3_VBUS_VALID);
268 }
276} 269}
277 270
278
279static int ssusb_mode_show(struct seq_file *sf, void *unused) 271static int ssusb_mode_show(struct seq_file *sf, void *unused)
280{ 272{
281 struct ssusb_mtk *ssusb = sf->private; 273 struct ssusb_mtk *ssusb = sf->private;
@@ -388,17 +380,45 @@ static void ssusb_debugfs_exit(struct ssusb_mtk *ssusb)
388 debugfs_remove_recursive(ssusb->dbgfs_root); 380 debugfs_remove_recursive(ssusb->dbgfs_root);
389} 381}
390 382
383void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
384 enum mtu3_dr_force_mode mode)
385{
386 u32 value;
387
388 value = mtu3_readl(ssusb->ippc_base, SSUSB_U2_CTRL(0));
389 switch (mode) {
390 case MTU3_DR_FORCE_DEVICE:
391 value |= SSUSB_U2_PORT_FORCE_IDDIG | SSUSB_U2_PORT_RG_IDDIG;
392 break;
393 case MTU3_DR_FORCE_HOST:
394 value |= SSUSB_U2_PORT_FORCE_IDDIG;
395 value &= ~SSUSB_U2_PORT_RG_IDDIG;
396 break;
397 case MTU3_DR_FORCE_NONE:
398 value &= ~(SSUSB_U2_PORT_FORCE_IDDIG | SSUSB_U2_PORT_RG_IDDIG);
399 break;
400 default:
401 return;
402 }
403 mtu3_writel(ssusb->ippc_base, SSUSB_U2_CTRL(0), value);
404}
405
391int ssusb_otg_switch_init(struct ssusb_mtk *ssusb) 406int ssusb_otg_switch_init(struct ssusb_mtk *ssusb)
392{ 407{
393 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; 408 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
394 409
395 INIT_DELAYED_WORK(&otg_sx->extcon_reg_dwork, extcon_register_dwork); 410 if (otg_sx->manual_drd_enabled) {
396
397 if (otg_sx->manual_drd_enabled)
398 ssusb_debugfs_init(ssusb); 411 ssusb_debugfs_init(ssusb);
399 412 } else {
400 /* It is enough to delay 1s for waiting for host initialization */ 413 INIT_DELAYED_WORK(&otg_sx->extcon_reg_dwork,
401 schedule_delayed_work(&otg_sx->extcon_reg_dwork, HZ); 414 extcon_register_dwork);
415
416 /*
417 * It is enough to delay 1s for waiting for
418 * host initialization
419 */
420 schedule_delayed_work(&otg_sx->extcon_reg_dwork, HZ);
421 }
402 422
403 return 0; 423 return 0;
404} 424}
@@ -407,8 +427,8 @@ void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb)
407{ 427{
408 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; 428 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
409 429
410 cancel_delayed_work(&otg_sx->extcon_reg_dwork);
411
412 if (otg_sx->manual_drd_enabled) 430 if (otg_sx->manual_drd_enabled)
413 ssusb_debugfs_exit(ssusb); 431 ssusb_debugfs_exit(ssusb);
432 else
433 cancel_delayed_work(&otg_sx->extcon_reg_dwork);
414} 434}
diff --git a/drivers/usb/mtu3/mtu3_dr.h b/drivers/usb/mtu3/mtu3_dr.h
index 9b228b5811b0..c179192408ba 100644
--- a/drivers/usb/mtu3/mtu3_dr.h
+++ b/drivers/usb/mtu3/mtu3_dr.h
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_dr.h - dual role switch and host glue layer header 3 * mtu3_dr.h - dual role switch and host glue layer header
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#ifndef _MTU3_DR_H_ 10#ifndef _MTU3_DR_H_
@@ -87,6 +78,8 @@ static inline void ssusb_gadget_exit(struct ssusb_mtk *ssusb)
87int ssusb_otg_switch_init(struct ssusb_mtk *ssusb); 78int ssusb_otg_switch_init(struct ssusb_mtk *ssusb);
88void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb); 79void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb);
89int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on); 80int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on);
81void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
82 enum mtu3_dr_force_mode mode);
90 83
91#else 84#else
92 85
@@ -103,6 +96,10 @@ static inline int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on)
103 return 0; 96 return 0;
104} 97}
105 98
99static inline void
100ssusb_set_force_mode(struct ssusb_mtk *ssusb, enum mtu3_dr_force_mode mode)
101{}
102
106#endif 103#endif
107 104
108#endif /* _MTU3_DR_H_ */ 105#endif /* _MTU3_DR_H_ */
diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index 434fca58143c..f05f10f5c171 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_gadget.c - MediaTek usb3 DRD peripheral support 3 * mtu3_gadget.c - MediaTek usb3 DRD peripheral support
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include "mtu3.h" 10#include "mtu3.h"
@@ -89,6 +80,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
89 80
90 switch (mtu->g.speed) { 81 switch (mtu->g.speed) {
91 case USB_SPEED_SUPER: 82 case USB_SPEED_SUPER:
83 case USB_SPEED_SUPER_PLUS:
92 if (usb_endpoint_xfer_int(desc) || 84 if (usb_endpoint_xfer_int(desc) ||
93 usb_endpoint_xfer_isoc(desc)) { 85 usb_endpoint_xfer_isoc(desc)) {
94 interval = desc->bInterval; 86 interval = desc->bInterval;
@@ -456,7 +448,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget)
456 return -EOPNOTSUPP; 448 return -EOPNOTSUPP;
457 449
458 spin_lock_irqsave(&mtu->lock, flags); 450 spin_lock_irqsave(&mtu->lock, flags);
459 if (mtu->g.speed == USB_SPEED_SUPER) { 451 if (mtu->g.speed >= USB_SPEED_SUPER) {
460 mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); 452 mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT);
461 } else { 453 } else {
462 mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); 454 mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c
index 958d74dd2b78..ebdcf7a38c29 100644
--- a/drivers/usb/mtu3/mtu3_gadget_ep0.c
+++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_gadget_ep0.c - MediaTek USB3 DRD peripheral driver ep0 handling 3 * mtu3_gadget_ep0.c - MediaTek USB3 DRD peripheral driver ep0 handling
3 * 4 *
4 * Copyright (c) 2016 MediaTek Inc. 5 * Copyright (c) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng.Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng.Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include <linux/usb/composite.h> 10#include <linux/usb/composite.h>
@@ -212,8 +203,8 @@ ep0_get_status(struct mtu3 *mtu, const struct usb_ctrlrequest *setup)
212 case USB_RECIP_DEVICE: 203 case USB_RECIP_DEVICE:
213 result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED; 204 result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED;
214 result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; 205 result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP;
215 /* superspeed only */ 206
216 if (mtu->g.speed == USB_SPEED_SUPER) { 207 if (mtu->g.speed >= USB_SPEED_SUPER) {
217 result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED; 208 result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED;
218 result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED; 209 result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED;
219 } 210 }
@@ -329,8 +320,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
329 handled = handle_test_mode(mtu, setup); 320 handled = handle_test_mode(mtu, setup);
330 break; 321 break;
331 case USB_DEVICE_U1_ENABLE: 322 case USB_DEVICE_U1_ENABLE:
332 if (mtu->g.speed != USB_SPEED_SUPER || 323 if (mtu->g.speed < USB_SPEED_SUPER ||
333 mtu->g.state != USB_STATE_CONFIGURED) 324 mtu->g.state != USB_STATE_CONFIGURED)
334 break; 325 break;
335 326
336 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); 327 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
@@ -344,8 +335,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
344 handled = 1; 335 handled = 1;
345 break; 336 break;
346 case USB_DEVICE_U2_ENABLE: 337 case USB_DEVICE_U2_ENABLE:
347 if (mtu->g.speed != USB_SPEED_SUPER || 338 if (mtu->g.speed < USB_SPEED_SUPER ||
348 mtu->g.state != USB_STATE_CONFIGURED) 339 mtu->g.state != USB_STATE_CONFIGURED)
349 break; 340 break;
350 341
351 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); 342 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
@@ -384,8 +375,8 @@ static int ep0_handle_feature(struct mtu3 *mtu,
384 break; 375 break;
385 case USB_RECIP_INTERFACE: 376 case USB_RECIP_INTERFACE:
386 /* superspeed only */ 377 /* superspeed only */
387 if ((value == USB_INTRF_FUNC_SUSPEND) 378 if (value == USB_INTRF_FUNC_SUSPEND &&
388 && (mtu->g.speed == USB_SPEED_SUPER)) { 379 mtu->g.speed >= USB_SPEED_SUPER) {
389 /* 380 /*
390 * forward the request because function drivers 381 * forward the request because function drivers
391 * should handle it 382 * should handle it
diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index e42d308b8dc2..d237d7e65c44 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_dr.c - dual role switch and host glue layer 3 * mtu3_dr.c - dual role switch and host glue layer
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include <linux/clk.h> 10#include <linux/clk.h>
@@ -79,20 +70,6 @@ int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
79 if (!ssusb->wakeup_en) 70 if (!ssusb->wakeup_en)
80 return 0; 71 return 0;
81 72
82 ssusb->wk_deb_p0 = devm_clk_get(dev, "wakeup_deb_p0");
83 if (IS_ERR(ssusb->wk_deb_p0)) {
84 dev_err(dev, "fail to get wakeup_deb_p0\n");
85 return PTR_ERR(ssusb->wk_deb_p0);
86 }
87
88 if (of_property_read_bool(dn, "wakeup_deb_p1")) {
89 ssusb->wk_deb_p1 = devm_clk_get(dev, "wakeup_deb_p1");
90 if (IS_ERR(ssusb->wk_deb_p1)) {
91 dev_err(dev, "fail to get wakeup_deb_p1\n");
92 return PTR_ERR(ssusb->wk_deb_p1);
93 }
94 }
95
96 ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn, 73 ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
97 "mediatek,syscon-wakeup"); 74 "mediatek,syscon-wakeup");
98 if (IS_ERR(ssusb->pericfg)) { 75 if (IS_ERR(ssusb->pericfg)) {
@@ -103,36 +80,6 @@ int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
103 return 0; 80 return 0;
104} 81}
105 82
106static int ssusb_wakeup_clks_enable(struct ssusb_mtk *ssusb)
107{
108 int ret;
109
110 ret = clk_prepare_enable(ssusb->wk_deb_p0);
111 if (ret) {
112 dev_err(ssusb->dev, "failed to enable wk_deb_p0\n");
113 goto usb_p0_err;
114 }
115
116 ret = clk_prepare_enable(ssusb->wk_deb_p1);
117 if (ret) {
118 dev_err(ssusb->dev, "failed to enable wk_deb_p1\n");
119 goto usb_p1_err;
120 }
121
122 return 0;
123
124usb_p1_err:
125 clk_disable_unprepare(ssusb->wk_deb_p0);
126usb_p0_err:
127 return -EINVAL;
128}
129
130static void ssusb_wakeup_clks_disable(struct ssusb_mtk *ssusb)
131{
132 clk_disable_unprepare(ssusb->wk_deb_p1);
133 clk_disable_unprepare(ssusb->wk_deb_p0);
134}
135
136static void host_ports_num_get(struct ssusb_mtk *ssusb) 83static void host_ports_num_get(struct ssusb_mtk *ssusb)
137{ 84{
138 u32 xhci_cap; 85 u32 xhci_cap;
@@ -151,6 +98,7 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
151 void __iomem *ibase = ssusb->ippc_base; 98 void __iomem *ibase = ssusb->ippc_base;
152 int num_u3p = ssusb->u3_ports; 99 int num_u3p = ssusb->u3_ports;
153 int num_u2p = ssusb->u2_ports; 100 int num_u2p = ssusb->u2_ports;
101 int u3_ports_disabed;
154 u32 check_clk; 102 u32 check_clk;
155 u32 value; 103 u32 value;
156 int i; 104 int i;
@@ -158,8 +106,14 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
158 /* power on host ip */ 106 /* power on host ip */
159 mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL1, SSUSB_IP_HOST_PDN); 107 mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL1, SSUSB_IP_HOST_PDN);
160 108
161 /* power on and enable all u3 ports */ 109 /* power on and enable u3 ports except skipped ones */
110 u3_ports_disabed = 0;
162 for (i = 0; i < num_u3p; i++) { 111 for (i = 0; i < num_u3p; i++) {
112 if ((0x1 << i) & ssusb->u3p_dis_msk) {
113 u3_ports_disabed++;
114 continue;
115 }
116
163 value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); 117 value = mtu3_readl(ibase, SSUSB_U3_CTRL(i));
164 value &= ~(SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_DIS); 118 value &= ~(SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_DIS);
165 value |= SSUSB_U3_PORT_HOST_SEL; 119 value |= SSUSB_U3_PORT_HOST_SEL;
@@ -175,7 +129,7 @@ int ssusb_host_enable(struct ssusb_mtk *ssusb)
175 } 129 }
176 130
177 check_clk = SSUSB_XHCI_RST_B_STS; 131 check_clk = SSUSB_XHCI_RST_B_STS;
178 if (num_u3p) 132 if (num_u3p > u3_ports_disabed)
179 check_clk = SSUSB_U3_MAC_RST_B_STS; 133 check_clk = SSUSB_U3_MAC_RST_B_STS;
180 134
181 return ssusb_check_clocks(ssusb, check_clk); 135 return ssusb_check_clocks(ssusb, check_clk);
@@ -190,8 +144,11 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
190 int ret; 144 int ret;
191 int i; 145 int i;
192 146
193 /* power down and disable all u3 ports */ 147 /* power down and disable u3 ports except skipped ones */
194 for (i = 0; i < num_u3p; i++) { 148 for (i = 0; i < num_u3p; i++) {
149 if ((0x1 << i) & ssusb->u3p_dis_msk)
150 continue;
151
195 value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); 152 value = mtu3_readl(ibase, SSUSB_U3_CTRL(i));
196 value |= SSUSB_U3_PORT_PDN; 153 value |= SSUSB_U3_PORT_PDN;
197 value |= suspend ? 0 : SSUSB_U3_PORT_DIS; 154 value |= suspend ? 0 : SSUSB_U3_PORT_DIS;
@@ -223,6 +180,8 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
223 180
224static void ssusb_host_setup(struct ssusb_mtk *ssusb) 181static void ssusb_host_setup(struct ssusb_mtk *ssusb)
225{ 182{
183 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
184
226 host_ports_num_get(ssusb); 185 host_ports_num_get(ssusb);
227 186
228 /* 187 /*
@@ -231,6 +190,9 @@ static void ssusb_host_setup(struct ssusb_mtk *ssusb)
231 */ 190 */
232 ssusb_host_enable(ssusb); 191 ssusb_host_enable(ssusb);
233 192
193 if (otg_sx->manual_drd_enabled)
194 ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_HOST);
195
234 /* if port0 supports dual-role, works as host mode by default */ 196 /* if port0 supports dual-role, works as host mode by default */
235 ssusb_set_vbus(&ssusb->otg_switch, 1); 197 ssusb_set_vbus(&ssusb->otg_switch, 1);
236} 198}
@@ -276,19 +238,14 @@ void ssusb_host_exit(struct ssusb_mtk *ssusb)
276 238
277int ssusb_wakeup_enable(struct ssusb_mtk *ssusb) 239int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
278{ 240{
279 int ret = 0; 241 if (ssusb->wakeup_en)
280
281 if (ssusb->wakeup_en) {
282 ret = ssusb_wakeup_clks_enable(ssusb);
283 ssusb_wakeup_ip_sleep_en(ssusb); 242 ssusb_wakeup_ip_sleep_en(ssusb);
284 } 243
285 return ret; 244 return 0;
286} 245}
287 246
288void ssusb_wakeup_disable(struct ssusb_mtk *ssusb) 247void ssusb_wakeup_disable(struct ssusb_mtk *ssusb)
289{ 248{
290 if (ssusb->wakeup_en) { 249 if (ssusb->wakeup_en)
291 ssusb_wakeup_ip_sleep_dis(ssusb); 250 ssusb_wakeup_ip_sleep_dis(ssusb);
292 ssusb_wakeup_clks_disable(ssusb);
293 }
294} 251}
diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
index 06b29664470f..6ee371478d89 100644
--- a/drivers/usb/mtu3/mtu3_hw_regs.h
+++ b/drivers/usb/mtu3/mtu3_hw_regs.h
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_hw_regs.h - MediaTek USB3 DRD register and field definitions 3 * mtu3_hw_regs.h - MediaTek USB3 DRD register and field definitions
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#ifndef _SSUSB_HW_REGS_H_ 10#ifndef _SSUSB_HW_REGS_H_
@@ -58,6 +49,8 @@
58#define U3D_QCR1 (SSUSB_DEV_BASE + 0x0404) 49#define U3D_QCR1 (SSUSB_DEV_BASE + 0x0404)
59#define U3D_QCR2 (SSUSB_DEV_BASE + 0x0408) 50#define U3D_QCR2 (SSUSB_DEV_BASE + 0x0408)
60#define U3D_QCR3 (SSUSB_DEV_BASE + 0x040C) 51#define U3D_QCR3 (SSUSB_DEV_BASE + 0x040C)
52#define U3D_TXQHIAR1 (SSUSB_DEV_BASE + 0x0484)
53#define U3D_RXQHIAR1 (SSUSB_DEV_BASE + 0x04C4)
61 54
62#define U3D_TXQCSR1 (SSUSB_DEV_BASE + 0x0510) 55#define U3D_TXQCSR1 (SSUSB_DEV_BASE + 0x0510)
63#define U3D_TXQSAR1 (SSUSB_DEV_BASE + 0x0514) 56#define U3D_TXQSAR1 (SSUSB_DEV_BASE + 0x0514)
@@ -189,6 +182,13 @@
189#define QMU_RX_COZ(x) (BIT(16) << (x)) 182#define QMU_RX_COZ(x) (BIT(16) << (x))
190#define QMU_RX_ZLP(x) (BIT(0) << (x)) 183#define QMU_RX_ZLP(x) (BIT(0) << (x))
191 184
185/* U3D_TXQHIAR1 */
186/* U3D_RXQHIAR1 */
187#define QMU_LAST_DONE_PTR_HI(x) (((x) >> 16) & 0xf)
188#define QMU_CUR_GPD_ADDR_HI(x) (((x) >> 8) & 0xf)
189#define QMU_START_ADDR_HI_MSK GENMASK(3, 0)
190#define QMU_START_ADDR_HI(x) (((x) & 0xf) << 0)
191
192/* U3D_TXQCSR1 */ 192/* U3D_TXQCSR1 */
193/* U3D_RXQCSR1 */ 193/* U3D_RXQCSR1 */
194#define QMU_Q_ACTIVE BIT(15) 194#define QMU_Q_ACTIVE BIT(15)
@@ -225,6 +225,7 @@
225#define CAP_TX_EP_NUM(x) ((x) & 0x1f) 225#define CAP_TX_EP_NUM(x) ((x) & 0x1f)
226 226
227/* U3D_MISC_CTRL */ 227/* U3D_MISC_CTRL */
228#define DMA_ADDR_36BIT BIT(31)
228#define VBUS_ON BIT(1) 229#define VBUS_ON BIT(1)
229#define VBUS_FRC_EN BIT(0) 230#define VBUS_FRC_EN BIT(0)
230 231
@@ -457,11 +458,14 @@
457#define SSUSB_VBUS_CHG_INT_B_EN BIT(6) 458#define SSUSB_VBUS_CHG_INT_B_EN BIT(6)
458 459
459/* U3D_SSUSB_U3_CTRL_0P */ 460/* U3D_SSUSB_U3_CTRL_0P */
461#define SSUSB_U3_PORT_SSP_SPEED BIT(9)
460#define SSUSB_U3_PORT_HOST_SEL BIT(2) 462#define SSUSB_U3_PORT_HOST_SEL BIT(2)
461#define SSUSB_U3_PORT_PDN BIT(1) 463#define SSUSB_U3_PORT_PDN BIT(1)
462#define SSUSB_U3_PORT_DIS BIT(0) 464#define SSUSB_U3_PORT_DIS BIT(0)
463 465
464/* U3D_SSUSB_U2_CTRL_0P */ 466/* U3D_SSUSB_U2_CTRL_0P */
467#define SSUSB_U2_PORT_RG_IDDIG BIT(12)
468#define SSUSB_U2_PORT_FORCE_IDDIG BIT(11)
465#define SSUSB_U2_PORT_VBUSVALID BIT(9) 469#define SSUSB_U2_PORT_VBUSVALID BIT(9)
466#define SSUSB_U2_PORT_OTG_SEL BIT(7) 470#define SSUSB_U2_PORT_OTG_SEL BIT(7)
467#define SSUSB_U2_PORT_HOST BIT(2) 471#define SSUSB_U2_PORT_HOST BIT(2)
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index 088e3e685c4f..3650fd11fc49 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -1,17 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2016 MediaTek Inc. 3 * Copyright (C) 2016 MediaTek Inc.
3 * 4 *
4 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 5 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */ 6 */
16 7
17#include <linux/clk.h> 8#include <linux/clk.h>
@@ -21,7 +12,6 @@
21#include <linux/module.h> 12#include <linux/module.h>
22#include <linux/of_address.h> 13#include <linux/of_address.h>
23#include <linux/of_irq.h> 14#include <linux/of_irq.h>
24#include <linux/pinctrl/consumer.h>
25#include <linux/platform_device.h> 15#include <linux/platform_device.h>
26 16
27#include "mtu3.h" 17#include "mtu3.h"
@@ -110,15 +100,9 @@ static void ssusb_phy_power_off(struct ssusb_mtk *ssusb)
110 phy_power_off(ssusb->phys[i]); 100 phy_power_off(ssusb->phys[i]);
111} 101}
112 102
113static int ssusb_rscs_init(struct ssusb_mtk *ssusb) 103static int ssusb_clks_enable(struct ssusb_mtk *ssusb)
114{ 104{
115 int ret = 0; 105 int ret;
116
117 ret = regulator_enable(ssusb->vusb33);
118 if (ret) {
119 dev_err(ssusb->dev, "failed to enable vusb33\n");
120 goto vusb33_err;
121 }
122 106
123 ret = clk_prepare_enable(ssusb->sys_clk); 107 ret = clk_prepare_enable(ssusb->sys_clk);
124 if (ret) { 108 if (ret) {
@@ -132,6 +116,52 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
132 goto ref_clk_err; 116 goto ref_clk_err;
133 } 117 }
134 118
119 ret = clk_prepare_enable(ssusb->mcu_clk);
120 if (ret) {
121 dev_err(ssusb->dev, "failed to enable mcu_clk\n");
122 goto mcu_clk_err;
123 }
124
125 ret = clk_prepare_enable(ssusb->dma_clk);
126 if (ret) {
127 dev_err(ssusb->dev, "failed to enable dma_clk\n");
128 goto dma_clk_err;
129 }
130
131 return 0;
132
133dma_clk_err:
134 clk_disable_unprepare(ssusb->mcu_clk);
135mcu_clk_err:
136 clk_disable_unprepare(ssusb->ref_clk);
137ref_clk_err:
138 clk_disable_unprepare(ssusb->sys_clk);
139sys_clk_err:
140 return ret;
141}
142
143static void ssusb_clks_disable(struct ssusb_mtk *ssusb)
144{
145 clk_disable_unprepare(ssusb->dma_clk);
146 clk_disable_unprepare(ssusb->mcu_clk);
147 clk_disable_unprepare(ssusb->ref_clk);
148 clk_disable_unprepare(ssusb->sys_clk);
149}
150
151static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
152{
153 int ret = 0;
154
155 ret = regulator_enable(ssusb->vusb33);
156 if (ret) {
157 dev_err(ssusb->dev, "failed to enable vusb33\n");
158 goto vusb33_err;
159 }
160
161 ret = ssusb_clks_enable(ssusb);
162 if (ret)
163 goto clks_err;
164
135 ret = ssusb_phy_init(ssusb); 165 ret = ssusb_phy_init(ssusb);
136 if (ret) { 166 if (ret) {
137 dev_err(ssusb->dev, "failed to init phy\n"); 167 dev_err(ssusb->dev, "failed to init phy\n");
@@ -149,20 +179,16 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
149phy_err: 179phy_err:
150 ssusb_phy_exit(ssusb); 180 ssusb_phy_exit(ssusb);
151phy_init_err: 181phy_init_err:
152 clk_disable_unprepare(ssusb->ref_clk); 182 ssusb_clks_disable(ssusb);
153ref_clk_err: 183clks_err:
154 clk_disable_unprepare(ssusb->sys_clk);
155sys_clk_err:
156 regulator_disable(ssusb->vusb33); 184 regulator_disable(ssusb->vusb33);
157vusb33_err: 185vusb33_err:
158
159 return ret; 186 return ret;
160} 187}
161 188
162static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) 189static void ssusb_rscs_exit(struct ssusb_mtk *ssusb)
163{ 190{
164 clk_disable_unprepare(ssusb->sys_clk); 191 ssusb_clks_disable(ssusb);
165 clk_disable_unprepare(ssusb->ref_clk);
166 regulator_disable(ssusb->vusb33); 192 regulator_disable(ssusb->vusb33);
167 ssusb_phy_power_off(ssusb); 193 ssusb_phy_power_off(ssusb);
168 ssusb_phy_exit(ssusb); 194 ssusb_phy_exit(ssusb);
@@ -176,31 +202,17 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
176 mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST); 202 mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
177} 203}
178 204
179static int get_iddig_pinctrl(struct ssusb_mtk *ssusb) 205/* ignore the error if the clock does not exist */
206static struct clk *get_optional_clk(struct device *dev, const char *id)
180{ 207{
181 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; 208 struct clk *opt_clk;
182
183 otg_sx->id_pinctrl = devm_pinctrl_get(ssusb->dev);
184 if (IS_ERR(otg_sx->id_pinctrl)) {
185 dev_err(ssusb->dev, "Cannot find id pinctrl!\n");
186 return PTR_ERR(otg_sx->id_pinctrl);
187 }
188
189 otg_sx->id_float =
190 pinctrl_lookup_state(otg_sx->id_pinctrl, "id_float");
191 if (IS_ERR(otg_sx->id_float)) {
192 dev_err(ssusb->dev, "Cannot find pinctrl id_float!\n");
193 return PTR_ERR(otg_sx->id_float);
194 }
195 209
196 otg_sx->id_ground = 210 opt_clk = devm_clk_get(dev, id);
197 pinctrl_lookup_state(otg_sx->id_pinctrl, "id_ground"); 211 /* ignore error number except EPROBE_DEFER */
198 if (IS_ERR(otg_sx->id_ground)) { 212 if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
199 dev_err(ssusb->dev, "Cannot find pinctrl id_ground!\n"); 213 opt_clk = NULL;
200 return PTR_ERR(otg_sx->id_ground);
201 }
202 214
203 return 0; 215 return opt_clk;
204} 216}
205 217
206static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) 218static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
@@ -225,18 +237,17 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
225 return PTR_ERR(ssusb->sys_clk); 237 return PTR_ERR(ssusb->sys_clk);
226 } 238 }
227 239
228 /* 240 ssusb->ref_clk = get_optional_clk(dev, "ref_ck");
229 * reference clock is usually a "fixed-clock", make it optional 241 if (IS_ERR(ssusb->ref_clk))
230 * for backward compatibility and ignore the error if it does 242 return PTR_ERR(ssusb->ref_clk);
231 * not exist.
232 */
233 ssusb->ref_clk = devm_clk_get(dev, "ref_ck");
234 if (IS_ERR(ssusb->ref_clk)) {
235 if (PTR_ERR(ssusb->ref_clk) == -EPROBE_DEFER)
236 return -EPROBE_DEFER;
237 243
238 ssusb->ref_clk = NULL; 244 ssusb->mcu_clk = get_optional_clk(dev, "mcu_ck");
239 } 245 if (IS_ERR(ssusb->mcu_clk))
246 return PTR_ERR(ssusb->mcu_clk);
247
248 ssusb->dma_clk = get_optional_clk(dev, "dma_ck");
249 if (IS_ERR(ssusb->dma_clk))
250 return PTR_ERR(ssusb->dma_clk);
240 251
241 ssusb->num_phys = of_count_phandle_with_args(node, 252 ssusb->num_phys = of_count_phandle_with_args(node,
242 "phys", "#phy-cells"); 253 "phys", "#phy-cells");
@@ -263,10 +274,8 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
263 return PTR_ERR(ssusb->ippc_base); 274 return PTR_ERR(ssusb->ippc_base);
264 275
265 ssusb->dr_mode = usb_get_dr_mode(dev); 276 ssusb->dr_mode = usb_get_dr_mode(dev);
266 if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN) { 277 if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN)
267 dev_err(dev, "dr_mode is error\n"); 278 ssusb->dr_mode = USB_DR_MODE_OTG;
268 return -EINVAL;
269 }
270 279
271 if (ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) 280 if (ssusb->dr_mode == USB_DR_MODE_PERIPHERAL)
272 return 0; 281 return 0;
@@ -276,10 +285,10 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
276 if (ret) 285 if (ret)
277 return ret; 286 return ret;
278 287
279 if (ssusb->dr_mode != USB_DR_MODE_OTG) 288 /* optional property, ignore the error if it does not exist */
280 return 0; 289 of_property_read_u32(node, "mediatek,u3p-dis-msk",
290 &ssusb->u3p_dis_msk);
281 291
282 /* if dual-role mode is supported */
283 vbus = devm_regulator_get(&pdev->dev, "vbus"); 292 vbus = devm_regulator_get(&pdev->dev, "vbus");
284 if (IS_ERR(vbus)) { 293 if (IS_ERR(vbus)) {
285 dev_err(dev, "failed to get vbus\n"); 294 dev_err(dev, "failed to get vbus\n");
@@ -287,6 +296,10 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
287 } 296 }
288 otg_sx->vbus = vbus; 297 otg_sx->vbus = vbus;
289 298
299 if (ssusb->dr_mode == USB_DR_MODE_HOST)
300 return 0;
301
302 /* if dual-role mode is supported */
290 otg_sx->is_u3_drd = of_property_read_bool(node, "mediatek,usb3-drd"); 303 otg_sx->is_u3_drd = of_property_read_bool(node, "mediatek,usb3-drd");
291 otg_sx->manual_drd_enabled = 304 otg_sx->manual_drd_enabled =
292 of_property_read_bool(node, "enable-manual-drd"); 305 of_property_read_bool(node, "enable-manual-drd");
@@ -297,15 +310,11 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
297 dev_err(ssusb->dev, "couldn't get extcon device\n"); 310 dev_err(ssusb->dev, "couldn't get extcon device\n");
298 return -EPROBE_DEFER; 311 return -EPROBE_DEFER;
299 } 312 }
300 if (otg_sx->manual_drd_enabled) {
301 ret = get_iddig_pinctrl(ssusb);
302 if (ret)
303 return ret;
304 }
305 } 313 }
306 314
307 dev_info(dev, "dr_mode: %d, is_u3_dr: %d\n", 315 dev_info(dev, "dr_mode: %d, is_u3_dr: %d, u3p_dis_msk: %x, drd: %s\n",
308 ssusb->dr_mode, otg_sx->is_u3_drd); 316 ssusb->dr_mode, otg_sx->is_u3_drd, ssusb->u3p_dis_msk,
317 otg_sx->manual_drd_enabled ? "manual" : "auto");
309 318
310 return 0; 319 return 0;
311} 320}
@@ -447,8 +456,7 @@ static int __maybe_unused mtu3_suspend(struct device *dev)
447 456
448 ssusb_host_disable(ssusb, true); 457 ssusb_host_disable(ssusb, true);
449 ssusb_phy_power_off(ssusb); 458 ssusb_phy_power_off(ssusb);
450 clk_disable_unprepare(ssusb->sys_clk); 459 ssusb_clks_disable(ssusb);
451 clk_disable_unprepare(ssusb->ref_clk);
452 ssusb_wakeup_enable(ssusb); 460 ssusb_wakeup_enable(ssusb);
453 461
454 return 0; 462 return 0;
@@ -466,27 +474,21 @@ static int __maybe_unused mtu3_resume(struct device *dev)
466 return 0; 474 return 0;
467 475
468 ssusb_wakeup_disable(ssusb); 476 ssusb_wakeup_disable(ssusb);
469 ret = clk_prepare_enable(ssusb->sys_clk); 477 ret = ssusb_clks_enable(ssusb);
470 if (ret)
471 goto err_sys_clk;
472
473 ret = clk_prepare_enable(ssusb->ref_clk);
474 if (ret) 478 if (ret)
475 goto err_ref_clk; 479 goto clks_err;
476 480
477 ret = ssusb_phy_power_on(ssusb); 481 ret = ssusb_phy_power_on(ssusb);
478 if (ret) 482 if (ret)
479 goto err_power_on; 483 goto phy_err;
480 484
481 ssusb_host_enable(ssusb); 485 ssusb_host_enable(ssusb);
482 486
483 return 0; 487 return 0;
484 488
485err_power_on: 489phy_err:
486 clk_disable_unprepare(ssusb->ref_clk); 490 ssusb_clks_disable(ssusb);
487err_ref_clk: 491clks_err:
488 clk_disable_unprepare(ssusb->sys_clk);
489err_sys_clk:
490 return ret; 492 return ret;
491} 493}
492 494
diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
index 7d9ba8a52368..ff62ba232177 100644
--- a/drivers/usb/mtu3/mtu3_qmu.c
+++ b/drivers/usb/mtu3/mtu3_qmu.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_qmu.c - Queue Management Unit driver for device controller 3 * mtu3_qmu.c - Queue Management Unit driver for device controller
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19/* 10/*
@@ -40,7 +31,58 @@
40#define GPD_FLAGS_IOC BIT(7) 31#define GPD_FLAGS_IOC BIT(7)
41 32
42#define GPD_EXT_FLAG_ZLP BIT(5) 33#define GPD_EXT_FLAG_ZLP BIT(5)
34#define GPD_EXT_NGP(x) (((x) & 0xf) << 4)
35#define GPD_EXT_BUF(x) (((x) & 0xf) << 0)
36
37#define HILO_GEN64(hi, lo) (((u64)(hi) << 32) + (lo))
38#define HILO_DMA(hi, lo) \
39 ((dma_addr_t)HILO_GEN64((le32_to_cpu(hi)), (le32_to_cpu(lo))))
40
41static dma_addr_t read_txq_cur_addr(void __iomem *mbase, u8 epnum)
42{
43 u32 txcpr;
44 u32 txhiar;
45
46 txcpr = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
47 txhiar = mtu3_readl(mbase, USB_QMU_TQHIAR(epnum));
43 48
49 return HILO_DMA(QMU_CUR_GPD_ADDR_HI(txhiar), txcpr);
50}
51
52static dma_addr_t read_rxq_cur_addr(void __iomem *mbase, u8 epnum)
53{
54 u32 rxcpr;
55 u32 rxhiar;
56
57 rxcpr = mtu3_readl(mbase, USB_QMU_RQCPR(epnum));
58 rxhiar = mtu3_readl(mbase, USB_QMU_RQHIAR(epnum));
59
60 return HILO_DMA(QMU_CUR_GPD_ADDR_HI(rxhiar), rxcpr);
61}
62
63static void write_txq_start_addr(void __iomem *mbase, u8 epnum, dma_addr_t dma)
64{
65 u32 tqhiar;
66
67 mtu3_writel(mbase, USB_QMU_TQSAR(epnum),
68 cpu_to_le32(lower_32_bits(dma)));
69 tqhiar = mtu3_readl(mbase, USB_QMU_TQHIAR(epnum));
70 tqhiar &= ~QMU_START_ADDR_HI_MSK;
71 tqhiar |= QMU_START_ADDR_HI(upper_32_bits(dma));
72 mtu3_writel(mbase, USB_QMU_TQHIAR(epnum), tqhiar);
73}
74
75static void write_rxq_start_addr(void __iomem *mbase, u8 epnum, dma_addr_t dma)
76{
77 u32 rqhiar;
78
79 mtu3_writel(mbase, USB_QMU_RQSAR(epnum),
80 cpu_to_le32(lower_32_bits(dma)));
81 rqhiar = mtu3_readl(mbase, USB_QMU_RQHIAR(epnum));
82 rqhiar &= ~QMU_START_ADDR_HI_MSK;
83 rqhiar |= QMU_START_ADDR_HI(upper_32_bits(dma));
84 mtu3_writel(mbase, USB_QMU_RQHIAR(epnum), rqhiar);
85}
44 86
45static struct qmu_gpd *gpd_dma_to_virt(struct mtu3_gpd_ring *ring, 87static struct qmu_gpd *gpd_dma_to_virt(struct mtu3_gpd_ring *ring,
46 dma_addr_t dma_addr) 88 dma_addr_t dma_addr)
@@ -193,21 +235,27 @@ static int mtu3_prepare_tx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
193 struct mtu3_gpd_ring *ring = &mep->gpd_ring; 235 struct mtu3_gpd_ring *ring = &mep->gpd_ring;
194 struct qmu_gpd *gpd = ring->enqueue; 236 struct qmu_gpd *gpd = ring->enqueue;
195 struct usb_request *req = &mreq->request; 237 struct usb_request *req = &mreq->request;
238 dma_addr_t enq_dma;
239 u16 ext_addr;
196 240
197 /* set all fields to zero as default value */ 241 /* set all fields to zero as default value */
198 memset(gpd, 0, sizeof(*gpd)); 242 memset(gpd, 0, sizeof(*gpd));
199 243
200 gpd->buffer = cpu_to_le32((u32)req->dma); 244 gpd->buffer = cpu_to_le32(lower_32_bits(req->dma));
245 ext_addr = GPD_EXT_BUF(upper_32_bits(req->dma));
201 gpd->buf_len = cpu_to_le16(req->length); 246 gpd->buf_len = cpu_to_le16(req->length);
202 gpd->flag |= GPD_FLAGS_IOC; 247 gpd->flag |= GPD_FLAGS_IOC;
203 248
204 /* get the next GPD */ 249 /* get the next GPD */
205 enq = advance_enq_gpd(ring); 250 enq = advance_enq_gpd(ring);
206 dev_dbg(mep->mtu->dev, "TX-EP%d queue gpd=%p, enq=%p\n", 251 enq_dma = gpd_virt_to_dma(ring, enq);
207 mep->epnum, gpd, enq); 252 dev_dbg(mep->mtu->dev, "TX-EP%d queue gpd=%p, enq=%p, qdma=%pad\n",
253 mep->epnum, gpd, enq, &enq_dma);
208 254
209 enq->flag &= ~GPD_FLAGS_HWO; 255 enq->flag &= ~GPD_FLAGS_HWO;
210 gpd->next_gpd = cpu_to_le32((u32)gpd_virt_to_dma(ring, enq)); 256 gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
257 ext_addr |= GPD_EXT_NGP(upper_32_bits(enq_dma));
258 gpd->tx_ext_addr = cpu_to_le16(ext_addr);
211 259
212 if (req->zero) 260 if (req->zero)
213 gpd->ext_flag |= GPD_EXT_FLAG_ZLP; 261 gpd->ext_flag |= GPD_EXT_FLAG_ZLP;
@@ -226,21 +274,27 @@ static int mtu3_prepare_rx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
226 struct mtu3_gpd_ring *ring = &mep->gpd_ring; 274 struct mtu3_gpd_ring *ring = &mep->gpd_ring;
227 struct qmu_gpd *gpd = ring->enqueue; 275 struct qmu_gpd *gpd = ring->enqueue;
228 struct usb_request *req = &mreq->request; 276 struct usb_request *req = &mreq->request;
277 dma_addr_t enq_dma;
278 u16 ext_addr;
229 279
230 /* set all fields to zero as default value */ 280 /* set all fields to zero as default value */
231 memset(gpd, 0, sizeof(*gpd)); 281 memset(gpd, 0, sizeof(*gpd));
232 282
233 gpd->buffer = cpu_to_le32((u32)req->dma); 283 gpd->buffer = cpu_to_le32(lower_32_bits(req->dma));
284 ext_addr = GPD_EXT_BUF(upper_32_bits(req->dma));
234 gpd->data_buf_len = cpu_to_le16(req->length); 285 gpd->data_buf_len = cpu_to_le16(req->length);
235 gpd->flag |= GPD_FLAGS_IOC; 286 gpd->flag |= GPD_FLAGS_IOC;
236 287
237 /* get the next GPD */ 288 /* get the next GPD */
238 enq = advance_enq_gpd(ring); 289 enq = advance_enq_gpd(ring);
239 dev_dbg(mep->mtu->dev, "RX-EP%d queue gpd=%p, enq=%p\n", 290 enq_dma = gpd_virt_to_dma(ring, enq);
240 mep->epnum, gpd, enq); 291 dev_dbg(mep->mtu->dev, "RX-EP%d queue gpd=%p, enq=%p, qdma=%pad\n",
292 mep->epnum, gpd, enq, &enq_dma);
241 293
242 enq->flag &= ~GPD_FLAGS_HWO; 294 enq->flag &= ~GPD_FLAGS_HWO;
243 gpd->next_gpd = cpu_to_le32((u32)gpd_virt_to_dma(ring, enq)); 295 gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
296 ext_addr |= GPD_EXT_NGP(upper_32_bits(enq_dma));
297 gpd->rx_ext_addr = cpu_to_le16(ext_addr);
244 gpd->chksum = qmu_calc_checksum((u8 *)gpd); 298 gpd->chksum = qmu_calc_checksum((u8 *)gpd);
245 gpd->flag |= GPD_FLAGS_HWO; 299 gpd->flag |= GPD_FLAGS_HWO;
246 300
@@ -267,8 +321,8 @@ int mtu3_qmu_start(struct mtu3_ep *mep)
267 321
268 if (mep->is_in) { 322 if (mep->is_in) {
269 /* set QMU start address */ 323 /* set QMU start address */
270 mtu3_writel(mbase, USB_QMU_TQSAR(mep->epnum), ring->dma); 324 write_txq_start_addr(mbase, epnum, ring->dma);
271 mtu3_setbits(mbase, MU3D_EP_TXCR0(mep->epnum), TX_DMAREQEN); 325 mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_DMAREQEN);
272 mtu3_setbits(mbase, U3D_QCR0, QMU_TX_CS_EN(epnum)); 326 mtu3_setbits(mbase, U3D_QCR0, QMU_TX_CS_EN(epnum));
273 /* send zero length packet according to ZLP flag in GPD */ 327 /* send zero length packet according to ZLP flag in GPD */
274 mtu3_setbits(mbase, U3D_QCR1, QMU_TX_ZLP(epnum)); 328 mtu3_setbits(mbase, U3D_QCR1, QMU_TX_ZLP(epnum));
@@ -282,8 +336,8 @@ int mtu3_qmu_start(struct mtu3_ep *mep)
282 mtu3_writel(mbase, USB_QMU_TQCSR(epnum), QMU_Q_START); 336 mtu3_writel(mbase, USB_QMU_TQCSR(epnum), QMU_Q_START);
283 337
284 } else { 338 } else {
285 mtu3_writel(mbase, USB_QMU_RQSAR(mep->epnum), ring->dma); 339 write_rxq_start_addr(mbase, epnum, ring->dma);
286 mtu3_setbits(mbase, MU3D_EP_RXCR0(mep->epnum), RX_DMAREQEN); 340 mtu3_setbits(mbase, MU3D_EP_RXCR0(epnum), RX_DMAREQEN);
287 mtu3_setbits(mbase, U3D_QCR0, QMU_RX_CS_EN(epnum)); 341 mtu3_setbits(mbase, U3D_QCR0, QMU_RX_CS_EN(epnum));
288 /* don't expect ZLP */ 342 /* don't expect ZLP */
289 mtu3_clrbits(mbase, U3D_QCR3, QMU_RX_ZLP(epnum)); 343 mtu3_clrbits(mbase, U3D_QCR3, QMU_RX_ZLP(epnum));
@@ -353,9 +407,9 @@ static void qmu_tx_zlp_error_handler(struct mtu3 *mtu, u8 epnum)
353 struct mtu3_gpd_ring *ring = &mep->gpd_ring; 407 struct mtu3_gpd_ring *ring = &mep->gpd_ring;
354 void __iomem *mbase = mtu->mac_base; 408 void __iomem *mbase = mtu->mac_base;
355 struct qmu_gpd *gpd_current = NULL; 409 struct qmu_gpd *gpd_current = NULL;
356 dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
357 struct usb_request *req = NULL; 410 struct usb_request *req = NULL;
358 struct mtu3_request *mreq; 411 struct mtu3_request *mreq;
412 dma_addr_t cur_gpd_dma;
359 u32 txcsr = 0; 413 u32 txcsr = 0;
360 int ret; 414 int ret;
361 415
@@ -365,7 +419,8 @@ static void qmu_tx_zlp_error_handler(struct mtu3 *mtu, u8 epnum)
365 else 419 else
366 return; 420 return;
367 421
368 gpd_current = gpd_dma_to_virt(ring, gpd_dma); 422 cur_gpd_dma = read_txq_cur_addr(mbase, epnum);
423 gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
369 424
370 if (le16_to_cpu(gpd_current->buf_len) != 0) { 425 if (le16_to_cpu(gpd_current->buf_len) != 0) {
371 dev_err(mtu->dev, "TX EP%d buffer length error(!=0)\n", epnum); 426 dev_err(mtu->dev, "TX EP%d buffer length error(!=0)\n", epnum);
@@ -408,12 +463,13 @@ static void qmu_done_tx(struct mtu3 *mtu, u8 epnum)
408 void __iomem *mbase = mtu->mac_base; 463 void __iomem *mbase = mtu->mac_base;
409 struct qmu_gpd *gpd = ring->dequeue; 464 struct qmu_gpd *gpd = ring->dequeue;
410 struct qmu_gpd *gpd_current = NULL; 465 struct qmu_gpd *gpd_current = NULL;
411 dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
412 struct usb_request *request = NULL; 466 struct usb_request *request = NULL;
413 struct mtu3_request *mreq; 467 struct mtu3_request *mreq;
468 dma_addr_t cur_gpd_dma;
414 469
415 /*transfer phy address got from QMU register to virtual address */ 470 /*transfer phy address got from QMU register to virtual address */
416 gpd_current = gpd_dma_to_virt(ring, gpd_dma); 471 cur_gpd_dma = read_txq_cur_addr(mbase, epnum);
472 gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
417 473
418 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", 474 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n",
419 __func__, epnum, gpd, gpd_current, ring->enqueue); 475 __func__, epnum, gpd, gpd_current, ring->enqueue);
@@ -446,11 +502,12 @@ static void qmu_done_rx(struct mtu3 *mtu, u8 epnum)
446 void __iomem *mbase = mtu->mac_base; 502 void __iomem *mbase = mtu->mac_base;
447 struct qmu_gpd *gpd = ring->dequeue; 503 struct qmu_gpd *gpd = ring->dequeue;
448 struct qmu_gpd *gpd_current = NULL; 504 struct qmu_gpd *gpd_current = NULL;
449 dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_RQCPR(epnum));
450 struct usb_request *req = NULL; 505 struct usb_request *req = NULL;
451 struct mtu3_request *mreq; 506 struct mtu3_request *mreq;
507 dma_addr_t cur_gpd_dma;
452 508
453 gpd_current = gpd_dma_to_virt(ring, gpd_dma); 509 cur_gpd_dma = read_rxq_cur_addr(mbase, epnum);
510 gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
454 511
455 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", 512 dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n",
456 __func__, epnum, gpd, gpd_current, ring->enqueue); 513 __func__, epnum, gpd, gpd_current, ring->enqueue);
diff --git a/drivers/usb/mtu3/mtu3_qmu.h b/drivers/usb/mtu3/mtu3_qmu.h
index 4dafa16bf120..81f5151a55ed 100644
--- a/drivers/usb/mtu3/mtu3_qmu.h
+++ b/drivers/usb/mtu3/mtu3_qmu.h
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mtu3_qmu.h - Queue Management Unit driver header 3 * mtu3_qmu.h - Queue Management Unit driver header
3 * 4 *
4 * Copyright (C) 2016 MediaTek Inc. 5 * Copyright (C) 2016 MediaTek Inc.
5 * 6 *
6 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> 7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#ifndef __MTK_QMU_H__ 10#ifndef __MTK_QMU_H__
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 02fbb4fe3745..0ad664efda6b 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2/* 3/*
3 * Texas Instruments AM35x "glue layer" 4 * Texas Instruments AM35x "glue layer"
@@ -8,23 +9,6 @@
8 * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com> 9 * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
9 * 10 *
10 * This file is part of the Inventra Controller Driver for Linux. 11 * This file is part of the Inventra Controller Driver for Linux.
11 *
12 * The Inventra Controller Driver for Linux is free software; you
13 * can redistribute it and/or modify it under the terms of the GNU
14 * General Public License version 2 as published by the Free Software
15 * Foundation.
16 *
17 * The Inventra Controller Driver for Linux is distributed in
18 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
21 * License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with The Inventra Controller Driver for Linux ; if not,
25 * write to the Free Software Foundation, Inc., 59 Temple Place,
26 * Suite 330, Boston, MA 02111-1307 USA
27 *
28 */ 12 */
29 13
30#include <linux/module.h> 14#include <linux/module.h>
@@ -133,11 +117,9 @@ static void am35x_musb_set_vbus(struct musb *musb, int is_on)
133 117
134#define POLL_SECONDS 2 118#define POLL_SECONDS 2
135 119
136static struct timer_list otg_workaround; 120static void otg_timer(struct timer_list *t)
137
138static void otg_timer(unsigned long _musb)
139{ 121{
140 struct musb *musb = (void *)_musb; 122 struct musb *musb = from_timer(musb, t, dev_timer);
141 void __iomem *mregs = musb->mregs; 123 void __iomem *mregs = musb->mregs;
142 u8 devctl; 124 u8 devctl;
143 unsigned long flags; 125 unsigned long flags;
@@ -173,7 +155,7 @@ static void otg_timer(unsigned long _musb)
173 case OTG_STATE_B_IDLE: 155 case OTG_STATE_B_IDLE:
174 devctl = musb_readb(mregs, MUSB_DEVCTL); 156 devctl = musb_readb(mregs, MUSB_DEVCTL);
175 if (devctl & MUSB_DEVCTL_BDEVICE) 157 if (devctl & MUSB_DEVCTL_BDEVICE)
176 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 158 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
177 else 159 else
178 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 160 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
179 break; 161 break;
@@ -195,12 +177,12 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
195 musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) { 177 musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
196 dev_dbg(musb->controller, "%s active, deleting timer\n", 178 dev_dbg(musb->controller, "%s active, deleting timer\n",
197 usb_otg_state_string(musb->xceiv->otg->state)); 179 usb_otg_state_string(musb->xceiv->otg->state));
198 del_timer(&otg_workaround); 180 del_timer(&musb->dev_timer);
199 last_timer = jiffies; 181 last_timer = jiffies;
200 return; 182 return;
201 } 183 }
202 184
203 if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) { 185 if (time_after(last_timer, timeout) && timer_pending(&musb->dev_timer)) {
204 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n"); 186 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
205 return; 187 return;
206 } 188 }
@@ -209,7 +191,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
209 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", 191 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
210 usb_otg_state_string(musb->xceiv->otg->state), 192 usb_otg_state_string(musb->xceiv->otg->state),
211 jiffies_to_msecs(timeout - jiffies)); 193 jiffies_to_msecs(timeout - jiffies));
212 mod_timer(&otg_workaround, timeout); 194 mod_timer(&musb->dev_timer, timeout);
213} 195}
214 196
215static irqreturn_t am35x_musb_interrupt(int irq, void *hci) 197static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
@@ -278,14 +260,14 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
278 */ 260 */
279 musb->int_usb &= ~MUSB_INTR_VBUSERROR; 261 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
280 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; 262 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
281 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 263 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
282 WARNING("VBUS error workaround (delay coming)\n"); 264 WARNING("VBUS error workaround (delay coming)\n");
283 } else if (drvvbus) { 265 } else if (drvvbus) {
284 MUSB_HST_MODE(musb); 266 MUSB_HST_MODE(musb);
285 otg->default_a = 1; 267 otg->default_a = 1;
286 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 268 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
287 portstate(musb->port1_status |= USB_PORT_STAT_POWER); 269 portstate(musb->port1_status |= USB_PORT_STAT_POWER);
288 del_timer(&otg_workaround); 270 del_timer(&musb->dev_timer);
289 } else { 271 } else {
290 musb->is_active = 0; 272 musb->is_active = 0;
291 MUSB_DEV_MODE(musb); 273 MUSB_DEV_MODE(musb);
@@ -324,7 +306,7 @@ eoi:
324 306
325 /* Poll for ID change */ 307 /* Poll for ID change */
326 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) 308 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
327 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 309 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
328 310
329 spin_unlock_irqrestore(&musb->lock, flags); 311 spin_unlock_irqrestore(&musb->lock, flags);
330 312
@@ -365,7 +347,7 @@ static int am35x_musb_init(struct musb *musb)
365 if (IS_ERR_OR_NULL(musb->xceiv)) 347 if (IS_ERR_OR_NULL(musb->xceiv))
366 return -EPROBE_DEFER; 348 return -EPROBE_DEFER;
367 349
368 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); 350 timer_setup(&musb->dev_timer, otg_timer, 0);
369 351
370 /* Reset the musb */ 352 /* Reset the musb */
371 if (data->reset) 353 if (data->reset)
@@ -395,7 +377,7 @@ static int am35x_musb_exit(struct musb *musb)
395 struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); 377 struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
396 struct omap_musb_board_data *data = plat->board_data; 378 struct omap_musb_board_data *data = plat->board_data;
397 379
398 del_timer_sync(&otg_workaround); 380 del_timer_sync(&musb->dev_timer);
399 381
400 /* Shutdown the on-chip PHY and its PLL. */ 382 /* Shutdown the on-chip PHY and its PLL. */
401 if (data->set_phy_power) 383 if (data->set_phy_power)
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 4418574a36a1..0a98dcd66d19 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * MUSB OTG controller driver for Blackfin Processors 3 * MUSB OTG controller driver for Blackfin Processors
3 * 4 *
4 * Copyright 2006-2008 Analog Devices Inc. 5 * Copyright 2006-2008 Analog Devices Inc.
5 * 6 *
6 * Enter bugs at http://blackfin.uclinux.org/ 7 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */ 8 */
10 9
11#include <linux/module.h> 10#include <linux/module.h>
@@ -223,7 +222,7 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
223 if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE 222 if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
224 || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) || 223 || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
225 (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { 224 (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
226 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 225 mod_timer(&musb->dev_timer, jiffies + TIMER_DELAY);
227 musb->a_wait_bcon = TIMER_DELAY; 226 musb->a_wait_bcon = TIMER_DELAY;
228 } 227 }
229 228
@@ -232,9 +231,9 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
232 return retval; 231 return retval;
233} 232}
234 233
235static void musb_conn_timer_handler(unsigned long _musb) 234static void musb_conn_timer_handler(struct timer_list *t)
236{ 235{
237 struct musb *musb = (void *)_musb; 236 struct musb *musb = from_timer(musb, t, dev_timer);
238 unsigned long flags; 237 unsigned long flags;
239 u16 val; 238 u16 val;
240 static u8 toggle; 239 static u8 toggle;
@@ -266,7 +265,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
266 musb_writeb(musb->mregs, MUSB_INTRUSB, val); 265 musb_writeb(musb->mregs, MUSB_INTRUSB, val);
267 musb->xceiv->otg->state = OTG_STATE_B_IDLE; 266 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
268 } 267 }
269 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 268 mod_timer(&musb->dev_timer, jiffies + TIMER_DELAY);
270 break; 269 break;
271 case OTG_STATE_B_IDLE: 270 case OTG_STATE_B_IDLE:
272 /* 271 /*
@@ -310,7 +309,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
310 * shortening it, if accelerating A-plug detection 309 * shortening it, if accelerating A-plug detection
311 * is needed in OTG mode. 310 * is needed in OTG mode.
312 */ 311 */
313 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY / 4); 312 mod_timer(&musb->dev_timer, jiffies + TIMER_DELAY / 4);
314 } 313 }
315 break; 314 break;
316 default: 315 default:
@@ -445,8 +444,7 @@ static int bfin_musb_init(struct musb *musb)
445 444
446 bfin_musb_reg_init(musb); 445 bfin_musb_reg_init(musb);
447 446
448 setup_timer(&musb_conn_timer, musb_conn_timer_handler, 447 timer_setup(&musb->dev_timer, musb_conn_timer_handler, 0);
449 (unsigned long) musb);
450 448
451 musb->xceiv->set_power = bfin_musb_set_power; 449 musb->xceiv->set_power = bfin_musb_set_power;
452 450
diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
index c84dae546dc6..5b149915b0f8 100644
--- a/drivers/usb/musb/blackfin.h
+++ b/drivers/usb/musb/blackfin.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2007 by Analog Devices, Inc. 3 * Copyright (C) 2007 by Analog Devices, Inc.
3 *
4 * The Inventra Controller Driver for Linux is free software; you
5 * can redistribute it and/or modify it under the terms of the GNU
6 * General Public License version 2 as published by the Free Software
7 * Foundation.
8 */ 4 */
9 5
10#ifndef __MUSB_BLACKFIN_H__ 6#ifndef __MUSB_BLACKFIN_H__
@@ -82,6 +78,4 @@ static void dump_fifo_data(u8 *buf, u16 len)
82/* Almost 1 second */ 78/* Almost 1 second */
83#define TIMER_DELAY (1 * HZ) 79#define TIMER_DELAY (1 * HZ)
84 80
85static struct timer_list musb_conn_timer;
86
87#endif /* __MUSB_BLACKFIN_H__ */ 81#endif /* __MUSB_BLACKFIN_H__ */
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index a13bd3625043..b4d6d9bb3239 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005-2006 by Texas Instruments 3 * Copyright (C) 2005-2006 by Texas Instruments
3 * 4 *
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index df88123274ca..0397606a211b 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Texas Instruments DA8xx/OMAP-L1x "glue layer" 3 * Texas Instruments DA8xx/OMAP-L1x "glue layer"
3 * 4 *
@@ -10,23 +11,6 @@
10 * Copyright (c) 2016 Petr Kulhavy <petr@barix.com> 11 * Copyright (c) 2016 Petr Kulhavy <petr@barix.com>
11 * 12 *
12 * This file is part of the Inventra Controller Driver for Linux. 13 * This file is part of the Inventra Controller Driver for Linux.
13 *
14 * The Inventra Controller Driver for Linux is free software; you
15 * can redistribute it and/or modify it under the terms of the GNU
16 * General Public License version 2 as published by the Free Software
17 * Foundation.
18 *
19 * The Inventra Controller Driver for Linux is distributed in
20 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
21 * without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
23 * License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with The Inventra Controller Driver for Linux ; if not,
27 * write to the Free Software Foundation, Inc., 59 Temple Place,
28 * Suite 330, Boston, MA 02111-1307 USA
29 *
30 */ 14 */
31 15
32#include <linux/module.h> 16#include <linux/module.h>
@@ -50,10 +34,7 @@
50#define DA8XX_USB_CTRL_REG 0x04 34#define DA8XX_USB_CTRL_REG 0x04
51#define DA8XX_USB_STAT_REG 0x08 35#define DA8XX_USB_STAT_REG 0x08
52#define DA8XX_USB_EMULATION_REG 0x0c 36#define DA8XX_USB_EMULATION_REG 0x0c
53#define DA8XX_USB_MODE_REG 0x10 /* Transparent, CDC, [Generic] RNDIS */
54#define DA8XX_USB_AUTOREQ_REG 0x14
55#define DA8XX_USB_SRP_FIX_TIME_REG 0x18 37#define DA8XX_USB_SRP_FIX_TIME_REG 0x18
56#define DA8XX_USB_TEARDOWN_REG 0x1c
57#define DA8XX_USB_INTR_SRC_REG 0x20 38#define DA8XX_USB_INTR_SRC_REG 0x20
58#define DA8XX_USB_INTR_SRC_SET_REG 0x24 39#define DA8XX_USB_INTR_SRC_SET_REG 0x24
59#define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28 40#define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
@@ -138,11 +119,9 @@ static void da8xx_musb_set_vbus(struct musb *musb, int is_on)
138 119
139#define POLL_SECONDS 2 120#define POLL_SECONDS 2
140 121
141static struct timer_list otg_workaround; 122static void otg_timer(struct timer_list *t)
142
143static void otg_timer(unsigned long _musb)
144{ 123{
145 struct musb *musb = (void *)_musb; 124 struct musb *musb = from_timer(musb, t, dev_timer);
146 void __iomem *mregs = musb->mregs; 125 void __iomem *mregs = musb->mregs;
147 u8 devctl; 126 u8 devctl;
148 unsigned long flags; 127 unsigned long flags;
@@ -178,7 +157,7 @@ static void otg_timer(unsigned long _musb)
178 * VBUSERR got reported during enumeration" cases. 157 * VBUSERR got reported during enumeration" cases.
179 */ 158 */
180 if (devctl & MUSB_DEVCTL_VBUS) { 159 if (devctl & MUSB_DEVCTL_VBUS) {
181 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 160 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
182 break; 161 break;
183 } 162 }
184 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 163 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
@@ -201,7 +180,7 @@ static void otg_timer(unsigned long _musb)
201 musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION); 180 musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
202 devctl = musb_readb(mregs, MUSB_DEVCTL); 181 devctl = musb_readb(mregs, MUSB_DEVCTL);
203 if (devctl & MUSB_DEVCTL_BDEVICE) 182 if (devctl & MUSB_DEVCTL_BDEVICE)
204 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 183 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
205 else 184 else
206 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 185 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
207 break; 186 break;
@@ -223,12 +202,12 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
223 musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) { 202 musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
224 dev_dbg(musb->controller, "%s active, deleting timer\n", 203 dev_dbg(musb->controller, "%s active, deleting timer\n",
225 usb_otg_state_string(musb->xceiv->otg->state)); 204 usb_otg_state_string(musb->xceiv->otg->state));
226 del_timer(&otg_workaround); 205 del_timer(&musb->dev_timer);
227 last_timer = jiffies; 206 last_timer = jiffies;
228 return; 207 return;
229 } 208 }
230 209
231 if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) { 210 if (time_after(last_timer, timeout) && timer_pending(&musb->dev_timer)) {
232 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n"); 211 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
233 return; 212 return;
234 } 213 }
@@ -237,7 +216,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
237 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", 216 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
238 usb_otg_state_string(musb->xceiv->otg->state), 217 usb_otg_state_string(musb->xceiv->otg->state),
239 jiffies_to_msecs(timeout - jiffies)); 218 jiffies_to_msecs(timeout - jiffies));
240 mod_timer(&otg_workaround, timeout); 219 mod_timer(&musb->dev_timer, timeout);
241} 220}
242 221
243static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) 222static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
@@ -297,14 +276,14 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
297 */ 276 */
298 musb->int_usb &= ~MUSB_INTR_VBUSERROR; 277 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
299 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; 278 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
300 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 279 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
301 WARNING("VBUS error workaround (delay coming)\n"); 280 WARNING("VBUS error workaround (delay coming)\n");
302 } else if (drvvbus) { 281 } else if (drvvbus) {
303 MUSB_HST_MODE(musb); 282 MUSB_HST_MODE(musb);
304 otg->default_a = 1; 283 otg->default_a = 1;
305 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 284 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
306 portstate(musb->port1_status |= USB_PORT_STAT_POWER); 285 portstate(musb->port1_status |= USB_PORT_STAT_POWER);
307 del_timer(&otg_workaround); 286 del_timer(&musb->dev_timer);
308 } else { 287 } else {
309 musb->is_active = 0; 288 musb->is_active = 0;
310 MUSB_DEV_MODE(musb); 289 MUSB_DEV_MODE(musb);
@@ -331,7 +310,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
331 310
332 /* Poll for ID change */ 311 /* Poll for ID change */
333 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) 312 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
334 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 313 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
335 314
336 spin_unlock_irqrestore(&musb->lock, flags); 315 spin_unlock_irqrestore(&musb->lock, flags);
337 316
@@ -393,7 +372,7 @@ static int da8xx_musb_init(struct musb *musb)
393 goto fail; 372 goto fail;
394 } 373 }
395 374
396 setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); 375 timer_setup(&musb->dev_timer, otg_timer, 0);
397 376
398 /* Reset the controller */ 377 /* Reset the controller */
399 musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); 378 musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
@@ -431,7 +410,7 @@ static int da8xx_musb_exit(struct musb *musb)
431{ 410{
432 struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent); 411 struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
433 412
434 del_timer_sync(&otg_workaround); 413 del_timer_sync(&musb->dev_timer);
435 414
436 phy_power_off(glue->phy); 415 phy_power_off(glue->phy);
437 phy_exit(glue->phy); 416 phy_exit(glue->phy);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 52b491d3d5d8..2ad39dcd2f4c 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -1,24 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005-2006 by Texas Instruments 3 * Copyright (C) 2005-2006 by Texas Instruments
3 * 4 *
4 * This file is part of the Inventra Controller Driver for Linux. 5 * This file is part of the Inventra Controller Driver for Linux.
5 *
6 * The Inventra Controller Driver for Linux is free software; you
7 * can redistribute it and/or modify it under the terms of the GNU
8 * General Public License version 2 as published by the Free Software
9 * Foundation.
10 *
11 * The Inventra Controller Driver for Linux is distributed in
12 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with The Inventra Controller Driver for Linux ; if not,
19 * write to the Free Software Foundation, Inc., 59 Temple Place,
20 * Suite 330, Boston, MA 02111-1307 USA
21 *
22 */ 6 */
23 7
24#include <linux/module.h> 8#include <linux/module.h>
@@ -199,11 +183,9 @@ static void davinci_musb_set_vbus(struct musb *musb, int is_on)
199 183
200#define POLL_SECONDS 2 184#define POLL_SECONDS 2
201 185
202static struct timer_list otg_workaround; 186static void otg_timer(struct timer_list *t)
203
204static void otg_timer(unsigned long _musb)
205{ 187{
206 struct musb *musb = (void *)_musb; 188 struct musb *musb = from_timer(musb, t, dev_timer);
207 void __iomem *mregs = musb->mregs; 189 void __iomem *mregs = musb->mregs;
208 u8 devctl; 190 u8 devctl;
209 unsigned long flags; 191 unsigned long flags;
@@ -224,7 +206,7 @@ static void otg_timer(unsigned long _musb)
224 * VBUSERR got reported during enumeration" cases. 206 * VBUSERR got reported during enumeration" cases.
225 */ 207 */
226 if (devctl & MUSB_DEVCTL_VBUS) { 208 if (devctl & MUSB_DEVCTL_VBUS) {
227 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 209 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
228 break; 210 break;
229 } 211 }
230 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 212 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
@@ -248,7 +230,7 @@ static void otg_timer(unsigned long _musb)
248 devctl | MUSB_DEVCTL_SESSION); 230 devctl | MUSB_DEVCTL_SESSION);
249 devctl = musb_readb(mregs, MUSB_DEVCTL); 231 devctl = musb_readb(mregs, MUSB_DEVCTL);
250 if (devctl & MUSB_DEVCTL_BDEVICE) 232 if (devctl & MUSB_DEVCTL_BDEVICE)
251 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 233 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
252 else 234 else
253 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 235 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
254 break; 236 break;
@@ -325,14 +307,14 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
325 */ 307 */
326 musb->int_usb &= ~MUSB_INTR_VBUSERROR; 308 musb->int_usb &= ~MUSB_INTR_VBUSERROR;
327 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; 309 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
328 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 310 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
329 WARNING("VBUS error workaround (delay coming)\n"); 311 WARNING("VBUS error workaround (delay coming)\n");
330 } else if (drvvbus) { 312 } else if (drvvbus) {
331 MUSB_HST_MODE(musb); 313 MUSB_HST_MODE(musb);
332 otg->default_a = 1; 314 otg->default_a = 1;
333 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 315 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
334 portstate(musb->port1_status |= USB_PORT_STAT_POWER); 316 portstate(musb->port1_status |= USB_PORT_STAT_POWER);
335 del_timer(&otg_workaround); 317 del_timer(&musb->dev_timer);
336 } else { 318 } else {
337 musb->is_active = 0; 319 musb->is_active = 0;
338 MUSB_DEV_MODE(musb); 320 MUSB_DEV_MODE(musb);
@@ -361,7 +343,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
361 343
362 /* poll for ID change */ 344 /* poll for ID change */
363 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) 345 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
364 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 346 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
365 347
366 spin_unlock_irqrestore(&musb->lock, flags); 348 spin_unlock_irqrestore(&musb->lock, flags);
367 349
@@ -393,7 +375,7 @@ static int davinci_musb_init(struct musb *musb)
393 if (revision == 0) 375 if (revision == 0)
394 goto fail; 376 goto fail;
395 377
396 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); 378 timer_setup(&musb->dev_timer, otg_timer, 0);
397 379
398 davinci_musb_source_power(musb, 0, 1); 380 davinci_musb_source_power(musb, 0, 1);
399 381
@@ -443,7 +425,7 @@ unregister:
443 425
444static int davinci_musb_exit(struct musb *musb) 426static int davinci_musb_exit(struct musb *musb)
445{ 427{
446 del_timer_sync(&otg_workaround); 428 del_timer_sync(&musb->dev_timer);
447 429
448 /* force VBUS off */ 430 /* force VBUS off */
449 if (cpu_is_davinci_dm355()) { 431 if (cpu_is_davinci_dm355()) {
diff --git a/drivers/usb/musb/davinci.h b/drivers/usb/musb/davinci.h
index 371baa0ee509..e021485c83ae 100644
--- a/drivers/usb/musb/davinci.h
+++ b/drivers/usb/musb/davinci.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005-2006 by Texas Instruments 3 * Copyright (C) 2005-2006 by Texas Instruments
3 *
4 * The Inventra Controller Driver for Linux is free software; you
5 * can redistribute it and/or modify it under the terms of the GNU
6 * General Public License version 2 as published by the Free Software
7 * Foundation.
8 */ 4 */
9 5
10#ifndef __MUSB_HDRDF_H__ 6#ifndef __MUSB_HDRDF_H__
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
index 40c68c23d553..04d8b2bc205a 100644
--- a/drivers/usb/musb/jz4740.c
+++ b/drivers/usb/musb/jz4740.c
@@ -1,16 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Ingenic JZ4740 "glue layer" 3 * Ingenic JZ4740 "glue layer"
3 * 4 *
4 * Copyright (C) 2013, Apelete Seketeli <apelete@seketeli.net> 5 * Copyright (C) 2013, Apelete Seketeli <apelete@seketeli.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 675 Mass Ave, Cambridge, MA 02139, USA.
14 */ 6 */
15 7
16#include <linux/clk.h> 8#include <linux/clk.h>
diff --git a/drivers/usb/musb/musb_am335x.c b/drivers/usb/musb/musb_am335x.c
index 1e58ed2361cc..5f04f8e3a640 100644
--- a/drivers/usb/musb/musb_am335x.c
+++ b/drivers/usb/musb/musb_am335x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/platform_device.h> 2#include <linux/platform_device.h>
2#include <linux/pm_runtime.h> 3#include <linux/pm_runtime.h>
3#include <linux/module.h> 4#include <linux/module.h>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index ff5a1a8989d5..ea5013aa69e2 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver core code 3 * MUSB OTG driver core code
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35/* 10/*
@@ -485,9 +460,9 @@ void musb_load_testpacket(struct musb *musb)
485/* 460/*
486 * Handles OTG hnp timeouts, such as b_ase0_brst 461 * Handles OTG hnp timeouts, such as b_ase0_brst
487 */ 462 */
488static void musb_otg_timer_func(unsigned long data) 463static void musb_otg_timer_func(struct timer_list *t)
489{ 464{
490 struct musb *musb = (struct musb *)data; 465 struct musb *musb = from_timer(musb, t, otg_timer);
491 unsigned long flags; 466 unsigned long flags;
492 467
493 spin_lock_irqsave(&musb->lock, flags); 468 spin_lock_irqsave(&musb->lock, flags);
@@ -767,6 +742,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
767 case OTG_STATE_B_IDLE: 742 case OTG_STATE_B_IDLE:
768 if (!musb->is_active) 743 if (!musb->is_active)
769 break; 744 break;
745 /* fall through */
770 case OTG_STATE_B_PERIPHERAL: 746 case OTG_STATE_B_PERIPHERAL:
771 musb_g_suspend(musb); 747 musb_g_suspend(musb);
772 musb->is_active = musb->g.b_hnp_enable; 748 musb->is_active = musb->g.b_hnp_enable;
@@ -2330,7 +2306,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2330 if (status < 0) 2306 if (status < 0)
2331 goto fail3; 2307 goto fail3;
2332 2308
2333 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); 2309 timer_setup(&musb->otg_timer, musb_otg_timer_func, 0);
2334 2310
2335 /* attach to the IRQ */ 2311 /* attach to the IRQ */
2336 if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) { 2312 if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 20f4614178d9..385841ee6f46 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver defines 3 * MUSB OTG driver defines
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_CORE_H__ 10#ifndef __MUSB_CORE_H__
@@ -345,6 +320,7 @@ struct musb {
345 struct list_head pending_list; /* pending work list */ 320 struct list_head pending_list; /* pending work list */
346 321
347 struct timer_list otg_timer; 322 struct timer_list otg_timer;
323 struct timer_list dev_timer;
348 struct notifier_block nb; 324 struct notifier_block nb;
349 325
350 struct dma_controller *dma_controller; 326 struct dma_controller *dma_controller;
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 1ec0a4947b6b..d0dd4f470bbe 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/device.h> 2#include <linux/device.h>
2#include <linux/dma-mapping.h> 3#include <linux/dma-mapping.h>
3#include <linux/dmaengine.h> 4#include <linux/dmaengine.h>
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index 9a78877a8afe..5e0f079dde21 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver debug defines 3 * MUSB OTG driver debug defines
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_LINUX_DEBUG_H__ 10#ifndef __MUSB_LINUX_DEBUG_H__
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 952733ceaac8..7cf5a1bbdaff 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -1,34 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver debugfs support 3 * MUSB OTG driver debugfs support
3 * 4 *
4 * Copyright 2010 Nokia Corporation 5 * Copyright 2010 Nokia Corporation
5 * Contact: Felipe Balbi <felipe.balbi@nokia.com> 6 * Contact: Felipe Balbi <felipe.balbi@nokia.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */ 7 */
33 8
34#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 04c3bd86bd62..a4241f4d430e 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver DMA controller abstraction 3 * MUSB OTG driver DMA controller abstraction
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_DMA_H__ 10#ifndef __MUSB_DMA_H__
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index f6b526606ad1..05a679d5e3a2 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Texas Instruments DSPS platforms "glue layer" 3 * Texas Instruments DSPS platforms "glue layer"
3 * 4 *
@@ -7,22 +8,6 @@
7 * 8 *
8 * This file is part of the Inventra Controller Driver for Linux. 9 * This file is part of the Inventra Controller Driver for Linux.
9 * 10 *
10 * The Inventra Controller Driver for Linux is free software; you
11 * can redistribute it and/or modify it under the terms of the GNU
12 * General Public License version 2 as published by the Free Software
13 * Foundation.
14 *
15 * The Inventra Controller Driver for Linux is distributed in
16 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
17 * without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with The Inventra Controller Driver for Linux ; if not,
23 * write to the Free Software Foundation, Inc., 59 Temple Place,
24 * Suite 330, Boston, MA 02111-1307 USA
25 *
26 * musb_dsps.c will be a common file for all the TI DSPS platforms 11 * musb_dsps.c will be a common file for all the TI DSPS platforms
27 * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. 12 * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x.
28 * For now only ti81x is using this and in future davinci.c, am35x.c 13 * For now only ti81x is using this and in future davinci.c, am35x.c
@@ -119,7 +104,6 @@ struct dsps_glue {
119 struct platform_device *musb; /* child musb pdev */ 104 struct platform_device *musb; /* child musb pdev */
120 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ 105 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
121 int vbus_irq; /* optional vbus irq */ 106 int vbus_irq; /* optional vbus irq */
122 struct timer_list timer; /* otg_workaround timer */
123 unsigned long last_timer; /* last timer data for each instance */ 107 unsigned long last_timer; /* last timer data for each instance */
124 bool sw_babble_enabled; 108 bool sw_babble_enabled;
125 void __iomem *usbss_base; 109 void __iomem *usbss_base;
@@ -149,6 +133,7 @@ static const struct debugfs_reg32 dsps_musb_regs[] = {
149 133
150static void dsps_mod_timer(struct dsps_glue *glue, int wait_ms) 134static void dsps_mod_timer(struct dsps_glue *glue, int wait_ms)
151{ 135{
136 struct musb *musb = platform_get_drvdata(glue->musb);
152 int wait; 137 int wait;
153 138
154 if (wait_ms < 0) 139 if (wait_ms < 0)
@@ -156,7 +141,7 @@ static void dsps_mod_timer(struct dsps_glue *glue, int wait_ms)
156 else 141 else
157 wait = msecs_to_jiffies(wait_ms); 142 wait = msecs_to_jiffies(wait_ms);
158 143
159 mod_timer(&glue->timer, jiffies + wait); 144 mod_timer(&musb->dev_timer, jiffies + wait);
160} 145}
161 146
162/* 147/*
@@ -216,7 +201,7 @@ static void dsps_musb_disable(struct musb *musb)
216 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); 201 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap);
217 musb_writel(reg_base, wrp->epintr_clear, 202 musb_writel(reg_base, wrp->epintr_clear,
218 wrp->txep_bitmap | wrp->rxep_bitmap); 203 wrp->txep_bitmap | wrp->rxep_bitmap);
219 del_timer_sync(&glue->timer); 204 del_timer_sync(&musb->dev_timer);
220} 205}
221 206
222/* Caller must take musb->lock */ 207/* Caller must take musb->lock */
@@ -230,7 +215,7 @@ static int dsps_check_status(struct musb *musb, void *unused)
230 int skip_session = 0; 215 int skip_session = 0;
231 216
232 if (glue->vbus_irq) 217 if (glue->vbus_irq)
233 del_timer(&glue->timer); 218 del_timer(&musb->dev_timer);
234 219
235 /* 220 /*
236 * We poll because DSPS IP's won't expose several OTG-critical 221 * We poll because DSPS IP's won't expose several OTG-critical
@@ -282,9 +267,9 @@ static int dsps_check_status(struct musb *musb, void *unused)
282 return 0; 267 return 0;
283} 268}
284 269
285static void otg_timer(unsigned long _musb) 270static void otg_timer(struct timer_list *t)
286{ 271{
287 struct musb *musb = (void *)_musb; 272 struct musb *musb = from_timer(musb, t, dev_timer);
288 struct device *dev = musb->controller; 273 struct device *dev = musb->controller;
289 unsigned long flags; 274 unsigned long flags;
290 int err; 275 int err;
@@ -480,7 +465,7 @@ static int dsps_musb_init(struct musb *musb)
480 } 465 }
481 } 466 }
482 467
483 setup_timer(&glue->timer, otg_timer, (unsigned long) musb); 468 timer_setup(&musb->dev_timer, otg_timer, 0);
484 469
485 /* Reset the musb */ 470 /* Reset the musb */
486 musb_writel(reg_base, wrp->control, (1 << wrp->reset)); 471 musb_writel(reg_base, wrp->control, (1 << wrp->reset));
@@ -515,7 +500,7 @@ static int dsps_musb_exit(struct musb *musb)
515 struct device *dev = musb->controller; 500 struct device *dev = musb->controller;
516 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 501 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
517 502
518 del_timer_sync(&glue->timer); 503 del_timer_sync(&musb->dev_timer);
519 usb_phy_shutdown(musb->xceiv); 504 usb_phy_shutdown(musb->xceiv);
520 phy_power_off(musb->phy); 505 phy_power_off(musb->phy);
521 phy_exit(musb->phy); 506 phy_exit(musb->phy);
@@ -1027,7 +1012,7 @@ static int dsps_suspend(struct device *dev)
1027 return ret; 1012 return ret;
1028 } 1013 }
1029 1014
1030 del_timer_sync(&glue->timer); 1015 del_timer_sync(&musb->dev_timer);
1031 1016
1032 mbase = musb->ctrl_base; 1017 mbase = musb->ctrl_base;
1033 glue->context.control = musb_readl(mbase, wrp->control); 1018 glue->context.control = musb_readl(mbase, wrp->control);
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index bc6d1717c9ec..293e5b8da565 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver peripheral support 3 * MUSB OTG driver peripheral support
3 * 4 *
@@ -5,32 +6,6 @@
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 * Copyright (C) 2009 MontaVista Software, Inc. <source@mvista.com> 8 * Copyright (C) 2009 MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
26 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */ 9 */
35 10
36#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 0314dfc770c7..9c34aca06db6 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver peripheral defines 3 * MUSB OTG driver peripheral defines
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_GADGET_H 10#ifndef __MUSB_GADGET_H
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 844a309fe895..18da4873e52e 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG peripheral driver ep0 handling 3 * MUSB OTG peripheral driver ep0 handling
3 * 4 *
@@ -5,32 +6,6 @@
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com> 8 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
26 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */ 9 */
35 10
36#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index b17450a59882..2627363fb4fe 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver host support 3 * MUSB OTG driver host support
3 * 4 *
@@ -5,32 +6,6 @@
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com> 8 * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
26 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */ 9 */
35 10
36#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 7bbf01bf4bb0..72392bbcd0a4 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver host defines 3 * MUSB OTG driver host defines
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef _MUSB_HOST_H 10#ifndef _MUSB_HOST_H
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h
index 17a80ae20674..b7025b2e6e00 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver register I/O 3 * MUSB OTG driver register I/O
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_LINUX_PLATFORM_ARCH_H__ 10#ifndef __MUSB_LINUX_PLATFORM_ARCH_H__
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index cff5bcf0d00f..a4beba184798 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver register defines 3 * MUSB OTG driver register defines
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#ifndef __MUSB_REGS_H__ 10#ifndef __MUSB_REGS_H__
diff --git a/drivers/usb/musb/musb_trace.c b/drivers/usb/musb/musb_trace.c
index 70973d901a21..476872adce80 100644
--- a/drivers/usb/musb/musb_trace.c
+++ b/drivers/usb/musb/musb_trace.c
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * musb_trace.c - MUSB Controller Trace Support 3 * musb_trace.c - MUSB Controller Trace Support
3 * 4 *
4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Author: Bin Liu <b-liu@ti.com> 7 * Author: Bin Liu <b-liu@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#define CREATE_TRACE_POINTS 10#define CREATE_TRACE_POINTS
diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h
index f031c9e74322..a97d618fe8ff 100644
--- a/drivers/usb/musb/musb_trace.h
+++ b/drivers/usb/musb/musb_trace.h
@@ -1,18 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * musb_trace.h - MUSB Controller Trace Support 3 * musb_trace.h - MUSB Controller Trace Support
3 * 4 *
4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
5 * 6 *
6 * Author: Bin Liu <b-liu@ti.com> 7 * Author: Bin Liu <b-liu@ti.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 of
10 * the License as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */ 8 */
17 9
18#undef TRACE_SYSTEM 10#undef TRACE_SYSTEM
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 0b4595439d51..5165d2b07ade 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -1,35 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver virtual root hub support 3 * MUSB OTG driver virtual root hub support
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments 6 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation 7 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */ 8 */
34 9
35#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 3620073da58c..21fb9e6622f3 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -1,34 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver - support for Mentor's DMA controller 3 * MUSB OTG driver - support for Mentor's DMA controller
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2007 by Texas Instruments 6 * Copyright (C) 2005-2007 by Texas Instruments
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */ 7 */
33#include <linux/device.h> 8#include <linux/device.h>
34#include <linux/interrupt.h> 9#include <linux/interrupt.h>
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
index a3dcbd55e436..44f7983df0a1 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -1,34 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MUSB OTG driver - support for Mentor's DMA controller 3 * MUSB OTG driver - support for Mentor's DMA controller
3 * 4 *
4 * Copyright 2005 Mentor Graphics Corporation 5 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2007 by Texas Instruments 6 * Copyright (C) 2005-2007 by Texas Instruments
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */ 7 */
33 8
34#ifndef CONFIG_BLACKFIN 9#ifndef CONFIG_BLACKFIN
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 456f3e6ecf03..5d705930ef47 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005-2007 by Texas Instruments 3 * Copyright (C) 2005-2007 by Texas Instruments
3 * Some code has been taken from tusb6010.c 4 * Some code has been taken from tusb6010.c
@@ -6,23 +7,6 @@
6 * Tony Lindgren <tony@atomide.com> 7 * Tony Lindgren <tony@atomide.com>
7 * 8 *
8 * This file is part of the Inventra Controller Driver for Linux. 9 * This file is part of the Inventra Controller Driver for Linux.
9 *
10 * The Inventra Controller Driver for Linux is free software; you
11 * can redistribute it and/or modify it under the terms of the GNU
12 * General Public License version 2 as published by the Free Software
13 * Foundation.
14 *
15 * The Inventra Controller Driver for Linux is distributed in
16 * the hope that it will be useful, but WITHOUT ANY WARRANTY;
17 * without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with The Inventra Controller Driver for Linux ; if not,
23 * write to the Free Software Foundation, Inc., 59 Temple Place,
24 * Suite 330, Boston, MA 02111-1307 USA
25 *
26 */ 10 */
27#include <linux/module.h> 11#include <linux/module.h>
28#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index 1b5e83a9840e..859008fa0e3c 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005-2006 by Texas Instruments 3 * Copyright (C) 2005-2006 by Texas Instruments
3 *
4 * The Inventra Controller Driver for Linux is free software; you
5 * can redistribute it and/or modify it under the terms of the GNU
6 * General Public License version 2 as published by the Free Software
7 * Foundation.
8 */ 4 */
9 5
10#ifndef __MUSB_OMAP243X_H__ 6#ifndef __MUSB_OMAP243X_H__
diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index dc353e24d53c..2d201219ecff 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Allwinner sun4i MUSB Glue Layer 3 * Allwinner sun4i MUSB Glue Layer
3 * 4 *
@@ -5,16 +6,6 @@
5 * 6 *
6 * Based on code from 7 * Based on code from
7 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> 8 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */ 9 */
19 10
20#include <linux/clk.h> 11#include <linux/clk.h>
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 4eb640c54f2c..39453287b5c3 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * TUSB6010 USB 2.0 OTG Dual Role controller 3 * TUSB6010 USB 2.0 OTG Dual Role controller
3 * 4 *
4 * Copyright (C) 2006 Nokia Corporation 5 * Copyright (C) 2006 Nokia Corporation
5 * Tony Lindgren <tony@atomide.com> 6 * Tony Lindgren <tony@atomide.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Notes: 8 * Notes:
12 * - Driver assumes that interface to external host (main CPU) is 9 * - Driver assumes that interface to external host (main CPU) is
13 * configured for NOR FLASH interface instead of VLYNQ serial 10 * configured for NOR FLASH interface instead of VLYNQ serial
@@ -452,11 +449,9 @@ static int tusb_musb_vbus_status(struct musb *musb)
452 return ret; 449 return ret;
453} 450}
454 451
455static struct timer_list musb_idle_timer; 452static void musb_do_idle(struct timer_list *t)
456
457static void musb_do_idle(unsigned long _musb)
458{ 453{
459 struct musb *musb = (void *)_musb; 454 struct musb *musb = from_timer(musb, t, dev_timer);
460 unsigned long flags; 455 unsigned long flags;
461 456
462 spin_lock_irqsave(&musb->lock, flags); 457 spin_lock_irqsave(&musb->lock, flags);
@@ -523,13 +518,13 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
523 && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) { 518 && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
524 dev_dbg(musb->controller, "%s active, deleting timer\n", 519 dev_dbg(musb->controller, "%s active, deleting timer\n",
525 usb_otg_state_string(musb->xceiv->otg->state)); 520 usb_otg_state_string(musb->xceiv->otg->state));
526 del_timer(&musb_idle_timer); 521 del_timer(&musb->dev_timer);
527 last_timer = jiffies; 522 last_timer = jiffies;
528 return; 523 return;
529 } 524 }
530 525
531 if (time_after(last_timer, timeout)) { 526 if (time_after(last_timer, timeout)) {
532 if (!timer_pending(&musb_idle_timer)) 527 if (!timer_pending(&musb->dev_timer))
533 last_timer = timeout; 528 last_timer = timeout;
534 else { 529 else {
535 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n"); 530 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n");
@@ -541,7 +536,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
541 dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", 536 dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
542 usb_otg_state_string(musb->xceiv->otg->state), 537 usb_otg_state_string(musb->xceiv->otg->state),
543 (unsigned long)jiffies_to_msecs(timeout - jiffies)); 538 (unsigned long)jiffies_to_msecs(timeout - jiffies));
544 mod_timer(&musb_idle_timer, timeout); 539 mod_timer(&musb->dev_timer, timeout);
545} 540}
546 541
547/* ticks of 60 MHz clock */ 542/* ticks of 60 MHz clock */
@@ -873,7 +868,7 @@ static irqreturn_t tusb_musb_interrupt(int irq, void *__hci)
873 } 868 }
874 869
875 if (int_src & TUSB_INT_SRC_USB_IP_CONN) 870 if (int_src & TUSB_INT_SRC_USB_IP_CONN)
876 del_timer(&musb_idle_timer); 871 del_timer(&musb->dev_timer);
877 872
878 /* OTG state change reports (annoyingly) not issued by Mentor core */ 873 /* OTG state change reports (annoyingly) not issued by Mentor core */
879 if (int_src & (TUSB_INT_SRC_VBUS_SENSE_CHNG 874 if (int_src & (TUSB_INT_SRC_VBUS_SENSE_CHNG
@@ -982,7 +977,7 @@ static void tusb_musb_disable(struct musb *musb)
982 musb_writel(tbase, TUSB_DMA_INT_MASK, 0x7fffffff); 977 musb_writel(tbase, TUSB_DMA_INT_MASK, 0x7fffffff);
983 musb_writel(tbase, TUSB_GPIO_INT_MASK, 0x1ff); 978 musb_writel(tbase, TUSB_GPIO_INT_MASK, 0x1ff);
984 979
985 del_timer(&musb_idle_timer); 980 del_timer(&musb->dev_timer);
986 981
987 if (is_dma_capable() && !dma_off) { 982 if (is_dma_capable() && !dma_off) {
988 printk(KERN_WARNING "%s %s: dma still active\n", 983 printk(KERN_WARNING "%s %s: dma still active\n",
@@ -1142,7 +1137,7 @@ static int tusb_musb_init(struct musb *musb)
1142 musb->xceiv->set_power = tusb_draw_power; 1137 musb->xceiv->set_power = tusb_draw_power;
1143 the_musb = musb; 1138 the_musb = musb;
1144 1139
1145 setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); 1140 timer_setup(&musb->dev_timer, musb_do_idle, 0);
1146 1141
1147done: 1142done:
1148 if (ret < 0) { 1143 if (ret < 0) {
@@ -1156,7 +1151,7 @@ done:
1156 1151
1157static int tusb_musb_exit(struct musb *musb) 1152static int tusb_musb_exit(struct musb *musb)
1158{ 1153{
1159 del_timer_sync(&musb_idle_timer); 1154 del_timer_sync(&musb->dev_timer);
1160 the_musb = NULL; 1155 the_musb = NULL;
1161 1156
1162 if (musb->board_set_power) 1157 if (musb->board_set_power)
diff --git a/drivers/usb/musb/tusb6010.h b/drivers/usb/musb/tusb6010.h
index 72cdad23ced9..fd8025bbece7 100644
--- a/drivers/usb/musb/tusb6010.h
+++ b/drivers/usb/musb/tusb6010.h
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Definitions for TUSB6010 USB 2.0 OTG Dual Role controller 3 * Definitions for TUSB6010 USB 2.0 OTG Dual Role controller
3 * 4 *
4 * Copyright (C) 2006 Nokia Corporation 5 * Copyright (C) 2006 Nokia Corporation
5 * Tony Lindgren <tony@atomide.com> 6 * Tony Lindgren <tony@atomide.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#ifndef __TUSB6010_H__ 9#ifndef __TUSB6010_H__
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index e8060e49b0f4..60a93b8bbe3c 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * TUSB6010 USB 2.0 OTG Dual Role controller OMAP DMA interface 3 * TUSB6010 USB 2.0 OTG Dual Role controller OMAP DMA interface
3 * 4 *
4 * Copyright (C) 2006 Nokia Corporation 5 * Copyright (C) 2006 Nokia Corporation
5 * Tony Lindgren <tony@atomide.com> 6 * Tony Lindgren <tony@atomide.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11#include <linux/module.h> 8#include <linux/module.h>
12#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 5a572500c418..27b4a77a9e23 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2010 ST-Ericsson AB 3 * Copyright (C) 2010 ST-Ericsson AB
3 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> 4 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
4 * 5 *
5 * Based on omap2430.c 6 * Based on omap2430.c
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 7 */
21 8
22#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index c92a295049ad..d19bb3e89da6 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * drivers/usb/musb/ux500_dma.c 3 * drivers/usb/musb/ux500_dma.c
3 * 4 *
@@ -9,19 +10,6 @@
9 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> 10 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
10 * Praveena Nadahally <praveen.nadahally@stericsson.com> 11 * Praveena Nadahally <praveen.nadahally@stericsson.com>
11 * Rajaram Regupathy <ragupathy.rajaram@stericsson.com> 12 * Rajaram Regupathy <ragupathy.rajaram@stericsson.com>
12 *
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 */ 13 */
26 14
27#include <linux/device.h> 15#include <linux/device.h>
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index aff702c0eb9f..0f8ab981d572 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -137,35 +137,6 @@ config USB_ISP1301
137 To compile this driver as a module, choose M here: the 137 To compile this driver as a module, choose M here: the
138 module will be called phy-isp1301. 138 module will be called phy-isp1301.
139 139
140config USB_MSM_OTG
141 tristate "Qualcomm on-chip USB OTG controller support"
142 depends on (USB || USB_GADGET) && (ARCH_QCOM || COMPILE_TEST)
143 depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y'
144 depends on RESET_CONTROLLER
145 select USB_PHY
146 help
147 Enable this to support the USB OTG transceiver on Qualcomm chips. It
148 handles PHY initialization, clock management, and workarounds
149 required after resetting the hardware and power management.
150 This driver is required even for peripheral only or host only
151 mode configurations.
152 This driver is not supported on boards like trout which
153 has an external PHY.
154
155config USB_QCOM_8X16_PHY
156 tristate "Qualcomm APQ8016/MSM8916 on-chip USB PHY controller support"
157 depends on ARCH_QCOM || COMPILE_TEST
158 depends on RESET_CONTROLLER
159 select USB_PHY
160 select USB_ULPI_VIEWPORT
161 help
162 Enable this to support the USB transceiver on Qualcomm 8x16 chipsets.
163 It handles PHY initialization, clock management, power management,
164 and workarounds required after resetting the hardware.
165
166 To compile this driver as a module, choose M here: the
167 module will be called phy-qcom-8x16-usb.
168
169config USB_MV_OTG 140config USB_MV_OTG
170 tristate "Marvell USB OTG support" 141 tristate "Marvell USB OTG support"
171 depends on USB_EHCI_MV && USB_MV_UDC && PM && USB_OTG 142 depends on USB_EHCI_MV && USB_MV_UDC && PM && USB_OTG
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 0c40ccc90631..25e579fb92b8 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -19,8 +19,6 @@ obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o
19obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o 19obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o
20obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o 20obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o
21obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o 21obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o
22obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o
23obj-$(CONFIG_USB_QCOM_8X16_PHY) += phy-qcom-8x16-usb.o
24obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o 22obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o
25obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o 23obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o
26obj-$(CONFIG_USB_ULPI) += phy-ulpi.o 24obj-$(CONFIG_USB_ULPI) += phy-ulpi.o
diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
index 66ffa82457a8..1ab134f45d67 100644
--- a/drivers/usb/phy/of.c
+++ b/drivers/usb/phy/of.c
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB of helper code 3 * USB of helper code
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */ 4 */
9 5
10#include <linux/kernel.h> 6#include <linux/kernel.h>
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 61bf2285d5b1..87295313a10c 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB transceiver driver for AB8500 family chips 3 * USB transceiver driver for AB8500 family chips
3 * 4 *
@@ -5,21 +6,6 @@
5 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> 6 * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
6 * Avinash Kumar <avinash.kumar@stericsson.com> 7 * Avinash Kumar <avinash.kumar@stericsson.com>
7 * Thirupathi Chippakurthy <thirupathi.chippakurthy@stericsson.com> 8 * Thirupathi Chippakurthy <thirupathi.chippakurthy@stericsson.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */ 9 */
24 10
25#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index 5f5f19813fde..a3cb25cb74f8 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/module.h> 2#include <linux/module.h>
2#include <linux/platform_device.h> 3#include <linux/platform_device.h>
3#include <linux/err.h> 4#include <linux/err.h>
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 7e5aece769da..b36fa8b953d0 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/module.h> 2#include <linux/module.h>
2#include <linux/platform_device.h> 3#include <linux/platform_device.h>
3#include <linux/dma-mapping.h> 4#include <linux/dma-mapping.h>
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index cf8f40ae6e01..900875f326d7 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2007,2008 Freescale semiconductor, Inc. 3 * Copyright (C) 2007,2008 Freescale semiconductor, Inc.
3 * 4 *
@@ -5,20 +6,6 @@
5 * Jerry Huang <Chang-Ming.Huang@freescale.com> 6 * Jerry Huang <Chang-Ming.Huang@freescale.com>
6 * 7 *
7 * Initialization based on code from Shlomi Gridish. 8 * Initialization based on code from Shlomi Gridish.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 9 */
23 10
24#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h
index 23149954a09c..43d410f6641b 100644
--- a/drivers/usb/phy/phy-fsl-usb.h
+++ b/drivers/usb/phy/phy-fsl-usb.h
@@ -1,19 +1,5 @@
1/* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. 1// SPDX-License-Identifier: GPL-2.0+
2 * 2/* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. */
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2 of the License, or (at your
6 * option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17 3
18#include <linux/usb/otg-fsm.h> 4#include <linux/usb/otg-fsm.h>
19#include <linux/usb/otg.h> 5#include <linux/usb/otg.h>
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 89d6e7a5fdb7..74ba88297991 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * NOP USB transceiver for all USB transceiver which are either built-in 3 * NOP USB transceiver for all USB transceiver which are either built-in
3 * into USB IP or which are mostly autonomous. 4 * into USB IP or which are mostly autonomous.
@@ -5,20 +6,6 @@
5 * Copyright (C) 2009 Texas Instruments Inc 6 * Copyright (C) 2009 Texas Instruments Inc
6 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com> 7 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Current status: 9 * Current status:
23 * This provides a "nop" transceiver for PHYs which are 10 * This provides a "nop" transceiver for PHYs which are
24 * autonomous such as isp1504, isp1707, etc. 11 * autonomous such as isp1504, isp1707, etc.
@@ -224,7 +211,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
224 int err = 0; 211 int err = 0;
225 212
226 u32 clk_rate = 0; 213 u32 clk_rate = 0;
227 bool needs_vcc = false; 214 bool needs_vcc = false, needs_clk = false;
228 215
229 if (dev->of_node) { 216 if (dev->of_node) {
230 struct device_node *node = dev->of_node; 217 struct device_node *node = dev->of_node;
@@ -233,6 +220,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
233 clk_rate = 0; 220 clk_rate = 0;
234 221
235 needs_vcc = of_property_read_bool(node, "vcc-supply"); 222 needs_vcc = of_property_read_bool(node, "vcc-supply");
223 needs_clk = of_property_read_bool(node, "clocks");
236 nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset", 224 nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
237 GPIOD_ASIS); 225 GPIOD_ASIS);
238 err = PTR_ERR_OR_ZERO(nop->gpiod_reset); 226 err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
@@ -275,6 +263,8 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
275 if (IS_ERR(nop->clk)) { 263 if (IS_ERR(nop->clk)) {
276 dev_dbg(dev, "Can't get phy clock: %ld\n", 264 dev_dbg(dev, "Can't get phy clock: %ld\n",
277 PTR_ERR(nop->clk)); 265 PTR_ERR(nop->clk));
266 if (needs_clk)
267 return PTR_ERR(nop->clk);
278 } 268 }
279 269
280 if (!IS_ERR(nop->clk) && clk_rate) { 270 if (!IS_ERR(nop->clk) && clk_rate) {
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f66120db8a41..553e2573c74f 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * gpio-vbus.c - simple GPIO VBUS sensing driver for B peripheral devices 3 * gpio-vbus.c - simple GPIO VBUS sensing driver for B peripheral devices
3 * 4 *
4 * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.com> 5 * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
index c6052c814bcc..7041ba030052 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * isp1301_omap - ISP 1301 USB transceiver, talking to OMAP OTG controller 3 * isp1301_omap - ISP 1301 USB transceiver, talking to OMAP OTG controller
3 * 4 *
4 * Copyright (C) 2004 Texas Instruments 5 * Copyright (C) 2004 Texas Instruments
5 * Copyright (C) 2004 David Brownell 6 * Copyright (C) 2004 David Brownell
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 7 */
21 8
22#include <linux/kernel.h> 9#include <linux/kernel.h>
@@ -1183,9 +1170,11 @@ static irqreturn_t isp1301_irq(int irq, void *isp)
1183 return IRQ_HANDLED; 1170 return IRQ_HANDLED;
1184} 1171}
1185 1172
1186static void isp1301_timer(unsigned long _isp) 1173static void isp1301_timer(struct timer_list *t)
1187{ 1174{
1188 isp1301_defer_work((void *)_isp, WORK_TIMER); 1175 struct isp1301 *isp = from_timer(isp, t, timer);
1176
1177 isp1301_defer_work(isp, WORK_TIMER);
1189} 1178}
1190 1179
1191/*-------------------------------------------------------------------------*/ 1180/*-------------------------------------------------------------------------*/
@@ -1222,7 +1211,6 @@ static int isp1301_remove(struct i2c_client *i2c)
1222 if (machine_is_omap_h2()) 1211 if (machine_is_omap_h2())
1223 gpio_free(2); 1212 gpio_free(2);
1224 1213
1225 isp->timer.data = 0;
1226 set_bit(WORK_STOP, &isp->todo); 1214 set_bit(WORK_STOP, &isp->todo);
1227 del_timer_sync(&isp->timer); 1215 del_timer_sync(&isp->timer);
1228 flush_work(&isp->work); 1216 flush_work(&isp->work);
@@ -1507,9 +1495,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
1507 } 1495 }
1508 1496
1509 INIT_WORK(&isp->work, isp1301_work); 1497 INIT_WORK(&isp->work, isp1301_work);
1510 init_timer(&isp->timer); 1498 timer_setup(&isp->timer, isp1301_timer, 0);
1511 isp->timer.function = isp1301_timer;
1512 isp->timer.data = (unsigned long) isp;
1513 1499
1514 i2c_set_clientdata(i2c, isp); 1500 i2c_set_clientdata(i2c, isp);
1515 isp->client = i2c; 1501 isp->client = i2c;
diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index f333024660b4..93b7d6a30aad 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * NXP ISP1301 USB transceiver driver 3 * NXP ISP1301 USB transceiver driver
3 * 4 *
4 * Copyright (C) 2012 Roland Stigge 5 * Copyright (C) 2012 Roland Stigge
5 * 6 *
6 * Author: Roland Stigge <stigge@antcom.de> 7 * Author: Roland Stigge <stigge@antcom.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/phy/phy-keystone.c b/drivers/usb/phy/phy-keystone.c
index 01d4e4cdbc79..19871266312d 100644
--- a/drivers/usb/phy/phy-keystone.c
+++ b/drivers/usb/phy/phy-keystone.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * phy-keystone - USB PHY, talking to dwc3 controller in Keystone. 3 * phy-keystone - USB PHY, talking to dwc3 controller in Keystone.
3 * 4 *
4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * 6 *
10 * Author: WingMan Kwok <w-kwok2@ti.com> 7 * Author: WingMan Kwok <w-kwok2@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */ 8 */
18 9
19#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
deleted file mode 100644
index 3d0dd2f97415..000000000000
--- a/drivers/usb/phy/phy-msm-usb.c
+++ /dev/null
@@ -1,2085 +0,0 @@
1/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 *
17 */
18
19#include <linux/module.h>
20#include <linux/device.h>
21#include <linux/extcon.h>
22#include <linux/gpio/consumer.h>
23#include <linux/platform_device.h>
24#include <linux/clk.h>
25#include <linux/slab.h>
26#include <linux/interrupt.h>
27#include <linux/err.h>
28#include <linux/delay.h>
29#include <linux/io.h>
30#include <linux/ioport.h>
31#include <linux/uaccess.h>
32#include <linux/debugfs.h>
33#include <linux/seq_file.h>
34#include <linux/pm_runtime.h>
35#include <linux/of.h>
36#include <linux/of_device.h>
37#include <linux/reboot.h>
38#include <linux/reset.h>
39#include <linux/types.h>
40#include <linux/usb/otg.h>
41
42#include <linux/usb.h>
43#include <linux/usb/otg.h>
44#include <linux/usb/of.h>
45#include <linux/usb/ulpi.h>
46#include <linux/usb/gadget.h>
47#include <linux/usb/hcd.h>
48#include <linux/usb/msm_hsusb_hw.h>
49#include <linux/regulator/consumer.h>
50
51/**
52 * OTG control
53 *
54 * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
55 * only configuration.
56 * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
57 * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
58 * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
59 *
60 */
61enum otg_control_type {
62 OTG_NO_CONTROL = 0,
63 OTG_PHY_CONTROL,
64 OTG_PMIC_CONTROL,
65 OTG_USER_CONTROL,
66};
67
68/**
69 * PHY used in
70 *
71 * INVALID_PHY Unsupported PHY
72 * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
73 * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
74 *
75 */
76enum msm_usb_phy_type {
77 INVALID_PHY = 0,
78 CI_45NM_INTEGRATED_PHY,
79 SNPS_28NM_INTEGRATED_PHY,
80};
81
82#define IDEV_CHG_MAX 1500
83#define IUNIT 100
84
85/**
86 * Different states involved in USB charger detection.
87 *
88 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
89 * process is not yet started.
90 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
91 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
92 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
93 * between SDP and DCP/CDP).
94 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
95 * between DCP and CDP).
96 * USB_CHG_STATE_DETECTED USB charger type is determined.
97 *
98 */
99enum usb_chg_state {
100 USB_CHG_STATE_UNDEFINED = 0,
101 USB_CHG_STATE_WAIT_FOR_DCD,
102 USB_CHG_STATE_DCD_DONE,
103 USB_CHG_STATE_PRIMARY_DONE,
104 USB_CHG_STATE_SECONDARY_DONE,
105 USB_CHG_STATE_DETECTED,
106};
107
108/**
109 * USB charger types
110 *
111 * USB_INVALID_CHARGER Invalid USB charger.
112 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
113 * on USB2.0 compliant host/hub.
114 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
115 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
116 * IDEV_CHG_MAX can be drawn irrespective of USB state.
117 *
118 */
119enum usb_chg_type {
120 USB_INVALID_CHARGER = 0,
121 USB_SDP_CHARGER,
122 USB_DCP_CHARGER,
123 USB_CDP_CHARGER,
124};
125
126/**
127 * struct msm_otg_platform_data - platform device data
128 * for msm_otg driver.
129 * @phy_init_seq: PHY configuration sequence values. Value of -1 is reserved as
130 * "do not overwrite default vaule at this address".
131 * @phy_init_sz: PHY configuration sequence size.
132 * @vbus_power: VBUS power on/off routine.
133 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
134 * @mode: Supported mode (OTG/peripheral/host).
135 * @otg_control: OTG switch controlled by user/Id pin
136 */
137struct msm_otg_platform_data {
138 int *phy_init_seq;
139 int phy_init_sz;
140 void (*vbus_power)(bool on);
141 unsigned power_budget;
142 enum usb_dr_mode mode;
143 enum otg_control_type otg_control;
144 enum msm_usb_phy_type phy_type;
145 void (*setup_gpio)(enum usb_otg_state state);
146};
147
148/**
149 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
150 * @otg: USB OTG Transceiver structure.
151 * @pdata: otg device platform data.
152 * @irq: IRQ number assigned for HSUSB controller.
153 * @clk: clock struct of usb_hs_clk.
154 * @pclk: clock struct of usb_hs_pclk.
155 * @core_clk: clock struct of usb_hs_core_clk.
156 * @regs: ioremapped register base address.
157 * @inputs: OTG state machine inputs(Id, SessValid etc).
158 * @sm_work: OTG state machine work.
159 * @in_lpm: indicates low power mode (LPM) state.
160 * @async_int: Async interrupt arrived.
161 * @cur_power: The amount of mA available from downstream port.
162 * @chg_work: Charger detection work.
163 * @chg_state: The state of charger detection process.
164 * @chg_type: The type of charger attached.
165 * @dcd_retires: The retry count used to track Data contact
166 * detection process.
167 * @manual_pullup: true if VBUS is not routed to USB controller/phy
168 * and controller driver therefore enables pull-up explicitly before
169 * starting controller using usbcmd run/stop bit.
170 * @vbus: VBUS signal state trakining, using extcon framework
171 * @id: ID signal state trakining, using extcon framework
172 * @switch_gpio: Descriptor for GPIO used to control external Dual
173 * SPDT USB Switch.
174 * @reboot: Used to inform the driver to route USB D+/D- line to Device
175 * connector
176 */
177struct msm_otg {
178 struct usb_phy phy;
179 struct msm_otg_platform_data *pdata;
180 int irq;
181 struct clk *clk;
182 struct clk *pclk;
183 struct clk *core_clk;
184 void __iomem *regs;
185#define ID 0
186#define B_SESS_VLD 1
187 unsigned long inputs;
188 struct work_struct sm_work;
189 atomic_t in_lpm;
190 int async_int;
191 unsigned cur_power;
192 int phy_number;
193 struct delayed_work chg_work;
194 enum usb_chg_state chg_state;
195 enum usb_chg_type chg_type;
196 u8 dcd_retries;
197 struct regulator *v3p3;
198 struct regulator *v1p8;
199 struct regulator *vddcx;
200 struct regulator_bulk_data supplies[3];
201
202 struct reset_control *phy_rst;
203 struct reset_control *link_rst;
204 int vdd_levels[3];
205
206 bool manual_pullup;
207
208 struct gpio_desc *switch_gpio;
209 struct notifier_block reboot;
210};
211
212#define MSM_USB_BASE (motg->regs)
213#define DRIVER_NAME "msm_otg"
214
215#define ULPI_IO_TIMEOUT_USEC (10 * 1000)
216#define LINK_RESET_TIMEOUT_USEC (250 * 1000)
217
218#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
219#define USB_PHY_3P3_VOL_MAX 3300000 /* uV */
220#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
221#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
222
223#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
224#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
225#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
226#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
227
228#define USB_PHY_VDD_DIG_VOL_MIN 1000000 /* uV */
229#define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
230#define USB_PHY_SUSP_DIG_VOL 500000 /* uV */
231
232enum vdd_levels {
233 VDD_LEVEL_NONE = 0,
234 VDD_LEVEL_MIN,
235 VDD_LEVEL_MAX,
236};
237
238static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
239{
240 int ret = 0;
241
242 if (init) {
243 ret = regulator_set_voltage(motg->vddcx,
244 motg->vdd_levels[VDD_LEVEL_MIN],
245 motg->vdd_levels[VDD_LEVEL_MAX]);
246 if (ret) {
247 dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
248 return ret;
249 }
250
251 ret = regulator_enable(motg->vddcx);
252 if (ret)
253 dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n");
254 } else {
255 ret = regulator_set_voltage(motg->vddcx, 0,
256 motg->vdd_levels[VDD_LEVEL_MAX]);
257 if (ret)
258 dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
259 ret = regulator_disable(motg->vddcx);
260 if (ret)
261 dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n");
262 }
263
264 return ret;
265}
266
267static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
268{
269 int rc = 0;
270
271 if (init) {
272 rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
273 USB_PHY_3P3_VOL_MAX);
274 if (rc) {
275 dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
276 goto exit;
277 }
278 rc = regulator_enable(motg->v3p3);
279 if (rc) {
280 dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n");
281 goto exit;
282 }
283 rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
284 USB_PHY_1P8_VOL_MAX);
285 if (rc) {
286 dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
287 goto disable_3p3;
288 }
289 rc = regulator_enable(motg->v1p8);
290 if (rc) {
291 dev_err(motg->phy.dev, "unable to enable the hsusb 1p8\n");
292 goto disable_3p3;
293 }
294
295 return 0;
296 }
297
298 regulator_disable(motg->v1p8);
299disable_3p3:
300 regulator_disable(motg->v3p3);
301exit:
302 return rc;
303}
304
305static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
306{
307 int ret = 0;
308
309 if (on) {
310 ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_HPM_LOAD);
311 if (ret < 0) {
312 pr_err("Could not set HPM for v1p8\n");
313 return ret;
314 }
315 ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_HPM_LOAD);
316 if (ret < 0) {
317 pr_err("Could not set HPM for v3p3\n");
318 regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);
319 return ret;
320 }
321 } else {
322 ret = regulator_set_load(motg->v1p8, USB_PHY_1P8_LPM_LOAD);
323 if (ret < 0)
324 pr_err("Could not set LPM for v1p8\n");
325 ret = regulator_set_load(motg->v3p3, USB_PHY_3P3_LPM_LOAD);
326 if (ret < 0)
327 pr_err("Could not set LPM for v3p3\n");
328 }
329
330 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
331 return ret < 0 ? ret : 0;
332}
333
334static int ulpi_read(struct usb_phy *phy, u32 reg)
335{
336 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
337 int cnt = 0;
338
339 /* initiate read operation */
340 writel(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg),
341 USB_ULPI_VIEWPORT);
342
343 /* wait for completion */
344 while (cnt < ULPI_IO_TIMEOUT_USEC) {
345 if (!(readl(USB_ULPI_VIEWPORT) & ULPI_RUN))
346 break;
347 udelay(1);
348 cnt++;
349 }
350
351 if (cnt >= ULPI_IO_TIMEOUT_USEC) {
352 dev_err(phy->dev, "ulpi_read: timeout %08x\n",
353 readl(USB_ULPI_VIEWPORT));
354 return -ETIMEDOUT;
355 }
356 return ULPI_DATA_READ(readl(USB_ULPI_VIEWPORT));
357}
358
359static int ulpi_write(struct usb_phy *phy, u32 val, u32 reg)
360{
361 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
362 int cnt = 0;
363
364 /* initiate write operation */
365 writel(ULPI_RUN | ULPI_WRITE |
366 ULPI_ADDR(reg) | ULPI_DATA(val),
367 USB_ULPI_VIEWPORT);
368
369 /* wait for completion */
370 while (cnt < ULPI_IO_TIMEOUT_USEC) {
371 if (!(readl(USB_ULPI_VIEWPORT) & ULPI_RUN))
372 break;
373 udelay(1);
374 cnt++;
375 }
376
377 if (cnt >= ULPI_IO_TIMEOUT_USEC) {
378 dev_err(phy->dev, "ulpi_write: timeout\n");
379 return -ETIMEDOUT;
380 }
381 return 0;
382}
383
384static struct usb_phy_io_ops msm_otg_io_ops = {
385 .read = ulpi_read,
386 .write = ulpi_write,
387};
388
389static void ulpi_init(struct msm_otg *motg)
390{
391 struct msm_otg_platform_data *pdata = motg->pdata;
392 int *seq = pdata->phy_init_seq, idx;
393 u32 addr = ULPI_EXT_VENDOR_SPECIFIC;
394
395 for (idx = 0; idx < pdata->phy_init_sz; idx++) {
396 if (seq[idx] == -1)
397 continue;
398
399 dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
400 seq[idx], addr + idx);
401 ulpi_write(&motg->phy, seq[idx], addr + idx);
402 }
403}
404
405static int msm_phy_notify_disconnect(struct usb_phy *phy,
406 enum usb_device_speed speed)
407{
408 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
409 int val;
410
411 if (motg->manual_pullup) {
412 val = ULPI_MISC_A_VBUSVLDEXT | ULPI_MISC_A_VBUSVLDEXTSEL;
413 usb_phy_io_write(phy, val, ULPI_CLR(ULPI_MISC_A));
414 }
415
416 /*
417 * Put the transceiver in non-driving mode. Otherwise host
418 * may not detect soft-disconnection.
419 */
420 val = ulpi_read(phy, ULPI_FUNC_CTRL);
421 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
422 val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
423 ulpi_write(phy, val, ULPI_FUNC_CTRL);
424
425 return 0;
426}
427
428static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
429{
430 int ret;
431
432 if (assert)
433 ret = reset_control_assert(motg->link_rst);
434 else
435 ret = reset_control_deassert(motg->link_rst);
436
437 if (ret)
438 dev_err(motg->phy.dev, "usb link clk reset %s failed\n",
439 assert ? "assert" : "deassert");
440
441 return ret;
442}
443
444static int msm_otg_phy_clk_reset(struct msm_otg *motg)
445{
446 int ret = 0;
447
448 if (motg->phy_rst)
449 ret = reset_control_reset(motg->phy_rst);
450
451 if (ret)
452 dev_err(motg->phy.dev, "usb phy clk reset failed\n");
453
454 return ret;
455}
456
457static int msm_link_reset(struct msm_otg *motg)
458{
459 u32 val;
460 int ret;
461
462 ret = msm_otg_link_clk_reset(motg, 1);
463 if (ret)
464 return ret;
465
466 /* wait for 1ms delay as suggested in HPG. */
467 usleep_range(1000, 1200);
468
469 ret = msm_otg_link_clk_reset(motg, 0);
470 if (ret)
471 return ret;
472
473 if (motg->phy_number)
474 writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
475
476 /* put transceiver in serial mode as part of reset */
477 val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
478 writel(val | PORTSC_PTS_SERIAL, USB_PORTSC);
479
480 return 0;
481}
482
483static int msm_otg_reset(struct usb_phy *phy)
484{
485 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
486 int cnt = 0;
487
488 writel(USBCMD_RESET, USB_USBCMD);
489 while (cnt < LINK_RESET_TIMEOUT_USEC) {
490 if (!(readl(USB_USBCMD) & USBCMD_RESET))
491 break;
492 udelay(1);
493 cnt++;
494 }
495 if (cnt >= LINK_RESET_TIMEOUT_USEC)
496 return -ETIMEDOUT;
497
498 /* select ULPI phy and clear other status/control bits in PORTSC */
499 writel(PORTSC_PTS_ULPI, USB_PORTSC);
500
501 writel(0x0, USB_AHBBURST);
502 writel(0x08, USB_AHBMODE);
503
504 if (motg->phy_number)
505 writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
506 return 0;
507}
508
509static void msm_phy_reset(struct msm_otg *motg)
510{
511 void __iomem *addr;
512
513 if (motg->pdata->phy_type != SNPS_28NM_INTEGRATED_PHY) {
514 msm_otg_phy_clk_reset(motg);
515 return;
516 }
517
518 addr = USB_PHY_CTRL;
519 if (motg->phy_number)
520 addr = USB_PHY_CTRL2;
521
522 /* Assert USB PHY_POR */
523 writel(readl(addr) | PHY_POR_ASSERT, addr);
524
525 /*
526 * wait for minimum 10 microseconds as suggested in HPG.
527 * Use a slightly larger value since the exact value didn't
528 * work 100% of the time.
529 */
530 udelay(12);
531
532 /* Deassert USB PHY_POR */
533 writel(readl(addr) & ~PHY_POR_ASSERT, addr);
534}
535
536static int msm_usb_reset(struct usb_phy *phy)
537{
538 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
539 int ret;
540
541 if (!IS_ERR(motg->core_clk))
542 clk_prepare_enable(motg->core_clk);
543
544 ret = msm_link_reset(motg);
545 if (ret) {
546 dev_err(phy->dev, "phy_reset failed\n");
547 return ret;
548 }
549
550 ret = msm_otg_reset(&motg->phy);
551 if (ret) {
552 dev_err(phy->dev, "link reset failed\n");
553 return ret;
554 }
555
556 msleep(100);
557
558 /* Reset USB PHY after performing USB Link RESET */
559 msm_phy_reset(motg);
560
561 if (!IS_ERR(motg->core_clk))
562 clk_disable_unprepare(motg->core_clk);
563
564 return 0;
565}
566
567static int msm_phy_init(struct usb_phy *phy)
568{
569 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
570 struct msm_otg_platform_data *pdata = motg->pdata;
571 u32 val, ulpi_val = 0;
572
573 /* Program USB PHY Override registers. */
574 ulpi_init(motg);
575
576 /*
577 * It is recommended in HPG to reset USB PHY after programming
578 * USB PHY Override registers.
579 */
580 msm_phy_reset(motg);
581
582 if (pdata->otg_control == OTG_PHY_CONTROL) {
583 val = readl(USB_OTGSC);
584 if (pdata->mode == USB_DR_MODE_OTG) {
585 ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID;
586 val |= OTGSC_IDIE | OTGSC_BSVIE;
587 } else if (pdata->mode == USB_DR_MODE_PERIPHERAL) {
588 ulpi_val = ULPI_INT_SESS_VALID;
589 val |= OTGSC_BSVIE;
590 }
591 writel(val, USB_OTGSC);
592 ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_RISE);
593 ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL);
594 }
595
596 if (motg->manual_pullup) {
597 val = ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT;
598 ulpi_write(phy, val, ULPI_SET(ULPI_MISC_A));
599
600 val = readl(USB_GENCONFIG_2);
601 val |= GENCONFIG_2_SESS_VLD_CTRL_EN;
602 writel(val, USB_GENCONFIG_2);
603
604 val = readl(USB_USBCMD);
605 val |= USBCMD_SESS_VLD_CTRL;
606 writel(val, USB_USBCMD);
607
608 val = ulpi_read(phy, ULPI_FUNC_CTRL);
609 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
610 val |= ULPI_FUNC_CTRL_OPMODE_NORMAL;
611 ulpi_write(phy, val, ULPI_FUNC_CTRL);
612 }
613
614 if (motg->phy_number)
615 writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
616
617 return 0;
618}
619
620#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)
621#define PHY_RESUME_TIMEOUT_USEC (100 * 1000)
622
623#ifdef CONFIG_PM
624
625static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
626{
627 int max_vol = motg->vdd_levels[VDD_LEVEL_MAX];
628 int min_vol;
629 int ret;
630
631 if (high)
632 min_vol = motg->vdd_levels[VDD_LEVEL_MIN];
633 else
634 min_vol = motg->vdd_levels[VDD_LEVEL_NONE];
635
636 ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
637 if (ret) {
638 pr_err("Cannot set vddcx voltage\n");
639 return ret;
640 }
641
642 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
643
644 return ret;
645}
646
647static int msm_otg_suspend(struct msm_otg *motg)
648{
649 struct usb_phy *phy = &motg->phy;
650 struct usb_bus *bus = phy->otg->host;
651 struct msm_otg_platform_data *pdata = motg->pdata;
652 void __iomem *addr;
653 int cnt = 0;
654
655 if (atomic_read(&motg->in_lpm))
656 return 0;
657
658 disable_irq(motg->irq);
659 /*
660 * Chipidea 45-nm PHY suspend sequence:
661 *
662 * Interrupt Latch Register auto-clear feature is not present
663 * in all PHY versions. Latch register is clear on read type.
664 * Clear latch register to avoid spurious wakeup from
665 * low power mode (LPM).
666 *
667 * PHY comparators are disabled when PHY enters into low power
668 * mode (LPM). Keep PHY comparators ON in LPM only when we expect
669 * VBUS/Id notifications from USB PHY. Otherwise turn off USB
670 * PHY comparators. This save significant amount of power.
671 *
672 * PLL is not turned off when PHY enters into low power mode (LPM).
673 * Disable PLL for maximum power savings.
674 */
675
676 if (motg->pdata->phy_type == CI_45NM_INTEGRATED_PHY) {
677 ulpi_read(phy, 0x14);
678 if (pdata->otg_control == OTG_PHY_CONTROL)
679 ulpi_write(phy, 0x01, 0x30);
680 ulpi_write(phy, 0x08, 0x09);
681 }
682
683 /*
684 * PHY may take some time or even fail to enter into low power
685 * mode (LPM). Hence poll for 500 msec and reset the PHY and link
686 * in failure case.
687 */
688 writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC);
689 while (cnt < PHY_SUSPEND_TIMEOUT_USEC) {
690 if (readl(USB_PORTSC) & PORTSC_PHCD)
691 break;
692 udelay(1);
693 cnt++;
694 }
695
696 if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) {
697 dev_err(phy->dev, "Unable to suspend PHY\n");
698 msm_otg_reset(phy);
699 enable_irq(motg->irq);
700 return -ETIMEDOUT;
701 }
702
703 /*
704 * PHY has capability to generate interrupt asynchronously in low
705 * power mode (LPM). This interrupt is level triggered. So USB IRQ
706 * line must be disabled till async interrupt enable bit is cleared
707 * in USBCMD register. Assert STP (ULPI interface STOP signal) to
708 * block data communication from PHY.
709 */
710 writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);
711
712 addr = USB_PHY_CTRL;
713 if (motg->phy_number)
714 addr = USB_PHY_CTRL2;
715
716 if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
717 motg->pdata->otg_control == OTG_PMIC_CONTROL)
718 writel(readl(addr) | PHY_RETEN, addr);
719
720 clk_disable_unprepare(motg->pclk);
721 clk_disable_unprepare(motg->clk);
722 if (!IS_ERR(motg->core_clk))
723 clk_disable_unprepare(motg->core_clk);
724
725 if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
726 motg->pdata->otg_control == OTG_PMIC_CONTROL) {
727 msm_hsusb_ldo_set_mode(motg, 0);
728 msm_hsusb_config_vddcx(motg, 0);
729 }
730
731 if (device_may_wakeup(phy->dev))
732 enable_irq_wake(motg->irq);
733 if (bus)
734 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);
735
736 atomic_set(&motg->in_lpm, 1);
737 enable_irq(motg->irq);
738
739 dev_info(phy->dev, "USB in low power mode\n");
740
741 return 0;
742}
743
744static int msm_otg_resume(struct msm_otg *motg)
745{
746 struct usb_phy *phy = &motg->phy;
747 struct usb_bus *bus = phy->otg->host;
748 void __iomem *addr;
749 int cnt = 0;
750 unsigned temp;
751
752 if (!atomic_read(&motg->in_lpm))
753 return 0;
754
755 clk_prepare_enable(motg->pclk);
756 clk_prepare_enable(motg->clk);
757 if (!IS_ERR(motg->core_clk))
758 clk_prepare_enable(motg->core_clk);
759
760 if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
761 motg->pdata->otg_control == OTG_PMIC_CONTROL) {
762
763 addr = USB_PHY_CTRL;
764 if (motg->phy_number)
765 addr = USB_PHY_CTRL2;
766
767 msm_hsusb_ldo_set_mode(motg, 1);
768 msm_hsusb_config_vddcx(motg, 1);
769 writel(readl(addr) & ~PHY_RETEN, addr);
770 }
771
772 temp = readl(USB_USBCMD);
773 temp &= ~ASYNC_INTR_CTRL;
774 temp &= ~ULPI_STP_CTRL;
775 writel(temp, USB_USBCMD);
776
777 /*
778 * PHY comes out of low power mode (LPM) in case of wakeup
779 * from asynchronous interrupt.
780 */
781 if (!(readl(USB_PORTSC) & PORTSC_PHCD))
782 goto skip_phy_resume;
783
784 writel(readl(USB_PORTSC) & ~PORTSC_PHCD, USB_PORTSC);
785 while (cnt < PHY_RESUME_TIMEOUT_USEC) {
786 if (!(readl(USB_PORTSC) & PORTSC_PHCD))
787 break;
788 udelay(1);
789 cnt++;
790 }
791
792 if (cnt >= PHY_RESUME_TIMEOUT_USEC) {
793 /*
794 * This is a fatal error. Reset the link and
795 * PHY. USB state can not be restored. Re-insertion
796 * of USB cable is the only way to get USB working.
797 */
798 dev_err(phy->dev, "Unable to resume USB. Re-plugin the cable\n");
799 msm_otg_reset(phy);
800 }
801
802skip_phy_resume:
803 if (device_may_wakeup(phy->dev))
804 disable_irq_wake(motg->irq);
805 if (bus)
806 set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);
807
808 atomic_set(&motg->in_lpm, 0);
809
810 if (motg->async_int) {
811 motg->async_int = 0;
812 pm_runtime_put(phy->dev);
813 enable_irq(motg->irq);
814 }
815
816 dev_info(phy->dev, "USB exited from low power mode\n");
817
818 return 0;
819}
820#endif
821
822static void msm_otg_notify_charger(struct msm_otg *motg, unsigned mA)
823{
824 if (motg->cur_power == mA)
825 return;
826
827 /* TODO: Notify PMIC about available current */
828 dev_info(motg->phy.dev, "Avail curr from USB = %u\n", mA);
829 motg->cur_power = mA;
830}
831
832static void msm_otg_start_host(struct usb_phy *phy, int on)
833{
834 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
835 struct msm_otg_platform_data *pdata = motg->pdata;
836 struct usb_hcd *hcd;
837
838 if (!phy->otg->host)
839 return;
840
841 hcd = bus_to_hcd(phy->otg->host);
842
843 if (on) {
844 dev_dbg(phy->dev, "host on\n");
845
846 if (pdata->vbus_power)
847 pdata->vbus_power(1);
848 /*
849 * Some boards have a switch cotrolled by gpio
850 * to enable/disable internal HUB. Enable internal
851 * HUB before kicking the host.
852 */
853 if (pdata->setup_gpio)
854 pdata->setup_gpio(OTG_STATE_A_HOST);
855#ifdef CONFIG_USB
856 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
857 device_wakeup_enable(hcd->self.controller);
858#endif
859 } else {
860 dev_dbg(phy->dev, "host off\n");
861
862#ifdef CONFIG_USB
863 usb_remove_hcd(hcd);
864#endif
865 if (pdata->setup_gpio)
866 pdata->setup_gpio(OTG_STATE_UNDEFINED);
867 if (pdata->vbus_power)
868 pdata->vbus_power(0);
869 }
870}
871
872static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
873{
874 struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
875 struct usb_hcd *hcd;
876
877 /*
878 * Fail host registration if this board can support
879 * only peripheral configuration.
880 */
881 if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
882 dev_info(otg->usb_phy->dev, "Host mode is not supported\n");
883 return -ENODEV;
884 }
885
886 if (!host) {
887 if (otg->state == OTG_STATE_A_HOST) {
888 pm_runtime_get_sync(otg->usb_phy->dev);
889 msm_otg_start_host(otg->usb_phy, 0);
890 otg->host = NULL;
891 otg->state = OTG_STATE_UNDEFINED;
892 schedule_work(&motg->sm_work);
893 } else {
894 otg->host = NULL;
895 }
896
897 return 0;
898 }
899
900 hcd = bus_to_hcd(host);
901 hcd->power_budget = motg->pdata->power_budget;
902
903 otg->host = host;
904 dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");
905
906 pm_runtime_get_sync(otg->usb_phy->dev);
907 schedule_work(&motg->sm_work);
908
909 return 0;
910}
911
912static void msm_otg_start_peripheral(struct usb_phy *phy, int on)
913{
914 struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
915 struct msm_otg_platform_data *pdata = motg->pdata;
916
917 if (!phy->otg->gadget)
918 return;
919
920 if (on) {
921 dev_dbg(phy->dev, "gadget on\n");
922 /*
923 * Some boards have a switch cotrolled by gpio
924 * to enable/disable internal HUB. Disable internal
925 * HUB before kicking the gadget.
926 */
927 if (pdata->setup_gpio)
928 pdata->setup_gpio(OTG_STATE_B_PERIPHERAL);
929 usb_gadget_vbus_connect(phy->otg->gadget);
930 } else {
931 dev_dbg(phy->dev, "gadget off\n");
932 usb_gadget_vbus_disconnect(phy->otg->gadget);
933 if (pdata->setup_gpio)
934 pdata->setup_gpio(OTG_STATE_UNDEFINED);
935 }
936
937}
938
939static int msm_otg_set_peripheral(struct usb_otg *otg,
940 struct usb_gadget *gadget)
941{
942 struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
943
944 /*
945 * Fail peripheral registration if this board can support
946 * only host configuration.
947 */
948 if (motg->pdata->mode == USB_DR_MODE_HOST) {
949 dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n");
950 return -ENODEV;
951 }
952
953 if (!gadget) {
954 if (otg->state == OTG_STATE_B_PERIPHERAL) {
955 pm_runtime_get_sync(otg->usb_phy->dev);
956 msm_otg_start_peripheral(otg->usb_phy, 0);
957 otg->gadget = NULL;
958 otg->state = OTG_STATE_UNDEFINED;
959 schedule_work(&motg->sm_work);
960 } else {
961 otg->gadget = NULL;
962 }
963
964 return 0;
965 }
966 otg->gadget = gadget;
967 dev_dbg(otg->usb_phy->dev,
968 "peripheral driver registered w/ tranceiver\n");
969
970 pm_runtime_get_sync(otg->usb_phy->dev);
971 schedule_work(&motg->sm_work);
972
973 return 0;
974}
975
976static bool msm_chg_check_secondary_det(struct msm_otg *motg)
977{
978 struct usb_phy *phy = &motg->phy;
979 u32 chg_det;
980 bool ret = false;
981
982 switch (motg->pdata->phy_type) {
983 case CI_45NM_INTEGRATED_PHY:
984 chg_det = ulpi_read(phy, 0x34);
985 ret = chg_det & (1 << 4);
986 break;
987 case SNPS_28NM_INTEGRATED_PHY:
988 chg_det = ulpi_read(phy, 0x87);
989 ret = chg_det & 1;
990 break;
991 default:
992 break;
993 }
994 return ret;
995}
996
997static void msm_chg_enable_secondary_det(struct msm_otg *motg)
998{
999 struct usb_phy *phy = &motg->phy;
1000 u32 chg_det;
1001
1002 switch (motg->pdata->phy_type) {
1003 case CI_45NM_INTEGRATED_PHY:
1004 chg_det = ulpi_read(phy, 0x34);
1005 /* Turn off charger block */
1006 chg_det |= ~(1 << 1);
1007 ulpi_write(phy, chg_det, 0x34);
1008 udelay(20);
1009 /* control chg block via ULPI */
1010 chg_det &= ~(1 << 3);
1011 ulpi_write(phy, chg_det, 0x34);
1012 /* put it in host mode for enabling D- source */
1013 chg_det &= ~(1 << 2);
1014 ulpi_write(phy, chg_det, 0x34);
1015 /* Turn on chg detect block */
1016 chg_det &= ~(1 << 1);
1017 ulpi_write(phy, chg_det, 0x34);
1018 udelay(20);
1019 /* enable chg detection */
1020 chg_det &= ~(1 << 0);
1021 ulpi_write(phy, chg_det, 0x34);
1022 break;
1023 case SNPS_28NM_INTEGRATED_PHY:
1024 /*
1025 * Configure DM as current source, DP as current sink
1026 * and enable battery charging comparators.
1027 */
1028 ulpi_write(phy, 0x8, 0x85);
1029 ulpi_write(phy, 0x2, 0x85);
1030 ulpi_write(phy, 0x1, 0x85);
1031 break;
1032 default:
1033 break;
1034 }
1035}
1036
1037static bool msm_chg_check_primary_det(struct msm_otg *motg)
1038{
1039 struct usb_phy *phy = &motg->phy;
1040 u32 chg_det;
1041 bool ret = false;
1042
1043 switch (motg->pdata->phy_type) {
1044 case CI_45NM_INTEGRATED_PHY:
1045 chg_det = ulpi_read(phy, 0x34);
1046 ret = chg_det & (1 << 4);
1047 break;
1048 case SNPS_28NM_INTEGRATED_PHY:
1049 chg_det = ulpi_read(phy, 0x87);
1050 ret = chg_det & 1;
1051 break;
1052 default:
1053 break;
1054 }
1055 return ret;
1056}
1057
1058static void msm_chg_enable_primary_det(struct msm_otg *motg)
1059{
1060 struct usb_phy *phy = &motg->phy;
1061 u32 chg_det;
1062
1063 switch (motg->pdata->phy_type) {
1064 case CI_45NM_INTEGRATED_PHY:
1065 chg_det = ulpi_read(phy, 0x34);
1066 /* enable chg detection */
1067 chg_det &= ~(1 << 0);
1068 ulpi_write(phy, chg_det, 0x34);
1069 break;
1070 case SNPS_28NM_INTEGRATED_PHY:
1071 /*
1072 * Configure DP as current source, DM as current sink
1073 * and enable battery charging comparators.
1074 */
1075 ulpi_write(phy, 0x2, 0x85);
1076 ulpi_write(phy, 0x1, 0x85);
1077 break;
1078 default:
1079 break;
1080 }
1081}
1082
1083static bool msm_chg_check_dcd(struct msm_otg *motg)
1084{
1085 struct usb_phy *phy = &motg->phy;
1086 u32 line_state;
1087 bool ret = false;
1088
1089 switch (motg->pdata->phy_type) {
1090 case CI_45NM_INTEGRATED_PHY:
1091 line_state = ulpi_read(phy, 0x15);
1092 ret = !(line_state & 1);
1093 break;
1094 case SNPS_28NM_INTEGRATED_PHY:
1095 line_state = ulpi_read(phy, 0x87);
1096 ret = line_state & 2;
1097 break;
1098 default:
1099 break;
1100 }
1101 return ret;
1102}
1103
1104static void msm_chg_disable_dcd(struct msm_otg *motg)
1105{
1106 struct usb_phy *phy = &motg->phy;
1107 u32 chg_det;
1108
1109 switch (motg->pdata->phy_type) {
1110 case CI_45NM_INTEGRATED_PHY:
1111 chg_det = ulpi_read(phy, 0x34);
1112 chg_det &= ~(1 << 5);
1113 ulpi_write(phy, chg_det, 0x34);
1114 break;
1115 case SNPS_28NM_INTEGRATED_PHY:
1116 ulpi_write(phy, 0x10, 0x86);
1117 break;
1118 default:
1119 break;
1120 }
1121}
1122
1123static void msm_chg_enable_dcd(struct msm_otg *motg)
1124{
1125 struct usb_phy *phy = &motg->phy;
1126 u32 chg_det;
1127
1128 switch (motg->pdata->phy_type) {
1129 case CI_45NM_INTEGRATED_PHY:
1130 chg_det = ulpi_read(phy, 0x34);
1131 /* Turn on D+ current source */
1132 chg_det |= (1 << 5);
1133 ulpi_write(phy, chg_det, 0x34);
1134 break;
1135 case SNPS_28NM_INTEGRATED_PHY:
1136 /* Data contact detection enable */
1137 ulpi_write(phy, 0x10, 0x85);
1138 break;
1139 default:
1140 break;
1141 }
1142}
1143
1144static void msm_chg_block_on(struct msm_otg *motg)
1145{
1146 struct usb_phy *phy = &motg->phy;
1147 u32 func_ctrl, chg_det;
1148
1149 /* put the controller in non-driving mode */
1150 func_ctrl = ulpi_read(phy, ULPI_FUNC_CTRL);
1151 func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
1152 func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
1153 ulpi_write(phy, func_ctrl, ULPI_FUNC_CTRL);
1154
1155 switch (motg->pdata->phy_type) {
1156 case CI_45NM_INTEGRATED_PHY:
1157 chg_det = ulpi_read(phy, 0x34);
1158 /* control chg block via ULPI */
1159 chg_det &= ~(1 << 3);
1160 ulpi_write(phy, chg_det, 0x34);
1161 /* Turn on chg detect block */
1162 chg_det &= ~(1 << 1);
1163 ulpi_write(phy, chg_det, 0x34);
1164 udelay(20);
1165 break;
1166 case SNPS_28NM_INTEGRATED_PHY:
1167 /* Clear charger detecting control bits */
1168 ulpi_write(phy, 0x3F, 0x86);
1169 /* Clear alt interrupt latch and enable bits */
1170 ulpi_write(phy, 0x1F, 0x92);
1171 ulpi_write(phy, 0x1F, 0x95);
1172 udelay(100);
1173 break;
1174 default:
1175 break;
1176 }
1177}
1178
1179static void msm_chg_block_off(struct msm_otg *motg)
1180{
1181 struct usb_phy *phy = &motg->phy;
1182 u32 func_ctrl, chg_det;
1183
1184 switch (motg->pdata->phy_type) {
1185 case CI_45NM_INTEGRATED_PHY:
1186 chg_det = ulpi_read(phy, 0x34);
1187 /* Turn off charger block */
1188 chg_det |= ~(1 << 1);
1189 ulpi_write(phy, chg_det, 0x34);
1190 break;
1191 case SNPS_28NM_INTEGRATED_PHY:
1192 /* Clear charger detecting control bits */
1193 ulpi_write(phy, 0x3F, 0x86);
1194 /* Clear alt interrupt latch and enable bits */
1195 ulpi_write(phy, 0x1F, 0x92);
1196 ulpi_write(phy, 0x1F, 0x95);
1197 break;
1198 default:
1199 break;
1200 }
1201
1202 /* put the controller in normal mode */
1203 func_ctrl = ulpi_read(phy, ULPI_FUNC_CTRL);
1204 func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
1205 func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NORMAL;
1206 ulpi_write(phy, func_ctrl, ULPI_FUNC_CTRL);
1207}
1208
1209#define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */
1210#define MSM_CHG_DCD_MAX_RETRIES 6 /* Tdcd_tmout = 6 * 100 msec */
1211#define MSM_CHG_PRIMARY_DET_TIME (40 * HZ/1000) /* TVDPSRC_ON */
1212#define MSM_CHG_SECONDARY_DET_TIME (40 * HZ/1000) /* TVDMSRC_ON */
1213static void msm_chg_detect_work(struct work_struct *w)
1214{
1215 struct msm_otg *motg = container_of(w, struct msm_otg, chg_work.work);
1216 struct usb_phy *phy = &motg->phy;
1217 bool is_dcd, tmout, vout;
1218 unsigned long delay;
1219
1220 dev_dbg(phy->dev, "chg detection work\n");
1221 switch (motg->chg_state) {
1222 case USB_CHG_STATE_UNDEFINED:
1223 pm_runtime_get_sync(phy->dev);
1224 msm_chg_block_on(motg);
1225 msm_chg_enable_dcd(motg);
1226 motg->chg_state = USB_CHG_STATE_WAIT_FOR_DCD;
1227 motg->dcd_retries = 0;
1228 delay = MSM_CHG_DCD_POLL_TIME;
1229 break;
1230 case USB_CHG_STATE_WAIT_FOR_DCD:
1231 is_dcd = msm_chg_check_dcd(motg);
1232 tmout = ++motg->dcd_retries == MSM_CHG_DCD_MAX_RETRIES;
1233 if (is_dcd || tmout) {
1234 msm_chg_disable_dcd(motg);
1235 msm_chg_enable_primary_det(motg);
1236 delay = MSM_CHG_PRIMARY_DET_TIME;
1237 motg->chg_state = USB_CHG_STATE_DCD_DONE;
1238 } else {
1239 delay = MSM_CHG_DCD_POLL_TIME;
1240 }
1241 break;
1242 case USB_CHG_STATE_DCD_DONE:
1243 vout = msm_chg_check_primary_det(motg);
1244 if (vout) {
1245 msm_chg_enable_secondary_det(motg);
1246 delay = MSM_CHG_SECONDARY_DET_TIME;
1247 motg->chg_state = USB_CHG_STATE_PRIMARY_DONE;
1248 } else {
1249 motg->chg_type = USB_SDP_CHARGER;
1250 motg->chg_state = USB_CHG_STATE_DETECTED;
1251 delay = 0;
1252 }
1253 break;
1254 case USB_CHG_STATE_PRIMARY_DONE:
1255 vout = msm_chg_check_secondary_det(motg);
1256 if (vout)
1257 motg->chg_type = USB_DCP_CHARGER;
1258 else
1259 motg->chg_type = USB_CDP_CHARGER;
1260 motg->chg_state = USB_CHG_STATE_SECONDARY_DONE;
1261 /* fall through */
1262 case USB_CHG_STATE_SECONDARY_DONE:
1263 motg->chg_state = USB_CHG_STATE_DETECTED;
1264 case USB_CHG_STATE_DETECTED:
1265 msm_chg_block_off(motg);
1266 dev_dbg(phy->dev, "charger = %d\n", motg->chg_type);
1267 schedule_work(&motg->sm_work);
1268 return;
1269 default:
1270 return;
1271 }
1272
1273 schedule_delayed_work(&motg->chg_work, delay);
1274}
1275
1276/*
1277 * We support OTG, Peripheral only and Host only configurations. In case
1278 * of OTG, mode switch (host-->peripheral/peripheral-->host) can happen
1279 * via Id pin status or user request (debugfs). Id/BSV interrupts are not
1280 * enabled when switch is controlled by user and default mode is supplied
1281 * by board file, which can be changed by userspace later.
1282 */
1283static void msm_otg_init_sm(struct msm_otg *motg)
1284{
1285 struct msm_otg_platform_data *pdata = motg->pdata;
1286 u32 otgsc = readl(USB_OTGSC);
1287
1288 switch (pdata->mode) {
1289 case USB_DR_MODE_OTG:
1290 if (pdata->otg_control == OTG_PHY_CONTROL) {
1291 if (otgsc & OTGSC_ID)
1292 set_bit(ID, &motg->inputs);
1293 else
1294 clear_bit(ID, &motg->inputs);
1295
1296 if (otgsc & OTGSC_BSV)
1297 set_bit(B_SESS_VLD, &motg->inputs);
1298 else
1299 clear_bit(B_SESS_VLD, &motg->inputs);
1300 } else if (pdata->otg_control == OTG_USER_CONTROL) {
1301 set_bit(ID, &motg->inputs);
1302 clear_bit(B_SESS_VLD, &motg->inputs);
1303 }
1304 break;
1305 case USB_DR_MODE_HOST:
1306 clear_bit(ID, &motg->inputs);
1307 break;
1308 case USB_DR_MODE_PERIPHERAL:
1309 set_bit(ID, &motg->inputs);
1310 if (otgsc & OTGSC_BSV)
1311 set_bit(B_SESS_VLD, &motg->inputs);
1312 else
1313 clear_bit(B_SESS_VLD, &motg->inputs);
1314 break;
1315 default:
1316 break;
1317 }
1318}
1319
1320static void msm_otg_sm_work(struct work_struct *w)
1321{
1322 struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
1323 struct usb_otg *otg = motg->phy.otg;
1324
1325 switch (otg->state) {
1326 case OTG_STATE_UNDEFINED:
1327 dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n");
1328 msm_otg_reset(otg->usb_phy);
1329 msm_otg_init_sm(motg);
1330 otg->state = OTG_STATE_B_IDLE;
1331 /* FALL THROUGH */
1332 case OTG_STATE_B_IDLE:
1333 dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n");
1334 if (!test_bit(ID, &motg->inputs) && otg->host) {
1335 /* disable BSV bit */
1336 writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
1337 msm_otg_start_host(otg->usb_phy, 1);
1338 otg->state = OTG_STATE_A_HOST;
1339 } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
1340 switch (motg->chg_state) {
1341 case USB_CHG_STATE_UNDEFINED:
1342 msm_chg_detect_work(&motg->chg_work.work);
1343 break;
1344 case USB_CHG_STATE_DETECTED:
1345 switch (motg->chg_type) {
1346 case USB_DCP_CHARGER:
1347 msm_otg_notify_charger(motg,
1348 IDEV_CHG_MAX);
1349 break;
1350 case USB_CDP_CHARGER:
1351 msm_otg_notify_charger(motg,
1352 IDEV_CHG_MAX);
1353 msm_otg_start_peripheral(otg->usb_phy,
1354 1);
1355 otg->state
1356 = OTG_STATE_B_PERIPHERAL;
1357 break;
1358 case USB_SDP_CHARGER:
1359 msm_otg_notify_charger(motg, IUNIT);
1360 msm_otg_start_peripheral(otg->usb_phy,
1361 1);
1362 otg->state
1363 = OTG_STATE_B_PERIPHERAL;
1364 break;
1365 default:
1366 break;
1367 }
1368 break;
1369 default:
1370 break;
1371 }
1372 } else {
1373 /*
1374 * If charger detection work is pending, decrement
1375 * the pm usage counter to balance with the one that
1376 * is incremented in charger detection work.
1377 */
1378 if (cancel_delayed_work_sync(&motg->chg_work)) {
1379 pm_runtime_put_sync(otg->usb_phy->dev);
1380 msm_otg_reset(otg->usb_phy);
1381 }
1382 msm_otg_notify_charger(motg, 0);
1383 motg->chg_state = USB_CHG_STATE_UNDEFINED;
1384 motg->chg_type = USB_INVALID_CHARGER;
1385 }
1386
1387 if (otg->state == OTG_STATE_B_IDLE)
1388 pm_runtime_put_sync(otg->usb_phy->dev);
1389 break;
1390 case OTG_STATE_B_PERIPHERAL:
1391 dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
1392 if (!test_bit(B_SESS_VLD, &motg->inputs) ||
1393 !test_bit(ID, &motg->inputs)) {
1394 msm_otg_notify_charger(motg, 0);
1395 msm_otg_start_peripheral(otg->usb_phy, 0);
1396 motg->chg_state = USB_CHG_STATE_UNDEFINED;
1397 motg->chg_type = USB_INVALID_CHARGER;
1398 otg->state = OTG_STATE_B_IDLE;
1399 msm_otg_reset(otg->usb_phy);
1400 schedule_work(w);
1401 }
1402 break;
1403 case OTG_STATE_A_HOST:
1404 dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n");
1405 if (test_bit(ID, &motg->inputs)) {
1406 msm_otg_start_host(otg->usb_phy, 0);
1407 otg->state = OTG_STATE_B_IDLE;
1408 msm_otg_reset(otg->usb_phy);
1409 schedule_work(w);
1410 }
1411 break;
1412 default:
1413 break;
1414 }
1415}
1416
1417static irqreturn_t msm_otg_irq(int irq, void *data)
1418{
1419 struct msm_otg *motg = data;
1420 struct usb_phy *phy = &motg->phy;
1421 u32 otgsc = 0;
1422
1423 if (atomic_read(&motg->in_lpm)) {
1424 disable_irq_nosync(irq);
1425 motg->async_int = 1;
1426 pm_runtime_get(phy->dev);
1427 return IRQ_HANDLED;
1428 }
1429
1430 otgsc = readl(USB_OTGSC);
1431 if (!(otgsc & (OTGSC_IDIS | OTGSC_BSVIS)))
1432 return IRQ_NONE;
1433
1434 if ((otgsc & OTGSC_IDIS) && (otgsc & OTGSC_IDIE)) {
1435 if (otgsc & OTGSC_ID)
1436 set_bit(ID, &motg->inputs);
1437 else
1438 clear_bit(ID, &motg->inputs);
1439 dev_dbg(phy->dev, "ID set/clear\n");
1440 pm_runtime_get_noresume(phy->dev);
1441 } else if ((otgsc & OTGSC_BSVIS) && (otgsc & OTGSC_BSVIE)) {
1442 if (otgsc & OTGSC_BSV)
1443 set_bit(B_SESS_VLD, &motg->inputs);
1444 else
1445 clear_bit(B_SESS_VLD, &motg->inputs);
1446 dev_dbg(phy->dev, "BSV set/clear\n");
1447 pm_runtime_get_noresume(phy->dev);
1448 }
1449
1450 writel(otgsc, USB_OTGSC);
1451 schedule_work(&motg->sm_work);
1452 return IRQ_HANDLED;
1453}
1454
1455static int msm_otg_mode_show(struct seq_file *s, void *unused)
1456{
1457 struct msm_otg *motg = s->private;
1458 struct usb_otg *otg = motg->phy.otg;
1459
1460 switch (otg->state) {
1461 case OTG_STATE_A_HOST:
1462 seq_puts(s, "host\n");
1463 break;
1464 case OTG_STATE_B_PERIPHERAL:
1465 seq_puts(s, "peripheral\n");
1466 break;
1467 default:
1468 seq_puts(s, "none\n");
1469 break;
1470 }
1471
1472 return 0;
1473}
1474
1475static int msm_otg_mode_open(struct inode *inode, struct file *file)
1476{
1477 return single_open(file, msm_otg_mode_show, inode->i_private);
1478}
1479
1480static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
1481 size_t count, loff_t *ppos)
1482{
1483 struct seq_file *s = file->private_data;
1484 struct msm_otg *motg = s->private;
1485 char buf[16];
1486 struct usb_otg *otg = motg->phy.otg;
1487 int status = count;
1488 enum usb_dr_mode req_mode;
1489
1490 memset(buf, 0x00, sizeof(buf));
1491
1492 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) {
1493 status = -EFAULT;
1494 goto out;
1495 }
1496
1497 if (!strncmp(buf, "host", 4)) {
1498 req_mode = USB_DR_MODE_HOST;
1499 } else if (!strncmp(buf, "peripheral", 10)) {
1500 req_mode = USB_DR_MODE_PERIPHERAL;
1501 } else if (!strncmp(buf, "none", 4)) {
1502 req_mode = USB_DR_MODE_UNKNOWN;
1503 } else {
1504 status = -EINVAL;
1505 goto out;
1506 }
1507
1508 switch (req_mode) {
1509 case USB_DR_MODE_UNKNOWN:
1510 switch (otg->state) {
1511 case OTG_STATE_A_HOST:
1512 case OTG_STATE_B_PERIPHERAL:
1513 set_bit(ID, &motg->inputs);
1514 clear_bit(B_SESS_VLD, &motg->inputs);
1515 break;
1516 default:
1517 goto out;
1518 }
1519 break;
1520 case USB_DR_MODE_PERIPHERAL:
1521 switch (otg->state) {
1522 case OTG_STATE_B_IDLE:
1523 case OTG_STATE_A_HOST:
1524 set_bit(ID, &motg->inputs);
1525 set_bit(B_SESS_VLD, &motg->inputs);
1526 break;
1527 default:
1528 goto out;
1529 }
1530 break;
1531 case USB_DR_MODE_HOST:
1532 switch (otg->state) {
1533 case OTG_STATE_B_IDLE:
1534 case OTG_STATE_B_PERIPHERAL:
1535 clear_bit(ID, &motg->inputs);
1536 break;
1537 default:
1538 goto out;
1539 }
1540 break;
1541 default:
1542 goto out;
1543 }
1544
1545 pm_runtime_get_sync(otg->usb_phy->dev);
1546 schedule_work(&motg->sm_work);
1547out:
1548 return status;
1549}
1550
1551static const struct file_operations msm_otg_mode_fops = {
1552 .open = msm_otg_mode_open,
1553 .read = seq_read,
1554 .write = msm_otg_mode_write,
1555 .llseek = seq_lseek,
1556 .release = single_release,
1557};
1558
1559static struct dentry *msm_otg_dbg_root;
1560static struct dentry *msm_otg_dbg_mode;
1561
1562static int msm_otg_debugfs_init(struct msm_otg *motg)
1563{
1564 msm_otg_dbg_root = debugfs_create_dir("msm_otg", NULL);
1565
1566 if (!msm_otg_dbg_root || IS_ERR(msm_otg_dbg_root))
1567 return -ENODEV;
1568
1569 msm_otg_dbg_mode = debugfs_create_file("mode", S_IRUGO | S_IWUSR,
1570 msm_otg_dbg_root, motg, &msm_otg_mode_fops);
1571 if (!msm_otg_dbg_mode) {
1572 debugfs_remove(msm_otg_dbg_root);
1573 msm_otg_dbg_root = NULL;
1574 return -ENODEV;
1575 }
1576
1577 return 0;
1578}
1579
1580static void msm_otg_debugfs_cleanup(void)
1581{
1582 debugfs_remove(msm_otg_dbg_mode);
1583 debugfs_remove(msm_otg_dbg_root);
1584}
1585
1586static const struct of_device_id msm_otg_dt_match[] = {
1587 {
1588 .compatible = "qcom,usb-otg-ci",
1589 .data = (void *) CI_45NM_INTEGRATED_PHY
1590 },
1591 {
1592 .compatible = "qcom,usb-otg-snps",
1593 .data = (void *) SNPS_28NM_INTEGRATED_PHY
1594 },
1595 { }
1596};
1597MODULE_DEVICE_TABLE(of, msm_otg_dt_match);
1598
1599static int msm_otg_vbus_notifier(struct notifier_block *nb, unsigned long event,
1600 void *ptr)
1601{
1602 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, vbus_nb);
1603 struct msm_otg *motg = container_of(usb_phy, struct msm_otg, phy);
1604
1605 if (event)
1606 set_bit(B_SESS_VLD, &motg->inputs);
1607 else
1608 clear_bit(B_SESS_VLD, &motg->inputs);
1609
1610 if (test_bit(B_SESS_VLD, &motg->inputs)) {
1611 /* Switch D+/D- lines to Device connector */
1612 gpiod_set_value_cansleep(motg->switch_gpio, 0);
1613 } else {
1614 /* Switch D+/D- lines to Hub */
1615 gpiod_set_value_cansleep(motg->switch_gpio, 1);
1616 }
1617
1618 schedule_work(&motg->sm_work);
1619
1620 return NOTIFY_DONE;
1621}
1622
1623static int msm_otg_id_notifier(struct notifier_block *nb, unsigned long event,
1624 void *ptr)
1625{
1626 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, id_nb);
1627 struct msm_otg *motg = container_of(usb_phy, struct msm_otg, phy);
1628
1629 if (event)
1630 clear_bit(ID, &motg->inputs);
1631 else
1632 set_bit(ID, &motg->inputs);
1633
1634 schedule_work(&motg->sm_work);
1635
1636 return NOTIFY_DONE;
1637}
1638
1639static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg)
1640{
1641 struct msm_otg_platform_data *pdata;
1642 struct device_node *node = pdev->dev.of_node;
1643 struct property *prop;
1644 int len, ret, words;
1645 u32 val, tmp[3];
1646
1647 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1648 if (!pdata)
1649 return -ENOMEM;
1650
1651 motg->pdata = pdata;
1652
1653 pdata->phy_type = (enum msm_usb_phy_type)of_device_get_match_data(&pdev->dev);
1654 if (!pdata->phy_type)
1655 return 1;
1656
1657 motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
1658 if (IS_ERR(motg->link_rst))
1659 return PTR_ERR(motg->link_rst);
1660
1661 motg->phy_rst = devm_reset_control_get(&pdev->dev, "phy");
1662 if (IS_ERR(motg->phy_rst))
1663 motg->phy_rst = NULL;
1664
1665 pdata->mode = usb_get_dr_mode(&pdev->dev);
1666 if (pdata->mode == USB_DR_MODE_UNKNOWN)
1667 pdata->mode = USB_DR_MODE_OTG;
1668
1669 pdata->otg_control = OTG_PHY_CONTROL;
1670 if (!of_property_read_u32(node, "qcom,otg-control", &val))
1671 if (val == OTG_PMIC_CONTROL)
1672 pdata->otg_control = val;
1673
1674 if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
1675 motg->phy_number = val;
1676
1677 motg->vdd_levels[VDD_LEVEL_NONE] = USB_PHY_SUSP_DIG_VOL;
1678 motg->vdd_levels[VDD_LEVEL_MIN] = USB_PHY_VDD_DIG_VOL_MIN;
1679 motg->vdd_levels[VDD_LEVEL_MAX] = USB_PHY_VDD_DIG_VOL_MAX;
1680
1681 if (of_get_property(node, "qcom,vdd-levels", &len) &&
1682 len == sizeof(tmp)) {
1683 of_property_read_u32_array(node, "qcom,vdd-levels",
1684 tmp, len / sizeof(*tmp));
1685 motg->vdd_levels[VDD_LEVEL_NONE] = tmp[VDD_LEVEL_NONE];
1686 motg->vdd_levels[VDD_LEVEL_MIN] = tmp[VDD_LEVEL_MIN];
1687 motg->vdd_levels[VDD_LEVEL_MAX] = tmp[VDD_LEVEL_MAX];
1688 }
1689
1690 motg->manual_pullup = of_property_read_bool(node, "qcom,manual-pullup");
1691
1692 motg->switch_gpio = devm_gpiod_get_optional(&pdev->dev, "switch",
1693 GPIOD_OUT_LOW);
1694 if (IS_ERR(motg->switch_gpio))
1695 return PTR_ERR(motg->switch_gpio);
1696
1697 prop = of_find_property(node, "qcom,phy-init-sequence", &len);
1698 if (!prop || !len)
1699 return 0;
1700
1701 words = len / sizeof(u32);
1702
1703 if (words >= ULPI_EXT_VENDOR_SPECIFIC) {
1704 dev_warn(&pdev->dev, "Too big PHY init sequence %d\n", words);
1705 return 0;
1706 }
1707
1708 pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
1709 if (!pdata->phy_init_seq)
1710 return 0;
1711
1712 ret = of_property_read_u32_array(node, "qcom,phy-init-sequence",
1713 pdata->phy_init_seq, words);
1714 if (!ret)
1715 pdata->phy_init_sz = words;
1716
1717 return 0;
1718}
1719
1720static int msm_otg_reboot_notify(struct notifier_block *this,
1721 unsigned long code, void *unused)
1722{
1723 struct msm_otg *motg = container_of(this, struct msm_otg, reboot);
1724
1725 /*
1726 * Ensure that D+/D- lines are routed to uB connector, so
1727 * we could load bootloader/kernel at next reboot
1728 */
1729 gpiod_set_value_cansleep(motg->switch_gpio, 0);
1730 return NOTIFY_DONE;
1731}
1732
1733static int msm_otg_probe(struct platform_device *pdev)
1734{
1735 int ret = 0;
1736 struct device_node *np = pdev->dev.of_node;
1737 struct msm_otg_platform_data *pdata;
1738 struct resource *res;
1739 struct msm_otg *motg;
1740 struct usb_phy *phy;
1741 void __iomem *phy_select;
1742
1743 motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
1744 if (!motg)
1745 return -ENOMEM;
1746
1747 motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
1748 GFP_KERNEL);
1749 if (!motg->phy.otg)
1750 return -ENOMEM;
1751
1752 phy = &motg->phy;
1753 phy->dev = &pdev->dev;
1754
1755 motg->clk = devm_clk_get(&pdev->dev, np ? "core" : "usb_hs_clk");
1756 if (IS_ERR(motg->clk)) {
1757 dev_err(&pdev->dev, "failed to get usb_hs_clk\n");
1758 return PTR_ERR(motg->clk);
1759 }
1760
1761 /*
1762 * If USB Core is running its protocol engine based on CORE CLK,
1763 * CORE CLK must be running at >55Mhz for correct HSUSB
1764 * operation and USB core cannot tolerate frequency changes on
1765 * CORE CLK.
1766 */
1767 motg->pclk = devm_clk_get(&pdev->dev, np ? "iface" : "usb_hs_pclk");
1768 if (IS_ERR(motg->pclk)) {
1769 dev_err(&pdev->dev, "failed to get usb_hs_pclk\n");
1770 return PTR_ERR(motg->pclk);
1771 }
1772
1773 /*
1774 * USB core clock is not present on all MSM chips. This
1775 * clock is introduced to remove the dependency on AXI
1776 * bus frequency.
1777 */
1778 motg->core_clk = devm_clk_get(&pdev->dev,
1779 np ? "alt_core" : "usb_hs_core_clk");
1780
1781 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1782 if (!res)
1783 return -EINVAL;
1784 motg->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
1785 if (!motg->regs)
1786 return -ENOMEM;
1787
1788 pdata = dev_get_platdata(&pdev->dev);
1789 if (!pdata) {
1790 if (!np)
1791 return -ENXIO;
1792 ret = msm_otg_read_dt(pdev, motg);
1793 if (ret)
1794 return ret;
1795 }
1796
1797 /*
1798 * NOTE: The PHYs can be multiplexed between the chipidea controller
1799 * and the dwc3 controller, using a single bit. It is important that
1800 * the dwc3 driver does not set this bit in an incompatible way.
1801 */
1802 if (motg->phy_number) {
1803 phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
1804 if (!phy_select)
1805 return -ENOMEM;
1806
1807 /* Enable second PHY with the OTG port */
1808 writel(0x1, phy_select);
1809 }
1810
1811 dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);
1812
1813 motg->irq = platform_get_irq(pdev, 0);
1814 if (motg->irq < 0) {
1815 dev_err(&pdev->dev, "platform_get_irq failed\n");
1816 ret = motg->irq;
1817 return motg->irq;
1818 }
1819
1820 motg->supplies[0].supply = "vddcx";
1821 motg->supplies[1].supply = "v3p3";
1822 motg->supplies[2].supply = "v1p8";
1823
1824 ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(motg->supplies),
1825 motg->supplies);
1826 if (ret)
1827 return ret;
1828
1829 motg->vddcx = motg->supplies[0].consumer;
1830 motg->v3p3 = motg->supplies[1].consumer;
1831 motg->v1p8 = motg->supplies[2].consumer;
1832
1833 clk_set_rate(motg->clk, 60000000);
1834
1835 clk_prepare_enable(motg->clk);
1836 clk_prepare_enable(motg->pclk);
1837
1838 if (!IS_ERR(motg->core_clk))
1839 clk_prepare_enable(motg->core_clk);
1840
1841 ret = msm_hsusb_init_vddcx(motg, 1);
1842 if (ret) {
1843 dev_err(&pdev->dev, "hsusb vddcx configuration failed\n");
1844 goto disable_clks;
1845 }
1846
1847 ret = msm_hsusb_ldo_init(motg, 1);
1848 if (ret) {
1849 dev_err(&pdev->dev, "hsusb vreg configuration failed\n");
1850 goto disable_vddcx;
1851 }
1852 ret = msm_hsusb_ldo_set_mode(motg, 1);
1853 if (ret) {
1854 dev_err(&pdev->dev, "hsusb vreg enable failed\n");
1855 goto disable_ldo;
1856 }
1857
1858 writel(0, USB_USBINTR);
1859 writel(0, USB_OTGSC);
1860
1861 INIT_WORK(&motg->sm_work, msm_otg_sm_work);
1862 INIT_DELAYED_WORK(&motg->chg_work, msm_chg_detect_work);
1863 ret = devm_request_irq(&pdev->dev, motg->irq, msm_otg_irq, IRQF_SHARED,
1864 "msm_otg", motg);
1865 if (ret) {
1866 dev_err(&pdev->dev, "request irq failed\n");
1867 goto disable_ldo;
1868 }
1869
1870 phy->init = msm_phy_init;
1871 phy->notify_disconnect = msm_phy_notify_disconnect;
1872 phy->type = USB_PHY_TYPE_USB2;
1873 phy->vbus_nb.notifier_call = msm_otg_vbus_notifier;
1874 phy->id_nb.notifier_call = msm_otg_id_notifier;
1875
1876 phy->io_ops = &msm_otg_io_ops;
1877
1878 phy->otg->usb_phy = &motg->phy;
1879 phy->otg->set_host = msm_otg_set_host;
1880 phy->otg->set_peripheral = msm_otg_set_peripheral;
1881
1882 msm_usb_reset(phy);
1883
1884 ret = usb_add_phy_dev(&motg->phy);
1885 if (ret) {
1886 dev_err(&pdev->dev, "usb_add_phy failed\n");
1887 goto disable_ldo;
1888 }
1889
1890 ret = extcon_get_state(phy->edev, EXTCON_USB);
1891 if (ret)
1892 set_bit(B_SESS_VLD, &motg->inputs);
1893 else
1894 clear_bit(B_SESS_VLD, &motg->inputs);
1895
1896 ret = extcon_get_state(phy->id_edev, EXTCON_USB_HOST);
1897 if (ret)
1898 clear_bit(ID, &motg->inputs);
1899 else
1900 set_bit(ID, &motg->inputs);
1901
1902 platform_set_drvdata(pdev, motg);
1903 device_init_wakeup(&pdev->dev, 1);
1904
1905 if (motg->pdata->mode == USB_DR_MODE_OTG &&
1906 motg->pdata->otg_control == OTG_USER_CONTROL) {
1907 ret = msm_otg_debugfs_init(motg);
1908 if (ret)
1909 dev_dbg(&pdev->dev, "Can not create mode change file\n");
1910 }
1911
1912 if (test_bit(B_SESS_VLD, &motg->inputs)) {
1913 /* Switch D+/D- lines to Device connector */
1914 gpiod_set_value_cansleep(motg->switch_gpio, 0);
1915 } else {
1916 /* Switch D+/D- lines to Hub */
1917 gpiod_set_value_cansleep(motg->switch_gpio, 1);
1918 }
1919
1920 motg->reboot.notifier_call = msm_otg_reboot_notify;
1921 register_reboot_notifier(&motg->reboot);
1922
1923 pm_runtime_set_active(&pdev->dev);
1924 pm_runtime_enable(&pdev->dev);
1925
1926 return 0;
1927
1928disable_ldo:
1929 msm_hsusb_ldo_init(motg, 0);
1930disable_vddcx:
1931 msm_hsusb_init_vddcx(motg, 0);
1932disable_clks:
1933 clk_disable_unprepare(motg->pclk);
1934 clk_disable_unprepare(motg->clk);
1935 if (!IS_ERR(motg->core_clk))
1936 clk_disable_unprepare(motg->core_clk);
1937
1938 return ret;
1939}
1940
1941static int msm_otg_remove(struct platform_device *pdev)
1942{
1943 struct msm_otg *motg = platform_get_drvdata(pdev);
1944 struct usb_phy *phy = &motg->phy;
1945 int cnt = 0;
1946
1947 if (phy->otg->host || phy->otg->gadget)
1948 return -EBUSY;
1949
1950 unregister_reboot_notifier(&motg->reboot);
1951
1952 /*
1953 * Ensure that D+/D- lines are routed to uB connector, so
1954 * we could load bootloader/kernel at next reboot
1955 */
1956 gpiod_set_value_cansleep(motg->switch_gpio, 0);
1957
1958 msm_otg_debugfs_cleanup();
1959 cancel_delayed_work_sync(&motg->chg_work);
1960 cancel_work_sync(&motg->sm_work);
1961
1962 pm_runtime_resume(&pdev->dev);
1963
1964 device_init_wakeup(&pdev->dev, 0);
1965 pm_runtime_disable(&pdev->dev);
1966
1967 usb_remove_phy(phy);
1968 disable_irq(motg->irq);
1969
1970 /*
1971 * Put PHY in low power mode.
1972 */
1973 ulpi_read(phy, 0x14);
1974 ulpi_write(phy, 0x08, 0x09);
1975
1976 writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC);
1977 while (cnt < PHY_SUSPEND_TIMEOUT_USEC) {
1978 if (readl(USB_PORTSC) & PORTSC_PHCD)
1979 break;
1980 udelay(1);
1981 cnt++;
1982 }
1983 if (cnt >= PHY_SUSPEND_TIMEOUT_USEC)
1984 dev_err(phy->dev, "Unable to suspend PHY\n");
1985
1986 clk_disable_unprepare(motg->pclk);
1987 clk_disable_unprepare(motg->clk);
1988 if (!IS_ERR(motg->core_clk))
1989 clk_disable_unprepare(motg->core_clk);
1990 msm_hsusb_ldo_init(motg, 0);
1991
1992 pm_runtime_set_suspended(&pdev->dev);
1993
1994 return 0;
1995}
1996
1997#ifdef CONFIG_PM
1998static int msm_otg_runtime_idle(struct device *dev)
1999{
2000 struct msm_otg *motg = dev_get_drvdata(dev);
2001 struct usb_otg *otg = motg->phy.otg;
2002
2003 dev_dbg(dev, "OTG runtime idle\n");
2004
2005 /*
2006 * It is observed some times that a spurious interrupt
2007 * comes when PHY is put into LPM immediately after PHY reset.
2008 * This 1 sec delay also prevents entering into LPM immediately
2009 * after asynchronous interrupt.
2010 */
2011 if (otg->state != OTG_STATE_UNDEFINED)
2012 pm_schedule_suspend(dev, 1000);
2013
2014 return -EAGAIN;
2015}
2016
2017static int msm_otg_runtime_suspend(struct device *dev)
2018{
2019 struct msm_otg *motg = dev_get_drvdata(dev);
2020
2021 dev_dbg(dev, "OTG runtime suspend\n");
2022 return msm_otg_suspend(motg);
2023}
2024
2025static int msm_otg_runtime_resume(struct device *dev)
2026{
2027 struct msm_otg *motg = dev_get_drvdata(dev);
2028
2029 dev_dbg(dev, "OTG runtime resume\n");
2030 return msm_otg_resume(motg);
2031}
2032#endif
2033
2034#ifdef CONFIG_PM_SLEEP
2035static int msm_otg_pm_suspend(struct device *dev)
2036{
2037 struct msm_otg *motg = dev_get_drvdata(dev);
2038
2039 dev_dbg(dev, "OTG PM suspend\n");
2040 return msm_otg_suspend(motg);
2041}
2042
2043static int msm_otg_pm_resume(struct device *dev)
2044{
2045 struct msm_otg *motg = dev_get_drvdata(dev);
2046 int ret;
2047
2048 dev_dbg(dev, "OTG PM resume\n");
2049
2050 ret = msm_otg_resume(motg);
2051 if (ret)
2052 return ret;
2053
2054 /*
2055 * Runtime PM Documentation recommends bringing the
2056 * device to full powered state upon resume.
2057 */
2058 pm_runtime_disable(dev);
2059 pm_runtime_set_active(dev);
2060 pm_runtime_enable(dev);
2061
2062 return 0;
2063}
2064#endif
2065
2066static const struct dev_pm_ops msm_otg_dev_pm_ops = {
2067 SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume)
2068 SET_RUNTIME_PM_OPS(msm_otg_runtime_suspend, msm_otg_runtime_resume,
2069 msm_otg_runtime_idle)
2070};
2071
2072static struct platform_driver msm_otg_driver = {
2073 .probe = msm_otg_probe,
2074 .remove = msm_otg_remove,
2075 .driver = {
2076 .name = DRIVER_NAME,
2077 .pm = &msm_otg_dev_pm_ops,
2078 .of_match_table = msm_otg_dt_match,
2079 },
2080};
2081
2082module_platform_driver(msm_otg_driver);
2083
2084MODULE_LICENSE("GPL v2");
2085MODULE_DESCRIPTION("MSM USB transceiver driver");
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 0e315694adc9..554b72282276 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 * Author: Chao Xie <chao.xie@marvell.com> 4 * Author: Chao Xie <chao.xie@marvell.com>
4 * Neil Zhang <zhangwm@marvell.com> 5 * Neil Zhang <zhangwm@marvell.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */ 6 */
11 7
12#include <linux/module.h> 8#include <linux/module.h>
@@ -87,9 +83,10 @@ static void mv_otg_run_state_machine(struct mv_otg *mvotg,
87 queue_delayed_work(mvotg->qwork, &mvotg->work, delay); 83 queue_delayed_work(mvotg->qwork, &mvotg->work, delay);
88} 84}
89 85
90static void mv_otg_timer_await_bcon(unsigned long data) 86static void mv_otg_timer_await_bcon(struct timer_list *t)
91{ 87{
92 struct mv_otg *mvotg = (struct mv_otg *) data; 88 struct mv_otg *mvotg = from_timer(mvotg, t,
89 otg_ctrl.timer[A_WAIT_BCON_TIMER]);
93 90
94 mvotg->otg_ctrl.a_wait_bcon_timeout = 1; 91 mvotg->otg_ctrl.a_wait_bcon_timeout = 1;
95 92
@@ -117,8 +114,7 @@ static int mv_otg_cancel_timer(struct mv_otg *mvotg, unsigned int id)
117} 114}
118 115
119static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id, 116static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id,
120 unsigned long interval, 117 unsigned long interval)
121 void (*callback) (unsigned long))
122{ 118{
123 struct timer_list *timer; 119 struct timer_list *timer;
124 120
@@ -131,9 +127,6 @@ static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id,
131 return -EBUSY; 127 return -EBUSY;
132 } 128 }
133 129
134 init_timer(timer);
135 timer->data = (unsigned long) mvotg;
136 timer->function = callback;
137 timer->expires = jiffies + interval; 130 timer->expires = jiffies + interval;
138 add_timer(timer); 131 add_timer(timer);
139 132
@@ -459,8 +452,7 @@ run:
459 if (old_state != OTG_STATE_A_HOST) 452 if (old_state != OTG_STATE_A_HOST)
460 mv_otg_start_host(mvotg, 1); 453 mv_otg_start_host(mvotg, 1);
461 mv_otg_set_timer(mvotg, A_WAIT_BCON_TIMER, 454 mv_otg_set_timer(mvotg, A_WAIT_BCON_TIMER,
462 T_A_WAIT_BCON, 455 T_A_WAIT_BCON);
463 mv_otg_timer_await_bcon);
464 /* 456 /*
465 * Now, we directly enter A_HOST. So set b_conn = 1 457 * Now, we directly enter A_HOST. So set b_conn = 1
466 * here. In fact, it need host driver to notify us. 458 * here. In fact, it need host driver to notify us.
@@ -722,7 +714,8 @@ static int mv_otg_probe(struct platform_device *pdev)
722 otg->set_vbus = mv_otg_set_vbus; 714 otg->set_vbus = mv_otg_set_vbus;
723 715
724 for (i = 0; i < OTG_TIMER_NUM; i++) 716 for (i = 0; i < OTG_TIMER_NUM; i++)
725 init_timer(&mvotg->otg_ctrl.timer[i]); 717 timer_setup(&mvotg->otg_ctrl.timer[i],
718 mv_otg_timer_await_bcon, 0);
726 719
727 r = platform_get_resource_byname(mvotg->pdev, 720 r = platform_get_resource_byname(mvotg->pdev,
728 IORESOURCE_MEM, "phyregs"); 721 IORESOURCE_MEM, "phyregs");
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 551da6eb0ba8..96701a1229ad 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */ 4 */
9 5
10#ifndef __MV_USB_OTG_CONTROLLER__ 6#ifndef __MV_USB_OTG_CONTROLLER__
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 0e2f1a36d315..da031c45395a 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -1,14 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2012-2014 Freescale Semiconductor, Inc. 3 * Copyright 2012-2014 Freescale Semiconductor, Inc.
3 * Copyright (C) 2012 Marek Vasut <marex@denx.de> 4 * Copyright (C) 2012 Marek Vasut <marex@denx.de>
4 * on behalf of DENX Software Engineering GmbH 5 * on behalf of DENX Software Engineering GmbH
5 *
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
9 *
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
12 */ 6 */
13 7
14#include <linux/module.h> 8#include <linux/module.h>
@@ -67,11 +61,26 @@
67#define ANADIG_ANA_MISC0_SET 0x154 61#define ANADIG_ANA_MISC0_SET 0x154
68#define ANADIG_ANA_MISC0_CLR 0x158 62#define ANADIG_ANA_MISC0_CLR 0x158
69 63
64#define ANADIG_USB1_CHRG_DETECT_SET 0x1b4
65#define ANADIG_USB1_CHRG_DETECT_CLR 0x1b8
66#define ANADIG_USB1_CHRG_DETECT_EN_B BIT(20)
67#define ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B BIT(19)
68#define ANADIG_USB1_CHRG_DETECT_CHK_CONTACT BIT(18)
69
70#define ANADIG_USB1_VBUS_DET_STAT 0x1c0 70#define ANADIG_USB1_VBUS_DET_STAT 0x1c0
71#define ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID BIT(3)
72
73#define ANADIG_USB1_CHRG_DET_STAT 0x1d0
74#define ANADIG_USB1_CHRG_DET_STAT_DM_STATE BIT(2)
75#define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED BIT(1)
76#define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
77
71#define ANADIG_USB2_VBUS_DET_STAT 0x220 78#define ANADIG_USB2_VBUS_DET_STAT 0x220
72 79
73#define ANADIG_USB1_LOOPBACK_SET 0x1e4 80#define ANADIG_USB1_LOOPBACK_SET 0x1e4
74#define ANADIG_USB1_LOOPBACK_CLR 0x1e8 81#define ANADIG_USB1_LOOPBACK_CLR 0x1e8
82#define ANADIG_USB1_LOOPBACK_UTMI_TESTSTART BIT(0)
83
75#define ANADIG_USB2_LOOPBACK_SET 0x244 84#define ANADIG_USB2_LOOPBACK_SET 0x244
76#define ANADIG_USB2_LOOPBACK_CLR 0x248 85#define ANADIG_USB2_LOOPBACK_CLR 0x248
77 86
@@ -479,6 +488,144 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
479 return 0; 488 return 0;
480} 489}
481 490
491#define MXS_USB_CHARGER_DATA_CONTACT_TIMEOUT 100
492static int mxs_charger_data_contact_detect(struct mxs_phy *x)
493{
494 struct regmap *regmap = x->regmap_anatop;
495 int i, stable_contact_count = 0;
496 u32 val;
497
498 /* Check if vbus is valid */
499 regmap_read(regmap, ANADIG_USB1_VBUS_DET_STAT, &val);
500 if (!(val & ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)) {
501 dev_err(x->phy.dev, "vbus is not valid\n");
502 return -EINVAL;
503 }
504
505 /* Enable charger detector */
506 regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_CLR,
507 ANADIG_USB1_CHRG_DETECT_EN_B);
508 /*
509 * - Do not check whether a charger is connected to the USB port
510 * - Check whether the USB plug has been in contact with each other
511 */
512 regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_SET,
513 ANADIG_USB1_CHRG_DETECT_CHK_CONTACT |
514 ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
515
516 /* Check if plug is connected */
517 for (i = 0; i < MXS_USB_CHARGER_DATA_CONTACT_TIMEOUT; i++) {
518 regmap_read(regmap, ANADIG_USB1_CHRG_DET_STAT, &val);
519 if (val & ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT) {
520 stable_contact_count++;
521 if (stable_contact_count > 5)
522 /* Data pin makes contact */
523 break;
524 else
525 usleep_range(5000, 10000);
526 } else {
527 stable_contact_count = 0;
528 usleep_range(5000, 6000);
529 }
530 }
531
532 if (i == MXS_USB_CHARGER_DATA_CONTACT_TIMEOUT) {
533 dev_err(x->phy.dev,
534 "Data pin can't make good contact.\n");
535 /* Disable charger detector */
536 regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_SET,
537 ANADIG_USB1_CHRG_DETECT_EN_B |
538 ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
539 return -ENXIO;
540 }
541
542 return 0;
543}
544
545static enum usb_charger_type mxs_charger_primary_detection(struct mxs_phy *x)
546{
547 struct regmap *regmap = x->regmap_anatop;
548 enum usb_charger_type chgr_type = UNKNOWN_TYPE;
549 u32 val;
550
551 /*
552 * - Do check whether a charger is connected to the USB port
553 * - Do not Check whether the USB plug has been in contact with
554 * each other
555 */
556 regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_CLR,
557 ANADIG_USB1_CHRG_DETECT_CHK_CONTACT |
558 ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
559
560 msleep(100);
561
562 /* Check if it is a charger */
563 regmap_read(regmap, ANADIG_USB1_CHRG_DET_STAT, &val);
564 if (!(val & ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED)) {
565 chgr_type = SDP_TYPE;
566 dev_dbg(x->phy.dev, "It is a stardard downstream port\n");
567 }
568
569 /* Disable charger detector */
570 regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_SET,
571 ANADIG_USB1_CHRG_DETECT_EN_B |
572 ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
573
574 return chgr_type;
575}
576
577/*
578 * It must be called after DP is pulled up, which is used to
579 * differentiate DCP and CDP.
580 */
581enum usb_charger_type mxs_charger_secondary_detection(struct mxs_phy *x)
582{
583 struct regmap *regmap = x->regmap_anatop;
584 int val;
585
586 msleep(80);
587
588 regmap_read(regmap, ANADIG_USB1_CHRG_DET_STAT, &val);
589 if (val & ANADIG_USB1_CHRG_DET_STAT_DM_STATE) {
590 dev_dbg(x->phy.dev, "It is a dedicate charging port\n");
591 return DCP_TYPE;
592 } else {
593 dev_dbg(x->phy.dev, "It is a charging downstream port\n");
594 return CDP_TYPE;
595 }
596}
597
598static enum usb_charger_type mxs_phy_charger_detect(struct usb_phy *phy)
599{
600 struct mxs_phy *mxs_phy = to_mxs_phy(phy);
601 struct regmap *regmap = mxs_phy->regmap_anatop;
602 void __iomem *base = phy->io_priv;
603 enum usb_charger_type chgr_type = UNKNOWN_TYPE;
604
605 if (mxs_charger_data_contact_detect(mxs_phy))
606 return chgr_type;
607
608 chgr_type = mxs_charger_primary_detection(mxs_phy);
609
610 if (chgr_type != SDP_TYPE) {
611 /* Pull up DP via test */
612 writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
613 base + HW_USBPHY_DEBUG_CLR);
614 regmap_write(regmap, ANADIG_USB1_LOOPBACK_SET,
615 ANADIG_USB1_LOOPBACK_UTMI_TESTSTART);
616
617 chgr_type = mxs_charger_secondary_detection(mxs_phy);
618
619 /* Stop the test */
620 regmap_write(regmap, ANADIG_USB1_LOOPBACK_CLR,
621 ANADIG_USB1_LOOPBACK_UTMI_TESTSTART);
622 writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
623 base + HW_USBPHY_DEBUG_SET);
624 }
625
626 return chgr_type;
627}
628
482static int mxs_phy_probe(struct platform_device *pdev) 629static int mxs_phy_probe(struct platform_device *pdev)
483{ 630{
484 struct resource *res; 631 struct resource *res;
@@ -567,6 +714,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
567 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; 714 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect;
568 mxs_phy->phy.type = USB_PHY_TYPE_USB2; 715 mxs_phy->phy.type = USB_PHY_TYPE_USB2;
569 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; 716 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup;
717 mxs_phy->phy.charger_detect = mxs_phy_charger_detect;
570 718
571 mxs_phy->clk = clk; 719 mxs_phy->clk = clk;
572 mxs_phy->data = of_id->data; 720 mxs_phy->data = of_id->data;
diff --git a/drivers/usb/phy/phy-omap-otg.c b/drivers/usb/phy/phy-omap-otg.c
index 800d1d90753d..ee0863c6553e 100644
--- a/drivers/usb/phy/phy-omap-otg.c
+++ b/drivers/usb/phy/phy-omap-otg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * OMAP OTG controller driver 3 * OMAP OTG controller driver
3 * 4 *
@@ -6,15 +7,6 @@
6 * Copyright (C) 2005-2006 Nokia Corporation 7 * Copyright (C) 2005-2006 Nokia Corporation
7 * Copyright (C) 2004 Texas Instruments 8 * Copyright (C) 2004 Texas Instruments
8 * Copyright (C) 2004 David Brownell 9 * Copyright (C) 2004 David Brownell
9 *
10 * This file is subject to the terms and conditions of the GNU General
11 * Public License. See the file "COPYING" in the main directory of this
12 * archive for more details.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */ 10 */
19 11
20#include <linux/io.h> 12#include <linux/io.h>
diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c b/drivers/usb/phy/phy-qcom-8x16-usb.c
deleted file mode 100644
index 679afeaaa9a8..000000000000
--- a/drivers/usb/phy/phy-qcom-8x16-usb.c
+++ /dev/null
@@ -1,366 +0,0 @@
1/*
2 * Copyright (c) 2015, Linaro Limited
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/clk.h>
15#include <linux/delay.h>
16#include <linux/device.h>
17#include <linux/err.h>
18#include <linux/extcon.h>
19#include <linux/gpio/consumer.h>
20#include <linux/io.h>
21#include <linux/module.h>
22#include <linux/of.h>
23#include <linux/platform_device.h>
24#include <linux/reboot.h>
25#include <linux/regulator/consumer.h>
26#include <linux/reset.h>
27#include <linux/slab.h>
28#include <linux/usb.h>
29#include <linux/usb/ulpi.h>
30
31#define HSPHY_AHBBURST 0x0090
32#define HSPHY_AHBMODE 0x0098
33#define HSPHY_GENCONFIG 0x009c
34#define HSPHY_GENCONFIG_2 0x00a0
35
36#define HSPHY_USBCMD 0x0140
37#define HSPHY_ULPI_VIEWPORT 0x0170
38#define HSPHY_CTRL 0x0240
39
40#define HSPHY_TXFIFO_IDLE_FORCE_DIS BIT(4)
41#define HSPHY_SESS_VLD_CTRL_EN BIT(7)
42#define HSPHY_POR_ASSERT BIT(0)
43#define HSPHY_RETEN BIT(1)
44
45#define HSPHY_SESS_VLD_CTRL BIT(25)
46
47#define ULPI_PWR_CLK_MNG_REG 0x88
48#define ULPI_PWR_OTG_COMP_DISABLE BIT(0)
49
50#define ULPI_MISC_A 0x96
51#define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1)
52#define ULPI_MISC_A_VBUSVLDEXT BIT(0)
53
54#define HSPHY_3P3_MIN 3050000 /* uV */
55#define HSPHY_3P3_MAX 3300000 /* uV */
56
57#define HSPHY_1P8_MIN 1800000 /* uV */
58#define HSPHY_1P8_MAX 1800000 /* uV */
59
60#define HSPHY_VDD_MIN 5
61#define HSPHY_VDD_MAX 7
62
63struct phy_8x16 {
64 struct usb_phy phy;
65 void __iomem *regs;
66 struct clk *core_clk;
67 struct clk *iface_clk;
68 struct regulator_bulk_data regulator[3];
69
70 struct reset_control *phy_reset;
71
72 struct gpio_desc *switch_gpio;
73 struct notifier_block reboot_notify;
74};
75
76static int phy_8x16_notify_connect(struct usb_phy *phy,
77 enum usb_device_speed speed)
78{
79 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy);
80 u32 val;
81
82 val = ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT;
83 usb_phy_io_write(&qphy->phy, val, ULPI_SET(ULPI_MISC_A));
84
85 val = readl(qphy->regs + HSPHY_USBCMD);
86 val |= HSPHY_SESS_VLD_CTRL;
87 writel(val, qphy->regs + HSPHY_USBCMD);
88
89 return 0;
90}
91
92static int phy_8x16_notify_disconnect(struct usb_phy *phy,
93 enum usb_device_speed speed)
94{
95 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy);
96 u32 val;
97
98 val = ULPI_MISC_A_VBUSVLDEXT | ULPI_MISC_A_VBUSVLDEXTSEL;
99 usb_phy_io_write(&qphy->phy, val, ULPI_CLR(ULPI_MISC_A));
100
101 val = readl(qphy->regs + HSPHY_USBCMD);
102 val &= ~HSPHY_SESS_VLD_CTRL;
103 writel(val, qphy->regs + HSPHY_USBCMD);
104
105 return 0;
106}
107
108static int phy_8x16_vbus_on(struct phy_8x16 *qphy)
109{
110 phy_8x16_notify_connect(&qphy->phy, USB_SPEED_UNKNOWN);
111
112 /* Switch D+/D- lines to Device connector */
113 gpiod_set_value_cansleep(qphy->switch_gpio, 0);
114
115 return 0;
116}
117
118static int phy_8x16_vbus_off(struct phy_8x16 *qphy)
119{
120 phy_8x16_notify_disconnect(&qphy->phy, USB_SPEED_UNKNOWN);
121
122 /* Switch D+/D- lines to USB HUB */
123 gpiod_set_value_cansleep(qphy->switch_gpio, 1);
124
125 return 0;
126}
127
128static int phy_8x16_vbus_notify(struct notifier_block *nb, unsigned long event,
129 void *ptr)
130{
131 struct usb_phy *usb_phy = container_of(nb, struct usb_phy, vbus_nb);
132 struct phy_8x16 *qphy = container_of(usb_phy, struct phy_8x16, phy);
133
134 if (event)
135 phy_8x16_vbus_on(qphy);
136 else
137 phy_8x16_vbus_off(qphy);
138
139 return NOTIFY_DONE;
140}
141
142static int phy_8x16_init(struct usb_phy *phy)
143{
144 struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy);
145 u32 val, init[] = {0x44, 0x6B, 0x24, 0x13};
146 u32 addr = ULPI_EXT_VENDOR_SPECIFIC;
147 int idx, state;
148
149 for (idx = 0; idx < ARRAY_SIZE(init); idx++)
150 usb_phy_io_write(phy, init[idx], addr + idx);
151
152 reset_control_reset(qphy->phy_reset);
153
154 /* Assert USB HSPHY_POR */
155 val = readl(qphy->regs + HSPHY_CTRL);
156 val |= HSPHY_POR_ASSERT;
157 writel(val, qphy->regs + HSPHY_CTRL);
158
159 /*
160 * wait for minimum 10 microseconds as suggested in HPG.
161 * Use a slightly larger value since the exact value didn't
162 * work 100% of the time.
163 */
164 usleep_range(12, 15);
165
166 /* Deassert USB HSPHY_POR */
167 val = readl(qphy->regs + HSPHY_CTRL);
168 val &= ~HSPHY_POR_ASSERT;
169 writel(val, qphy->regs + HSPHY_CTRL);
170
171 usleep_range(10, 15);
172
173 writel(0x00, qphy->regs + HSPHY_AHBBURST);
174 writel(0x08, qphy->regs + HSPHY_AHBMODE);
175
176 /* workaround for rx buffer collision issue */
177 val = readl(qphy->regs + HSPHY_GENCONFIG);
178 val &= ~HSPHY_TXFIFO_IDLE_FORCE_DIS;
179 writel(val, qphy->regs + HSPHY_GENCONFIG);
180
181 val = readl(qphy->regs + HSPHY_GENCONFIG_2);
182 val |= HSPHY_SESS_VLD_CTRL_EN;
183 writel(val, qphy->regs + HSPHY_GENCONFIG_2);
184
185 val = ULPI_PWR_OTG_COMP_DISABLE;
186 usb_phy_io_write(phy, val, ULPI_SET(ULPI_PWR_CLK_MNG_REG));
187
188 state = extcon_get_state(qphy->phy.edev, EXTCON_USB);
189 if (state)
190 phy_8x16_vbus_on(qphy);
191 else
192 phy_8x16_vbus_off(qphy);
193
194 val = usb_phy_io_read(&qphy->phy, ULPI_FUNC_CTRL);
195 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
196 val |= ULPI_FUNC_CTRL_OPMODE_NORMAL;
197 usb_phy_io_write(&qphy->phy, val, ULPI_FUNC_CTRL);
198
199 return 0;
200}
201
202static void phy_8x16_shutdown(struct usb_phy *phy)
203{
204 u32 val;
205
206 /* Put the controller in non-driving mode */
207 val = usb_phy_io_read(phy, ULPI_FUNC_CTRL);
208 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
209 val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
210 usb_phy_io_write(phy, val, ULPI_FUNC_CTRL);
211}
212
213static int phy_8x16_read_devicetree(struct phy_8x16 *qphy)
214{
215 struct device *dev = qphy->phy.dev;
216 int ret;
217
218 qphy->core_clk = devm_clk_get(dev, "core");
219 if (IS_ERR(qphy->core_clk))
220 return PTR_ERR(qphy->core_clk);
221
222 qphy->iface_clk = devm_clk_get(dev, "iface");
223 if (IS_ERR(qphy->iface_clk))
224 return PTR_ERR(qphy->iface_clk);
225
226 qphy->regulator[0].supply = "v3p3";
227 qphy->regulator[1].supply = "v1p8";
228 qphy->regulator[2].supply = "vddcx";
229
230 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(qphy->regulator),
231 qphy->regulator);
232 if (ret)
233 return ret;
234
235 qphy->phy_reset = devm_reset_control_get(dev, "phy");
236 if (IS_ERR(qphy->phy_reset))
237 return PTR_ERR(qphy->phy_reset);
238
239 qphy->switch_gpio = devm_gpiod_get_optional(dev, "switch",
240 GPIOD_OUT_LOW);
241 return PTR_ERR_OR_ZERO(qphy->switch_gpio);
242}
243
244static int phy_8x16_reboot_notify(struct notifier_block *this,
245 unsigned long code, void *unused)
246{
247 struct phy_8x16 *qphy;
248
249 qphy = container_of(this, struct phy_8x16, reboot_notify);
250
251 /*
252 * Ensure that D+/D- lines are routed to uB connector, so
253 * we could load bootloader/kernel at next reboot_notify
254 */
255 gpiod_set_value_cansleep(qphy->switch_gpio, 0);
256 return NOTIFY_DONE;
257}
258
259static int phy_8x16_probe(struct platform_device *pdev)
260{
261 struct phy_8x16 *qphy;
262 struct resource *res;
263 struct usb_phy *phy;
264 int ret;
265
266 qphy = devm_kzalloc(&pdev->dev, sizeof(*qphy), GFP_KERNEL);
267 if (!qphy)
268 return -ENOMEM;
269
270 platform_set_drvdata(pdev, qphy);
271
272 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
273 qphy->regs = devm_ioremap_resource(&pdev->dev, res);
274 if (IS_ERR(qphy->regs))
275 return PTR_ERR(qphy->regs);
276
277 phy = &qphy->phy;
278 phy->dev = &pdev->dev;
279 phy->label = dev_name(&pdev->dev);
280 phy->init = phy_8x16_init;
281 phy->shutdown = phy_8x16_shutdown;
282 phy->notify_connect = phy_8x16_notify_connect;
283 phy->notify_disconnect = phy_8x16_notify_disconnect;
284 phy->io_priv = qphy->regs + HSPHY_ULPI_VIEWPORT;
285 phy->io_ops = &ulpi_viewport_access_ops;
286 phy->type = USB_PHY_TYPE_USB2;
287 phy->vbus_nb.notifier_call = phy_8x16_vbus_notify;
288 phy->id_nb.notifier_call = NULL;
289
290 ret = phy_8x16_read_devicetree(qphy);
291 if (ret < 0)
292 return ret;
293
294 ret = clk_set_rate(qphy->core_clk, INT_MAX);
295 if (ret < 0)
296 dev_dbg(phy->dev, "Can't boost core clock\n");
297
298 ret = clk_prepare_enable(qphy->core_clk);
299 if (ret < 0)
300 return ret;
301
302 ret = clk_prepare_enable(qphy->iface_clk);
303 if (ret < 0)
304 goto off_core;
305
306 ret = regulator_bulk_enable(ARRAY_SIZE(qphy->regulator),
307 qphy->regulator);
308 if (WARN_ON(ret))
309 goto off_clks;
310
311 ret = usb_add_phy_dev(&qphy->phy);
312 if (ret)
313 goto off_power;
314
315 qphy->reboot_notify.notifier_call = phy_8x16_reboot_notify;
316 register_reboot_notifier(&qphy->reboot_notify);
317
318 return 0;
319
320off_power:
321 regulator_bulk_disable(ARRAY_SIZE(qphy->regulator), qphy->regulator);
322off_clks:
323 clk_disable_unprepare(qphy->iface_clk);
324off_core:
325 clk_disable_unprepare(qphy->core_clk);
326 return ret;
327}
328
329static int phy_8x16_remove(struct platform_device *pdev)
330{
331 struct phy_8x16 *qphy = platform_get_drvdata(pdev);
332
333 unregister_reboot_notifier(&qphy->reboot_notify);
334
335 /*
336 * Ensure that D+/D- lines are routed to uB connector, so
337 * we could load bootloader/kernel at next reboot_notify
338 */
339 gpiod_set_value_cansleep(qphy->switch_gpio, 0);
340
341 usb_remove_phy(&qphy->phy);
342
343 clk_disable_unprepare(qphy->iface_clk);
344 clk_disable_unprepare(qphy->core_clk);
345 regulator_bulk_disable(ARRAY_SIZE(qphy->regulator), qphy->regulator);
346 return 0;
347}
348
349static const struct of_device_id phy_8x16_dt_match[] = {
350 { .compatible = "qcom,usb-8x16-phy" },
351 { }
352};
353MODULE_DEVICE_TABLE(of, phy_8x16_dt_match);
354
355static struct platform_driver phy_8x16_driver = {
356 .probe = phy_8x16_probe,
357 .remove = phy_8x16_remove,
358 .driver = {
359 .name = "phy-qcom-8x16-usb",
360 .of_match_table = phy_8x16_dt_match,
361 },
362};
363module_platform_driver(phy_8x16_driver);
364
365MODULE_LICENSE("GPL v2");
366MODULE_DESCRIPTION("Qualcomm APQ8016/MSM8916 chipsets USB transceiver driver");
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index 8babd318c0ed..b3ce42edb373 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Tahvo USB transceiver driver 3 * Tahvo USB transceiver driver
3 * 4 *
@@ -9,21 +10,12 @@
9 * 10 *
10 * Original driver written by Juha Yrjölä, Tony Lindgren and Timo Teräs. 11 * Original driver written by Juha Yrjölä, Tony Lindgren and Timo Teräs.
11 * Modified for Retu/Tahvo MFD by Aaro Koskinen. 12 * Modified for Retu/Tahvo MFD by Aaro Koskinen.
12 *
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file "COPYING" in the main directory of this
15 * archive for more details.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 */ 13 */
22 14
23#include <linux/io.h> 15#include <linux/io.h>
24#include <linux/clk.h> 16#include <linux/clk.h>
25#include <linux/usb.h> 17#include <linux/usb.h>
26#include <linux/extcon.h> 18#include <linux/extcon-provider.h>
27#include <linux/kernel.h> 19#include <linux/kernel.h>
28#include <linux/module.h> 20#include <linux/module.h>
29#include <linux/usb/otg.h> 21#include <linux/usb/otg.h>
@@ -368,7 +360,8 @@ static int tahvo_usb_probe(struct platform_device *pdev)
368 tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable); 360 tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable);
369 if (IS_ERR(tu->extcon)) { 361 if (IS_ERR(tu->extcon)) {
370 dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); 362 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
371 return -ENOMEM; 363 ret = PTR_ERR(tu->extcon);
364 goto err_disable_clk;
372 } 365 }
373 366
374 ret = devm_extcon_dev_register(&pdev->dev, tu->extcon); 367 ret = devm_extcon_dev_register(&pdev->dev, tu->extcon);
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index ccc2bf5274b4..f668bfb708d3 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2010 Google, Inc. 3 * Copyright (C) 2010 Google, Inc.
3 * Copyright (C) 2013 NVIDIA Corporation 4 * Copyright (C) 2013 NVIDIA Corporation
@@ -6,16 +7,6 @@
6 * Erik Gilling <konkers@google.com> 7 * Erik Gilling <konkers@google.com>
7 * Benoit Goby <benoit@android.com> 8 * Benoit Goby <benoit@android.com>
8 * Venu Byravarasu <vbyravarasu@nvidia.com> 9 * Venu Byravarasu <vbyravarasu@nvidia.com>
9 *
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */ 10 */
20 11
21#include <linux/resource.h> 12#include <linux/resource.h>
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
index b5dc077ed7d3..e78ed52339e6 100644
--- a/drivers/usb/phy/phy-twl6030-usb.c
+++ b/drivers/usb/phy/phy-twl6030-usb.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * twl6030_usb - TWL6030 USB transceiver, talking to OMAP OTG driver. 3 * twl6030_usb - TWL6030 USB transceiver, talking to OMAP OTG driver.
3 * 4 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com 5 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * 6 *
10 * Author: Hema HK <hemahk@ti.com> 7 * Author: Hema HK <hemahk@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */ 8 */
22 9
23#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/usb/phy/phy-ulpi-viewport.c b/drivers/usb/phy/phy-ulpi-viewport.c
index 18bb8264b5a0..7a14e0e3b635 100644
--- a/drivers/usb/phy/phy-ulpi-viewport.c
+++ b/drivers/usb/phy/phy-ulpi-viewport.c
@@ -1,15 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2011 Google, Inc. 3 * Copyright (C) 2011 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */ 4 */
14 5
15#include <linux/export.h> 6#include <linux/export.h>
diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
index f48a7a21e3c2..a43c49369a60 100644
--- a/drivers/usb/phy/phy-ulpi.c
+++ b/drivers/usb/phy/phy-ulpi.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Generic ULPI USB transceiver support 3 * Generic ULPI USB transceiver support
3 * 4 *
@@ -7,20 +8,6 @@
7 * 8 *
8 * Sascha Hauer <s.hauer@pengutronix.de> 9 * Sascha Hauer <s.hauer@pengutronix.de>
9 * Freescale Semiconductors 10 * Freescale Semiconductors
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 11 */
25 12
26#include <linux/kernel.h> 13#include <linux/kernel.h>
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 89f4ac4cd93e..f97cb47577fc 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * phy.c -- USB phy handling 3 * phy.c -- USB phy handling
3 * 4 *
4 * Copyright (C) 2004-2013 Texas Instruments 5 * Copyright (C) 2004-2013 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11#include <linux/kernel.h> 7#include <linux/kernel.h>
12#include <linux/export.h> 8#include <linux/export.h>
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index f0ce304c5aaf..56079bb6759a 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/err.h> 8#include <linux/err.h>
18#include <linux/gpio.h> 9#include <linux/gpio.h>
@@ -486,6 +477,10 @@ static const struct of_device_id usbhs_of_match[] = {
486 .data = (void *)USBHS_TYPE_RCAR_GEN3, 477 .data = (void *)USBHS_TYPE_RCAR_GEN3,
487 }, 478 },
488 { 479 {
480 .compatible = "renesas,usbhs-r8a77995",
481 .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL,
482 },
483 {
489 .compatible = "renesas,rcar-gen2-usbhs", 484 .compatible = "renesas,rcar-gen2-usbhs",
490 .data = (void *)USBHS_TYPE_RCAR_GEN2, 485 .data = (void *)USBHS_TYPE_RCAR_GEN2,
491 }, 486 },
@@ -501,7 +496,6 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
501{ 496{
502 struct renesas_usbhs_platform_info *info; 497 struct renesas_usbhs_platform_info *info;
503 struct renesas_usbhs_driver_param *dparam; 498 struct renesas_usbhs_driver_param *dparam;
504 const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
505 u32 tmp; 499 u32 tmp;
506 int gpio; 500 int gpio;
507 501
@@ -510,7 +504,7 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
510 return NULL; 504 return NULL;
511 505
512 dparam = &info->driver_param; 506 dparam = &info->driver_param;
513 dparam->type = of_id ? (uintptr_t)of_id->data : 0; 507 dparam->type = (uintptr_t)of_device_get_match_data(dev);
514 if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp)) 508 if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
515 dparam->buswait_bwait = tmp; 509 dparam->buswait_bwait = tmp;
516 gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0, 510 gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
@@ -519,15 +513,19 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
519 dparam->enable_gpio = gpio; 513 dparam->enable_gpio = gpio;
520 514
521 if (dparam->type == USBHS_TYPE_RCAR_GEN2 || 515 if (dparam->type == USBHS_TYPE_RCAR_GEN2 ||
522 dparam->type == USBHS_TYPE_RCAR_GEN3) 516 dparam->type == USBHS_TYPE_RCAR_GEN3 ||
517 dparam->type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) {
523 dparam->has_usb_dmac = 1; 518 dparam->has_usb_dmac = 1;
519 dparam->pipe_configs = usbhsc_new_pipe;
520 dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
521 }
524 522
525 return info; 523 return info;
526} 524}
527 525
528static int usbhs_probe(struct platform_device *pdev) 526static int usbhs_probe(struct platform_device *pdev)
529{ 527{
530 struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev); 528 struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
531 struct renesas_usbhs_driver_callback *dfunc; 529 struct renesas_usbhs_driver_callback *dfunc;
532 struct usbhs_priv *priv; 530 struct usbhs_priv *priv;
533 struct resource *res, *irq_res; 531 struct resource *res, *irq_res;
@@ -577,17 +575,12 @@ static int usbhs_probe(struct platform_device *pdev)
577 switch (priv->dparam.type) { 575 switch (priv->dparam.type) {
578 case USBHS_TYPE_RCAR_GEN2: 576 case USBHS_TYPE_RCAR_GEN2:
579 priv->pfunc = usbhs_rcar2_ops; 577 priv->pfunc = usbhs_rcar2_ops;
580 if (!priv->dparam.pipe_configs) {
581 priv->dparam.pipe_configs = usbhsc_new_pipe;
582 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
583 }
584 break; 578 break;
585 case USBHS_TYPE_RCAR_GEN3: 579 case USBHS_TYPE_RCAR_GEN3:
586 priv->pfunc = usbhs_rcar3_ops; 580 priv->pfunc = usbhs_rcar3_ops;
587 if (!priv->dparam.pipe_configs) { 581 break;
588 priv->dparam.pipe_configs = usbhsc_new_pipe; 582 case USBHS_TYPE_RCAR_GEN3_WITH_PLL:
589 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 583 priv->pfunc = usbhs_rcar3_with_pll_ops;
590 }
591 break; 584 break;
592 default: 585 default:
593 if (!info->platform_callback.get_id) { 586 if (!info->platform_callback.get_id) {
@@ -710,7 +703,7 @@ probe_end_pipe_exit:
710static int usbhs_remove(struct platform_device *pdev) 703static int usbhs_remove(struct platform_device *pdev)
711{ 704{
712 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 705 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
713 struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev); 706 struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
714 struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback; 707 struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback;
715 708
716 dev_dbg(&pdev->dev, "usb remove\n"); 709 dev_dbg(&pdev->dev, "usb remove\n");
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 8c5fc12ad778..64797784a6df 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#ifndef RENESAS_USB_DRIVER_H 8#ifndef RENESAS_USB_DRIVER_H
18#define RENESAS_USB_DRIVER_H 9#define RENESAS_USB_DRIVER_H
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 50285b01da92..2d24ef3076ef 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/delay.h> 8#include <linux/delay.h>
18#include <linux/io.h> 9#include <linux/io.h>
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h
index 8b98507d7abc..88d1816bcda2 100644
--- a/drivers/usb/renesas_usbhs/fifo.h
+++ b/drivers/usb/renesas_usbhs/fifo.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#ifndef RENESAS_USB_FIFO_H 8#ifndef RENESAS_USB_FIFO_H
18#define RENESAS_USB_FIFO_H 9#define RENESAS_USB_FIFO_H
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 28965ef4f824..7475c4f64724 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/interrupt.h> 8#include <linux/interrupt.h>
18 9
diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h
index 1ef5bf604070..a4a61d6b82a1 100644
--- a/drivers/usb/renesas_usbhs/mod.h
+++ b/drivers/usb/renesas_usbhs/mod.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#ifndef RENESAS_USB_MOD_H 8#ifndef RENESAS_USB_MOD_H
18#define RENESAS_USB_MOD_H 9#define RENESAS_USB_MOD_H
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index c068b673420b..34ee9ebe12a3 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/delay.h> 8#include <linux/delay.h>
18#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index e256351cb72d..4e59c649db81 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/io.h> 8#include <linux/io.h>
18#include <linux/list.h> 9#include <linux/list.h>
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index d811f0550c04..093cd8e87335 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#include <linux/delay.h> 8#include <linux/delay.h>
18#include <linux/slab.h> 9#include <linux/slab.h>
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 95185fdb29b1..d3d002244891 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver 3 * Renesas USB driver
3 * 4 *
4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */ 7 */
17#ifndef RENESAS_USB_PIPE_H 8#ifndef RENESAS_USB_PIPE_H
18#define RENESAS_USB_PIPE_H 9#define RENESAS_USB_PIPE_H
diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c
index 277160bc6f25..85a0e0933917 100644
--- a/drivers/usb/renesas_usbhs/rcar2.c
+++ b/drivers/usb/renesas_usbhs/rcar2.c
@@ -1,13 +1,8 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB driver R-Car Gen. 2 initialization and power control 3 * Renesas USB driver R-Car Gen. 2 initialization and power control
3 * 4 *
4 * Copyright (C) 2014 Ulrich Hecht 5 * Copyright (C) 2014 Ulrich Hecht
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 */ 6 */
12 7
13#include <linux/gpio.h> 8#include <linux/gpio.h>
diff --git a/drivers/usb/renesas_usbhs/rcar2.h b/drivers/usb/renesas_usbhs/rcar2.h
index f07f10d9b3b2..45e3526cedeb 100644
--- a/drivers/usb/renesas_usbhs/rcar2.h
+++ b/drivers/usb/renesas_usbhs/rcar2.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "common.h" 2#include "common.h"
2 3
3extern const struct renesas_usbhs_platform_callback 4extern const struct renesas_usbhs_platform_callback
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
index 02b67abfc2a1..c929d296c77b 100644
--- a/drivers/usb/renesas_usbhs/rcar3.c
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Renesas USB driver R-Car Gen. 3 initialization and power control 3 * Renesas USB driver R-Car Gen. 3 initialization and power control
3 * 4 *
4 * Copyright (C) 2016 Renesas Electronics Corporation 5 * Copyright (C) 2016 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */ 6 */
11 7
12#include <linux/delay.h> 8#include <linux/delay.h>
@@ -15,24 +11,39 @@
15#include "rcar3.h" 11#include "rcar3.h"
16 12
17#define LPSTS 0x102 13#define LPSTS 0x102
14#define UGCTRL 0x180 /* 32-bit register */
18#define UGCTRL2 0x184 /* 32-bit register */ 15#define UGCTRL2 0x184 /* 32-bit register */
16#define UGSTS 0x188 /* 32-bit register */
19 17
20/* Low Power Status register (LPSTS) */ 18/* Low Power Status register (LPSTS) */
21#define LPSTS_SUSPM 0x4000 19#define LPSTS_SUSPM 0x4000
22 20
21/* R-Car D3 only: USB General control register (UGCTRL) */
22#define UGCTRL_PLLRESET 0x00000001
23#define UGCTRL_CONNECT 0x00000004
24
23/* 25/*
24 * USB General control register 2 (UGCTRL2) 26 * USB General control register 2 (UGCTRL2)
25 * Remarks: bit[31:11] and bit[9:6] should be 0 27 * Remarks: bit[31:11] and bit[9:6] should be 0
26 */ 28 */
27#define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */ 29#define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */
30#define UGCTRL2_USB0SEL_HSUSB 0x00000020
28#define UGCTRL2_USB0SEL_OTG 0x00000030 31#define UGCTRL2_USB0SEL_OTG 0x00000030
29#define UGCTRL2_VBUSSEL 0x00000400 32#define UGCTRL2_VBUSSEL 0x00000400
30 33
34/* R-Car D3 only: USB General status register (UGSTS) */
35#define UGSTS_LOCK 0x00000100
36
31static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data) 37static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data)
32{ 38{
33 iowrite32(data, priv->base + reg); 39 iowrite32(data, priv->base + reg);
34} 40}
35 41
42static u32 usbhs_read32(struct usbhs_priv *priv, u32 reg)
43{
44 return ioread32(priv->base + reg);
45}
46
36static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, 47static int usbhs_rcar3_power_ctrl(struct platform_device *pdev,
37 void __iomem *base, int enable) 48 void __iomem *base, int enable)
38{ 49{
@@ -52,6 +63,34 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev,
52 return 0; 63 return 0;
53} 64}
54 65
66/* R-Car D3 needs to release UGCTRL.PLLRESET */
67static int usbhs_rcar3_power_and_pll_ctrl(struct platform_device *pdev,
68 void __iomem *base, int enable)
69{
70 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
71 u32 val;
72 int timeout = 1000;
73
74 if (enable) {
75 usbhs_write32(priv, UGCTRL, 0); /* release PLLRESET */
76 usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 |
77 UGCTRL2_USB0SEL_HSUSB);
78
79 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
80 do {
81 val = usbhs_read32(priv, UGSTS);
82 udelay(1);
83 } while (!(val & UGSTS_LOCK) && timeout--);
84 usbhs_write32(priv, UGCTRL, UGCTRL_CONNECT);
85 } else {
86 usbhs_write32(priv, UGCTRL, 0);
87 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0);
88 usbhs_write32(priv, UGCTRL, UGCTRL_PLLRESET);
89 }
90
91 return 0;
92}
93
55static int usbhs_rcar3_get_id(struct platform_device *pdev) 94static int usbhs_rcar3_get_id(struct platform_device *pdev)
56{ 95{
57 return USBHS_GADGET; 96 return USBHS_GADGET;
@@ -61,3 +100,8 @@ const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
61 .power_ctrl = usbhs_rcar3_power_ctrl, 100 .power_ctrl = usbhs_rcar3_power_ctrl,
62 .get_id = usbhs_rcar3_get_id, 101 .get_id = usbhs_rcar3_get_id,
63}; 102};
103
104const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = {
105 .power_ctrl = usbhs_rcar3_power_and_pll_ctrl,
106 .get_id = usbhs_rcar3_get_id,
107};
diff --git a/drivers/usb/renesas_usbhs/rcar3.h b/drivers/usb/renesas_usbhs/rcar3.h
index 5f850b23ff18..49e535a31771 100644
--- a/drivers/usb/renesas_usbhs/rcar3.h
+++ b/drivers/usb/renesas_usbhs/rcar3.h
@@ -1,3 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0
1#include "common.h" 2#include "common.h"
2 3
3extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops; 4extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops;
5extern const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops;
diff --git a/drivers/usb/serial/Makefile-keyspan_pda_fw b/drivers/usb/serial/Makefile-keyspan_pda_fw
index c20baf728011..503b472d85f2 100644
--- a/drivers/usb/serial/Makefile-keyspan_pda_fw
+++ b/drivers/usb/serial/Makefile-keyspan_pda_fw
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1 2
2# some rules to handle the quirks of the 'as31' assembler, like 3# some rules to handle the quirks of the 'as31' assembler, like
3# insisting upon fixed suffixes for the input and output files, 4# insisting upon fixed suffixes for the input and output files,
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 569c2200ba42..84d52953dd0a 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * AIRcable USB Bluetooth Dongle Driver. 3 * AIRcable USB Bluetooth Dongle Driver.
3 * 4 *
4 * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com> 5 * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
5 * Copyright (C) 2006 Manuel Francisco Naranjo (naranjo.manuel@gmail.com) 6 * Copyright (C) 2006 Manuel Francisco Naranjo (naranjo.manuel@gmail.com)
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License version 2 as published by the
9 * Free Software Foundation.
10 *
11 * The device works as an standard CDC device, it has 2 interfaces, the first 8 * The device works as an standard CDC device, it has 2 interfaces, the first
12 * one is for firmware access and the second is the serial one. 9 * one is for firmware access and the second is the serial one.
13 * The protocol is very simply, there are two possibilities reading or writing. 10 * The protocol is very simply, there are two possibilities reading or writing.
@@ -161,4 +158,4 @@ module_usb_serial_driver(serial_drivers, id_table);
161 158
162MODULE_AUTHOR(DRIVER_AUTHOR); 159MODULE_AUTHOR(DRIVER_AUTHOR);
163MODULE_DESCRIPTION(DRIVER_DESC); 160MODULE_DESCRIPTION(DRIVER_DESC);
164MODULE_LICENSE("GPL"); 161MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 0adbd38b4eea..3c544782f60b 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2009 by Bart Hartgers (bart.hartgers+ark3116@gmail.com) 3 * Copyright (C) 2009 by Bart Hartgers (bart.hartgers+ark3116@gmail.com)
3 * Original version: 4 * Original version:
@@ -15,11 +16,6 @@
15 * into the old ark3116.c driver and suddenly realized the ark3116 is 16 * into the old ark3116.c driver and suddenly realized the ark3116 is
16 * a 16450 with a USB interface glued to it. See comments at the 17 * a 16450 with a USB interface glued to it. See comments at the
17 * bottom of this file. 18 * bottom of this file.
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2 of the License, or (at your
22 * option) any later version.
23 */ 19 */
24 20
25#include <linux/kernel.h> 21#include <linux/kernel.h>
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 15bc71853db5..c1235d5b9fba 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Belkin USB Serial Adapter Driver 3 * Belkin USB Serial Adapter Driver
3 * 4 *
@@ -9,11 +10,6 @@
9 * and associated source files. Please see the usb/serial files for 10 * and associated source files. Please see the usb/serial files for
10 * individual credits and copyrights. 11 * individual credits and copyrights.
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * See Documentation/usb/usb-serial.txt for more information on using this 13 * See Documentation/usb/usb-serial.txt for more information on using this
18 * driver 14 * driver
19 * 15 *
diff --git a/drivers/usb/serial/belkin_sa.h b/drivers/usb/serial/belkin_sa.h
index c74b58ab56f9..51bc06287603 100644
--- a/drivers/usb/serial/belkin_sa.h
+++ b/drivers/usb/serial/belkin_sa.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Definitions for Belkin USB Serial Adapter Driver 3 * Definitions for Belkin USB Serial Adapter Driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * and associated source files. Please see the usb/serial files for 9 * and associated source files. Please see the usb/serial files for
9 * individual credits and copyrights. 10 * individual credits and copyrights.
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * See Documentation/usb/usb-serial.txt for more information on using this 12 * See Documentation/usb/usb-serial.txt for more information on using this
17 * driver 13 * driver
18 * 14 *
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 8936a83c96cd..9e265eb92611 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial Converter Bus specific functions 3 * USB Serial Converter Bus specific functions
3 * 4 *
4 * Copyright (C) 2002 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 2002 Greg Kroah-Hartman (greg@kroah.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 351745aec0e1..bdd7a5ad3bf1 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk> 3 * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk>
3 * Copyright 2007, Werner Cornelius <werner@cornelius-consult.de> 4 * Copyright 2007, Werner Cornelius <werner@cornelius-consult.de>
@@ -9,10 +10,6 @@
9 * serial port, an IEEE-1284 parallel printer port or a memory-like 10 * serial port, an IEEE-1284 parallel printer port or a memory-like
10 * interface. In all cases the CH341 supports an I2C interface as well. 11 * interface. In all cases the CH341 supports an I2C interface as well.
11 * This driver only supports the asynchronous serial interface. 12 * This driver only supports the asynchronous serial interface.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License version
15 * 2 as published by the Free Software Foundation.
16 */ 13 */
17 14
18#include <linux/kernel.h> 15#include <linux/kernel.h>
@@ -644,4 +641,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
644 641
645module_usb_serial_driver(serial_drivers, id_table); 642module_usb_serial_driver(serial_drivers, id_table);
646 643
647MODULE_LICENSE("GPL"); 644MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 43a862a90a77..17940589c647 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial Console driver 3 * USB Serial Console driver
3 * 4 *
4 * Copyright (C) 2001 - 2002 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 2001 - 2002 Greg Kroah-Hartman (greg@kroah.com)
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * Thanks to Randy Dunlap for the original version of this code. 7 * Thanks to Randy Dunlap for the original version of this code.
11 * 8 *
12 */ 9 */
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 412f812522ee..7c6273bf5beb 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver 3 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
3 * 4 *
4 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk) 5 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * Support to set flow control line levels using TIOCMGET and TIOCMSET 7 * Support to set flow control line levels using TIOCMGET and TIOCMSET
11 * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow 8 * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow
12 * control thanks to Munir Nassar nassarmu@real-time.com 9 * control thanks to Munir Nassar nassarmu@real-time.com
@@ -1529,4 +1526,4 @@ static void cp210x_release(struct usb_serial *serial)
1529module_usb_serial_driver(serial_drivers, id_table); 1526module_usb_serial_driver(serial_drivers, id_table);
1530 1527
1531MODULE_DESCRIPTION(DRIVER_DESC); 1528MODULE_DESCRIPTION(DRIVER_DESC);
1532MODULE_LICENSE("GPL"); 1529MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 47fbd9f0c0c7..dc67a2eb98d7 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver 3 * REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver
3 * 4 *
@@ -10,11 +11,6 @@
10 * and associated source files. Please see the usb/serial files for 11 * and associated source files. Please see the usb/serial files for
11 * individual credits and copyrights. 12 * individual credits and copyrights.
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * Thanks to Greg Kroah-Hartman (greg@kroah.com) for his help and 14 * Thanks to Greg Kroah-Hartman (greg@kroah.com) for his help and
19 * patience. 15 * patience.
20 * 16 *
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 90110de715e0..e0035c023120 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Cypress M8 driver 3 * USB Cypress M8 driver
3 * 4 *
@@ -6,11 +7,6 @@
6 * Copyright (C) 2003,2004 7 * Copyright (C) 2003,2004
7 * Neil Whelchel (koyama@firstlight.net) 8 * Neil Whelchel (koyama@firstlight.net)
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * See Documentation/usb/usb-serial.txt for more information on using this 10 * See Documentation/usb/usb-serial.txt for more information on using this
15 * driver 11 * driver
16 * 12 *
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 2ce39af32cfa..b0526786fb02 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2* Digi AccelePort USB-4 and USB-2 Serial Converters 3* Digi AccelePort USB-4 and USB-2 Serial Converters
3* 4*
4* Copyright 2000 by Digi International 5* Copyright 2000 by Digi International
5* 6*
6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2 of the License, or
9* (at your option) any later version.
10*
11* Shamelessly based on Brian Warner's keyspan_pda.c and Greg Kroah-Hartman's 7* Shamelessly based on Brian Warner's keyspan_pda.c and Greg Kroah-Hartman's
12* usb-serial driver. 8* usb-serial driver.
13* 9*
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 90e603d5f660..d680bec62547 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Empeg empeg-car player driver 3 * USB Empeg empeg-car player driver
3 * 4 *
@@ -7,10 +8,6 @@
7 * Copyright (C) 1999 - 2001 8 * Copyright (C) 1999 - 2001
8 * Greg Kroah-Hartman (greg@kroah.com) 9 * Greg Kroah-Hartman (greg@kroah.com)
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License, as published by
12 * the Free Software Foundation, version 2.
13 *
14 * See Documentation/usb/usb-serial.txt for more information on using this 11 * See Documentation/usb/usb-serial.txt for more information on using this
15 * driver 12 * driver
16 */ 13 */
@@ -126,4 +123,4 @@ module_usb_serial_driver(serial_drivers, id_table);
126 123
127MODULE_AUTHOR(DRIVER_AUTHOR); 124MODULE_AUTHOR(DRIVER_AUTHOR);
128MODULE_DESCRIPTION(DRIVER_DESC); 125MODULE_DESCRIPTION(DRIVER_DESC);
129MODULE_LICENSE("GPL"); 126MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 972f5a5fe577..96036f87b1de 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Fintek F81232 USB to serial adaptor driver 3 * Fintek F81232 USB to serial adaptor driver
3 * 4 *
4 * Copyright (C) 2012 Greg Kroah-Hartman (gregkh@linuxfoundation.org) 5 * Copyright (C) 2012 Greg Kroah-Hartman (gregkh@linuxfoundation.org)
5 * Copyright (C) 2012 Linux Foundation 6 * Copyright (C) 2012 Linux Foundation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 3d616a2a9f96..e4573b4c8935 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * F81532/F81534 USB to Serial Ports Bridge 3 * F81532/F81534 USB to Serial Ports Bridge
3 * 4 *
4 * F81532 => 2 Serial Ports 5 * F81532 => 2 Serial Ports
5 * F81534 => 4 Serial Ports 6 * F81534 => 4 Serial Ports
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Copyright (C) 2016 Feature Integration Technology Inc., (Fintek) 8 * Copyright (C) 2016 Feature Integration Technology Inc., (Fintek)
13 * Copyright (C) 2016 Tom Tsai (Tom_Tsai@fintek.com.tw) 9 * Copyright (C) 2016 Tom Tsai (Tom_Tsai@fintek.com.tw)
14 * Copyright (C) 2016 Peter Hong (Peter_Hong@fintek.com.tw) 10 * Copyright (C) 2016 Peter Hong (Peter_Hong@fintek.com.tw)
@@ -39,9 +35,11 @@
39#define F81534_UART_OFFSET 0x10 35#define F81534_UART_OFFSET 0x10
40#define F81534_DIVISOR_LSB_REG (0x00 + F81534_UART_BASE_ADDRESS) 36#define F81534_DIVISOR_LSB_REG (0x00 + F81534_UART_BASE_ADDRESS)
41#define F81534_DIVISOR_MSB_REG (0x01 + F81534_UART_BASE_ADDRESS) 37#define F81534_DIVISOR_MSB_REG (0x01 + F81534_UART_BASE_ADDRESS)
38#define F81534_INTERRUPT_ENABLE_REG (0x01 + F81534_UART_BASE_ADDRESS)
42#define F81534_FIFO_CONTROL_REG (0x02 + F81534_UART_BASE_ADDRESS) 39#define F81534_FIFO_CONTROL_REG (0x02 + F81534_UART_BASE_ADDRESS)
43#define F81534_LINE_CONTROL_REG (0x03 + F81534_UART_BASE_ADDRESS) 40#define F81534_LINE_CONTROL_REG (0x03 + F81534_UART_BASE_ADDRESS)
44#define F81534_MODEM_CONTROL_REG (0x04 + F81534_UART_BASE_ADDRESS) 41#define F81534_MODEM_CONTROL_REG (0x04 + F81534_UART_BASE_ADDRESS)
42#define F81534_LINE_STATUS_REG (0x05 + F81534_UART_BASE_ADDRESS)
45#define F81534_MODEM_STATUS_REG (0x06 + F81534_UART_BASE_ADDRESS) 43#define F81534_MODEM_STATUS_REG (0x06 + F81534_UART_BASE_ADDRESS)
46#define F81534_CONFIG1_REG (0x09 + F81534_UART_BASE_ADDRESS) 44#define F81534_CONFIG1_REG (0x09 + F81534_UART_BASE_ADDRESS)
47 45
@@ -126,9 +124,13 @@ struct f81534_serial_private {
126 124
127struct f81534_port_private { 125struct f81534_port_private {
128 struct mutex mcr_mutex; 126 struct mutex mcr_mutex;
127 struct mutex lcr_mutex;
128 struct work_struct lsr_work;
129 struct usb_serial_port *port;
129 unsigned long tx_empty; 130 unsigned long tx_empty;
130 spinlock_t msr_lock; 131 spinlock_t msr_lock;
131 u8 shadow_mcr; 132 u8 shadow_mcr;
133 u8 shadow_lcr;
132 u8 shadow_msr; 134 u8 shadow_msr;
133 u8 phy_num; 135 u8 phy_num;
134}; 136};
@@ -461,6 +463,7 @@ static u32 f81534_calc_baud_divisor(u32 baudrate, u32 clockrate)
461static int f81534_set_port_config(struct usb_serial_port *port, u32 baudrate, 463static int f81534_set_port_config(struct usb_serial_port *port, u32 baudrate,
462 u8 lcr) 464 u8 lcr)
463{ 465{
466 struct f81534_port_private *port_priv = usb_get_serial_port_data(port);
464 u32 divisor; 467 u32 divisor;
465 int status; 468 int status;
466 u8 value; 469 u8 value;
@@ -489,35 +492,65 @@ static int f81534_set_port_config(struct usb_serial_port *port, u32 baudrate,
489 } 492 }
490 493
491 divisor = f81534_calc_baud_divisor(baudrate, F81534_MAX_BAUDRATE); 494 divisor = f81534_calc_baud_divisor(baudrate, F81534_MAX_BAUDRATE);
495
496 mutex_lock(&port_priv->lcr_mutex);
497
492 value = UART_LCR_DLAB; 498 value = UART_LCR_DLAB;
493 status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG, 499 status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG,
494 value); 500 value);
495 if (status) { 501 if (status) {
496 dev_err(&port->dev, "%s: set LCR failed\n", __func__); 502 dev_err(&port->dev, "%s: set LCR failed\n", __func__);
497 return status; 503 goto out_unlock;
498 } 504 }
499 505
500 value = divisor & 0xff; 506 value = divisor & 0xff;
501 status = f81534_set_port_register(port, F81534_DIVISOR_LSB_REG, value); 507 status = f81534_set_port_register(port, F81534_DIVISOR_LSB_REG, value);
502 if (status) { 508 if (status) {
503 dev_err(&port->dev, "%s: set DLAB LSB failed\n", __func__); 509 dev_err(&port->dev, "%s: set DLAB LSB failed\n", __func__);
504 return status; 510 goto out_unlock;
505 } 511 }
506 512
507 value = (divisor >> 8) & 0xff; 513 value = (divisor >> 8) & 0xff;
508 status = f81534_set_port_register(port, F81534_DIVISOR_MSB_REG, value); 514 status = f81534_set_port_register(port, F81534_DIVISOR_MSB_REG, value);
509 if (status) { 515 if (status) {
510 dev_err(&port->dev, "%s: set DLAB MSB failed\n", __func__); 516 dev_err(&port->dev, "%s: set DLAB MSB failed\n", __func__);
511 return status; 517 goto out_unlock;
512 } 518 }
513 519
514 status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG, lcr); 520 value = lcr | (port_priv->shadow_lcr & UART_LCR_SBC);
521 status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG,
522 value);
515 if (status) { 523 if (status) {
516 dev_err(&port->dev, "%s: set LCR failed\n", __func__); 524 dev_err(&port->dev, "%s: set LCR failed\n", __func__);
517 return status; 525 goto out_unlock;
518 } 526 }
519 527
520 return 0; 528 port_priv->shadow_lcr = value;
529out_unlock:
530 mutex_unlock(&port_priv->lcr_mutex);
531
532 return status;
533}
534
535static void f81534_break_ctl(struct tty_struct *tty, int break_state)
536{
537 struct usb_serial_port *port = tty->driver_data;
538 struct f81534_port_private *port_priv = usb_get_serial_port_data(port);
539 int status;
540
541 mutex_lock(&port_priv->lcr_mutex);
542
543 if (break_state)
544 port_priv->shadow_lcr |= UART_LCR_SBC;
545 else
546 port_priv->shadow_lcr &= ~UART_LCR_SBC;
547
548 status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG,
549 port_priv->shadow_lcr);
550 if (status)
551 dev_err(&port->dev, "set break failed: %d\n", status);
552
553 mutex_unlock(&port_priv->lcr_mutex);
521} 554}
522 555
523static int f81534_update_mctrl(struct usb_serial_port *port, unsigned int set, 556static int f81534_update_mctrl(struct usb_serial_port *port, unsigned int set,
@@ -1015,6 +1048,8 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
1015 tty_insert_flip_char(&port->port, 0, 1048 tty_insert_flip_char(&port->port, 0,
1016 TTY_OVERRUN); 1049 TTY_OVERRUN);
1017 } 1050 }
1051
1052 schedule_work(&port_priv->lsr_work);
1018 } 1053 }
1019 1054
1020 if (port->port.console && port->sysrq) { 1055 if (port->port.console && port->sysrq) {
@@ -1162,6 +1197,21 @@ static int f81534_attach(struct usb_serial *serial)
1162 return 0; 1197 return 0;
1163} 1198}
1164 1199
1200static void f81534_lsr_worker(struct work_struct *work)
1201{
1202 struct f81534_port_private *port_priv;
1203 struct usb_serial_port *port;
1204 int status;
1205 u8 tmp;
1206
1207 port_priv = container_of(work, struct f81534_port_private, lsr_work);
1208 port = port_priv->port;
1209
1210 status = f81534_get_port_register(port, F81534_LINE_STATUS_REG, &tmp);
1211 if (status)
1212 dev_warn(&port->dev, "read LSR failed: %d\n", status);
1213}
1214
1165static int f81534_port_probe(struct usb_serial_port *port) 1215static int f81534_port_probe(struct usb_serial_port *port)
1166{ 1216{
1167 struct f81534_port_private *port_priv; 1217 struct f81534_port_private *port_priv;
@@ -1173,6 +1223,8 @@ static int f81534_port_probe(struct usb_serial_port *port)
1173 1223
1174 spin_lock_init(&port_priv->msr_lock); 1224 spin_lock_init(&port_priv->msr_lock);
1175 mutex_init(&port_priv->mcr_mutex); 1225 mutex_init(&port_priv->mcr_mutex);
1226 mutex_init(&port_priv->lcr_mutex);
1227 INIT_WORK(&port_priv->lsr_work, f81534_lsr_worker);
1176 1228
1177 /* Assign logic-to-phy mapping */ 1229 /* Assign logic-to-phy mapping */
1178 ret = f81534_logic_to_phy_port(port->serial, port); 1230 ret = f81534_logic_to_phy_port(port->serial, port);
@@ -1180,10 +1232,30 @@ static int f81534_port_probe(struct usb_serial_port *port)
1180 return ret; 1232 return ret;
1181 1233
1182 port_priv->phy_num = ret; 1234 port_priv->phy_num = ret;
1235 port_priv->port = port;
1183 usb_set_serial_port_data(port, port_priv); 1236 usb_set_serial_port_data(port, port_priv);
1184 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, 1237 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__,
1185 port->port_number, port_priv->phy_num); 1238 port->port_number, port_priv->phy_num);
1186 1239
1240 /*
1241 * The F81532/534 will hang-up when enable LSR interrupt in IER and
1242 * occur data overrun. So we'll disable the LSR interrupt in probe()
1243 * and submit the LSR worker to clear LSR state when reported LSR error
1244 * bit with bulk-in data in f81534_process_per_serial_block().
1245 */
1246 ret = f81534_set_port_register(port, F81534_INTERRUPT_ENABLE_REG,
1247 UART_IER_RDI | UART_IER_THRI | UART_IER_MSI);
1248 if (ret)
1249 return ret;
1250
1251 return 0;
1252}
1253
1254static int f81534_port_remove(struct usb_serial_port *port)
1255{
1256 struct f81534_port_private *port_priv = usb_get_serial_port_data(port);
1257
1258 flush_work(&port_priv->lsr_work);
1187 return 0; 1259 return 0;
1188} 1260}
1189 1261
@@ -1317,6 +1389,8 @@ static struct usb_serial_driver f81534_device = {
1317 .calc_num_ports = f81534_calc_num_ports, 1389 .calc_num_ports = f81534_calc_num_ports,
1318 .attach = f81534_attach, 1390 .attach = f81534_attach,
1319 .port_probe = f81534_port_probe, 1391 .port_probe = f81534_port_probe,
1392 .port_remove = f81534_port_remove,
1393 .break_ctl = f81534_break_ctl,
1320 .dtr_rts = f81534_dtr_rts, 1394 .dtr_rts = f81534_dtr_rts,
1321 .process_read_urb = f81534_process_read_urb, 1395 .process_read_urb = f81534_process_read_urb,
1322 .ioctl = f81534_ioctl, 1396 .ioctl = f81534_ioctl,
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 49d1b2d4606d..1aba9105b369 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB FTDI SIO driver 3 * USB FTDI SIO driver
3 * 4 *
@@ -9,11 +10,6 @@
9 * Copyright (C) 2002 10 * Copyright (C) 2002
10 * Kuba Ober (kuba@mareimbrium.org) 11 * Kuba Ober (kuba@mareimbrium.org)
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * See Documentation/usb/usb-serial.txt for more information on using this 13 * See Documentation/usb/usb-serial.txt for more information on using this
18 * driver 14 * driver
19 * 15 *
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index b2f2e87aed94..633550ec3025 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Garmin GPS driver 3 * Garmin GPS driver
3 * 4 *
@@ -7,20 +8,6 @@
7 * http://sourceforge.net/projects/garmin-gps/ 8 * http://sourceforge.net/projects/garmin-gps/
8 * 9 *
9 * This driver has been derived from v2.1 of the visor driver. 10 * This driver has been derived from v2.1 of the visor driver.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
24 */ 11 */
25 12
26#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -138,6 +125,7 @@ struct garmin_data {
138 __u8 privpkt[4*6]; 125 __u8 privpkt[4*6];
139 spinlock_t lock; 126 spinlock_t lock;
140 struct list_head pktlist; 127 struct list_head pktlist;
128 struct usb_anchor write_urbs;
141}; 129};
142 130
143 131
@@ -875,42 +863,38 @@ static int garmin_clear(struct garmin_data *garmin_data_p)
875 863
876static int garmin_init_session(struct usb_serial_port *port) 864static int garmin_init_session(struct usb_serial_port *port)
877{ 865{
878 struct usb_serial *serial = port->serial;
879 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 866 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
880 int status = 0; 867 int status;
881 int i = 0; 868 int i;
882 869
883 if (status == 0) { 870 usb_kill_urb(port->interrupt_in_urb);
884 usb_kill_urb(port->interrupt_in_urb);
885 871
886 dev_dbg(&serial->dev->dev, "%s - adding interrupt input\n", __func__); 872 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
887 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 873 if (status) {
888 if (status) 874 dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
889 dev_err(&serial->dev->dev, 875 status);
890 "%s - failed submitting interrupt urb, error %d\n", 876 return status;
891 __func__, status);
892 } 877 }
893 878
894 /* 879 /*
895 * using the initialization method from gpsbabel. See comments in 880 * using the initialization method from gpsbabel. See comments in
896 * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() 881 * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles()
897 */ 882 */
898 if (status == 0) { 883 dev_dbg(&port->dev, "%s - starting session ...\n", __func__);
899 dev_dbg(&serial->dev->dev, "%s - starting session ...\n", __func__); 884 garmin_data_p->state = STATE_ACTIVE;
900 garmin_data_p->state = STATE_ACTIVE;
901 885
902 for (i = 0; i < 3; i++) { 886 for (i = 0; i < 3; i++) {
903 status = garmin_write_bulk(port, 887 status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
904 GARMIN_START_SESSION_REQ, 888 sizeof(GARMIN_START_SESSION_REQ), 0);
905 sizeof(GARMIN_START_SESSION_REQ), 0); 889 if (status < 0)
890 goto err_kill_urbs;
891 }
906 892
907 if (status < 0) 893 return 0;
908 break;
909 }
910 894
911 if (status > 0) 895err_kill_urbs:
912 status = 0; 896 usb_kill_anchored_urbs(&garmin_data_p->write_urbs);
913 } 897 usb_kill_urb(port->interrupt_in_urb);
914 898
915 return status; 899 return status;
916} 900}
@@ -930,7 +914,6 @@ static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port)
930 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 914 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
931 915
932 /* shutdown any bulk reads that might be going on */ 916 /* shutdown any bulk reads that might be going on */
933 usb_kill_urb(port->write_urb);
934 usb_kill_urb(port->read_urb); 917 usb_kill_urb(port->read_urb);
935 918
936 if (garmin_data_p->state == STATE_RESET) 919 if (garmin_data_p->state == STATE_RESET)
@@ -953,7 +936,7 @@ static void garmin_close(struct usb_serial_port *port)
953 936
954 /* shutdown our urbs */ 937 /* shutdown our urbs */
955 usb_kill_urb(port->read_urb); 938 usb_kill_urb(port->read_urb);
956 usb_kill_urb(port->write_urb); 939 usb_kill_anchored_urbs(&garmin_data_p->write_urbs);
957 940
958 /* keep reset state so we know that we must start a new session */ 941 /* keep reset state so we know that we must start a new session */
959 if (garmin_data_p->state != STATE_RESET) 942 if (garmin_data_p->state != STATE_RESET)
@@ -1037,12 +1020,14 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1037 } 1020 }
1038 1021
1039 /* send it down the pipe */ 1022 /* send it down the pipe */
1023 usb_anchor_urb(urb, &garmin_data_p->write_urbs);
1040 status = usb_submit_urb(urb, GFP_ATOMIC); 1024 status = usb_submit_urb(urb, GFP_ATOMIC);
1041 if (status) { 1025 if (status) {
1042 dev_err(&port->dev, 1026 dev_err(&port->dev,
1043 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 1027 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
1044 __func__, status); 1028 __func__, status);
1045 count = status; 1029 count = status;
1030 usb_unanchor_urb(urb);
1046 kfree(buffer); 1031 kfree(buffer);
1047 } 1032 }
1048 1033
@@ -1370,9 +1355,9 @@ static void garmin_unthrottle(struct tty_struct *tty)
1370 * the tty in cases where the protocol provides no own handshaking 1355 * the tty in cases where the protocol provides no own handshaking
1371 * to initiate the transfer. 1356 * to initiate the transfer.
1372 */ 1357 */
1373static void timeout_handler(unsigned long data) 1358static void timeout_handler(struct timer_list *t)
1374{ 1359{
1375 struct garmin_data *garmin_data_p = (struct garmin_data *) data; 1360 struct garmin_data *garmin_data_p = from_timer(garmin_data_p, t, timer);
1376 1361
1377 /* send the next queued packet to the tty port */ 1362 /* send the next queued packet to the tty port */
1378 if (garmin_data_p->mode == MODE_NATIVE) 1363 if (garmin_data_p->mode == MODE_NATIVE)
@@ -1391,19 +1376,23 @@ static int garmin_port_probe(struct usb_serial_port *port)
1391 if (!garmin_data_p) 1376 if (!garmin_data_p)
1392 return -ENOMEM; 1377 return -ENOMEM;
1393 1378
1394 init_timer(&garmin_data_p->timer); 1379 timer_setup(&garmin_data_p->timer, timeout_handler, 0);
1395 spin_lock_init(&garmin_data_p->lock); 1380 spin_lock_init(&garmin_data_p->lock);
1396 INIT_LIST_HEAD(&garmin_data_p->pktlist); 1381 INIT_LIST_HEAD(&garmin_data_p->pktlist);
1397 /* garmin_data_p->timer.expires = jiffies + session_timeout; */
1398 garmin_data_p->timer.data = (unsigned long)garmin_data_p;
1399 garmin_data_p->timer.function = timeout_handler;
1400 garmin_data_p->port = port; 1382 garmin_data_p->port = port;
1401 garmin_data_p->state = 0; 1383 garmin_data_p->state = 0;
1402 garmin_data_p->flags = 0; 1384 garmin_data_p->flags = 0;
1403 garmin_data_p->count = 0; 1385 garmin_data_p->count = 0;
1386 init_usb_anchor(&garmin_data_p->write_urbs);
1404 usb_set_serial_port_data(port, garmin_data_p); 1387 usb_set_serial_port_data(port, garmin_data_p);
1405 1388
1406 status = garmin_init_session(port); 1389 status = garmin_init_session(port);
1390 if (status)
1391 goto err_free;
1392
1393 return 0;
1394err_free:
1395 kfree(garmin_data_p);
1407 1396
1408 return status; 1397 return status;
1409} 1398}
@@ -1413,6 +1402,7 @@ static int garmin_port_remove(struct usb_serial_port *port)
1413{ 1402{
1414 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1403 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1415 1404
1405 usb_kill_anchored_urbs(&garmin_data_p->write_urbs);
1416 usb_kill_urb(port->interrupt_in_urb); 1406 usb_kill_urb(port->interrupt_in_urb);
1417 del_timer_sync(&garmin_data_p->timer); 1407 del_timer_sync(&garmin_data_p->timer);
1418 kfree(garmin_data_p); 1408 kfree(garmin_data_p);
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 35cb8c0e584f..2274d9625f63 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial Converter Generic functions 3 * USB Serial Converter Generic functions
3 * 4 *
4 * Copyright (C) 2010 - 2013 Johan Hovold (jhovold@gmail.com) 5 * Copyright (C) 2010 - 2013 Johan Hovold (jhovold@gmail.com)
5 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) 6 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/serial/io_16654.h b/drivers/usb/serial/io_16654.h
index a53abc9530ff..4980f72dc56f 100644
--- a/drivers/usb/serial/io_16654.h
+++ b/drivers/usb/serial/io_16654.h
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * 3 *
3 * 16654.H Definitions for 16C654 UART used on EdgePorts 4 * 16654.H Definitions for 16C654 UART used on EdgePorts
4 * 5 *
5 * Copyright (C) 1998 Inside Out Networks, Inc. 6 * Copyright (C) 1998 Inside Out Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * 7 *
11 ************************************************************************/ 8 ************************************************************************/
12 9
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index bdf8bd814a9a..219265ce3711 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Edgeport USB Serial Converter driver 3 * Edgeport USB Serial Converter driver
3 * 4 *
4 * Copyright (C) 2000 Inside Out Networks, All rights reserved. 5 * Copyright (C) 2000 Inside Out Networks, All rights reserved.
5 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Supports the following devices: 8 * Supports the following devices:
13 * Edgeport/4 9 * Edgeport/4
14 * Edgeport/4t 10 * Edgeport/4t
diff --git a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h
index ad9c1d47a619..2e7fedbaf2ff 100644
--- a/drivers/usb/serial/io_edgeport.h
+++ b/drivers/usb/serial/io_edgeport.h
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * 3 *
3 * io_edgeport.h Edgeport Linux Interface definitions 4 * io_edgeport.h Edgeport Linux Interface definitions
4 * 5 *
5 * Copyright (C) 2000 Inside Out Networks, Inc. 6 * Copyright (C) 2000 Inside Out Networks, Inc.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 *
13 ************************************************************************/ 8 ************************************************************************/
14 9
15#if !defined(_IO_EDGEPORT_H_) 10#if !defined(_IO_EDGEPORT_H_)
diff --git a/drivers/usb/serial/io_ionsp.h b/drivers/usb/serial/io_ionsp.h
index 5cc591bae54d..4b8e4823bd45 100644
--- a/drivers/usb/serial/io_ionsp.h
+++ b/drivers/usb/serial/io_ionsp.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * 3 *
3 * IONSP.H Definitions for I/O Networks Serial Protocol 4 * IONSP.H Definitions for I/O Networks Serial Protocol
4 * 5 *
5 * Copyright (C) 1997-1998 Inside Out Networks, Inc. 6 * Copyright (C) 1997-1998 Inside Out Networks, Inc.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * These definitions are used by both kernel-mode driver and the 8 * These definitions are used by both kernel-mode driver and the
13 * peripheral firmware and MUST be kept in sync. 9 * peripheral firmware and MUST be kept in sync.
14 * 10 *
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 6cefb9cb133d..0fbadb37c104 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Edgeport USB Serial Converter driver 3 * Edgeport USB Serial Converter driver
3 * 4 *
4 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved. 5 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
5 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Supports the following devices: 8 * Supports the following devices:
13 * EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT 9 * EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT
14 * 10 *
diff --git a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h
index 1bd67b24f916..e53c68261017 100644
--- a/drivers/usb/serial/io_ti.h
+++ b/drivers/usb/serial/io_ti.h
@@ -1,13 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/***************************************************************************** 2/*****************************************************************************
2 * 3 *
3 * Copyright (C) 1997-2002 Inside Out Networks, Inc. 4 * Copyright (C) 1997-2002 Inside Out Networks, Inc.
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 *
11 * Feb-16-2001 DMI Added I2C structure definitions 6 * Feb-16-2001 DMI Added I2C structure definitions
12 * May-29-2002 gkh Ported to Linux 7 * May-29-2002 gkh Ported to Linux
13 * 8 *
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index 6f6a856bc37c..c38e87ac5ea9 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/************************************************************************ 2/************************************************************************
2 * 3 *
3 * USBVEND.H Vendor-specific USB definitions 4 * USBVEND.H Vendor-specific USB definitions
@@ -8,10 +9,6 @@
8 ************************************************************************ 9 ************************************************************************
9 * 10 *
10 * Copyright (C) 1998 Inside Out Networks, Inc. 11 * Copyright (C) 1998 Inside Out Networks, Inc.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 * 12 *
16 ************************************************************************/ 13 ************************************************************************/
17 14
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index cde0dcdce9c4..f81746c3c26c 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Compaq iPAQ driver 3 * USB Compaq iPAQ driver
3 * 4 *
4 * Copyright (C) 2001 - 2002 5 * Copyright (C) 2001 - 2002
5 * Ganesh Varadarajan <ganesh@veritas.com> 6 * Ganesh Varadarajan <ganesh@veritas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 8b1cf18a668b..d04c7cc5c1c2 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * IPWireless 3G UMTS TDD Modem driver (USB connected) 3 * IPWireless 3G UMTS TDD Modem driver (USB connected)
3 * 4 *
4 * Copyright (C) 2004 Roelf Diedericks <roelfd@inet.co.za> 5 * Copyright (C) 2004 Roelf Diedericks <roelfd@inet.co.za>
5 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * All information about the device was acquired using SnoopyPro 8 * All information about the device was acquired using SnoopyPro
13 * on MSFT's O/S, and examing the MSFT drivers' debug output 9 * on MSFT's O/S, and examing the MSFT drivers' debug output
14 * (insanely left _on_ in the enduser version) 10 * (insanely left _on_ in the enduser version)
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index f9734a96d516..24b06c7e5e2d 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB IR Dongle driver 3 * USB IR Dongle driver
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 2002 Gary Brubaker (xavyer@ix.netcom.com) 6 * Copyright (C) 2002 Gary Brubaker (xavyer@ix.netcom.com)
6 * Copyright (C) 2010 Johan Hovold (jhovold@gmail.com) 7 * Copyright (C) 2010 Johan Hovold (jhovold@gmail.com)
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This driver allows a USB IrDA device to be used as a "dumb" serial device. 9 * This driver allows a USB IrDA device to be used as a "dumb" serial device.
14 * This can be useful if you do not have access to a full IrDA stack on the 10 * This can be useful if you do not have access to a full IrDA stack on the
15 * other side of the connection. If you do have an IrDA stack on both devices, 11 * other side of the connection. If you do have an IrDA stack on both devices,
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 18fc992a245f..397a8012ffa3 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Infinity Unlimited USB Phoenix driver 3 * Infinity Unlimited USB Phoenix driver
3 * 4 *
@@ -7,13 +8,7 @@
7 * 8 *
8 * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás) 9 * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás)
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * And tested with help of WB Electronics 11 * And tested with help of WB Electronics
16 *
17 */ 12 */
18#include <linux/kernel.h> 13#include <linux/kernel.h>
19#include <linux/errno.h> 14#include <linux/errno.h>
diff --git a/drivers/usb/serial/iuu_phoenix.h b/drivers/usb/serial/iuu_phoenix.h
index b82630a3b8fd..b400b262f72e 100644
--- a/drivers/usb/serial/iuu_phoenix.h
+++ b/drivers/usb/serial/iuu_phoenix.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Infinity Unlimited USB Phoenix driver 3 * Infinity Unlimited USB Phoenix driver
3 * 4 *
@@ -6,13 +7,7 @@
6 * 7 *
7 * Original code taken from iuutool ( Copyright (C) 2006 Juan Carlos Borrás ) 8 * Original code taken from iuutool ( Copyright (C) 2006 Juan Carlos Borrás )
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * And tested with help of WB Electronics 10 * And tested with help of WB Electronics
15 *
16 */ 11 */
17 12
18#define IUU_USB_VENDOR_ID 0x104f 13#define IUU_USB_VENDOR_ID 0x104f
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 5662d324edd2..d34779fe4a8d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 Keyspan USB to Serial Converter driver 3 Keyspan USB to Serial Converter driver
3 4
4 (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org> 5 (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org>
5 (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com> 6 (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com>
6 7
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 See http://blemings.org/hugh/keyspan.html for more information. 8 See http://blemings.org/hugh/keyspan.html for more information.
13 9
14 Code in this driver inspired by and in a number of places taken 10 Code in this driver inspired by and in a number of places taken
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 196908dd25a1..5169624d8b11 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Keyspan PDA / Xircom / Entrega Converter driver 3 * USB Keyspan PDA / Xircom / Entrega Converter driver
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 1999, 2000 Brian Warner <warner@lothar.com> 6 * Copyright (C) 1999, 2000 Brian Warner <warner@lothar.com>
6 * Copyright (C) 2000 Al Borchers <borchers@steinerpoint.com> 7 * Copyright (C) 2000 Al Borchers <borchers@steinerpoint.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * See Documentation/usb/usb-serial.txt for more information on using this 9 * See Documentation/usb/usb-serial.txt for more information on using this
14 * driver 10 * driver
15 */ 11 */
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 595415e59d5d..5046ffd53cde 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * KLSI KL5KUSB105 chip RS232 converter driver 3 * KLSI KL5KUSB105 chip RS232 converter driver
3 * 4 *
4 * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com> 5 * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
5 * Copyright (C) 2001 Utz-Uwe Haus <haus@uuhaus.de> 6 * Copyright (C) 2001 Utz-Uwe Haus <haus@uuhaus.de>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * All information about the device was acquired using SniffUSB ans snoopUSB 8 * All information about the device was acquired using SniffUSB ans snoopUSB
13 * on Windows98. 9 * on Windows98.
14 * It was written out of frustration with the PalmConnect USB Serial adapter 10 * It was written out of frustration with the PalmConnect USB Serial adapter
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 3024b9b25360..a31ea7e194dd 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * KOBIL USB Smart Card Terminal Driver 3 * KOBIL USB Smart Card Terminal Driver
3 * 4 *
@@ -10,11 +11,6 @@
10 * and associated source files. Please see the usb/serial files for 11 * and associated source files. Please see the usb/serial files for
11 * individual credits and copyrights. 12 * individual credits and copyrights.
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * Thanks to Greg Kroah-Hartman (greg@kroah.com) for his help and 14 * Thanks to Greg Kroah-Hartman (greg@kroah.com) for his help and
19 * patience. 15 * patience.
20 * 16 *
@@ -491,6 +487,7 @@ static void kobil_set_termios(struct tty_struct *tty,
491 break; 487 break;
492 default: 488 default:
493 speed = 9600; 489 speed = 9600;
490 /* fall through */
494 case 9600: 491 case 9600:
495 urb_val = SUSBCR_SBR_9600; 492 urb_val = SUSBCR_SBR_9600;
496 break; 493 break;
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 70f346f1aa86..7887c312d9a9 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * MCT (Magic Control Technology Corp.) USB RS232 Converter Driver 3 * MCT (Magic Control Technology Corp.) USB RS232 Converter Driver
3 * 4 *
4 * Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch) 5 * Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch)
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is largely derived from the Belkin USB Serial Adapter Driver 7 * This program is largely derived from the Belkin USB Serial Adapter Driver
12 * (see belkin_sa.[ch]). All of the information about the device was acquired 8 * (see belkin_sa.[ch]). All of the information about the device was acquired
13 * by using SniffUSB on Windows98. For technical details see mct_u232.h. 9 * by using SniffUSB on Windows98. For technical details see mct_u232.h.
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h
index d325bb8cb583..0084edf518e8 100644
--- a/drivers/usb/serial/mct_u232.h
+++ b/drivers/usb/serial/mct_u232.h
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Definitions for MCT (Magic Control Technology) USB-RS232 Converter Driver 3 * Definitions for MCT (Magic Control Technology) USB-RS232 Converter Driver
3 * 4 *
4 * Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch) 5 * Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch)
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This driver is for the device MCT USB-RS232 Converter (25 pin, Model No. 7 * This driver is for the device MCT USB-RS232 Converter (25 pin, Model No.
12 * U232-P25) from Magic Control Technology Corp. (there is also a 9 pin 8 * U232-P25) from Magic Control Technology Corp. (there is also a 9 pin
13 * Model No. U232-P9). See http://www.mct.com.tw/products/product_us232.html 9 * Model No. U232-P9). See http://www.mct.com.tw/products/product_us232.html
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 14511d6a7d44..e63cea02cfd8 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 Some of this code is credited to Linux USB open source files that are 3 Some of this code is credited to Linux USB open source files that are
3 distributed with Linux. 4 distributed with Linux.
@@ -54,21 +55,33 @@ MODULE_DEVICE_TABLE(usb, id_table);
54#define UNI_CMD_OPEN 0x80 55#define UNI_CMD_OPEN 0x80
55#define UNI_CMD_CLOSE 0xFF 56#define UNI_CMD_CLOSE 0xFF
56 57
57static inline int metrousb_is_unidirectional_mode(struct usb_serial_port *port) 58static int metrousb_is_unidirectional_mode(struct usb_serial *serial)
58{ 59{
59 __u16 product_id = le16_to_cpu( 60 u16 product_id = le16_to_cpu(serial->dev->descriptor.idProduct);
60 port->serial->dev->descriptor.idProduct);
61 61
62 return product_id == FOCUS_PRODUCT_ID_UNI; 62 return product_id == FOCUS_PRODUCT_ID_UNI;
63} 63}
64 64
65static int metrousb_calc_num_ports(struct usb_serial *serial,
66 struct usb_serial_endpoints *epds)
67{
68 if (metrousb_is_unidirectional_mode(serial)) {
69 if (epds->num_interrupt_out == 0) {
70 dev_err(&serial->interface->dev, "interrupt-out endpoint missing\n");
71 return -ENODEV;
72 }
73 }
74
75 return 1;
76}
77
65static int metrousb_send_unidirectional_cmd(u8 cmd, struct usb_serial_port *port) 78static int metrousb_send_unidirectional_cmd(u8 cmd, struct usb_serial_port *port)
66{ 79{
67 int ret; 80 int ret;
68 int actual_len; 81 int actual_len;
69 u8 *buffer_cmd = NULL; 82 u8 *buffer_cmd = NULL;
70 83
71 if (!metrousb_is_unidirectional_mode(port)) 84 if (!metrousb_is_unidirectional_mode(port->serial))
72 return 0; 85 return 0;
73 86
74 buffer_cmd = kzalloc(sizeof(cmd), GFP_KERNEL); 87 buffer_cmd = kzalloc(sizeof(cmd), GFP_KERNEL);
@@ -161,13 +174,6 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
161 unsigned long flags = 0; 174 unsigned long flags = 0;
162 int result = 0; 175 int result = 0;
163 176
164 /* Make sure the urb is initialized. */
165 if (!port->interrupt_in_urb) {
166 dev_err(&port->dev, "%s - interrupt urb not initialized\n",
167 __func__);
168 return -ENODEV;
169 }
170
171 /* Set the private data information for the port. */ 177 /* Set the private data information for the port. */
172 spin_lock_irqsave(&metro_priv->lock, flags); 178 spin_lock_irqsave(&metro_priv->lock, flags);
173 metro_priv->control_state = 0; 179 metro_priv->control_state = 0;
@@ -189,7 +195,7 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
189 dev_err(&port->dev, 195 dev_err(&port->dev,
190 "%s - failed submitting interrupt in urb, error code=%d\n", 196 "%s - failed submitting interrupt in urb, error code=%d\n",
191 __func__, result); 197 __func__, result);
192 goto exit; 198 return result;
193 } 199 }
194 200
195 /* Send activate cmd to device */ 201 /* Send activate cmd to device */
@@ -198,9 +204,14 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
198 dev_err(&port->dev, 204 dev_err(&port->dev,
199 "%s - failed to configure device, error code=%d\n", 205 "%s - failed to configure device, error code=%d\n",
200 __func__, result); 206 __func__, result);
201 goto exit; 207 goto err_kill_urb;
202 } 208 }
203exit: 209
210 return 0;
211
212err_kill_urb:
213 usb_kill_urb(port->interrupt_in_urb);
214
204 return result; 215 return result;
205} 216}
206 217
@@ -337,7 +348,8 @@ static struct usb_serial_driver metrousb_device = {
337 }, 348 },
338 .description = "Metrologic USB to Serial", 349 .description = "Metrologic USB to Serial",
339 .id_table = id_table, 350 .id_table = id_table,
340 .num_ports = 1, 351 .num_interrupt_in = 1,
352 .calc_num_ports = metrousb_calc_num_ports,
341 .open = metrousb_open, 353 .open = metrousb_open,
342 .close = metrousb_cleanup, 354 .close = metrousb_cleanup,
343 .read_int_callback = metrousb_read_int_callback, 355 .read_int_callback = metrousb_read_int_callback,
@@ -356,7 +368,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
356 368
357module_usb_serial_driver(serial_drivers, id_table); 369module_usb_serial_driver(serial_drivers, id_table);
358 370
359MODULE_LICENSE("GPL"); 371MODULE_LICENSE("GPL v2");
360MODULE_AUTHOR("Philip Nicastro"); 372MODULE_AUTHOR("Philip Nicastro");
361MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>"); 373MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>");
362MODULE_DESCRIPTION(DRIVER_DESC); 374MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index a453965f9e9a..f4df3d5bf69c 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * mos7720.c 3 * mos7720.c
3 * Controls the Moschip 7720 usb to dual port serial converter 4 * Controls the Moschip 7720 usb to dual port serial converter
4 * 5 *
5 * Copyright 2006 Moschip Semiconductor Tech. Ltd. 6 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
10 *
11 * Developed by: 8 * Developed by:
12 * Vijaya Kumar <vijaykumar.gn@gmail.com> 9 * Vijaya Kumar <vijaykumar.gn@gmail.com>
13 * Ajay Kumar <naanuajay@yahoo.com> 10 * Ajay Kumar <naanuajay@yahoo.com>
@@ -2043,4 +2040,4 @@ module_usb_serial_driver(serial_drivers, id_table);
2043 2040
2044MODULE_AUTHOR(DRIVER_AUTHOR); 2041MODULE_AUTHOR(DRIVER_AUTHOR);
2045MODULE_DESCRIPTION(DRIVER_DESC); 2042MODULE_DESCRIPTION(DRIVER_DESC);
2046MODULE_LICENSE("GPL"); 2043MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index e8669aae14b3..a859c2d33c29 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1,18 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 *
16 * Clean ups from Moschip version and a few ioctl implementations by: 3 * Clean ups from Moschip version and a few ioctl implementations by:
17 * Paul B Schroeder <pschroeder "at" uplogix "dot" com> 4 * Paul B Schroeder <pschroeder "at" uplogix "dot" com>
18 * 5 *
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index 3aef091fe88b..2513ee902779 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * mxuport.c - MOXA UPort series driver 3 * mxuport.c - MOXA UPort series driver
3 * 4 *
4 * Copyright (c) 2006 Moxa Technologies Co., Ltd. 5 * Copyright (c) 2006 Moxa Technologies Co., Ltd.
5 * Copyright (c) 2013 Andrew Lunn <andrew@lunn.ch> 6 * Copyright (c) 2013 Andrew Lunn <andrew@lunn.ch>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Supports the following Moxa USB to serial converters: 8 * Supports the following Moxa USB to serial converters:
13 * 2 ports : UPort 1250, UPort 1250I 9 * 2 ports : UPort 1250, UPort 1250I
14 * 4 ports : UPort 1410, UPort 1450, UPort 1450I 10 * 4 ports : UPort 1410, UPort 1450, UPort 1450I
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 2a97cdc078d5..20277c52dded 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Navman Serial USB driver 3 * Navman Serial USB driver
3 * 4 *
4 * Copyright (C) 2006 Greg Kroah-Hartman <gregkh@suse.de> 5 * Copyright (C) 2006 Greg Kroah-Hartman <gregkh@suse.de>
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * TODO: 7 * TODO:
11 * Add termios method that uses copy_hw but also kills all echo 8 * Add termios method that uses copy_hw but also kills all echo
12 * flags as the navman is rx only so cannot echo. 9 * flags as the navman is rx only so cannot echo.
@@ -115,4 +112,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
115 112
116module_usb_serial_driver(serial_drivers, id_table); 113module_usb_serial_driver(serial_drivers, id_table);
117 114
118MODULE_LICENSE("GPL"); 115MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index efcd7feed6f4..e51c9464ea42 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB ZyXEL omni.net LCD PLUS driver 3 * USB ZyXEL omni.net LCD PLUS driver
3 * 4 *
4 * Copyright (C) 2013,2017 Johan Hovold <johan@kernel.org> 5 * Copyright (C) 2013,2017 Johan Hovold <johan@kernel.org>
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * See Documentation/usb/usb-serial.txt for more information on using this 7 * See Documentation/usb/usb-serial.txt for more information on using this
11 * driver 8 * driver
12 * 9 *
@@ -179,4 +176,4 @@ module_usb_serial_driver(serial_drivers, id_table);
179 176
180MODULE_AUTHOR(DRIVER_AUTHOR); 177MODULE_AUTHOR(DRIVER_AUTHOR);
181MODULE_DESCRIPTION(DRIVER_DESC); 178MODULE_DESCRIPTION(DRIVER_DESC);
182MODULE_LICENSE("GPL"); 179MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 58657d64678b..caa0746326fd 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Opticon USB barcode to serial driver 3 * Opticon USB barcode to serial driver
3 * 4 *
@@ -5,10 +6,6 @@
5 * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com> 6 * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com>
6 * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (C) 2008 - 2009 Novell Inc. 8 * Copyright (C) 2008 - 2009 Novell Inc.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 */ 9 */
13 10
14#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -420,4 +417,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
420module_usb_serial_driver(serial_drivers, id_table); 417module_usb_serial_driver(serial_drivers, id_table);
421 418
422MODULE_DESCRIPTION(DRIVER_DESC); 419MODULE_DESCRIPTION(DRIVER_DESC);
423MODULE_LICENSE("GPL"); 420MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index ba672cf4e888..aaa7d901a06d 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 USB Driver for GSM modems 3 USB Driver for GSM modems
3 4
4 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> 5 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de>
5 6
6 This driver is free software; you can redistribute it and/or modify
7 it under the terms of Version 2 of the GNU General Public License as
8 published by the Free Software Foundation.
9
10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> 7 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org>
11 8
12 History: see the git log. 9 History: see the git log.
@@ -2206,4 +2203,4 @@ static void option_instat_callback(struct urb *urb)
2206 2203
2207MODULE_AUTHOR(DRIVER_AUTHOR); 2204MODULE_AUTHOR(DRIVER_AUTHOR);
2208MODULE_DESCRIPTION(DRIVER_DESC); 2205MODULE_DESCRIPTION(DRIVER_DESC);
2209MODULE_LICENSE("GPL"); 2206MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index b11eead469ee..ae9cb15ee02d 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Ours Technology Inc. OTi-6858 USB to serial adapter driver. 3 * Ours Technology Inc. OTi-6858 USB to serial adapter driver.
3 * 4 *
@@ -21,10 +22,6 @@
21 * So, THIS CODE CAN DESTROY OTi-6858 AND ANY OTHER DEVICES, THAT ARE 22 * So, THIS CODE CAN DESTROY OTi-6858 AND ANY OTHER DEVICES, THAT ARE
22 * CONNECTED TO IT! 23 * CONNECTED TO IT!
23 * 24 *
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License.
27 *
28 * See Documentation/usb/usb-serial.txt for more information on using this 25 * See Documentation/usb/usb-serial.txt for more information on using this
29 * driver 26 * driver
30 * 27 *
@@ -847,4 +844,4 @@ module_usb_serial_driver(serial_drivers, id_table);
847 844
848MODULE_DESCRIPTION(OTI6858_DESCRIPTION); 845MODULE_DESCRIPTION(OTI6858_DESCRIPTION);
849MODULE_AUTHOR(OTI6858_AUTHOR); 846MODULE_AUTHOR(OTI6858_AUTHOR);
850MODULE_LICENSE("GPL"); 847MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/oti6858.h b/drivers/usb/serial/oti6858.h
index 704ac3a532b3..1226bf2347eb 100644
--- a/drivers/usb/serial/oti6858.h
+++ b/drivers/usb/serial/oti6858.h
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Ours Technology Inc. OTi-6858 USB to serial adapter driver. 3 * Ours Technology Inc. OTi-6858 USB to serial adapter driver.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */ 4 */
9#ifndef __LINUX_USB_SERIAL_OTI6858_H 5#ifndef __LINUX_USB_SERIAL_OTI6858_H
10#define __LINUX_USB_SERIAL_OTI6858_H 6#define __LINUX_USB_SERIAL_OTI6858_H
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index a585b477415d..57ae832a49ff 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Prolific PL2303 USB to serial adaptor driver 3 * Prolific PL2303 USB to serial adaptor driver
3 * 4 *
@@ -6,10 +7,6 @@
6 * 7 *
7 * Original driver for 2.2.x by anonymous 8 * Original driver for 2.2.x by anonymous
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * See Documentation/usb/usb-serial.txt for more information on using this 10 * See Documentation/usb/usb-serial.txt for more information on using this
14 * driver 11 * driver
15 */ 12 */
@@ -1025,4 +1022,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
1025module_usb_serial_driver(serial_drivers, id_table); 1022module_usb_serial_driver(serial_drivers, id_table);
1026 1023
1027MODULE_DESCRIPTION("Prolific PL2303 USB to serial adaptor driver"); 1024MODULE_DESCRIPTION("Prolific PL2303 USB to serial adaptor driver");
1028MODULE_LICENSE("GPL"); 1025MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 3b5a15d1dc0d..f98fd84890de 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -1,11 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Prolific PL2303 USB to serial adaptor driver header file 3 * Prolific PL2303 USB to serial adaptor driver header file
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 */ 4 */
10 5
11#define BENQ_VENDOR_ID 0x04a5 6#define BENQ_VENDOR_ID 0x04a5
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index 6e9f8af96959..929ffba663f2 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Qualcomm USB Auxiliary Serial Port driver 3 * Qualcomm USB Auxiliary Serial Port driver
3 * 4 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2010 Dan Williams <dcbw@redhat.com> 6 * Copyright (C) 2010 Dan Williams <dcbw@redhat.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Devices listed here usually provide a CDC ACM port on which normal modem 8 * Devices listed here usually provide a CDC ACM port on which normal modem
12 * AT commands and PPP can be used. But when that port is in-use by PPP it 9 * AT commands and PPP can be used. But when that port is in-use by PPP it
13 * cannot be used simultaneously for status or signal strength. Instead, the 10 * cannot be used simultaneously for status or signal strength. Instead, the
@@ -87,4 +84,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
87}; 84};
88 85
89module_usb_serial_driver(serial_drivers, id_table); 86module_usb_serial_driver(serial_drivers, id_table);
90MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index eb9928963a53..e3892541a489 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Qualcomm Serial USB driver 3 * Qualcomm Serial USB driver
3 * 4 *
4 * Copyright (c) 2008 QUALCOMM Incorporated. 5 * Copyright (c) 2008 QUALCOMM Incorporated.
5 * Copyright (c) 2009 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (c) 2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (c) 2009 Novell Inc. 7 * Copyright (c) 2009 Novell Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 */ 8 */
13 9
14#include <linux/tty.h> 10#include <linux/tty.h>
@@ -148,6 +144,7 @@ static const struct usb_device_id id_table[] = {
148 {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */ 144 {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */
149 {DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC7304/MC7354 */ 145 {DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC7304/MC7354 */
150 {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ 146 {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */
147 {DEVICE_SWI(0x1199, 0x901e)}, /* Sierra Wireless EM7355 QDL */
151 {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ 148 {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */
152 {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */ 149 {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */
153 {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */ 150 {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 60e17d1444c3..958e12e1e7c7 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * usb-serial driver for Quatech USB 2 devices 3 * usb-serial driver for Quatech USB 2 devices
3 * 4 *
4 * Copyright (C) 2012 Bill Pemberton (wfp5p@virginia.edu) 5 * Copyright (C) 2012 Bill Pemberton (wfp5p@virginia.edu)
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 *
11 * These devices all have only 1 bulk in and 1 bulk out that is shared 7 * These devices all have only 1 bulk in and 1 bulk out that is shared
12 * for all serial ports. 8 * for all serial ports.
13 * 9 *
@@ -1027,4 +1023,4 @@ static struct usb_serial_driver *const serial_drivers[] = {
1027module_usb_serial_driver(serial_drivers, id_table); 1023module_usb_serial_driver(serial_drivers, id_table);
1028 1024
1029MODULE_DESCRIPTION(DRIVER_DESC); 1025MODULE_DESCRIPTION(DRIVER_DESC);
1030MODULE_LICENSE("GPL"); 1026MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 27d7a7016298..6accbecb6318 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Safe Encapsulated USB Serial Driver 3 * Safe Encapsulated USB Serial Driver
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (C) 2001 Lineo 6 * Copyright (C) 2001 Lineo
6 * Copyright (C) 2001 Hewlett-Packard 7 * Copyright (C) 2001 Hewlett-Packard
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * By: 9 * By:
14 * Stuart Lynne <sl@lineo.com>, Tom Rushworth <tbr@lineo.com> 10 * Stuart Lynne <sl@lineo.com>, Tom Rushworth <tbr@lineo.com>
15 */ 11 */
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 4c4ac4705ac0..d189f953c891 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 USB Driver for Sierra Wireless 3 USB Driver for Sierra Wireless
3 4
@@ -9,10 +10,6 @@
9 IMPORTANT DISCLAIMER: This driver is not commercially supported by 10 IMPORTANT DISCLAIMER: This driver is not commercially supported by
10 Sierra Wireless. Use at your own risk. 11 Sierra Wireless. Use at your own risk.
11 12
12 This driver is free software; you can redistribute it and/or modify
13 it under the terms of Version 2 of the GNU General Public License as
14 published by the Free Software Foundation.
15
16 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de> 13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
17 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
18*/ 15*/
@@ -1078,7 +1075,7 @@ module_usb_serial_driver(serial_drivers, id_table);
1078 1075
1079MODULE_AUTHOR(DRIVER_AUTHOR); 1076MODULE_AUTHOR(DRIVER_AUTHOR);
1080MODULE_DESCRIPTION(DRIVER_DESC); 1077MODULE_DESCRIPTION(DRIVER_DESC);
1081MODULE_LICENSE("GPL"); 1078MODULE_LICENSE("GPL v2");
1082 1079
1083module_param(nmea, bool, S_IRUGO | S_IWUSR); 1080module_param(nmea, bool, S_IRUGO | S_IWUSR);
1084MODULE_PARM_DESC(nmea, "NMEA streaming"); 1081MODULE_PARM_DESC(nmea, "NMEA streaming");
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 5167b6564c8b..b42714855364 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * spcp8x5 USB to serial adaptor driver 3 * spcp8x5 USB to serial adaptor driver
3 * 4 *
@@ -8,11 +9,6 @@
8 * Original driver for 2.6.10 pl2303 driver by 9 * Original driver for 2.6.10 pl2303 driver by
9 * Greg Kroah-Hartman (greg@kroah.com) 10 * Greg Kroah-Hartman (greg@kroah.com)
10 * Changes for 2.6.20 by Harald Klein <hari@vt100.at> 11 * Changes for 2.6.20 by Harald Klein <hari@vt100.at>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */ 12 */
17#include <linux/kernel.h> 13#include <linux/kernel.h>
18#include <linux/errno.h> 14#include <linux/errno.h>
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 5aa7bbbeba3d..2083c267787b 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * usb-serial driver for Quatech SSU-100 3 * usb-serial driver for Quatech SSU-100
3 * 4 *
@@ -576,4 +577,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
576module_usb_serial_driver(serial_drivers, id_table); 577module_usb_serial_driver(serial_drivers, id_table);
577 578
578MODULE_DESCRIPTION(DRIVER_DESC); 579MODULE_DESCRIPTION(DRIVER_DESC);
579MODULE_LICENSE("GPL"); 580MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 0d1727232d0c..cd2f8dc8b58c 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Symbol USB barcode to serial driver 3 * Symbol USB barcode to serial driver
3 * 4 *
4 * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com> 5 * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
5 * Copyright (C) 2009 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (C) 2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (C) 2009 Novell Inc. 7 * Copyright (C) 2009 Novell Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -194,4 +191,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
194 191
195module_usb_serial_driver(serial_drivers, id_table); 192module_usb_serial_driver(serial_drivers, id_table);
196 193
197MODULE_LICENSE("GPL"); 194MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 8fc3854e5e69..6b22857f6e52 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * TI 3410/5052 USB Serial Driver 3 * TI 3410/5052 USB Serial Driver
3 * 4 *
@@ -7,11 +8,6 @@
7 * Copyright (C) 2000-2002 Inside Out Networks 8 * Copyright (C) 2000-2002 Inside Out Networks
8 * Copyright (C) 2001-2002 Greg Kroah-Hartman 9 * Copyright (C) 2001-2002 Greg Kroah-Hartman
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * For questions or problems with this driver, contact Texas Instruments 11 * For questions or problems with this driver, contact Texas Instruments
16 * technical support, or Al Borchers <alborchers@steinerpoint.com>, or 12 * technical support, or Al Borchers <alborchers@steinerpoint.com>, or
17 * Peter Berger <pberger@brimson.com>. 13 * Peter Berger <pberger@brimson.com>.
diff --git a/drivers/usb/serial/upd78f0730.c b/drivers/usb/serial/upd78f0730.c
index 6819a3486e5d..1ba1401d27d7 100644
--- a/drivers/usb/serial/upd78f0730.c
+++ b/drivers/usb/serial/upd78f0730.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Renesas Electronics uPD78F0730 USB to serial converter driver 3 * Renesas Electronics uPD78F0730 USB to serial converter driver
3 * 4 *
4 * Copyright (C) 2014,2016 Maksim Salau <maksim.salau@gmail.com> 5 * Copyright (C) 2014,2016 Maksim Salau <maksim.salau@gmail.com>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * Protocol of the adaptor is described in the application note U19660EJ1V0AN00 7 * Protocol of the adaptor is described in the application note U19660EJ1V0AN00
11 * μPD78F0730 8-bit Single-Chip Microcontroller 8 * μPD78F0730 8-bit Single-Chip Microcontroller
12 * USB-to-Serial Conversion Software 9 * USB-to-Serial Conversion Software
diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
index e98b6e57b703..74172fe158df 100644
--- a/drivers/usb/serial/usb-serial-simple.c
+++ b/drivers/usb/serial/usb-serial-simple.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial "Simple" driver 3 * USB Serial "Simple" driver
3 * 4 *
@@ -8,10 +9,6 @@
8 * Copyright (C) 2010 Zilogic Systems <code@zilogic.com> 9 * Copyright (C) 2010 Zilogic Systems <code@zilogic.com>
9 * Copyright (C) 2013 Wei Shuai <cpuwolf@gmail.com> 10 * Copyright (C) 2013 Wei Shuai <cpuwolf@gmail.com>
10 * Copyright (C) 2013 Linux Foundation 11 * Copyright (C) 2013 Linux Foundation
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License version
14 * 2 as published by the Free Software Foundation.
15 */ 12 */
16 13
17#include <linux/kernel.h> 14#include <linux/kernel.h>
@@ -134,4 +131,4 @@ static const struct usb_device_id id_table[] = {
134MODULE_DEVICE_TABLE(usb, id_table); 131MODULE_DEVICE_TABLE(usb, id_table);
135 132
136module_usb_serial_driver(serial_drivers, id_table); 133module_usb_serial_driver(serial_drivers, id_table);
137MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index bb34f9f7eaf4..790e0cbe3da9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial Converter driver 3 * USB Serial Converter driver
3 * 4 *
@@ -6,10 +7,6 @@
6 * Copyright (C) 2000 Peter Berger (pberger@brimson.com) 7 * Copyright (C) 2000 Peter Berger (pberger@brimson.com)
7 * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com) 8 * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com)
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This driver was originally based on the ACM driver by Armin Fuerst (which was 10 * This driver was originally based on the ACM driver by Armin Fuerst (which was
14 * based on a driver by Brad Keryan) 11 * based on a driver by Brad Keryan)
15 * 12 *
@@ -1201,17 +1198,6 @@ static const struct tty_operations serial_ops = {
1201 1198
1202struct tty_driver *usb_serial_tty_driver; 1199struct tty_driver *usb_serial_tty_driver;
1203 1200
1204/* Driver structure we register with the USB core */
1205static struct usb_driver usb_serial_driver = {
1206 .name = "usbserial",
1207 .probe = usb_serial_probe,
1208 .disconnect = usb_serial_disconnect,
1209 .suspend = usb_serial_suspend,
1210 .resume = usb_serial_resume,
1211 .no_dynamic_id = 1,
1212 .supports_autosuspend = 1,
1213};
1214
1215static int __init usb_serial_init(void) 1201static int __init usb_serial_init(void)
1216{ 1202{
1217 int result; 1203 int result;
@@ -1247,13 +1233,6 @@ static int __init usb_serial_init(void)
1247 goto exit_reg_driver; 1233 goto exit_reg_driver;
1248 } 1234 }
1249 1235
1250 /* register the USB driver */
1251 result = usb_register(&usb_serial_driver);
1252 if (result < 0) {
1253 pr_err("%s - usb_register failed\n", __func__);
1254 goto exit_tty;
1255 }
1256
1257 /* register the generic driver, if we should */ 1236 /* register the generic driver, if we should */
1258 result = usb_serial_generic_register(); 1237 result = usb_serial_generic_register();
1259 if (result < 0) { 1238 if (result < 0) {
@@ -1264,9 +1243,6 @@ static int __init usb_serial_init(void)
1264 return result; 1243 return result;
1265 1244
1266exit_generic: 1245exit_generic:
1267 usb_deregister(&usb_serial_driver);
1268
1269exit_tty:
1270 tty_unregister_driver(usb_serial_tty_driver); 1246 tty_unregister_driver(usb_serial_tty_driver);
1271 1247
1272exit_reg_driver: 1248exit_reg_driver:
@@ -1285,7 +1261,6 @@ static void __exit usb_serial_exit(void)
1285 1261
1286 usb_serial_generic_deregister(); 1262 usb_serial_generic_deregister();
1287 1263
1288 usb_deregister(&usb_serial_driver);
1289 tty_unregister_driver(usb_serial_tty_driver); 1264 tty_unregister_driver(usb_serial_tty_driver);
1290 put_tty_driver(usb_serial_tty_driver); 1265 put_tty_driver(usb_serial_tty_driver);
1291 bus_unregister(&usb_serial_bus_type); 1266 bus_unregister(&usb_serial_bus_type);
@@ -1460,4 +1435,4 @@ EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers);
1460 1435
1461MODULE_AUTHOR(DRIVER_AUTHOR); 1436MODULE_AUTHOR(DRIVER_AUTHOR);
1462MODULE_DESCRIPTION(DRIVER_DESC); 1437MODULE_DESCRIPTION(DRIVER_DESC);
1463MODULE_LICENSE("GPL"); 1438MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 12f4c5a91e62..ab5a2ac4993a 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Debug cable driver 3 * USB Debug cable driver
3 * 4 *
4 * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/gfp.h> 8#include <linux/gfp.h>
@@ -34,13 +31,13 @@ static const struct usb_device_id id_table[] = {
34}; 31};
35 32
36static const struct usb_device_id dbc_id_table[] = { 33static const struct usb_device_id dbc_id_table[] = {
37 { USB_DEVICE(0x1d6b, 0x0004) }, 34 { USB_DEVICE(0x1d6b, 0x0011) },
38 { }, 35 { },
39}; 36};
40 37
41static const struct usb_device_id id_table_combined[] = { 38static const struct usb_device_id id_table_combined[] = {
42 { USB_DEVICE(0x0525, 0x127a) }, 39 { USB_DEVICE(0x0525, 0x127a) },
43 { USB_DEVICE(0x1d6b, 0x0004) }, 40 { USB_DEVICE(0x1d6b, 0x0011) },
44 { }, 41 { },
45}; 42};
46MODULE_DEVICE_TABLE(usb, id_table_combined); 43MODULE_DEVICE_TABLE(usb, id_table_combined);
@@ -98,4 +95,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
98}; 95};
99 96
100module_usb_serial_driver(serial_drivers, id_table_combined); 97module_usb_serial_driver(serial_drivers, id_table_combined);
101MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 59bfcb3da116..107e64c42e94 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 USB Driver layer for GSM modems 3 USB Driver layer for GSM modems
3 4
4 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> 5 Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de>
5 6
6 This driver is free software; you can redistribute it and/or modify
7 it under the terms of Version 2 of the GNU General Public License as
8 published by the Free Software Foundation.
9
10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> 7 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org>
11 8
12 History: see the git log. 9 History: see the git log.
@@ -723,4 +720,4 @@ EXPORT_SYMBOL(usb_wwan_resume);
723 720
724MODULE_AUTHOR(DRIVER_AUTHOR); 721MODULE_AUTHOR(DRIVER_AUTHOR);
725MODULE_DESCRIPTION(DRIVER_DESC); 722MODULE_DESCRIPTION(DRIVER_DESC);
726MODULE_LICENSE("GPL"); 723MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 9f3317a940ef..f5373ed2cd45 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB HandSpring Visor, Palm m50x, and Sony Clie driver 3 * USB HandSpring Visor, Palm m50x, and Sony Clie driver
3 * (supports all of the Palm OS USB devices) 4 * (supports all of the Palm OS USB devices)
@@ -5,10 +6,6 @@
5 * Copyright (C) 1999 - 2004 6 * Copyright (C) 1999 - 2004
6 * Greg Kroah-Hartman (greg@kroah.com) 7 * Greg Kroah-Hartman (greg@kroah.com)
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * See Documentation/usb/usb-serial.txt for more information on using this 9 * See Documentation/usb/usb-serial.txt for more information on using this
13 * driver 10 * driver
14 * 11 *
@@ -579,4 +576,4 @@ module_usb_serial_driver(serial_drivers, id_table_combined);
579 576
580MODULE_AUTHOR(DRIVER_AUTHOR); 577MODULE_AUTHOR(DRIVER_AUTHOR);
581MODULE_DESCRIPTION(DRIVER_DESC); 578MODULE_DESCRIPTION(DRIVER_DESC);
582MODULE_LICENSE("GPL"); 579MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/serial/visor.h b/drivers/usb/serial/visor.h
index 4c456dd69ce5..fe290243f1ce 100644
--- a/drivers/usb/serial/visor.h
+++ b/drivers/usb/serial/visor.h
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB HandSpring Visor driver 3 * USB HandSpring Visor driver
3 * 4 *
4 * Copyright (C) 1999 - 2003 5 * Copyright (C) 1999 - 2003
5 * Greg Kroah-Hartman (greg@kroah.com) 6 * Greg Kroah-Hartman (greg@kroah.com)
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * See Documentation/usb/usb-serial.txt for more information on using this 8 * See Documentation/usb/usb-serial.txt for more information on using this
13 * driver. 9 * driver.
14 * 10 *
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 55cebc1e6fec..1c7b46a8620c 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB ConnectTech WhiteHEAT driver 3 * USB ConnectTech WhiteHEAT driver
3 * 4 *
@@ -7,11 +8,6 @@
7 * Copyright (C) 1999 - 2001 8 * Copyright (C) 1999 - 2001
8 * Greg Kroah-Hartman (greg@kroah.com) 9 * Greg Kroah-Hartman (greg@kroah.com)
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this 11 * See Documentation/usb/usb-serial.txt for more information on using this
16 * driver 12 * driver
17 */ 13 */
diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h
index 38065df4d2d8..72c1b0cf4063 100644
--- a/drivers/usb/serial/whiteheat.h
+++ b/drivers/usb/serial/whiteheat.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB ConnectTech WhiteHEAT driver 3 * USB ConnectTech WhiteHEAT driver
3 * 4 *
@@ -7,11 +8,6 @@
7 * Copyright (C) 1999, 2000 8 * Copyright (C) 1999, 2000
8 * Greg Kroah-Hartman (greg@kroah.com) 9 * Greg Kroah-Hartman (greg@kroah.com)
9 * 10 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this 11 * See Documentation/usb/usb-serial.txt for more information on using this
16 * driver 12 * driver
17 * 13 *
diff --git a/drivers/usb/serial/wishbone-serial.c b/drivers/usb/serial/wishbone-serial.c
index 4fed4a0bd702..ff4092f9b33c 100644
--- a/drivers/usb/serial/wishbone-serial.c
+++ b/drivers/usb/serial/wishbone-serial.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Wishbone-Serial adapter driver 3 * USB Wishbone-Serial adapter driver
3 * 4 *
4 * Copyright (C) 2013 Wesley W. Terpstra <w.terpstra@gsi.de> 5 * Copyright (C) 2013 Wesley W. Terpstra <w.terpstra@gsi.de>
5 * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH 6 * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 */ 7 */
12 8
13#include <linux/kernel.h> 9#include <linux/kernel.h>
diff --git a/drivers/usb/serial/xsens_mt.c b/drivers/usb/serial/xsens_mt.c
index 3837d5113bb2..cf262c9a9638 100644
--- a/drivers/usb/serial/xsens_mt.c
+++ b/drivers/usb/serial/xsens_mt.c
@@ -1,11 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Xsens MT USB driver 3 * Xsens MT USB driver
3 * 4 *
4 * Copyright (C) 2013 Xsens <info@xsens.com> 5 * Copyright (C) 2013 Xsens <info@xsens.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */ 6 */
10 7
11#include <linux/kernel.h> 8#include <linux/kernel.h>
@@ -69,4 +66,4 @@ module_usb_serial_driver(serial_drivers, id_table);
69 66
70MODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>"); 67MODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>");
71MODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers"); 68MODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers");
72MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 878b4b8761f5..900591df8bb2 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Alauda-based card readers 3 * Driver for Alauda-based card readers
3 * 4 *
@@ -15,20 +16,6 @@
15 * (very old) vendor-supplied GPL sma03 driver. 16 * (very old) vendor-supplied GPL sma03 driver.
16 * 17 *
17 * For protocol info, see http://alauda.sourceforge.net 18 * For protocol info, see http://alauda.sourceforge.net
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2, or (at your option) any
22 * later version.
23 *
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */ 19 */
33 20
34#include <linux/module.h> 21#include <linux/module.h>
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index 5e4af44d7d9f..4825902377eb 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Support for emulating SAT (ata pass through) on devices based 3 * Support for emulating SAT (ata pass through) on devices based
3 * on the Cypress USB/ATA bridge supporting ATACB. 4 * on the Cypress USB/ATA bridge supporting ATACB.
4 * 5 *
5 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr) 6 * Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 7 */
21 8
22#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 723197af6ec5..09353be199be 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Datafab USB Compact Flash reader 3 * Driver for Datafab USB Compact Flash reader
3 * 4 *
@@ -18,20 +19,6 @@
18 * 19 *
19 * Other contributors: 20 * Other contributors:
20 * (c) 2002 Alan Stern <stern@rowland.org> 21 * (c) 2002 Alan Stern <stern@rowland.org>
21 *
22 * This program is free software; you can redistribute it and/or modify it
23 * under the terms of the GNU General Public License as published by the
24 * Free Software Foundation; either version 2, or (at your option) any
25 * later version.
26 *
27 * This program is distributed in the hope that it will be useful, but
28 * WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 * General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License along
33 * with this program; if not, write to the Free Software Foundation, Inc.,
34 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 */ 22 */
36 23
37/* 24/*
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index 8d20804a59e6..e5a4969d15ae 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Debugging Functions Source Code File 4 * Debugging Functions Source Code File
@@ -27,20 +28,6 @@
27 * 28 *
28 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 29 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
29 * information about this driver. 30 * information about this driver.
30 *
31 * This program is free software; you can redistribute it and/or modify it
32 * under the terms of the GNU General Public License as published by the
33 * Free Software Foundation; either version 2, or (at your option) any
34 * later version.
35 *
36 * This program is distributed in the hope that it will be useful, but
37 * WITHOUT ANY WARRANTY; without even the implied warranty of
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 * General Public License for more details.
40 *
41 * You should have received a copy of the GNU General Public License along
42 * with this program; if not, write to the Free Software Foundation, Inc.,
43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */ 31 */
45 32
46#include <linux/device.h> 33#include <linux/device.h>
diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h
index 8ab73299b650..8833cd4f78b6 100644
--- a/drivers/usb/storage/debug.h
+++ b/drivers/usb/storage/debug.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Debugging Functions Header File 4 * Debugging Functions Header File
@@ -24,20 +25,6 @@
24 * 25 *
25 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 26 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
26 * information about this driver. 27 * information about this driver.
27 *
28 * This program is free software; you can redistribute it and/or modify it
29 * under the terms of the GNU General Public License as published by the
30 * Free Software Foundation; either version 2, or (at your option) any
31 * later version.
32 *
33 * This program is distributed in the hope that it will be useful, but
34 * WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 * General Public License for more details.
37 *
38 * You should have received a copy of the GNU General Public License along
39 * with this program; if not, write to the Free Software Foundation, Inc.,
40 * 675 Mass Ave, Cambridge, MA 02139, USA.
41 */ 28 */
42 29
43#ifndef _DEBUG_H_ 30#ifndef _DEBUG_H_
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index 28100374f7bd..93cf57ac47d6 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -1,19 +1,4 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17#include <linux/jiffies.h> 2#include <linux/jiffies.h>
18#include <linux/errno.h> 3#include <linux/errno.h>
19#include <linux/module.h> 4#include <linux/module.h>
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index c0a5d954414b..ec4d92c92762 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Freecom USB/IDE adaptor 3 * Driver for Freecom USB/IDE adaptor
3 * 4 *
@@ -8,20 +9,6 @@
8 * Current development and maintenance by: 9 * Current development and maintenance by:
9 * (C) 2000 David Brown <usb-storage@davidb.org> 10 * (C) 2000 David Brown <usb-storage@davidb.org>
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2, or (at your option) any
14 * later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * This driver was developed with information provided in FREECOM's USB 12 * This driver was developed with information provided in FREECOM's USB
26 * Programmers Reference Guide. For further information contact Freecom 13 * Programmers Reference Guide. For further information contact Freecom
27 * (http://www.freecom.de/) 14 * (http://www.freecom.de/)
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index d9d8c17e05d1..93a6bcf77806 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Special Initializers for certain USB Mass Storage devices 3 * Special Initializers for certain USB Mass Storage devices
3 * 4 *
@@ -20,20 +21,6 @@
20 * 21 *
21 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 22 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
22 * information about this driver. 23 * information about this driver.
23 *
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
27 * later version.
28 *
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
37 */ 24 */
38 25
39#include <linux/errno.h> 26#include <linux/errno.h>
diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h
index 039abf4d1cb7..e4cf28efb4a7 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Header file for Special Initializers for certain USB Mass Storage devices 3 * Header file for Special Initializers for certain USB Mass Storage devices
3 * 4 *
@@ -20,20 +21,6 @@
20 * 21 *
21 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 22 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
22 * information about this driver. 23 * information about this driver.
23 *
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
27 * later version.
28 *
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
37 */ 24 */
38 25
39#include "usb.h" 26#include "usb.h"
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 6a7720e66595..f5e4500d9970 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC 3 * Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC
3 * 4 *
@@ -14,20 +15,6 @@
14 * does implement an interface, the ATA Command Block (ATACB) which provides 15 * does implement an interface, the ATA Command Block (ATACB) which provides
15 * a means of passing ATA commands and ATA register accesses to a device. 16 * a means of passing ATA commands and ATA register accesses to a device.
16 * 17 *
17 * This program is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
20 * later version.
21 *
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 *
31 * History: 18 * History:
32 * 19 *
33 * 2002-10-19: Removed the specialized transfer routines. 20 * 2002-10-19: Removed the specialized transfer routines.
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index 011e5270690a..917f170c4124 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Lexar "Jumpshot" Compact Flash reader 3 * Driver for Lexar "Jumpshot" Compact Flash reader
3 * 4 *
@@ -19,20 +20,6 @@
19 * Developed with the assistance of: 20 * Developed with the assistance of:
20 * 21 *
21 * (C) 2002 Alan Stern <stern@rowland.org> 22 * (C) 2002 Alan Stern <stern@rowland.org>
22 *
23 * This program is free software; you can redistribute it and/or modify it
24 * under the terms of the GNU General Public License as published by the
25 * Free Software Foundation; either version 2, or (at your option) any
26 * later version.
27 *
28 * This program is distributed in the hope that it will be useful, but
29 * WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 * General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License along
34 * with this program; if not, write to the Free Software Foundation, Inc.,
35 * 675 Mass Ave, Cambridge, MA 02139, USA.
36 */ 23 */
37 24
38 /* 25 /*
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index b05ba4929f00..edcf2be0e0eb 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Rio Karma 3 * Driver for Rio Karma
3 * 4 *
4 * (c) 2006 Bob Copeland <me@bobcopeland.com> 5 * (c) 2006 Bob Copeland <me@bobcopeland.com>
5 * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk> 6 * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 7 */
21 8
22#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index acc3d03d8c1e..39a5009a41a6 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Support for the Maxtor OneTouch USB hard drive's button 3 * Support for the Maxtor OneTouch USB hard drive's button
3 * 4 *
@@ -10,24 +11,6 @@
10 * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) 11 * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann)
11 * 12 *
12 */ 13 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31#include <linux/kernel.h> 14#include <linux/kernel.h>
32#include <linux/input.h> 15#include <linux/input.h>
33#include <linux/slab.h> 16#include <linux/slab.h>
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 57282f12317b..7c0b05a36554 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -1,23 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Option High Speed Mobile Devices. 3 * Driver for Option High Speed Mobile Devices.
3 * 4 *
4 * (c) 2008 Dan Williams <dcbw@redhat.com> 5 * (c) 2008 Dan Williams <dcbw@redhat.com>
5 * 6 *
6 * Inspiration taken from sierra_ms.c by Kevin Lloyd <klloyd@sierrawireless.com> 7 * Inspiration taken from sierra_ms.c by Kevin Lloyd <klloyd@sierrawireless.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 8 */
22 9
23#include <linux/usb.h> 10#include <linux/usb.h>
@@ -41,7 +28,7 @@ MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem (default),"
41 28
42static int option_rezero(struct us_data *us) 29static int option_rezero(struct us_data *us)
43{ 30{
44 const unsigned char rezero_msg[] = { 31 static const unsigned char rezero_msg[] = {
45 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12, 32 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
46 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01, 33 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -87,7 +74,7 @@ out:
87 74
88static int option_inquiry(struct us_data *us) 75static int option_inquiry(struct us_data *us)
89{ 76{
90 const unsigned char inquiry_msg[] = { 77 static const unsigned char inquiry_msg[] = {
91 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 78 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,
92 0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12, 79 0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,
93 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 80 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
index 74c38870a17e..f3f2a93f52e1 100644
--- a/drivers/usb/storage/protocol.c
+++ b/drivers/usb/storage/protocol.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * 4 *
@@ -27,20 +28,6 @@
27 * 28 *
28 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 29 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
29 * information about this driver. 30 * information about this driver.
30 *
31 * This program is free software; you can redistribute it and/or modify it
32 * under the terms of the GNU General Public License as published by the
33 * Free Software Foundation; either version 2, or (at your option) any
34 * later version.
35 *
36 * This program is distributed in the hope that it will be useful, but
37 * WITHOUT ANY WARRANTY; without even the implied warranty of
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 * General Public License for more details.
40 *
41 * You should have received a copy of the GNU General Public License along
42 * with this program; if not, write to the Free Software Foundation, Inc.,
43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */ 31 */
45 32
46#include <linux/highmem.h> 33#include <linux/highmem.h>
diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h
index a55666880b7b..9198396e8c6e 100644
--- a/drivers/usb/storage/protocol.h
+++ b/drivers/usb/storage/protocol.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Protocol Functions Header File 4 * Protocol Functions Header File
@@ -21,20 +22,6 @@
21 * 22 *
22 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 23 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
23 * information about this driver. 24 * information about this driver.
24 *
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2, or (at your option) any
28 * later version.
29 *
30 * This program is distributed in the hope that it will be useful, but
31 * WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License along
36 * with this program; if not, write to the Free Software Foundation, Inc.,
37 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 */ 25 */
39 26
40#ifndef _PROTOCOL_H_ 27#ifndef _PROTOCOL_H_
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index ec83b3b5efa9..48e2e32c97e8 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Realtek RTS51xx USB card reader 3 * Driver for Realtek RTS51xx USB card reader
3 * 4 *
4 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 5 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: 7 * Author:
20 * wwang (wei_wang@realsil.com.cn) 8 * wwang (wei_wang@realsil.com.cn)
21 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China 9 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 8cd2926fb1fe..585efd120193 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * SCSI layer glue code 4 * SCSI layer glue code
@@ -28,20 +29,6 @@
28 * 29 *
29 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 30 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
30 * information about this driver. 31 * information about this driver.
31 *
32 * This program is free software; you can redistribute it and/or modify it
33 * under the terms of the GNU General Public License as published by the
34 * Free Software Foundation; either version 2, or (at your option) any
35 * later version.
36 *
37 * This program is distributed in the hope that it will be useful, but
38 * WITHOUT ANY WARRANTY; without even the implied warranty of
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40 * General Public License for more details.
41 *
42 * You should have received a copy of the GNU General Public License along
43 * with this program; if not, write to the Free Software Foundation, Inc.,
44 * 675 Mass Ave, Cambridge, MA 02139, USA.
45 */ 32 */
46 33
47#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/usb/storage/scsiglue.h b/drivers/usb/storage/scsiglue.h
index d0a331dd9bc5..bf99c6201331 100644
--- a/drivers/usb/storage/scsiglue.h
+++ b/drivers/usb/storage/scsiglue.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * SCSI Connecting Glue Header File 4 * SCSI Connecting Glue Header File
@@ -21,20 +22,6 @@
21 * 22 *
22 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 23 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
23 * information about this driver. 24 * information about this driver.
24 *
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2, or (at your option) any
28 * later version.
29 *
30 * This program is distributed in the hope that it will be useful, but
31 * WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License along
36 * with this program; if not, write to the Free Software Foundation, Inc.,
37 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 */ 25 */
39 26
40#ifndef _SCSIGLUE_H_ 27#ifndef _SCSIGLUE_H_
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 44f8ffccd031..1cf7dbfe277c 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SanDisk SDDR-09 SmartMedia reader 3 * Driver for SanDisk SDDR-09 SmartMedia reader
3 * 4 *
@@ -11,20 +12,6 @@
11 * been programmed to obey a certain limited set of SCSI commands. 12 * been programmed to obey a certain limited set of SCSI commands.
12 * This driver translates the "real" SCSI commands to the SDDR-09 SCSI 13 * This driver translates the "real" SCSI commands to the SDDR-09 SCSI
13 * commands. 14 * commands.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2, or (at your option) any
18 * later version.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 15 */
29 16
30/* 17/*
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index 147c50b3e00f..8c814b2ec9b2 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SanDisk SDDR-55 SmartMedia reader 3 * Driver for SanDisk SDDR-55 SmartMedia reader
3 * 4 *
@@ -7,20 +8,6 @@
7 * 8 *
8 * Current development and maintenance by: 9 * Current development and maintenance by:
9 * (c) 2002 Simon Munton 10 * (c) 2002 Simon Munton
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2, or (at your option) any
14 * later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 11 */
25 12
26#include <linux/jiffies.h> 13#include <linux/jiffies.h>
@@ -604,6 +591,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) {
604 case 0x64: 591 case 0x64:
605 info->pageshift = 8; 592 info->pageshift = 8;
606 info->smallpageshift = 1; 593 info->smallpageshift = 1;
594 /* fall through */
607 case 0x5d: // 5d is a ROM card with pagesize 512. 595 case 0x5d: // 5d is a ROM card with pagesize 512.
608 return 0x00200000; 596 return 0x00200000;
609 597
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 3b0294e4df93..854498e1012c 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable 3 * Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable
3 * 4 *
@@ -26,20 +27,6 @@
26 * 27 *
27 * See the Kconfig help text for a list of devices known to be supported by 28 * See the Kconfig help text for a list of devices known to be supported by
28 * this driver. 29 * this driver.
29 *
30 * This program is free software; you can redistribute it and/or modify it
31 * under the terms of the GNU General Public License as published by the
32 * Free Software Foundation; either version 2, or (at your option) any
33 * later version.
34 *
35 * This program is distributed in the hope that it will be useful, but
36 * WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 * General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License along
41 * with this program; if not, write to the Free Software Foundation, Inc.,
42 * 675 Mass Ave, Cambridge, MA 02139, USA.
43 */ 30 */
44 31
45#include <linux/errno.h> 32#include <linux/errno.h>
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index a3ccb899df60..d947957f3635 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * 4 *
@@ -28,20 +29,6 @@
28 * 29 *
29 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 30 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
30 * information about this driver. 31 * information about this driver.
31 *
32 * This program is free software; you can redistribute it and/or modify it
33 * under the terms of the GNU General Public License as published by the
34 * Free Software Foundation; either version 2, or (at your option) any
35 * later version.
36 *
37 * This program is distributed in the hope that it will be useful, but
38 * WITHOUT ANY WARRANTY; without even the implied warranty of
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40 * General Public License for more details.
41 *
42 * You should have received a copy of the GNU General Public License along
43 * with this program; if not, write to the Free Software Foundation, Inc.,
44 * 675 Mass Ave, Cambridge, MA 02139, USA.
45 */ 32 */
46 33
47#include <linux/sched.h> 34#include <linux/sched.h>
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index dae3ecd2e6cf..f559dc575f4f 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Transport Functions Header File 4 * Transport Functions Header File
@@ -21,20 +22,6 @@
21 * 22 *
22 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 23 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
23 * information about this driver. 24 * information about this driver.
24 *
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2, or (at your option) any
28 * later version.
29 *
30 * This program is distributed in the hope that it will be useful, but
31 * WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License along
36 * with this program; if not, write to the Free Software Foundation, Inc.,
37 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 */ 25 */
39 26
40#ifndef _TRANSPORT_H_ 27#ifndef _TRANSPORT_H_
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 63cf981ed81c..5d04c40ee40a 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Attached SCSI 3 * USB Attached SCSI
3 * Note that this is not the same as the USB Mass Storage driver 4 * Note that this is not the same as the USB Mass Storage driver
@@ -5,8 +6,6 @@
5 * Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2016 6 * Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2016
6 * Copyright Matthew Wilcox for Intel Corp, 2010 7 * Copyright Matthew Wilcox for Intel Corp, 2010
7 * Copyright Sarah Sharp for Intel Corp, 2010 8 * Copyright Sarah Sharp for Intel Corp, 2010
8 *
9 * Distributed under the terms of the GNU GPL, version two.
10 */ 9 */
11 10
12#include <linux/blkdev.h> 11#include <linux/blkdev.h>
@@ -668,6 +667,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
668 break; 667 break;
669 case DMA_BIDIRECTIONAL: 668 case DMA_BIDIRECTIONAL:
670 cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB; 669 cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
670 /* fall through */
671 case DMA_TO_DEVICE: 671 case DMA_TO_DEVICE:
672 cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB; 672 cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB;
673 case DMA_NONE: 673 case DMA_NONE:
diff --git a/drivers/usb/storage/unusual_alauda.h b/drivers/usb/storage/unusual_alauda.h
index 763bc03032a1..0ec8c99a4976 100644
--- a/drivers/usb/storage/unusual_alauda.h
+++ b/drivers/usb/storage/unusual_alauda.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Alauda-based card readers 3 * Unusual Devices File for the Alauda-based card readers
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_ALAUDA) || \ 6#if defined(CONFIG_USB_STORAGE_ALAUDA) || \
diff --git a/drivers/usb/storage/unusual_cypress.h b/drivers/usb/storage/unusual_cypress.h
index e9a2eb88869a..fb99e526cd48 100644
--- a/drivers/usb/storage/unusual_cypress.h
+++ b/drivers/usb/storage/unusual_cypress.h
@@ -1,20 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for devices based on the Cypress USB/ATA bridge 3 * Unusual Devices File for devices based on the Cypress USB/ATA bridge
3 * with support for ATACB 4 * with support for ATACB
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 5 */
19 6
20#if defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || \ 7#if defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || \
diff --git a/drivers/usb/storage/unusual_datafab.h b/drivers/usb/storage/unusual_datafab.h
index 5049b6bbe5d5..fdab5e7d68ca 100644
--- a/drivers/usb/storage/unusual_datafab.h
+++ b/drivers/usb/storage/unusual_datafab.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Datafab USB Compact Flash reader 3 * Unusual Devices File for the Datafab USB Compact Flash reader
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_DATAFAB) || \ 6#if defined(CONFIG_USB_STORAGE_DATAFAB) || \
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index eb06d88b41d6..2968046e7c05 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Unusual Devices File 4 * Unusual Devices File
@@ -10,20 +11,6 @@
10 * 11 *
11 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 12 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
12 * information about this driver. 13 * information about this driver.
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2, or (at your option) any
17 * later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 14 */
28 15
29/* 16/*
diff --git a/drivers/usb/storage/unusual_ene_ub6250.h b/drivers/usb/storage/unusual_ene_ub6250.h
index 5667f5d365c6..9134b91fbd73 100644
--- a/drivers/usb/storage/unusual_ene_ub6250.h
+++ b/drivers/usb/storage/unusual_ene_ub6250.h
@@ -1,20 +1,4 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the
5 * Free Software Foundation; either version 2, or (at your option) any
6 * later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#if defined(CONFIG_USB_STORAGE_ENE_UB6250) || \ 2#if defined(CONFIG_USB_STORAGE_ENE_UB6250) || \
19 defined(CONFIG_USB_STORAGE_ENE_UB6250_MODULE) 3 defined(CONFIG_USB_STORAGE_ENE_UB6250_MODULE)
20 4
diff --git a/drivers/usb/storage/unusual_freecom.h b/drivers/usb/storage/unusual_freecom.h
index 1f5aab42ece2..949231c7a36b 100644
--- a/drivers/usb/storage/unusual_freecom.h
+++ b/drivers/usb/storage/unusual_freecom.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Freecom USB/IDE adaptor 3 * Unusual Devices File for the Freecom USB/IDE adaptor
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_FREECOM) || \ 6#if defined(CONFIG_USB_STORAGE_FREECOM) || \
diff --git a/drivers/usb/storage/unusual_isd200.h b/drivers/usb/storage/unusual_isd200.h
index 9b6862ec3d4f..d03a02cc904e 100644
--- a/drivers/usb/storage/unusual_isd200.h
+++ b/drivers/usb/storage/unusual_isd200.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for In-System Design, Inc. ISD200 ASIC 3 * Unusual Devices File for In-System Design, Inc. ISD200 ASIC
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_ISD200) || \ 6#if defined(CONFIG_USB_STORAGE_ISD200) || \
diff --git a/drivers/usb/storage/unusual_jumpshot.h b/drivers/usb/storage/unusual_jumpshot.h
index 413e64fa6b95..c323338881ef 100644
--- a/drivers/usb/storage/unusual_jumpshot.h
+++ b/drivers/usb/storage/unusual_jumpshot.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Lexar "Jumpshot" Compact Flash reader 3 * Unusual Devices File for the Lexar "Jumpshot" Compact Flash reader
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_JUMPSHOT) || \ 6#if defined(CONFIG_USB_STORAGE_JUMPSHOT) || \
diff --git a/drivers/usb/storage/unusual_karma.h b/drivers/usb/storage/unusual_karma.h
index e6fad3aeae20..8f1eebd71d2c 100644
--- a/drivers/usb/storage/unusual_karma.h
+++ b/drivers/usb/storage/unusual_karma.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Rio Karma 3 * Unusual Devices File for the Rio Karma
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_KARMA) || \ 6#if defined(CONFIG_USB_STORAGE_KARMA) || \
diff --git a/drivers/usb/storage/unusual_onetouch.h b/drivers/usb/storage/unusual_onetouch.h
index 425dc22f345a..c76d4e990f7b 100644
--- a/drivers/usb/storage/unusual_onetouch.h
+++ b/drivers/usb/storage/unusual_onetouch.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for the Maxtor OneTouch USB hard drive's button 3 * Unusual Devices File for the Maxtor OneTouch USB hard drive's button
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_ONETOUCH) || \ 6#if defined(CONFIG_USB_STORAGE_ONETOUCH) || \
diff --git a/drivers/usb/storage/unusual_realtek.h b/drivers/usb/storage/unusual_realtek.h
index 8fe624ad302a..d17cd95b55bb 100644
--- a/drivers/usb/storage/unusual_realtek.h
+++ b/drivers/usb/storage/unusual_realtek.h
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for Realtek RTS51xx USB card reader 3 * Driver for Realtek RTS51xx USB card reader
3 * 4 *
4 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 5 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: 7 * Author:
20 * wwang (wei_wang@realsil.com.cn) 8 * wwang (wei_wang@realsil.com.cn)
21 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China 9 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
diff --git a/drivers/usb/storage/unusual_sddr09.h b/drivers/usb/storage/unusual_sddr09.h
index d9d38ac4abf9..650cf2862754 100644
--- a/drivers/usb/storage/unusual_sddr09.h
+++ b/drivers/usb/storage/unusual_sddr09.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for SanDisk SDDR-09 SmartMedia reader 3 * Unusual Devices File for SanDisk SDDR-09 SmartMedia reader
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_SDDR09) || \ 6#if defined(CONFIG_USB_STORAGE_SDDR09) || \
diff --git a/drivers/usb/storage/unusual_sddr55.h b/drivers/usb/storage/unusual_sddr55.h
index ebb1d1c6c467..e89df2cea7bd 100644
--- a/drivers/usb/storage/unusual_sddr55.h
+++ b/drivers/usb/storage/unusual_sddr55.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for SanDisk SDDR-55 SmartMedia reader 3 * Unusual Devices File for SanDisk SDDR-55 SmartMedia reader
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_SDDR55) || \ 6#if defined(CONFIG_USB_STORAGE_SDDR55) || \
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index cde115359793..d520374a824e 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Attached SCSI devices - Unusual Devices File 3 * Driver for USB Attached SCSI devices - Unusual Devices File
3 * 4 *
@@ -6,20 +7,6 @@
6 * Based on the same file for the usb-storage driver, which is: 7 * Based on the same file for the usb-storage driver, which is:
7 * (c) 2000-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) 8 * (c) 2000-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
8 * (c) 2000 Adam J. Richter (adam@yggdrasil.com), Yggdrasil Computing, Inc. 9 * (c) 2000 Adam J. Richter (adam@yggdrasil.com), Yggdrasil Computing, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2, or (at your option) any
13 * later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 10 */
24 11
25/* 12/*
diff --git a/drivers/usb/storage/unusual_usbat.h b/drivers/usb/storage/unusual_usbat.h
index 2044ad5ef5e4..05abf6870b8f 100644
--- a/drivers/usb/storage/unusual_usbat.h
+++ b/drivers/usb/storage/unusual_usbat.h
@@ -1,19 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable 3 * Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 4 */
18 5
19#if defined(CONFIG_USB_STORAGE_USBAT) || \ 6#if defined(CONFIG_USB_STORAGE_USBAT) || \
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 0dceb9fa3a06..a0c07e05a8f1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * 4 *
@@ -30,20 +31,6 @@
30 * 31 *
31 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 32 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
32 * information about this driver. 33 * information about this driver.
33 *
34 * This program is free software; you can redistribute it and/or modify it
35 * under the terms of the GNU General Public License as published by the
36 * Free Software Foundation; either version 2, or (at your option) any
37 * later version.
38 *
39 * This program is distributed in the hope that it will be useful, but
40 * WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 * General Public License for more details.
43 *
44 * You should have received a copy of the GNU General Public License along
45 * with this program; if not, write to the Free Software Foundation, Inc.,
46 * 675 Mass Ave, Cambridge, MA 02139, USA.
47 */ 34 */
48 35
49#ifdef CONFIG_USB_STORAGE_DEBUG 36#ifdef CONFIG_USB_STORAGE_DEBUG
@@ -332,7 +319,7 @@ static int usb_stor_control_thread(void * __us)
332 319
333 /* When we are called with no command pending, we're done */ 320 /* When we are called with no command pending, we're done */
334 srb = us->srb; 321 srb = us->srb;
335 if (us->srb == NULL) { 322 if (srb == NULL) {
336 scsi_unlock(host); 323 scsi_unlock(host);
337 mutex_unlock(&us->dev_mutex); 324 mutex_unlock(&us->dev_mutex);
338 usb_stor_dbg(us, "-- exiting\n"); 325 usb_stor_dbg(us, "-- exiting\n");
@@ -341,7 +328,7 @@ static int usb_stor_control_thread(void * __us)
341 328
342 /* has the command timed out *already* ? */ 329 /* has the command timed out *already* ? */
343 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 330 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
344 us->srb->result = DID_ABORT << 16; 331 srb->result = DID_ABORT << 16;
345 goto SkipForAbort; 332 goto SkipForAbort;
346 } 333 }
347 334
@@ -351,35 +338,35 @@ static int usb_stor_control_thread(void * __us)
351 * reject the command if the direction indicator 338 * reject the command if the direction indicator
352 * is UNKNOWN 339 * is UNKNOWN
353 */ 340 */
354 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { 341 if (srb->sc_data_direction == DMA_BIDIRECTIONAL) {
355 usb_stor_dbg(us, "UNKNOWN data direction\n"); 342 usb_stor_dbg(us, "UNKNOWN data direction\n");
356 us->srb->result = DID_ERROR << 16; 343 srb->result = DID_ERROR << 16;
357 } 344 }
358 345
359 /* 346 /*
360 * reject if target != 0 or if LUN is higher than 347 * reject if target != 0 or if LUN is higher than
361 * the maximum known LUN 348 * the maximum known LUN
362 */ 349 */
363 else if (us->srb->device->id && 350 else if (srb->device->id &&
364 !(us->fflags & US_FL_SCM_MULT_TARG)) { 351 !(us->fflags & US_FL_SCM_MULT_TARG)) {
365 usb_stor_dbg(us, "Bad target number (%d:%llu)\n", 352 usb_stor_dbg(us, "Bad target number (%d:%llu)\n",
366 us->srb->device->id, 353 srb->device->id,
367 us->srb->device->lun); 354 srb->device->lun);
368 us->srb->result = DID_BAD_TARGET << 16; 355 srb->result = DID_BAD_TARGET << 16;
369 } 356 }
370 357
371 else if (us->srb->device->lun > us->max_lun) { 358 else if (srb->device->lun > us->max_lun) {
372 usb_stor_dbg(us, "Bad LUN (%d:%llu)\n", 359 usb_stor_dbg(us, "Bad LUN (%d:%llu)\n",
373 us->srb->device->id, 360 srb->device->id,
374 us->srb->device->lun); 361 srb->device->lun);
375 us->srb->result = DID_BAD_TARGET << 16; 362 srb->result = DID_BAD_TARGET << 16;
376 } 363 }
377 364
378 /* 365 /*
379 * Handle those devices which need us to fake 366 * Handle those devices which need us to fake
380 * their inquiry data 367 * their inquiry data
381 */ 368 */
382 else if ((us->srb->cmnd[0] == INQUIRY) && 369 else if ((srb->cmnd[0] == INQUIRY) &&
383 (us->fflags & US_FL_FIX_INQUIRY)) { 370 (us->fflags & US_FL_FIX_INQUIRY)) {
384 unsigned char data_ptr[36] = { 371 unsigned char data_ptr[36] = {
385 0x00, 0x80, 0x02, 0x02, 372 0x00, 0x80, 0x02, 0x02,
@@ -387,13 +374,13 @@ static int usb_stor_control_thread(void * __us)
387 374
388 usb_stor_dbg(us, "Faking INQUIRY command\n"); 375 usb_stor_dbg(us, "Faking INQUIRY command\n");
389 fill_inquiry_response(us, data_ptr, 36); 376 fill_inquiry_response(us, data_ptr, 36);
390 us->srb->result = SAM_STAT_GOOD; 377 srb->result = SAM_STAT_GOOD;
391 } 378 }
392 379
393 /* we've got a command, let's do it! */ 380 /* we've got a command, let's do it! */
394 else { 381 else {
395 US_DEBUG(usb_stor_show_command(us, us->srb)); 382 US_DEBUG(usb_stor_show_command(us, srb));
396 us->proto_handler(us->srb, us); 383 us->proto_handler(srb, us);
397 usb_mark_last_busy(us->pusb_dev); 384 usb_mark_last_busy(us->pusb_dev);
398 } 385 }
399 386
@@ -401,7 +388,7 @@ static int usb_stor_control_thread(void * __us)
401 scsi_lock(host); 388 scsi_lock(host);
402 389
403 /* was the command aborted? */ 390 /* was the command aborted? */
404 if (us->srb->result == DID_ABORT << 16) { 391 if (srb->result == DID_ABORT << 16) {
405SkipForAbort: 392SkipForAbort:
406 usb_stor_dbg(us, "scsi command aborted\n"); 393 usb_stor_dbg(us, "scsi command aborted\n");
407 srb = NULL; /* Don't call srb->scsi_done() */ 394 srb = NULL; /* Don't call srb->scsi_done() */
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 8fae28b40bb4..90133e16bec5 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage compliant devices 3 * Driver for USB Mass Storage compliant devices
3 * Main Header File 4 * Main Header File
@@ -24,20 +25,6 @@
24 * 25 *
25 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 26 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
26 * information about this driver. 27 * information about this driver.
27 *
28 * This program is free software; you can redistribute it and/or modify it
29 * under the terms of the GNU General Public License as published by the
30 * Free Software Foundation; either version 2, or (at your option) any
31 * later version.
32 *
33 * This program is distributed in the hope that it will be useful, but
34 * WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 * General Public License for more details.
37 *
38 * You should have received a copy of the GNU General Public License along
39 * with this program; if not, write to the Free Software Foundation, Inc.,
40 * 675 Mass Ave, Cambridge, MA 02139, USA.
41 */ 28 */
42 29
43#ifndef _USB_H_ 30#ifndef _USB_H_
diff --git a/drivers/usb/storage/usual-tables.c b/drivers/usb/storage/usual-tables.c
index 499669bcf700..83ad01747eed 100644
--- a/drivers/usb/storage/usual-tables.c
+++ b/drivers/usb/storage/usual-tables.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Driver for USB Mass Storage devices 3 * Driver for USB Mass Storage devices
3 * Usual Tables File for usb-storage and libusual 4 * Usual Tables File for usb-storage and libusual
@@ -6,20 +7,6 @@
6 * 7 *
7 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more 8 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
8 * information about this driver. 9 * information about this driver.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2, or (at your option) any
13 * later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 10 */
24 11
25#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 819c0ed2b200..465d7da849c3 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -16,8 +16,6 @@ if TYPEC_TCPM
16 16
17source "drivers/usb/typec/fusb302/Kconfig" 17source "drivers/usb/typec/fusb302/Kconfig"
18 18
19endif
20
21config TYPEC_WCOVE 19config TYPEC_WCOVE
22 tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver" 20 tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver"
23 depends on ACPI 21 depends on ACPI
@@ -33,6 +31,19 @@ config TYPEC_WCOVE
33 To compile this driver as module, choose M here: the module will be 31 To compile this driver as module, choose M here: the module will be
34 called typec_wcove 32 called typec_wcove
35 33
34endif
35
36source "drivers/usb/typec/ucsi/Kconfig" 36source "drivers/usb/typec/ucsi/Kconfig"
37 37
38config TYPEC_TPS6598X
39 tristate "TI TPS6598x USB Power Delivery controller driver"
40 depends on I2C
41 select TYPEC
42 help
43 Say Y or M here if your system has TI TPS65982 or TPS65983 USB Power
44 Delivery controller.
45
46 If you choose to build this driver as a dynamically linked module, the
47 module will be called tps6598x.ko.
48
38endmenu 49endmenu
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index b77688ce1f16..bb3138a6eaac 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,5 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_TYPEC) += typec.o 2obj-$(CONFIG_TYPEC) += typec.o
2obj-$(CONFIG_TYPEC_TCPM) += tcpm.o 3obj-$(CONFIG_TYPEC_TCPM) += tcpm.o
3obj-y += fusb302/ 4obj-y += fusb302/
4obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o 5obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o
5obj-$(CONFIG_TYPEC_UCSI) += ucsi/ 6obj-$(CONFIG_TYPEC_UCSI) += ucsi/
7obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o
diff --git a/drivers/usb/typec/fusb302/Makefile b/drivers/usb/typec/fusb302/Makefile
index 207efa5fbab8..3b51b33631a0 100644
--- a/drivers/usb/typec/fusb302/Makefile
+++ b/drivers/usb/typec/fusb302/Makefile
@@ -1 +1,2 @@
1# SPDX-License-Identifier: GPL-2.0
1obj-$(CONFIG_TYPEC_FUSB302) += fusb302.o 2obj-$(CONFIG_TYPEC_FUSB302) += fusb302.o
diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index e790b67d4953..72cb060b3fca 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -1,16 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2016-2017 Google, Inc 3 * Copyright 2016-2017 Google, Inc
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * Fairchild FUSB302 Type-C Chip Driver 5 * Fairchild FUSB302 Type-C Chip Driver
15 */ 6 */
16 7
diff --git a/drivers/usb/typec/fusb302/fusb302_reg.h b/drivers/usb/typec/fusb302/fusb302_reg.h
index 0682e63de773..00b39d365478 100644
--- a/drivers/usb/typec/fusb302/fusb302_reg.h
+++ b/drivers/usb/typec/fusb302/fusb302_reg.h
@@ -1,16 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2016-2017 Google, Inc 3 * Copyright 2016-2017 Google, Inc
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * Fairchild FUSB302 Type-C Chip Driver 5 * Fairchild FUSB302 Type-C Chip Driver
15 */ 6 */
16 7
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index f557c479fdc2..c166fc77dfb8 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -1,16 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright 2015-2017 Google, Inc 3 * Copyright 2015-2017 Google, Inc
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * USB Power Delivery protocol stack. 5 * USB Power Delivery protocol stack.
15 */ 6 */
16 7
@@ -986,7 +977,7 @@ static void svdm_consume_modes(struct tcpm_port *port, const __le32 *payload,
986 } 977 }
987 port->partner_altmode[pmdata->altmodes] = 978 port->partner_altmode[pmdata->altmodes] =
988 typec_partner_register_altmode(port->partner, paltmode); 979 typec_partner_register_altmode(port->partner, paltmode);
989 if (port->partner_altmode[pmdata->altmodes] == NULL) { 980 if (!port->partner_altmode[pmdata->altmodes]) {
990 tcpm_log(port, 981 tcpm_log(port,
991 "Failed to register alternate modes for SVID 0x%04x", 982 "Failed to register alternate modes for SVID 0x%04x",
992 paltmode->svid); 983 paltmode->svid);
@@ -3602,6 +3593,7 @@ void tcpm_unregister_port(struct tcpm_port *port)
3602{ 3593{
3603 int i; 3594 int i;
3604 3595
3596 tcpm_reset_port(port);
3605 for (i = 0; i < ARRAY_SIZE(port->port_altmode); i++) 3597 for (i = 0; i < ARRAY_SIZE(port->port_altmode); i++)
3606 typec_unregister_altmode(port->port_altmode[i]); 3598 typec_unregister_altmode(port->port_altmode[i]);
3607 typec_unregister_port(port->typec_port); 3599 typec_unregister_port(port->typec_port);
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
new file mode 100644
index 000000000000..2719f5d382f7
--- /dev/null
+++ b/drivers/usb/typec/tps6598x.c
@@ -0,0 +1,473 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Driver for TI TPS6598x USB Power Delivery controller family
4 *
5 * Copyright (C) 2017, Intel Corporation
6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
7 */
8
9#include <linux/i2c.h>
10#include <linux/acpi.h>
11#include <linux/module.h>
12#include <linux/regmap.h>
13#include <linux/interrupt.h>
14#include <linux/usb/typec.h>
15
16/* Register offsets */
17#define TPS_REG_CMD1 0x08
18#define TPS_REG_DATA1 0x09
19#define TPS_REG_INT_EVENT1 0x14
20#define TPS_REG_INT_EVENT2 0x15
21#define TPS_REG_INT_MASK1 0x16
22#define TPS_REG_INT_MASK2 0x17
23#define TPS_REG_INT_CLEAR1 0x18
24#define TPS_REG_INT_CLEAR2 0x19
25#define TPS_REG_STATUS 0x1a
26#define TPS_REG_SYSTEM_CONF 0x28
27#define TPS_REG_CTRL_CONF 0x29
28#define TPS_REG_POWER_STATUS 0x3f
29#define TPS_REG_RX_IDENTITY_SOP 0x48
30
31/* TPS_REG_INT_* bits */
32#define TPS_REG_INT_PLUG_EVENT BIT(3)
33
34/* TPS_REG_STATUS bits */
35#define TPS_STATUS_PLUG_PRESENT BIT(0)
36#define TPS_STATUS_ORIENTATION BIT(4)
37#define TPS_STATUS_PORTROLE(s) (!!((s) & BIT(5)))
38#define TPS_STATUS_DATAROLE(s) (!!((s) & BIT(6)))
39#define TPS_STATUS_VCONN(s) (!!((s) & BIT(7)))
40
41/* TPS_REG_SYSTEM_CONF bits */
42#define TPS_SYSCONF_PORTINFO(c) ((c) & 3)
43
44enum {
45 TPS_PORTINFO_SINK,
46 TPS_PORTINFO_SINK_ACCESSORY,
47 TPS_PORTINFO_DRP_UFP,
48 TPS_PORTINFO_DRP_UFP_DRD,
49 TPS_PORTINFO_DRP_DFP,
50 TPS_PORTINFO_DRP_DFP_DRD,
51 TPS_PORTINFO_SOURCE,
52};
53
54/* TPS_REG_POWER_STATUS bits */
55#define TPS_POWER_STATUS_SOURCESINK BIT(1)
56#define TPS_POWER_STATUS_PWROPMODE(p) (((p) & GENMASK(3, 2)) >> 2)
57
58/* TPS_REG_RX_IDENTITY_SOP */
59struct tps6598x_rx_identity_reg {
60 u8 status;
61 struct usb_pd_identity identity;
62 u32 vdo[3];
63} __packed;
64
65/* Standard Task return codes */
66#define TPS_TASK_TIMEOUT 1
67#define TPS_TASK_REJECTED 3
68
69/* Unrecognized commands will be replaced with "!CMD" */
70#define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321)
71
72struct tps6598x {
73 struct device *dev;
74 struct regmap *regmap;
75 struct mutex lock; /* device lock */
76
77 struct typec_port *port;
78 struct typec_partner *partner;
79 struct usb_pd_identity partner_identity;
80 struct typec_capability typec_cap;
81};
82
83static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val)
84{
85 return regmap_raw_read(tps->regmap, reg, val, sizeof(u16));
86}
87
88static inline int tps6598x_read32(struct tps6598x *tps, u8 reg, u32 *val)
89{
90 return regmap_raw_read(tps->regmap, reg, val, sizeof(u32));
91}
92
93static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val)
94{
95 return regmap_raw_read(tps->regmap, reg, val, sizeof(u64));
96}
97
98static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val)
99{
100 return regmap_raw_write(tps->regmap, reg, &val, sizeof(u16));
101}
102
103static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val)
104{
105 return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
106}
107
108static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
109{
110 return regmap_raw_write(tps->regmap, reg, &val, sizeof(u64));
111}
112
113static inline int
114tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
115{
116 return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32));
117}
118
119static int tps6598x_read_partner_identity(struct tps6598x *tps)
120{
121 struct tps6598x_rx_identity_reg id;
122 int ret;
123
124 ret = regmap_raw_read(tps->regmap, TPS_REG_RX_IDENTITY_SOP,
125 &id, sizeof(id));
126 if (ret)
127 return ret;
128
129 tps->partner_identity = id.identity;
130
131 return 0;
132}
133
134static int tps6598x_connect(struct tps6598x *tps, u32 status)
135{
136 struct typec_partner_desc desc;
137 enum typec_pwr_opmode mode;
138 u16 pwr_status;
139 int ret;
140
141 if (tps->partner)
142 return 0;
143
144 ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status);
145 if (ret < 0)
146 return ret;
147
148 mode = TPS_POWER_STATUS_PWROPMODE(pwr_status);
149
150 desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
151 desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
152 desc.identity = NULL;
153
154 if (desc.usb_pd) {
155 ret = tps6598x_read_partner_identity(tps);
156 if (ret)
157 return ret;
158 desc.identity = &tps->partner_identity;
159 }
160
161 tps->partner = typec_register_partner(tps->port, &desc);
162 if (!tps->partner)
163 return -ENODEV;
164
165 typec_set_pwr_opmode(tps->port, mode);
166 typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
167 typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
168 typec_set_data_role(tps->port, TPS_STATUS_DATAROLE(status));
169
170 if (desc.identity)
171 typec_partner_set_identity(tps->partner);
172
173 return 0;
174}
175
176static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
177{
178 typec_unregister_partner(tps->partner);
179 tps->partner = NULL;
180 typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
181 typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
182 typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
183 typec_set_data_role(tps->port, TPS_STATUS_DATAROLE(status));
184}
185
186static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
187 size_t in_len, u8 *in_data,
188 size_t out_len, u8 *out_data)
189{
190 unsigned long timeout;
191 u32 val;
192 int ret;
193
194 ret = tps6598x_read32(tps, TPS_REG_CMD1, &val);
195 if (ret)
196 return ret;
197 if (val && !INVALID_CMD(val))
198 return -EBUSY;
199
200 if (in_len) {
201 ret = regmap_raw_write(tps->regmap, TPS_REG_DATA1,
202 in_data, in_len);
203 if (ret)
204 return ret;
205 }
206
207 ret = tps6598x_write_4cc(tps, TPS_REG_CMD1, cmd);
208 if (ret < 0)
209 return ret;
210
211 /* XXX: Using 1s for now, but it may not be enough for every command. */
212 timeout = jiffies + msecs_to_jiffies(1000);
213
214 do {
215 ret = tps6598x_read32(tps, TPS_REG_CMD1, &val);
216 if (ret)
217 return ret;
218 if (INVALID_CMD(val))
219 return -EINVAL;
220
221 if (time_is_before_jiffies(timeout))
222 return -ETIMEDOUT;
223 } while (val);
224
225 if (out_len) {
226 ret = regmap_raw_read(tps->regmap, TPS_REG_DATA1,
227 out_data, out_len);
228 if (ret)
229 return ret;
230 val = out_data[0];
231 } else {
232 ret = regmap_read(tps->regmap, TPS_REG_DATA1, &val);
233 if (ret)
234 return ret;
235 }
236
237 switch (val) {
238 case TPS_TASK_TIMEOUT:
239 return -ETIMEDOUT;
240 case TPS_TASK_REJECTED:
241 return -EPERM;
242 default:
243 break;
244 }
245
246 return 0;
247}
248
249static int
250tps6598x_dr_set(const struct typec_capability *cap, enum typec_data_role role)
251{
252 struct tps6598x *tps = container_of(cap, struct tps6598x, typec_cap);
253 const char *cmd = (role == TYPEC_DEVICE) ? "SWUF" : "SWDF";
254 u32 status;
255 int ret;
256
257 mutex_lock(&tps->lock);
258
259 ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL);
260 if (ret)
261 goto out_unlock;
262
263 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
264 if (ret)
265 goto out_unlock;
266
267 if (role != TPS_STATUS_DATAROLE(status)) {
268 ret = -EPROTO;
269 goto out_unlock;
270 }
271
272 typec_set_data_role(tps->port, role);
273
274out_unlock:
275 mutex_unlock(&tps->lock);
276
277 return ret;
278}
279
280static int
281tps6598x_pr_set(const struct typec_capability *cap, enum typec_role role)
282{
283 struct tps6598x *tps = container_of(cap, struct tps6598x, typec_cap);
284 const char *cmd = (role == TYPEC_SINK) ? "SWSk" : "SWSr";
285 u32 status;
286 int ret;
287
288 mutex_lock(&tps->lock);
289
290 ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL);
291 if (ret)
292 goto out_unlock;
293
294 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
295 if (ret)
296 goto out_unlock;
297
298 if (role != TPS_STATUS_PORTROLE(status)) {
299 ret = -EPROTO;
300 goto out_unlock;
301 }
302
303 typec_set_pwr_role(tps->port, role);
304
305out_unlock:
306 mutex_unlock(&tps->lock);
307
308 return ret;
309}
310
311static irqreturn_t tps6598x_interrupt(int irq, void *data)
312{
313 struct tps6598x *tps = data;
314 u64 event1;
315 u64 event2;
316 u32 status;
317 int ret;
318
319 mutex_lock(&tps->lock);
320
321 ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1);
322 ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2);
323 if (ret) {
324 dev_err(tps->dev, "%s: failed to read events\n", __func__);
325 goto err_unlock;
326 }
327
328 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
329 if (ret) {
330 dev_err(tps->dev, "%s: failed to read status\n", __func__);
331 goto err_clear_ints;
332 }
333
334 /* Handle plug insert or removal */
335 if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
336 if (status & TPS_STATUS_PLUG_PRESENT) {
337 ret = tps6598x_connect(tps, status);
338 if (ret)
339 dev_err(tps->dev,
340 "failed to register partner\n");
341 } else {
342 tps6598x_disconnect(tps, status);
343 }
344 }
345
346err_clear_ints:
347 tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1);
348 tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2);
349
350err_unlock:
351 mutex_unlock(&tps->lock);
352
353 return IRQ_HANDLED;
354}
355
356static const struct regmap_config tps6598x_regmap_config = {
357 .reg_bits = 8,
358 .val_bits = 8,
359 .max_register = 0x7F,
360};
361
362static int tps6598x_probe(struct i2c_client *client)
363{
364 struct tps6598x *tps;
365 u32 status;
366 u32 conf;
367 u32 vid;
368 int ret;
369
370 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
371 if (!tps)
372 return -ENOMEM;
373
374 mutex_init(&tps->lock);
375 tps->dev = &client->dev;
376
377 tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config);
378 if (IS_ERR(tps->regmap))
379 return PTR_ERR(tps->regmap);
380
381 ret = tps6598x_read32(tps, 0, &vid);
382 if (ret < 0)
383 return ret;
384 if (!vid)
385 return -ENODEV;
386
387 ret = tps6598x_read32(tps, TPS_REG_STATUS, &status);
388 if (ret < 0)
389 return ret;
390
391 ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf);
392 if (ret < 0)
393 return ret;
394
395 switch (TPS_SYSCONF_PORTINFO(conf)) {
396 case TPS_PORTINFO_SINK_ACCESSORY:
397 case TPS_PORTINFO_SINK:
398 tps->typec_cap.type = TYPEC_PORT_UFP;
399 break;
400 case TPS_PORTINFO_DRP_UFP_DRD:
401 case TPS_PORTINFO_DRP_DFP_DRD:
402 tps->typec_cap.dr_set = tps6598x_dr_set;
403 /* fall through */
404 case TPS_PORTINFO_DRP_UFP:
405 case TPS_PORTINFO_DRP_DFP:
406 tps->typec_cap.pr_set = tps6598x_pr_set;
407 tps->typec_cap.type = TYPEC_PORT_DRP;
408 break;
409 case TPS_PORTINFO_SOURCE:
410 tps->typec_cap.type = TYPEC_PORT_DFP;
411 break;
412 default:
413 return -ENODEV;
414 }
415
416 tps->typec_cap.revision = USB_TYPEC_REV_1_2;
417 tps->typec_cap.pd_revision = 0x200;
418 tps->typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
419
420 tps->port = typec_register_port(&client->dev, &tps->typec_cap);
421 if (!tps->port)
422 return -ENODEV;
423
424 if (status & TPS_STATUS_PLUG_PRESENT) {
425 ret = tps6598x_connect(tps, status);
426 if (ret)
427 dev_err(&client->dev, "failed to register partner\n");
428 }
429
430 ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
431 tps6598x_interrupt,
432 IRQF_SHARED | IRQF_ONESHOT,
433 dev_name(&client->dev), tps);
434 if (ret) {
435 tps6598x_disconnect(tps, 0);
436 typec_unregister_port(tps->port);
437 return ret;
438 }
439
440 i2c_set_clientdata(client, tps);
441
442 return 0;
443}
444
445static int tps6598x_remove(struct i2c_client *client)
446{
447 struct tps6598x *tps = i2c_get_clientdata(client);
448
449 tps6598x_disconnect(tps, 0);
450 typec_unregister_port(tps->port);
451
452 return 0;
453}
454
455static const struct acpi_device_id tps6598x_acpi_match[] = {
456 { "INT3515", 0 },
457 { }
458};
459MODULE_DEVICE_TABLE(acpi, tps6598x_acpi_match);
460
461static struct i2c_driver tps6598x_i2c_driver = {
462 .driver = {
463 .name = "tps6598x",
464 .acpi_match_table = tps6598x_acpi_match,
465 },
466 .probe_new = tps6598x_probe,
467 .remove = tps6598x_remove,
468};
469module_i2c_driver(tps6598x_i2c_driver);
470
471MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
472MODULE_LICENSE("GPL v2");
473MODULE_DESCRIPTION("TI TPS6598x USB Power Delivery Controller Driver");
diff --git a/drivers/usb/typec/typec.c b/drivers/usb/typec/typec.c
index 24e355ba109d..735726ced602 100644
--- a/drivers/usb/typec/typec.c
+++ b/drivers/usb/typec/typec.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Type-C Connector Class 3 * USB Type-C Connector Class
3 * 4 *
4 * Copyright (C) 2017, Intel Corporation 5 * Copyright (C) 2017, Intel Corporation
5 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/device.h> 9#include <linux/device.h>
diff --git a/drivers/usb/typec/typec_wcove.c b/drivers/usb/typec/typec_wcove.c
index e9c4e784a9cb..a8d479eb221a 100644
--- a/drivers/usb/typec/typec_wcove.c
+++ b/drivers/usb/typec/typec_wcove.c
@@ -1,24 +1,20 @@
1// SPDX-License-Identifier: GPL-2.0
1/** 2/**
2 * typec_wcove.c - WhiskeyCove PMIC USB Type-C PHY driver 3 * typec_wcove.c - WhiskeyCove PMIC USB Type-C PHY driver
3 * 4 *
4 * Copyright (C) 2017 Intel Corporation 5 * Copyright (C) 2017 Intel Corporation
5 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/acpi.h> 9#include <linux/acpi.h>
13#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/usb/tcpm.h>
14#include <linux/interrupt.h> 12#include <linux/interrupt.h>
15#include <linux/usb/typec.h>
16#include <linux/platform_device.h> 13#include <linux/platform_device.h>
17#include <linux/mfd/intel_soc_pmic.h> 14#include <linux/mfd/intel_soc_pmic.h>
18 15
19/* Register offsets */ 16/* Register offsets */
20#define WCOVE_CHGRIRQ0 0x4e09 17#define WCOVE_CHGRIRQ0 0x4e09
21#define WCOVE_PHYCTRL 0x5e07
22 18
23#define USBC_CONTROL1 0x7001 19#define USBC_CONTROL1 0x7001
24#define USBC_CONTROL2 0x7002 20#define USBC_CONTROL2 0x7002
@@ -28,22 +24,57 @@
28#define USBC_STATUS1 0x7007 24#define USBC_STATUS1 0x7007
29#define USBC_STATUS2 0x7008 25#define USBC_STATUS2 0x7008
30#define USBC_STATUS3 0x7009 26#define USBC_STATUS3 0x7009
27#define USBC_CC1 0x700a
28#define USBC_CC2 0x700b
29#define USBC_CC1_STATUS 0x700c
30#define USBC_CC2_STATUS 0x700d
31#define USBC_IRQ1 0x7015 31#define USBC_IRQ1 0x7015
32#define USBC_IRQ2 0x7016 32#define USBC_IRQ2 0x7016
33#define USBC_IRQMASK1 0x7017 33#define USBC_IRQMASK1 0x7017
34#define USBC_IRQMASK2 0x7018 34#define USBC_IRQMASK2 0x7018
35#define USBC_PDCFG2 0x701a
36#define USBC_PDCFG3 0x701b
37#define USBC_PDSTATUS 0x701c
38#define USBC_RXSTATUS 0x701d
39#define USBC_RXINFO 0x701e
40#define USBC_TXCMD 0x701f
41#define USBC_TXINFO 0x7020
42#define USBC_RX_DATA 0x7028
43#define USBC_TX_DATA 0x7047
35 44
36/* Register bits */ 45/* Register bits */
37 46
38#define USBC_CONTROL1_MODE_DRP(r) (((r) & ~0x7) | 4) 47#define USBC_CONTROL1_MODE_MASK 0x3
48#define USBC_CONTROL1_MODE_SNK 0
49#define USBC_CONTROL1_MODE_SNKACC 1
50#define USBC_CONTROL1_MODE_SRC 2
51#define USBC_CONTROL1_MODE_SRCACC 3
52#define USBC_CONTROL1_MODE_DRP 4
53#define USBC_CONTROL1_MODE_DRPACC 5
54#define USBC_CONTROL1_MODE_TEST 7
55#define USBC_CONTROL1_CURSRC_MASK 0xc
56#define USBC_CONTROL1_CURSRC_UA_0 (0 << 3)
57#define USBC_CONTROL1_CURSRC_UA_80 (1 << 3)
58#define USBC_CONTROL1_CURSRC_UA_180 (2 << 3)
59#define USBC_CONTROL1_CURSRC_UA_330 (3 << 3)
60#define USBC_CONTROL1_DRPTOGGLE_RANDOM 0xe0
39 61
40#define USBC_CONTROL2_UNATT_SNK BIT(0) 62#define USBC_CONTROL2_UNATT_SNK BIT(0)
41#define USBC_CONTROL2_UNATT_SRC BIT(1) 63#define USBC_CONTROL2_UNATT_SRC BIT(1)
42#define USBC_CONTROL2_DIS_ST BIT(2) 64#define USBC_CONTROL2_DIS_ST BIT(2)
43 65
66#define USBC_CONTROL3_DET_DIS BIT(0)
44#define USBC_CONTROL3_PD_DIS BIT(1) 67#define USBC_CONTROL3_PD_DIS BIT(1)
68#define USBC_CONTROL3_RESETPHY BIT(2)
45 69
70#define USBC_CC_CTRL_PU_EN BIT(0)
46#define USBC_CC_CTRL_VCONN_EN BIT(1) 71#define USBC_CC_CTRL_VCONN_EN BIT(1)
72#define USBC_CC_CTRL_TX_EN BIT(2)
73#define USBC_CC_CTRL_PD_EN BIT(3)
74#define USBC_CC_CTRL_CDET_EN BIT(4)
75#define USBC_CC_CTRL_RDET_EN BIT(5)
76#define USBC_CC_CTRL_ADC_EN BIT(6)
77#define USBC_CC_CTRL_VBUSOK BIT(7)
47 78
48#define USBC_STATUS1_DET_ONGOING BIT(6) 79#define USBC_STATUS1_DET_ONGOING BIT(6)
49#define USBC_STATUS1_RSLT(r) ((r) & 0xf) 80#define USBC_STATUS1_RSLT(r) ((r) & 0xf)
@@ -61,6 +92,15 @@
61 92
62#define USBC_STATUS2_VBUS_REQ BIT(5) 93#define USBC_STATUS2_VBUS_REQ BIT(5)
63 94
95#define UCSC_CC_STATUS_SNK_RP BIT(0)
96#define UCSC_CC_STATUS_PWRDEFSNK BIT(1)
97#define UCSC_CC_STATUS_PWR_1P5A_SNK BIT(2)
98#define UCSC_CC_STATUS_PWR_3A_SNK BIT(3)
99#define UCSC_CC_STATUS_SRC_RP BIT(4)
100#define UCSC_CC_STATUS_RX(r) (((r) >> 5) & 0x3)
101#define USBC_CC_STATUS_RD 1
102#define USBC_CC_STATUS_RA 2
103
64#define USBC_IRQ1_ADCDONE1 BIT(2) 104#define USBC_IRQ1_ADCDONE1 BIT(2)
65#define USBC_IRQ1_OVERTEMP BIT(1) 105#define USBC_IRQ1_OVERTEMP BIT(1)
66#define USBC_IRQ1_SHORT BIT(0) 106#define USBC_IRQ1_SHORT BIT(0)
@@ -79,15 +119,44 @@
79 USBC_IRQ2_RX_HR | USBC_IRQ2_RX_CR | \ 119 USBC_IRQ2_RX_HR | USBC_IRQ2_RX_CR | \
80 USBC_IRQ2_TX_SUCCESS | USBC_IRQ2_TX_FAIL) 120 USBC_IRQ2_TX_SUCCESS | USBC_IRQ2_TX_FAIL)
81 121
122#define USBC_PDCFG2_SOP BIT(0)
123#define USBC_PDCFG2_SOP_P BIT(1)
124#define USBC_PDCFG2_SOP_PP BIT(2)
125#define USBC_PDCFG2_SOP_P_DEBUG BIT(3)
126#define USBC_PDCFG2_SOP_PP_DEBUG BIT(4)
127
128#define USBC_PDCFG3_DATAROLE_SHIFT 1
129#define USBC_PDCFG3_SOP_SHIFT 2
130
131#define USBC_RXSTATUS_RXCLEAR BIT(0)
132#define USBC_RXSTATUS_RXDATA BIT(7)
133
134#define USBC_RXINFO_RXBYTES(i) (((i) >> 3) & 0x1f)
135
136#define USBC_TXCMD_BUF_RDY BIT(0)
137#define USBC_TXCMD_START BIT(1)
138#define USBC_TXCMD_NOP (0 << 5)
139#define USBC_TXCMD_MSG (1 << 5)
140#define USBC_TXCMD_CR (2 << 5)
141#define USBC_TXCMD_HR (3 << 5)
142#define USBC_TXCMD_BIST (4 << 5)
143
144#define USBC_TXINFO_RETRIES(d) (d << 3)
145
82struct wcove_typec { 146struct wcove_typec {
83 struct mutex lock; /* device lock */ 147 struct mutex lock; /* device lock */
84 struct device *dev; 148 struct device *dev;
85 struct regmap *regmap; 149 struct regmap *regmap;
86 struct typec_port *port; 150 guid_t guid;
87 struct typec_capability cap; 151
88 struct typec_partner *partner; 152 bool vbus;
153
154 struct tcpc_dev tcpc;
155 struct tcpm_port *tcpm;
89}; 156};
90 157
158#define tcpc_to_wcove(_tcpc_) container_of(_tcpc_, struct wcove_typec, tcpc)
159
91enum wcove_typec_func { 160enum wcove_typec_func {
92 WCOVE_FUNC_DRIVE_VBUS = 1, 161 WCOVE_FUNC_DRIVE_VBUS = 1,
93 WCOVE_FUNC_ORIENTATION, 162 WCOVE_FUNC_ORIENTATION,
@@ -105,8 +174,7 @@ enum wcove_typec_role {
105 WCOVE_ROLE_DEVICE, 174 WCOVE_ROLE_DEVICE,
106}; 175};
107 176
108static guid_t guid = GUID_INIT(0x482383f0, 0x2876, 0x4e49, 177#define WCOVE_DSM_UUID "482383f0-2876-4e49-8685-db66211af037"
109 0x86, 0x85, 0xdb, 0x66, 0x21, 0x1a, 0xf0, 0x37);
110 178
111static int wcove_typec_func(struct wcove_typec *wcove, 179static int wcove_typec_func(struct wcove_typec *wcove,
112 enum wcove_typec_func func, int param) 180 enum wcove_typec_func func, int param)
@@ -118,7 +186,7 @@ static int wcove_typec_func(struct wcove_typec *wcove,
118 tmp.type = ACPI_TYPE_INTEGER; 186 tmp.type = ACPI_TYPE_INTEGER;
119 tmp.integer.value = param; 187 tmp.integer.value = param;
120 188
121 obj = acpi_evaluate_dsm(ACPI_HANDLE(wcove->dev), &guid, 1, func, 189 obj = acpi_evaluate_dsm(ACPI_HANDLE(wcove->dev), &wcove->guid, 1, func,
122 &argv4); 190 &argv4);
123 if (!obj) { 191 if (!obj) {
124 dev_err(wcove->dev, "%s: failed to evaluate _DSM\n", __func__); 192 dev_err(wcove->dev, "%s: failed to evaluate _DSM\n", __func__);
@@ -129,158 +197,349 @@ static int wcove_typec_func(struct wcove_typec *wcove,
129 return 0; 197 return 0;
130} 198}
131 199
132static irqreturn_t wcove_typec_irq(int irq, void *data) 200static int wcove_init(struct tcpc_dev *tcpc)
133{ 201{
134 enum typec_role role = TYPEC_SINK; 202 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
135 struct typec_partner_desc partner;
136 struct wcove_typec *wcove = data;
137 unsigned int cc1_ctrl;
138 unsigned int cc2_ctrl;
139 unsigned int cc_irq1;
140 unsigned int cc_irq2;
141 unsigned int status1;
142 unsigned int status2;
143 int ret; 203 int ret;
144 204
145 mutex_lock(&wcove->lock); 205 /* Unmask everything */
146 206 ret = regmap_write(wcove->regmap, USBC_IRQMASK1, 0);
147 ret = regmap_read(wcove->regmap, USBC_IRQ1, &cc_irq1);
148 if (ret) 207 if (ret)
149 goto err; 208 return ret;
150 209
151 ret = regmap_read(wcove->regmap, USBC_IRQ2, &cc_irq2); 210 return regmap_write(wcove->regmap, USBC_IRQMASK2, 0);
152 if (ret) 211}
153 goto err;
154 212
155 ret = regmap_read(wcove->regmap, USBC_STATUS1, &status1); 213static int wcove_get_vbus(struct tcpc_dev *tcpc)
156 if (ret) 214{
157 goto err; 215 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
216 unsigned int cc1ctrl;
217 int ret;
158 218
159 ret = regmap_read(wcove->regmap, USBC_STATUS2, &status2); 219 ret = regmap_read(wcove->regmap, USBC_CC1_CTRL, &cc1ctrl);
160 if (ret) 220 if (ret)
161 goto err; 221 return ret;
162 222
163 ret = regmap_read(wcove->regmap, USBC_CC1_CTRL, &cc1_ctrl); 223 wcove->vbus = !!(cc1ctrl & USBC_CC_CTRL_VBUSOK);
164 if (ret)
165 goto err;
166 224
167 ret = regmap_read(wcove->regmap, USBC_CC2_CTRL, &cc2_ctrl); 225 return wcove->vbus;
168 if (ret) 226}
169 goto err;
170 227
171 if (cc_irq1) { 228static int wcove_set_vbus(struct tcpc_dev *tcpc, bool on, bool sink)
172 if (cc_irq1 & USBC_IRQ1_OVERTEMP) 229{
173 dev_err(wcove->dev, "VCONN Switch Over Temperature!\n"); 230 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
174 if (cc_irq1 & USBC_IRQ1_SHORT)
175 dev_err(wcove->dev, "VCONN Switch Short Circuit!\n");
176 ret = regmap_write(wcove->regmap, USBC_IRQ1, cc_irq1);
177 if (ret)
178 goto err;
179 }
180 231
181 if (cc_irq2) { 232 return wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VBUS, on);
182 ret = regmap_write(wcove->regmap, USBC_IRQ2, cc_irq2); 233}
183 if (ret) 234
184 goto err; 235static int wcove_set_vconn(struct tcpc_dev *tcpc, bool on)
185 /* 236{
186 * Ignoring any PD communication interrupts until the PD support 237 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
187 * is available 238
188 */ 239 return wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VCONN, on);
189 if (cc_irq2 & ~USBC_IRQ2_CC_CHANGE) { 240}
190 dev_WARN(wcove->dev, "USB PD handling missing\n"); 241
191 goto err; 242static enum typec_cc_status wcove_to_typec_cc(unsigned int cc)
243{
244 if (cc & UCSC_CC_STATUS_SNK_RP) {
245 if (cc & UCSC_CC_STATUS_PWRDEFSNK)
246 return TYPEC_CC_RP_DEF;
247 else if (cc & UCSC_CC_STATUS_PWR_1P5A_SNK)
248 return TYPEC_CC_RP_1_5;
249 else if (cc & UCSC_CC_STATUS_PWR_3A_SNK)
250 return TYPEC_CC_RP_3_0;
251 } else {
252 switch (UCSC_CC_STATUS_RX(cc)) {
253 case USBC_CC_STATUS_RD:
254 return TYPEC_CC_RD;
255 case USBC_CC_STATUS_RA:
256 return TYPEC_CC_RA;
257 default:
258 break;
192 } 259 }
193 } 260 }
261 return TYPEC_CC_OPEN;
262}
194 263
195 if (status1 & USBC_STATUS1_DET_ONGOING) 264static int wcove_get_cc(struct tcpc_dev *tcpc, enum typec_cc_status *cc1,
196 goto out; 265 enum typec_cc_status *cc2)
266{
267 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
268 unsigned int cc1_status;
269 unsigned int cc2_status;
270 int ret;
197 271
198 if (USBC_STATUS1_RSLT(status1) == USBC_RSLT_NOTHING) { 272 ret = regmap_read(wcove->regmap, USBC_CC1_STATUS, &cc1_status);
199 if (wcove->partner) { 273 if (ret)
200 typec_unregister_partner(wcove->partner); 274 return ret;
201 wcove->partner = NULL;
202 }
203 275
204 wcove_typec_func(wcove, WCOVE_FUNC_ORIENTATION, 276 ret = regmap_read(wcove->regmap, USBC_CC2_STATUS, &cc2_status);
205 WCOVE_ORIENTATION_NORMAL); 277 if (ret)
278 return ret;
206 279
207 /* This makes sure the device controller is disconnected */ 280 *cc1 = wcove_to_typec_cc(cc1_status);
208 wcove_typec_func(wcove, WCOVE_FUNC_ROLE, WCOVE_ROLE_HOST); 281 *cc2 = wcove_to_typec_cc(cc2_status);
209 282
210 /* Port to default role */ 283 return 0;
211 typec_set_data_role(wcove->port, TYPEC_DEVICE); 284}
212 typec_set_pwr_role(wcove->port, TYPEC_SINK);
213 typec_set_pwr_opmode(wcove->port, TYPEC_PWR_MODE_USB);
214 285
215 goto out; 286static int wcove_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
216 } 287{
288 /* XXX: Relying on the HW FSM to configure things correctly for now */
289 return 0;
290}
217 291
218 if (wcove->partner) 292static int wcove_set_polarity(struct tcpc_dev *tcpc, enum typec_cc_polarity pol)
219 goto out; 293{
294 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
220 295
221 switch (USBC_STATUS1_ORIENT(status1)) { 296 return wcove_typec_func(wcove, WCOVE_FUNC_ORIENTATION, pol);
222 case USBC_ORIENT_NORMAL: 297}
223 wcove_typec_func(wcove, WCOVE_FUNC_ORIENTATION, 298
224 WCOVE_ORIENTATION_NORMAL); 299static int wcove_set_current_limit(struct tcpc_dev *tcpc, u32 max_ma, u32 mv)
225 break; 300{
226 case USBC_ORIENT_REVERSE: 301 return 0;
227 wcove_typec_func(wcove, WCOVE_FUNC_ORIENTATION, 302}
228 WCOVE_ORIENTATION_REVERSE); 303
229 default: 304static int wcove_set_roles(struct tcpc_dev *tcpc, bool attached,
230 break; 305 enum typec_role role, enum typec_data_role data)
306{
307 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
308 unsigned int val;
309 int ret;
310
311 ret = wcove_typec_func(wcove, WCOVE_FUNC_ROLE, data == TYPEC_HOST ?
312 WCOVE_ROLE_HOST : WCOVE_ROLE_DEVICE);
313 if (ret)
314 return ret;
315
316 val = role;
317 val |= data << USBC_PDCFG3_DATAROLE_SHIFT;
318 val |= PD_REV20 << USBC_PDCFG3_SOP_SHIFT;
319
320 return regmap_write(wcove->regmap, USBC_PDCFG3, val);
321}
322
323static int wcove_set_pd_rx(struct tcpc_dev *tcpc, bool on)
324{
325 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
326
327 return regmap_write(wcove->regmap, USBC_PDCFG2,
328 on ? USBC_PDCFG2_SOP : 0);
329}
330
331static int wcove_pd_transmit(struct tcpc_dev *tcpc,
332 enum tcpm_transmit_type type,
333 const struct pd_message *msg)
334{
335 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
336 unsigned int info = 0;
337 unsigned int cmd;
338 int ret;
339
340 ret = regmap_read(wcove->regmap, USBC_TXCMD, &cmd);
341 if (ret)
342 return ret;
343
344 if (!(cmd & USBC_TXCMD_BUF_RDY)) {
345 dev_warn(wcove->dev, "%s: Last transmission still ongoing!",
346 __func__);
347 return -EBUSY;
231 } 348 }
232 349
233 memset(&partner, 0, sizeof(partner)); 350 if (msg) {
351 const u8 *data = (void *)msg;
352 int i;
353
354 for (i = 0; i < pd_header_cnt(msg->header) * 4 + 2; i++) {
355 ret = regmap_write(wcove->regmap, USBC_TX_DATA + i,
356 data[i]);
357 if (ret)
358 return ret;
359 }
360 }
234 361
235 switch (USBC_STATUS1_RSLT(status1)) { 362 switch (type) {
236 case USBC_RSLT_SRC_DEFAULT: 363 case TCPC_TX_SOP:
237 typec_set_pwr_opmode(wcove->port, TYPEC_PWR_MODE_USB); 364 case TCPC_TX_SOP_PRIME:
365 case TCPC_TX_SOP_PRIME_PRIME:
366 case TCPC_TX_SOP_DEBUG_PRIME:
367 case TCPC_TX_SOP_DEBUG_PRIME_PRIME:
368 info = type + 1;
369 cmd = USBC_TXCMD_MSG;
238 break; 370 break;
239 case USBC_RSLT_SRC_1_5A: 371 case TCPC_TX_HARD_RESET:
240 typec_set_pwr_opmode(wcove->port, TYPEC_PWR_MODE_1_5A); 372 cmd = USBC_TXCMD_HR;
241 break; 373 break;
242 case USBC_RSLT_SRC_3_0A: 374 case TCPC_TX_CABLE_RESET:
243 typec_set_pwr_opmode(wcove->port, TYPEC_PWR_MODE_3_0A); 375 cmd = USBC_TXCMD_CR;
244 break; 376 break;
245 case USBC_RSLT_SNK: 377 case TCPC_TX_BIST_MODE_2:
246 role = TYPEC_SOURCE; 378 cmd = USBC_TXCMD_BIST;
247 break; 379 break;
248 case USBC_RSLT_DEBUG_ACC: 380 default:
249 partner.accessory = TYPEC_ACCESSORY_DEBUG; 381 return -EINVAL;
382 }
383
384 /* NOTE Setting maximum number of retries (7) */
385 ret = regmap_write(wcove->regmap, USBC_TXINFO,
386 info | USBC_TXINFO_RETRIES(7));
387 if (ret)
388 return ret;
389
390 return regmap_write(wcove->regmap, USBC_TXCMD, cmd | USBC_TXCMD_START);
391}
392
393static int wcove_start_drp_toggling(struct tcpc_dev *tcpc,
394 enum typec_cc_status cc)
395{
396 struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
397 unsigned int usbc_ctrl;
398
399 usbc_ctrl = USBC_CONTROL1_MODE_DRP | USBC_CONTROL1_DRPTOGGLE_RANDOM;
400
401 switch (cc) {
402 case TYPEC_CC_RP_1_5:
403 usbc_ctrl |= USBC_CONTROL1_CURSRC_UA_180;
250 break; 404 break;
251 case USBC_RSLT_AUDIO_ACC: 405 case TYPEC_CC_RP_3_0:
252 partner.accessory = TYPEC_ACCESSORY_AUDIO; 406 usbc_ctrl |= USBC_CONTROL1_CURSRC_UA_330;
253 break; 407 break;
254 default: 408 default:
255 dev_WARN(wcove->dev, "%s Undefined result\n", __func__); 409 usbc_ctrl |= USBC_CONTROL1_CURSRC_UA_80;
256 goto err; 410 break;
257 } 411 }
258 412
259 if (role == TYPEC_SINK) { 413 return regmap_write(wcove->regmap, USBC_CONTROL1, usbc_ctrl);
260 wcove_typec_func(wcove, WCOVE_FUNC_ROLE, WCOVE_ROLE_DEVICE); 414}
261 typec_set_data_role(wcove->port, TYPEC_DEVICE); 415
262 typec_set_pwr_role(wcove->port, TYPEC_SINK); 416static int wcove_read_rx_buffer(struct wcove_typec *wcove, void *msg)
263 } else { 417{
264 wcove_typec_func(wcove, WCOVE_FUNC_ROLE, WCOVE_ROLE_HOST); 418 unsigned int info;
265 typec_set_pwr_role(wcove->port, TYPEC_SOURCE); 419 int ret;
266 typec_set_data_role(wcove->port, TYPEC_HOST); 420 int i;
421
422 ret = regmap_read(wcove->regmap, USBC_RXINFO, &info);
423 if (ret)
424 return ret;
425
426 /* FIXME: Check that USBC_RXINFO_RXBYTES(info) matches the header */
427
428 for (i = 0; i < USBC_RXINFO_RXBYTES(info); i++) {
429 ret = regmap_read(wcove->regmap, USBC_RX_DATA + i, msg + i);
430 if (ret)
431 return ret;
267 } 432 }
268 433
269 wcove->partner = typec_register_partner(wcove->port, &partner); 434 return regmap_write(wcove->regmap, USBC_RXSTATUS,
270 if (!wcove->partner) 435 USBC_RXSTATUS_RXCLEAR);
271 dev_err(wcove->dev, "failed register partner\n"); 436}
272out: 437
273 /* If either CC pins is requesting VCONN, we turn it on */ 438static irqreturn_t wcove_typec_irq(int irq, void *data)
274 if ((cc1_ctrl & USBC_CC_CTRL_VCONN_EN) || 439{
275 (cc2_ctrl & USBC_CC_CTRL_VCONN_EN)) 440 struct wcove_typec *wcove = data;
276 wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VCONN, true); 441 unsigned int usbc_irq1 = 0;
277 else 442 unsigned int usbc_irq2 = 0;
443 unsigned int cc1ctrl;
444 int ret;
445
446 mutex_lock(&wcove->lock);
447
448 /* Read.. */
449 ret = regmap_read(wcove->regmap, USBC_IRQ1, &usbc_irq1);
450 if (ret)
451 goto err;
452
453 ret = regmap_read(wcove->regmap, USBC_IRQ2, &usbc_irq2);
454 if (ret)
455 goto err;
456
457 ret = regmap_read(wcove->regmap, USBC_CC1_CTRL, &cc1ctrl);
458 if (ret)
459 goto err;
460
461 if (!wcove->tcpm)
462 goto err;
463
464 /* ..check.. */
465 if (usbc_irq1 & USBC_IRQ1_OVERTEMP) {
466 dev_err(wcove->dev, "VCONN Switch Over Temperature!\n");
467 wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VCONN, false);
468 /* REVISIT: Report an error? */
469 }
470
471 if (usbc_irq1 & USBC_IRQ1_SHORT) {
472 dev_err(wcove->dev, "VCONN Switch Short Circuit!\n");
278 wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VCONN, false); 473 wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VCONN, false);
474 /* REVISIT: Report an error? */
475 }
476
477 if (wcove->vbus != !!(cc1ctrl & USBC_CC_CTRL_VBUSOK))
478 tcpm_vbus_change(wcove->tcpm);
479
480 /* REVISIT: See if tcpm code can be made to consider Type-C HW FSMs */
481 if (usbc_irq2 & USBC_IRQ2_CC_CHANGE)
482 tcpm_cc_change(wcove->tcpm);
483
484 if (usbc_irq2 & USBC_IRQ2_RX_PD) {
485 unsigned int status;
486
487 /*
488 * FIXME: Need to check if TX is ongoing and report
489 * TX_DIREGARDED if needed?
490 */
491
492 ret = regmap_read(wcove->regmap, USBC_RXSTATUS, &status);
493 if (ret)
494 goto err;
495
496 /* Flush all buffers */
497 while (status & USBC_RXSTATUS_RXDATA) {
498 struct pd_message msg;
499
500 ret = wcove_read_rx_buffer(wcove, &msg);
501 if (ret) {
502 dev_err(wcove->dev, "%s: RX read failed\n",
503 __func__);
504 goto err;
505 }
506
507 tcpm_pd_receive(wcove->tcpm, &msg);
508
509 ret = regmap_read(wcove->regmap, USBC_RXSTATUS,
510 &status);
511 if (ret)
512 goto err;
513 }
514 }
515
516 if (usbc_irq2 & USBC_IRQ2_RX_HR)
517 tcpm_pd_hard_reset(wcove->tcpm);
518
519 /* REVISIT: if (usbc_irq2 & USBC_IRQ2_RX_CR) */
520
521 if (usbc_irq2 & USBC_IRQ2_TX_SUCCESS)
522 tcpm_pd_transmit_complete(wcove->tcpm, TCPC_TX_SUCCESS);
523
524 if (usbc_irq2 & USBC_IRQ2_TX_FAIL)
525 tcpm_pd_transmit_complete(wcove->tcpm, TCPC_TX_FAILED);
279 526
280 /* Relying on the FSM to know when we need to drive VBUS. */
281 wcove_typec_func(wcove, WCOVE_FUNC_DRIVE_VBUS,
282 !!(status2 & USBC_STATUS2_VBUS_REQ));
283err: 527err:
528 /* ..and clear. */
529 if (usbc_irq1) {
530 ret = regmap_write(wcove->regmap, USBC_IRQ1, usbc_irq1);
531 if (ret)
532 dev_WARN(wcove->dev, "%s failed to clear IRQ1\n",
533 __func__);
534 }
535
536 if (usbc_irq2) {
537 ret = regmap_write(wcove->regmap, USBC_IRQ2, usbc_irq2);
538 if (ret)
539 dev_WARN(wcove->dev, "%s failed to clear IRQ2\n",
540 __func__);
541 }
542
284 /* REVISIT: Clear WhiskeyCove CHGR Type-C interrupt */ 543 /* REVISIT: Clear WhiskeyCove CHGR Type-C interrupt */
285 regmap_write(wcove->regmap, WCOVE_CHGRIRQ0, BIT(5)); 544 regmap_write(wcove->regmap, WCOVE_CHGRIRQ0, BIT(5));
286 545
@@ -288,11 +547,41 @@ err:
288 return IRQ_HANDLED; 547 return IRQ_HANDLED;
289} 548}
290 549
550/*
551 * The following power levels should be safe to use with Joule board.
552 */
553static const u32 src_pdo[] = {
554 PDO_FIXED(5000, 1500, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |
555 PDO_FIXED_USB_COMM),
556};
557
558static const u32 snk_pdo[] = {
559 PDO_FIXED(12000, 3000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |
560 PDO_FIXED_USB_COMM),
561 PDO_BATT(4750, 12000, 15000),
562 PDO_VAR(4750, 12000, 3000),
563};
564
565static struct tcpc_config wcove_typec_config = {
566 .src_pdo = src_pdo,
567 .nr_src_pdo = ARRAY_SIZE(src_pdo),
568 .snk_pdo = snk_pdo,
569 .nr_snk_pdo = ARRAY_SIZE(snk_pdo),
570
571 .max_snk_mv = 12000,
572 .max_snk_ma = 3000,
573 .max_snk_mw = 36000,
574 .operating_snk_mw = 15000,
575
576 .type = TYPEC_PORT_DRP,
577 .default_role = TYPEC_SINK,
578};
579
291static int wcove_typec_probe(struct platform_device *pdev) 580static int wcove_typec_probe(struct platform_device *pdev)
292{ 581{
293 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); 582 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
294 struct wcove_typec *wcove; 583 struct wcove_typec *wcove;
295 unsigned int val; 584 int irq;
296 int ret; 585 int ret;
297 586
298 wcove = devm_kzalloc(&pdev->dev, sizeof(*wcove), GFP_KERNEL); 587 wcove = devm_kzalloc(&pdev->dev, sizeof(*wcove), GFP_KERNEL);
@@ -303,43 +592,47 @@ static int wcove_typec_probe(struct platform_device *pdev)
303 wcove->dev = &pdev->dev; 592 wcove->dev = &pdev->dev;
304 wcove->regmap = pmic->regmap; 593 wcove->regmap = pmic->regmap;
305 594
306 ret = regmap_irq_get_virq(pmic->irq_chip_data_chgr, 595 irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr,
307 platform_get_irq(pdev, 0)); 596 platform_get_irq(pdev, 0));
308 if (ret < 0) 597 if (irq < 0)
309 return ret; 598 return irq;
310 599
311 ret = devm_request_threaded_irq(&pdev->dev, ret, NULL, 600 ret = guid_parse(WCOVE_DSM_UUID, &wcove->guid);
312 wcove_typec_irq, IRQF_ONESHOT,
313 "wcove_typec", wcove);
314 if (ret) 601 if (ret)
315 return ret; 602 return ret;
316 603
317 if (!acpi_check_dsm(ACPI_HANDLE(&pdev->dev), &guid, 0, 0x1f)) { 604 if (!acpi_check_dsm(ACPI_HANDLE(&pdev->dev), &wcove->guid, 0, 0x1f)) {
318 dev_err(&pdev->dev, "Missing _DSM functions\n"); 605 dev_err(&pdev->dev, "Missing _DSM functions\n");
319 return -ENODEV; 606 return -ENODEV;
320 } 607 }
321 608
322 wcove->cap.type = TYPEC_PORT_DRP; 609 wcove->tcpc.init = wcove_init;
323 wcove->cap.revision = USB_TYPEC_REV_1_1; 610 wcove->tcpc.get_vbus = wcove_get_vbus;
324 wcove->cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; 611 wcove->tcpc.set_vbus = wcove_set_vbus;
612 wcove->tcpc.set_cc = wcove_set_cc;
613 wcove->tcpc.get_cc = wcove_get_cc;
614 wcove->tcpc.set_polarity = wcove_set_polarity;
615 wcove->tcpc.set_vconn = wcove_set_vconn;
616 wcove->tcpc.set_current_limit = wcove_set_current_limit;
617 wcove->tcpc.start_drp_toggling = wcove_start_drp_toggling;
325 618
326 /* Make sure the PD PHY is disabled until USB PD is available */ 619 wcove->tcpc.set_pd_rx = wcove_set_pd_rx;
327 regmap_read(wcove->regmap, USBC_CONTROL3, &val); 620 wcove->tcpc.set_roles = wcove_set_roles;
328 regmap_write(wcove->regmap, USBC_CONTROL3, val | USBC_CONTROL3_PD_DIS); 621 wcove->tcpc.pd_transmit = wcove_pd_transmit;
329 622
330 /* DRP mode without accessory support */ 623 wcove->tcpc.config = &wcove_typec_config;
331 regmap_read(wcove->regmap, USBC_CONTROL1, &val);
332 regmap_write(wcove->regmap, USBC_CONTROL1, USBC_CONTROL1_MODE_DRP(val));
333 624
334 wcove->port = typec_register_port(&pdev->dev, &wcove->cap); 625 wcove->tcpm = tcpm_register_port(wcove->dev, &wcove->tcpc);
335 if (!wcove->port) 626 if (IS_ERR(wcove->tcpm))
336 return -ENODEV; 627 return PTR_ERR(wcove->tcpm);
337 628
338 /* Unmask everything */ 629 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
339 regmap_read(wcove->regmap, USBC_IRQMASK1, &val); 630 wcove_typec_irq, IRQF_ONESHOT,
340 regmap_write(wcove->regmap, USBC_IRQMASK1, val & ~USBC_IRQMASK1_ALL); 631 "wcove_typec", wcove);
341 regmap_read(wcove->regmap, USBC_IRQMASK2, &val); 632 if (ret) {
342 regmap_write(wcove->regmap, USBC_IRQMASK2, val & ~USBC_IRQMASK2_ALL); 633 tcpm_unregister_port(wcove->tcpm);
634 return ret;
635 }
343 636
344 platform_set_drvdata(pdev, wcove); 637 platform_set_drvdata(pdev, wcove);
345 return 0; 638 return 0;
@@ -356,8 +649,8 @@ static int wcove_typec_remove(struct platform_device *pdev)
356 regmap_read(wcove->regmap, USBC_IRQMASK2, &val); 649 regmap_read(wcove->regmap, USBC_IRQMASK2, &val);
357 regmap_write(wcove->regmap, USBC_IRQMASK2, val | USBC_IRQMASK2_ALL); 650 regmap_write(wcove->regmap, USBC_IRQMASK2, val | USBC_IRQMASK2_ALL);
358 651
359 typec_unregister_partner(wcove->partner); 652 tcpm_unregister_port(wcove->tcpm);
360 typec_unregister_port(wcove->port); 653
361 return 0; 654 return 0;
362} 655}
363 656
diff --git a/drivers/usb/typec/ucsi/trace.c b/drivers/usb/typec/ucsi/trace.c
index 006f65c72a34..d9a6ff6e673c 100644
--- a/drivers/usb/typec/ucsi/trace.c
+++ b/drivers/usb/typec/ucsi/trace.c
@@ -1,2 +1,3 @@
1// SPDX-License-Identifier: GPL-2.0
1#define CREATE_TRACE_POINTS 2#define CREATE_TRACE_POINTS
2#include "trace.h" 3#include "trace.h"
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 714c5bcedf2b..79046fe66426 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Type-C Connector System Software Interface driver 3 * USB Type-C Connector System Software Interface driver
3 * 4 *
4 * Copyright (C) 2017, Intel Corporation 5 * Copyright (C) 2017, Intel Corporation
5 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/completion.h> 9#include <linux/completion.h>
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index cabd47612b0a..44eb4e1ea817 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * UCSI ACPI driver 3 * UCSI ACPI driver
3 * 4 *
4 * Copyright (C) 2017, Intel Corporation 5 * Copyright (C) 2017, Intel Corporation
5 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/platform_device.h> 9#include <linux/platform_device.h>
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index bb0bd732e29a..26ca0ec01fd5 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -1,15 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Skeleton driver - 2.2 3 * USB Skeleton driver - 2.2
3 * 4 *
4 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
5 * 6 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c 7 * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
11 * but has been rewritten to be easier to read and use. 8 * but has been rewritten to be easier to read and use.
12 *
13 */ 9 */
14 10
15#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/usb/usbip/stub.h b/drivers/usb/usbip/stub.h
index 910f027773aa..14a72357800a 100644
--- a/drivers/usb/usbip/stub.h
+++ b/drivers/usb/usbip/stub.h
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#ifndef __USBIP_STUB_H 6#ifndef __USBIP_STUB_H
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index c653ce533430..a3df8ee82faf 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <linux/device.h> 6#include <linux/device.h>
diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index 7170404e8979..4f48b306713f 100644
--- a/drivers/usb/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <linux/string.h> 6#include <linux/string.h>
diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
index 191b176ffedf..536e037f541f 100644
--- a/drivers/usb/usbip/stub_rx.c
+++ b/drivers/usb/usbip/stub_rx.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <asm/byteorder.h> 6#include <asm/byteorder.h>
diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
index be50cef645d8..b18bce96c212 100644
--- a/drivers/usb/usbip/stub_tx.c
+++ b/drivers/usb/usbip/stub_tx.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <linux/kthread.h> 6#include <linux/kthread.h>
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index 2281f3562870..f7978933b402 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -1,22 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Krzysztof Opasiak <k.opasiak@samsung.com> 5 * Krzysztof Opasiak <k.opasiak@samsung.com>
5 *
6 * This is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
20 */ 6 */
21 7
22#include <asm/byteorder.h> 8#include <asm/byteorder.h>
diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index 3050fc99a417..e5de35c8c505 100644
--- a/drivers/usb/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -1,22 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Krzysztof Opasiak <k.opasiak@samsung.com> 5 * Krzysztof Opasiak <k.opasiak@samsung.com>
5 *
6 * This is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
20 */ 6 */
21 7
22#ifndef __USBIP_COMMON_H 8#ifndef __USBIP_COMMON_H
diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
index f1635662c299..5b4c0864ad92 100644
--- a/drivers/usb/usbip/usbip_event.c
+++ b/drivers/usb/usbip/usbip_event.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015 Nobuo Iwata 4 * Copyright (C) 2015 Nobuo Iwata
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */ 5 */
20 6
21#include <linux/kthread.h> 7#include <linux/kthread.h>
diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index 5cfb59e98e44..5659dce1526e 100644
--- a/drivers/usb/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
@@ -1,12 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015 Nobuo Iwata 4 * Copyright (C) 2015 Nobuo Iwata
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 */ 5 */
11 6
12#ifndef __USBIP_VHCI_H 7#ifndef __USBIP_VHCI_H
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 11b9a22799cc..713e94170963 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015-2016 Nobuo Iwata 4 * Copyright (C) 2015-2016 Nobuo Iwata
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */ 5 */
20 6
21#include <linux/init.h> 7#include <linux/init.h>
diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index ef2f2d5ca6b2..90577e8b2282 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <linux/kthread.h> 6#include <linux/kthread.h>
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 1b9f60a22e0b..e78f7472cac4 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 * Copyright (C) 2015-2016 Nobuo Iwata 4 * Copyright (C) 2015-2016 Nobuo Iwata
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */ 5 */
20 6
21#include <linux/kthread.h> 7#include <linux/kthread.h>
diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index 3e7878fe2fd4..d625a2ff4b71 100644
--- a/drivers/usb/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
@@ -1,20 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi 3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */ 4 */
19 5
20#include <linux/kthread.h> 6#include <linux/kthread.h>
diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
index 25e01b09c4c3..cf968192e59f 100644
--- a/drivers/usb/usbip/vudc.h
+++ b/drivers/usb/usbip/vudc.h
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 * Krzysztof Opasiak <k.opasiak@samsung.com> 6 * Krzysztof Opasiak <k.opasiak@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 7 */
20 8
21#ifndef __USBIP_VUDC_H 9#ifndef __USBIP_VUDC_H
@@ -104,7 +92,7 @@ struct vudc {
104 92
105 struct usbip_device ud; 93 struct usbip_device ud;
106 struct transfer_timer tr_timer; 94 struct transfer_timer tr_timer;
107 struct timeval start_time; 95 struct timespec64 start_time;
108 96
109 struct list_head urb_queue; 97 struct list_head urb_queue;
110 98
diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index 968471b62cbc..1b9a4f87db59 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 * Krzysztof Opasiak <k.opasiak@samsung.com> 6 * Krzysztof Opasiak <k.opasiak@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 7 */
20 8
21#include <linux/device.h> 9#include <linux/device.h>
@@ -135,16 +123,15 @@ struct vep *vudc_find_endpoint(struct vudc *udc, u8 address)
135 123
136/* gadget ops */ 124/* gadget ops */
137 125
138/* FIXME - this will probably misbehave when suspend/resume is added */
139static int vgadget_get_frame(struct usb_gadget *_gadget) 126static int vgadget_get_frame(struct usb_gadget *_gadget)
140{ 127{
141 struct timeval now; 128 struct timespec64 now;
142 struct vudc *udc = usb_gadget_to_vudc(_gadget); 129 struct vudc *udc = usb_gadget_to_vudc(_gadget);
143 130
144 do_gettimeofday(&now); 131 ktime_get_ts64(&now);
145 return ((now.tv_sec - udc->start_time.tv_sec) * 1000 + 132 return ((now.tv_sec - udc->start_time.tv_sec) * 1000 +
146 (now.tv_usec - udc->start_time.tv_usec) / 1000) 133 (now.tv_nsec - udc->start_time.tv_nsec) / NSEC_PER_MSEC)
147 % 0x7FF; 134 & 0x7FF;
148} 135}
149 136
150static int vgadget_set_selfpowered(struct usb_gadget *_gadget, int value) 137static int vgadget_set_selfpowered(struct usb_gadget *_gadget, int value)
diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
index 9e655714e389..3fc22037a82f 100644
--- a/drivers/usb/usbip/vudc_main.c
+++ b/drivers/usb/usbip/vudc_main.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 * Krzysztof Opasiak <k.opasiak@samsung.com> 6 * Krzysztof Opasiak <k.opasiak@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 7 */
20 8
21#include <linux/device.h> 9#include <linux/device.h>
diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c
index e429b59f6f8a..df1e30989148 100644
--- a/drivers/usb/usbip/vudc_rx.c
+++ b/drivers/usb/usbip/vudc_rx.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 6 */
19 7
20#include <net/sock.h> 8#include <net/sock.h>
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 0f98f2c7475f..1adc8af292ec 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -1,21 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 * Krzysztof Opasiak <k.opasiak@samsung.com> 6 * Krzysztof Opasiak <k.opasiak@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 7 */
20 8
21#include <linux/device.h> 9#include <linux/device.h>
@@ -161,7 +149,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
161 udc->ud.status = SDEV_ST_USED; 149 udc->ud.status = SDEV_ST_USED;
162 spin_unlock_irq(&udc->ud.lock); 150 spin_unlock_irq(&udc->ud.lock);
163 151
164 do_gettimeofday(&udc->start_time); 152 ktime_get_ts64(&udc->start_time);
165 v_start_timer(udc); 153 v_start_timer(udc);
166 udc->connected = 1; 154 udc->connected = 1;
167 } else { 155 } else {
diff --git a/drivers/usb/usbip/vudc_transfer.c b/drivers/usb/usbip/vudc_transfer.c
index 4cfd475ee865..c9db846ee4f6 100644
--- a/drivers/usb/usbip/vudc_transfer.c
+++ b/drivers/usb/usbip/vudc_transfer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
@@ -6,19 +7,6 @@
6 * Based on dummy_hcd.c, which is: 7 * Based on dummy_hcd.c, which is:
7 * Copyright (C) 2003 David Brownell 8 * Copyright (C) 2003 David Brownell
8 * Copyright (C) 2003-2005 Alan Stern 9 * Copyright (C) 2003-2005 Alan Stern
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */ 10 */
23 11
24#include <linux/usb.h> 12#include <linux/usb.h>
@@ -311,9 +299,9 @@ top:
311 return sent; 299 return sent;
312} 300}
313 301
314static void v_timer(unsigned long _vudc) 302static void v_timer(struct timer_list *t)
315{ 303{
316 struct vudc *udc = (struct vudc *) _vudc; 304 struct vudc *udc = from_timer(udc, t, tr_timer.timer);
317 struct transfer_timer *timer = &udc->tr_timer; 305 struct transfer_timer *timer = &udc->tr_timer;
318 struct urbp *urb_p, *tmp; 306 struct urbp *urb_p, *tmp;
319 unsigned long flags; 307 unsigned long flags;
@@ -459,7 +447,7 @@ void v_init_timer(struct vudc *udc)
459{ 447{
460 struct transfer_timer *t = &udc->tr_timer; 448 struct transfer_timer *t = &udc->tr_timer;
461 449
462 setup_timer(&t->timer, v_timer, (unsigned long) udc); 450 timer_setup(&t->timer, v_timer, 0);
463 t->state = VUDC_TR_STOPPED; 451 t->state = VUDC_TR_STOPPED;
464} 452}
465 453
diff --git a/drivers/usb/usbip/vudc_tx.c b/drivers/usb/usbip/vudc_tx.c
index 234661782fa0..1440ae0919ec 100644
--- a/drivers/usb/usbip/vudc_tx.c
+++ b/drivers/usb/usbip/vudc_tx.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> 3 * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
3 * Copyright (C) 2015-2016 Samsung Electronics 4 * Copyright (C) 2015-2016 Samsung Electronics
4 * Igor Kotrasinski <i.kotrasinsk@samsung.com> 5 * Igor Kotrasinski <i.kotrasinsk@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 6 */
19 7
20#include <net/sock.h> 8#include <net/sock.h>
diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index aa4e440e9975..222228c5c1e1 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB - Cable Based Association 3 * Wireless USB - Cable Based Association
3 * 4 *
@@ -6,21 +7,6 @@
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * Copyright (C) 2008 Cambridge Silicon Radio Ltd. 8 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * WUSB devices have to be paired (associated in WUSB lingo) so 10 * WUSB devices have to be paired (associated in WUSB lingo) so
25 * that they can connect to the system. 11 * that they can connect to the system.
26 * 12 *
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c
index 062c205f0046..4c00be2d1993 100644
--- a/drivers/usb/wusbcore/crypto.c
+++ b/drivers/usb/wusbcore/crypto.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Ultra Wide Band 3 * Ultra Wide Band
3 * AES-128 CCM Encryption 4 * AES-128 CCM Encryption
@@ -5,21 +6,6 @@
5 * Copyright (C) 2007 Intel Corporation 6 * Copyright (C) 2007 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * We don't do any encryption here; we use the Linux Kernel's AES-128 9 * We don't do any encryption here; we use the Linux Kernel's AES-128
24 * crypto modules to construct keys and payload blocks in a way 10 * crypto modules to construct keys and payload blocks in a way
25 * defined by WUSB1.0[6]. Check the erratas, as typos are are patched 11 * defined by WUSB1.0[6]. Check the erratas, as typos are are patched
diff --git a/drivers/usb/wusbcore/dev-sysfs.c b/drivers/usb/wusbcore/dev-sysfs.c
index 78212f8180ce..85a1acf3a729 100644
--- a/drivers/usb/wusbcore/dev-sysfs.c
+++ b/drivers/usb/wusbcore/dev-sysfs.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB devices 3 * WUSB devices
3 * sysfs bindings 4 * sysfs bindings
@@ -5,21 +6,6 @@
5 * Copyright (C) 2007 Intel Corporation 6 * Copyright (C) 2007 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * Get them out of the way... 9 * Get them out of the way...
24 */ 10 */
25 11
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index bf9551735938..fcb06aef2675 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8]) 3 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8])
3 * Device Connect handling 4 * Device Connect handling
@@ -5,21 +6,6 @@
5 * Copyright (C) 2006 Intel Corporation 6 * Copyright (C) 2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs 9 * FIXME: docs
24 * FIXME: this file needs to be broken up, it's grown too big 10 * FIXME: this file needs to be broken up, it's grown too big
25 * 11 *
diff --git a/drivers/usb/wusbcore/mmc.c b/drivers/usb/wusbcore/mmc.c
index 3f485df96226..acce0d551eb2 100644
--- a/drivers/usb/wusbcore/mmc.c
+++ b/drivers/usb/wusbcore/mmc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8]) 3 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8])
3 * MMC (Microscheduled Management Command) handling 4 * MMC (Microscheduled Management Command) handling
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * WUIEs and MMC IEs...well, they are almost the same at the end. MMC 9 * WUIEs and MMC IEs...well, they are almost the same at the end. MMC
24 * IEs are Wireless USB IEs that go into the MMC period...[what is 10 * IEs are Wireless USB IEs that go into the MMC period...[what is
25 * that? look in Design-overview.txt]. 11 * that? look in Design-overview.txt].
diff --git a/drivers/usb/wusbcore/pal.c b/drivers/usb/wusbcore/pal.c
index 090f27371a8f..30f569131471 100644
--- a/drivers/usb/wusbcore/pal.c
+++ b/drivers/usb/wusbcore/pal.c
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Host Controller 3 * Wireless USB Host Controller
3 * UWB Protocol Adaptation Layer (PAL) glue. 4 * UWB Protocol Adaptation Layer (PAL) glue.
4 * 5 *
5 * Copyright (C) 2008 Cambridge Silicon Radio Ltd. 6 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19#include "wusbhc.h" 8#include "wusbhc.h"
20 9
diff --git a/drivers/usb/wusbcore/reservation.c b/drivers/usb/wusbcore/reservation.c
index 7b1b2e2fb673..6dcfc6825f55 100644
--- a/drivers/usb/wusbcore/reservation.c
+++ b/drivers/usb/wusbcore/reservation.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB cluster reservation management 3 * WUSB cluster reservation management
3 * 4 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd. 5 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 6 */
18#include <linux/kernel.h> 7#include <linux/kernel.h>
19#include <linux/uwb.h> 8#include <linux/uwb.h>
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index a082fe62b1f0..20c08cd9dcbf 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Host Controller 3 * Wireless USB Host Controller
3 * Root Hub operations 4 * Root Hub operations
@@ -6,21 +7,6 @@
6 * Copyright (C) 2005-2006 Intel Corporation 7 * Copyright (C) 2005-2006 Intel Corporation
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * We fake a root hub that has fake ports (as many as simultaneous 10 * We fake a root hub that has fake ports (as many as simultaneous
25 * devices the Wireless USB Host Controller can deal with). For each 11 * devices the Wireless USB Host Controller can deal with). For each
26 * port we keep an state in @wusbhc->port[index] identical to the one 12 * port we keep an state in @wusbhc->port[index] identical to the one
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index 170f2c38de9b..33d2f5d7f33b 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Host Controller 3 * Wireless USB Host Controller
3 * Security support: encryption enablement, etc 4 * Security support: encryption enablement, etc
@@ -5,21 +6,6 @@
5 * Copyright (C) 2006 Intel Corporation 6 * Copyright (C) 2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs 9 * FIXME: docs
24 */ 10 */
25#include <linux/types.h> 11#include <linux/types.h>
@@ -28,6 +14,7 @@
28#include <linux/random.h> 14#include <linux/random.h>
29#include <linux/export.h> 15#include <linux/export.h>
30#include "wusbhc.h" 16#include "wusbhc.h"
17#include <asm/unaligned.h>
31 18
32static void wusbhc_gtk_rekey_work(struct work_struct *work); 19static void wusbhc_gtk_rekey_work(struct work_struct *work);
33 20
@@ -367,7 +354,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
367 struct usb_device *usb_dev = wusb_dev->usb_dev; 354 struct usb_device *usb_dev = wusb_dev->usb_dev;
368 struct device *dev = &usb_dev->dev; 355 struct device *dev = &usb_dev->dev;
369 u32 tkid; 356 u32 tkid;
370 __le32 tkid_le;
371 struct usb_handshake *hs; 357 struct usb_handshake *hs;
372 struct aes_ccm_nonce ccm_n; 358 struct aes_ccm_nonce ccm_n;
373 u8 mic[8]; 359 u8 mic[8];
@@ -385,11 +371,10 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
385 goto error_dev_set_encryption; 371 goto error_dev_set_encryption;
386 372
387 tkid = wusbhc_next_tkid(wusbhc, wusb_dev); 373 tkid = wusbhc_next_tkid(wusbhc, wusb_dev);
388 tkid_le = cpu_to_le32(tkid);
389 374
390 hs[0].bMessageNumber = 1; 375 hs[0].bMessageNumber = 1;
391 hs[0].bStatus = 0; 376 hs[0].bStatus = 0;
392 memcpy(hs[0].tTKID, &tkid_le, sizeof(hs[0].tTKID)); 377 put_unaligned_le32(tkid, hs[0].tTKID);
393 hs[0].bReserved = 0; 378 hs[0].bReserved = 0;
394 memcpy(hs[0].CDID, &wusb_dev->cdid, sizeof(hs[0].CDID)); 379 memcpy(hs[0].CDID, &wusb_dev->cdid, sizeof(hs[0].CDID));
395 get_random_bytes(&hs[0].nonce, sizeof(hs[0].nonce)); 380 get_random_bytes(&hs[0].nonce, sizeof(hs[0].nonce));
@@ -441,7 +426,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
441 426
442 /* Setup the CCM nonce */ 427 /* Setup the CCM nonce */
443 memset(&ccm_n.sfn, 0, sizeof(ccm_n.sfn)); /* Per WUSB1.0[6.5.2] */ 428 memset(&ccm_n.sfn, 0, sizeof(ccm_n.sfn)); /* Per WUSB1.0[6.5.2] */
444 memcpy(ccm_n.tkid, &tkid_le, sizeof(ccm_n.tkid)); 429 put_unaligned_le32(tkid, ccm_n.tkid);
445 ccm_n.src_addr = wusbhc->uwb_rc->uwb_dev.dev_addr; 430 ccm_n.src_addr = wusbhc->uwb_rc->uwb_dev.dev_addr;
446 ccm_n.dest_addr.data[0] = wusb_dev->addr; 431 ccm_n.dest_addr.data[0] = wusb_dev->addr;
447 ccm_n.dest_addr.data[1] = 0; 432 ccm_n.dest_addr.data[1] = 0;
@@ -472,7 +457,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
472 /* Send Handshake3 */ 457 /* Send Handshake3 */
473 hs[2].bMessageNumber = 3; 458 hs[2].bMessageNumber = 3;
474 hs[2].bStatus = 0; 459 hs[2].bStatus = 0;
475 memcpy(hs[2].tTKID, &tkid_le, sizeof(hs[2].tTKID)); 460 put_unaligned_le32(tkid, hs[2].tTKID);
476 hs[2].bReserved = 0; 461 hs[2].bReserved = 0;
477 memcpy(hs[2].CDID, &wusb_dev->cdid, sizeof(hs[2].CDID)); 462 memcpy(hs[2].CDID, &wusb_dev->cdid, sizeof(hs[2].CDID));
478 memcpy(hs[2].nonce, hs[0].nonce, sizeof(hs[2].nonce)); 463 memcpy(hs[2].nonce, hs[0].nonce, sizeof(hs[2].nonce));
diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c
index d01496fd27fe..6827075fb8a1 100644
--- a/drivers/usb/wusbcore/wa-hc.c
+++ b/drivers/usb/wusbcore/wa-hc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wire Adapter Host Controller Driver 3 * Wire Adapter Host Controller Driver
3 * Common items to HWA and DWA based HCDs 4 * Common items to HWA and DWA based HCDs
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs 9 * FIXME: docs
24 */ 10 */
25#include <linux/slab.h> 11#include <linux/slab.h>
diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
index edc7267157f3..ec90fff21deb 100644
--- a/drivers/usb/wusbcore/wa-hc.h
+++ b/drivers/usb/wusbcore/wa-hc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * HWA Host Controller Driver 3 * HWA Host Controller Driver
3 * Wire Adapter Control/Data Streaming Iface (WUSB1.0[8]) 4 * Wire Adapter Control/Data Streaming Iface (WUSB1.0[8])
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * This driver implements a USB Host Controller (struct usb_hcd) for a 9 * This driver implements a USB Host Controller (struct usb_hcd) for a
24 * Wireless USB Host Controller based on the Wireless USB 1.0 10 * Wireless USB Host Controller based on the Wireless USB 1.0
25 * Host-Wire-Adapter specification (in layman terms, a USB-dongle that 11 * Host-Wire-Adapter specification (in layman terms, a USB-dongle that
diff --git a/drivers/usb/wusbcore/wa-nep.c b/drivers/usb/wusbcore/wa-nep.c
index e3819fc182b0..9fdcb6b84abf 100644
--- a/drivers/usb/wusbcore/wa-nep.c
+++ b/drivers/usb/wusbcore/wa-nep.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8]) 3 * WUSB Wire Adapter: Control/Data Streaming Interface (WUSB[8])
3 * Notification EndPoint support 4 * Notification EndPoint support
@@ -5,21 +6,6 @@
5 * Copyright (C) 2006 Intel Corporation 6 * Copyright (C) 2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * This part takes care of getting the notification from the hw 9 * This part takes care of getting the notification from the hw
24 * only and dispatching through wusbwad into 10 * only and dispatching through wusbwad into
25 * wa_notif_dispatch. Handling is done there. 11 * wa_notif_dispatch. Handling is done there.
diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
index c7ecdbe19a32..d0f1a6698460 100644
--- a/drivers/usb/wusbcore/wa-rpipe.c
+++ b/drivers/usb/wusbcore/wa-rpipe.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB Wire Adapter 3 * WUSB Wire Adapter
3 * rpipe management 4 * rpipe management
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs 9 * FIXME: docs
24 * 10 *
25 * RPIPE 11 * RPIPE
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index e70322b1dd02..7fca4e7e556d 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * WUSB Wire Adapter 3 * WUSB Wire Adapter
3 * Data transfer and URB enqueing 4 * Data transfer and URB enqueing
@@ -5,21 +6,6 @@
5 * Copyright (C) 2005-2006 Intel Corporation 6 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * How transfers work: get a buffer, break it up in segments (segment 9 * How transfers work: get a buffer, break it up in segments (segment
24 * size is a multiple of the maxpacket size). For each segment issue a 10 * size is a multiple of the maxpacket size). For each segment issue a
25 * segment request (struct wa_xfer_*), then send the data buffer if 11 * segment request (struct wa_xfer_*), then send the data buffer if
@@ -2156,6 +2142,7 @@ static void wa_complete_remaining_xfer_segs(struct wa_xfer *xfer,
2156 * do not increment RPIPE avail for the WA_SEG_DELAYED case 2142 * do not increment RPIPE avail for the WA_SEG_DELAYED case
2157 * since it has not been submitted to the RPIPE. 2143 * since it has not been submitted to the RPIPE.
2158 */ 2144 */
2145 /* fall through */
2159 case WA_SEG_DELAYED: 2146 case WA_SEG_DELAYED:
2160 xfer->segs_done++; 2147 xfer->segs_done++;
2161 current_seg->status = status; 2148 current_seg->status = status;
diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
index 5338e42533c8..e5ba6140c1ba 100644
--- a/drivers/usb/wusbcore/wusbhc.c
+++ b/drivers/usb/wusbcore/wusbhc.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Host Controller 3 * Wireless USB Host Controller
3 * sysfs glue, wusbcore module support and life cycle management 4 * sysfs glue, wusbcore module support and life cycle management
@@ -6,21 +7,6 @@
6 * Copyright (C) 2005-2006 Intel Corporation 7 * Copyright (C) 2005-2006 Intel Corporation
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * Creation/destruction of wusbhc is split in two parts; that that 10 * Creation/destruction of wusbhc is split in two parts; that that
25 * doesn't require the HCD to be added (wusbhc_{create,destroy}) and 11 * doesn't require the HCD to be added (wusbhc_{create,destroy}) and
26 * the one that requires (phase B, wusbhc_b_{create,destroy}). 12 * the one that requires (phase B, wusbhc_b_{create,destroy}).
diff --git a/drivers/usb/wusbcore/wusbhc.h b/drivers/usb/wusbcore/wusbhc.h
index 8c5bd000739b..7681d796ca5b 100644
--- a/drivers/usb/wusbcore/wusbhc.h
+++ b/drivers/usb/wusbcore/wusbhc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Host Controller 3 * Wireless USB Host Controller
3 * Common infrastructure for WHCI and HWA WUSB-HC drivers 4 * Common infrastructure for WHCI and HWA WUSB-HC drivers
@@ -6,21 +7,6 @@
6 * Copyright (C) 2005-2006 Intel Corporation 7 * Copyright (C) 2005-2006 Intel Corporation
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * 9 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * This driver implements parts common to all Wireless USB Host 10 * This driver implements parts common to all Wireless USB Host
25 * Controllers (struct wusbhc, embedding a struct usb_hcd) and is used 11 * Controllers (struct wusbhc, embedding a struct usb_hcd) and is used
26 * by: 12 * by:
diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h
index 6c901930eb3e..d16e8755f6a9 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -15,5 +15,6 @@
15#define PHY_TYPE_PCIE 2 15#define PHY_TYPE_PCIE 2
16#define PHY_TYPE_USB2 3 16#define PHY_TYPE_USB2 3
17#define PHY_TYPE_USB3 4 17#define PHY_TYPE_USB3 4
18#define PHY_TYPE_UFS 5
18 19
19#endif /* _DT_BINDINGS_PHY */ 20#endif /* _DT_BINDINGS_PHY */
diff --git a/include/linux/extcon-provider.h b/include/linux/extcon-provider.h
new file mode 100644
index 000000000000..2feca5881fa7
--- /dev/null
+++ b/include/linux/extcon-provider.h
@@ -0,0 +1,142 @@
1/*
2 * External Connector (extcon) framework
3 * - linux/include/linux/extcon-provider.h for extcon provider device driver.
4 *
5 * Copyright (C) 2017 Samsung Electronics
6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#ifndef __LINUX_EXTCON_PROVIDER_H__
19#define __LINUX_EXTCON_PROVIDER_H__
20
21#include <linux/extcon.h>
22
23struct extcon_dev;
24
25#if IS_ENABLED(CONFIG_EXTCON)
26
27/* Following APIs register/unregister the extcon device. */
28extern int extcon_dev_register(struct extcon_dev *edev);
29extern void extcon_dev_unregister(struct extcon_dev *edev);
30extern int devm_extcon_dev_register(struct device *dev,
31 struct extcon_dev *edev);
32extern void devm_extcon_dev_unregister(struct device *dev,
33 struct extcon_dev *edev);
34
35/* Following APIs allocate/free the memory of the extcon device. */
36extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
37extern void extcon_dev_free(struct extcon_dev *edev);
38extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
39 const unsigned int *cable);
40extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
41
42/* Synchronize the state and property value for each external connector. */
43extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
44
45/*
46 * Following APIs set the connected state of each external connector.
47 * The 'id' argument indicates the defined external connector.
48 */
49extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
50 bool state);
51extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
52 bool state);
53
54/*
55 * Following APIs set the property of each external connector.
56 * The 'id' argument indicates the defined external connector
57 * and the 'prop' indicates the extcon property.
58 *
59 * And extcon_set_property_capability() set the capability of the property
60 * for each external connector. They are used to set the capability of the
61 * property of each external connector based on the id and property.
62 */
63extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
64 unsigned int prop,
65 union extcon_property_value prop_val);
66extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
67 unsigned int prop,
68 union extcon_property_value prop_val);
69extern int extcon_set_property_capability(struct extcon_dev *edev,
70 unsigned int id, unsigned int prop);
71
72#else /* CONFIG_EXTCON */
73static inline int extcon_dev_register(struct extcon_dev *edev)
74{
75 return 0;
76}
77
78static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
79
80static inline int devm_extcon_dev_register(struct device *dev,
81 struct extcon_dev *edev)
82{
83 return -EINVAL;
84}
85
86static inline void devm_extcon_dev_unregister(struct device *dev,
87 struct extcon_dev *edev) { }
88
89static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
90{
91 return ERR_PTR(-ENOSYS);
92}
93
94static inline void extcon_dev_free(struct extcon_dev *edev) { }
95
96static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
97 const unsigned int *cable)
98{
99 return ERR_PTR(-ENOSYS);
100}
101
102static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
103
104
105static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
106 bool state)
107{
108 return 0;
109}
110
111static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
112 bool state)
113{
114 return 0;
115}
116
117static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
118{
119 return 0;
120}
121
122static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
123 unsigned int prop,
124 union extcon_property_value prop_val)
125{
126 return 0;
127}
128
129static inline int extcon_set_property_sync(struct extcon_dev *edev,
130 unsigned int id, unsigned int prop,
131 union extcon_property_value prop_val)
132{
133 return 0;
134}
135
136static inline int extcon_set_property_capability(struct extcon_dev *edev,
137 unsigned int id, unsigned int prop)
138{
139 return 0;
140}
141#endif /* CONFIG_EXTCON */
142#endif /* __LINUX_EXTCON_PROVIDER_H__ */
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 744d60ca80c3..6d94e82c8ad9 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * External Connector (extcon) framework 2 * External Connector (extcon) framework
3 * - linux/include/linux/extcon.h for extcon consumer device driver.
3 * 4 *
4 * Copyright (C) 2015 Samsung Electronics 5 * Copyright (C) 2015 Samsung Electronics
5 * Author: Chanwoo Choi <cw00.choi@samsung.com> 6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
@@ -170,61 +171,29 @@ union extcon_property_value {
170 int intval; /* type : integer (intval) */ 171 int intval; /* type : integer (intval) */
171}; 172};
172 173
173struct extcon_cable;
174struct extcon_dev; 174struct extcon_dev;
175 175
176#if IS_ENABLED(CONFIG_EXTCON) 176#if IS_ENABLED(CONFIG_EXTCON)
177
178/* Following APIs register/unregister the extcon device. */
179extern int extcon_dev_register(struct extcon_dev *edev);
180extern void extcon_dev_unregister(struct extcon_dev *edev);
181extern int devm_extcon_dev_register(struct device *dev,
182 struct extcon_dev *edev);
183extern void devm_extcon_dev_unregister(struct device *dev,
184 struct extcon_dev *edev);
185
186/* Following APIs allocate/free the memory of the extcon device. */
187extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
188extern void extcon_dev_free(struct extcon_dev *edev);
189extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
190 const unsigned int *cable);
191extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
192
193/* Synchronize the state and property value for each external connector. */
194extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
195
196/* 177/*
197 * Following APIs get/set the connected state of each external connector. 178 * Following APIs get the connected state of each external connector.
198 * The 'id' argument indicates the defined external connector. 179 * The 'id' argument indicates the defined external connector.
199 */ 180 */
200extern int extcon_get_state(struct extcon_dev *edev, unsigned int id); 181extern int extcon_get_state(struct extcon_dev *edev, unsigned int id);
201extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
202 bool state);
203extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
204 bool state);
205 182
206/* 183/*
207 * Following APIs get/set the property of each external connector. 184 * Following APIs get the property of each external connector.
208 * The 'id' argument indicates the defined external connector 185 * The 'id' argument indicates the defined external connector
209 * and the 'prop' indicates the extcon property. 186 * and the 'prop' indicates the extcon property.
210 * 187 *
211 * And extcon_get/set_property_capability() set the capability of the property 188 * And extcon_get_property_capability() get the capability of the property
212 * for each external connector. They are used to set the capability of the 189 * for each external connector. They are used to get the capability of the
213 * property of each external connector based on the id and property. 190 * property of each external connector based on the id and property.
214 */ 191 */
215extern int extcon_get_property(struct extcon_dev *edev, unsigned int id, 192extern int extcon_get_property(struct extcon_dev *edev, unsigned int id,
216 unsigned int prop, 193 unsigned int prop,
217 union extcon_property_value *prop_val); 194 union extcon_property_value *prop_val);
218extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
219 unsigned int prop,
220 union extcon_property_value prop_val);
221extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
222 unsigned int prop,
223 union extcon_property_value prop_val);
224extern int extcon_get_property_capability(struct extcon_dev *edev, 195extern int extcon_get_property_capability(struct extcon_dev *edev,
225 unsigned int id, unsigned int prop); 196 unsigned int id, unsigned int prop);
226extern int extcon_set_property_capability(struct extcon_dev *edev,
227 unsigned int id, unsigned int prop);
228 197
229/* 198/*
230 * Following APIs register the notifier block in order to detect 199 * Following APIs register the notifier block in order to detect
@@ -268,79 +237,17 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
268extern const char *extcon_get_edev_name(struct extcon_dev *edev); 237extern const char *extcon_get_edev_name(struct extcon_dev *edev);
269 238
270#else /* CONFIG_EXTCON */ 239#else /* CONFIG_EXTCON */
271static inline int extcon_dev_register(struct extcon_dev *edev)
272{
273 return 0;
274}
275
276static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
277
278static inline int devm_extcon_dev_register(struct device *dev,
279 struct extcon_dev *edev)
280{
281 return -EINVAL;
282}
283
284static inline void devm_extcon_dev_unregister(struct device *dev,
285 struct extcon_dev *edev) { }
286
287static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
288{
289 return ERR_PTR(-ENOSYS);
290}
291
292static inline void extcon_dev_free(struct extcon_dev *edev) { }
293
294static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
295 const unsigned int *cable)
296{
297 return ERR_PTR(-ENOSYS);
298}
299
300static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
301
302
303static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id) 240static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
304{ 241{
305 return 0; 242 return 0;
306} 243}
307 244
308static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
309 bool state)
310{
311 return 0;
312}
313
314static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
315 bool state)
316{
317 return 0;
318}
319
320static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
321{
322 return 0;
323}
324
325static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id, 245static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
326 unsigned int prop, 246 unsigned int prop,
327 union extcon_property_value *prop_val) 247 union extcon_property_value *prop_val)
328{ 248{
329 return 0; 249 return 0;
330} 250}
331static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
332 unsigned int prop,
333 union extcon_property_value prop_val)
334{
335 return 0;
336}
337
338static inline int extcon_set_property_sync(struct extcon_dev *edev,
339 unsigned int id, unsigned int prop,
340 union extcon_property_value prop_val)
341{
342 return 0;
343}
344 251
345static inline int extcon_get_property_capability(struct extcon_dev *edev, 252static inline int extcon_get_property_capability(struct extcon_dev *edev,
346 unsigned int id, unsigned int prop) 253 unsigned int id, unsigned int prop)
@@ -348,12 +255,6 @@ static inline int extcon_get_property_capability(struct extcon_dev *edev,
348 return 0; 255 return 0;
349} 256}
350 257
351static inline int extcon_set_property_capability(struct extcon_dev *edev,
352 unsigned int id, unsigned int prop)
353{
354 return 0;
355}
356
357static inline int extcon_register_notifier(struct extcon_dev *edev, 258static inline int extcon_register_notifier(struct extcon_dev *edev,
358 unsigned int id, struct notifier_block *nb) 259 unsigned int id, struct notifier_block *nb)
359{ 260{
diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h
index c19303b0ccfd..b8908bf8d315 100644
--- a/include/linux/mfd/max77843-private.h
+++ b/include/linux/mfd/max77843-private.h
@@ -245,10 +245,13 @@ enum max77843_irq_muic {
245#define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4) 245#define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4)
246 246
247/* MAX77843 CHG_CNFG_00 register */ 247/* MAX77843 CHG_CNFG_00 register */
248#define MAX77843_CHG_MODE_MASK 0x0f
248#define MAX77843_CHG_DISABLE 0x00 249#define MAX77843_CHG_DISABLE 0x00
249#define MAX77843_CHG_ENABLE 0x05 250#define MAX77843_CHG_ENABLE 0x05
250#define MAX77843_CHG_MASK 0x01 251#define MAX77843_CHG_MASK 0x01
252#define MAX77843_CHG_OTG_MASK 0x02
251#define MAX77843_CHG_BUCK_MASK 0x04 253#define MAX77843_CHG_BUCK_MASK 0x04
254#define MAX77843_CHG_BOOST_MASK 0x08
252 255
253/* MAX77843 CHG_CNFG_01 register */ 256/* MAX77843 CHG_CNFG_01 register */
254#define MAX77843_CHG_RESTART_THRESHOLD_100 0x00 257#define MAX77843_CHG_RESTART_THRESHOLD_100 0x00
@@ -347,6 +350,7 @@ enum max77843_irq_muic {
347/* MAX77843 CONTROL register */ 350/* MAX77843 CONTROL register */
348#define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0 351#define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0
349#define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3 352#define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3
353#define MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT 6
350#define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7 354#define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7
351#define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0 355#define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0
352#define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1 356#define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1
@@ -363,6 +367,7 @@ enum max77843_irq_muic {
363#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT) 367#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT)
364#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT) 368#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT)
365#define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT) 369#define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT)
370#define MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK BIT(MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT)
366#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT) 371#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT)
367#define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT) 372#define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT)
368#define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT) 373#define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 6dec43826303..3c8568aa82a5 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,7 +20,7 @@
20#include <linux/leds.h> 20#include <linux/leds.h>
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22#include <linux/regulator/driver.h> 22#include <linux/regulator/driver.h>
23#include <linux/extcon.h> 23#include <linux/extcon-provider.h>
24#include <linux/of_gpio.h> 24#include <linux/of_gpio.h>
25#include <linux/usb/phy_companion.h> 25#include <linux/usb/phy_companion.h>
26 26
diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 35c070ea6ea3..0a2c18a9771d 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -31,10 +31,7 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy *phy);
31 */ 31 */
32void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy); 32void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
33 33
34int ufs_qcom_phy_start_serdes(struct phy *phy);
35int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes); 34int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
36int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);
37int ufs_qcom_phy_is_pcs_ready(struct phy *phy);
38void ufs_qcom_phy_save_controller_version(struct phy *phy, 35void ufs_qcom_phy_save_controller_version(struct phy *phy,
39 u8 major, u16 minor, u16 step); 36 u8 major, u16 minor, u16 step);
40 37
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index e694d4008c4a..4f8423a948d5 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -29,6 +29,8 @@ enum phy_mode {
29 PHY_MODE_USB_OTG, 29 PHY_MODE_USB_OTG,
30 PHY_MODE_SGMII, 30 PHY_MODE_SGMII,
31 PHY_MODE_10GKR, 31 PHY_MODE_10GKR,
32 PHY_MODE_UFS_HS_A,
33 PHY_MODE_UFS_HS_B,
32}; 34};
33 35
34/** 36/**
@@ -39,6 +41,7 @@ enum phy_mode {
39 * @power_off: powering off the phy 41 * @power_off: powering off the phy
40 * @set_mode: set the mode of the phy 42 * @set_mode: set the mode of the phy
41 * @reset: resetting the phy 43 * @reset: resetting the phy
44 * @calibrate: calibrate the phy
42 * @owner: the module owner containing the ops 45 * @owner: the module owner containing the ops
43 */ 46 */
44struct phy_ops { 47struct phy_ops {
@@ -48,6 +51,7 @@ struct phy_ops {
48 int (*power_off)(struct phy *phy); 51 int (*power_off)(struct phy *phy);
49 int (*set_mode)(struct phy *phy, enum phy_mode mode); 52 int (*set_mode)(struct phy *phy, enum phy_mode mode);
50 int (*reset)(struct phy *phy); 53 int (*reset)(struct phy *phy);
54 int (*calibrate)(struct phy *phy);
51 struct module *owner; 55 struct module *owner;
52}; 56};
53 57
@@ -141,6 +145,7 @@ int phy_power_on(struct phy *phy);
141int phy_power_off(struct phy *phy); 145int phy_power_off(struct phy *phy);
142int phy_set_mode(struct phy *phy, enum phy_mode mode); 146int phy_set_mode(struct phy *phy, enum phy_mode mode);
143int phy_reset(struct phy *phy); 147int phy_reset(struct phy *phy);
148int phy_calibrate(struct phy *phy);
144static inline int phy_get_bus_width(struct phy *phy) 149static inline int phy_get_bus_width(struct phy *phy)
145{ 150{
146 return phy->attrs.bus_width; 151 return phy->attrs.bus_width;
@@ -262,6 +267,13 @@ static inline int phy_reset(struct phy *phy)
262 return -ENOSYS; 267 return -ENOSYS;
263} 268}
264 269
270static inline int phy_calibrate(struct phy *phy)
271{
272 if (!phy)
273 return 0;
274 return -ENOSYS;
275}
276
265static inline int phy_get_bus_width(struct phy *phy) 277static inline int phy_get_bus_width(struct phy *phy)
266{ 278{
267 return -ENOSYS; 279 return -ENOSYS;
@@ -291,7 +303,7 @@ static inline struct phy *devm_phy_get(struct device *dev, const char *string)
291static inline struct phy *devm_phy_optional_get(struct device *dev, 303static inline struct phy *devm_phy_optional_get(struct device *dev,
292 const char *string) 304 const char *string)
293{ 305{
294 return ERR_PTR(-ENOSYS); 306 return NULL;
295} 307}
296 308
297static inline struct phy *devm_of_phy_get(struct device *dev, 309static inline struct phy *devm_of_phy_get(struct device *dev,
diff --git a/include/linux/soc/brcmstb/brcmstb.h b/include/linux/soc/brcmstb/brcmstb.h
index 003f3dd5b192..12e548938bbb 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -2,10 +2,27 @@
2#ifndef __BRCMSTB_SOC_H 2#ifndef __BRCMSTB_SOC_H
3#define __BRCMSTB_SOC_H 3#define __BRCMSTB_SOC_H
4 4
5static inline u32 BRCM_ID(u32 reg)
6{
7 return reg >> 28 ? reg >> 16 : reg >> 8;
8}
9
10static inline u32 BRCM_REV(u32 reg)
11{
12 return reg & 0xff;
13}
14
5/* 15/*
6 * Bus Interface Unit control register setup, must happen early during boot, 16 * Bus Interface Unit control register setup, must happen early during boot,
7 * before SMP is brought up, called by machine entry point. 17 * before SMP is brought up, called by machine entry point.
8 */ 18 */
9void brcmstb_biuctrl_init(void); 19void brcmstb_biuctrl_init(void);
10 20
21/*
22 * Helper functions for getting family or product id from the
23 * SoC driver.
24 */
25u32 brcmstb_get_family_id(void);
26u32 brcmstb_get_product_id(void);
27
11#endif /* __BRCMSTB_SOC_H */ 28#endif /* __BRCMSTB_SOC_H */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 9c63792a8134..f019b0397599 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1767,7 +1767,21 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
1767extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, 1767extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
1768 unsigned char descindex, void *buf, int size); 1768 unsigned char descindex, void *buf, int size);
1769extern int usb_get_status(struct usb_device *dev, 1769extern int usb_get_status(struct usb_device *dev,
1770 int type, int target, void *data); 1770 int recip, int type, int target, void *data);
1771
1772static inline int usb_get_std_status(struct usb_device *dev,
1773 int recip, int target, void *data)
1774{
1775 return usb_get_status(dev, recip, USB_STATUS_TYPE_STANDARD, target,
1776 data);
1777}
1778
1779static inline int usb_get_ptm_status(struct usb_device *dev, void *data)
1780{
1781 return usb_get_status(dev, USB_RECIP_DEVICE, USB_STATUS_TYPE_PTM,
1782 0, data);
1783}
1784
1771extern int usb_string(struct usb_device *dev, int index, 1785extern int usb_string(struct usb_device *dev, int index,
1772 char *buf, size_t size); 1786 char *buf, size_t size);
1773 1787
diff --git a/include/linux/usb/association.h b/include/linux/usb/association.h
index 0a4a18b3c1bb..d7f3cb9b9db5 100644
--- a/include/linux/usb/association.h
+++ b/include/linux/usb/association.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB - Cable Based Association 3 * Wireless USB - Cable Based Association
3 * 4 *
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index fd73bc0e9027..3119d0ace7aa 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de> 3 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de>
3 * 4 *
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 3d84619110a4..170acd500ea1 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * <linux/usb/audio.h> -- USB Audio definitions. 3 * <linux/usb/audio.h> -- USB Audio definitions.
3 * 4 *
diff --git a/include/linux/usb/c67x00.h b/include/linux/usb/c67x00.h
index 83c6b45470ca..2fc39e3b7281 100644
--- a/include/linux/usb/c67x00.h
+++ b/include/linux/usb/c67x00.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * usb_c67x00.h: platform definitions for the Cypress C67X00 USB chip 3 * usb_c67x00.h: platform definitions for the Cypress C67X00 USB chip
3 * 4 *
diff --git a/include/linux/usb/cdc-wdm.h b/include/linux/usb/cdc-wdm.h
index 0b3f4295c025..9b895f93d8de 100644
--- a/include/linux/usb/cdc-wdm.h
+++ b/include/linux/usb/cdc-wdm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB CDC Device Management subdriver 3 * USB CDC Device Management subdriver
3 * 4 *
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index b5706f94ee9e..35d784cf32a4 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB CDC common helpers 3 * USB CDC common helpers
3 * 4 *
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 1a59699cf82a..1646c06989df 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
1/* 2/*
2 * Copyright (C) ST-Ericsson 2010-2012 3 * Copyright (C) ST-Ericsson 2010-2012
3 * Contact: Alexey Orishko <alexey.orishko@stericsson.com> 4 * Contact: Alexey Orishko <alexey.orishko@stericsson.com>
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index f665d2ceac20..cef0e44601f8 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * composite.h -- framework for usb gadgets which are composite devices 3 * composite.h -- framework for usb gadgets which are composite devices
3 * 4 *
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index e479033bd782..a15ce99dfc2d 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001-2002 by David Brownell 3 * Copyright (c) 2001-2002 by David Brownell
3 * 4 *
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index db0431b39a63..dd742afdc03f 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> 3 * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de>
3 * 4 *
diff --git a/include/linux/usb/g_hid.h b/include/linux/usb/g_hid.h
index 50f5745df28c..7581e488c237 100644
--- a/include/linux/usb/g_hid.h
+++ b/include/linux/usb/g_hid.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * g_hid.h -- Header file for USB HID gadget driver 3 * g_hid.h -- Header file for USB HID gadget driver
3 * 4 *
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 21468a722c4a..0142f3af0da6 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * <linux/usb/gadget.h> 3 * <linux/usb/gadget.h>
3 * 4 *
@@ -188,6 +189,8 @@ struct usb_ep_caps {
188 * @ops: Function pointers used to access hardware-specific operations. 189 * @ops: Function pointers used to access hardware-specific operations.
189 * @ep_list:the gadget's ep_list holds all of its endpoints 190 * @ep_list:the gadget's ep_list holds all of its endpoints
190 * @caps:The structure describing types and directions supported by endoint. 191 * @caps:The structure describing types and directions supported by endoint.
192 * @enabled: The current endpoint enabled/disabled state.
193 * @claimed: True if this endpoint is claimed by a function.
191 * @maxpacket:The maximum packet size used on this endpoint. The initial 194 * @maxpacket:The maximum packet size used on this endpoint. The initial
192 * value can sometimes be reduced (hardware allowing), according to 195 * value can sometimes be reduced (hardware allowing), according to
193 * the endpoint descriptor used to configure the endpoint. 196 * the endpoint descriptor used to configure the endpoint.
@@ -349,6 +352,9 @@ struct usb_gadget_ops {
349 * or B-Peripheral wants to take host role. 352 * or B-Peripheral wants to take host role.
350 * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to 353 * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to
351 * MaxPacketSize. 354 * MaxPacketSize.
355 * @quirk_altset_not_supp: UDC controller doesn't support alt settings.
356 * @quirk_stall_not_supp: UDC controller doesn't support stalling.
357 * @quirk_zlp_not_supp: UDC controller doesn't support ZLP.
352 * @quirk_avoids_skb_reserve: udc/platform wants to avoid skb_reserve() in 358 * @quirk_avoids_skb_reserve: udc/platform wants to avoid skb_reserve() in
353 * u_ether.c to improve performance. 359 * u_ether.c to improve performance.
354 * @is_selfpowered: if the gadget is self-powered. 360 * @is_selfpowered: if the gadget is self-powered.
diff --git a/include/linux/usb/gpio_vbus.h b/include/linux/usb/gpio_vbus.h
index 837bba604a0b..804fb06cf6d6 100644
--- a/include/linux/usb/gpio_vbus.h
+++ b/include/linux/usb/gpio_vbus.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * A simple GPIO VBUS sensing driver for B peripheral only devices 3 * A simple GPIO VBUS sensing driver for B peripheral only devices
3 * with internal transceivers. 4 * with internal transceivers.
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index a1f03ebfde47..176900528822 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (c) 2001-2002 by David Brownell 3 * Copyright (c) 2001-2002 by David Brownell
3 * 4 *
diff --git a/include/linux/usb/input.h b/include/linux/usb/input.h
index 0e010b220e85..974befa72ac0 100644
--- a/include/linux/usb/input.h
+++ b/include/linux/usb/input.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2005 Dmitry Torokhov 3 * Copyright (C) 2005 Dmitry Torokhov
3 * 4 *
diff --git a/include/linux/usb/isp1301.h b/include/linux/usb/isp1301.h
index d3a851c28b6a..dedb3b2473e8 100644
--- a/include/linux/usb/isp1301.h
+++ b/include/linux/usb/isp1301.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * NXP ISP1301 USB transceiver driver 3 * NXP ISP1301 USB transceiver driver
3 * 4 *
diff --git a/include/linux/usb/m66592.h b/include/linux/usb/m66592.h
index a4ba31ab2fed..2dfe68183495 100644
--- a/include/linux/usb/m66592.h
+++ b/include/linux/usb/m66592.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * M66592 driver platform data 3 * M66592 driver platform data
3 * 4 *
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
deleted file mode 100644
index 974c3796a23f..000000000000
--- a/include/linux/usb/msm_hsusb_hw.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (C) 2007 Google, Inc.
3 * Author: Brian Swetland <swetland@google.com>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__
17#define __LINUX_USB_GADGET_MSM72K_UDC_H__
18
19/* USB phy selector - in TCSR address range */
20#define USB2_PHY_SEL 0xfd4ab000
21
22#define USB_AHBBURST (MSM_USB_BASE + 0x0090)
23#define USB_AHBMODE (MSM_USB_BASE + 0x0098)
24#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0)
25#define ULPI_TX_PKT_EN_CLR_FIX BIT(19)
26
27#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */
28
29#define USB_USBCMD (MSM_USB_BASE + 0x0140)
30#define USB_PORTSC (MSM_USB_BASE + 0x0184)
31#define USB_OTGSC (MSM_USB_BASE + 0x01A4)
32#define USB_USBMODE (MSM_USB_BASE + 0x01A8)
33#define USB_PHY_CTRL (MSM_USB_BASE + 0x0240)
34#define USB_PHY_CTRL2 (MSM_USB_BASE + 0x0278)
35
36#define GENCONFIG_2_SESS_VLD_CTRL_EN BIT(7)
37#define USBCMD_SESS_VLD_CTRL BIT(25)
38
39#define USBCMD_RESET 2
40#define USB_USBINTR (MSM_USB_BASE + 0x0148)
41
42#define PORTSC_PHCD (1 << 23) /* phy suspend mode */
43#define PORTSC_PTS_MASK (3 << 30)
44#define PORTSC_PTS_ULPI (2 << 30)
45#define PORTSC_PTS_SERIAL (3 << 30)
46
47#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170)
48#define ULPI_RUN (1 << 30)
49#define ULPI_WRITE (1 << 29)
50#define ULPI_READ (0 << 29)
51#define ULPI_ADDR(n) (((n) & 255) << 16)
52#define ULPI_DATA(n) ((n) & 255)
53#define ULPI_DATA_READ(n) (((n) >> 8) & 255)
54
55/* synopsys 28nm phy registers */
56#define ULPI_PWR_CLK_MNG_REG 0x88
57#define OTG_COMP_DISABLE BIT(0)
58
59#define ULPI_MISC_A 0x96
60#define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1)
61#define ULPI_MISC_A_VBUSVLDEXT BIT(0)
62
63#define ASYNC_INTR_CTRL (1 << 29) /* Enable async interrupt */
64#define ULPI_STP_CTRL (1 << 30) /* Block communication with PHY */
65#define PHY_RETEN (1 << 1) /* PHY retention enable/disable */
66#define PHY_POR_ASSERT (1 << 0) /* USB2 28nm PHY POR ASSERT */
67
68/* OTG definitions */
69#define OTGSC_INTSTS_MASK (0x7f << 16)
70#define OTGSC_ID (1 << 8)
71#define OTGSC_BSV (1 << 11)
72#define OTGSC_IDIS (1 << 16)
73#define OTGSC_BSVIS (1 << 19)
74#define OTGSC_IDIE (1 << 24)
75#define OTGSC_BSVIE (1 << 27)
76
77#endif /* __LINUX_USB_GADGET_MSM72K_UDC_H__ */
diff --git a/include/linux/usb/musb-ux500.h b/include/linux/usb/musb-ux500.h
index 1e2c7130f6e1..c4b7ad9850ca 100644
--- a/include/linux/usb/musb-ux500.h
+++ b/include/linux/usb/musb-ux500.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2013 ST-Ericsson AB 3 * Copyright (C) 2013 ST-Ericsson AB
3 * 4 *
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index 725120224472..08b85caecfaf 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * NetChip 2280 high/full speed USB device controller. 3 * NetChip 2280 high/full speed USB device controller.
3 * Unlike many such controllers, this one talks PCI. 4 * Unlike many such controllers, this one talks PCI.
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
index 4031f47629ec..6cbe7a5c2b57 100644
--- a/include/linux/usb/of.h
+++ b/include/linux/usb/of.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * OF helpers for usb devices. 3 * OF helpers for usb devices.
3 * 4 *
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 012f2b7eb2b6..7eb16cf587ee 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> 3 * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de>
3 * 4 *
diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
index a0a8f878503c..e78eb577d0fa 100644
--- a/include/linux/usb/otg-fsm.h
+++ b/include/linux/usb/otg-fsm.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. 2/* Copyright (C) 2007,2008 Freescale Semiconductor, Inc.
2 * 3 *
3 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
diff --git a/include/linux/usb/phy_companion.h b/include/linux/usb/phy_companion.h
index edd2ec23d282..407f530061cd 100644
--- a/include/linux/usb/phy_companion.h
+++ b/include/linux/usb/phy_companion.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * phy-companion.h -- phy companion to indicate the comparator part of PHY 3 * phy-companion.h -- phy companion to indicate the comparator part of PHY
3 * 4 *
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 7cd553a3ce05..f1fcec2fd5f8 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -57,4 +57,10 @@
57 */ 57 */
58#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11) 58#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11)
59 59
60/*
61 * Device needs to be disconnected before suspend to prevent spurious
62 * wakeup.
63 */
64#define USB_QUIRK_DISCONNECT_SUSPEND BIT(12)
65
60#endif /* __LINUX_USB_QUIRKS_H */ 66#endif /* __LINUX_USB_QUIRKS_H */
diff --git a/include/linux/usb/r8a66597.h b/include/linux/usb/r8a66597.h
index 55805f9dcf21..c0753d026bbf 100644
--- a/include/linux/usb/r8a66597.h
+++ b/include/linux/usb/r8a66597.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * R8A66597 driver platform data 3 * R8A66597 driver platform data
3 * 4 *
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 00a47d058d83..67102f3d59d4 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-1.0+
1/* 2/*
2 * Renesas USB 3 * Renesas USB
3 * 4 *
@@ -183,8 +184,9 @@ struct renesas_usbhs_driver_param {
183#define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ 184#define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */
184}; 185};
185 186
186#define USBHS_TYPE_RCAR_GEN2 1 187#define USBHS_TYPE_RCAR_GEN2 1
187#define USBHS_TYPE_RCAR_GEN3 2 188#define USBHS_TYPE_RCAR_GEN3 2
189#define USBHS_TYPE_RCAR_GEN3_WITH_PLL 3
188 190
189/* 191/*
190 * option: 192 * option:
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index d44ef85db177..809bccd08455 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Host Side support for RNDIS Networking Links 3 * Host Side support for RNDIS Networking Links
3 * Copyright (C) 2005 by David Brownell 4 * Copyright (C) 2005 by David Brownell
diff --git a/include/linux/usb/samsung_usb_phy.h b/include/linux/usb/samsung_usb_phy.h
index 916782699f1c..dc0071741695 100644
--- a/include/linux/usb/samsung_usb_phy.h
+++ b/include/linux/usb/samsung_usb_phy.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Copyright (C) 2012 Samsung Electronics Co.Ltd 3 * Copyright (C) 2012 Samsung Electronics Co.Ltd
3 * http://www.samsung.com/ 4 * http://www.samsung.com/
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index e2f0ab07eea5..106551a5616e 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * USB Serial Converter stuff 3 * USB Serial Converter stuff
3 * 4 *
diff --git a/include/linux/usb/storage.h b/include/linux/usb/storage.h
index 305ee8db7faf..e0240f864548 100644
--- a/include/linux/usb/storage.h
+++ b/include/linux/usb/storage.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#ifndef __LINUX_USB_STORAGE_H 2#ifndef __LINUX_USB_STORAGE_H
2#define __LINUX_USB_STORAGE_H 3#define __LINUX_USB_STORAGE_H
3 4
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index 1de16c324ec8..d641ea1660b7 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2010 Google, Inc. 3 * Copyright (C) 2010 Google, Inc.
3 * 4 *
diff --git a/include/linux/usb/tilegx.h b/include/linux/usb/tilegx.h
index 2d65e3435680..817908573fe8 100644
--- a/include/linux/usb/tilegx.h
+++ b/include/linux/usb/tilegx.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2012 Tilera Corporation. All Rights Reserved. 3 * Copyright 2012 Tilera Corporation. All Rights Reserved.
3 * 4 *
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h
index 5f07407a367a..c515765adab7 100644
--- a/include/linux/usb/ulpi.h
+++ b/include/linux/usb/ulpi.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ulpi.h -- ULPI defines and function prorotypes 3 * ulpi.h -- ULPI defines and function prorotypes
3 * 4 *
diff --git a/include/linux/usb/usb338x.h b/include/linux/usb/usb338x.h
index 11525d8d89a7..7189e3387bf9 100644
--- a/include/linux/usb/usb338x.h
+++ b/include/linux/usb/usb338x.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB 338x super/high/full speed USB device controller. 3 * USB 338x super/high/full speed USB device controller.
3 * Unlike many such controllers, this one talks PCI. 4 * Unlike many such controllers, this one talks PCI.
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 97116379db5f..a69877734c4e 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * USB Networking Link Interface 3 * USB Networking Link Interface
3 * 4 *
diff --git a/include/linux/usb/wusb-wa.h b/include/linux/usb/wusb-wa.h
index c1257130769b..64a840b5106e 100644
--- a/include/linux/usb/wusb-wa.h
+++ b/include/linux/usb/wusb-wa.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Wire Adapter constants and structures. 3 * Wireless USB Wire Adapter constants and structures.
3 * 4 *
diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
index eeb28329fa3c..9e4a3213f2c2 100644
--- a/include/linux/usb/wusb.h
+++ b/include/linux/usb/wusb.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Wireless USB Standard Definitions 3 * Wireless USB Standard Definitions
3 * Event Size Tables 4 * Event Size Tables
diff --git a/include/linux/usb/xhci-dbgp.h b/include/linux/usb/xhci-dbgp.h
index 80c1cca1f529..0a37f1283bf0 100644
--- a/include/linux/usb/xhci-dbgp.h
+++ b/include/linux/usb/xhci-dbgp.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Standalone xHCI debug capability driver 3 * Standalone xHCI debug capability driver
3 * 4 *
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 04a26285416c..79aab0065ec8 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/*****************************************************************************/ 2/*****************************************************************************/
2 3
3/* 4/*
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index cec06625f407..41a0a81b01e6 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -144,6 +144,10 @@
144#define TEST_PACKET 4 144#define TEST_PACKET 4
145#define TEST_FORCE_EN 5 145#define TEST_FORCE_EN 5
146 146
147/* Status Type */
148#define USB_STATUS_TYPE_STANDARD 0
149#define USB_STATUS_TYPE_PTM 1
150
147/* 151/*
148 * New Feature Selectors as added by USB 3.0 152 * New Feature Selectors as added by USB 3.0
149 * See USB 3.0 spec Table 9-7 153 * See USB 3.0 spec Table 9-7
diff --git a/tools/usb/usbip/Makefile.am b/tools/usb/usbip/Makefile.am
index da3a430849a8..5961e9c18812 100644
--- a/tools/usb/usbip/Makefile.am
+++ b/tools/usb/usbip/Makefile.am
@@ -2,6 +2,7 @@
2SUBDIRS := libsrc src 2SUBDIRS := libsrc src
3includedir = @includedir@/usbip 3includedir = @includedir@/usbip
4include_HEADERS := $(addprefix libsrc/, \ 4include_HEADERS := $(addprefix libsrc/, \
5 usbip_common.h vhci_driver.h usbip_host_driver.h) 5 usbip_common.h vhci_driver.h usbip_host_driver.h \
6 list.h sysfs_utils.h usbip_host_common.h)
6 7
7dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8) 8dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8)