USB patches for 3.18-rc1
Here's the big USB patchset for 3.18-rc1. Also in here is the PHY tree, as it seems to fit well with the USB tree for various reasons... Anyway, lots of little changes in here, all over the place, full details in the changelog below. All have been in the linux-next tree for a while with no issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlQ0aLYACgkQMUfUDdst+ylBvwCgs9fGRj0RQkLyGhQdEpzdZtTU ZcwAoMPBImnaA1ZeSl7ZnoO8vC/WE4bR =tfpj -----END PGP SIGNATURE----- Merge tag 'usb-3.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB updates from Greg KH: "Here's the big USB patchset for 3.18-rc1. Also in here is the PHY tree, as it seems to fit well with the USB tree for various reasons... Anyway, lots of little changes in here, all over the place, full details in the changelog All have been in the linux-next tree for a while with no issues" * tag 'usb-3.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (244 commits) USB: host: st: fix typo 'CONFIG_USB_EHCI_HCD_ST' uas: Reduce number of function arguments for uas_alloc_foo functions xhci: Allow xHCI drivers to be built as separate modules xhci: Export symbols used by host-controller drivers xhci: Check for XHCI_COMP_MODE_QUIRK when disabling D3cold xhci: Introduce xhci_init_driver() usb: hcd: add generic PHY support usb: rename phy to usb_phy in HCD usb: gadget: uvc: fix up uvcg_v4l2_get_unmapped_area typo USB: host: st: fix ehci/ohci driver selection usb: host: ehci-exynos: Remove unnecessary usb-phy support usb: core: return -ENOTSUPP for all targeted hosts USB: Remove .owner field for driver usb: core: log higher level message on malformed LANGID descriptor usb: Add LED triggers for USB activity usb: Rename usb-common.c usb: gadget: Refactor request completion usb: gadget: Introduce usb_gadget_giveback_request() usb: dwc2/gadget: move phy bus legth initialization phy: remove .owner field for drivers using module_platform_driver ...
This commit is contained in:
Коммит
463311960e
|
@ -0,0 +1,12 @@
|
|||
What: /config/usb-gadget/gadget/functions/uac1.name
|
||||
Date: Sep 2014
|
||||
KernelVersion: 3.18
|
||||
Description:
|
||||
The attributes:
|
||||
|
||||
audio_buf_size - audio buffer size
|
||||
fn_cap - capture pcm device file name
|
||||
fn_cntl - control device file name
|
||||
fn_play - playback pcm device file name
|
||||
req_buf_size - ISO OUT endpoint request buffer size
|
||||
req_count - ISO OUT endpoint request count
|
|
@ -0,0 +1,12 @@
|
|||
What: /config/usb-gadget/gadget/functions/uac2.name
|
||||
Date: Sep 2014
|
||||
KernelVersion: 3.18
|
||||
Description:
|
||||
The attributes:
|
||||
|
||||
c_chmask - capture channel mask
|
||||
c_srate - capture sampling rate
|
||||
c_ssize - capture sample size (bytes)
|
||||
p_chmask - playback channel mask
|
||||
p_srate - playback sampling rate
|
||||
p_ssize - playback sample size (bytes)
|
|
@ -43,6 +43,19 @@ Description:
|
|||
Reading returns the currently active channel, or -1 if
|
||||
the radio controller is not beaconing.
|
||||
|
||||
What: /sys/class/uwb_rc/uwbN/ASIE
|
||||
Date: August 2014
|
||||
KernelVersion: 3.18
|
||||
Contact: linux-usb@vger.kernel.org
|
||||
Description:
|
||||
|
||||
The application-specific information element (ASIE)
|
||||
included in this device's beacon, in space separated
|
||||
hex octets.
|
||||
|
||||
Reading returns the current ASIE. Writing replaces
|
||||
the current ASIE with the one written.
|
||||
|
||||
What: /sys/class/uwb_rc/uwbN/scan
|
||||
Date: July 2008
|
||||
KernelVersion: 2.6.27
|
||||
|
|
|
@ -593,7 +593,7 @@ for (;;) {
|
|||
Each device has one control endpoint (endpoint zero)
|
||||
which supports a limited RPC style RPC access.
|
||||
Devices are configured
|
||||
by khubd (in the kernel) setting a device-wide
|
||||
by hub_wq (in the kernel) setting a device-wide
|
||||
<emphasis>configuration</emphasis> that affects things
|
||||
like power consumption and basic functionality.
|
||||
The endpoints are part of USB <emphasis>interfaces</emphasis>,
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
ST STiH407 USB PHY controller
|
||||
|
||||
This file documents the dt bindings for the usb picoPHY driver which is the PHY for both USB2 and USB3
|
||||
host controllers (when controlling usb2/1.1 devices) available on STiH407 SoC family from STMicroelectronics.
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "st,stih407-usb2-phy"
|
||||
- reg : contain the offset and length of the system configuration registers
|
||||
used as glue logic to control & parameter phy
|
||||
- reg-names : the names of the system configuration registers in "reg", should be "param" and "reg"
|
||||
- st,syscfg : sysconfig register to manage phy parameter at driver level
|
||||
- resets : list of phandle and reset specifier pairs. There should be two entries, one
|
||||
for the whole phy and one for the port
|
||||
- reset-names : list of reset signal names. Should be "global" and "port"
|
||||
See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
|
||||
See: Documentation/devicetree/bindings/reset/reset.txt
|
||||
|
||||
Example:
|
||||
|
||||
usb2_picophy0: usbpicophy@f8 {
|
||||
compatible = "st,stih407-usb2-phy";
|
||||
reg = <0xf8 0x04>, /* syscfg 5062 */
|
||||
<0xf4 0x04>; /* syscfg 5061 */
|
||||
reg-names = "param", "ctrl";
|
||||
#phy-cells = <0>;
|
||||
st,syscfg = <&syscfg_core>;
|
||||
resets = <&softreset STIH407_PICOPHY_SOFTRESET>,
|
||||
<&picophyreset STIH407_PICOPHY0_RESET>;
|
||||
reset-names = "global", "port";
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
STMicroelectronics STiH41x USB PHY binding
|
||||
------------------------------------------
|
||||
|
||||
This file contains documentation for the usb phy found in STiH415/6 SoCs from
|
||||
STMicroelectronics.
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "st,stih416-usb-phy" or "st,stih415-usb-phy"
|
||||
- st,syscfg : should be a phandle of the syscfg node
|
||||
- clock-names : must contain "osc_phy"
|
||||
- clocks : must contain an entry for each name in clock-names.
|
||||
See: Documentation/devicetree/bindings/clock/clock-bindings.txt
|
||||
- #phy-cells : must be 0 for this phy
|
||||
See: Documentation/devicetree/bindings/phy/phy-bindings.txt
|
||||
|
||||
Example:
|
||||
|
||||
usb2_phy: usb2phy@0 {
|
||||
compatible = "st,stih416-usb-phy";
|
||||
#phy-cell = <0>;
|
||||
st,syscfg = <&syscfg_rear>;
|
||||
clocks = <&clk_sysin>;
|
||||
clock-names = "osc_phy";
|
||||
};
|
|
@ -0,0 +1,39 @@
|
|||
Qualcomm DWC3 HS AND SS PHY CONTROLLER
|
||||
--------------------------------------
|
||||
|
||||
DWC3 PHY nodes are defined to describe on-chip Synopsis Physical layer
|
||||
controllers. Each DWC3 PHY controller should have its own node.
|
||||
|
||||
Required properties:
|
||||
- compatible: should contain one of the following:
|
||||
- "qcom,dwc3-hs-usb-phy" for High Speed Synopsis PHY controller
|
||||
- "qcom,dwc3-ss-usb-phy" for Super Speed Synopsis PHY controller
|
||||
- reg: offset and length of the DWC3 PHY controller register set
|
||||
- #phy-cells: must be zero
|
||||
- clocks: a list of phandles and clock-specifier pairs, one for each entry in
|
||||
clock-names.
|
||||
- clock-names: Should contain "ref" for the PHY reference clock
|
||||
|
||||
Optional clocks:
|
||||
"xo" External reference clock
|
||||
|
||||
Example:
|
||||
phy@100f8800 {
|
||||
compatible = "qcom,dwc3-hs-usb-phy";
|
||||
reg = <0x100f8800 0x30>;
|
||||
clocks = <&gcc USB30_0_UTMI_CLK>;
|
||||
clock-names = "ref";
|
||||
#phy-cells = <0>;
|
||||
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
phy@100f8830 {
|
||||
compatible = "qcom,dwc3-ss-usb-phy";
|
||||
reg = <0x100f8830 0x30>;
|
||||
clocks = <&gcc USB30_0_MASTER_CLK>;
|
||||
clock-names = "ref";
|
||||
#phy-cells = <0>;
|
||||
|
||||
status = "ok";
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
* Renesas R-Car generation 2 USB PHY
|
||||
|
||||
This file provides information on what the device node for the R-Car generation
|
||||
2 USB PHY contains.
|
||||
|
||||
Required properties:
|
||||
- compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
|
||||
"renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
|
||||
- reg: offset and length of the register block.
|
||||
- #address-cells: number of address cells for the USB channel subnodes, must
|
||||
be <1>.
|
||||
- #size-cells: number of size cells for the USB channel subnodes, must be <0>.
|
||||
- clocks: clock phandle and specifier pair.
|
||||
- clock-names: string, clock input name, must be "usbhs".
|
||||
|
||||
The USB PHY device tree node should have the subnodes corresponding to the USB
|
||||
channels. These subnodes must contain the following properties:
|
||||
- reg: the USB controller selector; see the table below for the values.
|
||||
- #phy-cells: see phy-bindings.txt in the same directory, must be <1>.
|
||||
|
||||
The phandle's argument in the PHY specifier is the USB controller selector for
|
||||
the USB channel; see the selector meanings below:
|
||||
|
||||
+-----------+---------------+---------------+
|
||||
|\ Selector | | |
|
||||
+ --------- + 0 | 1 |
|
||||
| Channel \| | |
|
||||
+-----------+---------------+---------------+
|
||||
| 0 | PCI EHCI/OHCI | HS-USB |
|
||||
| 2 | PCI EHCI/OHCI | xHCI |
|
||||
+-----------+---------------+---------------+
|
||||
|
||||
Example (Lager board):
|
||||
|
||||
usb-phy@e6590100 {
|
||||
compatible = "renesas,usb-phy-r8a7790";
|
||||
reg = <0 0xe6590100 0 0x100>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
clocks = <&mstp7_clks R8A7790_CLK_HSUSB>;
|
||||
clock-names = "usbhs";
|
||||
|
||||
usb-channel@0 {
|
||||
reg = <0>;
|
||||
#phy-cells = <1>;
|
||||
};
|
||||
usb-channel@2 {
|
||||
reg = <2>;
|
||||
#phy-cells = <1>;
|
||||
};
|
||||
};
|
|
@ -17,8 +17,11 @@ Samsung EXYNOS SoC series Display Port PHY
|
|||
-------------------------------------------------
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "samsung,exynos5250-dp-video-phy";
|
||||
- reg : offset and length of the Display Port PHY register set;
|
||||
- compatible : should be one of the following supported values:
|
||||
- "samsung,exynos5250-dp-video-phy"
|
||||
- "samsung,exynos5420-dp-video-phy"
|
||||
- samsung,pmu-syscon: phandle for PMU system controller interface, used to
|
||||
control pmu registers for power isolation.
|
||||
- #phy-cells : from the generic PHY bindings, must be 0;
|
||||
|
||||
Samsung S5P/EXYNOS SoC series USB PHY
|
||||
|
|
|
@ -19,6 +19,7 @@ Optional properties:
|
|||
- disable-over-current: disable over current detect
|
||||
- external-vbus-divider: enables off-chip resistor divider for Vbus
|
||||
- maximum-speed: limit the maximum connection speed to "full-speed".
|
||||
- tpl-support: TPL (Targeted Peripheral List) feature for targeted hosts
|
||||
|
||||
Examples:
|
||||
usb@02184000 { /* USB OTG */
|
||||
|
@ -30,4 +31,5 @@ usb@02184000 { /* USB OTG */
|
|||
disable-over-current;
|
||||
external-vbus-divider;
|
||||
maximum-speed = "full-speed";
|
||||
tpl-support;
|
||||
};
|
||||
|
|
|
@ -4,6 +4,9 @@ Platform DesignWare HS OTG USB 2.0 controller
|
|||
Required properties:
|
||||
- compatible : One of:
|
||||
- brcm,bcm2835-usb: The DWC2 USB controller instance in the BCM2835 SoC.
|
||||
- rockchip,rk3066-usb: The DWC2 USB controller instance in the rk3066 Soc;
|
||||
- "rockchip,rk3188-usb", "rockchip,rk3066-usb", "snps,dwc2": for rk3188 Soc;
|
||||
- "rockchip,rk3288-usb", "rockchip,rk3066-usb", "snps,dwc2": for rk3288 Soc;
|
||||
- snps,dwc2: A generic DWC2 USB controller with default parameters.
|
||||
- reg : Should contain 1 register range (address and length)
|
||||
- interrupts : Should contain 1 interrupt
|
||||
|
@ -15,6 +18,8 @@ Optional properties:
|
|||
- phys: phy provider specifier
|
||||
- phy-names: shall be "usb2-phy"
|
||||
Refer to phy/phy-bindings.txt for generic phy consumer properties
|
||||
- dr_mode: shall be one of "host", "peripheral" and "otg"
|
||||
Refer to usb/generic.txt
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
ST DWC3 glue logic
|
||||
|
||||
This file documents the parameters for the dwc3-st driver.
|
||||
This driver controls the glue logic used to configure the dwc3 core on
|
||||
STiH407 based platforms.
|
||||
|
||||
Required properties:
|
||||
- compatible : must be "st,stih407-dwc3"
|
||||
- reg : glue logic base address and USB syscfg ctrl register offset
|
||||
- reg-names : should be "reg-glue" and "syscfg-reg"
|
||||
- st,syscon : should be phandle to system configuration node which
|
||||
encompasses the glue registers
|
||||
- resets : list of phandle and reset specifier pairs. There should be two entries, one
|
||||
for the powerdown and softreset lines of the usb3 IP
|
||||
- reset-names : list of reset signal names. Names should be "powerdown" and "softreset"
|
||||
See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
|
||||
See: Documentation/devicetree/bindings/reset/reset.txt
|
||||
|
||||
- #address-cells, #size-cells : should be '1' if the device has sub-nodes
|
||||
with 'reg' property
|
||||
|
||||
- pinctl-names : A pinctrl state named "default" must be defined
|
||||
See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
|
||||
|
||||
- pinctrl-0 : Pin control group
|
||||
See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
|
||||
|
||||
- ranges : allows valid 1:1 translation between child's address space and
|
||||
parent's address space
|
||||
|
||||
Sub-nodes:
|
||||
The dwc3 core should be added as subnode to ST DWC3 glue as shown in the
|
||||
example below. The DT binding details of dwc3 can be found in:
|
||||
Documentation/devicetree/bindings/usb/dwc3.txt
|
||||
|
||||
NB: The dr_mode property described in [1] is NOT optional for this driver, as the default value
|
||||
is "otg", which isn't supported by this SoC. Valid dr_mode values for dwc3-st are either "host"
|
||||
or "device".
|
||||
|
||||
[1] Documentation/devicetree/bindings/usb/generic.txt
|
||||
|
||||
Example:
|
||||
|
||||
st_dwc3: dwc3@8f94000 {
|
||||
status = "disabled";
|
||||
compatible = "st,stih407-dwc3";
|
||||
reg = <0x08f94000 0x1000>, <0x110 0x4>;
|
||||
reg-names = "reg-glue", "syscfg-reg";
|
||||
st,syscfg = <&syscfg_core>;
|
||||
resets = <&powerdown STIH407_USB3_POWERDOWN>,
|
||||
<&softreset STIH407_MIPHY2_SOFTRESET>;
|
||||
reset-names = "powerdown",
|
||||
"softreset";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pinctrl_usb3>;
|
||||
ranges;
|
||||
|
||||
dwc3: dwc3@9900000 {
|
||||
compatible = "snps,dwc3";
|
||||
reg = <0x09900000 0x100000>;
|
||||
interrupts = <GIC_SPI 155 IRQ_TYPE_NONE>;
|
||||
dr_mode = "host";
|
||||
phys-names = "usb2-phy", "usb3-phy";
|
||||
phys = <&usb2_picophy2>, <&phy_port2 MIPHY_TYPE_USB>;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,39 @@
|
|||
ST USB EHCI controller
|
||||
|
||||
Required properties:
|
||||
- compatible : must be "st,st-ehci-300x"
|
||||
- reg : physical base addresses of the controller and length of memory mapped
|
||||
region
|
||||
- interrupts : one EHCI interrupt should be described here
|
||||
- pinctrl-names : a pinctrl state named "default" must be defined
|
||||
- pinctrl-0 : phandle referencing pin configuration of the USB controller
|
||||
See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
|
||||
- clocks : phandle list of usb clocks
|
||||
- clock-names : should be "ic" for interconnect clock and "clk48"
|
||||
See: Documentation/devicetree/bindings/clock/clock-bindings.txt
|
||||
|
||||
- phys : phandle for the PHY device
|
||||
- phy-names : should be "usb"
|
||||
- resets : phandle + reset specifier pairs to the powerdown and softreset lines
|
||||
of the USB IP
|
||||
- reset-names : should be "power" and "softreset"
|
||||
See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
|
||||
See: Documentation/devicetree/bindings/reset/reset.txt
|
||||
|
||||
Example:
|
||||
|
||||
ehci1: usb@0xfe203e00 {
|
||||
compatible = "st,st-ehci-300x";
|
||||
reg = <0xfe203e00 0x100>;
|
||||
interrupts = <GIC_SPI 148 IRQ_TYPE_NONE>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pinctrl_usb1>;
|
||||
clocks = <&clk_s_a1_ls 0>;
|
||||
phys = <&usb2_phy>;
|
||||
phy-names = "usb";
|
||||
status = "okay";
|
||||
|
||||
resets = <&powerdown STIH416_USB1_POWERDOWN>,
|
||||
<&softreset STIH416_USB1_SOFTRESET>;
|
||||
reset-names = "power", "softreset";
|
||||
};
|
|
@ -5,6 +5,7 @@ Required properties:
|
|||
* "fsl,imx23-usbphy" for imx23 and imx28
|
||||
* "fsl,imx6q-usbphy" for imx6dq and imx6dl
|
||||
* "fsl,imx6sl-usbphy" for imx6sl
|
||||
* "fsl,vf610-usbphy" for Vybrid vf610
|
||||
* "fsl,imx6sx-usbphy" for imx6sx
|
||||
"fsl,imx23-usbphy" is still a fallback for other strings
|
||||
- reg: Should contain registers location and length
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
ST USB OHCI controller
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible : must be "st,st-ohci-300x"
|
||||
- reg : physical base addresses of the controller and length of memory mapped
|
||||
region
|
||||
- interrupts : one OHCI controller interrupt should be described here
|
||||
- clocks : phandle list of usb clocks
|
||||
- clock-names : should be "ic" for interconnect clock and "clk48"
|
||||
See: Documentation/devicetree/bindings/clock/clock-bindings.txt
|
||||
|
||||
- phys : phandle for the PHY device
|
||||
- phy-names : should be "usb"
|
||||
|
||||
- resets : phandle to the powerdown and reset controller for the USB IP
|
||||
- reset-names : should be "power" and "softreset".
|
||||
See: Documentation/devicetree/bindings/reset/st,sti-powerdown.txt
|
||||
See: Documentation/devicetree/bindings/reset/reset.txt
|
||||
|
||||
Example:
|
||||
|
||||
ohci0: usb@0xfe1ffc00 {
|
||||
compatible = "st,st-ohci-300x";
|
||||
reg = <0xfe1ffc00 0x100>;
|
||||
interrupts = <GIC_SPI 149 IRQ_TYPE_NONE>;
|
||||
clocks = <&clk_s_a1_ls 0>,
|
||||
<&clockgen_b0 0>;
|
||||
clock-names = "ic", "clk48";
|
||||
phys = <&usb2_phy>;
|
||||
phy-names = "usb";
|
||||
status = "okay";
|
||||
|
||||
resets = <&powerdown STIH416_USB0_POWERDOWN>,
|
||||
<&softreset STIH416_USB0_SOFTRESET>;
|
||||
reset-names = "power", "softreset";
|
||||
};
|
|
@ -0,0 +1,66 @@
|
|||
Qualcomm SuperSpeed DWC3 USB SoC controller
|
||||
|
||||
Required properties:
|
||||
- compatible: should contain "qcom,dwc3"
|
||||
- clocks: A list of phandle + clock-specifier pairs for the
|
||||
clocks listed in clock-names
|
||||
- clock-names: Should contain the following:
|
||||
"core" Master/Core clock, have to be >= 125 MHz for SS
|
||||
operation and >= 60MHz for HS operation
|
||||
|
||||
Optional clocks:
|
||||
"iface" System bus AXI clock. Not present on all platforms
|
||||
"sleep" Sleep clock, used when USB3 core goes into low
|
||||
power mode (U3).
|
||||
|
||||
Required child node:
|
||||
A child node must exist to represent the core DWC3 IP block. The name of
|
||||
the node is not important. The content of the node is defined in dwc3.txt.
|
||||
|
||||
Phy documentation is provided in the following places:
|
||||
Documentation/devicetree/bindings/phy/qcom,dwc3-usb-phy.txt
|
||||
|
||||
Example device nodes:
|
||||
|
||||
hs_phy: phy@100f8800 {
|
||||
compatible = "qcom,dwc3-hs-usb-phy";
|
||||
reg = <0x100f8800 0x30>;
|
||||
clocks = <&gcc USB30_0_UTMI_CLK>;
|
||||
clock-names = "ref";
|
||||
#phy-cells = <0>;
|
||||
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
ss_phy: phy@100f8830 {
|
||||
compatible = "qcom,dwc3-ss-usb-phy";
|
||||
reg = <0x100f8830 0x30>;
|
||||
clocks = <&gcc USB30_0_MASTER_CLK>;
|
||||
clock-names = "ref";
|
||||
#phy-cells = <0>;
|
||||
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
usb3_0: usb30@0 {
|
||||
compatible = "qcom,dwc3";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
clocks = <&gcc USB30_0_MASTER_CLK>;
|
||||
clock-names = "core";
|
||||
|
||||
ranges;
|
||||
|
||||
status = "ok";
|
||||
|
||||
dwc3@10000000 {
|
||||
compatible = "snps,dwc3";
|
||||
reg = <0x10000000 0xcd00>;
|
||||
interrupts = <0 205 0x4>;
|
||||
phys = <&hs_phy>, <&ss_phy>;
|
||||
phy-names = "usb2-phy", "usb3-phy";
|
||||
tx-fifo-resize;
|
||||
dr_mode = "host";
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
Renesas Electronics USBHS driver
|
||||
|
||||
Required properties:
|
||||
- compatible: Must contain one of the following:
|
||||
- "renesas,usbhs-r8a7790"
|
||||
- "renesas,usbhs-r8a7791"
|
||||
- reg: Base address and length of the register for the USBHS
|
||||
- interrupts: Interrupt specifier for the USBHS
|
||||
- clocks: A list of phandle + clock specifier pairs
|
||||
|
||||
Optional properties:
|
||||
- renesas,buswait: Integer to use BUSWAIT register
|
||||
- renesas,enable-gpio: A gpio specifier to check GPIO determining if USB
|
||||
function should be enabled
|
||||
- phys: phandle + phy specifier pair
|
||||
- phy-names: must be "usb"
|
||||
|
||||
Example:
|
||||
usbhs: usb@e6590000 {
|
||||
compatible = "renesas,usbhs-r8a7790";
|
||||
reg = <0 0xe6590000 0 0x100>;
|
||||
interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&mstp7_clks R8A7790_CLK_HSUSB>;
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
Xilinx USB2 device controller
|
||||
|
||||
Required properties:
|
||||
- compatible : Should be "xlnx,usb2-device-4.00.a"
|
||||
- reg : Physical base address and size of the USB2
|
||||
device registers map.
|
||||
- interrupts : Should contain single irq line of USB2 device
|
||||
controller
|
||||
- xlnx,has-builtin-dma : if DMA is included
|
||||
|
||||
Example:
|
||||
axi-usb2-device@42e00000 {
|
||||
compatible = "xlnx,usb2-device-4.00.a";
|
||||
interrupts = <0x0 0x39 0x1>;
|
||||
reg = <0x42e00000 0x10000>;
|
||||
xlnx,has-builtin-dma;
|
||||
};
|
||||
|
|
@ -8,8 +8,8 @@ Optional properties:
|
|||
if I2C is used.
|
||||
- connect-gpios: Should specify GPIO for connect.
|
||||
- disabled-ports: Should specify the ports unused.
|
||||
'1' or '2' or '3' are availe for this property to describe the port
|
||||
number. 1~3 property values are possible to be desribed.
|
||||
'1' or '2' or '3' are available for this property to describe the port
|
||||
number. 1~3 property values are possible to be described.
|
||||
Do not describe this property if all ports have to be enabled.
|
||||
- intn-gpios: Should specify GPIO for interrupt.
|
||||
- reset-gpios: Should specify GPIO for reset.
|
||||
|
|
|
@ -4,6 +4,7 @@ Required properties:
|
|||
- #index-cells: Cells used to descibe usb controller index. Should be <1>
|
||||
- compatible: Should be one of below:
|
||||
"fsl,imx6q-usbmisc" for imx6q
|
||||
"fsl,vf610-usbmisc" for Vybrid vf610
|
||||
- reg: Should contain registers location and length
|
||||
|
||||
Examples:
|
||||
|
|
|
@ -29,6 +29,7 @@ calxeda Calxeda
|
|||
capella Capella Microsystems, Inc
|
||||
cavium Cavium, Inc.
|
||||
cdns Cadence Design Systems Inc.
|
||||
chipidea Chipidea, Inc
|
||||
chrp Common Hardware Reference Platform
|
||||
chunghwa Chunghwa Picture Tubes Ltd.
|
||||
cirrus Cirrus Logic, Inc.
|
||||
|
|
|
@ -3522,6 +3522,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
|
|||
READ_DISC_INFO command);
|
||||
e = NO_READ_CAPACITY_16 (don't use
|
||||
READ_CAPACITY_16 command);
|
||||
f = NO_REPORT_OPCODES (don't use report opcodes
|
||||
command, uas only);
|
||||
h = CAPACITY_HEURISTICS (decrease the
|
||||
reported device capacity by one
|
||||
sector if the number is odd);
|
||||
|
@ -3541,6 +3543,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
|
|||
bogus residue values);
|
||||
s = SINGLE_LUN (the device has only one
|
||||
Logical Unit);
|
||||
t = NO_ATA_1X (don't allow ATA(12) and ATA(16)
|
||||
commands, uas only);
|
||||
u = IGNORE_UAS (don't bind to the uas driver);
|
||||
w = NO_WP_DETECT (don't test whether the
|
||||
medium is write-protected).
|
||||
|
|
|
@ -161,19 +161,10 @@ now on), such as to start/stop beaconing, scan, allocate bandwidth, etc.
|
|||
The main building block here is the UWB device (struct uwb_dev). For
|
||||
each device that pops up in radio presence (ie: the UWB host receives a
|
||||
beacon from it) you get a struct uwb_dev that will show up in
|
||||
/sys/class/uwb and in /sys/bus/uwb/devices.
|
||||
/sys/bus/uwb/devices.
|
||||
|
||||
For each RC that is detected, a new struct uwb_rc is created. In turn, a
|
||||
RC is also a device, so they also show in /sys/class/uwb and
|
||||
/sys/bus/uwb/devices, but at the same time, only radio controllers show
|
||||
up in /sys/class/uwb_rc.
|
||||
|
||||
*
|
||||
|
||||
[*] The reason for RCs being also devices is that not only we can
|
||||
see them while enumerating the system device tree, but also on the
|
||||
radio (their beacons and stuff), so the handling has to be
|
||||
likewise to that of a device.
|
||||
For each RC that is detected, a new struct uwb_rc and struct uwb_dev are
|
||||
created. An entry is also created in /sys/class/uwb_rc for each RC.
|
||||
|
||||
Each RC driver is implemented by a separate driver that plugs into the
|
||||
interface that the UWB stack provides through a struct uwb_rc_ops. The
|
||||
|
@ -246,7 +237,7 @@ the beacon cache of dead devices].
|
|||
|
||||
Device lists
|
||||
|
||||
All UWB devices are kept in the list of the struct bus_type uwb_bus.
|
||||
All UWB devices are kept in the list of the struct bus_type uwb_bus_type.
|
||||
|
||||
|
||||
Bandwidth allocation
|
||||
|
@ -317,7 +308,7 @@ HC picks the /DN_Connect/ out (nep module sends to notif.c for delivery
|
|||
into /devconnect/). This process starts the authentication process for
|
||||
the device. First we allocate a /fake port/ and assign an
|
||||
unauthenticated address (128 to 255--what we really do is
|
||||
0x80 | fake_port_idx). We fiddle with the fake port status and /khubd/
|
||||
0x80 | fake_port_idx). We fiddle with the fake port status and /hub_wq/
|
||||
sees a new connection, so he moves on to enable the fake port with a reset.
|
||||
|
||||
So now we are in the reset path -- we know we have a non-yet enumerated
|
||||
|
@ -326,7 +317,7 @@ device with an unauthorized address; we ask user space to authenticate
|
|||
exchange (FIXME: not yet done) and issue a /set address 0/ to bring the
|
||||
device to the default state. Device is authenticated.
|
||||
|
||||
From here, the USB stack takes control through the usb_hcd ops. khubd
|
||||
From here, the USB stack takes control through the usb_hcd ops. hub_wq
|
||||
has seen the port status changes, as we have been toggling them. It will
|
||||
start enumerating and doing transfers through usb_hcd->urb_enqueue() to
|
||||
read descriptors and move our data.
|
||||
|
@ -340,7 +331,7 @@ Keep Alive IE; it responds with a /DN_Alive/ pong during the DNTS (this
|
|||
arrives to us as a notification through
|
||||
devconnect.c:wusb_handle_dn_alive(). If a device times out, we
|
||||
disconnect it from the system (cleaning up internal information and
|
||||
toggling the bits in the fake hub port, which kicks khubd into removing
|
||||
toggling the bits in the fake hub port, which kicks hub_wq into removing
|
||||
the rest of the stuff).
|
||||
|
||||
This is done through devconnect:__wusb_check_devs(), which will scan the
|
||||
|
|
|
@ -58,7 +58,7 @@ USB POLICY AGENT
|
|||
|
||||
The USB subsystem currently invokes /sbin/hotplug when USB devices
|
||||
are added or removed from system. The invocation is done by the kernel
|
||||
hub daemon thread [khubd], or else as part of root hub initialization
|
||||
hub workqueue [hub_wq], or else as part of root hub initialization
|
||||
(done by init, modprobe, kapmd, etc). Its single command line parameter
|
||||
is the string "usb", and it passes these environment variables:
|
||||
|
||||
|
|
16
MAINTAINERS
16
MAINTAINERS
|
@ -1387,12 +1387,17 @@ S: Maintained
|
|||
F: arch/arm/mach-sti/
|
||||
F: arch/arm/boot/dts/sti*
|
||||
F: drivers/clocksource/arm_global_timer.c
|
||||
F: drivers/reset/sti/
|
||||
F: drivers/pinctrl/pinctrl-st.c
|
||||
F: drivers/media/rc/st_rc.c
|
||||
F: drivers/i2c/busses/i2c-st.c
|
||||
F: drivers/tty/serial/st-asc.c
|
||||
F: drivers/media/rc/st_rc.c
|
||||
F: drivers/mmc/host/sdhci-st.c
|
||||
F: drivers/phy/phy-stih407-usb.c
|
||||
F: drivers/phy/phy-stih41x-usb.c
|
||||
F: drivers/pinctrl/pinctrl-st.c
|
||||
F: drivers/reset/sti/
|
||||
F: drivers/tty/serial/st-asc.c
|
||||
F: drivers/usb/dwc3/dwc3-st.c
|
||||
F: drivers/usb/host/ehci-st.c
|
||||
F: drivers/usb/host/ohci-st.c
|
||||
|
||||
ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT
|
||||
M: Lennert Buytenhek <kernel@wantstofly.org>
|
||||
|
@ -2849,6 +2854,7 @@ F: drivers/platform/x86/dell-wmi.c
|
|||
DESIGNWARE USB2 DRD IP DRIVER
|
||||
M: Paul Zimmerman <paulz@synopsys.com>
|
||||
L: linux-usb@vger.kernel.org
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
|
||||
S: Maintained
|
||||
F: drivers/usb/dwc2/
|
||||
|
||||
|
@ -9682,7 +9688,7 @@ USB WEBCAM GADGET
|
|||
M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
||||
L: linux-usb@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/usb/gadget/function/*uvc*.c
|
||||
F: drivers/usb/gadget/function/*uvc*
|
||||
F: drivers/usb/gadget/legacy/webcam.c
|
||||
|
||||
USB WIRELESS RNDIS DRIVER (rndis_wlan)
|
||||
|
|
|
@ -69,8 +69,9 @@
|
|||
// reawaken network queue this soon after stopping; else watchdog barks
|
||||
#define TX_TIMEOUT_JIFFIES (5*HZ)
|
||||
|
||||
// throttle rx/tx briefly after some faults, so khubd might disconnect()
|
||||
// us (it polls at HZ/4 usually) before we report too many false errors.
|
||||
/* throttle rx/tx briefly after some faults, so hub_wq might disconnect()
|
||||
* us (it polls at HZ/4 usually) before we report too many false errors.
|
||||
*/
|
||||
#define THROTTLE_JIFFIES (HZ/8)
|
||||
|
||||
// between wakeups
|
||||
|
@ -595,9 +596,9 @@ static void rx_complete (struct urb *urb)
|
|||
"rx shutdown, code %d\n", urb_status);
|
||||
goto block;
|
||||
|
||||
/* we get controller i/o faults during khubd disconnect() delays.
|
||||
/* we get controller i/o faults during hub_wq disconnect() delays.
|
||||
* throttle down resubmits, to avoid log floods; just temporarily,
|
||||
* so we still recover when the fault isn't a khubd delay.
|
||||
* so we still recover when the fault isn't a hub_wq delay.
|
||||
*/
|
||||
case -EPROTO:
|
||||
case -ETIME:
|
||||
|
@ -1185,8 +1186,9 @@ static void tx_complete (struct urb *urb)
|
|||
case -ESHUTDOWN: // hardware gone
|
||||
break;
|
||||
|
||||
// like rx, tx gets controller i/o faults during khubd delays
|
||||
// and so it uses the same throttling mechanism.
|
||||
/* like rx, tx gets controller i/o faults during hub_wq
|
||||
* delays and so it uses the same throttling mechanism.
|
||||
*/
|
||||
case -EPROTO:
|
||||
case -ETIME:
|
||||
case -EILSEQ:
|
||||
|
|
|
@ -48,6 +48,13 @@ config PHY_MIPHY365X
|
|||
Enable this to support the miphy transceiver (for SATA/PCIE)
|
||||
that is part of STMicroelectronics STiH41x SoC series.
|
||||
|
||||
config PHY_RCAR_GEN2
|
||||
tristate "Renesas R-Car generation 2 USB PHY driver"
|
||||
depends on ARCH_SHMOBILE
|
||||
depends on GENERIC_PHY
|
||||
help
|
||||
Support for USB PHY found on Renesas R-Car generation 2 SoCs.
|
||||
|
||||
config OMAP_CONTROL_PHY
|
||||
tristate "OMAP CONTROL PHY Driver"
|
||||
depends on ARCH_OMAP2PLUS || COMPILE_TEST
|
||||
|
@ -232,4 +239,21 @@ config PHY_XGENE
|
|||
help
|
||||
This option enables support for APM X-Gene SoC multi-purpose PHY.
|
||||
|
||||
config PHY_STIH407_USB
|
||||
tristate "STMicroelectronics USB2 picoPHY driver for STiH407 family"
|
||||
depends on RESET_CONTROLLER
|
||||
depends on ARCH_STI || COMPILE_TEST
|
||||
select GENERIC_PHY
|
||||
help
|
||||
Enable this support to enable the picoPHY device used by USB2
|
||||
and USB3 controllers on STMicroelectronics STiH407 SoC families.
|
||||
|
||||
config PHY_STIH41X_USB
|
||||
tristate "STMicroelectronics USB2 PHY driver for STiH41x series"
|
||||
depends on ARCH_STI
|
||||
select GENERIC_PHY
|
||||
help
|
||||
Enable this to support the USB transceiver that is part of
|
||||
STMicroelectronics STiH41x SoC series.
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o
|
|||
obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o
|
||||
obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
|
||||
obj-$(CONFIG_PHY_MIPHY365X) += phy-miphy365x.o
|
||||
obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o
|
||||
obj-$(CONFIG_OMAP_CONTROL_PHY) += phy-omap-control.o
|
||||
obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o
|
||||
obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o
|
||||
|
@ -28,3 +29,5 @@ obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o
|
|||
obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
|
||||
obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
|
||||
obj-$(CONFIG_PHY_XGENE) += phy-xgene.o
|
||||
obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-usb.o
|
||||
obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o
|
||||
|
|
|
@ -143,7 +143,6 @@ static struct platform_driver bcm_kona_usb2_driver = {
|
|||
.probe = bcm_kona_usb2_probe,
|
||||
.driver = {
|
||||
.name = "bcm-kona-usb2",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = bcm_kona_usb2_dt_ids,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -273,7 +273,6 @@ static struct platform_driver phy_berlin_sata_driver = {
|
|||
.probe = phy_berlin_sata_probe,
|
||||
.driver = {
|
||||
.name = "phy-berlin-sata",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = phy_berlin_sata_of_match,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -13,44 +13,55 @@
|
|||
#include <linux/io.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/mfd/syscon/exynos5-pmu.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
/* DPTX_PHY_CONTROL register */
|
||||
#define EXYNOS_DPTX_PHY_ENABLE (1 << 0)
|
||||
|
||||
struct exynos_dp_video_phy {
|
||||
void __iomem *regs;
|
||||
struct exynos_dp_video_phy_drvdata {
|
||||
u32 phy_ctrl_offset;
|
||||
};
|
||||
|
||||
static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
|
||||
struct exynos_dp_video_phy {
|
||||
struct regmap *regs;
|
||||
const struct exynos_dp_video_phy_drvdata *drvdata;
|
||||
};
|
||||
|
||||
static void exynos_dp_video_phy_pwr_isol(struct exynos_dp_video_phy *state,
|
||||
unsigned int on)
|
||||
{
|
||||
u32 reg;
|
||||
unsigned int val;
|
||||
|
||||
reg = readl(state->regs);
|
||||
if (on)
|
||||
reg |= EXYNOS_DPTX_PHY_ENABLE;
|
||||
else
|
||||
reg &= ~EXYNOS_DPTX_PHY_ENABLE;
|
||||
writel(reg, state->regs);
|
||||
if (IS_ERR(state->regs))
|
||||
return;
|
||||
|
||||
return 0;
|
||||
val = on ? 0 : EXYNOS5_PHY_ENABLE;
|
||||
|
||||
regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
|
||||
EXYNOS5_PHY_ENABLE, val);
|
||||
}
|
||||
|
||||
static int exynos_dp_video_phy_power_on(struct phy *phy)
|
||||
{
|
||||
struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
|
||||
|
||||
return __set_phy_state(state, 1);
|
||||
/* Disable power isolation on DP-PHY */
|
||||
exynos_dp_video_phy_pwr_isol(state, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int exynos_dp_video_phy_power_off(struct phy *phy)
|
||||
{
|
||||
struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
|
||||
|
||||
return __set_phy_state(state, 0);
|
||||
/* Enable power isolation on DP-PHY */
|
||||
exynos_dp_video_phy_pwr_isol(state, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct phy_ops exynos_dp_video_phy_ops = {
|
||||
|
@ -59,11 +70,31 @@ static struct phy_ops exynos_dp_video_phy_ops = {
|
|||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
|
||||
.phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL,
|
||||
};
|
||||
|
||||
static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
|
||||
.phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL,
|
||||
};
|
||||
|
||||
static const struct of_device_id exynos_dp_video_phy_of_match[] = {
|
||||
{
|
||||
.compatible = "samsung,exynos5250-dp-video-phy",
|
||||
.data = &exynos5250_dp_video_phy,
|
||||
}, {
|
||||
.compatible = "samsung,exynos5420-dp-video-phy",
|
||||
.data = &exynos5420_dp_video_phy,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
|
||||
|
||||
static int exynos_dp_video_phy_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct exynos_dp_video_phy *state;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
const struct of_device_id *match;
|
||||
struct phy_provider *phy_provider;
|
||||
struct phy *phy;
|
||||
|
||||
|
@ -71,11 +102,15 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
|
|||
if (!state)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
||||
state->regs = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(state->regs))
|
||||
state->regs = syscon_regmap_lookup_by_phandle(dev->of_node,
|
||||
"samsung,pmu-syscon");
|
||||
if (IS_ERR(state->regs)) {
|
||||
dev_err(dev, "Failed to lookup PMU regmap\n");
|
||||
return PTR_ERR(state->regs);
|
||||
}
|
||||
|
||||
match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
|
||||
state->drvdata = match->data;
|
||||
|
||||
phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
|
||||
if (IS_ERR(phy)) {
|
||||
|
@ -89,17 +124,10 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
|
|||
return PTR_ERR_OR_ZERO(phy_provider);
|
||||
}
|
||||
|
||||
static const struct of_device_id exynos_dp_video_phy_of_match[] = {
|
||||
{ .compatible = "samsung,exynos5250-dp-video-phy" },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
|
||||
|
||||
static struct platform_driver exynos_dp_video_phy_driver = {
|
||||
.probe = exynos_dp_video_phy_probe,
|
||||
.driver = {
|
||||
.name = "exynos-dp-video-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = exynos_dp_video_phy_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -165,7 +165,6 @@ static struct platform_driver exynos_mipi_video_phy_driver = {
|
|||
.driver = {
|
||||
.of_match_table = exynos_mipi_video_phy_of_match,
|
||||
.name = "exynos-mipi-video-phy",
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
module_platform_driver(exynos_mipi_video_phy_driver);
|
||||
|
|
|
@ -667,7 +667,6 @@ static struct platform_driver exynos5_usb3drd_phy = {
|
|||
.driver = {
|
||||
.of_match_table = exynos5_usbdrd_phy_of_match,
|
||||
.name = "exynos5_usb3drd_phy",
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -240,7 +240,6 @@ static struct platform_driver exynos_sata_phy_driver = {
|
|||
.driver = {
|
||||
.of_match_table = exynos_sata_phy_of_match,
|
||||
.name = "samsung,sata-phy",
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
module_platform_driver(exynos_sata_phy_driver);
|
||||
|
|
|
@ -180,7 +180,6 @@ static struct platform_driver hix5hd2_sata_phy_driver = {
|
|||
.probe = hix5hd2_sata_phy_probe,
|
||||
.driver = {
|
||||
.name = "hix5hd2-sata-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = hix5hd2_sata_phy_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -626,7 +626,6 @@ static struct platform_driver miphy365x_driver = {
|
|||
.probe = miphy365x_probe,
|
||||
.driver = {
|
||||
.name = "miphy365x-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = miphy365x_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -89,6 +89,8 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
|
|||
struct phy *phy;
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
priv->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
|
@ -126,7 +128,6 @@ static struct platform_driver phy_mvebu_sata_driver = {
|
|||
.probe = phy_mvebu_sata_probe,
|
||||
.driver = {
|
||||
.name = "phy-mvebu-sata",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = phy_mvebu_sata_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -295,10 +295,8 @@ static int omap_control_phy_probe(struct platform_device *pdev)
|
|||
|
||||
control_phy = devm_kzalloc(&pdev->dev, sizeof(*control_phy),
|
||||
GFP_KERNEL);
|
||||
if (!control_phy) {
|
||||
dev_err(&pdev->dev, "unable to alloc memory for control phy\n");
|
||||
if (!control_phy)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
control_phy->dev = &pdev->dev;
|
||||
control_phy->type = *(enum omap_control_phy_type *)of_id->data;
|
||||
|
@ -347,7 +345,6 @@ static struct platform_driver omap_control_phy_driver = {
|
|||
.probe = omap_control_phy_probe,
|
||||
.driver = {
|
||||
.name = "omap-control-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(omap_control_phy_id_table),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -212,16 +212,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
|
|||
phy_data = (struct usb_phy_data *)of_id->data;
|
||||
|
||||
phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
|
||||
if (!phy) {
|
||||
dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n");
|
||||
if (!phy)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL);
|
||||
if (!otg) {
|
||||
dev_err(&pdev->dev, "unable to allocate memory for USB OTG\n");
|
||||
if (!otg)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
phy->dev = &pdev->dev;
|
||||
|
||||
|
@ -382,7 +378,6 @@ static struct platform_driver omap_usb2_driver = {
|
|||
.remove = omap_usb2_remove,
|
||||
.driver = {
|
||||
.name = "omap-usb2",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = DEV_PM_OPS,
|
||||
.of_match_table = of_match_ptr(omap_usb2_id_table),
|
||||
},
|
||||
|
|
|
@ -279,7 +279,6 @@ static struct platform_driver qcom_apq8064_sata_phy_driver = {
|
|||
.remove = qcom_apq8064_sata_phy_remove,
|
||||
.driver = {
|
||||
.name = "qcom-apq8064-sata-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = qcom_apq8064_sata_phy_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -201,7 +201,6 @@ static struct platform_driver qcom_ipq806x_sata_phy_driver = {
|
|||
.remove = qcom_ipq806x_sata_phy_remove,
|
||||
.driver = {
|
||||
.name = "qcom-ipq806x-sata-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = qcom_ipq806x_sata_phy_of_match,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* Renesas R-Car Gen2 PHY driver
|
||||
*
|
||||
* Copyright (C) 2014 Renesas Solutions Corp.
|
||||
* Copyright (C) 2014 Cogent Embedded, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#include <asm/cmpxchg.h>
|
||||
|
||||
#define USBHS_LPSTS 0x02
|
||||
#define USBHS_UGCTRL 0x80
|
||||
#define USBHS_UGCTRL2 0x84
|
||||
#define USBHS_UGSTS 0x88 /* The manuals have 0x90 */
|
||||
|
||||
/* Low Power Status register (LPSTS) */
|
||||
#define USBHS_LPSTS_SUSPM 0x4000
|
||||
|
||||
/* USB General control register (UGCTRL) */
|
||||
#define USBHS_UGCTRL_CONNECT 0x00000004
|
||||
#define USBHS_UGCTRL_PLLRESET 0x00000001
|
||||
|
||||
/* USB General control register 2 (UGCTRL2) */
|
||||
#define USBHS_UGCTRL2_USB2SEL 0x80000000
|
||||
#define USBHS_UGCTRL2_USB2SEL_PCI 0x00000000
|
||||
#define USBHS_UGCTRL2_USB2SEL_USB30 0x80000000
|
||||
#define USBHS_UGCTRL2_USB0SEL 0x00000030
|
||||
#define USBHS_UGCTRL2_USB0SEL_PCI 0x00000010
|
||||
#define USBHS_UGCTRL2_USB0SEL_HS_USB 0x00000030
|
||||
|
||||
/* USB General status register (UGSTS) */
|
||||
#define USBHS_UGSTS_LOCK 0x00000300 /* The manuals have 0x3 */
|
||||
|
||||
#define PHYS_PER_CHANNEL 2
|
||||
|
||||
struct rcar_gen2_phy {
|
||||
struct phy *phy;
|
||||
struct rcar_gen2_channel *channel;
|
||||
int number;
|
||||
u32 select_value;
|
||||
};
|
||||
|
||||
struct rcar_gen2_channel {
|
||||
struct device_node *of_node;
|
||||
struct rcar_gen2_phy_driver *drv;
|
||||
struct rcar_gen2_phy phys[PHYS_PER_CHANNEL];
|
||||
int selected_phy;
|
||||
u32 select_mask;
|
||||
};
|
||||
|
||||
struct rcar_gen2_phy_driver {
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
spinlock_t lock;
|
||||
int num_channels;
|
||||
struct rcar_gen2_channel *channels;
|
||||
};
|
||||
|
||||
static int rcar_gen2_phy_init(struct phy *p)
|
||||
{
|
||||
struct rcar_gen2_phy *phy = phy_get_drvdata(p);
|
||||
struct rcar_gen2_channel *channel = phy->channel;
|
||||
struct rcar_gen2_phy_driver *drv = channel->drv;
|
||||
unsigned long flags;
|
||||
u32 ugctrl2;
|
||||
|
||||
/*
|
||||
* Try to acquire exclusive access to PHY. The first driver calling
|
||||
* phy_init() on a given channel wins, and all attempts to use another
|
||||
* PHY on this channel will fail until phy_exit() is called by the first
|
||||
* driver. Achieving this with cmpxcgh() should be SMP-safe.
|
||||
*/
|
||||
if (cmpxchg(&channel->selected_phy, -1, phy->number) != -1)
|
||||
return -EBUSY;
|
||||
|
||||
clk_prepare_enable(drv->clk);
|
||||
|
||||
spin_lock_irqsave(&drv->lock, flags);
|
||||
ugctrl2 = readl(drv->base + USBHS_UGCTRL2);
|
||||
ugctrl2 &= ~channel->select_mask;
|
||||
ugctrl2 |= phy->select_value;
|
||||
writel(ugctrl2, drv->base + USBHS_UGCTRL2);
|
||||
spin_unlock_irqrestore(&drv->lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rcar_gen2_phy_exit(struct phy *p)
|
||||
{
|
||||
struct rcar_gen2_phy *phy = phy_get_drvdata(p);
|
||||
struct rcar_gen2_channel *channel = phy->channel;
|
||||
|
||||
clk_disable_unprepare(channel->drv->clk);
|
||||
|
||||
channel->selected_phy = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rcar_gen2_phy_power_on(struct phy *p)
|
||||
{
|
||||
struct rcar_gen2_phy *phy = phy_get_drvdata(p);
|
||||
struct rcar_gen2_phy_driver *drv = phy->channel->drv;
|
||||
void __iomem *base = drv->base;
|
||||
unsigned long flags;
|
||||
u32 value;
|
||||
int err = 0, i;
|
||||
|
||||
/* Skip if it's not USBHS */
|
||||
if (phy->select_value != USBHS_UGCTRL2_USB0SEL_HS_USB)
|
||||
return 0;
|
||||
|
||||
spin_lock_irqsave(&drv->lock, flags);
|
||||
|
||||
/* Power on USBHS PHY */
|
||||
value = readl(base + USBHS_UGCTRL);
|
||||
value &= ~USBHS_UGCTRL_PLLRESET;
|
||||
writel(value, base + USBHS_UGCTRL);
|
||||
|
||||
value = readw(base + USBHS_LPSTS);
|
||||
value |= USBHS_LPSTS_SUSPM;
|
||||
writew(value, base + USBHS_LPSTS);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
value = readl(base + USBHS_UGSTS);
|
||||
if ((value & USBHS_UGSTS_LOCK) == USBHS_UGSTS_LOCK) {
|
||||
value = readl(base + USBHS_UGCTRL);
|
||||
value |= USBHS_UGCTRL_CONNECT;
|
||||
writel(value, base + USBHS_UGCTRL);
|
||||
goto out;
|
||||
}
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
/* Timed out waiting for the PLL lock */
|
||||
err = -ETIMEDOUT;
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&drv->lock, flags);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int rcar_gen2_phy_power_off(struct phy *p)
|
||||
{
|
||||
struct rcar_gen2_phy *phy = phy_get_drvdata(p);
|
||||
struct rcar_gen2_phy_driver *drv = phy->channel->drv;
|
||||
void __iomem *base = drv->base;
|
||||
unsigned long flags;
|
||||
u32 value;
|
||||
|
||||
/* Skip if it's not USBHS */
|
||||
if (phy->select_value != USBHS_UGCTRL2_USB0SEL_HS_USB)
|
||||
return 0;
|
||||
|
||||
spin_lock_irqsave(&drv->lock, flags);
|
||||
|
||||
/* Power off USBHS PHY */
|
||||
value = readl(base + USBHS_UGCTRL);
|
||||
value &= ~USBHS_UGCTRL_CONNECT;
|
||||
writel(value, base + USBHS_UGCTRL);
|
||||
|
||||
value = readw(base + USBHS_LPSTS);
|
||||
value &= ~USBHS_LPSTS_SUSPM;
|
||||
writew(value, base + USBHS_LPSTS);
|
||||
|
||||
value = readl(base + USBHS_UGCTRL);
|
||||
value |= USBHS_UGCTRL_PLLRESET;
|
||||
writel(value, base + USBHS_UGCTRL);
|
||||
|
||||
spin_unlock_irqrestore(&drv->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct phy_ops rcar_gen2_phy_ops = {
|
||||
.init = rcar_gen2_phy_init,
|
||||
.exit = rcar_gen2_phy_exit,
|
||||
.power_on = rcar_gen2_phy_power_on,
|
||||
.power_off = rcar_gen2_phy_power_off,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct of_device_id rcar_gen2_phy_match_table[] = {
|
||||
{ .compatible = "renesas,usb-phy-r8a7790" },
|
||||
{ .compatible = "renesas,usb-phy-r8a7791" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rcar_gen2_phy_match_table);
|
||||
|
||||
static struct phy *rcar_gen2_phy_xlate(struct device *dev,
|
||||
struct of_phandle_args *args)
|
||||
{
|
||||
struct rcar_gen2_phy_driver *drv;
|
||||
struct device_node *np = args->np;
|
||||
int i;
|
||||
|
||||
if (!of_device_is_available(np)) {
|
||||
dev_warn(dev, "Requested PHY is disabled\n");
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
drv = dev_get_drvdata(dev);
|
||||
if (!drv)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
for (i = 0; i < drv->num_channels; i++) {
|
||||
if (np == drv->channels[i].of_node)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= drv->num_channels || args->args[0] >= 2)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
return drv->channels[i].phys[args->args[0]].phy;
|
||||
}
|
||||
|
||||
static const u32 select_mask[] = {
|
||||
[0] = USBHS_UGCTRL2_USB0SEL,
|
||||
[2] = USBHS_UGCTRL2_USB2SEL,
|
||||
};
|
||||
|
||||
static const u32 select_value[][PHYS_PER_CHANNEL] = {
|
||||
[0] = { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
|
||||
[2] = { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
|
||||
};
|
||||
|
||||
static int rcar_gen2_phy_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct rcar_gen2_phy_driver *drv;
|
||||
struct phy_provider *provider;
|
||||
struct device_node *np;
|
||||
struct resource *res;
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
int i = 0;
|
||||
|
||||
if (!dev->of_node) {
|
||||
dev_err(dev,
|
||||
"This driver is required to be instantiated from device tree\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
clk = devm_clk_get(dev, "usbhs");
|
||||
if (IS_ERR(clk)) {
|
||||
dev_err(dev, "Can't get USBHS clock\n");
|
||||
return PTR_ERR(clk);
|
||||
}
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
base = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
|
||||
if (!drv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&drv->lock);
|
||||
|
||||
drv->clk = clk;
|
||||
drv->base = base;
|
||||
|
||||
drv->num_channels = of_get_child_count(dev->of_node);
|
||||
drv->channels = devm_kcalloc(dev, drv->num_channels,
|
||||
sizeof(struct rcar_gen2_channel),
|
||||
GFP_KERNEL);
|
||||
if (!drv->channels)
|
||||
return -ENOMEM;
|
||||
|
||||
for_each_child_of_node(dev->of_node, np) {
|
||||
struct rcar_gen2_channel *channel = drv->channels + i;
|
||||
u32 channel_num;
|
||||
int error, n;
|
||||
|
||||
channel->of_node = np;
|
||||
channel->drv = drv;
|
||||
channel->selected_phy = -1;
|
||||
|
||||
error = of_property_read_u32(np, "reg", &channel_num);
|
||||
if (error || channel_num > 2) {
|
||||
dev_err(dev, "Invalid \"reg\" property\n");
|
||||
return error;
|
||||
}
|
||||
channel->select_mask = select_mask[channel_num];
|
||||
|
||||
for (n = 0; n < PHYS_PER_CHANNEL; n++) {
|
||||
struct rcar_gen2_phy *phy = &channel->phys[n];
|
||||
|
||||
phy->channel = channel;
|
||||
phy->number = n;
|
||||
phy->select_value = select_value[channel_num][n];
|
||||
|
||||
phy->phy = devm_phy_create(dev, NULL,
|
||||
&rcar_gen2_phy_ops, NULL);
|
||||
if (IS_ERR(phy->phy)) {
|
||||
dev_err(dev, "Failed to create PHY\n");
|
||||
return PTR_ERR(phy->phy);
|
||||
}
|
||||
phy_set_drvdata(phy->phy, phy);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
provider = devm_of_phy_provider_register(dev, rcar_gen2_phy_xlate);
|
||||
if (IS_ERR(provider)) {
|
||||
dev_err(dev, "Failed to register PHY provider\n");
|
||||
return PTR_ERR(provider);
|
||||
}
|
||||
|
||||
dev_set_drvdata(dev, drv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver rcar_gen2_phy_driver = {
|
||||
.driver = {
|
||||
.name = "phy_rcar_gen2",
|
||||
.of_match_table = rcar_gen2_phy_match_table,
|
||||
},
|
||||
.probe = rcar_gen2_phy_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(rcar_gen2_phy_driver);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("Renesas R-Car Gen2 PHY");
|
||||
MODULE_AUTHOR("Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>");
|
|
@ -231,7 +231,6 @@ static struct platform_driver samsung_usb2_phy_driver = {
|
|||
.driver = {
|
||||
.of_match_table = samsung_usb2_phy_of_match,
|
||||
.name = "samsung-usb2-phy",
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -212,10 +212,8 @@ static int spear1310_miphy_probe(struct platform_device *pdev)
|
|||
struct phy_provider *phy_provider;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv) {
|
||||
dev_err(dev, "can't alloc spear1310_miphy private date memory\n");
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
priv->misc =
|
||||
syscon_regmap_lookup_by_phandle(dev->of_node, "misc");
|
||||
|
@ -252,22 +250,11 @@ static struct platform_driver spear1310_miphy_driver = {
|
|||
.probe = spear1310_miphy_probe,
|
||||
.driver = {
|
||||
.name = "spear1310-miphy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(spear1310_miphy_of_match),
|
||||
},
|
||||
};
|
||||
|
||||
static int __init spear1310_miphy_phy_init(void)
|
||||
{
|
||||
return platform_driver_register(&spear1310_miphy_driver);
|
||||
}
|
||||
module_init(spear1310_miphy_phy_init);
|
||||
|
||||
static void __exit spear1310_miphy_phy_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&spear1310_miphy_driver);
|
||||
}
|
||||
module_exit(spear1310_miphy_phy_exit);
|
||||
module_platform_driver(spear1310_miphy_driver);
|
||||
|
||||
MODULE_DESCRIPTION("ST SPEAR1310-MIPHY driver");
|
||||
MODULE_AUTHOR("Pratyush Anand <pratyush.anand@st.com>");
|
||||
|
|
|
@ -249,10 +249,8 @@ static int spear1340_miphy_probe(struct platform_device *pdev)
|
|||
struct phy_provider *phy_provider;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv) {
|
||||
dev_err(dev, "can't alloc spear1340_miphy private date memory\n");
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
priv->misc =
|
||||
syscon_regmap_lookup_by_phandle(dev->of_node, "misc");
|
||||
|
@ -284,23 +282,12 @@ static struct platform_driver spear1340_miphy_driver = {
|
|||
.probe = spear1340_miphy_probe,
|
||||
.driver = {
|
||||
.name = "spear1340-miphy",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &spear1340_miphy_pm_ops,
|
||||
.of_match_table = of_match_ptr(spear1340_miphy_of_match),
|
||||
},
|
||||
};
|
||||
|
||||
static int __init spear1340_miphy_phy_init(void)
|
||||
{
|
||||
return platform_driver_register(&spear1340_miphy_driver);
|
||||
}
|
||||
module_init(spear1340_miphy_phy_init);
|
||||
|
||||
static void __exit spear1340_miphy_phy_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&spear1340_miphy_driver);
|
||||
}
|
||||
module_exit(spear1340_miphy_phy_exit);
|
||||
module_platform_driver(spear1340_miphy_driver);
|
||||
|
||||
MODULE_DESCRIPTION("ST SPEAR1340-MIPHY driver");
|
||||
MODULE_AUTHOR("Pratyush Anand <pratyush.anand@st.com>");
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* Copyright (C) 2014 STMicroelectronics
|
||||
*
|
||||
* STMicroelectronics Generic PHY driver for STiH407 USB2.
|
||||
*
|
||||
* Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/phy/phy.h>
|
||||
|
||||
/* Default PHY_SEL and REFCLKSEL configuration */
|
||||
#define STIH407_USB_PICOPHY_CTRL_PORT_CONF 0x6
|
||||
#define STIH407_USB_PICOPHY_CTRL_PORT_MASK 0x1f
|
||||
|
||||
/* ports parameters overriding */
|
||||
#define STIH407_USB_PICOPHY_PARAM_DEF 0x39a4dc
|
||||
#define STIH407_USB_PICOPHY_PARAM_MASK 0xffffffff
|
||||
|
||||
struct stih407_usb2_picophy {
|
||||
struct phy *phy;
|
||||
struct regmap *regmap;
|
||||
struct device *dev;
|
||||
struct reset_control *rstc;
|
||||
struct reset_control *rstport;
|
||||
int ctrl;
|
||||
int param;
|
||||
};
|
||||
|
||||
static int stih407_usb2_pico_ctrl(struct stih407_usb2_picophy *phy_dev)
|
||||
{
|
||||
reset_control_deassert(phy_dev->rstc);
|
||||
|
||||
return regmap_update_bits(phy_dev->regmap, phy_dev->ctrl,
|
||||
STIH407_USB_PICOPHY_CTRL_PORT_MASK,
|
||||
STIH407_USB_PICOPHY_CTRL_PORT_CONF);
|
||||
}
|
||||
|
||||
static int stih407_usb2_init_port(struct phy *phy)
|
||||
{
|
||||
int ret;
|
||||
struct stih407_usb2_picophy *phy_dev = phy_get_drvdata(phy);
|
||||
|
||||
stih407_usb2_pico_ctrl(phy_dev);
|
||||
|
||||
ret = regmap_update_bits(phy_dev->regmap,
|
||||
phy_dev->param,
|
||||
STIH407_USB_PICOPHY_PARAM_MASK,
|
||||
STIH407_USB_PICOPHY_PARAM_DEF);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return reset_control_deassert(phy_dev->rstport);
|
||||
}
|
||||
|
||||
static int stih407_usb2_exit_port(struct phy *phy)
|
||||
{
|
||||
struct stih407_usb2_picophy *phy_dev = phy_get_drvdata(phy);
|
||||
|
||||
/*
|
||||
* Only port reset is asserted, phy global reset is kept untouched
|
||||
* as other ports may still be active. When all ports are in reset
|
||||
* state, assumption is made that power will be cut off on the phy, in
|
||||
* case of suspend for instance. Theoretically, asserting individual
|
||||
* reset (like here) or global reset should be equivalent.
|
||||
*/
|
||||
return reset_control_assert(phy_dev->rstport);
|
||||
}
|
||||
|
||||
static const struct phy_ops stih407_usb2_picophy_data = {
|
||||
.init = stih407_usb2_init_port,
|
||||
.exit = stih407_usb2_exit_port,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int stih407_usb2_picophy_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct stih407_usb2_picophy *phy_dev;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct phy_provider *phy_provider;
|
||||
struct phy *phy;
|
||||
struct resource *res;
|
||||
|
||||
phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL);
|
||||
if (!phy_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
phy_dev->dev = dev;
|
||||
dev_set_drvdata(dev, phy_dev);
|
||||
|
||||
phy_dev->rstc = devm_reset_control_get(dev, "global");
|
||||
if (IS_ERR(phy_dev->rstc)) {
|
||||
dev_err(dev, "failed to ctrl picoPHY reset\n");
|
||||
return PTR_ERR(phy_dev->rstc);
|
||||
}
|
||||
|
||||
phy_dev->rstport = devm_reset_control_get(dev, "port");
|
||||
if (IS_ERR(phy_dev->rstport)) {
|
||||
dev_err(dev, "failed to ctrl picoPHY reset\n");
|
||||
return PTR_ERR(phy_dev->rstport);
|
||||
}
|
||||
|
||||
/* Reset port by default: only deassert it in phy init */
|
||||
reset_control_assert(phy_dev->rstport);
|
||||
|
||||
phy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
|
||||
if (IS_ERR(phy_dev->regmap)) {
|
||||
dev_err(dev, "No syscfg phandle specified\n");
|
||||
return PTR_ERR(phy_dev->regmap);
|
||||
}
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl");
|
||||
if (!res) {
|
||||
dev_err(dev, "No ctrl reg found\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
phy_dev->ctrl = res->start;
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param");
|
||||
if (!res) {
|
||||
dev_err(dev, "No param reg found\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
phy_dev->param = res->start;
|
||||
|
||||
phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data, NULL);
|
||||
if (IS_ERR(phy)) {
|
||||
dev_err(dev, "failed to create Display Port PHY\n");
|
||||
return PTR_ERR(phy);
|
||||
}
|
||||
|
||||
phy_dev->phy = phy;
|
||||
phy_set_drvdata(phy, phy_dev);
|
||||
|
||||
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
|
||||
if (IS_ERR(phy_provider))
|
||||
return PTR_ERR(phy_provider);
|
||||
|
||||
dev_info(dev, "STiH407 USB Generic picoPHY driver probed!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id stih407_usb2_picophy_of_match[] = {
|
||||
{ .compatible = "st,stih407-usb2-phy" },
|
||||
{ /*sentinel */ },
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, stih407_usb2_picophy_of_match);
|
||||
|
||||
static struct platform_driver stih407_usb2_picophy_driver = {
|
||||
.probe = stih407_usb2_picophy_probe,
|
||||
.driver = {
|
||||
.name = "stih407-usb-genphy",
|
||||
.of_match_table = stih407_usb2_picophy_of_match,
|
||||
}
|
||||
};
|
||||
|
||||
module_platform_driver(stih407_usb2_picophy_driver);
|
||||
|
||||
MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
|
||||
MODULE_DESCRIPTION("STMicroelectronics Generic picoPHY driver for STiH407");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Copyright (C) 2014 STMicroelectronics
|
||||
*
|
||||
* STMicroelectronics PHY driver for STiH41x USB.
|
||||
*
|
||||
* Author: Maxime Coquelin <maxime.coquelin@st.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
|
||||
#define SYSCFG332 0x80
|
||||
#define SYSCFG2520 0x820
|
||||
|
||||
/**
|
||||
* struct stih41x_usb_cfg - SoC specific PHY register mapping
|
||||
* @syscfg: Offset in syscfg registers bank
|
||||
* @cfg_mask: Bits mask for PHY configuration
|
||||
* @cfg: Static configuration value for PHY
|
||||
* @oscok: Notify the PHY oscillator clock is ready
|
||||
* Setting this bit enable the PHY
|
||||
*/
|
||||
struct stih41x_usb_cfg {
|
||||
u32 syscfg;
|
||||
u32 cfg_mask;
|
||||
u32 cfg;
|
||||
u32 oscok;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct stih41x_usb_phy - Private data for the PHY
|
||||
* @dev: device for this controller
|
||||
* @regmap: Syscfg registers bank in which PHY is configured
|
||||
* @cfg: SoC specific PHY register mapping
|
||||
* @clk: Oscillator used by the PHY
|
||||
*/
|
||||
struct stih41x_usb_phy {
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
const struct stih41x_usb_cfg *cfg;
|
||||
struct clk *clk;
|
||||
};
|
||||
|
||||
static struct stih41x_usb_cfg stih415_usb_phy_cfg = {
|
||||
.syscfg = SYSCFG332,
|
||||
.cfg_mask = 0x3f,
|
||||
.cfg = 0x38,
|
||||
.oscok = BIT(6),
|
||||
};
|
||||
|
||||
static struct stih41x_usb_cfg stih416_usb_phy_cfg = {
|
||||
.syscfg = SYSCFG2520,
|
||||
.cfg_mask = 0x33f,
|
||||
.cfg = 0x238,
|
||||
.oscok = BIT(6),
|
||||
};
|
||||
|
||||
static int stih41x_usb_phy_init(struct phy *phy)
|
||||
{
|
||||
struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy);
|
||||
|
||||
return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
|
||||
phy_dev->cfg->cfg_mask, phy_dev->cfg->cfg);
|
||||
}
|
||||
|
||||
static int stih41x_usb_phy_power_on(struct phy *phy)
|
||||
{
|
||||
struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy);
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(phy_dev->clk);
|
||||
if (ret) {
|
||||
dev_err(phy_dev->dev, "Failed to enable osc_phy clock\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
|
||||
phy_dev->cfg->oscok, phy_dev->cfg->oscok);
|
||||
}
|
||||
|
||||
static int stih41x_usb_phy_power_off(struct phy *phy)
|
||||
{
|
||||
struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy);
|
||||
int ret;
|
||||
|
||||
ret = regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
|
||||
phy_dev->cfg->oscok, 0);
|
||||
if (ret) {
|
||||
dev_err(phy_dev->dev, "Failed to clear oscok bit\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
clk_disable_unprepare(phy_dev->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct phy_ops stih41x_usb_phy_ops = {
|
||||
.init = stih41x_usb_phy_init,
|
||||
.power_on = stih41x_usb_phy_power_on,
|
||||
.power_off = stih41x_usb_phy_power_off,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct of_device_id stih41x_usb_phy_of_match[];
|
||||
|
||||
static int stih41x_usb_phy_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
const struct of_device_id *match;
|
||||
struct stih41x_usb_phy *phy_dev;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct phy_provider *phy_provider;
|
||||
struct phy *phy;
|
||||
|
||||
phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL);
|
||||
if (!phy_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
match = of_match_device(stih41x_usb_phy_of_match, &pdev->dev);
|
||||
if (!match)
|
||||
return -ENODEV;
|
||||
|
||||
phy_dev->cfg = match->data;
|
||||
|
||||
phy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
|
||||
if (IS_ERR(phy_dev->regmap)) {
|
||||
dev_err(dev, "No syscfg phandle specified\n");
|
||||
return PTR_ERR(phy_dev->regmap);
|
||||
}
|
||||
|
||||
phy_dev->clk = devm_clk_get(dev, "osc_phy");
|
||||
if (IS_ERR(phy_dev->clk)) {
|
||||
dev_err(dev, "osc_phy clk not found\n");
|
||||
return PTR_ERR(phy_dev->clk);
|
||||
}
|
||||
|
||||
phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops, NULL);
|
||||
|
||||
if (IS_ERR(phy)) {
|
||||
dev_err(dev, "failed to create phy\n");
|
||||
return PTR_ERR(phy);
|
||||
}
|
||||
|
||||
phy_dev->dev = dev;
|
||||
|
||||
phy_set_drvdata(phy, phy_dev);
|
||||
|
||||
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
|
||||
if (IS_ERR(phy_provider))
|
||||
return PTR_ERR(phy_provider);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id stih41x_usb_phy_of_match[] = {
|
||||
{ .compatible = "st,stih415-usb-phy", .data = &stih415_usb_phy_cfg },
|
||||
{ .compatible = "st,stih416-usb-phy", .data = &stih416_usb_phy_cfg },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, stih41x_usb_phy_of_match);
|
||||
|
||||
static struct platform_driver stih41x_usb_phy_driver = {
|
||||
.probe = stih41x_usb_phy_probe,
|
||||
.driver = {
|
||||
.name = "stih41x-usb-phy",
|
||||
.of_match_table = stih41x_usb_phy_of_match,
|
||||
}
|
||||
};
|
||||
module_platform_driver(stih41x_usb_phy_driver);
|
||||
|
||||
MODULE_AUTHOR("Maxime Coquelin <maxime.coquelin@st.com>");
|
||||
MODULE_DESCRIPTION("STMicroelectronics USB PHY driver for STiH41x series");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -325,7 +325,6 @@ static struct platform_driver sun4i_usb_phy_driver = {
|
|||
.driver = {
|
||||
.of_match_table = sun4i_usb_phy_of_match,
|
||||
.name = "sun4i-usb-phy",
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
module_platform_driver(sun4i_usb_phy_driver);
|
||||
|
|
|
@ -299,10 +299,9 @@ static int ti_pipe3_probe(struct platform_device *pdev)
|
|||
struct clk *clk;
|
||||
|
||||
phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
|
||||
if (!phy) {
|
||||
dev_err(&pdev->dev, "unable to alloc mem for TI PIPE3 PHY\n");
|
||||
if (!phy)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
phy->dev = &pdev->dev;
|
||||
|
||||
if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
|
||||
|
@ -519,7 +518,6 @@ static struct platform_driver ti_pipe3_driver = {
|
|||
.remove = ti_pipe3_remove,
|
||||
.driver = {
|
||||
.name = "ti-pipe3",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = DEV_PM_OPS,
|
||||
.of_match_table = of_match_ptr(ti_pipe3_id_table),
|
||||
},
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/delay.h>
|
||||
|
@ -155,7 +154,7 @@ struct twl4030_usb {
|
|||
struct regulator *usb3v1;
|
||||
|
||||
/* for vbus reporting with irqs disabled */
|
||||
spinlock_t lock;
|
||||
struct mutex lock;
|
||||
|
||||
/* pin configuration */
|
||||
enum twl4030_usb_mode usb_mode;
|
||||
|
@ -163,8 +162,6 @@ struct twl4030_usb {
|
|||
int irq;
|
||||
enum omap_musb_vbus_id_status linkstat;
|
||||
bool vbus_supplied;
|
||||
u8 asleep;
|
||||
bool irq_enabled;
|
||||
|
||||
struct delayed_work id_workaround_work;
|
||||
};
|
||||
|
@ -384,55 +381,18 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on)
|
|||
WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
|
||||
}
|
||||
|
||||
static void twl4030_phy_power(struct twl4030_usb *twl, int on)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (on) {
|
||||
ret = regulator_enable(twl->usb3v1);
|
||||
if (ret)
|
||||
dev_err(twl->dev, "Failed to enable usb3v1\n");
|
||||
|
||||
ret = regulator_enable(twl->usb1v8);
|
||||
if (ret)
|
||||
dev_err(twl->dev, "Failed to enable usb1v8\n");
|
||||
|
||||
/*
|
||||
* Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP
|
||||
* in twl4030) resets the VUSB_DEDICATED2 register. This reset
|
||||
* enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to
|
||||
* SLEEP. We work around this by clearing the bit after usv3v1
|
||||
* is re-activated. This ensures that VUSB3V1 is really active.
|
||||
*/
|
||||
twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
|
||||
|
||||
ret = regulator_enable(twl->usb1v5);
|
||||
if (ret)
|
||||
dev_err(twl->dev, "Failed to enable usb1v5\n");
|
||||
|
||||
__twl4030_phy_power(twl, 1);
|
||||
twl4030_usb_write(twl, PHY_CLK_CTRL,
|
||||
twl4030_usb_read(twl, PHY_CLK_CTRL) |
|
||||
(PHY_CLK_CTRL_CLOCKGATING_EN |
|
||||
PHY_CLK_CTRL_CLK32K_EN));
|
||||
} else {
|
||||
__twl4030_phy_power(twl, 0);
|
||||
regulator_disable(twl->usb1v5);
|
||||
regulator_disable(twl->usb1v8);
|
||||
regulator_disable(twl->usb3v1);
|
||||
}
|
||||
}
|
||||
|
||||
static int twl4030_usb_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct twl4030_usb *twl = dev_get_drvdata(dev);
|
||||
|
||||
dev_dbg(twl->dev, "%s\n", __func__);
|
||||
if (twl->asleep)
|
||||
if (pm_runtime_suspended(dev))
|
||||
return 0;
|
||||
|
||||
twl4030_phy_power(twl, 0);
|
||||
twl->asleep = 1;
|
||||
__twl4030_phy_power(twl, 0);
|
||||
regulator_disable(twl->usb1v5);
|
||||
regulator_disable(twl->usb1v8);
|
||||
regulator_disable(twl->usb3v1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -440,13 +400,38 @@ static int twl4030_usb_runtime_suspend(struct device *dev)
|
|||
static int twl4030_usb_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct twl4030_usb *twl = dev_get_drvdata(dev);
|
||||
int res;
|
||||
|
||||
dev_dbg(twl->dev, "%s\n", __func__);
|
||||
if (!twl->asleep)
|
||||
if (pm_runtime_active(dev))
|
||||
return 0;
|
||||
|
||||
twl4030_phy_power(twl, 1);
|
||||
twl->asleep = 0;
|
||||
res = regulator_enable(twl->usb3v1);
|
||||
if (res)
|
||||
dev_err(twl->dev, "Failed to enable usb3v1\n");
|
||||
|
||||
res = regulator_enable(twl->usb1v8);
|
||||
if (res)
|
||||
dev_err(twl->dev, "Failed to enable usb1v8\n");
|
||||
|
||||
/*
|
||||
* Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP
|
||||
* in twl4030) resets the VUSB_DEDICATED2 register. This reset
|
||||
* enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to
|
||||
* SLEEP. We work around this by clearing the bit after usv3v1
|
||||
* is re-activated. This ensures that VUSB3V1 is really active.
|
||||
*/
|
||||
twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
|
||||
|
||||
res = regulator_enable(twl->usb1v5);
|
||||
if (res)
|
||||
dev_err(twl->dev, "Failed to enable usb1v5\n");
|
||||
|
||||
__twl4030_phy_power(twl, 1);
|
||||
twl4030_usb_write(twl, PHY_CLK_CTRL,
|
||||
twl4030_usb_read(twl, PHY_CLK_CTRL) |
|
||||
(PHY_CLK_CTRL_CLOCKGATING_EN |
|
||||
PHY_CLK_CTRL_CLK32K_EN));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -472,16 +457,8 @@ static int twl4030_phy_power_on(struct phy *phy)
|
|||
twl4030_usb_set_mode(twl, twl->usb_mode);
|
||||
if (twl->usb_mode == T2_USB_MODE_ULPI)
|
||||
twl4030_i2c_access(twl, 0);
|
||||
schedule_delayed_work(&twl->id_workaround_work, 0);
|
||||
|
||||
/*
|
||||
* XXX When VBUS gets driven after musb goes to A mode,
|
||||
* ID_PRES related interrupts no longer arrive, why?
|
||||
* Register itself is updated fine though, so we must poll.
|
||||
*/
|
||||
if (twl->linkstat == OMAP_MUSB_ID_GROUND) {
|
||||
cancel_delayed_work(&twl->id_workaround_work);
|
||||
schedule_delayed_work(&twl->id_workaround_work, HZ);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -538,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct twl4030_usb *twl = dev_get_drvdata(dev);
|
||||
unsigned long flags;
|
||||
int ret = -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&twl->lock, flags);
|
||||
mutex_lock(&twl->lock);
|
||||
ret = sprintf(buf, "%s\n",
|
||||
twl->vbus_supplied ? "on" : "off");
|
||||
spin_unlock_irqrestore(&twl->lock, flags);
|
||||
mutex_unlock(&twl->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -558,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
|
|||
|
||||
status = twl4030_usb_linkstat(twl);
|
||||
|
||||
spin_lock_irq(&twl->lock);
|
||||
mutex_lock(&twl->lock);
|
||||
if (status >= 0 && status != twl->linkstat) {
|
||||
twl->linkstat = status;
|
||||
status_changed = true;
|
||||
}
|
||||
spin_unlock_irq(&twl->lock);
|
||||
mutex_unlock(&twl->lock);
|
||||
|
||||
if (status_changed) {
|
||||
/* FIXME add a set_power() method so that B-devices can
|
||||
|
@ -579,10 +555,10 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
|
|||
*/
|
||||
if ((status == OMAP_MUSB_VBUS_VALID) ||
|
||||
(status == OMAP_MUSB_ID_GROUND)) {
|
||||
if (twl->asleep)
|
||||
if (pm_runtime_suspended(twl->dev))
|
||||
pm_runtime_get_sync(twl->dev);
|
||||
} else {
|
||||
if (!twl->asleep) {
|
||||
if (pm_runtime_active(twl->dev)) {
|
||||
pm_runtime_mark_last_busy(twl->dev);
|
||||
pm_runtime_put_autosuspend(twl->dev);
|
||||
}
|
||||
|
@ -591,7 +567,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
|
|||
}
|
||||
|
||||
/* don't schedule during sleep - irq works right then */
|
||||
if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) {
|
||||
if (status == OMAP_MUSB_ID_GROUND && pm_runtime_active(twl->dev)) {
|
||||
cancel_delayed_work(&twl->id_workaround_work);
|
||||
schedule_delayed_work(&twl->id_workaround_work, HZ);
|
||||
}
|
||||
|
@ -613,16 +589,9 @@ static void twl4030_id_workaround_work(struct work_struct *work)
|
|||
static int twl4030_phy_init(struct phy *phy)
|
||||
{
|
||||
struct twl4030_usb *twl = phy_get_drvdata(phy);
|
||||
enum omap_musb_vbus_id_status status;
|
||||
|
||||
pm_runtime_get_sync(twl->dev);
|
||||
status = twl4030_usb_linkstat(twl);
|
||||
twl->linkstat = status;
|
||||
|
||||
if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
|
||||
omap_musb_mailbox(twl->linkstat);
|
||||
|
||||
sysfs_notify(&twl->dev->kobj, NULL, "vbus");
|
||||
schedule_delayed_work(&twl->id_workaround_work, 0);
|
||||
pm_runtime_mark_last_busy(twl->dev);
|
||||
pm_runtime_put_autosuspend(twl->dev);
|
||||
|
||||
|
@ -699,7 +668,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
|
|||
twl->dev = &pdev->dev;
|
||||
twl->irq = platform_get_irq(pdev, 0);
|
||||
twl->vbus_supplied = false;
|
||||
twl->asleep = 1;
|
||||
twl->linkstat = -EINVAL;
|
||||
twl->linkstat = OMAP_MUSB_UNKNOWN;
|
||||
|
||||
twl->phy.dev = twl->dev;
|
||||
|
@ -724,8 +693,8 @@ static int twl4030_usb_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(phy_provider))
|
||||
return PTR_ERR(phy_provider);
|
||||
|
||||
/* init spinlock for workqueue */
|
||||
spin_lock_init(&twl->lock);
|
||||
/* init mutex for workqueue */
|
||||
mutex_init(&twl->lock);
|
||||
|
||||
INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work);
|
||||
|
||||
|
@ -755,7 +724,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
|
|||
* set_host() and/or set_peripheral() ... OTG_capable boards
|
||||
* need both handles, otherwise just one suffices.
|
||||
*/
|
||||
twl->irq_enabled = true;
|
||||
status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
|
||||
twl4030_usb_irq, IRQF_TRIGGER_FALLING |
|
||||
IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
|
||||
|
@ -817,7 +785,6 @@ static struct platform_driver twl4030_usb_driver = {
|
|||
.driver = {
|
||||
.name = "twl4030_usb",
|
||||
.pm = &twl4030_usb_pm_ops,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(twl4030_usb_id_table),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1738,7 +1738,6 @@ static struct platform_driver xgene_phy_driver = {
|
|||
.probe = xgene_phy_probe,
|
||||
.driver = {
|
||||
.name = "xgene-phy",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = xgene_phy_of_match,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -149,4 +149,14 @@ source "drivers/usb/phy/Kconfig"
|
|||
|
||||
source "drivers/usb/gadget/Kconfig"
|
||||
|
||||
config USB_LED_TRIG
|
||||
bool "USB LED Triggers"
|
||||
depends on LEDS_CLASS && USB_COMMON && LEDS_TRIGGERS
|
||||
help
|
||||
This option adds LED triggers for USB host and/or gadget activity.
|
||||
|
||||
Say Y here if you are working on a system with led-class supported
|
||||
LEDs and you want to use them as activity indicators for USB host or
|
||||
gadget.
|
||||
|
||||
endif # USB_SUPPORT
|
||||
|
|
|
@ -24,7 +24,7 @@ Here is a list of what each subdirectory here is, and what is contained in
|
|||
them.
|
||||
|
||||
core/ - This is for the core USB host code, including the
|
||||
usbfs files and the hub class driver ("khubd").
|
||||
usbfs files and the hub class driver ("hub_wq").
|
||||
|
||||
host/ - This is for USB host controller drivers. This
|
||||
includes UHCI, OHCI, EHCI, and others that might
|
||||
|
|
|
@ -99,10 +99,10 @@ enum ci_role {
|
|||
|
||||
/**
|
||||
* struct ci_role_driver - host/gadget role driver
|
||||
* start: start this role
|
||||
* stop: stop this role
|
||||
* irq: irq handler for this role
|
||||
* name: role name string (host/gadget)
|
||||
* @start: start this role
|
||||
* @stop: stop this role
|
||||
* @irq: irq handler for this role
|
||||
* @name: role name string (host/gadget)
|
||||
*/
|
||||
struct ci_role_driver {
|
||||
int (*start)(struct ci_hdrc *);
|
||||
|
@ -245,6 +245,7 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
|
|||
|
||||
/**
|
||||
* hw_read: reads from a hw register
|
||||
* @ci: the controller
|
||||
* @reg: register index
|
||||
* @mask: bitfield mask
|
||||
*
|
||||
|
@ -277,6 +278,7 @@ static inline void __hw_write(struct ci_hdrc *ci, u32 val,
|
|||
|
||||
/**
|
||||
* hw_write: writes to a hw register
|
||||
* @ci: the controller
|
||||
* @reg: register index
|
||||
* @mask: bitfield mask
|
||||
* @data: new value
|
||||
|
@ -293,6 +295,7 @@ static inline void hw_write(struct ci_hdrc *ci, enum ci_hw_regs reg,
|
|||
|
||||
/**
|
||||
* hw_test_and_clear: tests & clears a hw register
|
||||
* @ci: the controller
|
||||
* @reg: register index
|
||||
* @mask: bitfield mask
|
||||
*
|
||||
|
@ -309,6 +312,7 @@ static inline u32 hw_test_and_clear(struct ci_hdrc *ci, enum ci_hw_regs reg,
|
|||
|
||||
/**
|
||||
* hw_test_and_write: tests & writes a hw register
|
||||
* @ci: the controller
|
||||
* @reg: register index
|
||||
* @mask: bitfield mask
|
||||
* @data: new value
|
||||
|
@ -327,6 +331,8 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg,
|
|||
/**
|
||||
* ci_otg_is_fsm_mode: runtime check if otg controller
|
||||
* is in otg fsm mode.
|
||||
*
|
||||
* @ci: chipidea device
|
||||
*/
|
||||
static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ struct ci_hdrc_imx_data {
|
|||
|
||||
static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
|
||||
{
|
||||
struct platform_device *misc_pdev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct of_phandle_args args;
|
||||
struct imx_usbmisc_data *data;
|
||||
|
@ -79,8 +80,15 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
|
|||
}
|
||||
|
||||
data->index = args.args[0];
|
||||
|
||||
misc_pdev = of_find_device_by_node(args.np);
|
||||
of_node_put(args.np);
|
||||
|
||||
if (!misc_pdev)
|
||||
return ERR_PTR(-EPROBE_DEFER);
|
||||
|
||||
data->dev = &misc_pdev->dev;
|
||||
|
||||
if (of_find_property(np, "disable-over-current", NULL))
|
||||
data->disable_oc = 1;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H
|
||||
|
||||
struct imx_usbmisc_data {
|
||||
struct device *dev;
|
||||
int index;
|
||||
|
||||
unsigned int disable_oc:1; /* over current detect disabled */
|
||||
|
|
|
@ -139,6 +139,8 @@ static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
|
|||
/**
|
||||
* hw_read_intr_enable: returns interrupt enable register
|
||||
*
|
||||
* @ci: the controller
|
||||
*
|
||||
* This function returns register data
|
||||
*/
|
||||
u32 hw_read_intr_enable(struct ci_hdrc *ci)
|
||||
|
@ -149,6 +151,8 @@ u32 hw_read_intr_enable(struct ci_hdrc *ci)
|
|||
/**
|
||||
* hw_read_intr_status: returns interrupt status register
|
||||
*
|
||||
* @ci: the controller
|
||||
*
|
||||
* This function returns register data
|
||||
*/
|
||||
u32 hw_read_intr_status(struct ci_hdrc *ci)
|
||||
|
@ -176,6 +180,8 @@ int hw_port_test_set(struct ci_hdrc *ci, u8 mode)
|
|||
/**
|
||||
* hw_port_test_get: reads port test mode value
|
||||
*
|
||||
* @ci: the controller
|
||||
*
|
||||
* This function returns port test mode value
|
||||
*/
|
||||
u8 hw_port_test_get(struct ci_hdrc *ci)
|
||||
|
@ -295,7 +301,7 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
|
|||
/**
|
||||
* ci_usb_phy_init: initialize phy according to different phy type
|
||||
* @ci: the controller
|
||||
*
|
||||
*
|
||||
* This function returns an error code if usb_phy_init has failed
|
||||
*/
|
||||
static int ci_usb_phy_init(struct ci_hdrc *ci)
|
||||
|
@ -473,6 +479,10 @@ static int ci_get_platdata(struct device *dev,
|
|||
PTR_ERR(platdata->reg_vbus));
|
||||
return PTR_ERR(platdata->reg_vbus);
|
||||
}
|
||||
/* Get TPL support */
|
||||
if (!platdata->tpl_support)
|
||||
platdata->tpl_support =
|
||||
of_usb_host_tpl_support(dev->of_node);
|
||||
}
|
||||
|
||||
if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
|
||||
|
@ -658,7 +668,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
|
|||
goto deinit_phy;
|
||||
}
|
||||
|
||||
if (ci->is_otg) {
|
||||
if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
|
||||
/* Disable and clear all OTG irq */
|
||||
hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
|
||||
OTGSC_INT_STATUS_BITS);
|
||||
|
|
|
@ -59,7 +59,8 @@ static int host_start(struct ci_hdrc *ci)
|
|||
hcd->has_tt = 1;
|
||||
|
||||
hcd->power_budget = ci->platdata->power_budget;
|
||||
hcd->phy = ci->transceiver;
|
||||
hcd->usb_phy = ci->transceiver;
|
||||
hcd->tpl_support = ci->platdata->tpl_support;
|
||||
|
||||
ehci = hcd_to_ehci(hcd);
|
||||
ehci->caps = ci->hw_bank.cap;
|
||||
|
|
|
@ -627,7 +627,7 @@ __acquires(hwep->lock)
|
|||
|
||||
if (hwreq->req.complete != NULL) {
|
||||
spin_unlock(hwep->lock);
|
||||
hwreq->req.complete(&hwep->ep, &hwreq->req);
|
||||
usb_gadget_giveback_request(&hwep->ep, &hwreq->req);
|
||||
spin_lock(hwep->lock);
|
||||
}
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ __acquires(hwep->lock)
|
|||
if ((hwep->type == USB_ENDPOINT_XFER_CONTROL) &&
|
||||
hwreq->req.length)
|
||||
hweptemp = hwep->ci->ep0in;
|
||||
hwreq->req.complete(&hweptemp->ep, &hwreq->req);
|
||||
usb_gadget_giveback_request(&hweptemp->ep, &hwreq->req);
|
||||
spin_lock(hwep->lock);
|
||||
}
|
||||
}
|
||||
|
@ -1347,7 +1347,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
|
|||
|
||||
if (hwreq->req.complete != NULL) {
|
||||
spin_unlock(hwep->lock);
|
||||
hwreq->req.complete(&hwep->ep, &hwreq->req);
|
||||
usb_gadget_giveback_request(&hwep->ep, &hwreq->req);
|
||||
spin_lock(hwep->lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
#define MX6_BM_OVER_CUR_DIS BIT(7)
|
||||
|
||||
#define VF610_OVER_CUR_DIS BIT(7)
|
||||
|
||||
struct usbmisc_ops {
|
||||
/* It's called once when probe a usb device */
|
||||
int (*init)(struct imx_usbmisc_data *data);
|
||||
|
@ -71,10 +73,9 @@ struct imx_usbmisc {
|
|||
const struct usbmisc_ops *ops;
|
||||
};
|
||||
|
||||
static struct imx_usbmisc *usbmisc;
|
||||
|
||||
static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 val = 0;
|
||||
|
||||
|
@ -108,6 +109,7 @@ static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
|
|||
|
||||
static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
void __iomem *reg;
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
@ -130,6 +132,7 @@ static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
|
|||
|
||||
static int usbmisc_imx27_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
|
@ -160,6 +163,7 @@ static int usbmisc_imx27_init(struct imx_usbmisc_data *data)
|
|||
|
||||
static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
void __iomem *reg = NULL;
|
||||
unsigned long flags;
|
||||
u32 val = 0;
|
||||
|
@ -204,6 +208,7 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
|
|||
|
||||
static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
unsigned long flags;
|
||||
u32 reg;
|
||||
|
||||
|
@ -221,6 +226,26 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int usbmisc_vf610_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
u32 reg;
|
||||
|
||||
/*
|
||||
* Vybrid only has one misc register set, but in two different
|
||||
* areas. These is reflected in two instances of this driver.
|
||||
*/
|
||||
if (data->index >= 1)
|
||||
return -EINVAL;
|
||||
|
||||
if (data->disable_oc) {
|
||||
reg = readl(usbmisc->base);
|
||||
writel(reg | VF610_OVER_CUR_DIS, usbmisc->base);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct usbmisc_ops imx25_usbmisc_ops = {
|
||||
.init = usbmisc_imx25_init,
|
||||
.post = usbmisc_imx25_post,
|
||||
|
@ -238,10 +263,14 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = {
|
|||
.init = usbmisc_imx6q_init,
|
||||
};
|
||||
|
||||
static const struct usbmisc_ops vf610_usbmisc_ops = {
|
||||
.init = usbmisc_vf610_init,
|
||||
};
|
||||
|
||||
int imx_usbmisc_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
if (!usbmisc)
|
||||
return -EPROBE_DEFER;
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
|
||||
if (!usbmisc->ops->init)
|
||||
return 0;
|
||||
return usbmisc->ops->init(data);
|
||||
|
@ -250,8 +279,8 @@ EXPORT_SYMBOL_GPL(imx_usbmisc_init);
|
|||
|
||||
int imx_usbmisc_init_post(struct imx_usbmisc_data *data)
|
||||
{
|
||||
if (!usbmisc)
|
||||
return -EPROBE_DEFER;
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
|
||||
if (!usbmisc->ops->post)
|
||||
return 0;
|
||||
return usbmisc->ops->post(data);
|
||||
|
@ -283,6 +312,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
|
|||
.compatible = "fsl,imx6q-usbmisc",
|
||||
.data = &imx6q_usbmisc_ops,
|
||||
},
|
||||
{
|
||||
.compatible = "fsl,vf610-usbmisc",
|
||||
.data = &vf610_usbmisc_ops,
|
||||
},
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
|
||||
|
@ -294,9 +327,6 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
|
|||
int ret;
|
||||
struct of_device_id *tmp_dev;
|
||||
|
||||
if (usbmisc)
|
||||
return -EBUSY;
|
||||
|
||||
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
@ -325,15 +355,15 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
|
|||
tmp_dev = (struct of_device_id *)
|
||||
of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
|
||||
data->ops = (const struct usbmisc_ops *)tmp_dev->data;
|
||||
usbmisc = data;
|
||||
platform_set_drvdata(pdev, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbmisc_imx_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(&pdev->dev);
|
||||
clk_disable_unprepare(usbmisc->clk);
|
||||
usbmisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,8 @@
|
|||
# Makefile for the usb common parts.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_USB_COMMON) += usb-common.o
|
||||
obj-$(CONFIG_USB_COMMON) += usb-common.o
|
||||
usb-common-y += common.o
|
||||
usb-common-$(CONFIG_USB_LED_TRIG) += led.o
|
||||
|
||||
obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
|
||||
|
|
|
@ -139,6 +139,21 @@ enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed);
|
||||
|
||||
/**
|
||||
* of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
|
||||
* for given targeted hosts (non-PC hosts)
|
||||
* @np: Pointer to the given device_node
|
||||
*
|
||||
* The function gets if the targeted hosts support TPL or not
|
||||
*/
|
||||
bool of_usb_host_tpl_support(struct device_node *np)
|
||||
{
|
||||
if (of_find_property(np, "tpl-support", NULL))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
|
||||
#endif
|
||||
|
||||
MODULE_LICENSE("GPL");
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* LED Triggers for USB Activity
|
||||
*
|
||||
* Copyright 2014 Michal Sojka <sojka@merica.cz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/usb.h>
|
||||
|
||||
#define BLINK_DELAY 30
|
||||
|
||||
static unsigned long usb_blink_delay = BLINK_DELAY;
|
||||
|
||||
DEFINE_LED_TRIGGER(ledtrig_usb_gadget);
|
||||
DEFINE_LED_TRIGGER(ledtrig_usb_host);
|
||||
|
||||
void usb_led_activity(enum usb_led_event ev)
|
||||
{
|
||||
struct led_trigger *trig = NULL;
|
||||
|
||||
switch (ev) {
|
||||
case USB_LED_EVENT_GADGET:
|
||||
trig = ledtrig_usb_gadget;
|
||||
break;
|
||||
case USB_LED_EVENT_HOST:
|
||||
trig = ledtrig_usb_host;
|
||||
break;
|
||||
}
|
||||
/* led_trigger_blink_oneshot() handles trig == NULL gracefully */
|
||||
led_trigger_blink_oneshot(trig, &usb_blink_delay, &usb_blink_delay, 0);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_led_activity);
|
||||
|
||||
|
||||
static int __init ledtrig_usb_init(void)
|
||||
{
|
||||
led_trigger_register_simple("usb-gadget", &ledtrig_usb_gadget);
|
||||
led_trigger_register_simple("usb-host", &ledtrig_usb_host);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit ledtrig_usb_exit(void)
|
||||
{
|
||||
led_trigger_unregister_simple(ledtrig_usb_gadget);
|
||||
led_trigger_unregister_simple(ledtrig_usb_host);
|
||||
}
|
||||
|
||||
module_init(ledtrig_usb_init);
|
||||
module_exit(ledtrig_usb_exit);
|
|
@ -56,22 +56,16 @@ config USB_OTG
|
|||
connector.
|
||||
|
||||
config USB_OTG_WHITELIST
|
||||
bool "Rely on OTG Targeted Peripherals List"
|
||||
depends on USB_OTG || EXPERT
|
||||
default y if USB_OTG
|
||||
bool "Rely on OTG and EH Targeted Peripherals List"
|
||||
depends on USB
|
||||
help
|
||||
If you say Y here, the "otg_whitelist.h" file will be used as a
|
||||
product whitelist, so USB peripherals not listed there will be
|
||||
rejected during enumeration. This behavior is required by the
|
||||
USB OTG specification for all devices not on your product's
|
||||
USB OTG and EH specification for all devices not on your product's
|
||||
"Targeted Peripherals List". "Embedded Hosts" are likewise
|
||||
allowed to support only a limited number of peripherals.
|
||||
|
||||
Otherwise, peripherals not listed there will only generate a
|
||||
warning and enumeration will continue. That's more like what
|
||||
normal Linux-USB hosts do (other than the warning), and is
|
||||
convenient for many stages of product development.
|
||||
|
||||
config USB_OTG_BLACKLIST_HUB
|
||||
bool "Disable external hubs"
|
||||
depends on USB_OTG || EXPERT
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <linux/pm_runtime.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/usb/hcd.h>
|
||||
#include <linux/usb/phy.h>
|
||||
|
@ -1272,7 +1273,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep);
|
|||
* The usb core itself is however optimized for host controllers that can dma
|
||||
* using regular system memory - like pci devices doing bus mastering.
|
||||
*
|
||||
* To support host controllers with limited dma capabilites we provide dma
|
||||
* To support host controllers with limited dma capabilities we provide dma
|
||||
* bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag.
|
||||
* For this to work properly the host controller code must first use the
|
||||
* function dma_declare_coherent_memory() to point out which memory area
|
||||
|
@ -1664,6 +1665,8 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
|
|||
usbmon_urb_complete(&hcd->self, urb, status);
|
||||
usb_anchor_suspend_wakeups(anchor);
|
||||
usb_unanchor_urb(urb);
|
||||
if (likely(status == 0))
|
||||
usb_led_activity(USB_LED_EVENT_HOST);
|
||||
|
||||
/* pass ownership to the completion handler */
|
||||
urb->status = status;
|
||||
|
@ -2301,7 +2304,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
|
|||
* Context: in_interrupt()
|
||||
*
|
||||
* Starts enumeration, with an immediate reset followed later by
|
||||
* khubd identifying and possibly configuring the device.
|
||||
* hub_wq identifying and possibly configuring the device.
|
||||
* This is needed by OTG controller drivers, where it helps meet
|
||||
* HNP protocol timing requirements for starting a port reset.
|
||||
*
|
||||
|
@ -2320,7 +2323,7 @@ int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num)
|
|||
if (port_num && hcd->driver->start_port_reset)
|
||||
status = hcd->driver->start_port_reset(hcd, port_num);
|
||||
|
||||
/* run khubd shortly after (first) root port reset finishes;
|
||||
/* allocate hub_wq shortly after (first) root port reset finishes;
|
||||
* it may issue others, until at least 50 msecs have passed.
|
||||
*/
|
||||
if (status == 0)
|
||||
|
@ -2383,20 +2386,20 @@ void usb_hc_died (struct usb_hcd *hcd)
|
|||
if (hcd->rh_registered) {
|
||||
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
|
||||
|
||||
/* make khubd clean up old urbs and devices */
|
||||
/* make hub_wq clean up old urbs and devices */
|
||||
usb_set_device_state (hcd->self.root_hub,
|
||||
USB_STATE_NOTATTACHED);
|
||||
usb_kick_khubd (hcd->self.root_hub);
|
||||
usb_kick_hub_wq(hcd->self.root_hub);
|
||||
}
|
||||
if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) {
|
||||
hcd = hcd->shared_hcd;
|
||||
if (hcd->rh_registered) {
|
||||
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
|
||||
|
||||
/* make khubd clean up old urbs and devices */
|
||||
/* make hub_wq clean up old urbs and devices */
|
||||
usb_set_device_state(hcd->self.root_hub,
|
||||
USB_STATE_NOTATTACHED);
|
||||
usb_kick_khubd(hcd->self.root_hub);
|
||||
usb_kick_hub_wq(hcd->self.root_hub);
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore (&hcd_root_hub_lock, flags);
|
||||
|
@ -2627,7 +2630,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
|
|||
int retval;
|
||||
struct usb_device *rhdev;
|
||||
|
||||
if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) {
|
||||
if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->usb_phy) {
|
||||
struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
|
||||
|
||||
if (IS_ERR(phy)) {
|
||||
|
@ -2640,11 +2643,34 @@ int usb_add_hcd(struct usb_hcd *hcd,
|
|||
usb_put_phy(phy);
|
||||
return retval;
|
||||
}
|
||||
hcd->phy = phy;
|
||||
hcd->usb_phy = phy;
|
||||
hcd->remove_phy = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
|
||||
struct phy *phy = phy_get(hcd->self.controller, "usb");
|
||||
|
||||
if (IS_ERR(phy)) {
|
||||
retval = PTR_ERR(phy);
|
||||
if (retval == -EPROBE_DEFER)
|
||||
goto err_phy;
|
||||
} else {
|
||||
retval = phy_init(phy);
|
||||
if (retval) {
|
||||
phy_put(phy);
|
||||
goto err_phy;
|
||||
}
|
||||
retval = phy_power_on(phy);
|
||||
if (retval) {
|
||||
phy_exit(phy);
|
||||
phy_put(phy);
|
||||
goto err_phy;
|
||||
}
|
||||
hcd->phy = phy;
|
||||
}
|
||||
}
|
||||
|
||||
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
|
||||
|
||||
/* Keep old behaviour if authorized_default is not in [0, 1]. */
|
||||
|
@ -2655,12 +2681,12 @@ int usb_add_hcd(struct usb_hcd *hcd,
|
|||
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
|
||||
|
||||
/* HC is in reset state, but accessible. Now do the one-time init,
|
||||
* bottom up so that hcds can customize the root hubs before khubd
|
||||
* bottom up so that hcds can customize the root hubs before hub_wq
|
||||
* starts talking to them. (Note, bus id is assigned early too.)
|
||||
*/
|
||||
if ((retval = hcd_buffer_create(hcd)) != 0) {
|
||||
dev_dbg(hcd->self.controller, "pool alloc failed\n");
|
||||
goto err_remove_phy;
|
||||
goto err_create_buf;
|
||||
}
|
||||
|
||||
if ((retval = usb_register_bus(&hcd->self)) < 0)
|
||||
|
@ -2787,12 +2813,19 @@ err_allocate_root_hub:
|
|||
usb_deregister_bus(&hcd->self);
|
||||
err_register_bus:
|
||||
hcd_buffer_destroy(hcd);
|
||||
err_remove_phy:
|
||||
if (hcd->remove_phy && hcd->phy) {
|
||||
usb_phy_shutdown(hcd->phy);
|
||||
usb_put_phy(hcd->phy);
|
||||
err_create_buf:
|
||||
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
|
||||
phy_power_off(hcd->phy);
|
||||
phy_exit(hcd->phy);
|
||||
phy_put(hcd->phy);
|
||||
hcd->phy = NULL;
|
||||
}
|
||||
err_phy:
|
||||
if (hcd->remove_phy && hcd->usb_phy) {
|
||||
usb_phy_shutdown(hcd->usb_phy);
|
||||
usb_put_phy(hcd->usb_phy);
|
||||
hcd->usb_phy = NULL;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_add_hcd);
|
||||
|
@ -2864,11 +2897,18 @@ void usb_remove_hcd(struct usb_hcd *hcd)
|
|||
|
||||
usb_deregister_bus(&hcd->self);
|
||||
hcd_buffer_destroy(hcd);
|
||||
if (hcd->remove_phy && hcd->phy) {
|
||||
usb_phy_shutdown(hcd->phy);
|
||||
usb_put_phy(hcd->phy);
|
||||
|
||||
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
|
||||
phy_power_off(hcd->phy);
|
||||
phy_exit(hcd->phy);
|
||||
phy_put(hcd->phy);
|
||||
hcd->phy = NULL;
|
||||
}
|
||||
if (hcd->remove_phy && hcd->usb_phy) {
|
||||
usb_phy_shutdown(hcd->usb_phy);
|
||||
usb_put_phy(hcd->usb_phy);
|
||||
hcd->usb_phy = NULL;
|
||||
}
|
||||
|
||||
usb_put_invalidate_rhdev(hcd);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
#include <linux/usb/hcd.h>
|
||||
#include <linux/usb/otg.h>
|
||||
#include <linux/usb/quirks.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/pm_qos.h>
|
||||
|
||||
|
@ -32,6 +31,7 @@
|
|||
#include <asm/byteorder.h>
|
||||
|
||||
#include "hub.h"
|
||||
#include "otg_whitelist.h"
|
||||
|
||||
#define USB_VENDOR_GENESYS_LOGIC 0x05e3
|
||||
#define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01
|
||||
|
@ -41,14 +41,9 @@
|
|||
* change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
|
||||
static DEFINE_SPINLOCK(device_state_lock);
|
||||
|
||||
/* khubd's worklist and its lock */
|
||||
static DEFINE_SPINLOCK(hub_event_lock);
|
||||
static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
|
||||
|
||||
/* Wakes up khubd */
|
||||
static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
|
||||
|
||||
static struct task_struct *khubd_task;
|
||||
/* workqueue to process hub events */
|
||||
static struct workqueue_struct *hub_wq;
|
||||
static void hub_event(struct work_struct *work);
|
||||
|
||||
/* synchronize hub-port add/remove and peering operations */
|
||||
DEFINE_MUTEX(usb_port_peer_mutex);
|
||||
|
@ -104,6 +99,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
|
|||
#define HUB_DEBOUNCE_STEP 25
|
||||
#define HUB_DEBOUNCE_STABLE 100
|
||||
|
||||
static void hub_release(struct kref *kref);
|
||||
static int usb_reset_and_verify_device(struct usb_device *udev);
|
||||
|
||||
static inline char *portspeed(struct usb_hub *hub, int portstatus)
|
||||
|
@ -575,28 +571,39 @@ static int hub_port_status(struct usb_hub *hub, int port1,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void kick_khubd(struct usb_hub *hub)
|
||||
static void kick_hub_wq(struct usb_hub *hub)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct usb_interface *intf;
|
||||
|
||||
spin_lock_irqsave(&hub_event_lock, flags);
|
||||
if (!hub->disconnected && list_empty(&hub->event_list)) {
|
||||
list_add_tail(&hub->event_list, &hub_event_list);
|
||||
if (hub->disconnected || work_pending(&hub->events))
|
||||
return;
|
||||
|
||||
/* Suppress autosuspend until khubd runs */
|
||||
usb_autopm_get_interface_no_resume(
|
||||
to_usb_interface(hub->intfdev));
|
||||
wake_up(&khubd_wait);
|
||||
}
|
||||
spin_unlock_irqrestore(&hub_event_lock, flags);
|
||||
/*
|
||||
* Suppress autosuspend until the event is proceed.
|
||||
*
|
||||
* Be careful and make sure that the symmetric operation is
|
||||
* always called. We are here only when there is no pending
|
||||
* work for this hub. Therefore put the interface either when
|
||||
* the new work is called or when it is canceled.
|
||||
*/
|
||||
intf = to_usb_interface(hub->intfdev);
|
||||
usb_autopm_get_interface_no_resume(intf);
|
||||
kref_get(&hub->kref);
|
||||
|
||||
if (queue_work(hub_wq, &hub->events))
|
||||
return;
|
||||
|
||||
/* the work has already been scheduled */
|
||||
usb_autopm_put_interface_async(intf);
|
||||
kref_put(&hub->kref, hub_release);
|
||||
}
|
||||
|
||||
void usb_kick_khubd(struct usb_device *hdev)
|
||||
void usb_kick_hub_wq(struct usb_device *hdev)
|
||||
{
|
||||
struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
|
||||
|
||||
if (hub)
|
||||
kick_khubd(hub);
|
||||
kick_hub_wq(hub);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -618,7 +625,7 @@ void usb_wakeup_notification(struct usb_device *hdev,
|
|||
hub = usb_hub_to_struct_hub(hdev);
|
||||
if (hub) {
|
||||
set_bit(portnum, hub->wakeup_bits);
|
||||
kick_khubd(hub);
|
||||
kick_hub_wq(hub);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_wakeup_notification);
|
||||
|
@ -645,7 +652,7 @@ static void hub_irq(struct urb *urb)
|
|||
hub->error = status;
|
||||
/* FALL THROUGH */
|
||||
|
||||
/* let khubd handle things */
|
||||
/* let hub_wq handle things */
|
||||
case 0: /* we got data: port status changed */
|
||||
bits = 0;
|
||||
for (i = 0; i < urb->actual_length; ++i)
|
||||
|
@ -657,8 +664,8 @@ static void hub_irq(struct urb *urb)
|
|||
|
||||
hub->nerrors = 0;
|
||||
|
||||
/* Something happened, let khubd figure it out */
|
||||
kick_khubd(hub);
|
||||
/* Something happened, let hub_wq figure it out */
|
||||
kick_hub_wq(hub);
|
||||
|
||||
resubmit:
|
||||
if (hub->quiescing)
|
||||
|
@ -688,7 +695,7 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
|
|||
}
|
||||
|
||||
/*
|
||||
* enumeration blocks khubd for a long time. we use keventd instead, since
|
||||
* enumeration blocks hub_wq for a long time. we use keventd instead, since
|
||||
* long blocking there is the exception, not the rule. accordingly, HCDs
|
||||
* talking to TTs must queue control transfers (not just bulk and iso), so
|
||||
* both can talk to the same hub concurrently.
|
||||
|
@ -954,7 +961,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
|
|||
|
||||
/*
|
||||
* Disable a port and mark a logical connect-change event, so that some
|
||||
* time later khubd will disconnect() any existing usb_device on the port
|
||||
* time later hub_wq will disconnect() any existing usb_device on the port
|
||||
* and will re-enumerate if there actually is a device attached.
|
||||
*/
|
||||
static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
|
||||
|
@ -967,12 +974,12 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
|
|||
* - SRP saves power that way
|
||||
* - ... new call, TBD ...
|
||||
* That's easy if this hub can switch power per-port, and
|
||||
* khubd reactivates the port later (timer, SRP, etc).
|
||||
* hub_wq reactivates the port later (timer, SRP, etc).
|
||||
* Powerdown must be optional, because of reset/DFU.
|
||||
*/
|
||||
|
||||
set_bit(port1, hub->change_bits);
|
||||
kick_khubd(hub);
|
||||
kick_hub_wq(hub);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -980,7 +987,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
|
|||
* @udev: device to be disabled and removed
|
||||
* Context: @udev locked, must be able to sleep.
|
||||
*
|
||||
* After @udev's port has been disabled, khubd is notified and it will
|
||||
* After @udev's port has been disabled, hub_wq is notified and it will
|
||||
* see that the device has been disconnected. When the device is
|
||||
* physically unplugged and something is plugged in, the events will
|
||||
* be received and processed normally.
|
||||
|
@ -1100,7 +1107,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
init2:
|
||||
|
||||
/*
|
||||
* Check each port and set hub->change_bits to let khubd know
|
||||
* Check each port and set hub->change_bits to let hub_wq know
|
||||
* which ports need attention.
|
||||
*/
|
||||
for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
|
||||
|
@ -1167,7 +1174,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
clear_bit(port1, hub->removed_bits);
|
||||
|
||||
if (!udev || udev->state == USB_STATE_NOTATTACHED) {
|
||||
/* Tell khubd to disconnect the device or
|
||||
/* Tell hub_wq to disconnect the device or
|
||||
* check for a new connection
|
||||
*/
|
||||
if (udev || (portstatus & USB_PORT_STAT_CONNECTION) ||
|
||||
|
@ -1180,7 +1187,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
USB_SS_PORT_LS_U0;
|
||||
/* The power session apparently survived the resume.
|
||||
* If there was an overcurrent or suspend change
|
||||
* (i.e., remote wakeup request), have khubd
|
||||
* (i.e., remote wakeup request), have hub_wq
|
||||
* take care of it. Look at the port link state
|
||||
* for USB 3.0 hubs, since they don't have a suspend
|
||||
* change bit, and they don't set the port link change
|
||||
|
@ -1201,7 +1208,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
set_bit(port1, hub->change_bits);
|
||||
|
||||
} else {
|
||||
/* The power session is gone; tell khubd */
|
||||
/* The power session is gone; tell hub_wq */
|
||||
usb_set_device_state(udev, USB_STATE_NOTATTACHED);
|
||||
set_bit(port1, hub->change_bits);
|
||||
}
|
||||
|
@ -1209,10 +1216,10 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
|
||||
/* If no port-status-change flags were set, we don't need any
|
||||
* debouncing. If flags were set we can try to debounce the
|
||||
* ports all at once right now, instead of letting khubd do them
|
||||
* ports all at once right now, instead of letting hub_wq do them
|
||||
* one at a time later on.
|
||||
*
|
||||
* If any port-status changes do occur during this delay, khubd
|
||||
* If any port-status changes do occur during this delay, hub_wq
|
||||
* will see them later and handle them normally.
|
||||
*/
|
||||
if (need_debounce_delay) {
|
||||
|
@ -1240,7 +1247,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||
&hub->leds, LED_CYCLE_PERIOD);
|
||||
|
||||
/* Scan all ports that need attention */
|
||||
kick_khubd(hub);
|
||||
kick_hub_wq(hub);
|
||||
|
||||
/* Allow autosuspend if it was suppressed */
|
||||
if (type <= HUB_INIT3)
|
||||
|
@ -1273,7 +1280,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
|
|||
|
||||
cancel_delayed_work_sync(&hub->init_work);
|
||||
|
||||
/* khubd and related activity won't re-trigger */
|
||||
/* hub_wq and related activity won't re-trigger */
|
||||
hub->quiescing = 1;
|
||||
|
||||
if (type != HUB_SUSPEND) {
|
||||
|
@ -1284,7 +1291,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
|
|||
}
|
||||
}
|
||||
|
||||
/* Stop khubd and related activity */
|
||||
/* Stop hub_wq and related activity */
|
||||
usb_kill_urb(hub->urb);
|
||||
if (hub->has_indicators)
|
||||
cancel_delayed_work_sync(&hub->leds);
|
||||
|
@ -1606,7 +1613,7 @@ static int hub_configure(struct usb_hub *hub,
|
|||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
/* Update the HCD's internal representation of this hub before khubd
|
||||
/* Update the HCD's internal representation of this hub before hub_wq
|
||||
* starts getting port status changes for devices under the hub.
|
||||
*/
|
||||
if (hcd->driver->update_hub_device) {
|
||||
|
@ -1634,6 +1641,7 @@ static void hub_release(struct kref *kref)
|
|||
{
|
||||
struct usb_hub *hub = container_of(kref, struct usb_hub, kref);
|
||||
|
||||
usb_put_dev(hub->hdev);
|
||||
usb_put_intf(to_usb_interface(hub->intfdev));
|
||||
kfree(hub);
|
||||
}
|
||||
|
@ -1646,14 +1654,11 @@ static void hub_disconnect(struct usb_interface *intf)
|
|||
struct usb_device *hdev = interface_to_usbdev(intf);
|
||||
int port1;
|
||||
|
||||
/* Take the hub off the event list and don't let it be added again */
|
||||
spin_lock_irq(&hub_event_lock);
|
||||
if (!list_empty(&hub->event_list)) {
|
||||
list_del_init(&hub->event_list);
|
||||
usb_autopm_put_interface_no_suspend(intf);
|
||||
}
|
||||
/*
|
||||
* Stop adding new hub events. We do not want to block here and thus
|
||||
* will not try to remove any pending work item.
|
||||
*/
|
||||
hub->disconnected = 1;
|
||||
spin_unlock_irq(&hub_event_lock);
|
||||
|
||||
/* Disconnect all children and quiesce the hub */
|
||||
hub->error = 0;
|
||||
|
@ -1793,12 +1798,13 @@ descriptor_error:
|
|||
}
|
||||
|
||||
kref_init(&hub->kref);
|
||||
INIT_LIST_HEAD(&hub->event_list);
|
||||
hub->intfdev = &intf->dev;
|
||||
hub->hdev = hdev;
|
||||
INIT_DELAYED_WORK(&hub->leds, led_work);
|
||||
INIT_DELAYED_WORK(&hub->init_work, NULL);
|
||||
INIT_WORK(&hub->events, hub_event);
|
||||
usb_get_intf(intf);
|
||||
usb_get_dev(hdev);
|
||||
|
||||
usb_set_intfdata (intf, hub);
|
||||
intf->needs_remote_wakeup = 1;
|
||||
|
@ -1983,8 +1989,10 @@ void usb_set_device_state(struct usb_device *udev,
|
|||
|| new_state == USB_STATE_SUSPENDED)
|
||||
; /* No change to wakeup settings */
|
||||
else if (new_state == USB_STATE_CONFIGURED)
|
||||
wakeup = udev->actconfig->desc.bmAttributes
|
||||
& USB_CONFIG_ATT_WAKEUP;
|
||||
wakeup = (udev->quirks &
|
||||
USB_QUIRK_IGNORE_REMOTE_WAKEUP) ? 0 :
|
||||
udev->actconfig->desc.bmAttributes &
|
||||
USB_CONFIG_ATT_WAKEUP;
|
||||
else
|
||||
wakeup = 0;
|
||||
}
|
||||
|
@ -2037,7 +2045,8 @@ static void choose_devnum(struct usb_device *udev)
|
|||
int devnum;
|
||||
struct usb_bus *bus = udev->bus;
|
||||
|
||||
/* If khubd ever becomes multithreaded, this will need a lock */
|
||||
/* be safe when more hub events are proceed in parallel */
|
||||
mutex_lock(&bus->usb_address0_mutex);
|
||||
if (udev->wusb) {
|
||||
devnum = udev->portnum + 1;
|
||||
BUG_ON(test_bit(devnum, bus->devmap.devicemap));
|
||||
|
@ -2055,6 +2064,7 @@ static void choose_devnum(struct usb_device *udev)
|
|||
set_bit(devnum, bus->devmap.devicemap);
|
||||
udev->devnum = devnum;
|
||||
}
|
||||
mutex_unlock(&bus->usb_address0_mutex);
|
||||
}
|
||||
|
||||
static void release_devnum(struct usb_device *udev)
|
||||
|
@ -2205,9 +2215,6 @@ static void announce_device(struct usb_device *udev)
|
|||
static inline void announce_device(struct usb_device *udev) { }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_OTG
|
||||
#include "otg_whitelist.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* usb_enumerate_device_otg - FIXME (usbcore-internal)
|
||||
|
@ -2267,21 +2274,6 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_targeted(udev)) {
|
||||
|
||||
/* Maybe it can talk to us, though we can't talk to it.
|
||||
* (Includes HNP test device.)
|
||||
*/
|
||||
if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
|
||||
err = usb_port_suspend(udev, PMSG_SUSPEND);
|
||||
if (err < 0)
|
||||
dev_dbg(&udev->dev, "HNP fail, %d\n", err);
|
||||
}
|
||||
err = -ENOTSUPP;
|
||||
goto fail;
|
||||
}
|
||||
fail:
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
@ -2304,6 +2296,7 @@ fail:
|
|||
static int usb_enumerate_device(struct usb_device *udev)
|
||||
{
|
||||
int err;
|
||||
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
|
||||
|
||||
if (udev->config == NULL) {
|
||||
err = usb_get_configuration(udev);
|
||||
|
@ -2325,6 +2318,20 @@ static int usb_enumerate_device(struct usb_device *udev)
|
|||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (IS_ENABLED(CONFIG_USB_OTG_WHITELIST) && hcd->tpl_support &&
|
||||
!is_targeted(udev)) {
|
||||
/* Maybe it can talk to us, though we can't talk to it.
|
||||
* (Includes HNP test device.)
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_USB_OTG) && (udev->bus->b_hnp_enable
|
||||
|| udev->bus->is_b_host)) {
|
||||
err = usb_port_suspend(udev, PMSG_AUTO_SUSPEND);
|
||||
if (err < 0)
|
||||
dev_dbg(&udev->dev, "HNP fail, %d\n", err);
|
||||
}
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
usb_detect_interface_quirks(udev);
|
||||
|
||||
return 0;
|
||||
|
@ -3070,7 +3077,7 @@ static unsigned wakeup_enabled_descendants(struct usb_device *udev)
|
|||
* Once VBUS drop breaks the circuit, the port it's using has to go through
|
||||
* normal re-enumeration procedures, starting with enabling VBUS power.
|
||||
* Other than re-initializing the hub (plug/unplug, except for root hubs),
|
||||
* Linux (2.6) currently has NO mechanisms to initiate that: no khubd
|
||||
* Linux (2.6) currently has NO mechanisms to initiate that: no hub_wq
|
||||
* timer, no SRP, no requests through sysfs.
|
||||
*
|
||||
* If Runtime PM isn't enabled or used, non-SuperSpeed devices may not get
|
||||
|
@ -3212,7 +3219,7 @@ static int finish_port_resume(struct usb_device *udev)
|
|||
/* usb ch9 identifies four variants of SUSPENDED, based on what
|
||||
* state the device resumes to. Linux currently won't see the
|
||||
* first two on the host side; they'd be inside hub_port_init()
|
||||
* during many timeouts, but khubd can't suspend until later.
|
||||
* during many timeouts, but hub_wq can't suspend until later.
|
||||
*/
|
||||
usb_set_device_state(udev, udev->actconfig
|
||||
? USB_STATE_CONFIGURED
|
||||
|
@ -3577,7 +3584,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
|
|||
|
||||
dev_dbg(&intf->dev, "%s\n", __func__);
|
||||
|
||||
/* stop khubd and related activity */
|
||||
/* stop hub_wq and related activity */
|
||||
hub_quiesce(hub, HUB_SUSPEND);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4461,8 +4468,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
|
|||
if (retval)
|
||||
goto fail;
|
||||
|
||||
if (hcd->phy && !hdev->parent)
|
||||
usb_phy_notify_connect(hcd->phy, udev->speed);
|
||||
if (hcd->usb_phy && !hdev->parent)
|
||||
usb_phy_notify_connect(hcd->usb_phy, udev->speed);
|
||||
|
||||
/*
|
||||
* Some superspeed devices have finished the link training process
|
||||
|
@ -4538,6 +4545,9 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
|
|||
struct usb_qualifier_descriptor *qual;
|
||||
int status;
|
||||
|
||||
if (udev->quirks & USB_QUIRK_DEVICE_QUALIFIER)
|
||||
return;
|
||||
|
||||
qual = kmalloc (sizeof *qual, GFP_KERNEL);
|
||||
if (qual == NULL)
|
||||
return;
|
||||
|
@ -4617,9 +4627,9 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
|
|||
|
||||
/* Disconnect any existing devices under this port */
|
||||
if (udev) {
|
||||
if (hcd->phy && !hdev->parent &&
|
||||
if (hcd->usb_phy && !hdev->parent &&
|
||||
!(portstatus & USB_PORT_STAT_CONNECTION))
|
||||
usb_phy_notify_disconnect(hcd->phy, udev->speed);
|
||||
usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
|
||||
usb_disconnect(&port_dev->child);
|
||||
}
|
||||
|
||||
|
@ -4970,10 +4980,10 @@ static void port_event(struct usb_hub *hub, int port1)
|
|||
* On disconnect USB3 protocol ports transit from U0 to
|
||||
* SS.Inactive to Rx.Detect. If this happens a warm-
|
||||
* reset is not needed, but a (re)connect may happen
|
||||
* before khubd runs and sees the disconnect, and the
|
||||
* before hub_wq runs and sees the disconnect, and the
|
||||
* device may be an unknown state.
|
||||
*
|
||||
* If the port went through SS.Inactive without khubd
|
||||
* If the port went through SS.Inactive without hub_wq
|
||||
* seeing it the C_LINK_STATE change flag will be set,
|
||||
* and we reset the dev to put it in a known state.
|
||||
*/
|
||||
|
@ -4992,10 +5002,8 @@ static void port_event(struct usb_hub *hub, int port1)
|
|||
hub_port_connect_change(hub, port1, portstatus, portchange);
|
||||
}
|
||||
|
||||
|
||||
static void hub_events(void)
|
||||
static void hub_event(struct work_struct *work)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct usb_device *hdev;
|
||||
struct usb_interface *intf;
|
||||
struct usb_hub *hub;
|
||||
|
@ -5004,166 +5012,117 @@ static void hub_events(void)
|
|||
u16 hubchange;
|
||||
int i, ret;
|
||||
|
||||
/*
|
||||
* We restart the list every time to avoid a deadlock with
|
||||
* deleting hubs downstream from this one. This should be
|
||||
* safe since we delete the hub from the event list.
|
||||
* Not the most efficient, but avoids deadlocks.
|
||||
*/
|
||||
while (1) {
|
||||
hub = container_of(work, struct usb_hub, events);
|
||||
hdev = hub->hdev;
|
||||
hub_dev = hub->intfdev;
|
||||
intf = to_usb_interface(hub_dev);
|
||||
|
||||
/* Grab the first entry at the beginning of the list */
|
||||
spin_lock_irq(&hub_event_lock);
|
||||
if (list_empty(&hub_event_list)) {
|
||||
spin_unlock_irq(&hub_event_lock);
|
||||
break;
|
||||
}
|
||||
dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
|
||||
hdev->state, hdev->maxchild,
|
||||
/* NOTE: expects max 15 ports... */
|
||||
(u16) hub->change_bits[0],
|
||||
(u16) hub->event_bits[0]);
|
||||
|
||||
tmp = hub_event_list.next;
|
||||
list_del_init(tmp);
|
||||
/* Lock the device, then check to see if we were
|
||||
* disconnected while waiting for the lock to succeed. */
|
||||
usb_lock_device(hdev);
|
||||
if (unlikely(hub->disconnected))
|
||||
goto out_hdev_lock;
|
||||
|
||||
hub = list_entry(tmp, struct usb_hub, event_list);
|
||||
kref_get(&hub->kref);
|
||||
hdev = hub->hdev;
|
||||
usb_get_dev(hdev);
|
||||
spin_unlock_irq(&hub_event_lock);
|
||||
/* If the hub has died, clean up after it */
|
||||
if (hdev->state == USB_STATE_NOTATTACHED) {
|
||||
hub->error = -ENODEV;
|
||||
hub_quiesce(hub, HUB_DISCONNECT);
|
||||
goto out_hdev_lock;
|
||||
}
|
||||
|
||||
hub_dev = hub->intfdev;
|
||||
intf = to_usb_interface(hub_dev);
|
||||
dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
|
||||
hdev->state, hdev->maxchild,
|
||||
/* NOTE: expects max 15 ports... */
|
||||
(u16) hub->change_bits[0],
|
||||
(u16) hub->event_bits[0]);
|
||||
/* Autoresume */
|
||||
ret = usb_autopm_get_interface(intf);
|
||||
if (ret) {
|
||||
dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
|
||||
goto out_hdev_lock;
|
||||
}
|
||||
|
||||
/* Lock the device, then check to see if we were
|
||||
* disconnected while waiting for the lock to succeed. */
|
||||
usb_lock_device(hdev);
|
||||
if (unlikely(hub->disconnected))
|
||||
goto loop_disconnected;
|
||||
/* If this is an inactive hub, do nothing */
|
||||
if (hub->quiescing)
|
||||
goto out_autopm;
|
||||
|
||||
/* If the hub has died, clean up after it */
|
||||
if (hdev->state == USB_STATE_NOTATTACHED) {
|
||||
hub->error = -ENODEV;
|
||||
hub_quiesce(hub, HUB_DISCONNECT);
|
||||
goto loop;
|
||||
}
|
||||
if (hub->error) {
|
||||
dev_dbg(hub_dev, "resetting for error %d\n", hub->error);
|
||||
|
||||
/* Autoresume */
|
||||
ret = usb_autopm_get_interface(intf);
|
||||
ret = usb_reset_device(hdev);
|
||||
if (ret) {
|
||||
dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
|
||||
goto loop;
|
||||
dev_dbg(hub_dev, "error resetting hub: %d\n", ret);
|
||||
goto out_autopm;
|
||||
}
|
||||
|
||||
/* If this is an inactive hub, do nothing */
|
||||
if (hub->quiescing)
|
||||
goto loop_autopm;
|
||||
hub->nerrors = 0;
|
||||
hub->error = 0;
|
||||
}
|
||||
|
||||
if (hub->error) {
|
||||
dev_dbg (hub_dev, "resetting for error %d\n",
|
||||
hub->error);
|
||||
/* deal with port status changes */
|
||||
for (i = 1; i <= hdev->maxchild; i++) {
|
||||
struct usb_port *port_dev = hub->ports[i - 1];
|
||||
|
||||
ret = usb_reset_device(hdev);
|
||||
if (ret) {
|
||||
dev_dbg (hub_dev,
|
||||
"error resetting hub: %d\n", ret);
|
||||
goto loop_autopm;
|
||||
}
|
||||
|
||||
hub->nerrors = 0;
|
||||
hub->error = 0;
|
||||
if (test_bit(i, hub->event_bits)
|
||||
|| test_bit(i, hub->change_bits)
|
||||
|| test_bit(i, hub->wakeup_bits)) {
|
||||
/*
|
||||
* The get_noresume and barrier ensure that if
|
||||
* the port was in the process of resuming, we
|
||||
* flush that work and keep the port active for
|
||||
* the duration of the port_event(). However,
|
||||
* if the port is runtime pm suspended
|
||||
* (powered-off), we leave it in that state, run
|
||||
* an abbreviated port_event(), and move on.
|
||||
*/
|
||||
pm_runtime_get_noresume(&port_dev->dev);
|
||||
pm_runtime_barrier(&port_dev->dev);
|
||||
usb_lock_port(port_dev);
|
||||
port_event(hub, i);
|
||||
usb_unlock_port(port_dev);
|
||||
pm_runtime_put_sync(&port_dev->dev);
|
||||
}
|
||||
}
|
||||
|
||||
/* deal with port status changes */
|
||||
for (i = 1; i <= hdev->maxchild; i++) {
|
||||
struct usb_port *port_dev = hub->ports[i - 1];
|
||||
|
||||
if (test_bit(i, hub->event_bits)
|
||||
|| test_bit(i, hub->change_bits)
|
||||
|| test_bit(i, hub->wakeup_bits)) {
|
||||
/*
|
||||
* The get_noresume and barrier ensure that if
|
||||
* the port was in the process of resuming, we
|
||||
* flush that work and keep the port active for
|
||||
* the duration of the port_event(). However,
|
||||
* if the port is runtime pm suspended
|
||||
* (powered-off), we leave it in that state, run
|
||||
* an abbreviated port_event(), and move on.
|
||||
*/
|
||||
pm_runtime_get_noresume(&port_dev->dev);
|
||||
pm_runtime_barrier(&port_dev->dev);
|
||||
usb_lock_port(port_dev);
|
||||
port_event(hub, i);
|
||||
usb_unlock_port(port_dev);
|
||||
pm_runtime_put_sync(&port_dev->dev);
|
||||
}
|
||||
/* deal with hub status changes */
|
||||
if (test_and_clear_bit(0, hub->event_bits) == 0)
|
||||
; /* do nothing */
|
||||
else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0)
|
||||
dev_err(hub_dev, "get_hub_status failed\n");
|
||||
else {
|
||||
if (hubchange & HUB_CHANGE_LOCAL_POWER) {
|
||||
dev_dbg(hub_dev, "power change\n");
|
||||
clear_hub_feature(hdev, C_HUB_LOCAL_POWER);
|
||||
if (hubstatus & HUB_STATUS_LOCAL_POWER)
|
||||
/* FIXME: Is this always true? */
|
||||
hub->limited_power = 1;
|
||||
else
|
||||
hub->limited_power = 0;
|
||||
}
|
||||
if (hubchange & HUB_CHANGE_OVERCURRENT) {
|
||||
u16 status = 0;
|
||||
u16 unused;
|
||||
|
||||
/* deal with hub status changes */
|
||||
if (test_and_clear_bit(0, hub->event_bits) == 0)
|
||||
; /* do nothing */
|
||||
else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0)
|
||||
dev_err (hub_dev, "get_hub_status failed\n");
|
||||
else {
|
||||
if (hubchange & HUB_CHANGE_LOCAL_POWER) {
|
||||
dev_dbg (hub_dev, "power change\n");
|
||||
clear_hub_feature(hdev, C_HUB_LOCAL_POWER);
|
||||
if (hubstatus & HUB_STATUS_LOCAL_POWER)
|
||||
/* FIXME: Is this always true? */
|
||||
hub->limited_power = 1;
|
||||
else
|
||||
hub->limited_power = 0;
|
||||
}
|
||||
if (hubchange & HUB_CHANGE_OVERCURRENT) {
|
||||
u16 status = 0;
|
||||
u16 unused;
|
||||
|
||||
dev_dbg(hub_dev, "over-current change\n");
|
||||
clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
|
||||
msleep(500); /* Cool down */
|
||||
hub_power_on(hub, true);
|
||||
hub_hub_status(hub, &status, &unused);
|
||||
if (status & HUB_STATUS_OVERCURRENT)
|
||||
dev_err(hub_dev, "over-current "
|
||||
"condition\n");
|
||||
}
|
||||
dev_dbg(hub_dev, "over-current change\n");
|
||||
clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
|
||||
msleep(500); /* Cool down */
|
||||
hub_power_on(hub, true);
|
||||
hub_hub_status(hub, &status, &unused);
|
||||
if (status & HUB_STATUS_OVERCURRENT)
|
||||
dev_err(hub_dev, "over-current condition\n");
|
||||
}
|
||||
}
|
||||
|
||||
loop_autopm:
|
||||
/* Balance the usb_autopm_get_interface() above */
|
||||
usb_autopm_put_interface_no_suspend(intf);
|
||||
loop:
|
||||
/* Balance the usb_autopm_get_interface_no_resume() in
|
||||
* kick_khubd() and allow autosuspend.
|
||||
*/
|
||||
usb_autopm_put_interface(intf);
|
||||
loop_disconnected:
|
||||
usb_unlock_device(hdev);
|
||||
usb_put_dev(hdev);
|
||||
kref_put(&hub->kref, hub_release);
|
||||
out_autopm:
|
||||
/* Balance the usb_autopm_get_interface() above */
|
||||
usb_autopm_put_interface_no_suspend(intf);
|
||||
out_hdev_lock:
|
||||
usb_unlock_device(hdev);
|
||||
|
||||
} /* end while (1) */
|
||||
}
|
||||
|
||||
static int hub_thread(void *__unused)
|
||||
{
|
||||
/* khubd needs to be freezable to avoid interfering with USB-PERSIST
|
||||
* port handover. Otherwise it might see that a full-speed device
|
||||
* was gone before the EHCI controller had handed its port over to
|
||||
* the companion full-speed controller.
|
||||
*/
|
||||
set_freezable();
|
||||
|
||||
do {
|
||||
hub_events();
|
||||
wait_event_freezable(khubd_wait,
|
||||
!list_empty(&hub_event_list) ||
|
||||
kthread_should_stop());
|
||||
} while (!kthread_should_stop() || !list_empty(&hub_event_list));
|
||||
|
||||
pr_debug("%s: khubd exiting\n", usbcore_name);
|
||||
return 0;
|
||||
/* Balance the stuff in kick_hub_wq() and allow autosuspend */
|
||||
usb_autopm_put_interface(intf);
|
||||
kref_put(&hub->kref, hub_release);
|
||||
}
|
||||
|
||||
static const struct usb_device_id hub_id_table[] = {
|
||||
|
@ -5203,20 +5162,26 @@ int usb_hub_init(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
khubd_task = kthread_run(hub_thread, NULL, "khubd");
|
||||
if (!IS_ERR(khubd_task))
|
||||
/*
|
||||
* The workqueue needs to be freezable to avoid interfering with
|
||||
* USB-PERSIST port handover. Otherwise it might see that a full-speed
|
||||
* device was gone before the EHCI controller had handed its port
|
||||
* over to the companion full-speed controller.
|
||||
*/
|
||||
hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0);
|
||||
if (hub_wq)
|
||||
return 0;
|
||||
|
||||
/* Fall through if kernel_thread failed */
|
||||
usb_deregister(&hub_driver);
|
||||
printk(KERN_ERR "%s: can't start khubd\n", usbcore_name);
|
||||
pr_err("%s: can't allocate workqueue for usb hub\n", usbcore_name);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void usb_hub_cleanup(void)
|
||||
{
|
||||
kthread_stop(khubd_task);
|
||||
destroy_workqueue(hub_wq);
|
||||
|
||||
/*
|
||||
* Hub resources are freed for us by usb_deregister. It calls
|
||||
|
@ -5325,7 +5290,7 @@ static int descriptors_changed(struct usb_device *udev,
|
|||
* former operating configuration. If the reset fails, or the device's
|
||||
* descriptors change from their values before the reset, or the original
|
||||
* configuration and altsettings cannot be restored, a flag will be set
|
||||
* telling khubd to pretend the device has been disconnected and then
|
||||
* telling hub_wq to pretend the device has been disconnected and then
|
||||
* re-connected. All drivers will be unbound, and the device will be
|
||||
* re-enumerated and probed all over again.
|
||||
*
|
||||
|
|
|
@ -41,7 +41,6 @@ struct usb_hub {
|
|||
int error; /* last reported error */
|
||||
int nerrors; /* track consecutive errors */
|
||||
|
||||
struct list_head event_list; /* hubs w/data or errs ready */
|
||||
unsigned long event_bits[1]; /* status change bitmask */
|
||||
unsigned long change_bits[1]; /* ports with logical connect
|
||||
status change */
|
||||
|
@ -77,6 +76,7 @@ struct usb_hub {
|
|||
u8 indicator[USB_MAXCHILDREN];
|
||||
struct delayed_work leds;
|
||||
struct delayed_work init_work;
|
||||
struct work_struct events;
|
||||
struct usb_port **ports;
|
||||
};
|
||||
|
||||
|
|
|
@ -770,9 +770,7 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)
|
|||
dev->string_langid = 0x0409;
|
||||
dev->have_langid = 1;
|
||||
dev_err(&dev->dev,
|
||||
"string descriptor 0 malformed (err = %d), "
|
||||
"defaulting to 0x%04x\n",
|
||||
err, dev->string_langid);
|
||||
"language id specifier not provided by device, defaulting to English\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* This OTG Whitelist is the OTG "Targeted Peripheral List". It should
|
||||
* mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
|
||||
* This OTG and Embedded Host Whitelist is "Targeted Peripheral List".
|
||||
* It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
|
||||
*
|
||||
* YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
|
||||
*/
|
||||
|
@ -50,10 +50,6 @@ static int is_targeted(struct usb_device *dev)
|
|||
{
|
||||
struct usb_device_id *id = whitelist_table;
|
||||
|
||||
/* possible in developer configs only! */
|
||||
if (!dev->bus->otg_port)
|
||||
return 1;
|
||||
|
||||
/* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
|
||||
if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
|
||||
le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
|
||||
|
@ -103,10 +99,7 @@ static int is_targeted(struct usb_device *dev)
|
|||
dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
|
||||
le16_to_cpu(dev->descriptor.idVendor),
|
||||
le16_to_cpu(dev->descriptor.idProduct));
|
||||
#ifdef CONFIG_USB_OTG_WHITELIST
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,10 @@ static const struct usb_device_id usb_quirk_list[] = {
|
|||
{ USB_DEVICE(0x04e8, 0x6601), .driver_info =
|
||||
USB_QUIRK_CONFIG_INTF_STRINGS },
|
||||
|
||||
/* Elan Touchscreen */
|
||||
{ USB_DEVICE(0x04f3, 0x0089), .driver_info =
|
||||
USB_QUIRK_DEVICE_QUALIFIER },
|
||||
|
||||
/* Roland SC-8820 */
|
||||
{ USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
|
||||
|
||||
|
@ -159,6 +163,10 @@ static const struct usb_device_id usb_quirk_list[] = {
|
|||
/* USB3503 */
|
||||
{ USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
|
||||
|
||||
/* ASUS Base Station(T100) */
|
||||
{ USB_DEVICE(0x0b05, 0x17e0), .driver_info =
|
||||
USB_QUIRK_IGNORE_REMOTE_WAKEUP },
|
||||
|
||||
{ } /* terminating entry must be last */
|
||||
};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static inline unsigned usb_get_max_power(struct usb_device *udev,
|
|||
return c->desc.bMaxPower * mul;
|
||||
}
|
||||
|
||||
extern void usb_kick_khubd(struct usb_device *dev);
|
||||
extern void usb_kick_hub_wq(struct usb_device *dev);
|
||||
extern int usb_match_one_id_intf(struct usb_device *dev,
|
||||
struct usb_host_interface *intf,
|
||||
const struct usb_device_id *id);
|
||||
|
|
|
@ -118,6 +118,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
|
|||
{
|
||||
u32 greset;
|
||||
int count = 0;
|
||||
u32 gusbcfg;
|
||||
|
||||
dev_vdbg(hsotg->dev, "%s()\n", __func__);
|
||||
|
||||
|
@ -148,6 +149,23 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
|
|||
}
|
||||
} while (greset & GRSTCTL_CSFTRST);
|
||||
|
||||
if (hsotg->dr_mode == USB_DR_MODE_HOST) {
|
||||
gusbcfg = readl(hsotg->regs + GUSBCFG);
|
||||
gusbcfg &= ~GUSBCFG_FORCEDEVMODE;
|
||||
gusbcfg |= GUSBCFG_FORCEHOSTMODE;
|
||||
writel(gusbcfg, hsotg->regs + GUSBCFG);
|
||||
} else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) {
|
||||
gusbcfg = readl(hsotg->regs + GUSBCFG);
|
||||
gusbcfg &= ~GUSBCFG_FORCEHOSTMODE;
|
||||
gusbcfg |= GUSBCFG_FORCEDEVMODE;
|
||||
writel(gusbcfg, hsotg->regs + GUSBCFG);
|
||||
} else if (hsotg->dr_mode == USB_DR_MODE_OTG) {
|
||||
gusbcfg = readl(hsotg->regs + GUSBCFG);
|
||||
gusbcfg &= ~GUSBCFG_FORCEHOSTMODE;
|
||||
gusbcfg &= ~GUSBCFG_FORCEDEVMODE;
|
||||
writel(gusbcfg, hsotg->regs + GUSBCFG);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: This long sleep is _very_ important, otherwise the core will
|
||||
* not stay in host mode after a connector ID change!
|
||||
|
@ -2674,23 +2692,23 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
|
|||
hwcfg2 = readl(hsotg->regs + GHWCFG2);
|
||||
hwcfg3 = readl(hsotg->regs + GHWCFG3);
|
||||
hwcfg4 = readl(hsotg->regs + GHWCFG4);
|
||||
gnptxfsiz = readl(hsotg->regs + GNPTXFSIZ);
|
||||
grxfsiz = readl(hsotg->regs + GRXFSIZ);
|
||||
|
||||
dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hwcfg1);
|
||||
dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hwcfg2);
|
||||
dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hwcfg3);
|
||||
dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4);
|
||||
dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
|
||||
dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz);
|
||||
|
||||
/* Force host mode to get HPTXFSIZ exact power on value */
|
||||
/* Force host mode to get HPTXFSIZ / GNPTXFSIZ exact power on value */
|
||||
gusbcfg = readl(hsotg->regs + GUSBCFG);
|
||||
gusbcfg |= GUSBCFG_FORCEHOSTMODE;
|
||||
writel(gusbcfg, hsotg->regs + GUSBCFG);
|
||||
usleep_range(100000, 150000);
|
||||
|
||||
gnptxfsiz = readl(hsotg->regs + GNPTXFSIZ);
|
||||
hptxfsiz = readl(hsotg->regs + HPTXFSIZ);
|
||||
dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
|
||||
dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz);
|
||||
gusbcfg = readl(hsotg->regs + GUSBCFG);
|
||||
gusbcfg &= ~GUSBCFG_FORCEHOSTMODE;
|
||||
|
@ -2725,6 +2743,13 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
|
|||
width = (hwcfg3 & GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK) >>
|
||||
GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT;
|
||||
hw->max_transfer_size = (1 << (width + 11)) - 1;
|
||||
/*
|
||||
* Clip max_transfer_size to 65535. dwc2_hc_setup_align_buf() allocates
|
||||
* coherent buffers with this size, and if it's too large we can
|
||||
* exhaust the coherent DMA pool.
|
||||
*/
|
||||
if (hw->max_transfer_size > 65535)
|
||||
hw->max_transfer_size = 65535;
|
||||
width = (hwcfg3 & GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK) >>
|
||||
GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT;
|
||||
hw->max_packet_count = (1 << (width + 4)) - 1;
|
||||
|
|
|
@ -139,6 +139,7 @@ struct s3c_hsotg_ep {
|
|||
unsigned int last_load;
|
||||
unsigned int fifo_load;
|
||||
unsigned short fifo_size;
|
||||
unsigned short fifo_index;
|
||||
|
||||
unsigned char dir_in;
|
||||
unsigned char index;
|
||||
|
@ -194,8 +195,10 @@ struct s3c_hsotg {
|
|||
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
|
||||
|
||||
u32 phyif;
|
||||
int fifo_mem;
|
||||
unsigned int dedicated_fifos:1;
|
||||
unsigned char num_of_eps;
|
||||
u32 fifo_map;
|
||||
|
||||
struct dentry *debug_root;
|
||||
struct dentry *debug_file;
|
||||
|
@ -501,6 +504,10 @@ struct dwc2_hw_params {
|
|||
* a_peripheral and b_device=>b_host) this may not match
|
||||
* the core, but allows the software to determine
|
||||
* transitions
|
||||
* @dr_mode: Requested mode of operation, one of following:
|
||||
* - USB_DR_MODE_PERIPHERAL
|
||||
* - USB_DR_MODE_HOST
|
||||
* - USB_DR_MODE_OTG
|
||||
* @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
|
||||
* transfer are in process of being queued
|
||||
* @srp_success: Stores status of SRP request in the case of a FS PHY
|
||||
|
@ -592,6 +599,7 @@ struct dwc2_hsotg {
|
|||
/** Params to actually use */
|
||||
struct dwc2_core_params *core_params;
|
||||
enum usb_otg_state op_state;
|
||||
enum usb_dr_mode dr_mode;
|
||||
|
||||
unsigned int queuing_high_bandwidth:1;
|
||||
unsigned int srp_success:1;
|
||||
|
|
|
@ -182,16 +182,33 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
|
|||
|
||||
/* start at the end of the GNPTXFSIZ, rounded up */
|
||||
addr = 2048 + 1024;
|
||||
size = 768;
|
||||
|
||||
/*
|
||||
* currently we allocate TX FIFOs for all possible endpoints,
|
||||
* and assume that they are all the same size.
|
||||
* Because we have not enough memory to have each TX FIFO of size at
|
||||
* least 3072 bytes (the maximum single packet size), we create four
|
||||
* FIFOs of lenght 1024, and four of length 3072 bytes, and assing
|
||||
* them to endpoints dynamically according to maxpacket size value of
|
||||
* given endpoint.
|
||||
*/
|
||||
|
||||
for (ep = 1; ep <= 15; ep++) {
|
||||
/* 256*4=1024 bytes FIFO length */
|
||||
size = 256;
|
||||
for (ep = 1; ep <= 4; ep++) {
|
||||
val = addr;
|
||||
val |= size << FIFOSIZE_DEPTH_SHIFT;
|
||||
WARN_ONCE(addr + size > hsotg->fifo_mem,
|
||||
"insufficient fifo memory");
|
||||
addr += size;
|
||||
|
||||
writel(val, hsotg->regs + DPTXFSIZN(ep));
|
||||
}
|
||||
/* 768*4=3072 bytes FIFO length */
|
||||
size = 768;
|
||||
for (ep = 5; ep <= 8; ep++) {
|
||||
val = addr;
|
||||
val |= size << FIFOSIZE_DEPTH_SHIFT;
|
||||
WARN_ONCE(addr + size > hsotg->fifo_mem,
|
||||
"insufficient fifo memory");
|
||||
addr += size;
|
||||
|
||||
writel(val, hsotg->regs + DPTXFSIZN(ep));
|
||||
|
@ -987,8 +1004,8 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg *hsotg,
|
|||
hs_req = ep->req;
|
||||
ep->req = NULL;
|
||||
list_del_init(&hs_req->queue);
|
||||
hs_req->req.complete(&ep->ep,
|
||||
&hs_req->req);
|
||||
usb_gadget_giveback_request(&ep->ep,
|
||||
&hs_req->req);
|
||||
}
|
||||
|
||||
/* If we have pending request, then start it */
|
||||
|
@ -1245,7 +1262,7 @@ static void s3c_hsotg_complete_request(struct s3c_hsotg *hsotg,
|
|||
|
||||
if (hs_req->req.complete) {
|
||||
spin_unlock(&hsotg->lock);
|
||||
hs_req->req.complete(&hs_ep->ep, &hs_req->req);
|
||||
usb_gadget_giveback_request(&hs_ep->ep, &hs_req->req);
|
||||
spin_lock(&hsotg->lock);
|
||||
}
|
||||
|
||||
|
@ -1832,7 +1849,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
|
|||
if (dir_in) {
|
||||
int epctl = readl(hsotg->regs + epctl_reg);
|
||||
|
||||
s3c_hsotg_txfifo_flush(hsotg, idx);
|
||||
s3c_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index);
|
||||
|
||||
if ((epctl & DXEPCTL_STALL) &&
|
||||
(epctl & DXEPCTL_EPTYPE_BULK)) {
|
||||
|
@ -1981,6 +1998,7 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
|
|||
int result, bool force)
|
||||
{
|
||||
struct s3c_hsotg_req *req, *treq;
|
||||
unsigned size;
|
||||
|
||||
list_for_each_entry_safe(req, treq, &ep->queue, queue) {
|
||||
/*
|
||||
|
@ -1994,9 +2012,11 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
|
|||
s3c_hsotg_complete_request(hsotg, ep, req,
|
||||
result);
|
||||
}
|
||||
if (hsotg->dedicated_fifos)
|
||||
if ((readl(hsotg->regs + DTXFSTS(ep->index)) & 0xffff) * 4 < 3072)
|
||||
s3c_hsotg_txfifo_flush(hsotg, ep->index);
|
||||
if (!hsotg->dedicated_fifos)
|
||||
return;
|
||||
size = (readl(hsotg->regs + DTXFSTS(ep->index)) & 0xffff) * 4;
|
||||
if (size < ep->fifo_size)
|
||||
s3c_hsotg_txfifo_flush(hsotg, ep->fifo_index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2437,6 +2457,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
|
|||
u32 epctrl;
|
||||
u32 mps;
|
||||
int dir_in;
|
||||
int i, val, size;
|
||||
int ret = 0;
|
||||
|
||||
dev_dbg(hsotg->dev,
|
||||
|
@ -2509,17 +2530,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
|
|||
break;
|
||||
|
||||
case USB_ENDPOINT_XFER_INT:
|
||||
if (dir_in) {
|
||||
/*
|
||||
* Allocate our TxFNum by simply using the index
|
||||
* of the endpoint for the moment. We could do
|
||||
* something better if the host indicates how
|
||||
* many FIFOs we are expecting to use.
|
||||
*/
|
||||
|
||||
if (dir_in)
|
||||
hs_ep->periodic = 1;
|
||||
epctrl |= DXEPCTL_TXFNUM(index);
|
||||
}
|
||||
|
||||
epctrl |= DXEPCTL_EPTYPE_INTERRUPT;
|
||||
break;
|
||||
|
@ -2533,8 +2545,25 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
|
|||
* if the hardware has dedicated fifos, we must give each IN EP
|
||||
* a unique tx-fifo even if it is non-periodic.
|
||||
*/
|
||||
if (dir_in && hsotg->dedicated_fifos)
|
||||
epctrl |= DXEPCTL_TXFNUM(index);
|
||||
if (dir_in && hsotg->dedicated_fifos) {
|
||||
size = hs_ep->ep.maxpacket*hs_ep->mc;
|
||||
for (i = 1; i <= 8; ++i) {
|
||||
if (hsotg->fifo_map & (1<<i))
|
||||
continue;
|
||||
val = readl(hsotg->regs + DPTXFSIZN(i));
|
||||
val = (val >> FIFOSIZE_DEPTH_SHIFT)*4;
|
||||
if (val < size)
|
||||
continue;
|
||||
hsotg->fifo_map |= 1<<i;
|
||||
|
||||
epctrl |= DXEPCTL_TXFNUM(i);
|
||||
hs_ep->fifo_index = i;
|
||||
hs_ep->fifo_size = val;
|
||||
break;
|
||||
}
|
||||
if (i == 8)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* for non control endpoints, set PID to D0 */
|
||||
if (index)
|
||||
|
@ -2568,7 +2597,7 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
|
|||
u32 epctrl_reg;
|
||||
u32 ctrl;
|
||||
|
||||
dev_info(hsotg->dev, "%s(ep %p)\n", __func__, ep);
|
||||
dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep);
|
||||
|
||||
if (ep == &hsotg->eps[0].ep) {
|
||||
dev_err(hsotg->dev, "%s: called for ep0\n", __func__);
|
||||
|
@ -2581,6 +2610,9 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
|
|||
/* terminate all requests with shutdown */
|
||||
kill_all_requests(hsotg, hs_ep, -ESHUTDOWN, false);
|
||||
|
||||
hsotg->fifo_map &= ~(1<<hs_ep->fifo_index);
|
||||
hs_ep->fifo_index = 0;
|
||||
hs_ep->fifo_size = 0;
|
||||
|
||||
ctrl = readl(hsotg->regs + epctrl_reg);
|
||||
ctrl &= ~DXEPCTL_EPENA;
|
||||
|
@ -2626,7 +2658,7 @@ static int s3c_hsotg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
|
|||
struct s3c_hsotg *hs = hs_ep->parent;
|
||||
unsigned long flags;
|
||||
|
||||
dev_info(hs->dev, "ep_dequeue(%p,%p)\n", ep, req);
|
||||
dev_dbg(hs->dev, "ep_dequeue(%p,%p)\n", ep, req);
|
||||
|
||||
spin_lock_irqsave(&hs->lock, flags);
|
||||
|
||||
|
@ -2861,6 +2893,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
|
|||
hsotg->gadget.dev.of_node = hsotg->dev->of_node;
|
||||
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
|
||||
clk_enable(hsotg->clk);
|
||||
|
||||
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
|
||||
hsotg->supplies);
|
||||
if (ret) {
|
||||
|
@ -2909,6 +2943,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
|
|||
|
||||
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
|
||||
|
||||
clk_disable(hsotg->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2935,13 +2971,15 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
|
|||
struct s3c_hsotg *hsotg = to_hsotg(gadget);
|
||||
unsigned long flags = 0;
|
||||
|
||||
dev_dbg(hsotg->dev, "%s: is_in: %d\n", __func__, is_on);
|
||||
dev_dbg(hsotg->dev, "%s: is_on: %d\n", __func__, is_on);
|
||||
|
||||
spin_lock_irqsave(&hsotg->lock, flags);
|
||||
if (is_on) {
|
||||
s3c_hsotg_phy_enable(hsotg);
|
||||
clk_enable(hsotg->clk);
|
||||
s3c_hsotg_core_init(hsotg);
|
||||
} else {
|
||||
clk_disable(hsotg->clk);
|
||||
s3c_hsotg_phy_disable(hsotg);
|
||||
}
|
||||
|
||||
|
@ -2972,7 +3010,6 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
|
|||
struct s3c_hsotg_ep *hs_ep,
|
||||
int epnum)
|
||||
{
|
||||
u32 ptxfifo;
|
||||
char *dir;
|
||||
|
||||
if (epnum == 0)
|
||||
|
@ -3000,15 +3037,6 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
|
|||
usb_ep_set_maxpacket_limit(&hs_ep->ep, epnum ? 1024 : EP0_MPS_LIMIT);
|
||||
hs_ep->ep.ops = &s3c_hsotg_ep_ops;
|
||||
|
||||
/*
|
||||
* Read the FIFO size for the Periodic TX FIFO, even if we're
|
||||
* an OUT endpoint, we may as well do this if in future the
|
||||
* code is changed to make each endpoint's direction changeable.
|
||||
*/
|
||||
|
||||
ptxfifo = readl(hsotg->regs + DPTXFSIZN(epnum));
|
||||
hs_ep->fifo_size = FIFOSIZE_DEPTH_GET(ptxfifo) * 4;
|
||||
|
||||
/*
|
||||
* if we're using dma, we need to set the next-endpoint pointer
|
||||
* to be something valid.
|
||||
|
@ -3029,19 +3057,22 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
|
|||
*/
|
||||
static void s3c_hsotg_hw_cfg(struct s3c_hsotg *hsotg)
|
||||
{
|
||||
u32 cfg2, cfg4;
|
||||
u32 cfg2, cfg3, cfg4;
|
||||
/* check hardware configuration */
|
||||
|
||||
cfg2 = readl(hsotg->regs + 0x48);
|
||||
hsotg->num_of_eps = (cfg2 >> 10) & 0xF;
|
||||
|
||||
dev_info(hsotg->dev, "EPs:%d\n", hsotg->num_of_eps);
|
||||
cfg3 = readl(hsotg->regs + 0x4C);
|
||||
hsotg->fifo_mem = (cfg3 >> 16);
|
||||
|
||||
cfg4 = readl(hsotg->regs + 0x50);
|
||||
hsotg->dedicated_fifos = (cfg4 >> 25) & 1;
|
||||
|
||||
dev_info(hsotg->dev, "%s fifos\n",
|
||||
hsotg->dedicated_fifos ? "dedicated" : "shared");
|
||||
dev_info(hsotg->dev, "EPs: %d, %s fifos, %d entries in SPRAM\n",
|
||||
hsotg->num_of_eps,
|
||||
hsotg->dedicated_fifos ? "dedicated" : "shared",
|
||||
hsotg->fifo_mem);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3392,6 +3423,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
|
|||
if (!hsotg)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Set default UTMI width */
|
||||
hsotg->phyif = GUSBCFG_PHYIF16;
|
||||
|
||||
/*
|
||||
* Attempt to find a generic PHY, then look for an old style
|
||||
* USB PHY, finally fall back to pdata
|
||||
|
@ -3410,8 +3444,15 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
|
|||
hsotg->plat = plat;
|
||||
} else
|
||||
hsotg->uphy = uphy;
|
||||
} else
|
||||
} else {
|
||||
hsotg->phy = phy;
|
||||
/*
|
||||
* If using the generic PHY framework, check if the PHY bus
|
||||
* width is 8-bit and set the phyif appropriately.
|
||||
*/
|
||||
if (phy_get_bus_width(phy) == 8)
|
||||
hsotg->phyif = GUSBCFG_PHYIF8;
|
||||
}
|
||||
|
||||
hsotg->dev = dev;
|
||||
|
||||
|
@ -3471,22 +3512,12 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
|
|||
goto err_supplies;
|
||||
}
|
||||
|
||||
/* Set default UTMI width */
|
||||
hsotg->phyif = GUSBCFG_PHYIF16;
|
||||
|
||||
/*
|
||||
* If using the generic PHY framework, check if the PHY bus
|
||||
* width is 8-bit and set the phyif appropriately.
|
||||
*/
|
||||
if (hsotg->phy && (phy_get_bus_width(phy) == 8))
|
||||
hsotg->phyif = GUSBCFG_PHYIF8;
|
||||
|
||||
/* usb phy enable */
|
||||
s3c_hsotg_phy_enable(hsotg);
|
||||
|
||||
s3c_hsotg_corereset(hsotg);
|
||||
s3c_hsotg_init(hsotg);
|
||||
s3c_hsotg_hw_cfg(hsotg);
|
||||
s3c_hsotg_init(hsotg);
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
|
||||
dev_name(dev), hsotg);
|
||||
|
@ -3611,6 +3642,7 @@ static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state)
|
|||
|
||||
ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
|
||||
hsotg->supplies);
|
||||
clk_disable(hsotg->clk);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -3625,6 +3657,8 @@ static int s3c_hsotg_resume(struct platform_device *pdev)
|
|||
if (hsotg->driver) {
|
||||
dev_info(hsotg->dev, "resuming usb gadget %s\n",
|
||||
hsotg->driver->driver.name);
|
||||
|
||||
clk_enable(hsotg->clk);
|
||||
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
|
||||
hsotg->supplies);
|
||||
}
|
||||
|
|
|
@ -697,29 +697,45 @@ static void *dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
|
|||
}
|
||||
|
||||
static int dwc2_hc_setup_align_buf(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
|
||||
struct dwc2_host_chan *chan, void *bufptr)
|
||||
struct dwc2_host_chan *chan,
|
||||
struct dwc2_hcd_urb *urb, void *bufptr)
|
||||
{
|
||||
u32 buf_size;
|
||||
|
||||
if (chan->ep_type != USB_ENDPOINT_XFER_ISOC)
|
||||
buf_size = hsotg->core_params->max_transfer_size;
|
||||
else
|
||||
buf_size = 4096;
|
||||
struct urb *usb_urb;
|
||||
struct usb_hcd *hcd;
|
||||
|
||||
if (!qh->dw_align_buf) {
|
||||
if (chan->ep_type != USB_ENDPOINT_XFER_ISOC)
|
||||
buf_size = hsotg->core_params->max_transfer_size;
|
||||
else
|
||||
/* 3072 = 3 max-size Isoc packets */
|
||||
buf_size = 3072;
|
||||
|
||||
qh->dw_align_buf = dma_alloc_coherent(hsotg->dev, buf_size,
|
||||
&qh->dw_align_buf_dma,
|
||||
GFP_ATOMIC);
|
||||
if (!qh->dw_align_buf)
|
||||
return -ENOMEM;
|
||||
qh->dw_align_buf_size = buf_size;
|
||||
}
|
||||
|
||||
if (!chan->ep_is_in && chan->xfer_len) {
|
||||
dma_sync_single_for_cpu(hsotg->dev, chan->xfer_dma, buf_size,
|
||||
DMA_TO_DEVICE);
|
||||
memcpy(qh->dw_align_buf, bufptr, chan->xfer_len);
|
||||
dma_sync_single_for_device(hsotg->dev, chan->xfer_dma, buf_size,
|
||||
DMA_TO_DEVICE);
|
||||
if (chan->xfer_len) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__);
|
||||
usb_urb = urb->priv;
|
||||
|
||||
if (usb_urb) {
|
||||
if (usb_urb->transfer_flags &
|
||||
(URB_SETUP_MAP_SINGLE | URB_DMA_MAP_SG |
|
||||
URB_DMA_MAP_PAGE | URB_DMA_MAP_SINGLE)) {
|
||||
hcd = dwc2_hsotg_to_hcd(hsotg);
|
||||
usb_hcd_unmap_urb_for_dma(hcd, usb_urb);
|
||||
}
|
||||
if (!chan->ep_is_in)
|
||||
memcpy(qh->dw_align_buf, bufptr,
|
||||
chan->xfer_len);
|
||||
} else {
|
||||
dev_warn(hsotg->dev, "no URB in dwc2_urb\n");
|
||||
}
|
||||
}
|
||||
|
||||
chan->align_buf = qh->dw_align_buf_dma;
|
||||
|
@ -828,7 +844,7 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
|
|||
/* Non DWORD-aligned buffer case */
|
||||
if (bufptr) {
|
||||
dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
|
||||
if (dwc2_hc_setup_align_buf(hsotg, qh, chan, bufptr)) {
|
||||
if (dwc2_hc_setup_align_buf(hsotg, qh, chan, urb, bufptr)) {
|
||||
dev_err(hsotg->dev,
|
||||
"%s: Failed to allocate memory to handle non-dword aligned buffer\n",
|
||||
__func__);
|
||||
|
|
|
@ -243,7 +243,8 @@ enum dwc2_transaction_type {
|
|||
* @ntd: Actual number of transfer descriptors in a list
|
||||
* @dw_align_buf: Used instead of original buffer if its physical address
|
||||
* is not dword-aligned
|
||||
* @dw_align_buf_dma: DMA address for align_buf
|
||||
* @dw_align_buf_size: Size of dw_align_buf
|
||||
* @dw_align_buf_dma: DMA address for dw_align_buf
|
||||
* @qtd_list: List of QTDs for this QH
|
||||
* @channel: Host channel currently processing transfers for this QH
|
||||
* @qh_list_entry: Entry for QH in either the periodic or non-periodic
|
||||
|
@ -276,6 +277,7 @@ struct dwc2_qh {
|
|||
u16 start_split_frame;
|
||||
u16 ntd;
|
||||
u8 *dw_align_buf;
|
||||
int dw_align_buf_size;
|
||||
dma_addr_t dw_align_buf_dma;
|
||||
struct list_head qtd_list;
|
||||
struct dwc2_host_chan *channel;
|
||||
|
|
|
@ -465,12 +465,8 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg,
|
|||
/* Non DWORD-aligned buffer case handling */
|
||||
if (chan->align_buf && xfer_length && chan->ep_is_in) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__);
|
||||
dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
memcpy(urb->buf + urb->actual_length, chan->qh->dw_align_buf,
|
||||
xfer_length);
|
||||
dma_sync_single_for_device(hsotg->dev, urb->dma, urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
}
|
||||
|
||||
dev_vdbg(hsotg->dev, "urb->actual_length=%d xfer_length=%d\n",
|
||||
|
@ -560,14 +556,9 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
|
|||
chan->ep_is_in) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n",
|
||||
__func__);
|
||||
dma_sync_single_for_cpu(hsotg->dev, urb->dma,
|
||||
urb->length, DMA_FROM_DEVICE);
|
||||
memcpy(urb->buf + frame_desc->offset +
|
||||
qtd->isoc_split_offset, chan->qh->dw_align_buf,
|
||||
frame_desc->actual_length);
|
||||
dma_sync_single_for_device(hsotg->dev, urb->dma,
|
||||
urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
}
|
||||
break;
|
||||
case DWC2_HC_XFER_FRAME_OVERRUN:
|
||||
|
@ -594,14 +585,9 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
|
|||
chan->ep_is_in) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n",
|
||||
__func__);
|
||||
dma_sync_single_for_cpu(hsotg->dev, urb->dma,
|
||||
urb->length, DMA_FROM_DEVICE);
|
||||
memcpy(urb->buf + frame_desc->offset +
|
||||
qtd->isoc_split_offset, chan->qh->dw_align_buf,
|
||||
frame_desc->actual_length);
|
||||
dma_sync_single_for_device(hsotg->dev, urb->dma,
|
||||
urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
}
|
||||
|
||||
/* Skip whole frame */
|
||||
|
@ -937,12 +923,8 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
|
|||
|
||||
if (chan->align_buf) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__);
|
||||
dma_sync_single_for_cpu(hsotg->dev, qtd->urb->dma,
|
||||
qtd->urb->length, DMA_FROM_DEVICE);
|
||||
memcpy(qtd->urb->buf + frame_desc->offset +
|
||||
qtd->isoc_split_offset, chan->qh->dw_align_buf, len);
|
||||
dma_sync_single_for_device(hsotg->dev, qtd->urb->dma,
|
||||
qtd->urb->length, DMA_FROM_DEVICE);
|
||||
}
|
||||
|
||||
qtd->isoc_split_offset += len;
|
||||
|
@ -1170,12 +1152,8 @@ static void dwc2_update_urb_state_abn(struct dwc2_hsotg *hsotg,
|
|||
/* Non DWORD-aligned buffer case handling */
|
||||
if (chan->align_buf && xfer_length && chan->ep_is_in) {
|
||||
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__);
|
||||
dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
memcpy(urb->buf + urb->actual_length, chan->qh->dw_align_buf,
|
||||
xfer_length);
|
||||
dma_sync_single_for_device(hsotg->dev, urb->dma, urb->length,
|
||||
DMA_FROM_DEVICE);
|
||||
}
|
||||
|
||||
urb->actual_length += xfer_length;
|
||||
|
@ -1890,12 +1868,20 @@ static void dwc2_hc_chhltd_intr_dma(struct dwc2_hsotg *hsotg,
|
|||
"hcint 0x%08x, intsts 0x%08x\n",
|
||||
chan->hcint,
|
||||
readl(hsotg->regs + GINTSTS));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev_info(hsotg->dev,
|
||||
"NYET/NAK/ACK/other in non-error case, 0x%08x\n",
|
||||
chan->hcint);
|
||||
error:
|
||||
/* Failthrough: use 3-strikes rule */
|
||||
qtd->error_count++;
|
||||
dwc2_update_urb_state_abn(hsotg, chan, chnum, qtd->urb,
|
||||
qtd, DWC2_HC_XFER_XACT_ERR);
|
||||
dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd);
|
||||
dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_XACT_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,19 +229,11 @@ static struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg,
|
|||
*/
|
||||
void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
|
||||
{
|
||||
u32 buf_size;
|
||||
|
||||
if (hsotg->core_params->dma_desc_enable > 0) {
|
||||
if (hsotg->core_params->dma_desc_enable > 0)
|
||||
dwc2_hcd_qh_free_ddma(hsotg, qh);
|
||||
} else if (qh->dw_align_buf) {
|
||||
if (qh->ep_type == USB_ENDPOINT_XFER_ISOC)
|
||||
buf_size = 4096;
|
||||
else
|
||||
buf_size = hsotg->core_params->max_transfer_size;
|
||||
dma_free_coherent(hsotg->dev, buf_size, qh->dw_align_buf,
|
||||
qh->dw_align_buf_dma);
|
||||
}
|
||||
|
||||
else if (qh->dw_align_buf)
|
||||
dma_free_coherent(hsotg->dev, qh->dw_align_buf_size,
|
||||
qh->dw_align_buf, qh->dw_align_buf_dma);
|
||||
kfree(qh);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <linux/of_device.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <linux/usb/of.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "hcd.h"
|
||||
|
||||
|
@ -75,6 +77,34 @@ static const struct dwc2_core_params params_bcm2835 = {
|
|||
.uframe_sched = 0,
|
||||
};
|
||||
|
||||
static const struct dwc2_core_params params_rk3066 = {
|
||||
.otg_cap = 2, /* non-HNP/non-SRP */
|
||||
.otg_ver = -1,
|
||||
.dma_enable = -1,
|
||||
.dma_desc_enable = 0,
|
||||
.speed = -1,
|
||||
.enable_dynamic_fifo = 1,
|
||||
.en_multiple_tx_fifo = -1,
|
||||
.host_rx_fifo_size = 520, /* 520 DWORDs */
|
||||
.host_nperio_tx_fifo_size = 128, /* 128 DWORDs */
|
||||
.host_perio_tx_fifo_size = 256, /* 256 DWORDs */
|
||||
.max_transfer_size = 65535,
|
||||
.max_packet_count = -1,
|
||||
.host_channels = -1,
|
||||
.phy_type = -1,
|
||||
.phy_utmi_width = -1,
|
||||
.phy_ulpi_ddr = -1,
|
||||
.phy_ulpi_ext_vbus = -1,
|
||||
.i2c_enable = -1,
|
||||
.ulpi_fs_ls = -1,
|
||||
.host_support_fs_ls_low_power = -1,
|
||||
.host_ls_low_power_phy_clk = -1,
|
||||
.ts_dline = -1,
|
||||
.reload_ctl = -1,
|
||||
.ahbcfg = 0x7, /* INCR16 */
|
||||
.uframe_sched = -1,
|
||||
};
|
||||
|
||||
/**
|
||||
* dwc2_driver_remove() - Called when the DWC_otg core is unregistered with the
|
||||
* DWC_otg driver
|
||||
|
@ -97,6 +127,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
|
|||
|
||||
static const struct of_device_id dwc2_of_match_table[] = {
|
||||
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
|
||||
{ .compatible = "rockchip,rk3066-usb", .data = ¶ms_rk3066 },
|
||||
{ .compatible = "snps,dwc2", .data = NULL },
|
||||
{},
|
||||
};
|
||||
|
@ -171,6 +202,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
|
|||
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
|
||||
(unsigned long)res->start, hsotg->regs);
|
||||
|
||||
hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node);
|
||||
|
||||
retval = dwc2_hcd_init(hsotg, irq, params);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
|
|
@ -80,6 +80,23 @@ config USB_DWC3_KEYSTONE
|
|||
Support of USB2/3 functionality in TI Keystone2 platforms.
|
||||
Say 'Y' or 'M' here if you have one such device
|
||||
|
||||
config USB_DWC3_ST
|
||||
tristate "STMicroelectronics Platforms"
|
||||
depends on ARCH_STI && OF
|
||||
default USB_DWC3
|
||||
help
|
||||
STMicroelectronics SoCs with one DesignWare Core USB3 IP
|
||||
inside (i.e. STiH407).
|
||||
Say 'Y' or 'M' if you have one such device.
|
||||
|
||||
config USB_DWC3_QCOM
|
||||
tristate "Qualcomm Platforms"
|
||||
depends on ARCH_QCOM || COMPILE_TEST
|
||||
default USB_DWC3
|
||||
help
|
||||
Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside,
|
||||
say 'Y' or 'M' if you have one such device.
|
||||
|
||||
comment "Debugging features"
|
||||
|
||||
config USB_DWC3_DEBUG
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
# define_trace.h needs to know how to find our header
|
||||
CFLAGS_trace.o := -I$(src)
|
||||
|
||||
ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG
|
||||
ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG
|
||||
|
||||
obj-$(CONFIG_USB_DWC3) += dwc3.o
|
||||
|
||||
dwc3-y := core.o
|
||||
dwc3-y := core.o debug.o trace.o
|
||||
|
||||
ifneq ($(filter y,$(CONFIG_USB_DWC3_HOST) $(CONFIG_USB_DWC3_DUAL_ROLE)),)
|
||||
dwc3-y += host.o
|
||||
|
@ -33,3 +36,5 @@ obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o
|
|||
obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o
|
||||
obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
|
||||
obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o
|
||||
obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o
|
||||
obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
|
||||
|
|
|
@ -186,10 +186,8 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
|
|||
|
||||
dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
|
||||
GFP_KERNEL);
|
||||
if (!dwc->ev_buffs) {
|
||||
dev_err(dwc->dev, "can't allocate event buffers array\n");
|
||||
if (!dwc->ev_buffs)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
struct dwc3_event_buffer *evt;
|
||||
|
@ -639,10 +637,9 @@ static int dwc3_probe(struct platform_device *pdev)
|
|||
void *mem;
|
||||
|
||||
mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
|
||||
if (!mem) {
|
||||
dev_err(dev, "not enough memory\n");
|
||||
if (!mem)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
|
||||
dwc->mem = mem;
|
||||
dwc->dev = dev;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <linux/phy/phy.h>
|
||||
|
||||
#define DWC3_MSG_MAX 500
|
||||
|
||||
/* Global constants */
|
||||
#define DWC3_EP0_BOUNCE_SIZE 512
|
||||
#define DWC3_ENDPOINTS_NUM 32
|
||||
|
@ -938,7 +940,7 @@ int dwc3_gadget_get_link_state(struct dwc3 *dwc);
|
|||
int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state);
|
||||
int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
|
||||
unsigned cmd, struct dwc3_gadget_ep_cmd_params *params);
|
||||
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param);
|
||||
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param);
|
||||
#else
|
||||
static inline int dwc3_gadget_init(struct dwc3 *dwc)
|
||||
{ return 0; }
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* debug.c - DesignWare USB3 DRD Controller Debug/Trace Support
|
||||
*
|
||||
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
|
||||
*
|
||||
* Author: Felipe Balbi <balbi@ti.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 of
|
||||
* the License as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
|
||||
trace(&vaf);
|
||||
|
||||
va_end(args);
|
||||
}
|
|
@ -16,8 +16,206 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DWC3_DEBUG_H
|
||||
#define __DWC3_DEBUG_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
/**
|
||||
* dwc3_gadget_ep_cmd_string - returns endpoint command string
|
||||
* @cmd: command code
|
||||
*/
|
||||
static inline const char *
|
||||
dwc3_gadget_ep_cmd_string(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case DWC3_DEPCMD_DEPSTARTCFG:
|
||||
return "Start New Configuration";
|
||||
case DWC3_DEPCMD_ENDTRANSFER:
|
||||
return "End Transfer";
|
||||
case DWC3_DEPCMD_UPDATETRANSFER:
|
||||
return "Update Transfer";
|
||||
case DWC3_DEPCMD_STARTTRANSFER:
|
||||
return "Start Transfer";
|
||||
case DWC3_DEPCMD_CLEARSTALL:
|
||||
return "Clear Stall";
|
||||
case DWC3_DEPCMD_SETSTALL:
|
||||
return "Set Stall";
|
||||
case DWC3_DEPCMD_GETEPSTATE:
|
||||
return "Get Endpoint State";
|
||||
case DWC3_DEPCMD_SETTRANSFRESOURCE:
|
||||
return "Set Endpoint Transfer Resource";
|
||||
case DWC3_DEPCMD_SETEPCONFIG:
|
||||
return "Set Endpoint Configuration";
|
||||
default:
|
||||
return "UNKNOWN command";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_generic_cmd_string - returns generic command string
|
||||
* @cmd: command code
|
||||
*/
|
||||
static inline const char *
|
||||
dwc3_gadget_generic_cmd_string(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case DWC3_DGCMD_SET_LMP:
|
||||
return "Set LMP";
|
||||
case DWC3_DGCMD_SET_PERIODIC_PAR:
|
||||
return "Set Periodic Parameters";
|
||||
case DWC3_DGCMD_XMIT_FUNCTION:
|
||||
return "Transmit Function Wake Device Notification";
|
||||
case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO:
|
||||
return "Set Scratchpad Buffer Array Address Lo";
|
||||
case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI:
|
||||
return "Set Scratchpad Buffer Array Address Hi";
|
||||
case DWC3_DGCMD_SELECTED_FIFO_FLUSH:
|
||||
return "Selected FIFO Flush";
|
||||
case DWC3_DGCMD_ALL_FIFO_FLUSH:
|
||||
return "All FIFO Flush";
|
||||
case DWC3_DGCMD_SET_ENDPOINT_NRDY:
|
||||
return "Set Endpoint NRDY";
|
||||
case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK:
|
||||
return "Run SoC Bus Loopback Test";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_link_string - returns link name
|
||||
* @link_state: link state code
|
||||
*/
|
||||
static inline const char *
|
||||
dwc3_gadget_link_string(enum dwc3_link_state link_state)
|
||||
{
|
||||
switch (link_state) {
|
||||
case DWC3_LINK_STATE_U0:
|
||||
return "U0";
|
||||
case DWC3_LINK_STATE_U1:
|
||||
return "U1";
|
||||
case DWC3_LINK_STATE_U2:
|
||||
return "U2";
|
||||
case DWC3_LINK_STATE_U3:
|
||||
return "U3";
|
||||
case DWC3_LINK_STATE_SS_DIS:
|
||||
return "SS.Disabled";
|
||||
case DWC3_LINK_STATE_RX_DET:
|
||||
return "RX.Detect";
|
||||
case DWC3_LINK_STATE_SS_INACT:
|
||||
return "SS.Inactive";
|
||||
case DWC3_LINK_STATE_POLL:
|
||||
return "Polling";
|
||||
case DWC3_LINK_STATE_RECOV:
|
||||
return "Recovery";
|
||||
case DWC3_LINK_STATE_HRESET:
|
||||
return "Hot Reset";
|
||||
case DWC3_LINK_STATE_CMPLY:
|
||||
return "Compliance";
|
||||
case DWC3_LINK_STATE_LPBK:
|
||||
return "Loopback";
|
||||
case DWC3_LINK_STATE_RESET:
|
||||
return "Reset";
|
||||
case DWC3_LINK_STATE_RESUME:
|
||||
return "Resume";
|
||||
default:
|
||||
return "UNKNOWN link state\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_event_string - returns event name
|
||||
* @event: the event code
|
||||
*/
|
||||
static inline const char *dwc3_gadget_event_string(u8 event)
|
||||
{
|
||||
switch (event) {
|
||||
case DWC3_DEVICE_EVENT_DISCONNECT:
|
||||
return "Disconnect";
|
||||
case DWC3_DEVICE_EVENT_RESET:
|
||||
return "Reset";
|
||||
case DWC3_DEVICE_EVENT_CONNECT_DONE:
|
||||
return "Connection Done";
|
||||
case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
|
||||
return "Link Status Change";
|
||||
case DWC3_DEVICE_EVENT_WAKEUP:
|
||||
return "WakeUp";
|
||||
case DWC3_DEVICE_EVENT_EOPF:
|
||||
return "End-Of-Frame";
|
||||
case DWC3_DEVICE_EVENT_SOF:
|
||||
return "Start-Of-Frame";
|
||||
case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
|
||||
return "Erratic Error";
|
||||
case DWC3_DEVICE_EVENT_CMD_CMPL:
|
||||
return "Command Complete";
|
||||
case DWC3_DEVICE_EVENT_OVERFLOW:
|
||||
return "Overflow";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_ep_event_string - returns event name
|
||||
* @event: then event code
|
||||
*/
|
||||
static inline const char *dwc3_ep_event_string(u8 event)
|
||||
{
|
||||
switch (event) {
|
||||
case DWC3_DEPEVT_XFERCOMPLETE:
|
||||
return "Transfer Complete";
|
||||
case DWC3_DEPEVT_XFERINPROGRESS:
|
||||
return "Transfer In-Progress";
|
||||
case DWC3_DEPEVT_XFERNOTREADY:
|
||||
return "Transfer Not Ready";
|
||||
case DWC3_DEPEVT_RXTXFIFOEVT:
|
||||
return "FIFO";
|
||||
case DWC3_DEPEVT_STREAMEVT:
|
||||
return "Stream";
|
||||
case DWC3_DEPEVT_EPCMDCMPLT:
|
||||
return "Endpoint Command Complete";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_event_type_string - return event name
|
||||
* @event: the event code
|
||||
*/
|
||||
static inline const char *dwc3_gadget_event_type_string(u8 event)
|
||||
{
|
||||
switch (event) {
|
||||
case DWC3_DEVICE_EVENT_DISCONNECT:
|
||||
return "Disconnect";
|
||||
case DWC3_DEVICE_EVENT_RESET:
|
||||
return "Reset";
|
||||
case DWC3_DEVICE_EVENT_CONNECT_DONE:
|
||||
return "Connect Done";
|
||||
case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
|
||||
return "Link Status Change";
|
||||
case DWC3_DEVICE_EVENT_WAKEUP:
|
||||
return "Wake-Up";
|
||||
case DWC3_DEVICE_EVENT_HIBER_REQ:
|
||||
return "Hibernation";
|
||||
case DWC3_DEVICE_EVENT_EOPF:
|
||||
return "End of Periodic Frame";
|
||||
case DWC3_DEVICE_EVENT_SOF:
|
||||
return "Start of Frame";
|
||||
case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
|
||||
return "Erratic Error";
|
||||
case DWC3_DEVICE_EVENT_CMD_CMPL:
|
||||
return "Command Complete";
|
||||
case DWC3_DEVICE_EVENT_OVERFLOW:
|
||||
return "Overflow";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
extern int dwc3_debugfs_init(struct dwc3 *);
|
||||
extern void dwc3_debugfs_exit(struct dwc3 *);
|
||||
|
@ -27,4 +225,4 @@ static inline int dwc3_debugfs_init(struct dwc3 *d)
|
|||
static inline void dwc3_debugfs_exit(struct dwc3 *d)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
#endif /* __DWC3_DEBUG_H */
|
||||
|
|
|
@ -113,10 +113,8 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
|
|||
int ret;
|
||||
|
||||
exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL);
|
||||
if (!exynos) {
|
||||
dev_err(dev, "not enough memory\n");
|
||||
if (!exynos)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Right now device-tree probed devices don't get dma_mask set.
|
||||
|
|
|
@ -189,7 +189,6 @@ static struct platform_driver kdwc3_driver = {
|
|||
.remove = kdwc3_remove,
|
||||
.driver = {
|
||||
.name = "keystone-dwc3",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = kdwc3_of_match,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -481,10 +481,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
|
||||
if (!omap) {
|
||||
dev_err(dev, "not enough memory\n");
|
||||
if (!omap)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, omap);
|
||||
|
||||
|
|
|
@ -103,10 +103,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
|
|||
struct device *dev = &pci->dev;
|
||||
|
||||
glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
|
||||
if (!glue) {
|
||||
dev_err(dev, "not enough memory\n");
|
||||
if (!glue)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
glue->dev = dev;
|
||||
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
struct dwc3_qcom {
|
||||
struct device *dev;
|
||||
|
||||
struct clk *core_clk;
|
||||
struct clk *iface_clk;
|
||||
struct clk *sleep_clk;
|
||||
};
|
||||
|
||||
static int dwc3_qcom_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
struct dwc3_qcom *qdwc;
|
||||
int ret;
|
||||
|
||||
qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
|
||||
if (!qdwc)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(pdev, qdwc);
|
||||
|
||||
qdwc->dev = &pdev->dev;
|
||||
|
||||
qdwc->core_clk = devm_clk_get(qdwc->dev, "core");
|
||||
if (IS_ERR(qdwc->core_clk)) {
|
||||
dev_err(qdwc->dev, "failed to get core clock\n");
|
||||
return PTR_ERR(qdwc->core_clk);
|
||||
}
|
||||
|
||||
qdwc->iface_clk = devm_clk_get(qdwc->dev, "iface");
|
||||
if (IS_ERR(qdwc->iface_clk)) {
|
||||
dev_dbg(qdwc->dev, "failed to get optional iface clock\n");
|
||||
qdwc->iface_clk = NULL;
|
||||
}
|
||||
|
||||
qdwc->sleep_clk = devm_clk_get(qdwc->dev, "sleep");
|
||||
if (IS_ERR(qdwc->sleep_clk)) {
|
||||
dev_dbg(qdwc->dev, "failed to get optional sleep clock\n");
|
||||
qdwc->sleep_clk = NULL;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(qdwc->core_clk);
|
||||
if (ret) {
|
||||
dev_err(qdwc->dev, "failed to enable core clock\n");
|
||||
goto err_core;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(qdwc->iface_clk);
|
||||
if (ret) {
|
||||
dev_err(qdwc->dev, "failed to enable optional iface clock\n");
|
||||
goto err_iface;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(qdwc->sleep_clk);
|
||||
if (ret) {
|
||||
dev_err(qdwc->dev, "failed to enable optional sleep clock\n");
|
||||
goto err_sleep;
|
||||
}
|
||||
|
||||
ret = of_platform_populate(node, NULL, NULL, qdwc->dev);
|
||||
if (ret) {
|
||||
dev_err(qdwc->dev, "failed to register core - %d\n", ret);
|
||||
goto err_clks;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_clks:
|
||||
clk_disable_unprepare(qdwc->sleep_clk);
|
||||
err_sleep:
|
||||
clk_disable_unprepare(qdwc->iface_clk);
|
||||
err_iface:
|
||||
clk_disable_unprepare(qdwc->core_clk);
|
||||
err_core:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dwc3_qcom_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct dwc3_qcom *qdwc = platform_get_drvdata(pdev);
|
||||
|
||||
of_platform_depopulate(&pdev->dev);
|
||||
|
||||
clk_disable_unprepare(qdwc->sleep_clk);
|
||||
clk_disable_unprepare(qdwc->iface_clk);
|
||||
clk_disable_unprepare(qdwc->core_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id of_dwc3_match[] = {
|
||||
{ .compatible = "qcom,dwc3" },
|
||||
{ /* Sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, of_dwc3_match);
|
||||
|
||||
static struct platform_driver dwc3_qcom_driver = {
|
||||
.probe = dwc3_qcom_probe,
|
||||
.remove = dwc3_qcom_remove,
|
||||
.driver = {
|
||||
.name = "qcom-dwc3",
|
||||
.of_match_table = of_dwc3_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(dwc3_qcom_driver);
|
||||
|
||||
MODULE_ALIAS("platform:qcom-dwc3");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("DesignWare USB3 QCOM Glue Layer");
|
||||
MODULE_AUTHOR("Ivan T. Ivanov <iivanov@mm-sol.com>");
|
|
@ -0,0 +1,367 @@
|
|||
/**
|
||||
* dwc3-st.c Support for dwc3 platform devices on ST Microelectronics platforms
|
||||
*
|
||||
* This is a small driver for the dwc3 to provide the glue logic
|
||||
* to configure the controller. Tested on STi platforms.
|
||||
*
|
||||
* Copyright (C) 2014 Stmicroelectronics
|
||||
*
|
||||
* Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
|
||||
* Contributors: Aymen Bouattay <aymen.bouattay@st.com>
|
||||
* Peter Griffin <peter.griffin@linaro.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Inspired by dwc3-omap.c and dwc3-exynos.c.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/usb/of.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "io.h"
|
||||
|
||||
/* glue registers */
|
||||
#define CLKRST_CTRL 0x00
|
||||
#define AUX_CLK_EN BIT(0)
|
||||
#define SW_PIPEW_RESET_N BIT(4)
|
||||
#define EXT_CFG_RESET_N BIT(8)
|
||||
/*
|
||||
* 1'b0 : The host controller complies with the xHCI revision 0.96
|
||||
* 1'b1 : The host controller complies with the xHCI revision 1.0
|
||||
*/
|
||||
#define XHCI_REVISION BIT(12)
|
||||
|
||||
#define USB2_VBUS_MNGMNT_SEL1 0x2C
|
||||
/*
|
||||
* For all fields in USB2_VBUS_MNGMNT_SEL1
|
||||
* 2’b00 : Override value from Reg 0x30 is selected
|
||||
* 2’b01 : utmiotg_<signal_name> from usb3_top is selected
|
||||
* 2’b10 : pipew_<signal_name> from PIPEW instance is selected
|
||||
* 2’b11 : value is 1'b0
|
||||
*/
|
||||
#define USB2_VBUS_REG30 0x0
|
||||
#define USB2_VBUS_UTMIOTG 0x1
|
||||
#define USB2_VBUS_PIPEW 0x2
|
||||
#define USB2_VBUS_ZERO 0x3
|
||||
|
||||
#define SEL_OVERRIDE_VBUSVALID(n) (n << 0)
|
||||
#define SEL_OVERRIDE_POWERPRESENT(n) (n << 4)
|
||||
#define SEL_OVERRIDE_BVALID(n) (n << 8)
|
||||
|
||||
/* Static DRD configuration */
|
||||
#define USB3_CONTROL_MASK 0xf77
|
||||
|
||||
#define USB3_DEVICE_NOT_HOST BIT(0)
|
||||
#define USB3_FORCE_VBUSVALID BIT(1)
|
||||
#define USB3_DELAY_VBUSVALID BIT(2)
|
||||
#define USB3_SEL_FORCE_OPMODE BIT(4)
|
||||
#define USB3_FORCE_OPMODE(n) (n << 5)
|
||||
#define USB3_SEL_FORCE_DPPULLDOWN2 BIT(8)
|
||||
#define USB3_FORCE_DPPULLDOWN2 BIT(9)
|
||||
#define USB3_SEL_FORCE_DMPULLDOWN2 BIT(10)
|
||||
#define USB3_FORCE_DMPULLDOWN2 BIT(11)
|
||||
|
||||
/**
|
||||
* struct st_dwc3 - dwc3-st driver private structure
|
||||
* @dev: device pointer
|
||||
* @glue_base: ioaddr for the glue registers
|
||||
* @regmap: regmap pointer for getting syscfg
|
||||
* @syscfg_reg_off: usb syscfg control offset
|
||||
* @dr_mode: drd static host/device config
|
||||
* @rstc_pwrdn: rest controller for powerdown signal
|
||||
* @rstc_rst: reset controller for softreset signal
|
||||
*/
|
||||
|
||||
struct st_dwc3 {
|
||||
struct device *dev;
|
||||
void __iomem *glue_base;
|
||||
struct regmap *regmap;
|
||||
int syscfg_reg_off;
|
||||
enum usb_dr_mode dr_mode;
|
||||
struct reset_control *rstc_pwrdn;
|
||||
struct reset_control *rstc_rst;
|
||||
};
|
||||
|
||||
static inline u32 st_dwc3_readl(void __iomem *base, u32 offset)
|
||||
{
|
||||
return readl_relaxed(base + offset);
|
||||
}
|
||||
|
||||
static inline void st_dwc3_writel(void __iomem *base, u32 offset, u32 value)
|
||||
{
|
||||
writel_relaxed(value, base + offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_dwc3_drd_init: program the port
|
||||
* @dwc3_data: driver private structure
|
||||
* Description: this function is to program the port as either host or device
|
||||
* according to the static configuration passed from devicetree.
|
||||
* OTG and dual role are not yet supported!
|
||||
*/
|
||||
static int st_dwc3_drd_init(struct st_dwc3 *dwc3_data)
|
||||
{
|
||||
u32 val;
|
||||
int err;
|
||||
|
||||
err = regmap_read(dwc3_data->regmap, dwc3_data->syscfg_reg_off, &val);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
val &= USB3_CONTROL_MASK;
|
||||
|
||||
switch (dwc3_data->dr_mode) {
|
||||
case USB_DR_MODE_PERIPHERAL:
|
||||
|
||||
val &= ~(USB3_FORCE_VBUSVALID | USB3_DELAY_VBUSVALID
|
||||
| USB3_SEL_FORCE_OPMODE | USB3_FORCE_OPMODE(0x3)
|
||||
| USB3_SEL_FORCE_DPPULLDOWN2 | USB3_FORCE_DPPULLDOWN2
|
||||
| USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2);
|
||||
|
||||
val |= USB3_DEVICE_NOT_HOST;
|
||||
|
||||
dev_dbg(dwc3_data->dev, "Configuring as Device\n");
|
||||
break;
|
||||
|
||||
case USB_DR_MODE_HOST:
|
||||
|
||||
val &= ~(USB3_DEVICE_NOT_HOST | USB3_FORCE_VBUSVALID
|
||||
| USB3_SEL_FORCE_OPMODE | USB3_FORCE_OPMODE(0x3)
|
||||
| USB3_SEL_FORCE_DPPULLDOWN2 | USB3_FORCE_DPPULLDOWN2
|
||||
| USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2);
|
||||
|
||||
/*
|
||||
* USB3_DELAY_VBUSVALID is ANDed with USB_C_VBUSVALID. Thus,
|
||||
* when set to ‘0‘, it can delay the arrival of VBUSVALID
|
||||
* information to VBUSVLDEXT2 input of the pico PHY.
|
||||
* We don't want to do that so we set the bit to '1'.
|
||||
*/
|
||||
|
||||
val |= USB3_DELAY_VBUSVALID;
|
||||
|
||||
dev_dbg(dwc3_data->dev, "Configuring as Host\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(dwc3_data->dev, "Unsupported mode of operation %d\n",
|
||||
dwc3_data->dr_mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return regmap_write(dwc3_data->regmap, dwc3_data->syscfg_reg_off, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_dwc3_init: init the controller via glue logic
|
||||
* @dwc3_data: driver private structure
|
||||
*/
|
||||
static void st_dwc3_init(struct st_dwc3 *dwc3_data)
|
||||
{
|
||||
u32 reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL);
|
||||
|
||||
reg |= AUX_CLK_EN | EXT_CFG_RESET_N | XHCI_REVISION;
|
||||
reg &= ~SW_PIPEW_RESET_N;
|
||||
st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg);
|
||||
|
||||
/* configure mux for vbus, powerpresent and bvalid signals */
|
||||
reg = st_dwc3_readl(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1);
|
||||
|
||||
reg |= SEL_OVERRIDE_VBUSVALID(USB2_VBUS_UTMIOTG) |
|
||||
SEL_OVERRIDE_POWERPRESENT(USB2_VBUS_UTMIOTG) |
|
||||
SEL_OVERRIDE_BVALID(USB2_VBUS_UTMIOTG);
|
||||
|
||||
st_dwc3_writel(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1, reg);
|
||||
|
||||
reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL);
|
||||
reg |= SW_PIPEW_RESET_N;
|
||||
st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg);
|
||||
}
|
||||
|
||||
static int st_dwc3_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct st_dwc3 *dwc3_data;
|
||||
struct resource *res;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *node = dev->of_node, *child;
|
||||
struct regmap *regmap;
|
||||
int ret;
|
||||
|
||||
dwc3_data = devm_kzalloc(dev, sizeof(*dwc3_data), GFP_KERNEL);
|
||||
if (!dwc3_data)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg-glue");
|
||||
dwc3_data->glue_base = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(dwc3_data->glue_base))
|
||||
return PTR_ERR(dwc3_data->glue_base);
|
||||
|
||||
regmap = syscon_regmap_lookup_by_phandle(node, "st,syscfg");
|
||||
if (IS_ERR(regmap))
|
||||
return PTR_ERR(regmap);
|
||||
|
||||
dma_set_coherent_mask(dev, dev->coherent_dma_mask);
|
||||
dwc3_data->dev = dev;
|
||||
dwc3_data->regmap = regmap;
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "syscfg-reg");
|
||||
if (!res) {
|
||||
ret = -ENXIO;
|
||||
goto undo_platform_dev_alloc;
|
||||
}
|
||||
|
||||
dwc3_data->syscfg_reg_off = res->start;
|
||||
|
||||
dev_vdbg(&pdev->dev, "glue-logic addr 0x%p, syscfg-reg offset 0x%x\n",
|
||||
dwc3_data->glue_base, dwc3_data->syscfg_reg_off);
|
||||
|
||||
dwc3_data->rstc_pwrdn = devm_reset_control_get(dev, "powerdown");
|
||||
if (IS_ERR(dwc3_data->rstc_pwrdn)) {
|
||||
dev_err(&pdev->dev, "could not get power controller\n");
|
||||
ret = PTR_ERR(dwc3_data->rstc_pwrdn);
|
||||
goto undo_platform_dev_alloc;
|
||||
}
|
||||
|
||||
/* Manage PowerDown */
|
||||
reset_control_deassert(dwc3_data->rstc_pwrdn);
|
||||
|
||||
dwc3_data->rstc_rst = devm_reset_control_get(dev, "softreset");
|
||||
if (IS_ERR(dwc3_data->rstc_rst)) {
|
||||
dev_err(&pdev->dev, "could not get reset controller\n");
|
||||
ret = PTR_ERR(dwc3_data->rstc_pwrdn);
|
||||
goto undo_powerdown;
|
||||
}
|
||||
|
||||
/* Manage SoftReset */
|
||||
reset_control_deassert(dwc3_data->rstc_rst);
|
||||
|
||||
child = of_get_child_by_name(node, "dwc3");
|
||||
if (!child) {
|
||||
dev_err(&pdev->dev, "failed to find dwc3 core node\n");
|
||||
ret = -ENODEV;
|
||||
goto undo_softreset;
|
||||
}
|
||||
|
||||
dwc3_data->dr_mode = of_usb_get_dr_mode(child);
|
||||
|
||||
/* Allocate and initialize the core */
|
||||
ret = of_platform_populate(node, NULL, NULL, dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to add dwc3 core\n");
|
||||
goto undo_softreset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Configure the USB port as device or host according to the static
|
||||
* configuration passed from DT.
|
||||
* DRD is the only mode currently supported so this will be enhanced
|
||||
* as soon as OTG is available.
|
||||
*/
|
||||
ret = st_dwc3_drd_init(dwc3_data);
|
||||
if (ret) {
|
||||
dev_err(dev, "drd initialisation failed\n");
|
||||
goto undo_softreset;
|
||||
}
|
||||
|
||||
/* ST glue logic init */
|
||||
st_dwc3_init(dwc3_data);
|
||||
|
||||
platform_set_drvdata(pdev, dwc3_data);
|
||||
return 0;
|
||||
|
||||
undo_softreset:
|
||||
reset_control_assert(dwc3_data->rstc_rst);
|
||||
undo_powerdown:
|
||||
reset_control_assert(dwc3_data->rstc_pwrdn);
|
||||
undo_platform_dev_alloc:
|
||||
platform_device_put(pdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int st_dwc3_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct st_dwc3 *dwc3_data = platform_get_drvdata(pdev);
|
||||
|
||||
of_platform_depopulate(&pdev->dev);
|
||||
|
||||
reset_control_assert(dwc3_data->rstc_pwrdn);
|
||||
reset_control_assert(dwc3_data->rstc_rst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int st_dwc3_suspend(struct device *dev)
|
||||
{
|
||||
struct st_dwc3 *dwc3_data = dev_get_drvdata(dev);
|
||||
|
||||
reset_control_assert(dwc3_data->rstc_pwrdn);
|
||||
reset_control_assert(dwc3_data->rstc_rst);
|
||||
|
||||
pinctrl_pm_select_sleep_state(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int st_dwc3_resume(struct device *dev)
|
||||
{
|
||||
struct st_dwc3 *dwc3_data = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
pinctrl_pm_select_default_state(dev);
|
||||
|
||||
reset_control_deassert(dwc3_data->rstc_pwrdn);
|
||||
reset_control_deassert(dwc3_data->rstc_rst);
|
||||
|
||||
ret = st_dwc3_drd_init(dwc3_data);
|
||||
if (ret) {
|
||||
dev_err(dev, "drd initialisation failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ST glue logic init */
|
||||
st_dwc3_init(dwc3_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(st_dwc3_dev_pm_ops, st_dwc3_suspend, st_dwc3_resume);
|
||||
|
||||
static const struct of_device_id st_dwc3_match[] = {
|
||||
{ .compatible = "st,stih407-dwc3" },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, st_dwc3_match);
|
||||
|
||||
static struct platform_driver st_dwc3_driver = {
|
||||
.probe = st_dwc3_probe,
|
||||
.remove = st_dwc3_remove,
|
||||
.driver = {
|
||||
.name = "usb-st-dwc3",
|
||||
.of_match_table = st_dwc3_match,
|
||||
.pm = &st_dwc3_dev_pm_ops,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(st_dwc3_driver);
|
||||
|
||||
MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
|
||||
MODULE_DESCRIPTION("DesignWare USB3 STi Glue Layer");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -31,6 +31,7 @@
|
|||
#include <linux/usb/composite.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "debug.h"
|
||||
#include "gadget.h"
|
||||
#include "io.h"
|
||||
|
||||
|
@ -65,7 +66,7 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
|
|||
|
||||
dep = dwc->eps[epnum];
|
||||
if (dep->flags & DWC3_EP_BUSY) {
|
||||
dev_vdbg(dwc->dev, "%s: still busy\n", dep->name);
|
||||
dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -88,7 +89,8 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
|
|||
ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
|
||||
DWC3_DEPCMD_STARTTRANSFER, ¶ms);
|
||||
if (ret < 0) {
|
||||
dev_dbg(dwc->dev, "failed to send STARTTRANSFER command\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "%s STARTTRANSFER failed",
|
||||
dep->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -153,7 +155,8 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
|
|||
if (dwc->ep0state == EP0_STATUS_PHASE)
|
||||
__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
|
||||
else
|
||||
dev_dbg(dwc->dev, "too early for delayed status\n");
|
||||
dwc3_trace(trace_dwc3_ep0,
|
||||
"too early for delayed status");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -217,7 +220,8 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
|
|||
|
||||
spin_lock_irqsave(&dwc->lock, flags);
|
||||
if (!dep->endpoint.desc) {
|
||||
dev_dbg(dwc->dev, "trying to queue request %p to disabled %s\n",
|
||||
dwc3_trace(trace_dwc3_ep0,
|
||||
"trying to queue request %p to disabled %s",
|
||||
request, dep->name);
|
||||
ret = -ESHUTDOWN;
|
||||
goto out;
|
||||
|
@ -229,7 +233,8 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
|
|||
goto out;
|
||||
}
|
||||
|
||||
dev_vdbg(dwc->dev, "queueing request %p to %s length %d, state '%s'\n",
|
||||
dwc3_trace(trace_dwc3_ep0,
|
||||
"queueing request %p to %s length %d state '%s'",
|
||||
request, dep->name, request->length,
|
||||
dwc3_ep0_state_string(dwc->ep0state));
|
||||
|
||||
|
@ -485,12 +490,13 @@ static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
|
|||
|
||||
addr = le16_to_cpu(ctrl->wValue);
|
||||
if (addr > 127) {
|
||||
dev_dbg(dwc->dev, "invalid device address %d\n", addr);
|
||||
dwc3_trace(trace_dwc3_ep0, "invalid device address %d", addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (state == USB_STATE_CONFIGURED) {
|
||||
dev_dbg(dwc->dev, "trying to set address when configured\n");
|
||||
dwc3_trace(trace_dwc3_ep0,
|
||||
"trying to set address when configured");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -556,7 +562,7 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
|
|||
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
||||
|
||||
dwc->resize_fifos = true;
|
||||
dev_dbg(dwc->dev, "resize fifos flag SET\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -680,35 +686,35 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
|
|||
|
||||
switch (ctrl->bRequest) {
|
||||
case USB_REQ_GET_STATUS:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_GET_STATUS\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_GET_STATUS\n");
|
||||
ret = dwc3_ep0_handle_status(dwc, ctrl);
|
||||
break;
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_CLEAR_FEATURE\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_CLEAR_FEATURE\n");
|
||||
ret = dwc3_ep0_handle_feature(dwc, ctrl, 0);
|
||||
break;
|
||||
case USB_REQ_SET_FEATURE:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_SET_FEATURE\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_FEATURE\n");
|
||||
ret = dwc3_ep0_handle_feature(dwc, ctrl, 1);
|
||||
break;
|
||||
case USB_REQ_SET_ADDRESS:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_SET_ADDRESS\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_ADDRESS\n");
|
||||
ret = dwc3_ep0_set_address(dwc, ctrl);
|
||||
break;
|
||||
case USB_REQ_SET_CONFIGURATION:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_SET_CONFIGURATION\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_CONFIGURATION\n");
|
||||
ret = dwc3_ep0_set_config(dwc, ctrl);
|
||||
break;
|
||||
case USB_REQ_SET_SEL:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_SET_SEL\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_SEL\n");
|
||||
ret = dwc3_ep0_set_sel(dwc, ctrl);
|
||||
break;
|
||||
case USB_REQ_SET_ISOCH_DELAY:
|
||||
dev_vdbg(dwc->dev, "USB_REQ_SET_ISOCH_DELAY\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_ISOCH_DELAY\n");
|
||||
ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
|
||||
break;
|
||||
default:
|
||||
dev_vdbg(dwc->dev, "Forwarding to gadget driver\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Forwarding to gadget driver\n");
|
||||
ret = dwc3_ep0_delegate_req(dwc, ctrl);
|
||||
break;
|
||||
}
|
||||
|
@ -726,6 +732,8 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc,
|
|||
if (!dwc->gadget_driver)
|
||||
goto out;
|
||||
|
||||
trace_dwc3_ctrl_req(ctrl);
|
||||
|
||||
len = le16_to_cpu(ctrl->wLength);
|
||||
if (!len) {
|
||||
dwc->three_stage_setup = false;
|
||||
|
@ -774,7 +782,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
|
|||
|
||||
status = DWC3_TRB_SIZE_TRBSTS(trb->size);
|
||||
if (status == DWC3_TRBSTS_SETUP_PENDING) {
|
||||
dev_dbg(dwc->dev, "Setup Pending received\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Setup Pending received");
|
||||
|
||||
if (r)
|
||||
dwc3_gadget_giveback(ep0, r, -ECONNRESET);
|
||||
|
@ -834,7 +842,7 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc,
|
|||
|
||||
ret = dwc3_gadget_set_test_mode(dwc, dwc->test_mode_nr);
|
||||
if (ret < 0) {
|
||||
dev_dbg(dwc->dev, "Invalid Test #%d\n",
|
||||
dwc3_trace(trace_dwc3_ep0, "Invalid Test #%d",
|
||||
dwc->test_mode_nr);
|
||||
dwc3_ep0_stall_and_restart(dwc);
|
||||
return;
|
||||
|
@ -843,7 +851,7 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc,
|
|||
|
||||
status = DWC3_TRB_SIZE_TRBSTS(trb->size);
|
||||
if (status == DWC3_TRBSTS_SETUP_PENDING)
|
||||
dev_dbg(dwc->dev, "Setup Pending received\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Setup Pending received\n");
|
||||
|
||||
dwc->ep0state = EP0_SETUP_PHASE;
|
||||
dwc3_ep0_out_start(dwc);
|
||||
|
@ -860,17 +868,17 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc,
|
|||
|
||||
switch (dwc->ep0state) {
|
||||
case EP0_SETUP_PHASE:
|
||||
dev_vdbg(dwc->dev, "Inspecting Setup Bytes\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Setup Phase");
|
||||
dwc3_ep0_inspect_setup(dwc, event);
|
||||
break;
|
||||
|
||||
case EP0_DATA_PHASE:
|
||||
dev_vdbg(dwc->dev, "Data Phase\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Data Phase");
|
||||
dwc3_ep0_complete_data(dwc, event);
|
||||
break;
|
||||
|
||||
case EP0_STATUS_PHASE:
|
||||
dev_vdbg(dwc->dev, "Status Phase\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Status Phase");
|
||||
dwc3_ep0_complete_status(dwc, event);
|
||||
break;
|
||||
default:
|
||||
|
@ -946,7 +954,7 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
|
|||
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
|
||||
{
|
||||
if (dwc->resize_fifos) {
|
||||
dev_dbg(dwc->dev, "starting to resize fifos\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs");
|
||||
dwc3_gadget_resize_tx_fifos(dwc);
|
||||
dwc->resize_fifos = 0;
|
||||
}
|
||||
|
@ -987,7 +995,7 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
|
|||
|
||||
switch (event->status) {
|
||||
case DEPEVT_STATUS_CONTROL_DATA:
|
||||
dev_vdbg(dwc->dev, "Control Data\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Control Data");
|
||||
|
||||
/*
|
||||
* We already have a DATA transfer in the controller's cache,
|
||||
|
@ -1001,7 +1009,8 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
|
|||
if (dwc->ep0_expect_in != event->endpoint_number) {
|
||||
struct dwc3_ep *dep = dwc->eps[dwc->ep0_expect_in];
|
||||
|
||||
dev_vdbg(dwc->dev, "Wrong direction for Data phase\n");
|
||||
dwc3_trace(trace_dwc3_ep0,
|
||||
"Wrong direction for Data phase");
|
||||
dwc3_ep0_end_control_data(dwc, dep);
|
||||
dwc3_ep0_stall_and_restart(dwc);
|
||||
return;
|
||||
|
@ -1013,13 +1022,13 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
|
|||
if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS)
|
||||
return;
|
||||
|
||||
dev_vdbg(dwc->dev, "Control Status\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Control Status");
|
||||
|
||||
dwc->ep0state = EP0_STATUS_PHASE;
|
||||
|
||||
if (dwc->delayed_status) {
|
||||
WARN_ON_ONCE(event->endpoint_number != 1);
|
||||
dev_vdbg(dwc->dev, "Mass Storage delayed status\n");
|
||||
dwc3_trace(trace_dwc3_ep0, "Delayed Status");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1041,7 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
|
|||
{
|
||||
u8 epnum = event->endpoint_number;
|
||||
|
||||
dev_dbg(dwc->dev, "%s while ep%d%s in state '%s'\n",
|
||||
dwc3_trace(trace_dwc3_ep0, "%s while ep%d%s in state '%s'",
|
||||
dwc3_ep_event_string(event->endpoint_event),
|
||||
epnum >> 1, (epnum & 1) ? "in" : "out",
|
||||
dwc3_ep0_state_string(dwc->ep0state));
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <linux/usb/ch9.h>
|
||||
#include <linux/usb/gadget.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "core.h"
|
||||
#include "gadget.h"
|
||||
#include "io.h"
|
||||
|
@ -266,107 +267,19 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
|
|||
dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n",
|
||||
req, dep->name, req->request.actual,
|
||||
req->request.length, status);
|
||||
trace_dwc3_gadget_giveback(req);
|
||||
|
||||
spin_unlock(&dwc->lock);
|
||||
req->request.complete(&dep->endpoint, &req->request);
|
||||
usb_gadget_giveback_request(&dep->endpoint, &req->request);
|
||||
spin_lock(&dwc->lock);
|
||||
}
|
||||
|
||||
static const char *dwc3_gadget_ep_cmd_string(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case DWC3_DEPCMD_DEPSTARTCFG:
|
||||
return "Start New Configuration";
|
||||
case DWC3_DEPCMD_ENDTRANSFER:
|
||||
return "End Transfer";
|
||||
case DWC3_DEPCMD_UPDATETRANSFER:
|
||||
return "Update Transfer";
|
||||
case DWC3_DEPCMD_STARTTRANSFER:
|
||||
return "Start Transfer";
|
||||
case DWC3_DEPCMD_CLEARSTALL:
|
||||
return "Clear Stall";
|
||||
case DWC3_DEPCMD_SETSTALL:
|
||||
return "Set Stall";
|
||||
case DWC3_DEPCMD_GETEPSTATE:
|
||||
return "Get Endpoint State";
|
||||
case DWC3_DEPCMD_SETTRANSFRESOURCE:
|
||||
return "Set Endpoint Transfer Resource";
|
||||
case DWC3_DEPCMD_SETEPCONFIG:
|
||||
return "Set Endpoint Configuration";
|
||||
default:
|
||||
return "UNKNOWN command";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *dwc3_gadget_generic_cmd_string(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case DWC3_DGCMD_SET_LMP:
|
||||
return "Set LMP";
|
||||
case DWC3_DGCMD_SET_PERIODIC_PAR:
|
||||
return "Set Periodic Parameters";
|
||||
case DWC3_DGCMD_XMIT_FUNCTION:
|
||||
return "Transmit Function Wake Device Notification";
|
||||
case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO:
|
||||
return "Set Scratchpad Buffer Array Address Lo";
|
||||
case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI:
|
||||
return "Set Scratchpad Buffer Array Address Hi";
|
||||
case DWC3_DGCMD_SELECTED_FIFO_FLUSH:
|
||||
return "Selected FIFO Flush";
|
||||
case DWC3_DGCMD_ALL_FIFO_FLUSH:
|
||||
return "All FIFO Flush";
|
||||
case DWC3_DGCMD_SET_ENDPOINT_NRDY:
|
||||
return "Set Endpoint NRDY";
|
||||
case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK:
|
||||
return "Run SoC Bus Loopback Test";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state)
|
||||
{
|
||||
switch (link_state) {
|
||||
case DWC3_LINK_STATE_U0:
|
||||
return "U0";
|
||||
case DWC3_LINK_STATE_U1:
|
||||
return "U1";
|
||||
case DWC3_LINK_STATE_U2:
|
||||
return "U2";
|
||||
case DWC3_LINK_STATE_U3:
|
||||
return "U3";
|
||||
case DWC3_LINK_STATE_SS_DIS:
|
||||
return "SS.Disabled";
|
||||
case DWC3_LINK_STATE_RX_DET:
|
||||
return "RX.Detect";
|
||||
case DWC3_LINK_STATE_SS_INACT:
|
||||
return "SS.Inactive";
|
||||
case DWC3_LINK_STATE_POLL:
|
||||
return "Polling";
|
||||
case DWC3_LINK_STATE_RECOV:
|
||||
return "Recovery";
|
||||
case DWC3_LINK_STATE_HRESET:
|
||||
return "Hot Reset";
|
||||
case DWC3_LINK_STATE_CMPLY:
|
||||
return "Compliance";
|
||||
case DWC3_LINK_STATE_LPBK:
|
||||
return "Loopback";
|
||||
case DWC3_LINK_STATE_RESET:
|
||||
return "Reset";
|
||||
case DWC3_LINK_STATE_RESUME:
|
||||
return "Resume";
|
||||
default:
|
||||
return "UNKNOWN link state\n";
|
||||
}
|
||||
}
|
||||
|
||||
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param)
|
||||
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
|
||||
{
|
||||
u32 timeout = 500;
|
||||
u32 reg;
|
||||
|
||||
dev_vdbg(dwc->dev, "generic cmd '%s' [%d] param %08x\n",
|
||||
dwc3_gadget_generic_cmd_string(cmd), cmd, param);
|
||||
trace_dwc3_gadget_generic_cmd(cmd, param);
|
||||
|
||||
dwc3_writel(dwc->regs, DWC3_DGCMDPAR, param);
|
||||
dwc3_writel(dwc->regs, DWC3_DGCMD, cmd | DWC3_DGCMD_CMDACT);
|
||||
|
@ -397,10 +310,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
|
|||
u32 timeout = 500;
|
||||
u32 reg;
|
||||
|
||||
dev_vdbg(dwc->dev, "%s: cmd '%s' [%d] params %08x %08x %08x\n",
|
||||
dep->name,
|
||||
dwc3_gadget_ep_cmd_string(cmd), cmd, params->param0,
|
||||
params->param1, params->param2);
|
||||
trace_dwc3_gadget_ep_cmd(dep, cmd, params);
|
||||
|
||||
dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(ep), params->param0);
|
||||
dwc3_writel(dwc->regs, DWC3_DEPCMDPAR1(ep), params->param1);
|
||||
|
@ -789,17 +699,16 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep,
|
|||
{
|
||||
struct dwc3_request *req;
|
||||
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
||||
struct dwc3 *dwc = dep->dwc;
|
||||
|
||||
req = kzalloc(sizeof(*req), gfp_flags);
|
||||
if (!req) {
|
||||
dev_err(dwc->dev, "not enough memory\n");
|
||||
if (!req)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
req->epnum = dep->number;
|
||||
req->dep = dep;
|
||||
|
||||
trace_dwc3_alloc_request(req);
|
||||
|
||||
return &req->request;
|
||||
}
|
||||
|
||||
|
@ -808,6 +717,7 @@ static void dwc3_gadget_ep_free_request(struct usb_ep *ep,
|
|||
{
|
||||
struct dwc3_request *req = to_dwc3_request(request);
|
||||
|
||||
trace_dwc3_free_request(req);
|
||||
kfree(req);
|
||||
}
|
||||
|
||||
|
@ -889,6 +799,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
|
|||
trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(req->request.stream_id);
|
||||
|
||||
trb->ctrl |= DWC3_TRB_CTRL_HWO;
|
||||
|
||||
trace_dwc3_prepare_trb(dep, trb);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1235,6 +1147,7 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
|
|||
|
||||
dev_vdbg(dwc->dev, "queing request %p to %s length %d\n",
|
||||
request, ep->name, request->length);
|
||||
trace_dwc3_ep_queue(req);
|
||||
|
||||
ret = __dwc3_gadget_ep_queue(dep, req);
|
||||
spin_unlock_irqrestore(&dwc->lock, flags);
|
||||
|
@ -1254,6 +1167,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
|
|||
unsigned long flags;
|
||||
int ret = 0;
|
||||
|
||||
trace_dwc3_ep_dequeue(req);
|
||||
|
||||
spin_lock_irqsave(&dwc->lock, flags);
|
||||
|
||||
list_for_each_entry(r, &dep->request_list, list) {
|
||||
|
@ -1744,11 +1659,8 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
|
|||
u8 epnum = (i << 1) | (!!direction);
|
||||
|
||||
dep = kzalloc(sizeof(*dep), GFP_KERNEL);
|
||||
if (!dep) {
|
||||
dev_err(dwc->dev, "can't allocate endpoint %d\n",
|
||||
epnum);
|
||||
if (!dep)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dep->dwc = dwc;
|
||||
dep->number = epnum;
|
||||
|
@ -1847,6 +1759,8 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
|
|||
unsigned int s_pkt = 0;
|
||||
unsigned int trb_status;
|
||||
|
||||
trace_dwc3_complete_trb(dep, trb);
|
||||
|
||||
if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
|
||||
/*
|
||||
* We continue despite the error. There is not much we
|
||||
|
@ -2021,9 +1935,6 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
|
|||
if (!(dep->flags & DWC3_EP_ENABLED))
|
||||
return;
|
||||
|
||||
dev_vdbg(dwc->dev, "%s: %s\n", dep->name,
|
||||
dwc3_ep_event_string(event->endpoint_event));
|
||||
|
||||
if (epnum == 0 || epnum == 1) {
|
||||
dwc3_ep0_interrupt(dwc, event);
|
||||
return;
|
||||
|
@ -2210,8 +2121,6 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
|
|||
{
|
||||
int reg;
|
||||
|
||||
dev_vdbg(dwc->dev, "%s\n", __func__);
|
||||
|
||||
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
||||
reg &= ~DWC3_DCTL_INITU1ENA;
|
||||
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
||||
|
@ -2230,8 +2139,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
|
|||
{
|
||||
u32 reg;
|
||||
|
||||
dev_vdbg(dwc->dev, "%s\n", __func__);
|
||||
|
||||
/*
|
||||
* WORKAROUND: DWC3 revisions <1.88a have an issue which
|
||||
* would cause a missing Disconnect Event if there's a
|
||||
|
@ -2316,8 +2223,6 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
|
|||
u32 reg;
|
||||
u8 speed;
|
||||
|
||||
dev_vdbg(dwc->dev, "%s\n", __func__);
|
||||
|
||||
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
||||
speed = reg & DWC3_DSTS_CONNECTSPD;
|
||||
dwc->speed = speed;
|
||||
|
@ -2415,8 +2320,6 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
|
|||
|
||||
static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc)
|
||||
{
|
||||
dev_vdbg(dwc->dev, "%s\n", __func__);
|
||||
|
||||
/*
|
||||
* TODO take core out of low power mode when that's
|
||||
* implemented.
|
||||
|
@ -2521,10 +2424,6 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
|
|||
break;
|
||||
}
|
||||
|
||||
dev_vdbg(dwc->dev, "link change: %s [%d] -> %s [%d]\n",
|
||||
dwc3_gadget_link_string(dwc->link_state),
|
||||
dwc->link_state, dwc3_gadget_link_string(next), next);
|
||||
|
||||
dwc->link_state = next;
|
||||
}
|
||||
|
||||
|
@ -2601,6 +2500,8 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
|
|||
static void dwc3_process_event_entry(struct dwc3 *dwc,
|
||||
const union dwc3_event *event)
|
||||
{
|
||||
trace_dwc3_event(event->raw);
|
||||
|
||||
/* Endpoint IRQ, handle it and return early */
|
||||
if (event->type.is_devspec == 0) {
|
||||
/* depevt */
|
||||
|
@ -2754,7 +2655,6 @@ int dwc3_gadget_init(struct dwc3 *dwc)
|
|||
|
||||
dwc->setup_buf = kzalloc(DWC3_EP0_BOUNCE_SIZE, GFP_KERNEL);
|
||||
if (!dwc->setup_buf) {
|
||||
dev_err(dwc->dev, "failed to allocate setup buffer\n");
|
||||
ret = -ENOMEM;
|
||||
goto err2;
|
||||
}
|
||||
|
|
|
@ -103,60 +103,4 @@ static inline u32 dwc3_gadget_ep_get_transfer_index(struct dwc3 *dwc, u8 number)
|
|||
return DWC3_DEPCMD_GET_RSC_IDX(res_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_event_string - returns event name
|
||||
* @event: the event code
|
||||
*/
|
||||
static inline const char *dwc3_gadget_event_string(u8 event)
|
||||
{
|
||||
switch (event) {
|
||||
case DWC3_DEVICE_EVENT_DISCONNECT:
|
||||
return "Disconnect";
|
||||
case DWC3_DEVICE_EVENT_RESET:
|
||||
return "Reset";
|
||||
case DWC3_DEVICE_EVENT_CONNECT_DONE:
|
||||
return "Connection Done";
|
||||
case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
|
||||
return "Link Status Change";
|
||||
case DWC3_DEVICE_EVENT_WAKEUP:
|
||||
return "WakeUp";
|
||||
case DWC3_DEVICE_EVENT_EOPF:
|
||||
return "End-Of-Frame";
|
||||
case DWC3_DEVICE_EVENT_SOF:
|
||||
return "Start-Of-Frame";
|
||||
case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
|
||||
return "Erratic Error";
|
||||
case DWC3_DEVICE_EVENT_CMD_CMPL:
|
||||
return "Command Complete";
|
||||
case DWC3_DEVICE_EVENT_OVERFLOW:
|
||||
return "Overflow";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_ep_event_string - returns event name
|
||||
* @event: then event code
|
||||
*/
|
||||
static inline const char *dwc3_ep_event_string(u8 event)
|
||||
{
|
||||
switch (event) {
|
||||
case DWC3_DEPEVT_XFERCOMPLETE:
|
||||
return "Transfer Complete";
|
||||
case DWC3_DEPEVT_XFERINPROGRESS:
|
||||
return "Transfer In-Progress";
|
||||
case DWC3_DEPEVT_XFERNOTREADY:
|
||||
return "Transfer Not Ready";
|
||||
case DWC3_DEPEVT_RXTXFIFOEVT:
|
||||
return "FIFO";
|
||||
case DWC3_DEPEVT_STREAMEVT:
|
||||
return "Stream";
|
||||
case DWC3_DEPEVT_EPCMDCMPLT:
|
||||
return "Endpoint Command Complete";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
#endif /* __DRIVERS_USB_DWC3_GADGET_H */
|
||||
|
|
|
@ -20,27 +20,51 @@
|
|||
#define __DRIVERS_USB_DWC3_IO_H
|
||||
|
||||
#include <linux/io.h>
|
||||
|
||||
#include "trace.h"
|
||||
#include "debug.h"
|
||||
#include "core.h"
|
||||
|
||||
static inline u32 dwc3_readl(void __iomem *base, u32 offset)
|
||||
{
|
||||
u32 offs = offset - DWC3_GLOBALS_REGS_START;
|
||||
u32 value;
|
||||
|
||||
/*
|
||||
* We requested the mem region starting from the Globals address
|
||||
* space, see dwc3_probe in core.c.
|
||||
* However, the offsets are given starting from xHCI address space.
|
||||
*/
|
||||
return readl(base + (offset - DWC3_GLOBALS_REGS_START));
|
||||
value = readl(base + offs);
|
||||
|
||||
/*
|
||||
* When tracing we want to make it easy to find the correct address on
|
||||
* documentation, so we revert it back to the proper addresses, the
|
||||
* same way they are described on SNPS documentation
|
||||
*/
|
||||
dwc3_trace(trace_dwc3_readl, "addr %p value %08x",
|
||||
base - DWC3_GLOBALS_REGS_START + offset, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
|
||||
{
|
||||
u32 offs = offset - DWC3_GLOBALS_REGS_START;
|
||||
|
||||
/*
|
||||
* We requested the mem region starting from the Globals address
|
||||
* space, see dwc3_probe in core.c.
|
||||
* However, the offsets are given starting from xHCI address space.
|
||||
*/
|
||||
writel(value, base + (offset - DWC3_GLOBALS_REGS_START));
|
||||
writel(value, base + offs);
|
||||
|
||||
/*
|
||||
* When tracing we want to make it easy to find the correct address on
|
||||
* documentation, so we revert it back to the proper addresses, the
|
||||
* same way they are described on SNPS documentation
|
||||
*/
|
||||
dwc3_trace(trace_dwc3_writel, "addr %p value %08x",
|
||||
base - DWC3_GLOBALS_REGS_START + offset, value);
|
||||
}
|
||||
|
||||
#endif /* __DRIVERS_USB_DWC3_IO_H */
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* trace.c - DesignWare USB3 DRD Controller Trace Support
|
||||
*
|
||||
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
|
||||
*
|
||||
* Author: Felipe Balbi <balbi@ti.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 of
|
||||
* the License as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "trace.h"
|
|
@ -0,0 +1,220 @@
|
|||
/**
|
||||
* trace.h - DesignWare USB3 DRD Controller Trace Support
|
||||
*
|
||||
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
|
||||
*
|
||||
* Author: Felipe Balbi <balbi@ti.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 of
|
||||
* the License as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM dwc3
|
||||
|
||||
#if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define __DWC3_TRACE_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/tracepoint.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include "core.h"
|
||||
#include "debug.h"
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_msg,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf),
|
||||
TP_STRUCT__entry(__dynamic_array(char, msg, DWC3_MSG_MAX)),
|
||||
TP_fast_assign(
|
||||
vsnprintf(__get_str(msg), DWC3_MSG_MAX, vaf->fmt, *vaf->va);
|
||||
),
|
||||
TP_printk("%s", __get_str(msg))
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_msg, dwc3_readl,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_msg, dwc3_writel,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_msg, dwc3_ep0,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_event,
|
||||
TP_PROTO(u32 event),
|
||||
TP_ARGS(event),
|
||||
TP_STRUCT__entry(
|
||||
__field(u32, event)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->event = event;
|
||||
),
|
||||
TP_printk("event %08x\n", __entry->event)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_event, dwc3_event,
|
||||
TP_PROTO(u32 event),
|
||||
TP_ARGS(event)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_ctrl,
|
||||
TP_PROTO(struct usb_ctrlrequest *ctrl),
|
||||
TP_ARGS(ctrl),
|
||||
TP_STRUCT__entry(
|
||||
__field(struct usb_ctrlrequest *, ctrl)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->ctrl = ctrl;
|
||||
),
|
||||
TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
|
||||
__entry->ctrl->bRequestType, __entry->ctrl->bRequest,
|
||||
le16_to_cpu(__entry->ctrl->wValue), le16_to_cpu(__entry->ctrl->wIndex),
|
||||
le16_to_cpu(__entry->ctrl->wLength)
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
|
||||
TP_PROTO(struct usb_ctrlrequest *ctrl),
|
||||
TP_ARGS(ctrl)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_request,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req),
|
||||
TP_STRUCT__entry(
|
||||
__field(struct dwc3_request *, req)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->req = req;
|
||||
),
|
||||
TP_printk("%s: req %p length %u/%u ==> %d",
|
||||
__entry->req->dep->name, __entry->req,
|
||||
__entry->req->request.actual, __entry->req->request.length,
|
||||
__entry->req->request.status
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
|
||||
TP_PROTO(struct dwc3_request *req),
|
||||
TP_ARGS(req)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
|
||||
TP_PROTO(unsigned int cmd, u32 param),
|
||||
TP_ARGS(cmd, param),
|
||||
TP_STRUCT__entry(
|
||||
__field(unsigned int, cmd)
|
||||
__field(u32, param)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->cmd = cmd;
|
||||
__entry->param = param;
|
||||
),
|
||||
TP_printk("cmd '%s' [%d] param %08x\n",
|
||||
dwc3_gadget_generic_cmd_string(__entry->cmd),
|
||||
__entry->cmd, __entry->param
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
|
||||
TP_PROTO(unsigned int cmd, u32 param),
|
||||
TP_ARGS(cmd, param)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
|
||||
TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
|
||||
struct dwc3_gadget_ep_cmd_params *params),
|
||||
TP_ARGS(dep, cmd, params),
|
||||
TP_STRUCT__entry(
|
||||
__field(struct dwc3_ep *, dep)
|
||||
__field(unsigned int, cmd)
|
||||
__field(struct dwc3_gadget_ep_cmd_params *, params)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->dep = dep;
|
||||
__entry->cmd = cmd;
|
||||
__entry->params = params;
|
||||
),
|
||||
TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x\n",
|
||||
__entry->dep->name, dwc3_gadget_ep_cmd_string(__entry->cmd),
|
||||
__entry->cmd, __entry->params->param0,
|
||||
__entry->params->param1, __entry->params->param2
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
|
||||
TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
|
||||
struct dwc3_gadget_ep_cmd_params *params),
|
||||
TP_ARGS(dep, cmd, params)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dwc3_log_trb,
|
||||
TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
|
||||
TP_ARGS(dep, trb),
|
||||
TP_STRUCT__entry(
|
||||
__field(struct dwc3_ep *, dep)
|
||||
__field(struct dwc3_trb *, trb)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->dep = dep;
|
||||
__entry->trb = trb;
|
||||
),
|
||||
TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x\n",
|
||||
__entry->dep->name, __entry->trb, __entry->trb->bph,
|
||||
__entry->trb->bpl, __entry->trb->size, __entry->trb->ctrl
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
|
||||
TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
|
||||
TP_ARGS(dep, trb)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
|
||||
TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
|
||||
TP_ARGS(dep, trb)
|
||||
);
|
||||
|
||||
#endif /* __DWC3_TRACE_H */
|
||||
|
||||
/* this part has to be here */
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH .
|
||||
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE trace
|
||||
|
||||
#include <trace/define_trace.h>
|
|
@ -181,6 +181,15 @@ config USB_F_MASS_STORAGE
|
|||
config USB_F_FS
|
||||
tristate
|
||||
|
||||
config USB_F_UAC1
|
||||
tristate
|
||||
|
||||
config USB_F_UAC2
|
||||
tristate
|
||||
|
||||
config USB_F_UVC
|
||||
tristate
|
||||
|
||||
choice
|
||||
tristate "USB Gadget Drivers"
|
||||
default USB_ETH
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
|
||||
subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG
|
||||
ccflags-y += -Idrivers/usb/gadget/udc
|
||||
ccflags-y += -I$(srctree)/drivers/usb/gadget/udc
|
||||
|
||||
obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
|
||||
libcomposite-y := usbstring.o config.o epautoconf.o
|
||||
|
|
|
@ -1956,7 +1956,6 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev)
|
|||
}
|
||||
if (cdev->req) {
|
||||
kfree(cdev->req->buf);
|
||||
usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
|
||||
usb_ep_free_request(cdev->gadget->ep0, cdev->req);
|
||||
}
|
||||
cdev->next_string_id = 0;
|
||||
|
@ -2073,6 +2072,7 @@ static const struct usb_gadget_driver composite_driver_template = {
|
|||
.unbind = composite_unbind,
|
||||
|
||||
.setup = composite_setup,
|
||||
.reset = composite_disconnect,
|
||||
.disconnect = composite_disconnect,
|
||||
|
||||
.suspend = composite_suspend,
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче