aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/phy/phy-miphy28lp.txt43
-rw-r--r--Documentation/devicetree/bindings/phy/phy-miphy365x.txt15
-rw-r--r--Documentation/devicetree/bindings/phy/phy-stih407-usb.txt10
-rw-r--r--Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt37
-rw-r--r--Documentation/devicetree/bindings/phy/samsung-phy.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/usb-ehci.txt1
-rw-r--r--Documentation/usb/usbmon.txt4
-rw-r--r--arch/arm/boot/dts/stih416.dtsi10
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c152
-rw-r--r--drivers/phy/Kconfig7
-rw-r--r--drivers/phy/Makefile1
-rw-r--r--drivers/phy/phy-armada375-usb2.c4
-rw-r--r--drivers/phy/phy-exynos-mipi-video.c89
-rw-r--r--drivers/phy/phy-miphy28lp.c61
-rw-r--r--drivers/phy/phy-miphy365x.c29
-rw-r--r--drivers/phy/phy-rockchip-usb.c158
-rw-r--r--drivers/phy/phy-stih407-usb.c25
-rw-r--r--drivers/phy/phy-ti-pipe3.c143
-rw-r--r--drivers/usb/class/cdc-acm.c54
-rw-r--r--drivers/usb/core/buffer.c26
-rw-r--r--drivers/usb/core/devio.c63
-rw-r--r--drivers/usb/core/driver.c29
-rw-r--r--drivers/usb/core/hcd.c16
-rw-r--r--drivers/usb/core/hub.c33
-rw-r--r--drivers/usb/core/message.c23
-rw-r--r--drivers/usb/core/usb.c1
-rw-r--r--drivers/usb/dwc2/hcd.c4
-rw-r--r--drivers/usb/gadget/udc/bdc/bdc_core.c1
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c8
-rw-r--r--drivers/usb/host/ehci-atmel.c102
-rw-r--r--drivers/usb/host/ehci-fsl.c1
-rw-r--r--drivers/usb/host/ehci-grlib.c1
-rw-r--r--drivers/usb/host/ehci-hcd.c6
-rw-r--r--drivers/usb/host/ehci-hub.c8
-rw-r--r--drivers/usb/host/ehci-pci.c23
-rw-r--r--drivers/usb/host/ehci-platform.c92
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c1
-rw-r--r--drivers/usb/host/ehci-ppc-of.c1
-rw-r--r--drivers/usb/host/ehci-sead3.c1
-rw-r--r--drivers/usb/host/ehci-sh.c1
-rw-r--r--drivers/usb/host/ehci-tilegx.c1
-rw-r--r--drivers/usb/host/ehci-xilinx-of.c1
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/fhci-hub.c9
-rw-r--r--drivers/usb/host/fotg210-hcd.c4
-rw-r--r--drivers/usb/host/fusbh200-hcd.c4
-rw-r--r--drivers/usb/host/imx21-hcd.c5
-rw-r--r--drivers/usb/host/isp116x-hcd.c5
-rw-r--r--drivers/usb/host/isp1362-hcd.c8
-rw-r--r--drivers/usb/host/isp1760-hcd.c13
-rw-r--r--drivers/usb/host/max3421-hcd.c6
-rw-r--r--drivers/usb/host/ohci-at91.c132
-rw-r--r--drivers/usb/host/ohci-da8xx.c1
-rw-r--r--drivers/usb/host/ohci-hub.c10
-rw-r--r--drivers/usb/host/ohci-jz4740.c1
-rw-r--r--drivers/usb/host/ohci-platform.c83
-rw-r--r--drivers/usb/host/ohci-ppc-of.c1
-rw-r--r--drivers/usb/host/ohci-s3c2410.c6
-rw-r--r--drivers/usb/host/ohci-sm501.c1
-rw-r--r--drivers/usb/host/ohci-tilegx.c1
-rw-r--r--drivers/usb/host/ohci-tmio.c1
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c10
-rw-r--r--drivers/usb/host/pci-quirks.c46
-rw-r--r--drivers/usb/host/r8a66597-hcd.c13
-rw-r--r--drivers/usb/host/sl811-hcd.c10
-rw-r--r--drivers/usb/host/u132-hcd.c10
-rw-r--r--drivers/usb/host/uhci-grlib.c1
-rw-r--r--drivers/usb/host/uhci-platform.c1
-rw-r--r--drivers/usb/host/xhci-dbg.c2
-rw-r--r--drivers/usb/host/xhci-mem.c31
-rw-r--r--drivers/usb/host/xhci-ring.c12
-rw-r--r--drivers/usb/host/xhci.c78
-rw-r--r--drivers/usb/host/xhci.h12
-rw-r--r--drivers/usb/image/microtek.c4
-rw-r--r--drivers/usb/misc/uss720.c12
-rw-r--r--drivers/usb/musb/musb_virthub.c7
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c3
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/mos7840.c60
-rw-r--r--drivers/usb/serial/option.c60
-rw-r--r--drivers/usb/usbip/vhci_hcd.c3
-rw-r--r--drivers/usb/wusbcore/rh.c4
-rw-r--r--drivers/uwb/lc-dev.c7
-rw-r--r--include/linux/mfd/syscon/exynos4-pmu.h21
-rw-r--r--include/linux/mod_devicetable.h6
-rw-r--r--include/linux/usb.h7
-rw-r--r--include/linux/usb/ehci_pdriver.h4
-rw-r--r--include/linux/usb/hcd.h3
-rw-r--r--include/uapi/linux/usbdevice_fs.h3
89 files changed, 1181 insertions, 831 deletions
diff --git a/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt b/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt
index 46a135dae6b3..89caa885d08c 100644
--- a/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt
+++ b/Documentation/devicetree/bindings/phy/phy-miphy28lp.txt
@@ -26,6 +26,7 @@ Required properties (port (child) node):
26 filled in "reg". It can also contain the offset of the system configuration 26 filled in "reg". It can also contain the offset of the system configuration
27 registers used as glue-logic to setup the device for SATA/PCIe or USB3 27 registers used as glue-logic to setup the device for SATA/PCIe or USB3
28 devices. 28 devices.
29- st,syscfg : Offset of the parent configuration register.
29- resets : phandle to the parent reset controller. 30- resets : phandle to the parent reset controller.
30- reset-names : Associated name must be "miphy-sw-rst". 31- reset-names : Associated name must be "miphy-sw-rst".
31 32
@@ -54,18 +55,12 @@ example:
54 phy_port0: port@9b22000 { 55 phy_port0: port@9b22000 {
55 reg = <0x9b22000 0xff>, 56 reg = <0x9b22000 0xff>,
56 <0x9b09000 0xff>, 57 <0x9b09000 0xff>,
57 <0x9b04000 0xff>, 58 <0x9b04000 0xff>;
58 <0x114 0x4>, /* sysctrl MiPHY cntrl */
59 <0x818 0x4>, /* sysctrl MiPHY status*/
60 <0xe0 0x4>, /* sysctrl PCIe */
61 <0xec 0x4>; /* sysctrl SATA */
62 reg-names = "sata-up", 59 reg-names = "sata-up",
63 "pcie-up", 60 "pcie-up",
64 "pipew", 61 "pipew";
65 "miphy-ctrl-glue", 62
66 "miphy-status-glue", 63 st,syscfg = <0x114 0x818 0xe0 0xec>;
67 "pcie-glue",
68 "sata-glue";
69 #phy-cells = <1>; 64 #phy-cells = <1>;
70 st,osc-rdy; 65 st,osc-rdy;
71 reset-names = "miphy-sw-rst"; 66 reset-names = "miphy-sw-rst";
@@ -75,18 +70,13 @@ example:
75 phy_port1: port@9b2a000 { 70 phy_port1: port@9b2a000 {
76 reg = <0x9b2a000 0xff>, 71 reg = <0x9b2a000 0xff>,
77 <0x9b19000 0xff>, 72 <0x9b19000 0xff>,
78 <0x9b14000 0xff>, 73 <0x9b14000 0xff>;
79 <0x118 0x4>,
80 <0x81c 0x4>,
81 <0xe4 0x4>,
82 <0xf0 0x4>;
83 reg-names = "sata-up", 74 reg-names = "sata-up",
84 "pcie-up", 75 "pcie-up",
85 "pipew", 76 "pipew";
86 "miphy-ctrl-glue", 77
87 "miphy-status-glue", 78 st,syscfg = <0x118 0x81c 0xe4 0xf0>;
88 "pcie-glue", 79
89 "sata-glue";
90 #phy-cells = <1>; 80 #phy-cells = <1>;
91 st,osc-force-ext; 81 st,osc-force-ext;
92 reset-names = "miphy-sw-rst"; 82 reset-names = "miphy-sw-rst";
@@ -95,13 +85,12 @@ example:
95 85
96 phy_port2: port@8f95000 { 86 phy_port2: port@8f95000 {
97 reg = <0x8f95000 0xff>, 87 reg = <0x8f95000 0xff>,
98 <0x8f90000 0xff>, 88 <0x8f90000 0xff>;
99 <0x11c 0x4>,
100 <0x820 0x4>;
101 reg-names = "pipew", 89 reg-names = "pipew",
102 "usb3-up", 90 "usb3-up";
103 "miphy-ctrl-glue", 91
104 "miphy-status-glue"; 92 st,syscfg = <0x11c 0x820>;
93
105 #phy-cells = <1>; 94 #phy-cells = <1>;
106 reset-names = "miphy-sw-rst"; 95 reset-names = "miphy-sw-rst";
107 resets = <&softreset STIH407_MIPHY2_SOFTRESET>; 96 resets = <&softreset STIH407_MIPHY2_SOFTRESET>;
@@ -125,4 +114,4 @@ example:
125 114
126Macro definitions for the supported miphy configuration can be found in: 115Macro definitions for the supported miphy configuration can be found in:
127 116
128include/dt-bindings/phy/phy-miphy28lp.h 117include/dt-bindings/phy/phy.h
diff --git a/Documentation/devicetree/bindings/phy/phy-miphy365x.txt b/Documentation/devicetree/bindings/phy/phy-miphy365x.txt
index 42c880886cf7..9802d5d911aa 100644
--- a/Documentation/devicetree/bindings/phy/phy-miphy365x.txt
+++ b/Documentation/devicetree/bindings/phy/phy-miphy365x.txt
@@ -6,8 +6,10 @@ for SATA and PCIe.
6 6
7Required properties (controller (parent) node): 7Required properties (controller (parent) node):
8- compatible : Should be "st,miphy365x-phy" 8- compatible : Should be "st,miphy365x-phy"
9- st,syscfg : Should be a phandle of the system configuration register group 9- st,syscfg : Phandle / integer array property. Phandle of sysconfig group
10 which contain the SATA, PCIe mode setting bits 10 containing the miphy registers and integer array should contain
11 an entry for each port sub-node, specifying the control
12 register offset inside the sysconfig group.
11 13
12Required nodes : A sub-node is required for each channel the controller 14Required nodes : A sub-node is required for each channel the controller
13 provides. Address range information including the usual 15 provides. Address range information including the usual
@@ -26,7 +28,6 @@ Required properties (port (child) node):
26 registers filled in "reg": 28 registers filled in "reg":
27 - sata: For SATA devices 29 - sata: For SATA devices
28 - pcie: For PCIe devices 30 - pcie: For PCIe devices
29 - syscfg: To specify the syscfg based config register
30 31
31Optional properties (port (child) node): 32Optional properties (port (child) node):
32- st,sata-gen : Generation of locally attached SATA IP. Expected values 33- st,sata-gen : Generation of locally attached SATA IP. Expected values
@@ -39,20 +40,20 @@ Example:
39 40
40 miphy365x_phy: miphy365x@fe382000 { 41 miphy365x_phy: miphy365x@fe382000 {
41 compatible = "st,miphy365x-phy"; 42 compatible = "st,miphy365x-phy";
42 st,syscfg = <&syscfg_rear>; 43 st,syscfg = <&syscfg_rear 0x824 0x828>;
43 #address-cells = <1>; 44 #address-cells = <1>;
44 #size-cells = <1>; 45 #size-cells = <1>;
45 ranges; 46 ranges;
46 47
47 phy_port0: port@fe382000 { 48 phy_port0: port@fe382000 {
48 reg = <0xfe382000 0x100>, <0xfe394000 0x100>, <0x824 0x4>; 49 reg = <0xfe382000 0x100>, <0xfe394000 0x100>;
49 reg-names = "sata", "pcie", "syscfg"; 50 reg-names = "sata", "pcie";
50 #phy-cells = <1>; 51 #phy-cells = <1>;
51 st,sata-gen = <3>; 52 st,sata-gen = <3>;
52 }; 53 };
53 54
54 phy_port1: port@fe38a000 { 55 phy_port1: port@fe38a000 {
55 reg = <0xfe38a000 0x100>, <0xfe804000 0x100>, <0x828 0x4>;; 56 reg = <0xfe38a000 0x100>, <0xfe804000 0x100>;;
56 reg-names = "sata", "pcie", "syscfg"; 57 reg-names = "sata", "pcie", "syscfg";
57 #phy-cells = <1>; 58 #phy-cells = <1>;
58 st,pcie-tx-pol-inv; 59 st,pcie-tx-pol-inv;
diff --git a/Documentation/devicetree/bindings/phy/phy-stih407-usb.txt b/Documentation/devicetree/bindings/phy/phy-stih407-usb.txt
index 1ef8228db73b..de6a706abcdb 100644
--- a/Documentation/devicetree/bindings/phy/phy-stih407-usb.txt
+++ b/Documentation/devicetree/bindings/phy/phy-stih407-usb.txt
@@ -5,10 +5,7 @@ host controllers (when controlling usb2/1.1 devices) available on STiH407 SoC fa
5 5
6Required properties: 6Required properties:
7- compatible : should be "st,stih407-usb2-phy" 7- compatible : should be "st,stih407-usb2-phy"
8- reg : contain the offset and length of the system configuration registers 8- st,syscfg : phandle of sysconfig bank plus integer array containing phyparam and phyctrl register offsets
9 used as glue logic to control & parameter phy
10- reg-names : the names of the system configuration registers in "reg", should be "param" and "reg"
11- st,syscfg : sysconfig register to manage phy parameter at driver level
12- resets : list of phandle and reset specifier pairs. There should be two entries, one 9- resets : list of phandle and reset specifier pairs. There should be two entries, one
13 for the whole phy and one for the port 10 for the whole phy and one for the port
14- reset-names : list of reset signal names. Should be "global" and "port" 11- reset-names : list of reset signal names. Should be "global" and "port"
@@ -19,11 +16,8 @@ Example:
19 16
20usb2_picophy0: usbpicophy@f8 { 17usb2_picophy0: usbpicophy@f8 {
21 compatible = "st,stih407-usb2-phy"; 18 compatible = "st,stih407-usb2-phy";
22 reg = <0xf8 0x04>, /* syscfg 5062 */
23 <0xf4 0x04>; /* syscfg 5061 */
24 reg-names = "param", "ctrl";
25 #phy-cells = <0>; 19 #phy-cells = <0>;
26 st,syscfg = <&syscfg_core>; 20 st,syscfg = <&syscfg_core 0x100 0xf4>;
27 resets = <&softreset STIH407_PICOPHY_SOFTRESET>, 21 resets = <&softreset STIH407_PICOPHY_SOFTRESET>,
28 <&picophyreset STIH407_PICOPHY0_RESET>; 22 <&picophyreset STIH407_PICOPHY0_RESET>;
29 reset-names = "global", "port"; 23 reset-names = "global", "port";
diff --git a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
new file mode 100644
index 000000000000..826454ac43bb
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt
@@ -0,0 +1,37 @@
1ROCKCHIP USB2 PHY
2
3Required properties:
4 - compatible: rockchip,rk3288-usb-phy
5 - rockchip,grf : phandle to the syscon managing the "general
6 register files"
7 - #address-cells: should be 1
8 - #size-cells: should be 0
9
10Sub-nodes:
11Each PHY should be represented as a sub-node.
12
13Sub-nodes
14required properties:
15- #phy-cells: should be 0
16- reg: PHY configure reg address offset in GRF
17 "0x320" - for PHY attach to OTG controller
18 "0x334" - for PHY attach to HOST0 controller
19 "0x348" - for PHY attach to HOST1 controller
20
21Optional Properties:
22- clocks : phandle + clock specifier for the phy clocks
23- clock-names: string, clock name, must be "phyclk"
24
25Example:
26
27usbphy: phy {
28 compatible = "rockchip,rk3288-usb-phy";
29 rockchip,grf = <&grf>;
30 #address-cells = <1>;
31 #size-cells = <0>;
32
33 usbphy0: usb-phy0 {
34 #phy-cells = <0>;
35 reg = <0x320>;
36 };
37};
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index d5bad920827f..91e38cfe1f8f 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -3,8 +3,8 @@ Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY
3 3
4Required properties: 4Required properties:
5- compatible : should be "samsung,s5pv210-mipi-video-phy"; 5- compatible : should be "samsung,s5pv210-mipi-video-phy";
6- reg : offset and length of the MIPI DPHY register set;
7- #phy-cells : from the generic phy bindings, must be 1; 6- #phy-cells : from the generic phy bindings, must be 1;
7- syscon - phandle to the PMU system controller;
8 8
9For "samsung,s5pv210-mipi-video-phy" compatible PHYs the second cell in 9For "samsung,s5pv210-mipi-video-phy" compatible PHYs the second cell in
10the PHY specifier identifies the PHY and its meaning is as follows: 10the PHY specifier identifies the PHY and its meaning is as follows:
diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt
index 43c1a4e06767..0b04fdff9d5a 100644
--- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
@@ -12,6 +12,7 @@ Optional properties:
12 - big-endian-regs : boolean, set this for hcds with big-endian registers 12 - big-endian-regs : boolean, set this for hcds with big-endian registers
13 - big-endian-desc : boolean, set this for hcds with big-endian descriptors 13 - big-endian-desc : boolean, set this for hcds with big-endian descriptors
14 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc 14 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
15 - needs-reset-on-resume : boolean, set this to force EHCI reset after resume
15 - clocks : a list of phandle + clock specifier pairs 16 - clocks : a list of phandle + clock specifier pairs
16 - phys : phandle + phy specifier pair 17 - phys : phandle + phy specifier pair
17 - phy-names : "usb" 18 - phy-names : "usb"
diff --git a/Documentation/usb/usbmon.txt b/Documentation/usb/usbmon.txt
index c42bb9cd3b43..28425f736756 100644
--- a/Documentation/usb/usbmon.txt
+++ b/Documentation/usb/usbmon.txt
@@ -72,7 +72,7 @@ to listen on a single bus, otherwise, to listen on all buses, type:
72 72
73# cat /sys/kernel/debug/usb/usbmon/0u > /tmp/1.mon.out 73# cat /sys/kernel/debug/usb/usbmon/0u > /tmp/1.mon.out
74 74
75This process will be reading until killed. Naturally, the output can be 75This process will read until it is killed. Naturally, the output can be
76redirected to a desirable location. This is preferred, because it is going 76redirected to a desirable location. This is preferred, because it is going
77to be quite long. 77to be quite long.
78 78
@@ -231,7 +231,7 @@ number. Number zero (/dev/usbmon0) is special and means "all buses".
231Note that specific naming policy is set by your Linux distribution. 231Note that specific naming policy is set by your Linux distribution.
232 232
233If you create /dev/usbmon0 by hand, make sure that it is owned by root 233If you create /dev/usbmon0 by hand, make sure that it is owned by root
234and has mode 0600. Otherwise, unpriviledged users will be able to snoop 234and has mode 0600. Otherwise, unprivileged users will be able to snoop
235keyboard traffic. 235keyboard traffic.
236 236
237The following ioctl calls are available, with MON_IOC_MAGIC 0x92: 237The following ioctl calls are available, with MON_IOC_MAGIC 0x92:
diff --git a/arch/arm/boot/dts/stih416.dtsi b/arch/arm/boot/dts/stih416.dtsi
index fad9073ddeed..85afe01c34fa 100644
--- a/arch/arm/boot/dts/stih416.dtsi
+++ b/arch/arm/boot/dts/stih416.dtsi
@@ -283,21 +283,21 @@
283 283
284 miphy365x_phy: phy@fe382000 { 284 miphy365x_phy: phy@fe382000 {
285 compatible = "st,miphy365x-phy"; 285 compatible = "st,miphy365x-phy";
286 st,syscfg = <&syscfg_rear>; 286 st,syscfg = <&syscfg_rear 0x824 0x828>;
287 #address-cells = <1>; 287 #address-cells = <1>;
288 #size-cells = <1>; 288 #size-cells = <1>;
289 ranges; 289 ranges;
290 290
291 phy_port0: port@fe382000 { 291 phy_port0: port@fe382000 {
292 #phy-cells = <1>; 292 #phy-cells = <1>;
293 reg = <0xfe382000 0x100>, <0xfe394000 0x100>, <0x824 0x4>; 293 reg = <0xfe382000 0x100>, <0xfe394000 0x100>;
294 reg-names = "sata", "pcie", "syscfg"; 294 reg-names = "sata", "pcie";
295 }; 295 };
296 296
297 phy_port1: port@fe38a000 { 297 phy_port1: port@fe38a000 {
298 #phy-cells = <1>; 298 #phy-cells = <1>;
299 reg = <0xfe38a000 0x100>, <0xfe804000 0x100>, <0x828 0x4>; 299 reg = <0xfe38a000 0x100>, <0xfe804000 0x100>;
300 reg-names = "sata", "pcie", "syscfg"; 300 reg-names = "sata", "pcie";
301 }; 301 };
302 }; 302 };
303 303
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index b67ddf0f8bcd..12410a2788d8 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -77,7 +77,7 @@ static DEFINE_MUTEX(octeon2_usb_clocks_mutex);
77 77
78static int octeon2_usb_clock_start_cnt; 78static int octeon2_usb_clock_start_cnt;
79 79
80static void octeon2_usb_clocks_start(void) 80static void octeon2_usb_clocks_start(struct device *dev)
81{ 81{
82 u64 div; 82 u64 div;
83 union cvmx_uctlx_if_ena if_ena; 83 union cvmx_uctlx_if_ena if_ena;
@@ -86,6 +86,8 @@ static void octeon2_usb_clocks_start(void)
86 union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status; 86 union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status;
87 int i; 87 int i;
88 unsigned long io_clk_64_to_ns; 88 unsigned long io_clk_64_to_ns;
89 u32 clock_rate = 12000000;
90 bool is_crystal_clock = false;
89 91
90 92
91 mutex_lock(&octeon2_usb_clocks_mutex); 93 mutex_lock(&octeon2_usb_clocks_mutex);
@@ -96,6 +98,28 @@ static void octeon2_usb_clocks_start(void)
96 98
97 io_clk_64_to_ns = 64000000000ull / octeon_get_io_clock_rate(); 99 io_clk_64_to_ns = 64000000000ull / octeon_get_io_clock_rate();
98 100
101 if (dev->of_node) {
102 struct device_node *uctl_node;
103 const char *clock_type;
104
105 uctl_node = of_get_parent(dev->of_node);
106 if (!uctl_node) {
107 dev_err(dev, "No UCTL device node\n");
108 goto exit;
109 }
110 i = of_property_read_u32(uctl_node,
111 "refclk-frequency", &clock_rate);
112 if (i) {
113 dev_err(dev, "No UCTL \"refclk-frequency\"\n");
114 goto exit;
115 }
116 i = of_property_read_string(uctl_node,
117 "refclk-type", &clock_type);
118
119 if (!i && strcmp("crystal", clock_type) == 0)
120 is_crystal_clock = true;
121 }
122
99 /* 123 /*
100 * Step 1: Wait for voltages stable. That surely happened 124 * Step 1: Wait for voltages stable. That surely happened
101 * before starting the kernel. 125 * before starting the kernel.
@@ -126,9 +150,22 @@ static void octeon2_usb_clocks_start(void)
126 cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); 150 cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64);
127 151
128 /* 3b */ 152 /* 3b */
129 /* 12MHz crystal. */ 153 clk_rst_ctl.s.p_refclk_sel = is_crystal_clock ? 0 : 1;
130 clk_rst_ctl.s.p_refclk_sel = 0; 154 switch (clock_rate) {
131 clk_rst_ctl.s.p_refclk_div = 0; 155 default:
156 pr_err("Invalid UCTL clock rate of %u, using 12000000 instead\n",
157 clock_rate);
158 /* Fall through */
159 case 12000000:
160 clk_rst_ctl.s.p_refclk_div = 0;
161 break;
162 case 24000000:
163 clk_rst_ctl.s.p_refclk_div = 1;
164 break;
165 case 48000000:
166 clk_rst_ctl.s.p_refclk_div = 2;
167 break;
168 }
132 cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); 169 cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64);
133 170
134 /* 3c */ 171 /* 3c */
@@ -259,7 +296,7 @@ static void octeon2_usb_clocks_stop(void)
259 296
260static int octeon_ehci_power_on(struct platform_device *pdev) 297static int octeon_ehci_power_on(struct platform_device *pdev)
261{ 298{
262 octeon2_usb_clocks_start(); 299 octeon2_usb_clocks_start(&pdev->dev);
263 return 0; 300 return 0;
264} 301}
265 302
@@ -273,15 +310,16 @@ static struct usb_ehci_pdata octeon_ehci_pdata = {
273#ifdef __BIG_ENDIAN 310#ifdef __BIG_ENDIAN
274 .big_endian_mmio = 1, 311 .big_endian_mmio = 1,
275#endif 312#endif
313 .dma_mask_64 = 1,
276 .power_on = octeon_ehci_power_on, 314 .power_on = octeon_ehci_power_on,
277 .power_off = octeon_ehci_power_off, 315 .power_off = octeon_ehci_power_off,
278}; 316};
279 317
280static void __init octeon_ehci_hw_start(void) 318static void __init octeon_ehci_hw_start(struct device *dev)
281{ 319{
282 union cvmx_uctlx_ehci_ctl ehci_ctl; 320 union cvmx_uctlx_ehci_ctl ehci_ctl;
283 321
284 octeon2_usb_clocks_start(); 322 octeon2_usb_clocks_start(dev);
285 323
286 ehci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_EHCI_CTL(0)); 324 ehci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_EHCI_CTL(0));
287 /* Use 64-bit addressing. */ 325 /* Use 64-bit addressing. */
@@ -294,64 +332,30 @@ static void __init octeon_ehci_hw_start(void)
294 octeon2_usb_clocks_stop(); 332 octeon2_usb_clocks_stop();
295} 333}
296 334
297static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64);
298
299static int __init octeon_ehci_device_init(void) 335static int __init octeon_ehci_device_init(void)
300{ 336{
301 struct platform_device *pd; 337 struct platform_device *pd;
338 struct device_node *ehci_node;
302 int ret = 0; 339 int ret = 0;
303 340
304 struct resource usb_resources[] = { 341 ehci_node = of_find_node_by_name(NULL, "ehci");
305 { 342 if (!ehci_node)
306 .flags = IORESOURCE_MEM,
307 }, {
308 .flags = IORESOURCE_IRQ,
309 }
310 };
311
312 /* Only Octeon2 has ehci/ohci */
313 if (!OCTEON_IS_MODEL(OCTEON_CN63XX))
314 return 0; 343 return 0;
315 344
316 if (octeon_is_simulation() || usb_disabled()) 345 pd = of_find_device_by_node(ehci_node);
317 return 0; /* No USB in the simulator. */ 346 if (!pd)
318 347 return 0;
319 pd = platform_device_alloc("ehci-platform", 0);
320 if (!pd) {
321 ret = -ENOMEM;
322 goto out;
323 }
324
325 usb_resources[0].start = 0x00016F0000000000ULL;
326 usb_resources[0].end = usb_resources[0].start + 0x100;
327
328 usb_resources[1].start = OCTEON_IRQ_USB0;
329 usb_resources[1].end = OCTEON_IRQ_USB0;
330
331 ret = platform_device_add_resources(pd, usb_resources,
332 ARRAY_SIZE(usb_resources));
333 if (ret)
334 goto fail;
335 348
336 pd->dev.dma_mask = &octeon_ehci_dma_mask;
337 pd->dev.platform_data = &octeon_ehci_pdata; 349 pd->dev.platform_data = &octeon_ehci_pdata;
338 octeon_ehci_hw_start(); 350 octeon_ehci_hw_start(&pd->dev);
339 351
340 ret = platform_device_add(pd);
341 if (ret)
342 goto fail;
343
344 return ret;
345fail:
346 platform_device_put(pd);
347out:
348 return ret; 352 return ret;
349} 353}
350device_initcall(octeon_ehci_device_init); 354device_initcall(octeon_ehci_device_init);
351 355
352static int octeon_ohci_power_on(struct platform_device *pdev) 356static int octeon_ohci_power_on(struct platform_device *pdev)
353{ 357{
354 octeon2_usb_clocks_start(); 358 octeon2_usb_clocks_start(&pdev->dev);
355 return 0; 359 return 0;
356} 360}
357 361
@@ -369,11 +373,11 @@ static struct usb_ohci_pdata octeon_ohci_pdata = {
369 .power_off = octeon_ohci_power_off, 373 .power_off = octeon_ohci_power_off,
370}; 374};
371 375
372static void __init octeon_ohci_hw_start(void) 376static void __init octeon_ohci_hw_start(struct device *dev)
373{ 377{
374 union cvmx_uctlx_ohci_ctl ohci_ctl; 378 union cvmx_uctlx_ohci_ctl ohci_ctl;
375 379
376 octeon2_usb_clocks_start(); 380 octeon2_usb_clocks_start(dev);
377 381
378 ohci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_OHCI_CTL(0)); 382 ohci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_OHCI_CTL(0));
379 ohci_ctl.s.l2c_addr_msb = 0; 383 ohci_ctl.s.l2c_addr_msb = 0;
@@ -387,57 +391,27 @@ static void __init octeon_ohci_hw_start(void)
387static int __init octeon_ohci_device_init(void) 391static int __init octeon_ohci_device_init(void)
388{ 392{
389 struct platform_device *pd; 393 struct platform_device *pd;
394 struct device_node *ohci_node;
390 int ret = 0; 395 int ret = 0;
391 396
392 struct resource usb_resources[] = { 397 ohci_node = of_find_node_by_name(NULL, "ohci");
393 { 398 if (!ohci_node)
394 .flags = IORESOURCE_MEM,
395 }, {
396 .flags = IORESOURCE_IRQ,
397 }
398 };
399
400 /* Only Octeon2 has ehci/ohci */
401 if (!OCTEON_IS_MODEL(OCTEON_CN63XX))
402 return 0; 399 return 0;
403 400
404 if (octeon_is_simulation() || usb_disabled()) 401 pd = of_find_device_by_node(ohci_node);
405 return 0; /* No USB in the simulator. */ 402 if (!pd)
406 403 return 0;
407 pd = platform_device_alloc("ohci-platform", 0);
408 if (!pd) {
409 ret = -ENOMEM;
410 goto out;
411 }
412
413 usb_resources[0].start = 0x00016F0000000400ULL;
414 usb_resources[0].end = usb_resources[0].start + 0x100;
415
416 usb_resources[1].start = OCTEON_IRQ_USB0;
417 usb_resources[1].end = OCTEON_IRQ_USB0;
418
419 ret = platform_device_add_resources(pd, usb_resources,
420 ARRAY_SIZE(usb_resources));
421 if (ret)
422 goto fail;
423 404
424 pd->dev.platform_data = &octeon_ohci_pdata; 405 pd->dev.platform_data = &octeon_ohci_pdata;
425 octeon_ohci_hw_start(); 406 octeon_ohci_hw_start(&pd->dev);
426
427 ret = platform_device_add(pd);
428 if (ret)
429 goto fail;
430 407
431 return ret; 408 return ret;
432fail:
433 platform_device_put(pd);
434out:
435 return ret;
436} 409}
437device_initcall(octeon_ohci_device_init); 410device_initcall(octeon_ohci_device_init);
438 411
439#endif /* CONFIG_USB */ 412#endif /* CONFIG_USB */
440 413
414
441static struct of_device_id __initdata octeon_ids[] = { 415static struct of_device_id __initdata octeon_ids[] = {
442 { .compatible = "simple-bus", }, 416 { .compatible = "simple-bus", },
443 { .compatible = "cavium,octeon-6335-uctl", }, 417 { .compatible = "cavium,octeon-6335-uctl", },
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index ccad8809ecb1..b24500afba25 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
239 depends on OF 239 depends on OF
240 select GENERIC_PHY 240 select GENERIC_PHY
241 241
242config PHY_ROCKCHIP_USB
243 tristate "Rockchip USB2 PHY Driver"
244 depends on ARCH_ROCKCHIP && OF
245 select GENERIC_PHY
246 help
247 Enable this to support the Rockchip USB 2.0 PHY.
248
242config PHY_ST_SPEAR1310_MIPHY 249config PHY_ST_SPEAR1310_MIPHY
243 tristate "ST SPEAR1310-MIPHY driver" 250 tristate "ST SPEAR1310-MIPHY driver"
244 select GENERIC_PHY 251 select GENERIC_PHY
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index aa74f961e44e..48bf5a15f161 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o
28phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o 28phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
29obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o 29obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o
30obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o 30obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o
31obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
31obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o 32obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o
32obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o 33obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
33obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o 34obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
index ac7d99d01cb3..7c99ca256f05 100644
--- a/drivers/phy/phy-armada375-usb2.c
+++ b/drivers/phy/phy-armada375-usb2.c
@@ -118,8 +118,8 @@ static int armada375_usb_phy_probe(struct platform_device *pdev)
118 118
119 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 119 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
120 usb_cluster_base = devm_ioremap_resource(&pdev->dev, res); 120 usb_cluster_base = devm_ioremap_resource(&pdev->dev, res);
121 if (!usb_cluster_base) 121 if (IS_ERR(usb_cluster_base))
122 return -ENOMEM; 122 return PTR_ERR(usb_cluster_base);
123 123
124 phy = devm_phy_create(dev, NULL, &armada375_usb_phy_ops); 124 phy = devm_phy_create(dev, NULL, &armada375_usb_phy_ops);
125 if (IS_ERR(phy)) { 125 if (IS_ERR(phy)) {
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index 943e0f88a120..f017b2f2a54e 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -12,19 +12,18 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/mfd/syscon/exynos4-pmu.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/of.h> 17#include <linux/of.h>
17#include <linux/of_address.h> 18#include <linux/of_address.h>
18#include <linux/phy/phy.h> 19#include <linux/phy/phy.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regmap.h>
20#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/mfd/syscon.h>
21 24
22/* MIPI_PHYn_CONTROL register offset: n = 0..1 */ 25/* MIPI_PHYn_CONTROL reg. offset (for base address from ioremap): n = 0..1 */
23#define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4) 26#define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4)
24#define EXYNOS_MIPI_PHY_ENABLE (1 << 0)
25#define EXYNOS_MIPI_PHY_SRESETN (1 << 1)
26#define EXYNOS_MIPI_PHY_MRESETN (1 << 2)
27#define EXYNOS_MIPI_PHY_RESET_MASK (3 << 1)
28 27
29enum exynos_mipi_phy_id { 28enum exynos_mipi_phy_id {
30 EXYNOS_MIPI_PHY_ID_CSIS0, 29 EXYNOS_MIPI_PHY_ID_CSIS0,
@@ -38,43 +37,62 @@ enum exynos_mipi_phy_id {
38 ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM1) 37 ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM1)
39 38
40struct exynos_mipi_video_phy { 39struct exynos_mipi_video_phy {
41 spinlock_t slock;
42 struct video_phy_desc { 40 struct video_phy_desc {
43 struct phy *phy; 41 struct phy *phy;
44 unsigned int index; 42 unsigned int index;
45 } phys[EXYNOS_MIPI_PHYS_NUM]; 43 } phys[EXYNOS_MIPI_PHYS_NUM];
44 spinlock_t slock;
46 void __iomem *regs; 45 void __iomem *regs;
46 struct mutex mutex;
47 struct regmap *regmap;
47}; 48};
48 49
49static int __set_phy_state(struct exynos_mipi_video_phy *state, 50static int __set_phy_state(struct exynos_mipi_video_phy *state,
50 enum exynos_mipi_phy_id id, unsigned int on) 51 enum exynos_mipi_phy_id id, unsigned int on)
51{ 52{
53 const unsigned int offset = EXYNOS4_MIPI_PHY_CONTROL(id / 2);
52 void __iomem *addr; 54 void __iomem *addr;
53 u32 reg, reset; 55 u32 val, reset;
54
55 addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2);
56 56
57 if (is_mipi_dsim_phy_id(id)) 57 if (is_mipi_dsim_phy_id(id))
58 reset = EXYNOS_MIPI_PHY_MRESETN; 58 reset = EXYNOS4_MIPI_PHY_MRESETN;
59 else
60 reset = EXYNOS_MIPI_PHY_SRESETN;
61
62 spin_lock(&state->slock);
63 reg = readl(addr);
64 if (on)
65 reg |= reset;
66 else 59 else
67 reg &= ~reset; 60 reset = EXYNOS4_MIPI_PHY_SRESETN;
68 writel(reg, addr); 61
69 62 if (state->regmap) {
70 /* Clear ENABLE bit only if MRESETN, SRESETN bits are not set. */ 63 mutex_lock(&state->mutex);
71 if (on) 64 regmap_read(state->regmap, offset, &val);
72 reg |= EXYNOS_MIPI_PHY_ENABLE; 65 if (on)
73 else if (!(reg & EXYNOS_MIPI_PHY_RESET_MASK)) 66 val |= reset;
74 reg &= ~EXYNOS_MIPI_PHY_ENABLE; 67 else
68 val &= ~reset;
69 regmap_write(state->regmap, offset, val);
70 if (on)
71 val |= EXYNOS4_MIPI_PHY_ENABLE;
72 else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK))
73 val &= ~EXYNOS4_MIPI_PHY_ENABLE;
74 regmap_write(state->regmap, offset, val);
75 mutex_unlock(&state->mutex);
76 } else {
77 addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2);
78
79 spin_lock(&state->slock);
80 val = readl(addr);
81 if (on)
82 val |= reset;
83 else
84 val &= ~reset;
85 writel(val, addr);
86 /* Clear ENABLE bit only if MRESETN, SRESETN bits are not set */
87 if (on)
88 val |= EXYNOS4_MIPI_PHY_ENABLE;
89 else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK))
90 val &= ~EXYNOS4_MIPI_PHY_ENABLE;
91
92 writel(val, addr);
93 spin_unlock(&state->slock);
94 }
75 95
76 writel(reg, addr);
77 spin_unlock(&state->slock);
78 return 0; 96 return 0;
79} 97}
80 98
@@ -118,7 +136,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
118{ 136{
119 struct exynos_mipi_video_phy *state; 137 struct exynos_mipi_video_phy *state;
120 struct device *dev = &pdev->dev; 138 struct device *dev = &pdev->dev;
121 struct resource *res;
122 struct phy_provider *phy_provider; 139 struct phy_provider *phy_provider;
123 unsigned int i; 140 unsigned int i;
124 141
@@ -126,14 +143,22 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
126 if (!state) 143 if (!state)
127 return -ENOMEM; 144 return -ENOMEM;
128 145
129 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 146 state->regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
147 if (IS_ERR(state->regmap)) {
148 struct resource *res;
130 149
131 state->regs = devm_ioremap_resource(dev, res); 150 dev_info(dev, "regmap lookup failed: %ld\n",
132 if (IS_ERR(state->regs)) 151 PTR_ERR(state->regmap));
133 return PTR_ERR(state->regs); 152
153 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
154 state->regs = devm_ioremap_resource(dev, res);
155 if (IS_ERR(state->regs))
156 return PTR_ERR(state->regs);
157 }
134 158
135 dev_set_drvdata(dev, state); 159 dev_set_drvdata(dev, state);
136 spin_lock_init(&state->slock); 160 spin_lock_init(&state->slock);
161 mutex_init(&state->mutex);
137 162
138 for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { 163 for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
139 struct phy *phy = devm_phy_create(dev, NULL, 164 struct phy *phy = devm_phy_create(dev, NULL,
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 27fa62ce6136..9b2848e6115d 100644
--- a/drivers/phy/phy-miphy28lp.c
+++ b/drivers/phy/phy-miphy28lp.c
@@ -194,6 +194,14 @@
194#define MIPHY_SATA_BANK_NB 3 194#define MIPHY_SATA_BANK_NB 3
195#define MIPHY_PCIE_BANK_NB 2 195#define MIPHY_PCIE_BANK_NB 2
196 196
197enum {
198 SYSCFG_CTRL,
199 SYSCFG_STATUS,
200 SYSCFG_PCI,
201 SYSCFG_SATA,
202 SYSCFG_REG_MAX,
203};
204
197struct miphy28lp_phy { 205struct miphy28lp_phy {
198 struct phy *phy; 206 struct phy *phy;
199 struct miphy28lp_dev *phydev; 207 struct miphy28lp_dev *phydev;
@@ -211,10 +219,7 @@ struct miphy28lp_phy {
211 u32 sata_gen; 219 u32 sata_gen;
212 220
213 /* Sysconfig registers offsets needed to configure the device */ 221 /* Sysconfig registers offsets needed to configure the device */
214 u32 syscfg_miphy_ctrl; 222 u32 syscfg_reg[SYSCFG_REG_MAX];
215 u32 syscfg_miphy_status;
216 u32 syscfg_pci;
217 u32 syscfg_sata;
218 u8 type; 223 u8 type;
219}; 224};
220 225
@@ -834,12 +839,12 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
834 if (!miphy_phy->osc_rdy) 839 if (!miphy_phy->osc_rdy)
835 return 0; 840 return 0;
836 841
837 if (!miphy_phy->syscfg_miphy_status) 842 if (!miphy_phy->syscfg_reg[SYSCFG_STATUS])
838 return -EINVAL; 843 return -EINVAL;
839 844
840 do { 845 do {
841 regmap_read(miphy_dev->regmap, miphy_phy->syscfg_miphy_status, 846 regmap_read(miphy_dev->regmap,
842 &val); 847 miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
843 848
844 if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY) 849 if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
845 cpu_relax(); 850 cpu_relax();
@@ -888,7 +893,7 @@ static int miphy28lp_setup(struct miphy28lp_phy *miphy_phy, u32 miphy_val)
888 int err; 893 int err;
889 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; 894 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
890 895
891 if (!miphy_phy->syscfg_miphy_ctrl) 896 if (!miphy_phy->syscfg_reg[SYSCFG_CTRL])
892 return -EINVAL; 897 return -EINVAL;
893 898
894 err = reset_control_assert(miphy_phy->miphy_rst); 899 err = reset_control_assert(miphy_phy->miphy_rst);
@@ -900,7 +905,8 @@ static int miphy28lp_setup(struct miphy28lp_phy *miphy_phy, u32 miphy_val)
900 if (miphy_phy->osc_force_ext) 905 if (miphy_phy->osc_force_ext)
901 miphy_val |= MIPHY_OSC_FORCE_EXT; 906 miphy_val |= MIPHY_OSC_FORCE_EXT;
902 907
903 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_miphy_ctrl, 908 regmap_update_bits(miphy_dev->regmap,
909 miphy_phy->syscfg_reg[SYSCFG_CTRL],
904 MIPHY_CTRL_MASK, miphy_val); 910 MIPHY_CTRL_MASK, miphy_val);
905 911
906 err = reset_control_deassert(miphy_phy->miphy_rst); 912 err = reset_control_deassert(miphy_phy->miphy_rst);
@@ -917,8 +923,9 @@ static int miphy28lp_init_sata(struct miphy28lp_phy *miphy_phy)
917 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; 923 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
918 int err, sata_conf = SATA_CTRL_SELECT_SATA; 924 int err, sata_conf = SATA_CTRL_SELECT_SATA;
919 925
920 if ((!miphy_phy->syscfg_sata) || (!miphy_phy->syscfg_pci) 926 if ((!miphy_phy->syscfg_reg[SYSCFG_SATA]) ||
921 || (!miphy_phy->base)) 927 (!miphy_phy->syscfg_reg[SYSCFG_PCI]) ||
928 (!miphy_phy->base))
922 return -EINVAL; 929 return -EINVAL;
923 930
924 dev_info(miphy_dev->dev, "sata-up mode, addr 0x%p\n", miphy_phy->base); 931 dev_info(miphy_dev->dev, "sata-up mode, addr 0x%p\n", miphy_phy->base);
@@ -926,10 +933,11 @@ static int miphy28lp_init_sata(struct miphy28lp_phy *miphy_phy)
926 /* Configure the glue-logic */ 933 /* Configure the glue-logic */
927 sata_conf |= ((miphy_phy->sata_gen - SATA_GEN1) << SATA_SPDMODE); 934 sata_conf |= ((miphy_phy->sata_gen - SATA_GEN1) << SATA_SPDMODE);
928 935
929 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_sata, 936 regmap_update_bits(miphy_dev->regmap,
937 miphy_phy->syscfg_reg[SYSCFG_SATA],
930 SATA_CTRL_MASK, sata_conf); 938 SATA_CTRL_MASK, sata_conf);
931 939
932 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_pci, 940 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_reg[SYSCFG_PCI],
933 PCIE_CTRL_MASK, SATA_CTRL_SELECT_PCIE); 941 PCIE_CTRL_MASK, SATA_CTRL_SELECT_PCIE);
934 942
935 /* MiPHY path and clocking init */ 943 /* MiPHY path and clocking init */
@@ -951,17 +959,19 @@ static int miphy28lp_init_pcie(struct miphy28lp_phy *miphy_phy)
951 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; 959 struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
952 int err; 960 int err;
953 961
954 if ((!miphy_phy->syscfg_sata) || (!miphy_phy->syscfg_pci) 962 if ((!miphy_phy->syscfg_reg[SYSCFG_SATA]) ||
963 (!miphy_phy->syscfg_reg[SYSCFG_PCI])
955 || (!miphy_phy->base) || (!miphy_phy->pipebase)) 964 || (!miphy_phy->base) || (!miphy_phy->pipebase))
956 return -EINVAL; 965 return -EINVAL;
957 966
958 dev_info(miphy_dev->dev, "pcie-up mode, addr 0x%p\n", miphy_phy->base); 967 dev_info(miphy_dev->dev, "pcie-up mode, addr 0x%p\n", miphy_phy->base);
959 968
960 /* Configure the glue-logic */ 969 /* Configure the glue-logic */
961 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_sata, 970 regmap_update_bits(miphy_dev->regmap,
971 miphy_phy->syscfg_reg[SYSCFG_SATA],
962 SATA_CTRL_MASK, SATA_CTRL_SELECT_PCIE); 972 SATA_CTRL_MASK, SATA_CTRL_SELECT_PCIE);
963 973
964 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_pci, 974 regmap_update_bits(miphy_dev->regmap, miphy_phy->syscfg_reg[SYSCFG_PCI],
965 PCIE_CTRL_MASK, SYSCFG_PCIE_PCIE_VAL); 975 PCIE_CTRL_MASK, SYSCFG_PCIE_PCIE_VAL);
966 976
967 /* MiPHY path and clocking init */ 977 /* MiPHY path and clocking init */
@@ -1156,7 +1166,8 @@ static int miphy28lp_probe_resets(struct device_node *node,
1156static int miphy28lp_of_probe(struct device_node *np, 1166static int miphy28lp_of_probe(struct device_node *np,
1157 struct miphy28lp_phy *miphy_phy) 1167 struct miphy28lp_phy *miphy_phy)
1158{ 1168{
1159 struct resource res; 1169 int i;
1170 u32 ctrlreg;
1160 1171
1161 miphy_phy->osc_force_ext = 1172 miphy_phy->osc_force_ext =
1162 of_property_read_bool(np, "st,osc-force-ext"); 1173 of_property_read_bool(np, "st,osc-force-ext");
@@ -1175,18 +1186,10 @@ static int miphy28lp_of_probe(struct device_node *np,
1175 if (!miphy_phy->sata_gen) 1186 if (!miphy_phy->sata_gen)
1176 miphy_phy->sata_gen = SATA_GEN1; 1187 miphy_phy->sata_gen = SATA_GEN1;
1177 1188
1178 if (!miphy28lp_get_resource_byname(np, "miphy-ctrl-glue", &res)) 1189 for (i = 0; i < SYSCFG_REG_MAX; i++) {
1179 miphy_phy->syscfg_miphy_ctrl = res.start; 1190 if (!of_property_read_u32_index(np, "st,syscfg", i, &ctrlreg))
1180 1191 miphy_phy->syscfg_reg[i] = ctrlreg;
1181 if (!miphy28lp_get_resource_byname(np, "miphy-status-glue", &res)) 1192 }
1182 miphy_phy->syscfg_miphy_status = res.start;
1183
1184 if (!miphy28lp_get_resource_byname(np, "pcie-glue", &res))
1185 miphy_phy->syscfg_pci = res.start;
1186
1187 if (!miphy28lp_get_resource_byname(np, "sata-glue", &res))
1188 miphy_phy->syscfg_sata = res.start;
1189
1190 1193
1191 return 0; 1194 return 0;
1192} 1195}
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index 6ab43a814ad2..6c80154e8bff 100644
--- a/drivers/phy/phy-miphy365x.c
+++ b/drivers/phy/phy-miphy365x.c
@@ -141,7 +141,7 @@ struct miphy365x_phy {
141 bool pcie_tx_pol_inv; 141 bool pcie_tx_pol_inv;
142 bool sata_tx_pol_inv; 142 bool sata_tx_pol_inv;
143 u32 sata_gen; 143 u32 sata_gen;
144 u64 ctrlreg; 144 u32 ctrlreg;
145 u8 type; 145 u8 type;
146}; 146};
147 147
@@ -179,7 +179,7 @@ static int miphy365x_set_path(struct miphy365x_phy *miphy_phy,
179 bool sata = (miphy_phy->type == MIPHY_TYPE_SATA); 179 bool sata = (miphy_phy->type == MIPHY_TYPE_SATA);
180 180
181 return regmap_update_bits(miphy_dev->regmap, 181 return regmap_update_bits(miphy_dev->regmap,
182 (unsigned int)miphy_phy->ctrlreg, 182 miphy_phy->ctrlreg,
183 SYSCFG_SELECT_SATA_MASK, 183 SYSCFG_SELECT_SATA_MASK,
184 sata << SYSCFG_SELECT_SATA_POS); 184 sata << SYSCFG_SELECT_SATA_POS);
185} 185}
@@ -445,7 +445,6 @@ int miphy365x_get_addr(struct device *dev, struct miphy365x_phy *miphy_phy,
445{ 445{
446 struct device_node *phynode = miphy_phy->phy->dev.of_node; 446 struct device_node *phynode = miphy_phy->phy->dev.of_node;
447 const char *name; 447 const char *name;
448 const __be32 *taddr;
449 int type = miphy_phy->type; 448 int type = miphy_phy->type;
450 int ret; 449 int ret;
451 450
@@ -455,22 +454,6 @@ int miphy365x_get_addr(struct device *dev, struct miphy365x_phy *miphy_phy,
455 return ret; 454 return ret;
456 } 455 }
457 456
458 if (!strncmp(name, "syscfg", 6)) {
459 taddr = of_get_address(phynode, index, NULL, NULL);
460 if (!taddr) {
461 dev_err(dev, "failed to fetch syscfg address\n");
462 return -EINVAL;
463 }
464
465 miphy_phy->ctrlreg = of_translate_address(phynode, taddr);
466 if (miphy_phy->ctrlreg == OF_BAD_ADDR) {
467 dev_err(dev, "failed to translate syscfg address\n");
468 return -EINVAL;
469 }
470
471 return 0;
472 }
473
474 if (!((!strncmp(name, "sata", 4) && type == MIPHY_TYPE_SATA) || 457 if (!((!strncmp(name, "sata", 4) && type == MIPHY_TYPE_SATA) ||
475 (!strncmp(name, "pcie", 4) && type == MIPHY_TYPE_PCIE))) 458 (!strncmp(name, "pcie", 4) && type == MIPHY_TYPE_PCIE)))
476 return 0; 459 return 0;
@@ -606,7 +589,15 @@ static int miphy365x_probe(struct platform_device *pdev)
606 return ret; 589 return ret;
607 590
608 phy_set_drvdata(phy, miphy_dev->phys[port]); 591 phy_set_drvdata(phy, miphy_dev->phys[port]);
592
609 port++; 593 port++;
594 /* sysconfig offsets are indexed from 1 */
595 ret = of_property_read_u32_index(np, "st,syscfg", port,
596 &miphy_phy->ctrlreg);
597 if (ret) {
598 dev_err(&pdev->dev, "No sysconfig offset found\n");
599 return ret;
600 }
610 } 601 }
611 602
612 provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate); 603 provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate);
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
new file mode 100644
index 000000000000..22011c3b6a4b
--- /dev/null
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -0,0 +1,158 @@
1/*
2 * Rockchip usb PHY driver
3 *
4 * Copyright (C) 2014 Yunzhi Li <lyz@rock-chips.com>
5 * Copyright (C) 2014 ROCKCHIP, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/clk.h>
18#include <linux/io.h>
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/mutex.h>
22#include <linux/of.h>
23#include <linux/of_address.h>
24#include <linux/phy/phy.h>
25#include <linux/platform_device.h>
26#include <linux/regulator/consumer.h>
27#include <linux/reset.h>
28#include <linux/regmap.h>
29#include <linux/mfd/syscon.h>
30
31/*
32 * The higher 16-bit of this register is used for write protection
33 * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
34 */
35#define SIDDQ_WRITE_ENA BIT(29)
36#define SIDDQ_ON BIT(13)
37#define SIDDQ_OFF (0 << 13)
38
39struct rockchip_usb_phy {
40 unsigned int reg_offset;
41 struct regmap *reg_base;
42 struct clk *clk;
43 struct phy *phy;
44};
45
46static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
47 bool siddq)
48{
49 return regmap_write(phy->reg_base, phy->reg_offset,
50 SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
51}
52
53static int rockchip_usb_phy_power_off(struct phy *_phy)
54{
55 struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
56 int ret = 0;
57
58 /* Power down usb phy analog blocks by set siddq 1 */
59 ret = rockchip_usb_phy_power(phy, 1);
60 if (ret)
61 return ret;
62
63 clk_disable_unprepare(phy->clk);
64 if (ret)
65 return ret;
66
67 return 0;
68}
69
70static int rockchip_usb_phy_power_on(struct phy *_phy)
71{
72 struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
73 int ret = 0;
74
75 ret = clk_prepare_enable(phy->clk);
76 if (ret)
77 return ret;
78
79 /* Power up usb phy analog blocks by set siddq 0 */
80 ret = rockchip_usb_phy_power(phy, 0);
81 if (ret)
82 return ret;
83
84 return 0;
85}
86
87static struct phy_ops ops = {
88 .power_on = rockchip_usb_phy_power_on,
89 .power_off = rockchip_usb_phy_power_off,
90 .owner = THIS_MODULE,
91};
92
93static int rockchip_usb_phy_probe(struct platform_device *pdev)
94{
95 struct device *dev = &pdev->dev;
96 struct rockchip_usb_phy *rk_phy;
97 struct phy_provider *phy_provider;
98 struct device_node *child;
99 struct regmap *grf;
100 unsigned int reg_offset;
101
102 grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf");
103 if (IS_ERR(grf)) {
104 dev_err(&pdev->dev, "Missing rockchip,grf property\n");
105 return PTR_ERR(grf);
106 }
107
108 for_each_available_child_of_node(dev->of_node, child) {
109 rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL);
110 if (!rk_phy)
111 return -ENOMEM;
112
113 if (of_property_read_u32(child, "reg", &reg_offset)) {
114 dev_err(dev, "missing reg property in node %s\n",
115 child->name);
116 return -EINVAL;
117 }
118
119 rk_phy->reg_offset = reg_offset;
120 rk_phy->reg_base = grf;
121
122 rk_phy->clk = of_clk_get_by_name(child, "phyclk");
123 if (IS_ERR(rk_phy->clk))
124 rk_phy->clk = NULL;
125
126 rk_phy->phy = devm_phy_create(dev, child, &ops);
127 if (IS_ERR(rk_phy->phy)) {
128 dev_err(dev, "failed to create PHY\n");
129 return PTR_ERR(rk_phy->phy);
130 }
131 phy_set_drvdata(rk_phy->phy, rk_phy);
132 }
133
134 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
135 return PTR_ERR_OR_ZERO(phy_provider);
136}
137
138static const struct of_device_id rockchip_usb_phy_dt_ids[] = {
139 { .compatible = "rockchip,rk3288-usb-phy" },
140 {}
141};
142
143MODULE_DEVICE_TABLE(of, rockchip_usb_phy_dt_ids);
144
145static struct platform_driver rockchip_usb_driver = {
146 .probe = rockchip_usb_phy_probe,
147 .driver = {
148 .name = "rockchip-usb-phy",
149 .owner = THIS_MODULE,
150 .of_match_table = rockchip_usb_phy_dt_ids,
151 },
152};
153
154module_platform_driver(rockchip_usb_driver);
155
156MODULE_AUTHOR("Yunzhi Li <lyz@rock-chips.com>");
157MODULE_DESCRIPTION("Rockchip USB 2.0 PHY driver");
158MODULE_LICENSE("GPL v2");
diff --git a/drivers/phy/phy-stih407-usb.c b/drivers/phy/phy-stih407-usb.c
index 74f0fab3cd8a..1d5ae5f8ef69 100644
--- a/drivers/phy/phy-stih407-usb.c
+++ b/drivers/phy/phy-stih407-usb.c
@@ -22,6 +22,9 @@
22#include <linux/mfd/syscon.h> 22#include <linux/mfd/syscon.h>
23#include <linux/phy/phy.h> 23#include <linux/phy/phy.h>
24 24
25#define PHYPARAM_REG 1
26#define PHYCTRL_REG 2
27
25/* Default PHY_SEL and REFCLKSEL configuration */ 28/* Default PHY_SEL and REFCLKSEL configuration */
26#define STIH407_USB_PICOPHY_CTRL_PORT_CONF 0x6 29#define STIH407_USB_PICOPHY_CTRL_PORT_CONF 0x6
27#define STIH407_USB_PICOPHY_CTRL_PORT_MASK 0x1f 30#define STIH407_USB_PICOPHY_CTRL_PORT_MASK 0x1f
@@ -93,7 +96,7 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
93 struct device_node *np = dev->of_node; 96 struct device_node *np = dev->of_node;
94 struct phy_provider *phy_provider; 97 struct phy_provider *phy_provider;
95 struct phy *phy; 98 struct phy *phy;
96 struct resource *res; 99 int ret;
97 100
98 phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL); 101 phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL);
99 if (!phy_dev) 102 if (!phy_dev)
@@ -123,19 +126,19 @@ static int stih407_usb2_picophy_probe(struct platform_device *pdev)
123 return PTR_ERR(phy_dev->regmap); 126 return PTR_ERR(phy_dev->regmap);
124 } 127 }
125 128
126 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl"); 129 ret = of_property_read_u32_index(np, "st,syscfg", PHYPARAM_REG,
127 if (!res) { 130 &phy_dev->param);
128 dev_err(dev, "No ctrl reg found\n"); 131 if (ret) {
129 return -ENXIO; 132 dev_err(dev, "can't get phyparam offset (%d)\n", ret);
133 return ret;
130 } 134 }
131 phy_dev->ctrl = res->start;
132 135
133 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param"); 136 ret = of_property_read_u32_index(np, "st,syscfg", PHYCTRL_REG,
134 if (!res) { 137 &phy_dev->ctrl);
135 dev_err(dev, "No param reg found\n"); 138 if (ret) {
136 return -ENXIO; 139 dev_err(dev, "can't get phyctrl offset (%d)\n", ret);
140 return ret;
137 } 141 }
138 phy_dev->param = res->start;
139 142
140 phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data); 143 phy = devm_phy_create(dev, NULL, &stih407_usb2_picophy_data);
141 if (IS_ERR(phy)) { 144 if (IS_ERR(phy)) {
diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
index 465de2c800f2..95c88f929f27 100644
--- a/drivers/phy/phy-ti-pipe3.c
+++ b/drivers/phy/phy-ti-pipe3.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/phy/omap_control_phy.h> 29#include <linux/phy/omap_control_phy.h>
30#include <linux/of_platform.h> 30#include <linux/of_platform.h>
31#include <linux/spinlock.h>
31 32
32#define PLL_STATUS 0x00000004 33#define PLL_STATUS 0x00000004
33#define PLL_GO 0x00000008 34#define PLL_GO 0x00000008
@@ -82,6 +83,10 @@ struct ti_pipe3 {
82 struct clk *refclk; 83 struct clk *refclk;
83 struct clk *div_clk; 84 struct clk *div_clk;
84 struct pipe3_dpll_map *dpll_map; 85 struct pipe3_dpll_map *dpll_map;
86 bool enabled;
87 spinlock_t lock; /* serialize clock enable/disable */
88 /* the below flag is needed specifically for SATA */
89 bool refclk_enabled;
85}; 90};
86 91
87static struct pipe3_dpll_map dpll_map_usb[] = { 92static struct pipe3_dpll_map dpll_map_usb[] = {
@@ -307,6 +312,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)
307 return -ENOMEM; 312 return -ENOMEM;
308 313
309 phy->dev = &pdev->dev; 314 phy->dev = &pdev->dev;
315 spin_lock_init(&phy->lock);
310 316
311 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { 317 if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
312 match = of_match_device(of_match_ptr(ti_pipe3_id_table), 318 match = of_match_device(of_match_ptr(ti_pipe3_id_table),
@@ -333,21 +339,24 @@ static int ti_pipe3_probe(struct platform_device *pdev)
333 } 339 }
334 } 340 }
335 341
342 phy->refclk = devm_clk_get(phy->dev, "refclk");
343 if (IS_ERR(phy->refclk)) {
344 dev_err(&pdev->dev, "unable to get refclk\n");
345 /* older DTBs have missing refclk in SATA PHY
346 * so don't bail out in case of SATA PHY.
347 */
348 if (!of_device_is_compatible(node, "ti,phy-pipe3-sata"))
349 return PTR_ERR(phy->refclk);
350 }
351
336 if (!of_device_is_compatible(node, "ti,phy-pipe3-sata")) { 352 if (!of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
337 phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); 353 phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
338 if (IS_ERR(phy->wkupclk)) { 354 if (IS_ERR(phy->wkupclk)) {
339 dev_err(&pdev->dev, "unable to get wkupclk\n"); 355 dev_err(&pdev->dev, "unable to get wkupclk\n");
340 return PTR_ERR(phy->wkupclk); 356 return PTR_ERR(phy->wkupclk);
341 } 357 }
342
343 phy->refclk = devm_clk_get(phy->dev, "refclk");
344 if (IS_ERR(phy->refclk)) {
345 dev_err(&pdev->dev, "unable to get refclk\n");
346 return PTR_ERR(phy->refclk);
347 }
348 } else { 358 } else {
349 phy->wkupclk = ERR_PTR(-ENODEV); 359 phy->wkupclk = ERR_PTR(-ENODEV);
350 phy->refclk = ERR_PTR(-ENODEV);
351 } 360 }
352 361
353 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { 362 if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
@@ -426,33 +435,42 @@ static int ti_pipe3_remove(struct platform_device *pdev)
426} 435}
427 436
428#ifdef CONFIG_PM 437#ifdef CONFIG_PM
429 438static int ti_pipe3_enable_refclk(struct ti_pipe3 *phy)
430static int ti_pipe3_runtime_suspend(struct device *dev)
431{ 439{
432 struct ti_pipe3 *phy = dev_get_drvdata(dev); 440 if (!IS_ERR(phy->refclk) && !phy->refclk_enabled) {
441 int ret;
433 442
434 if (!IS_ERR(phy->wkupclk)) 443 ret = clk_prepare_enable(phy->refclk);
435 clk_disable_unprepare(phy->wkupclk); 444 if (ret) {
445 dev_err(phy->dev, "Failed to enable refclk %d\n", ret);
446 return ret;
447 }
448 phy->refclk_enabled = true;
449 }
450
451 return 0;
452}
453
454static void ti_pipe3_disable_refclk(struct ti_pipe3 *phy)
455{
436 if (!IS_ERR(phy->refclk)) 456 if (!IS_ERR(phy->refclk))
437 clk_disable_unprepare(phy->refclk); 457 clk_disable_unprepare(phy->refclk);
438 if (!IS_ERR(phy->div_clk))
439 clk_disable_unprepare(phy->div_clk);
440 458
441 return 0; 459 phy->refclk_enabled = false;
442} 460}
443 461
444static int ti_pipe3_runtime_resume(struct device *dev) 462static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
445{ 463{
446 u32 ret = 0; 464 int ret = 0;
447 struct ti_pipe3 *phy = dev_get_drvdata(dev); 465 unsigned long flags;
448 466
449 if (!IS_ERR(phy->refclk)) { 467 spin_lock_irqsave(&phy->lock, flags);
450 ret = clk_prepare_enable(phy->refclk); 468 if (phy->enabled)
451 if (ret) { 469 goto err1;
452 dev_err(phy->dev, "Failed to enable refclk %d\n", ret); 470
453 goto err1; 471 ret = ti_pipe3_enable_refclk(phy);
454 } 472 if (ret)
455 } 473 goto err1;
456 474
457 if (!IS_ERR(phy->wkupclk)) { 475 if (!IS_ERR(phy->wkupclk)) {
458 ret = clk_prepare_enable(phy->wkupclk); 476 ret = clk_prepare_enable(phy->wkupclk);
@@ -469,6 +487,9 @@ static int ti_pipe3_runtime_resume(struct device *dev)
469 goto err3; 487 goto err3;
470 } 488 }
471 } 489 }
490
491 phy->enabled = true;
492 spin_unlock_irqrestore(&phy->lock, flags);
472 return 0; 493 return 0;
473 494
474err3: 495err3:
@@ -479,20 +500,80 @@ err2:
479 if (!IS_ERR(phy->refclk)) 500 if (!IS_ERR(phy->refclk))
480 clk_disable_unprepare(phy->refclk); 501 clk_disable_unprepare(phy->refclk);
481 502
503 ti_pipe3_disable_refclk(phy);
482err1: 504err1:
505 spin_unlock_irqrestore(&phy->lock, flags);
483 return ret; 506 return ret;
484} 507}
485 508
509static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy)
510{
511 unsigned long flags;
512
513 spin_lock_irqsave(&phy->lock, flags);
514 if (!phy->enabled) {
515 spin_unlock_irqrestore(&phy->lock, flags);
516 return;
517 }
518
519 if (!IS_ERR(phy->wkupclk))
520 clk_disable_unprepare(phy->wkupclk);
521 /* Don't disable refclk for SATA PHY due to Errata i783 */
522 if (!of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata"))
523 ti_pipe3_disable_refclk(phy);
524 if (!IS_ERR(phy->div_clk))
525 clk_disable_unprepare(phy->div_clk);
526 phy->enabled = false;
527 spin_unlock_irqrestore(&phy->lock, flags);
528}
529
530static int ti_pipe3_runtime_suspend(struct device *dev)
531{
532 struct ti_pipe3 *phy = dev_get_drvdata(dev);
533
534 ti_pipe3_disable_clocks(phy);
535 return 0;
536}
537
538static int ti_pipe3_runtime_resume(struct device *dev)
539{
540 struct ti_pipe3 *phy = dev_get_drvdata(dev);
541 int ret = 0;
542
543 ret = ti_pipe3_enable_clocks(phy);
544 return ret;
545}
546
547static int ti_pipe3_suspend(struct device *dev)
548{
549 struct ti_pipe3 *phy = dev_get_drvdata(dev);
550
551 ti_pipe3_disable_clocks(phy);
552 return 0;
553}
554
555static int ti_pipe3_resume(struct device *dev)
556{
557 struct ti_pipe3 *phy = dev_get_drvdata(dev);
558 int ret;
559
560 ret = ti_pipe3_enable_clocks(phy);
561 if (ret)
562 return ret;
563
564 pm_runtime_disable(dev);
565 pm_runtime_set_active(dev);
566 pm_runtime_enable(dev);
567 return 0;
568}
569#endif
570
486static const struct dev_pm_ops ti_pipe3_pm_ops = { 571static const struct dev_pm_ops ti_pipe3_pm_ops = {
487 SET_RUNTIME_PM_OPS(ti_pipe3_runtime_suspend, 572 SET_RUNTIME_PM_OPS(ti_pipe3_runtime_suspend,
488 ti_pipe3_runtime_resume, NULL) 573 ti_pipe3_runtime_resume, NULL)
574 SET_SYSTEM_SLEEP_PM_OPS(ti_pipe3_suspend, ti_pipe3_resume)
489}; 575};
490 576
491#define DEV_PM_OPS (&ti_pipe3_pm_ops)
492#else
493#define DEV_PM_OPS NULL
494#endif
495
496#ifdef CONFIG_OF 577#ifdef CONFIG_OF
497static const struct of_device_id ti_pipe3_id_table[] = { 578static const struct of_device_id ti_pipe3_id_table[] = {
498 { 579 {
@@ -520,7 +601,7 @@ static struct platform_driver ti_pipe3_driver = {
520 .remove = ti_pipe3_remove, 601 .remove = ti_pipe3_remove,
521 .driver = { 602 .driver = {
522 .name = "ti-pipe3", 603 .name = "ti-pipe3",
523 .pm = DEV_PM_OPS, 604 .pm = &ti_pipe3_pm_ops,
524 .of_match_table = of_match_ptr(ti_pipe3_id_table), 605 .of_match_table = of_match_ptr(ti_pipe3_id_table),
525 }, 606 },
526}; 607};
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 546a17e8ad5b..e78720b59d67 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1091,6 +1091,7 @@ static int acm_probe(struct usb_interface *intf,
1091 unsigned long quirks; 1091 unsigned long quirks;
1092 int num_rx_buf; 1092 int num_rx_buf;
1093 int i; 1093 int i;
1094 unsigned int elength = 0;
1094 int combined_interfaces = 0; 1095 int combined_interfaces = 0;
1095 struct device *tty_dev; 1096 struct device *tty_dev;
1096 int rv = -ENOMEM; 1097 int rv = -ENOMEM;
@@ -1136,9 +1137,12 @@ static int acm_probe(struct usb_interface *intf,
1136 dev_err(&intf->dev, "skipping garbage\n"); 1137 dev_err(&intf->dev, "skipping garbage\n");
1137 goto next_desc; 1138 goto next_desc;
1138 } 1139 }
1140 elength = buffer[0];
1139 1141
1140 switch (buffer[2]) { 1142 switch (buffer[2]) {
1141 case USB_CDC_UNION_TYPE: /* we've found it */ 1143 case USB_CDC_UNION_TYPE: /* we've found it */
1144 if (elength < sizeof(struct usb_cdc_union_desc))
1145 goto next_desc;
1142 if (union_header) { 1146 if (union_header) {
1143 dev_err(&intf->dev, "More than one " 1147 dev_err(&intf->dev, "More than one "
1144 "union descriptor, skipping ...\n"); 1148 "union descriptor, skipping ...\n");
@@ -1147,29 +1151,36 @@ static int acm_probe(struct usb_interface *intf,
1147 union_header = (struct usb_cdc_union_desc *)buffer; 1151 union_header = (struct usb_cdc_union_desc *)buffer;
1148 break; 1152 break;
1149 case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/ 1153 case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
1154 if (elength < sizeof(struct usb_cdc_country_functional_desc))
1155 goto next_desc;
1150 cfd = (struct usb_cdc_country_functional_desc *)buffer; 1156 cfd = (struct usb_cdc_country_functional_desc *)buffer;
1151 break; 1157 break;
1152 case USB_CDC_HEADER_TYPE: /* maybe check version */ 1158 case USB_CDC_HEADER_TYPE: /* maybe check version */
1153 break; /* for now we ignore it */ 1159 break; /* for now we ignore it */
1154 case USB_CDC_ACM_TYPE: 1160 case USB_CDC_ACM_TYPE:
1161 if (elength < 4)
1162 goto next_desc;
1155 ac_management_function = buffer[3]; 1163 ac_management_function = buffer[3];
1156 break; 1164 break;
1157 case USB_CDC_CALL_MANAGEMENT_TYPE: 1165 case USB_CDC_CALL_MANAGEMENT_TYPE:
1166 if (elength < 5)
1167 goto next_desc;
1158 call_management_function = buffer[3]; 1168 call_management_function = buffer[3];
1159 call_interface_num = buffer[4]; 1169 call_interface_num = buffer[4];
1160 break; 1170 break;
1161 default: 1171 default:
1162 /* there are LOTS more CDC descriptors that 1172 /*
1173 * there are LOTS more CDC descriptors that
1163 * could legitimately be found here. 1174 * could legitimately be found here.
1164 */ 1175 */
1165 dev_dbg(&intf->dev, "Ignoring descriptor: " 1176 dev_dbg(&intf->dev, "Ignoring descriptor: "
1166 "type %02x, length %d\n", 1177 "type %02x, length %ud\n",
1167 buffer[2], buffer[0]); 1178 buffer[2], elength);
1168 break; 1179 break;
1169 } 1180 }
1170next_desc: 1181next_desc:
1171 buflen -= buffer[0]; 1182 buflen -= elength;
1172 buffer += buffer[0]; 1183 buffer += elength;
1173 } 1184 }
1174 1185
1175 if (!union_header) { 1186 if (!union_header) {
@@ -1287,10 +1298,8 @@ made_compressed_probe:
1287 dev_dbg(&intf->dev, "interfaces are valid\n"); 1298 dev_dbg(&intf->dev, "interfaces are valid\n");
1288 1299
1289 acm = kzalloc(sizeof(struct acm), GFP_KERNEL); 1300 acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
1290 if (acm == NULL) { 1301 if (acm == NULL)
1291 dev_err(&intf->dev, "out of memory (acm kzalloc)\n");
1292 goto alloc_fail; 1302 goto alloc_fail;
1293 }
1294 1303
1295 minor = acm_alloc_minor(acm); 1304 minor = acm_alloc_minor(acm);
1296 if (minor == ACM_TTY_MINORS) { 1305 if (minor == ACM_TTY_MINORS) {
@@ -1329,42 +1338,32 @@ made_compressed_probe:
1329 acm->quirks = quirks; 1338 acm->quirks = quirks;
1330 1339
1331 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 1340 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
1332 if (!buf) { 1341 if (!buf)
1333 dev_err(&intf->dev, "out of memory (ctrl buffer alloc)\n");
1334 goto alloc_fail2; 1342 goto alloc_fail2;
1335 }
1336 acm->ctrl_buffer = buf; 1343 acm->ctrl_buffer = buf;
1337 1344
1338 if (acm_write_buffers_alloc(acm) < 0) { 1345 if (acm_write_buffers_alloc(acm) < 0)
1339 dev_err(&intf->dev, "out of memory (write buffer alloc)\n");
1340 goto alloc_fail4; 1346 goto alloc_fail4;
1341 }
1342 1347
1343 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL); 1348 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
1344 if (!acm->ctrlurb) { 1349 if (!acm->ctrlurb)
1345 dev_err(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
1346 goto alloc_fail5; 1350 goto alloc_fail5;
1347 } 1351
1348 for (i = 0; i < num_rx_buf; i++) { 1352 for (i = 0; i < num_rx_buf; i++) {
1349 struct acm_rb *rb = &(acm->read_buffers[i]); 1353 struct acm_rb *rb = &(acm->read_buffers[i]);
1350 struct urb *urb; 1354 struct urb *urb;
1351 1355
1352 rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL, 1356 rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
1353 &rb->dma); 1357 &rb->dma);
1354 if (!rb->base) { 1358 if (!rb->base)
1355 dev_err(&intf->dev, "out of memory "
1356 "(read bufs usb_alloc_coherent)\n");
1357 goto alloc_fail6; 1359 goto alloc_fail6;
1358 }
1359 rb->index = i; 1360 rb->index = i;
1360 rb->instance = acm; 1361 rb->instance = acm;
1361 1362
1362 urb = usb_alloc_urb(0, GFP_KERNEL); 1363 urb = usb_alloc_urb(0, GFP_KERNEL);
1363 if (!urb) { 1364 if (!urb)
1364 dev_err(&intf->dev,
1365 "out of memory (read urbs usb_alloc_urb)\n");
1366 goto alloc_fail6; 1365 goto alloc_fail6;
1367 } 1366
1368 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1367 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1369 urb->transfer_dma = rb->dma; 1368 urb->transfer_dma = rb->dma;
1370 if (acm->is_int_ep) { 1369 if (acm->is_int_ep) {
@@ -1389,11 +1388,8 @@ made_compressed_probe:
1389 struct acm_wb *snd = &(acm->wb[i]); 1388 struct acm_wb *snd = &(acm->wb[i]);
1390 1389
1391 snd->urb = usb_alloc_urb(0, GFP_KERNEL); 1390 snd->urb = usb_alloc_urb(0, GFP_KERNEL);
1392 if (snd->urb == NULL) { 1391 if (snd->urb == NULL)
1393 dev_err(&intf->dev,
1394 "out of memory (write urbs usb_alloc_urb)\n");
1395 goto alloc_fail7; 1392 goto alloc_fail7;
1396 }
1397 1393
1398 if (usb_endpoint_xfer_int(epwrite)) 1394 if (usb_endpoint_xfer_int(epwrite))
1399 usb_fill_int_urb(snd->urb, usb_dev, 1395 usb_fill_int_urb(snd->urb, usb_dev,
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 684ef70dc09d..506b969ea7fd 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -22,17 +22,25 @@
22 */ 22 */
23 23
24/* FIXME tune these based on pool statistics ... */ 24/* FIXME tune these based on pool statistics ... */
25static const size_t pool_max[HCD_BUFFER_POOLS] = { 25static size_t pool_max[HCD_BUFFER_POOLS] = {
26 /* platforms without dma-friendly caches might need to 26 32, 128, 512, 2048,
27 * prevent cacheline sharing...
28 */
29 32,
30 128,
31 512,
32 PAGE_SIZE / 2
33 /* bigger --> allocate pages */
34}; 27};
35 28
29void __init usb_init_pool_max(void)
30{
31 /*
32 * The pool_max values must never be smaller than
33 * ARCH_KMALLOC_MINALIGN.
34 */
35 if (ARCH_KMALLOC_MINALIGN <= 32)
36 ; /* Original value is okay */
37 else if (ARCH_KMALLOC_MINALIGN <= 64)
38 pool_max[0] = 64;
39 else if (ARCH_KMALLOC_MINALIGN <= 128)
40 pool_max[0] = 0; /* Don't use this pool */
41 else
42 BUILD_BUG(); /* We don't allow this */
43}
36 44
37/* SETUP primitives */ 45/* SETUP primitives */
38 46
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 0b59731c3021..66abdbcfbfa5 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1689,7 +1689,7 @@ static struct async *reap_as(struct usb_dev_state *ps)
1689 for (;;) { 1689 for (;;) {
1690 __set_current_state(TASK_INTERRUPTIBLE); 1690 __set_current_state(TASK_INTERRUPTIBLE);
1691 as = async_getcompleted(ps); 1691 as = async_getcompleted(ps);
1692 if (as) 1692 if (as || !connected(ps))
1693 break; 1693 break;
1694 if (signal_pending(current)) 1694 if (signal_pending(current))
1695 break; 1695 break;
@@ -1712,7 +1712,7 @@ static int proc_reapurb(struct usb_dev_state *ps, void __user *arg)
1712 } 1712 }
1713 if (signal_pending(current)) 1713 if (signal_pending(current))
1714 return -EINTR; 1714 return -EINTR;
1715 return -EIO; 1715 return -ENODEV;
1716} 1716}
1717 1717
1718static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) 1718static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
@@ -1721,10 +1721,11 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
1721 struct async *as; 1721 struct async *as;
1722 1722
1723 as = async_getcompleted(ps); 1723 as = async_getcompleted(ps);
1724 retval = -EAGAIN;
1725 if (as) { 1724 if (as) {
1726 retval = processcompl(as, (void __user * __user *)arg); 1725 retval = processcompl(as, (void __user * __user *)arg);
1727 free_async(as); 1726 free_async(as);
1727 } else {
1728 retval = (connected(ps) ? -EAGAIN : -ENODEV);
1728 } 1729 }
1729 return retval; 1730 return retval;
1730} 1731}
@@ -1854,7 +1855,7 @@ static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg)
1854 } 1855 }
1855 if (signal_pending(current)) 1856 if (signal_pending(current))
1856 return -EINTR; 1857 return -EINTR;
1857 return -EIO; 1858 return -ENODEV;
1858} 1859}
1859 1860
1860static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg) 1861static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg)
@@ -1862,11 +1863,12 @@ static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *ar
1862 int retval; 1863 int retval;
1863 struct async *as; 1864 struct async *as;
1864 1865
1865 retval = -EAGAIN;
1866 as = async_getcompleted(ps); 1866 as = async_getcompleted(ps);
1867 if (as) { 1867 if (as) {
1868 retval = processcompl_compat(as, (void __user * __user *)arg); 1868 retval = processcompl_compat(as, (void __user * __user *)arg);
1869 free_async(as); 1869 free_async(as);
1870 } else {
1871 retval = (connected(ps) ? -EAGAIN : -ENODEV);
1870 } 1872 }
1871 return retval; 1873 return retval;
1872} 1874}
@@ -2038,7 +2040,8 @@ static int proc_get_capabilities(struct usb_dev_state *ps, void __user *arg)
2038{ 2040{
2039 __u32 caps; 2041 __u32 caps;
2040 2042
2041 caps = USBDEVFS_CAP_ZERO_PACKET | USBDEVFS_CAP_NO_PACKET_SIZE_LIM; 2043 caps = USBDEVFS_CAP_ZERO_PACKET | USBDEVFS_CAP_NO_PACKET_SIZE_LIM |
2044 USBDEVFS_CAP_REAP_AFTER_DISCONNECT;
2042 if (!ps->dev->bus->no_stop_on_short) 2045 if (!ps->dev->bus->no_stop_on_short)
2043 caps |= USBDEVFS_CAP_BULK_CONTINUATION; 2046 caps |= USBDEVFS_CAP_BULK_CONTINUATION;
2044 if (ps->dev->bus->sg_tablesize) 2047 if (ps->dev->bus->sg_tablesize)
@@ -2138,6 +2141,32 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2138 return -EPERM; 2141 return -EPERM;
2139 2142
2140 usb_lock_device(dev); 2143 usb_lock_device(dev);
2144
2145 /* Reap operations are allowed even after disconnection */
2146 switch (cmd) {
2147 case USBDEVFS_REAPURB:
2148 snoop(&dev->dev, "%s: REAPURB\n", __func__);
2149 ret = proc_reapurb(ps, p);
2150 goto done;
2151
2152 case USBDEVFS_REAPURBNDELAY:
2153 snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
2154 ret = proc_reapurbnonblock(ps, p);
2155 goto done;
2156
2157#ifdef CONFIG_COMPAT
2158 case USBDEVFS_REAPURB32:
2159 snoop(&dev->dev, "%s: REAPURB32\n", __func__);
2160 ret = proc_reapurb_compat(ps, p);
2161 goto done;
2162
2163 case USBDEVFS_REAPURBNDELAY32:
2164 snoop(&dev->dev, "%s: REAPURBNDELAY32\n", __func__);
2165 ret = proc_reapurbnonblock_compat(ps, p);
2166 goto done;
2167#endif
2168 }
2169
2141 if (!connected(ps)) { 2170 if (!connected(ps)) {
2142 usb_unlock_device(dev); 2171 usb_unlock_device(dev);
2143 return -ENODEV; 2172 return -ENODEV;
@@ -2231,16 +2260,6 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2231 inode->i_mtime = CURRENT_TIME; 2260 inode->i_mtime = CURRENT_TIME;
2232 break; 2261 break;
2233 2262
2234 case USBDEVFS_REAPURB32:
2235 snoop(&dev->dev, "%s: REAPURB32\n", __func__);
2236 ret = proc_reapurb_compat(ps, p);
2237 break;
2238
2239 case USBDEVFS_REAPURBNDELAY32:
2240 snoop(&dev->dev, "%s: REAPURBNDELAY32\n", __func__);
2241 ret = proc_reapurbnonblock_compat(ps, p);
2242 break;
2243
2244 case USBDEVFS_IOCTL32: 2263 case USBDEVFS_IOCTL32:
2245 snoop(&dev->dev, "%s: IOCTL32\n", __func__); 2264 snoop(&dev->dev, "%s: IOCTL32\n", __func__);
2246 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); 2265 ret = proc_ioctl_compat(ps, ptr_to_compat(p));
@@ -2252,16 +2271,6 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2252 ret = proc_unlinkurb(ps, p); 2271 ret = proc_unlinkurb(ps, p);
2253 break; 2272 break;
2254 2273
2255 case USBDEVFS_REAPURB:
2256 snoop(&dev->dev, "%s: REAPURB\n", __func__);
2257 ret = proc_reapurb(ps, p);
2258 break;
2259
2260 case USBDEVFS_REAPURBNDELAY:
2261 snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
2262 ret = proc_reapurbnonblock(ps, p);
2263 break;
2264
2265 case USBDEVFS_DISCSIGNAL: 2274 case USBDEVFS_DISCSIGNAL:
2266 snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__); 2275 snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__);
2267 ret = proc_disconnectsignal(ps, p); 2276 ret = proc_disconnectsignal(ps, p);
@@ -2304,6 +2313,8 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2304 ret = proc_free_streams(ps, p); 2313 ret = proc_free_streams(ps, p);
2305 break; 2314 break;
2306 } 2315 }
2316
2317 done:
2307 usb_unlock_device(dev); 2318 usb_unlock_device(dev);
2308 if (ret >= 0) 2319 if (ret >= 0)
2309 inode->i_atime = CURRENT_TIME; 2320 inode->i_atime = CURRENT_TIME;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 874dec31a111..818369afff63 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -275,21 +275,6 @@ static int usb_unbind_device(struct device *dev)
275 return 0; 275 return 0;
276} 276}
277 277
278/*
279 * Cancel any pending scheduled resets
280 *
281 * [see usb_queue_reset_device()]
282 *
283 * Called after unconfiguring / when releasing interfaces. See
284 * comments in __usb_queue_reset_device() regarding
285 * udev->reset_running.
286 */
287static void usb_cancel_queued_reset(struct usb_interface *iface)
288{
289 if (iface->reset_running == 0)
290 cancel_work_sync(&iface->reset_ws);
291}
292
293/* called from driver core with dev locked */ 278/* called from driver core with dev locked */
294static int usb_probe_interface(struct device *dev) 279static int usb_probe_interface(struct device *dev)
295{ 280{
@@ -380,7 +365,6 @@ static int usb_probe_interface(struct device *dev)
380 usb_set_intfdata(intf, NULL); 365 usb_set_intfdata(intf, NULL);
381 intf->needs_remote_wakeup = 0; 366 intf->needs_remote_wakeup = 0;
382 intf->condition = USB_INTERFACE_UNBOUND; 367 intf->condition = USB_INTERFACE_UNBOUND;
383 usb_cancel_queued_reset(intf);
384 368
385 /* If the LPM disable succeeded, balance the ref counts. */ 369 /* If the LPM disable succeeded, balance the ref counts. */
386 if (!lpm_disable_error) 370 if (!lpm_disable_error)
@@ -425,7 +409,6 @@ static int usb_unbind_interface(struct device *dev)
425 usb_disable_interface(udev, intf, false); 409 usb_disable_interface(udev, intf, false);
426 410
427 driver->disconnect(intf); 411 driver->disconnect(intf);
428 usb_cancel_queued_reset(intf);
429 412
430 /* Free streams */ 413 /* Free streams */
431 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 414 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
@@ -1797,6 +1780,18 @@ static int autosuspend_check(struct usb_device *udev)
1797 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n"); 1780 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n");
1798 return -EOPNOTSUPP; 1781 return -EOPNOTSUPP;
1799 } 1782 }
1783
1784 /*
1785 * If the device is a direct child of the root hub and the HCD
1786 * doesn't handle wakeup requests, don't allow autosuspend when
1787 * wakeup is needed.
1788 */
1789 if (w && udev->parent == udev->bus->root_hub &&
1790 bus_to_hcd(udev->bus)->cant_recv_wakeups) {
1791 dev_dbg(&udev->dev, "HCD doesn't handle wakeup requests\n");
1792 return -EOPNOTSUPP;
1793 }
1794
1800 udev->do_remote_wakeup = w; 1795 udev->do_remote_wakeup = w;
1801 return 0; 1796 return 0;
1802} 1797}
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 11cee55ae397..45a915ccd71c 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1618,6 +1618,7 @@ static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status)
1618int usb_hcd_unlink_urb (struct urb *urb, int status) 1618int usb_hcd_unlink_urb (struct urb *urb, int status)
1619{ 1619{
1620 struct usb_hcd *hcd; 1620 struct usb_hcd *hcd;
1621 struct usb_device *udev = urb->dev;
1621 int retval = -EIDRM; 1622 int retval = -EIDRM;
1622 unsigned long flags; 1623 unsigned long flags;
1623 1624
@@ -1629,20 +1630,19 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
1629 spin_lock_irqsave(&hcd_urb_unlink_lock, flags); 1630 spin_lock_irqsave(&hcd_urb_unlink_lock, flags);
1630 if (atomic_read(&urb->use_count) > 0) { 1631 if (atomic_read(&urb->use_count) > 0) {
1631 retval = 0; 1632 retval = 0;
1632 usb_get_dev(urb->dev); 1633 usb_get_dev(udev);
1633 } 1634 }
1634 spin_unlock_irqrestore(&hcd_urb_unlink_lock, flags); 1635 spin_unlock_irqrestore(&hcd_urb_unlink_lock, flags);
1635 if (retval == 0) { 1636 if (retval == 0) {
1636 hcd = bus_to_hcd(urb->dev->bus); 1637 hcd = bus_to_hcd(urb->dev->bus);
1637 retval = unlink1(hcd, urb, status); 1638 retval = unlink1(hcd, urb, status);
1638 usb_put_dev(urb->dev); 1639 if (retval == 0)
1640 retval = -EINPROGRESS;
1641 else if (retval != -EIDRM && retval != -EBUSY)
1642 dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n",
1643 urb, retval);
1644 usb_put_dev(udev);
1639 } 1645 }
1640
1641 if (retval == 0)
1642 retval = -EINPROGRESS;
1643 else if (retval != -EIDRM && retval != -EBUSY)
1644 dev_dbg(&urb->dev->dev, "hcd_unlink_urb %p fail %d\n",
1645 urb, retval);
1646 return retval; 1646 return retval;
1647} 1647}
1648 1648
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index aeb50bb6ba9c..3e9c4d477d1a 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4655,9 +4655,13 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4655 if (!(portstatus & USB_PORT_STAT_CONNECTION) || 4655 if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
4656 test_bit(port1, hub->removed_bits)) { 4656 test_bit(port1, hub->removed_bits)) {
4657 4657
4658 /* maybe switch power back on (e.g. root hub was reset) */ 4658 /*
4659 * maybe switch power back on (e.g. root hub was reset)
4660 * but only if the port isn't owned by someone else.
4661 */
4659 if (hub_is_port_power_switchable(hub) 4662 if (hub_is_port_power_switchable(hub)
4660 && !port_is_power_on(hub, portstatus)) 4663 && !port_is_power_on(hub, portstatus)
4664 && !port_dev->port_owner)
4661 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 4665 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
4662 4666
4663 if (portstatus & USB_PORT_STAT_ENABLE) 4667 if (portstatus & USB_PORT_STAT_ENABLE)
@@ -5589,26 +5593,19 @@ EXPORT_SYMBOL_GPL(usb_reset_device);
5589 * possible; depending on how the driver attached to each interface 5593 * possible; depending on how the driver attached to each interface
5590 * handles ->pre_reset(), the second reset might happen or not. 5594 * handles ->pre_reset(), the second reset might happen or not.
5591 * 5595 *
5592 * - If a driver is unbound and it had a pending reset, the reset will 5596 * - If the reset is delayed so long that the interface is unbound from
5593 * be cancelled. 5597 * its driver, the reset will be skipped.
5594 *
5595 * - This function can be called during .probe() or .disconnect()
5596 * times. On return from .disconnect(), any pending resets will be
5597 * cancelled.
5598 *
5599 * There is no no need to lock/unlock the @reset_ws as schedule_work()
5600 * does its own.
5601 * 5598 *
5602 * NOTE: We don't do any reference count tracking because it is not 5599 * - This function can be called during .probe(). It can also be called
5603 * needed. The lifecycle of the work_struct is tied to the 5600 * during .disconnect(), but doing so is pointless because the reset
5604 * usb_interface. Before destroying the interface we cancel the 5601 * will not occur. If you really want to reset the device during
5605 * work_struct, so the fact that work_struct is queued and or 5602 * .disconnect(), call usb_reset_device() directly -- but watch out
5606 * running means the interface (and thus, the device) exist and 5603 * for nested unbinding issues!
5607 * are referenced.
5608 */ 5604 */
5609void usb_queue_reset_device(struct usb_interface *iface) 5605void usb_queue_reset_device(struct usb_interface *iface)
5610{ 5606{
5611 schedule_work(&iface->reset_ws); 5607 if (schedule_work(&iface->reset_ws))
5608 usb_get_intf(iface);
5612} 5609}
5613EXPORT_SYMBOL_GPL(usb_queue_reset_device); 5610EXPORT_SYMBOL_GPL(usb_queue_reset_device);
5614 5611
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f7b7713cfb2a..f368d2053da5 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1551,6 +1551,7 @@ static void usb_release_interface(struct device *dev)
1551 altsetting_to_usb_interface_cache(intf->altsetting); 1551 altsetting_to_usb_interface_cache(intf->altsetting);
1552 1552
1553 kref_put(&intfc->ref, usb_release_interface_cache); 1553 kref_put(&intfc->ref, usb_release_interface_cache);
1554 usb_put_dev(interface_to_usbdev(intf));
1554 kfree(intf); 1555 kfree(intf);
1555} 1556}
1556 1557
@@ -1626,24 +1627,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev,
1626 1627
1627/* 1628/*
1628 * Internal function to queue a device reset 1629 * Internal function to queue a device reset
1629 *
1630 * This is initialized into the workstruct in 'struct
1631 * usb_device->reset_ws' that is launched by
1632 * message.c:usb_set_configuration() when initializing each 'struct
1633 * usb_interface'.
1634 *
1635 * It is safe to get the USB device without reference counts because
1636 * the life cycle of @iface is bound to the life cycle of @udev. Then,
1637 * this function will be ran only if @iface is alive (and before
1638 * freeing it any scheduled instances of it will have been cancelled).
1639 *
1640 * We need to set a flag (usb_dev->reset_running) because when we call
1641 * the reset, the interfaces might be unbound. The current interface
1642 * cannot try to remove the queued work as it would cause a deadlock
1643 * (you cannot remove your work from within your executing
1644 * workqueue). This flag lets it know, so that
1645 * usb_cancel_queued_reset() doesn't try to do it.
1646 *
1647 * See usb_queue_reset_device() for more details 1630 * See usb_queue_reset_device() for more details
1648 */ 1631 */
1649static void __usb_queue_reset_device(struct work_struct *ws) 1632static void __usb_queue_reset_device(struct work_struct *ws)
@@ -1655,11 +1638,10 @@ static void __usb_queue_reset_device(struct work_struct *ws)
1655 1638
1656 rc = usb_lock_device_for_reset(udev, iface); 1639 rc = usb_lock_device_for_reset(udev, iface);
1657 if (rc >= 0) { 1640 if (rc >= 0) {
1658 iface->reset_running = 1;
1659 usb_reset_device(udev); 1641 usb_reset_device(udev);
1660 iface->reset_running = 0;
1661 usb_unlock_device(udev); 1642 usb_unlock_device(udev);
1662 } 1643 }
1644 usb_put_intf(iface); /* Undo _get_ in usb_queue_reset_device() */
1663} 1645}
1664 1646
1665 1647
@@ -1854,6 +1836,7 @@ free_interfaces:
1854 dev_set_name(&intf->dev, "%d-%s:%d.%d", 1836 dev_set_name(&intf->dev, "%d-%s:%d.%d",
1855 dev->bus->busnum, dev->devpath, 1837 dev->bus->busnum, dev->devpath,
1856 configuration, alt->desc.bInterfaceNumber); 1838 configuration, alt->desc.bInterfaceNumber);
1839 usb_get_dev(dev);
1857 } 1840 }
1858 kfree(new_interfaces); 1841 kfree(new_interfaces);
1859 1842
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 2a92b97f0144..b1fb9aef0f5b 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1049,6 +1049,7 @@ static int __init usb_init(void)
1049 pr_info("%s: USB support disabled\n", usbcore_name); 1049 pr_info("%s: USB support disabled\n", usbcore_name);
1050 return 0; 1050 return 0;
1051 } 1051 }
1052 usb_init_pool_max();
1052 1053
1053 retval = usb_debugfs_init(); 1054 retval = usb_debugfs_init();
1054 if (retval) 1055 if (retval)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index a0cd9db6f4cd..c5fd43d2513f 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1622,7 +1622,9 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
1622 hub_desc->bDescLength = 9; 1622 hub_desc->bDescLength = 9;
1623 hub_desc->bDescriptorType = 0x29; 1623 hub_desc->bDescriptorType = 0x29;
1624 hub_desc->bNbrPorts = 1; 1624 hub_desc->bNbrPorts = 1;
1625 hub_desc->wHubCharacteristics = cpu_to_le16(0x08); 1625 hub_desc->wHubCharacteristics =
1626 cpu_to_le16(HUB_CHAR_COMMON_LPSM |
1627 HUB_CHAR_INDV_PORT_OCPM);
1626 hub_desc->bPwrOn2PwrGood = 1; 1628 hub_desc->bPwrOn2PwrGood = 1;
1627 hub_desc->bHubContrCurrent = 0; 1629 hub_desc->bHubContrCurrent = 0;
1628 hub_desc->u.hs.DeviceRemovable[0] = 0; 1630 hub_desc->u.hs.DeviceRemovable[0] = 0;
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index c6dfef8c7bbc..5c8f4effb62a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -521,7 +521,6 @@ static int bdc_remove(struct platform_device *pdev)
521static struct platform_driver bdc_driver = { 521static struct platform_driver bdc_driver = {
522 .driver = { 522 .driver = {
523 .name = BRCM_BDC_NAME, 523 .name = BRCM_BDC_NAME,
524 .owner = THIS_MODULE
525 }, 524 },
526 .probe = bdc_probe, 525 .probe = bdc_probe,
527 .remove = bdc_remove, 526 .remove = bdc_remove,
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 9c598801404c..270c1ec650fa 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1924,7 +1924,9 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc)
1924 memset(desc, 0, sizeof *desc); 1924 memset(desc, 0, sizeof *desc);
1925 desc->bDescriptorType = 0x2a; 1925 desc->bDescriptorType = 0x2a;
1926 desc->bDescLength = 12; 1926 desc->bDescLength = 12;
1927 desc->wHubCharacteristics = cpu_to_le16(0x0001); 1927 desc->wHubCharacteristics = cpu_to_le16(
1928 HUB_CHAR_INDV_PORT_LPSM |
1929 HUB_CHAR_COMMON_OCPM);
1928 desc->bNbrPorts = 1; 1930 desc->bNbrPorts = 1;
1929 desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/ 1931 desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/
1930 desc->u.ss.DeviceRemovable = 0xffff; 1932 desc->u.ss.DeviceRemovable = 0xffff;
@@ -1935,7 +1937,9 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
1935 memset(desc, 0, sizeof *desc); 1937 memset(desc, 0, sizeof *desc);
1936 desc->bDescriptorType = 0x29; 1938 desc->bDescriptorType = 0x29;
1937 desc->bDescLength = 9; 1939 desc->bDescLength = 9;
1938 desc->wHubCharacteristics = cpu_to_le16(0x0001); 1940 desc->wHubCharacteristics = cpu_to_le16(
1941 HUB_CHAR_INDV_PORT_LPSM |
1942 HUB_CHAR_COMMON_OCPM);
1939 desc->bNbrPorts = 1; 1943 desc->bNbrPorts = 1;
1940 desc->u.hs.DeviceRemovable[0] = 0xff; 1944 desc->u.hs.DeviceRemovable[0] = 0xff;
1941 desc->u.hs.DeviceRemovable[1] = 0xff; 1945 desc->u.hs.DeviceRemovable[1] = 0xff;
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 56a88506febe..663f7908b15c 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -27,44 +27,66 @@
27#define DRIVER_DESC "EHCI Atmel driver" 27#define DRIVER_DESC "EHCI Atmel driver"
28 28
29static const char hcd_name[] = "ehci-atmel"; 29static const char hcd_name[] = "ehci-atmel";
30static struct hc_driver __read_mostly ehci_atmel_hc_driver;
31 30
32/* interface and function clocks */ 31/* interface and function clocks */
33static struct clk *iclk, *fclk, *uclk; 32#define hcd_to_atmel_ehci_priv(h) \
34static int clocked; 33 ((struct atmel_ehci_priv *)hcd_to_ehci(h)->priv)
34
35struct atmel_ehci_priv {
36 struct clk *iclk;
37 struct clk *fclk;
38 struct clk *uclk;
39 bool clocked;
40};
41
42static struct hc_driver __read_mostly ehci_atmel_hc_driver;
43
44static const struct ehci_driver_overrides ehci_atmel_drv_overrides __initconst = {
45 .extra_priv_size = sizeof(struct atmel_ehci_priv),
46};
35 47
36/*-------------------------------------------------------------------------*/ 48/*-------------------------------------------------------------------------*/
37 49
38static void atmel_start_clock(void) 50static void atmel_start_clock(struct atmel_ehci_priv *atmel_ehci)
39{ 51{
52 if (atmel_ehci->clocked)
53 return;
40 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 54 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
41 clk_set_rate(uclk, 48000000); 55 clk_set_rate(atmel_ehci->uclk, 48000000);
42 clk_prepare_enable(uclk); 56 clk_prepare_enable(atmel_ehci->uclk);
43 } 57 }
44 clk_prepare_enable(iclk); 58 clk_prepare_enable(atmel_ehci->iclk);
45 clk_prepare_enable(fclk); 59 clk_prepare_enable(atmel_ehci->fclk);
46 clocked = 1; 60 atmel_ehci->clocked = true;
47} 61}
48 62
49static void atmel_stop_clock(void) 63static void atmel_stop_clock(struct atmel_ehci_priv *atmel_ehci)
50{ 64{
51 clk_disable_unprepare(fclk); 65 if (!atmel_ehci->clocked)
52 clk_disable_unprepare(iclk); 66 return;
67 clk_disable_unprepare(atmel_ehci->fclk);
68 clk_disable_unprepare(atmel_ehci->iclk);
53 if (IS_ENABLED(CONFIG_COMMON_CLK)) 69 if (IS_ENABLED(CONFIG_COMMON_CLK))
54 clk_disable_unprepare(uclk); 70 clk_disable_unprepare(atmel_ehci->uclk);
55 clocked = 0; 71 atmel_ehci->clocked = false;
56} 72}
57 73
58static void atmel_start_ehci(struct platform_device *pdev) 74static void atmel_start_ehci(struct platform_device *pdev)
59{ 75{
76 struct usb_hcd *hcd = platform_get_drvdata(pdev);
77 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
78
60 dev_dbg(&pdev->dev, "start\n"); 79 dev_dbg(&pdev->dev, "start\n");
61 atmel_start_clock(); 80 atmel_start_clock(atmel_ehci);
62} 81}
63 82
64static void atmel_stop_ehci(struct platform_device *pdev) 83static void atmel_stop_ehci(struct platform_device *pdev)
65{ 84{
85 struct usb_hcd *hcd = platform_get_drvdata(pdev);
86 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
87
66 dev_dbg(&pdev->dev, "stop\n"); 88 dev_dbg(&pdev->dev, "stop\n");
67 atmel_stop_clock(); 89 atmel_stop_clock(atmel_ehci);
68} 90}
69 91
70/*-------------------------------------------------------------------------*/ 92/*-------------------------------------------------------------------------*/
@@ -75,6 +97,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
75 const struct hc_driver *driver = &ehci_atmel_hc_driver; 97 const struct hc_driver *driver = &ehci_atmel_hc_driver;
76 struct resource *res; 98 struct resource *res;
77 struct ehci_hcd *ehci; 99 struct ehci_hcd *ehci;
100 struct atmel_ehci_priv *atmel_ehci;
78 int irq; 101 int irq;
79 int retval; 102 int retval;
80 103
@@ -105,6 +128,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
105 retval = -ENOMEM; 128 retval = -ENOMEM;
106 goto fail_create_hcd; 129 goto fail_create_hcd;
107 } 130 }
131 atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
108 132
109 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 133 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
110 hcd->regs = devm_ioremap_resource(&pdev->dev, res); 134 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -116,23 +140,23 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
116 hcd->rsrc_start = res->start; 140 hcd->rsrc_start = res->start;
117 hcd->rsrc_len = resource_size(res); 141 hcd->rsrc_len = resource_size(res);
118 142
119 iclk = devm_clk_get(&pdev->dev, "ehci_clk"); 143 atmel_ehci->iclk = devm_clk_get(&pdev->dev, "ehci_clk");
120 if (IS_ERR(iclk)) { 144 if (IS_ERR(atmel_ehci->iclk)) {
121 dev_err(&pdev->dev, "Error getting interface clock\n"); 145 dev_err(&pdev->dev, "Error getting interface clock\n");
122 retval = -ENOENT; 146 retval = -ENOENT;
123 goto fail_request_resource; 147 goto fail_request_resource;
124 } 148 }
125 fclk = devm_clk_get(&pdev->dev, "uhpck"); 149 atmel_ehci->fclk = devm_clk_get(&pdev->dev, "uhpck");
126 if (IS_ERR(fclk)) { 150 if (IS_ERR(atmel_ehci->fclk)) {
127 dev_err(&pdev->dev, "Error getting function clock\n"); 151 dev_err(&pdev->dev, "Error getting function clock\n");
128 retval = -ENOENT; 152 retval = -ENOENT;
129 goto fail_request_resource; 153 goto fail_request_resource;
130 } 154 }
131 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 155 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
132 uclk = devm_clk_get(&pdev->dev, "usb_clk"); 156 atmel_ehci->uclk = devm_clk_get(&pdev->dev, "usb_clk");
133 if (IS_ERR(uclk)) { 157 if (IS_ERR(atmel_ehci->uclk)) {
134 dev_err(&pdev->dev, "failed to get uclk\n"); 158 dev_err(&pdev->dev, "failed to get uclk\n");
135 retval = PTR_ERR(uclk); 159 retval = PTR_ERR(atmel_ehci->uclk);
136 goto fail_request_resource; 160 goto fail_request_resource;
137 } 161 }
138 } 162 }
@@ -169,11 +193,35 @@ static int ehci_atmel_drv_remove(struct platform_device *pdev)
169 usb_put_hcd(hcd); 193 usb_put_hcd(hcd);
170 194
171 atmel_stop_ehci(pdev); 195 atmel_stop_ehci(pdev);
172 fclk = iclk = NULL;
173 196
174 return 0; 197 return 0;
175} 198}
176 199
200#ifdef CONFIG_PM
201static int ehci_atmel_drv_suspend(struct device *dev)
202{
203 struct usb_hcd *hcd = dev_get_drvdata(dev);
204 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
205 int ret;
206
207 ret = ehci_suspend(hcd, false);
208 if (ret)
209 return ret;
210
211 atmel_stop_clock(atmel_ehci);
212 return 0;
213}
214
215static int ehci_atmel_drv_resume(struct device *dev)
216{
217 struct usb_hcd *hcd = dev_get_drvdata(dev);
218 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
219
220 atmel_start_clock(atmel_ehci);
221 return ehci_resume(hcd, false);
222}
223#endif
224
177#ifdef CONFIG_OF 225#ifdef CONFIG_OF
178static const struct of_device_id atmel_ehci_dt_ids[] = { 226static const struct of_device_id atmel_ehci_dt_ids[] = {
179 { .compatible = "atmel,at91sam9g45-ehci" }, 227 { .compatible = "atmel,at91sam9g45-ehci" },
@@ -183,12 +231,16 @@ static const struct of_device_id atmel_ehci_dt_ids[] = {
183MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids); 231MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
184#endif 232#endif
185 233
234static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend,
235 ehci_atmel_drv_resume);
236
186static struct platform_driver ehci_atmel_driver = { 237static struct platform_driver ehci_atmel_driver = {
187 .probe = ehci_atmel_drv_probe, 238 .probe = ehci_atmel_drv_probe,
188 .remove = ehci_atmel_drv_remove, 239 .remove = ehci_atmel_drv_remove,
189 .shutdown = usb_hcd_platform_shutdown, 240 .shutdown = usb_hcd_platform_shutdown,
190 .driver = { 241 .driver = {
191 .name = "atmel-ehci", 242 .name = "atmel-ehci",
243 .pm = &ehci_atmel_pm_ops,
192 .of_match_table = of_match_ptr(atmel_ehci_dt_ids), 244 .of_match_table = of_match_ptr(atmel_ehci_dt_ids),
193 }, 245 },
194}; 246};
@@ -199,7 +251,7 @@ static int __init ehci_atmel_init(void)
199 return -ENODEV; 251 return -ENODEV;
200 252
201 pr_info("%s: " DRIVER_DESC "\n", hcd_name); 253 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
202 ehci_init_driver(&ehci_atmel_hc_driver, NULL); 254 ehci_init_driver(&ehci_atmel_hc_driver, &ehci_atmel_drv_overrides);
203 return platform_driver_register(&ehci_atmel_driver); 255 return platform_driver_register(&ehci_atmel_driver);
204} 256}
205module_init(ehci_atmel_init); 257module_init(ehci_atmel_init);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index fb7bd0c7dc15..ab4eee3df97a 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -709,7 +709,6 @@ static struct platform_driver ehci_fsl_driver = {
709 .shutdown = usb_hcd_platform_shutdown, 709 .shutdown = usb_hcd_platform_shutdown,
710 .driver = { 710 .driver = {
711 .name = "fsl-ehci", 711 .name = "fsl-ehci",
712 .owner = THIS_MODULE,
713 .pm = EHCI_FSL_PM_OPS, 712 .pm = EHCI_FSL_PM_OPS,
714 }, 713 },
715}; 714};
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 495b6fbcbcd9..21650044b09e 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -187,7 +187,6 @@ static struct platform_driver ehci_grlib_driver = {
187 .shutdown = usb_hcd_platform_shutdown, 187 .shutdown = usb_hcd_platform_shutdown,
188 .driver = { 188 .driver = {
189 .name = "grlib-ehci", 189 .name = "grlib-ehci",
190 .owner = THIS_MODULE,
191 .of_match_table = ehci_hcd_grlib_of_match, 190 .of_match_table = ehci_hcd_grlib_of_match,
192 }, 191 },
193}; 192};
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 38bfeedae1d0..85e56d1abd23 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1110,7 +1110,7 @@ int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1110EXPORT_SYMBOL_GPL(ehci_suspend); 1110EXPORT_SYMBOL_GPL(ehci_suspend);
1111 1111
1112/* Returns 0 if power was preserved, 1 if power was lost */ 1112/* Returns 0 if power was preserved, 1 if power was lost */
1113int ehci_resume(struct usb_hcd *hcd, bool hibernated) 1113int ehci_resume(struct usb_hcd *hcd, bool force_reset)
1114{ 1114{
1115 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1115 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1116 1116
@@ -1124,12 +1124,12 @@ int ehci_resume(struct usb_hcd *hcd, bool hibernated)
1124 return 0; /* Controller is dead */ 1124 return 0; /* Controller is dead */
1125 1125
1126 /* 1126 /*
1127 * If CF is still set and we aren't resuming from hibernation 1127 * If CF is still set and reset isn't forced
1128 * then we maintained suspend power. 1128 * then we maintained suspend power.
1129 * Just undo the effect of ehci_suspend(). 1129 * Just undo the effect of ehci_suspend().
1130 */ 1130 */
1131 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF && 1131 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF &&
1132 !hibernated) { 1132 !force_reset) {
1133 int mask = INTR_MASK; 1133 int mask = INTR_MASK;
1134 1134
1135 ehci_prepare_ports_for_controller_resume(ehci); 1135 ehci_prepare_ports_for_controller_resume(ehci);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 118edb7bdca2..87cf86f38b36 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -700,15 +700,15 @@ ehci_hub_descriptor (
700 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 700 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
701 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 701 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
702 702
703 temp = 0x0008; /* per-port overcurrent reporting */ 703 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
704 if (HCS_PPC (ehci->hcs_params)) 704 if (HCS_PPC (ehci->hcs_params))
705 temp |= 0x0001; /* per-port power control */ 705 temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
706 else 706 else
707 temp |= 0x0002; /* no power switching */ 707 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
708#if 0 708#if 0
709// re-enable when we support USB_PORT_FEAT_INDICATOR below. 709// re-enable when we support USB_PORT_FEAT_INDICATOR below.
710 if (HCS_INDICATOR (ehci->hcs_params)) 710 if (HCS_INDICATOR (ehci->hcs_params))
711 temp |= 0x0080; /* per-port indicators (LEDs) */ 711 temp |= HUB_CHAR_PORTIND; /* per-port indicators (LEDs) */
712#endif 712#endif
713 desc->wHubCharacteristics = cpu_to_le16(temp); 713 desc->wHubCharacteristics = cpu_to_le16(temp);
714} 714}
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 851006a0d97b..965202138161 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -42,6 +42,20 @@ static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
42 pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC; 42 pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
43} 43}
44 44
45static const struct pci_device_id ci_hdrc_pci_id_table[] = {
46 { PCI_DEVICE(0x153F, 0x1004), },
47 { PCI_DEVICE(0x153F, 0x1006), },
48 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811), },
49 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), },
50 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), },
51 {}
52};
53
54static inline bool is_ci_hdrc_pci(struct pci_dev *pdev)
55{
56 return !!pci_match_id(ci_hdrc_pci_id_table, pdev);
57}
58
45/* 59/*
46 * 0x84 is the offset of in/out threshold register, 60 * 0x84 is the offset of in/out threshold register,
47 * and it is the same offset as the register of 'hostpc'. 61 * and it is the same offset as the register of 'hostpc'.
@@ -352,6 +366,13 @@ static const struct ehci_driver_overrides pci_overrides __initconst = {
352 366
353/*-------------------------------------------------------------------------*/ 367/*-------------------------------------------------------------------------*/
354 368
369static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
370{
371 if (is_ci_hdrc_pci(pdev))
372 return -ENODEV;
373 return usb_hcd_pci_probe(pdev, id);
374}
375
355/* PCI driver selection metadata; PCI hotplugging uses this */ 376/* PCI driver selection metadata; PCI hotplugging uses this */
356static const struct pci_device_id pci_ids [] = { { 377static const struct pci_device_id pci_ids [] = { {
357 /* handle any USB 2.0 EHCI controller */ 378 /* handle any USB 2.0 EHCI controller */
@@ -370,7 +391,7 @@ static struct pci_driver ehci_pci_driver = {
370 .name = (char *) hcd_name, 391 .name = (char *) hcd_name,
371 .id_table = pci_ids, 392 .id_table = pci_ids,
372 393
373 .probe = usb_hcd_pci_probe, 394 .probe = ehci_pci_probe,
374 .remove = usb_hcd_pci_remove, 395 .remove = usb_hcd_pci_remove,
375 .shutdown = usb_hcd_pci_shutdown, 396 .shutdown = usb_hcd_pci_shutdown,
376 397
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 8557803e6154..d8a75a51d6d4 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -43,7 +43,8 @@
43struct ehci_platform_priv { 43struct ehci_platform_priv {
44 struct clk *clks[EHCI_MAX_CLKS]; 44 struct clk *clks[EHCI_MAX_CLKS];
45 struct reset_control *rst; 45 struct reset_control *rst;
46 struct phy *phy; 46 struct phy **phys;
47 int num_phys;
47}; 48};
48 49
49static const char hcd_name[] = "ehci-platform"; 50static const char hcd_name[] = "ehci-platform";
@@ -78,7 +79,7 @@ static int ehci_platform_power_on(struct platform_device *dev)
78{ 79{
79 struct usb_hcd *hcd = platform_get_drvdata(dev); 80 struct usb_hcd *hcd = platform_get_drvdata(dev);
80 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); 81 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
81 int clk, ret; 82 int clk, ret, phy_num;
82 83
83 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) { 84 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) {
84 ret = clk_prepare_enable(priv->clks[clk]); 85 ret = clk_prepare_enable(priv->clks[clk]);
@@ -86,20 +87,28 @@ static int ehci_platform_power_on(struct platform_device *dev)
86 goto err_disable_clks; 87 goto err_disable_clks;
87 } 88 }
88 89
89 if (priv->phy) { 90 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
90 ret = phy_init(priv->phy); 91 if (priv->phys[phy_num]) {
91 if (ret) 92 ret = phy_init(priv->phys[phy_num]);
92 goto err_disable_clks; 93 if (ret)
93 94 goto err_exit_phy;
94 ret = phy_power_on(priv->phy); 95 ret = phy_power_on(priv->phys[phy_num]);
95 if (ret) 96 if (ret) {
96 goto err_exit_phy; 97 phy_exit(priv->phys[phy_num]);
98 goto err_exit_phy;
99 }
100 }
97 } 101 }
98 102
99 return 0; 103 return 0;
100 104
101err_exit_phy: 105err_exit_phy:
102 phy_exit(priv->phy); 106 while (--phy_num >= 0) {
107 if (priv->phys[phy_num]) {
108 phy_power_off(priv->phys[phy_num]);
109 phy_exit(priv->phys[phy_num]);
110 }
111 }
103err_disable_clks: 112err_disable_clks:
104 while (--clk >= 0) 113 while (--clk >= 0)
105 clk_disable_unprepare(priv->clks[clk]); 114 clk_disable_unprepare(priv->clks[clk]);
@@ -111,11 +120,13 @@ static void ehci_platform_power_off(struct platform_device *dev)
111{ 120{
112 struct usb_hcd *hcd = platform_get_drvdata(dev); 121 struct usb_hcd *hcd = platform_get_drvdata(dev);
113 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); 122 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
114 int clk; 123 int clk, phy_num;
115 124
116 if (priv->phy) { 125 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
117 phy_power_off(priv->phy); 126 if (priv->phys[phy_num]) {
118 phy_exit(priv->phy); 127 phy_power_off(priv->phys[phy_num]);
128 phy_exit(priv->phys[phy_num]);
129 }
119 } 130 }
120 131
121 for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--) 132 for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -143,7 +154,8 @@ static int ehci_platform_probe(struct platform_device *dev)
143 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); 154 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
144 struct ehci_platform_priv *priv; 155 struct ehci_platform_priv *priv;
145 struct ehci_hcd *ehci; 156 struct ehci_hcd *ehci;
146 int err, irq, clk = 0; 157 const char *phy_name;
158 int err, irq, phy_num, clk = 0;
147 159
148 if (usb_disabled()) 160 if (usb_disabled())
149 return -ENODEV; 161 return -ENODEV;
@@ -155,7 +167,8 @@ static int ehci_platform_probe(struct platform_device *dev)
155 if (!pdata) 167 if (!pdata)
156 pdata = &ehci_platform_defaults; 168 pdata = &ehci_platform_defaults;
157 169
158 err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); 170 err = dma_coerce_mask_and_coherent(&dev->dev,
171 pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
159 if (err) 172 if (err)
160 return err; 173 return err;
161 174
@@ -185,12 +198,42 @@ static int ehci_platform_probe(struct platform_device *dev)
185 if (of_property_read_bool(dev->dev.of_node, "big-endian")) 198 if (of_property_read_bool(dev->dev.of_node, "big-endian"))
186 ehci->big_endian_mmio = ehci->big_endian_desc = 1; 199 ehci->big_endian_mmio = ehci->big_endian_desc = 1;
187 200
188 priv->phy = devm_phy_get(&dev->dev, "usb"); 201 if (of_property_read_bool(dev->dev.of_node,
189 if (IS_ERR(priv->phy)) { 202 "needs-reset-on-resume"))
190 err = PTR_ERR(priv->phy); 203 pdata->reset_on_resume = 1;
191 if (err == -EPROBE_DEFER) 204
192 goto err_put_hcd; 205 priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
193 priv->phy = NULL; 206 "phys", "#phy-cells");
207 priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
208
209 priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
210 sizeof(struct phy *), GFP_KERNEL);
211 if (!priv->phys)
212 return -ENOMEM;
213
214 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
215 err = of_property_read_string_index(
216 dev->dev.of_node,
217 "phy-names", phy_num,
218 &phy_name);
219
220 if (err < 0) {
221 if (priv->num_phys > 1) {
222 dev_err(&dev->dev, "phy-names not provided");
223 goto err_put_hcd;
224 } else
225 phy_name = "usb";
226 }
227
228 priv->phys[phy_num] = devm_phy_get(&dev->dev,
229 phy_name);
230 if (IS_ERR(priv->phys[phy_num])) {
231 err = PTR_ERR(priv->phys[phy_num]);
232 if ((priv->num_phys > 1) ||
233 (err == -EPROBE_DEFER))
234 goto err_put_hcd;
235 priv->phys[phy_num] = NULL;
236 }
194 } 237 }
195 238
196 for (clk = 0; clk < EHCI_MAX_CLKS; clk++) { 239 for (clk = 0; clk < EHCI_MAX_CLKS; clk++) {
@@ -340,7 +383,7 @@ static int ehci_platform_resume(struct device *dev)
340 return err; 383 return err;
341 } 384 }
342 385
343 ehci_resume(hcd, false); 386 ehci_resume(hcd, pdata->reset_on_resume);
344 return 0; 387 return 0;
345} 388}
346#endif /* CONFIG_PM_SLEEP */ 389#endif /* CONFIG_PM_SLEEP */
@@ -349,6 +392,7 @@ static const struct of_device_id vt8500_ehci_ids[] = {
349 { .compatible = "via,vt8500-ehci", }, 392 { .compatible = "via,vt8500-ehci", },
350 { .compatible = "wm,prizm-ehci", }, 393 { .compatible = "wm,prizm-ehci", },
351 { .compatible = "generic-ehci", }, 394 { .compatible = "generic-ehci", },
395 { .compatible = "cavium,octeon-6335-ehci", },
352 {} 396 {}
353}; 397};
354MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); 398MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 7d75465d97c7..342816a7f8b1 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -325,6 +325,5 @@ static struct platform_driver ehci_hcd_msp_driver = {
325 .remove = ehci_hcd_msp_drv_remove, 325 .remove = ehci_hcd_msp_drv_remove,
326 .driver = { 326 .driver = {
327 .name = "pmcmsp-ehci", 327 .name = "pmcmsp-ehci",
328 .owner = THIS_MODULE,
329 }, 328 },
330}; 329};
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 547924796d29..1a10c8d542ca 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -234,7 +234,6 @@ static struct platform_driver ehci_hcd_ppc_of_driver = {
234 .shutdown = usb_hcd_platform_shutdown, 234 .shutdown = usb_hcd_platform_shutdown,
235 .driver = { 235 .driver = {
236 .name = "ppc-of-ehci", 236 .name = "ppc-of-ehci",
237 .owner = THIS_MODULE,
238 .of_match_table = ehci_hcd_ppc_of_match, 237 .of_match_table = ehci_hcd_ppc_of_match,
239 }, 238 },
240}; 239};
diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c
index 9b6e8d0eac43..3d86cc2ffe68 100644
--- a/drivers/usb/host/ehci-sead3.c
+++ b/drivers/usb/host/ehci-sead3.c
@@ -178,7 +178,6 @@ static struct platform_driver ehci_hcd_sead3_driver = {
178 .shutdown = usb_hcd_platform_shutdown, 178 .shutdown = usb_hcd_platform_shutdown,
179 .driver = { 179 .driver = {
180 .name = "sead3-ehci", 180 .name = "sead3-ehci",
181 .owner = THIS_MODULE,
182 .pm = SEAD3_EHCI_PMOPS, 181 .pm = SEAD3_EHCI_PMOPS,
183 } 182 }
184}; 183};
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 0e0ce684aff3..5caf88d679e4 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -189,7 +189,6 @@ static struct platform_driver ehci_hcd_sh_driver = {
189 .shutdown = ehci_hcd_sh_shutdown, 189 .shutdown = ehci_hcd_sh_shutdown,
190 .driver = { 190 .driver = {
191 .name = "sh_ehci", 191 .name = "sh_ehci",
192 .owner = THIS_MODULE,
193 }, 192 },
194}; 193};
195 194
diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index 0d247673c3ca..bdb93b6a356f 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -210,7 +210,6 @@ static struct platform_driver ehci_hcd_tilegx_driver = {
210 .shutdown = ehci_hcd_tilegx_drv_shutdown, 210 .shutdown = ehci_hcd_tilegx_drv_shutdown,
211 .driver = { 211 .driver = {
212 .name = "tilegx-ehci", 212 .name = "tilegx-ehci",
213 .owner = THIS_MODULE,
214 } 213 }
215}; 214};
216 215
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index a2328361dc80..f54480850bb8 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -236,7 +236,6 @@ static struct platform_driver ehci_hcd_xilinx_of_driver = {
236 .shutdown = usb_hcd_platform_shutdown, 236 .shutdown = usb_hcd_platform_shutdown,
237 .driver = { 237 .driver = {
238 .name = "xilinx-of-ehci", 238 .name = "xilinx-of-ehci",
239 .owner = THIS_MODULE,
240 .of_match_table = ehci_hcd_xilinx_of_match, 239 .of_match_table = ehci_hcd_xilinx_of_match,
241 }, 240 },
242}; 241};
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 6f0577b0a5ae..52ef0844a180 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -871,7 +871,7 @@ extern int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
871 871
872#ifdef CONFIG_PM 872#ifdef CONFIG_PM
873extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup); 873extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup);
874extern int ehci_resume(struct usb_hcd *hcd, bool hibernated); 874extern int ehci_resume(struct usb_hcd *hcd, bool force_reset);
875#endif /* CONFIG_PM */ 875#endif /* CONFIG_PM */
876 876
877extern int ehci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 877extern int ehci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
diff --git a/drivers/usb/host/fhci-hub.c b/drivers/usb/host/fhci-hub.c
index 6af2512f8378..70116a65262c 100644
--- a/drivers/usb/host/fhci-hub.c
+++ b/drivers/usb/host/fhci-hub.c
@@ -32,8 +32,8 @@ static u8 root_hub_des[] = {
32 0x09, /* blength */ 32 0x09, /* blength */
33 0x29, /* bDescriptorType;hub-descriptor */ 33 0x29, /* bDescriptorType;hub-descriptor */
34 0x01, /* bNbrPorts */ 34 0x01, /* bNbrPorts */
35 0x00, /* wHubCharacteristics */ 35 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM, /* wHubCharacteristics */
36 0x00, 36 0x00, /* per-port power, no overcurrent */
37 0x01, /* bPwrOn2pwrGood;2ms */ 37 0x01, /* bPwrOn2pwrGood;2ms */
38 0x00, /* bHubContrCurrent;0mA */ 38 0x00, /* bHubContrCurrent;0mA */
39 0x00, /* DeviceRemoveable */ 39 0x00, /* DeviceRemoveable */
@@ -208,7 +208,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
208{ 208{
209 struct fhci_hcd *fhci = hcd_to_fhci(hcd); 209 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
210 int retval = 0; 210 int retval = 0;
211 int len = 0;
212 struct usb_hub_status *hub_status; 211 struct usb_hub_status *hub_status;
213 struct usb_port_status *port_status; 212 struct usb_port_status *port_status;
214 unsigned long flags; 213 unsigned long flags;
@@ -272,8 +271,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
272 break; 271 break;
273 case GetHubDescriptor: 272 case GetHubDescriptor:
274 memcpy(buf, root_hub_des, sizeof(root_hub_des)); 273 memcpy(buf, root_hub_des, sizeof(root_hub_des));
275 buf[3] = 0x11; /* per-port power, no ovrcrnt */
276 len = (buf[0] < wLength) ? buf[0] : wLength;
277 break; 274 break;
278 case GetHubStatus: 275 case GetHubStatus:
279 hub_status = (struct usb_hub_status *)buf; 276 hub_status = (struct usb_hub_status *)buf;
@@ -281,7 +278,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
281 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus); 278 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus);
282 hub_status->wHubChange = 279 hub_status->wHubChange =
283 cpu_to_le16(fhci->vroot_hub->hub.wHubChange); 280 cpu_to_le16(fhci->vroot_hub->hub.wHubChange);
284 len = 4;
285 break; 281 break;
286 case GetPortStatus: 282 case GetPortStatus:
287 port_status = (struct usb_port_status *)buf; 283 port_status = (struct usb_port_status *)buf;
@@ -289,7 +285,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
289 cpu_to_le16(fhci->vroot_hub->port.wPortStatus); 285 cpu_to_le16(fhci->vroot_hub->port.wPortStatus);
290 port_status->wPortChange = 286 port_status->wPortChange =
291 cpu_to_le16(fhci->vroot_hub->port.wPortChange); 287 cpu_to_le16(fhci->vroot_hub->port.wPortChange);
292 len = 4;
293 break; 288 break;
294 case SetHubFeature: 289 case SetHubFeature:
295 switch (wValue) { 290 switch (wValue) {
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index ecf02b2623e8..475b21fd373b 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -1521,8 +1521,8 @@ fotg210_hub_descriptor(
1521 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 1521 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
1522 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1522 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1523 1523
1524 temp = 0x0008; /* per-port overcurrent reporting */ 1524 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
1525 temp |= 0x0002; /* no power switching */ 1525 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
1526 desc->wHubCharacteristics = cpu_to_le16(temp); 1526 desc->wHubCharacteristics = cpu_to_le16(temp);
1527} 1527}
1528 1528
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index 664d2aa1239c..a83eefefffda 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -1479,8 +1479,8 @@ fusbh200_hub_descriptor (
1479 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 1479 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
1480 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1480 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1481 1481
1482 temp = 0x0008; /* per-port overcurrent reporting */ 1482 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
1483 temp |= 0x0002; /* no power switching */ 1483 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
1484 desc->wHubCharacteristics = cpu_to_le16(temp); 1484 desc->wHubCharacteristics = cpu_to_le16(temp);
1485} 1485}
1486 1486
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index eb4efba9f1ad..6a2ad550b120 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -1482,9 +1482,8 @@ static int get_hub_descriptor(struct usb_hcd *hcd,
1482 desc->bDescLength = 9; 1482 desc->bDescLength = 9;
1483 desc->bPwrOn2PwrGood = 0; 1483 desc->bPwrOn2PwrGood = 0;
1484 desc->wHubCharacteristics = (__force __u16) cpu_to_le16( 1484 desc->wHubCharacteristics = (__force __u16) cpu_to_le16(
1485 0x0002 | /* No power switching */ 1485 HUB_CHAR_NO_LPSM | /* No power switching */
1486 0x0010 | /* No over current protection */ 1486 HUB_CHAR_NO_OCPM); /* No over current protection */
1487 0);
1488 1487
1489 desc->u.hs.DeviceRemovable[0] = 1 << 1; 1488 desc->u.hs.DeviceRemovable[0] = 1 << 1;
1490 desc->u.hs.DeviceRemovable[1] = ~0; 1489 desc->u.hs.DeviceRemovable[1] = ~0;
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 31c9c4d0fa0b..113d0cc6cc43 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -948,7 +948,10 @@ static void isp116x_hub_descriptor(struct isp116x *isp116x,
948 desc->bHubContrCurrent = 0; 948 desc->bHubContrCurrent = 0;
949 desc->bNbrPorts = (u8) (reg & 0x3); 949 desc->bNbrPorts = (u8) (reg & 0x3);
950 /* Power switching, device type, overcurrent. */ 950 /* Power switching, device type, overcurrent. */
951 desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) & 0x1f)); 951 desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) &
952 (HUB_CHAR_LPSM |
953 HUB_CHAR_COMPOUND |
954 HUB_CHAR_OCPM)));
952 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff); 955 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff);
953 /* ports removable, and legacy PortPwrCtrlMask */ 956 /* ports removable, and legacy PortPwrCtrlMask */
954 desc->u.hs.DeviceRemovable[0] = 0; 957 desc->u.hs.DeviceRemovable[0] = 0;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 75e5876f9d7c..b32ab60cad1e 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -1543,8 +1543,12 @@ static void isp1362_hub_descriptor(struct isp1362_hcd *isp1362_hcd,
1543 desc->bHubContrCurrent = 0; 1543 desc->bHubContrCurrent = 0;
1544 desc->bNbrPorts = reg & 0x3; 1544 desc->bNbrPorts = reg & 0x3;
1545 /* Power switching, device type, overcurrent. */ 1545 /* Power switching, device type, overcurrent. */
1546 desc->wHubCharacteristics = cpu_to_le16((reg >> 8) & 0x1f); 1546 desc->wHubCharacteristics = cpu_to_le16((reg >> 8) &
1547 DBG(0, "%s: hubcharacteristics = %02x\n", __func__, cpu_to_le16((reg >> 8) & 0x1f)); 1547 (HUB_CHAR_LPSM |
1548 HUB_CHAR_COMPOUND |
1549 HUB_CHAR_OCPM));
1550 DBG(0, "%s: hubcharacteristics = %02x\n", __func__,
1551 desc->wHubCharacteristics);
1548 desc->bPwrOn2PwrGood = (reg >> 24) & 0xff; 1552 desc->bPwrOn2PwrGood = (reg >> 24) & 0xff;
1549 /* ports removable, and legacy PortPwrCtrlMask */ 1553 /* ports removable, and legacy PortPwrCtrlMask */
1550 desc->u.hs.DeviceRemovable[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1; 1554 desc->u.hs.DeviceRemovable[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1;
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 395649f357aa..cecf39a220e7 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -1359,9 +1359,7 @@ static int isp1760_run(struct usb_hcd *hcd)
1359 if (retval) 1359 if (retval)
1360 return retval; 1360 return retval;
1361 1361
1362 init_timer(&errata2_timer); 1362 setup_timer(&errata2_timer, errata2_function, (unsigned long)hcd);
1363 errata2_timer.function = errata2_function;
1364 errata2_timer.data = (unsigned long) hcd;
1365 errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000; 1363 errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000;
1366 add_timer(&errata2_timer); 1364 add_timer(&errata2_timer);
1367 1365
@@ -1798,13 +1796,13 @@ static void isp1760_hub_descriptor(struct isp1760_hcd *priv,
1798 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1796 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1799 1797
1800 /* per-port overcurrent reporting */ 1798 /* per-port overcurrent reporting */
1801 temp = 0x0008; 1799 temp = HUB_CHAR_INDV_PORT_OCPM;
1802 if (HCS_PPC(priv->hcs_params)) 1800 if (HCS_PPC(priv->hcs_params))
1803 /* per-port power control */ 1801 /* per-port power control */
1804 temp |= 0x0001; 1802 temp |= HUB_CHAR_INDV_PORT_LPSM;
1805 else 1803 else
1806 /* no power switching */ 1804 /* no power switching */
1807 temp |= 0x0002; 1805 temp |= HUB_CHAR_NO_LPSM;
1808 desc->wHubCharacteristics = cpu_to_le16(temp); 1806 desc->wHubCharacteristics = cpu_to_le16(temp);
1809} 1807}
1810 1808
@@ -2247,6 +2245,9 @@ struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
2247 hcd->rsrc_start = res_start; 2245 hcd->rsrc_start = res_start;
2248 hcd->rsrc_len = res_len; 2246 hcd->rsrc_len = res_len;
2249 2247
2248 /* This driver doesn't support wakeup requests */
2249 hcd->cant_recv_wakeups = 1;
2250
2250 ret = usb_add_hcd(hcd, irq, irqflags); 2251 ret = usb_add_hcd(hcd, irq, irqflags);
2251 if (ret) 2252 if (ret)
2252 goto err_unmap; 2253 goto err_unmap;
diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 6234c75da33f..a98833cbfcf3 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -55,6 +55,7 @@
55 * single thread (max3421_spi_thread). 55 * single thread (max3421_spi_thread).
56 */ 56 */
57 57
58#include <linux/jiffies.h>
58#include <linux/module.h> 59#include <linux/module.h>
59#include <linux/spi/spi.h> 60#include <linux/spi/spi.h>
60#include <linux/usb.h> 61#include <linux/usb.h>
@@ -1291,7 +1292,7 @@ max3421_handle_irqs(struct usb_hcd *hcd)
1291 char sbuf[16 * 16], *dp, *end; 1292 char sbuf[16 * 16], *dp, *end;
1292 int i; 1293 int i;
1293 1294
1294 if (jiffies - last_time > 5*HZ) { 1295 if (time_after(jiffies, last_time + 5*HZ)) {
1295 dp = sbuf; 1296 dp = sbuf;
1296 end = sbuf + sizeof(sbuf); 1297 end = sbuf + sizeof(sbuf);
1297 *dp = '\0'; 1298 *dp = '\0';
@@ -1660,7 +1661,8 @@ hub_descriptor(struct usb_hub_descriptor *desc)
1660 */ 1661 */
1661 desc->bDescriptorType = 0x29; /* hub descriptor */ 1662 desc->bDescriptorType = 0x29; /* hub descriptor */
1662 desc->bDescLength = 9; 1663 desc->bDescLength = 9;
1663 desc->wHubCharacteristics = cpu_to_le16(0x0001); 1664 desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
1665 HUB_CHAR_COMMON_OCPM);
1664 desc->bNbrPorts = 1; 1666 desc->bNbrPorts = 1;
1665} 1667}
1666 1668
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index dc9e4e61f1c8..7cce85a1f7dc 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -33,7 +33,17 @@
33 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++) 33 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
34 34
35/* interface, function and usb clocks; sometimes also an AHB clock */ 35/* interface, function and usb clocks; sometimes also an AHB clock */
36static struct clk *iclk, *fclk, *uclk, *hclk; 36#define hcd_to_ohci_at91_priv(h) \
37 ((struct ohci_at91_priv *)hcd_to_ohci(h)->priv)
38
39struct ohci_at91_priv {
40 struct clk *iclk;
41 struct clk *fclk;
42 struct clk *uclk;
43 struct clk *hclk;
44 bool clocked;
45 bool wakeup; /* Saved wake-up state for resume */
46};
37/* interface and function clocks; sometimes also an AHB clock */ 47/* interface and function clocks; sometimes also an AHB clock */
38 48
39#define DRIVER_DESC "OHCI Atmel driver" 49#define DRIVER_DESC "OHCI Atmel driver"
@@ -41,45 +51,53 @@ static struct clk *iclk, *fclk, *uclk, *hclk;
41static const char hcd_name[] = "ohci-atmel"; 51static const char hcd_name[] = "ohci-atmel";
42 52
43static struct hc_driver __read_mostly ohci_at91_hc_driver; 53static struct hc_driver __read_mostly ohci_at91_hc_driver;
44static int clocked; 54
55static const struct ohci_driver_overrides ohci_at91_drv_overrides __initconst = {
56 .extra_priv_size = sizeof(struct ohci_at91_priv),
57};
45 58
46extern int usb_disabled(void); 59extern int usb_disabled(void);
47 60
48/*-------------------------------------------------------------------------*/ 61/*-------------------------------------------------------------------------*/
49 62
50static void at91_start_clock(void) 63static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
51{ 64{
65 if (ohci_at91->clocked)
66 return;
52 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 67 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
53 clk_set_rate(uclk, 48000000); 68 clk_set_rate(ohci_at91->uclk, 48000000);
54 clk_prepare_enable(uclk); 69 clk_prepare_enable(ohci_at91->uclk);
55 } 70 }
56 clk_prepare_enable(hclk); 71 clk_prepare_enable(ohci_at91->hclk);
57 clk_prepare_enable(iclk); 72 clk_prepare_enable(ohci_at91->iclk);
58 clk_prepare_enable(fclk); 73 clk_prepare_enable(ohci_at91->fclk);
59 clocked = 1; 74 ohci_at91->clocked = true;
60} 75}
61 76
62static void at91_stop_clock(void) 77static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
63{ 78{
64 clk_disable_unprepare(fclk); 79 if (!ohci_at91->clocked)
65 clk_disable_unprepare(iclk); 80 return;
66 clk_disable_unprepare(hclk); 81 clk_disable_unprepare(ohci_at91->fclk);
82 clk_disable_unprepare(ohci_at91->iclk);
83 clk_disable_unprepare(ohci_at91->hclk);
67 if (IS_ENABLED(CONFIG_COMMON_CLK)) 84 if (IS_ENABLED(CONFIG_COMMON_CLK))
68 clk_disable_unprepare(uclk); 85 clk_disable_unprepare(ohci_at91->uclk);
69 clocked = 0; 86 ohci_at91->clocked = false;
70} 87}
71 88
72static void at91_start_hc(struct platform_device *pdev) 89static void at91_start_hc(struct platform_device *pdev)
73{ 90{
74 struct usb_hcd *hcd = platform_get_drvdata(pdev); 91 struct usb_hcd *hcd = platform_get_drvdata(pdev);
75 struct ohci_regs __iomem *regs = hcd->regs; 92 struct ohci_regs __iomem *regs = hcd->regs;
93 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
76 94
77 dev_dbg(&pdev->dev, "start\n"); 95 dev_dbg(&pdev->dev, "start\n");
78 96
79 /* 97 /*
80 * Start the USB clocks. 98 * Start the USB clocks.
81 */ 99 */
82 at91_start_clock(); 100 at91_start_clock(ohci_at91);
83 101
84 /* 102 /*
85 * The USB host controller must remain in reset. 103 * The USB host controller must remain in reset.
@@ -91,6 +109,7 @@ static void at91_stop_hc(struct platform_device *pdev)
91{ 109{
92 struct usb_hcd *hcd = platform_get_drvdata(pdev); 110 struct usb_hcd *hcd = platform_get_drvdata(pdev);
93 struct ohci_regs __iomem *regs = hcd->regs; 111 struct ohci_regs __iomem *regs = hcd->regs;
112 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
94 113
95 dev_dbg(&pdev->dev, "stop\n"); 114 dev_dbg(&pdev->dev, "stop\n");
96 115
@@ -102,7 +121,7 @@ static void at91_stop_hc(struct platform_device *pdev)
102 /* 121 /*
103 * Stop the USB clocks. 122 * Stop the USB clocks.
104 */ 123 */
105 at91_stop_clock(); 124 at91_stop_clock(ohci_at91);
106} 125}
107 126
108 127
@@ -128,7 +147,8 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
128 struct at91_usbh_data *board; 147 struct at91_usbh_data *board;
129 struct ohci_hcd *ohci; 148 struct ohci_hcd *ohci;
130 int retval; 149 int retval;
131 struct usb_hcd *hcd = NULL; 150 struct usb_hcd *hcd;
151 struct ohci_at91_priv *ohci_at91;
132 struct device *dev = &pdev->dev; 152 struct device *dev = &pdev->dev;
133 struct resource *res; 153 struct resource *res;
134 int irq; 154 int irq;
@@ -142,6 +162,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
142 hcd = usb_create_hcd(driver, dev, "at91"); 162 hcd = usb_create_hcd(driver, dev, "at91");
143 if (!hcd) 163 if (!hcd)
144 return -ENOMEM; 164 return -ENOMEM;
165 ohci_at91 = hcd_to_ohci_at91_priv(hcd);
145 166
146 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 167 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
147 hcd->regs = devm_ioremap_resource(dev, res); 168 hcd->regs = devm_ioremap_resource(dev, res);
@@ -152,29 +173,29 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
152 hcd->rsrc_start = res->start; 173 hcd->rsrc_start = res->start;
153 hcd->rsrc_len = resource_size(res); 174 hcd->rsrc_len = resource_size(res);
154 175
155 iclk = devm_clk_get(dev, "ohci_clk"); 176 ohci_at91->iclk = devm_clk_get(dev, "ohci_clk");
156 if (IS_ERR(iclk)) { 177 if (IS_ERR(ohci_at91->iclk)) {
157 dev_err(dev, "failed to get ohci_clk\n"); 178 dev_err(dev, "failed to get ohci_clk\n");
158 retval = PTR_ERR(iclk); 179 retval = PTR_ERR(ohci_at91->iclk);
159 goto err; 180 goto err;
160 } 181 }
161 fclk = devm_clk_get(dev, "uhpck"); 182 ohci_at91->fclk = devm_clk_get(dev, "uhpck");
162 if (IS_ERR(fclk)) { 183 if (IS_ERR(ohci_at91->fclk)) {
163 dev_err(dev, "failed to get uhpck\n"); 184 dev_err(dev, "failed to get uhpck\n");
164 retval = PTR_ERR(fclk); 185 retval = PTR_ERR(ohci_at91->fclk);
165 goto err; 186 goto err;
166 } 187 }
167 hclk = devm_clk_get(dev, "hclk"); 188 ohci_at91->hclk = devm_clk_get(dev, "hclk");
168 if (IS_ERR(hclk)) { 189 if (IS_ERR(ohci_at91->hclk)) {
169 dev_err(dev, "failed to get hclk\n"); 190 dev_err(dev, "failed to get hclk\n");
170 retval = PTR_ERR(hclk); 191 retval = PTR_ERR(ohci_at91->hclk);
171 goto err; 192 goto err;
172 } 193 }
173 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 194 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
174 uclk = devm_clk_get(dev, "usb_clk"); 195 ohci_at91->uclk = devm_clk_get(dev, "usb_clk");
175 if (IS_ERR(uclk)) { 196 if (IS_ERR(ohci_at91->uclk)) {
176 dev_err(dev, "failed to get uclk\n"); 197 dev_err(dev, "failed to get uclk\n");
177 retval = PTR_ERR(uclk); 198 retval = PTR_ERR(ohci_at91->uclk);
178 goto err; 199 goto err;
179 } 200 }
180 } 201 }
@@ -347,11 +368,13 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
347 */ 368 */
348 369
349 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); 370 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
350 desc->wHubCharacteristics |= cpu_to_le16(0x0001); 371 desc->wHubCharacteristics |=
372 cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM);
351 373
352 if (pdata->overcurrent_supported) { 374 if (pdata->overcurrent_supported) {
353 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM); 375 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
354 desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001); 376 desc->wHubCharacteristics |=
377 cpu_to_le16(HUB_CHAR_INDV_PORT_OCPM);
355 } 378 }
356 379
357 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", 380 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
@@ -593,19 +616,27 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
593#ifdef CONFIG_PM 616#ifdef CONFIG_PM
594 617
595static int 618static int
596ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) 619ohci_hcd_at91_drv_suspend(struct device *dev)
597{ 620{
598 struct usb_hcd *hcd = platform_get_drvdata(pdev); 621 struct usb_hcd *hcd = dev_get_drvdata(dev);
599 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 622 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
600 bool do_wakeup = device_may_wakeup(&pdev->dev); 623 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
601 int ret; 624 int ret;
602 625
603 if (do_wakeup) 626 /*
627 * Disable wakeup if we are going to sleep with slow clock mode
628 * enabled.
629 */
630 ohci_at91->wakeup = device_may_wakeup(dev)
631 && !at91_suspend_entering_slow_clock();
632
633 if (ohci_at91->wakeup)
604 enable_irq_wake(hcd->irq); 634 enable_irq_wake(hcd->irq);
605 635
606 ret = ohci_suspend(hcd, do_wakeup); 636 ret = ohci_suspend(hcd, ohci_at91->wakeup);
607 if (ret) { 637 if (ret) {
608 disable_irq_wake(hcd->irq); 638 if (ohci_at91->wakeup)
639 disable_irq_wake(hcd->irq);
609 return ret; 640 return ret;
610 } 641 }
611 /* 642 /*
@@ -615,7 +646,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
615 * 646 *
616 * REVISIT: some boards will be able to turn VBUS off... 647 * REVISIT: some boards will be able to turn VBUS off...
617 */ 648 */
618 if (at91_suspend_entering_slow_clock()) { 649 if (!ohci_at91->wakeup) {
619 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); 650 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
620 ohci->hc_control &= OHCI_CTRL_RWC; 651 ohci->hc_control &= OHCI_CTRL_RWC;
621 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); 652 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
@@ -623,38 +654,37 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
623 654
624 /* flush the writes */ 655 /* flush the writes */
625 (void) ohci_readl (ohci, &ohci->regs->control); 656 (void) ohci_readl (ohci, &ohci->regs->control);
626 at91_stop_clock(); 657 at91_stop_clock(ohci_at91);
627 } 658 }
628 659
629 return ret; 660 return ret;
630} 661}
631 662
632static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) 663static int ohci_hcd_at91_drv_resume(struct device *dev)
633{ 664{
634 struct usb_hcd *hcd = platform_get_drvdata(pdev); 665 struct usb_hcd *hcd = dev_get_drvdata(dev);
666 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
635 667
636 if (device_may_wakeup(&pdev->dev)) 668 if (ohci_at91->wakeup)
637 disable_irq_wake(hcd->irq); 669 disable_irq_wake(hcd->irq);
638 670
639 if (!clocked) 671 at91_start_clock(ohci_at91);
640 at91_start_clock();
641 672
642 ohci_resume(hcd, false); 673 ohci_resume(hcd, false);
643 return 0; 674 return 0;
644} 675}
645#else
646#define ohci_hcd_at91_drv_suspend NULL
647#define ohci_hcd_at91_drv_resume NULL
648#endif 676#endif
649 677
678static SIMPLE_DEV_PM_OPS(ohci_hcd_at91_pm_ops, ohci_hcd_at91_drv_suspend,
679 ohci_hcd_at91_drv_resume);
680
650static struct platform_driver ohci_hcd_at91_driver = { 681static struct platform_driver ohci_hcd_at91_driver = {
651 .probe = ohci_hcd_at91_drv_probe, 682 .probe = ohci_hcd_at91_drv_probe,
652 .remove = ohci_hcd_at91_drv_remove, 683 .remove = ohci_hcd_at91_drv_remove,
653 .shutdown = usb_hcd_platform_shutdown, 684 .shutdown = usb_hcd_platform_shutdown,
654 .suspend = ohci_hcd_at91_drv_suspend,
655 .resume = ohci_hcd_at91_drv_resume,
656 .driver = { 685 .driver = {
657 .name = "at91_ohci", 686 .name = "at91_ohci",
687 .pm = &ohci_hcd_at91_pm_ops,
658 .of_match_table = of_match_ptr(at91_ohci_dt_ids), 688 .of_match_table = of_match_ptr(at91_ohci_dt_ids),
659 }, 689 },
660}; 690};
@@ -665,7 +695,7 @@ static int __init ohci_at91_init(void)
665 return -ENODEV; 695 return -ENODEV;
666 696
667 pr_info("%s: " DRIVER_DESC "\n", hcd_name); 697 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
668 ohci_init_driver(&ohci_at91_hc_driver, NULL); 698 ohci_init_driver(&ohci_at91_hc_driver, &ohci_at91_drv_overrides);
669 699
670 /* 700 /*
671 * The Atmel HW has some unusual quirks, which require Atmel-specific 701 * The Atmel HW has some unusual quirks, which require Atmel-specific
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 1c76999b2184..e5c33bc98ea4 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -431,7 +431,6 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
431 .resume = ohci_da8xx_resume, 431 .resume = ohci_da8xx_resume,
432#endif 432#endif
433 .driver = { 433 .driver = {
434 .owner = THIS_MODULE,
435 .name = "ohci", 434 .name = "ohci",
436 }, 435 },
437}; 436};
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 0aa17c937115..fe2aedd8a54d 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -544,15 +544,15 @@ ohci_hub_descriptor (
544 temp = 1 + (ohci->num_ports / 8); 544 temp = 1 + (ohci->num_ports / 8);
545 desc->bDescLength = 7 + 2 * temp; 545 desc->bDescLength = 7 + 2 * temp;
546 546
547 temp = 0; 547 temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
548 if (rh & RH_A_NPS) /* no power switching? */ 548 if (rh & RH_A_NPS) /* no power switching? */
549 temp |= 0x0002; 549 temp |= HUB_CHAR_NO_LPSM;
550 if (rh & RH_A_PSM) /* per-port power switching? */ 550 if (rh & RH_A_PSM) /* per-port power switching? */
551 temp |= 0x0001; 551 temp |= HUB_CHAR_INDV_PORT_LPSM;
552 if (rh & RH_A_NOCP) /* no overcurrent reporting? */ 552 if (rh & RH_A_NOCP) /* no overcurrent reporting? */
553 temp |= 0x0010; 553 temp |= HUB_CHAR_NO_OCPM;
554 else if (rh & RH_A_OCPM) /* per-port overcurrent reporting? */ 554 else if (rh & RH_A_OCPM) /* per-port overcurrent reporting? */
555 temp |= 0x0008; 555 temp |= HUB_CHAR_INDV_PORT_OCPM;
556 desc->wHubCharacteristics = cpu_to_le16(temp); 556 desc->wHubCharacteristics = cpu_to_le16(temp);
557 557
558 /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */ 558 /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index 8ddd8f5470cb..4db78f169256 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -239,7 +239,6 @@ static struct platform_driver ohci_hcd_jz4740_driver = {
239 .remove = jz4740_ohci_remove, 239 .remove = jz4740_ohci_remove,
240 .driver = { 240 .driver = {
241 .name = "jz4740-ohci", 241 .name = "jz4740-ohci",
242 .owner = THIS_MODULE,
243 }, 242 },
244}; 243};
245 244
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index b81d202b15a2..185ceee52d47 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -38,7 +38,8 @@
38struct ohci_platform_priv { 38struct ohci_platform_priv {
39 struct clk *clks[OHCI_MAX_CLKS]; 39 struct clk *clks[OHCI_MAX_CLKS];
40 struct reset_control *rst; 40 struct reset_control *rst;
41 struct phy *phy; 41 struct phy **phys;
42 int num_phys;
42}; 43};
43 44
44static const char hcd_name[] = "ohci-platform"; 45static const char hcd_name[] = "ohci-platform";
@@ -47,7 +48,7 @@ static int ohci_platform_power_on(struct platform_device *dev)
47{ 48{
48 struct usb_hcd *hcd = platform_get_drvdata(dev); 49 struct usb_hcd *hcd = platform_get_drvdata(dev);
49 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); 50 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
50 int clk, ret; 51 int clk, ret, phy_num;
51 52
52 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) { 53 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
53 ret = clk_prepare_enable(priv->clks[clk]); 54 ret = clk_prepare_enable(priv->clks[clk]);
@@ -55,20 +56,28 @@ static int ohci_platform_power_on(struct platform_device *dev)
55 goto err_disable_clks; 56 goto err_disable_clks;
56 } 57 }
57 58
58 if (priv->phy) { 59 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
59 ret = phy_init(priv->phy); 60 if (priv->phys[phy_num]) {
60 if (ret) 61 ret = phy_init(priv->phys[phy_num]);
61 goto err_disable_clks; 62 if (ret)
62 63 goto err_exit_phy;
63 ret = phy_power_on(priv->phy); 64 ret = phy_power_on(priv->phys[phy_num]);
64 if (ret) 65 if (ret) {
65 goto err_exit_phy; 66 phy_exit(priv->phys[phy_num]);
67 goto err_exit_phy;
68 }
69 }
66 } 70 }
67 71
68 return 0; 72 return 0;
69 73
70err_exit_phy: 74err_exit_phy:
71 phy_exit(priv->phy); 75 while (--phy_num >= 0) {
76 if (priv->phys[phy_num]) {
77 phy_power_off(priv->phys[phy_num]);
78 phy_exit(priv->phys[phy_num]);
79 }
80 }
72err_disable_clks: 81err_disable_clks:
73 while (--clk >= 0) 82 while (--clk >= 0)
74 clk_disable_unprepare(priv->clks[clk]); 83 clk_disable_unprepare(priv->clks[clk]);
@@ -80,11 +89,13 @@ static void ohci_platform_power_off(struct platform_device *dev)
80{ 89{
81 struct usb_hcd *hcd = platform_get_drvdata(dev); 90 struct usb_hcd *hcd = platform_get_drvdata(dev);
82 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); 91 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
83 int clk; 92 int clk, phy_num;
84 93
85 if (priv->phy) { 94 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
86 phy_power_off(priv->phy); 95 if (priv->phys[phy_num]) {
87 phy_exit(priv->phy); 96 phy_power_off(priv->phys[phy_num]);
97 phy_exit(priv->phys[phy_num]);
98 }
88 } 99 }
89 100
90 for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--) 101 for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -112,7 +123,8 @@ static int ohci_platform_probe(struct platform_device *dev)
112 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); 123 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
113 struct ohci_platform_priv *priv; 124 struct ohci_platform_priv *priv;
114 struct ohci_hcd *ohci; 125 struct ohci_hcd *ohci;
115 int err, irq, clk = 0; 126 const char *phy_name;
127 int err, irq, phy_num, clk = 0;
116 128
117 if (usb_disabled()) 129 if (usb_disabled())
118 return -ENODEV; 130 return -ENODEV;
@@ -160,12 +172,38 @@ static int ohci_platform_probe(struct platform_device *dev)
160 of_property_read_u32(dev->dev.of_node, "num-ports", 172 of_property_read_u32(dev->dev.of_node, "num-ports",
161 &ohci->num_ports); 173 &ohci->num_ports);
162 174
163 priv->phy = devm_phy_get(&dev->dev, "usb"); 175 priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
164 if (IS_ERR(priv->phy)) { 176 "phys", "#phy-cells");
165 err = PTR_ERR(priv->phy); 177 priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
166 if (err == -EPROBE_DEFER) 178
167 goto err_put_hcd; 179 priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
168 priv->phy = NULL; 180 sizeof(struct phy *), GFP_KERNEL);
181 if (!priv->phys)
182 return -ENOMEM;
183
184 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
185 err = of_property_read_string_index(
186 dev->dev.of_node,
187 "phy-names", phy_num,
188 &phy_name);
189
190 if (err < 0) {
191 if (priv->num_phys > 1) {
192 dev_err(&dev->dev, "phy-names not provided");
193 goto err_put_hcd;
194 } else
195 phy_name = "usb";
196 }
197
198 priv->phys[phy_num] = devm_phy_get(&dev->dev,
199 phy_name);
200 if (IS_ERR(priv->phys[phy_num])) {
201 err = PTR_ERR(priv->phys[phy_num]);
202 if ((priv->num_phys > 1) ||
203 (err == -EPROBE_DEFER))
204 goto err_put_hcd;
205 priv->phys[phy_num] = NULL;
206 }
169 } 207 }
170 208
171 for (clk = 0; clk < OHCI_MAX_CLKS; clk++) { 209 for (clk = 0; clk < OHCI_MAX_CLKS; clk++) {
@@ -328,6 +366,7 @@ static int ohci_platform_resume(struct device *dev)
328 366
329static const struct of_device_id ohci_platform_ids[] = { 367static const struct of_device_id ohci_platform_ids[] = {
330 { .compatible = "generic-ohci", }, 368 { .compatible = "generic-ohci", },
369 { .compatible = "cavium,octeon-6335-ohci", },
331 { } 370 { }
332}; 371};
333MODULE_DEVICE_TABLE(of, ohci_platform_ids); 372MODULE_DEVICE_TABLE(of, ohci_platform_ids);
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 965e3e9e688a..4f87a5c61b08 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -229,7 +229,6 @@ static struct platform_driver ohci_hcd_ppc_of_driver = {
229 .shutdown = usb_hcd_platform_shutdown, 229 .shutdown = usb_hcd_platform_shutdown,
230 .driver = { 230 .driver = {
231 .name = "ppc-of-ohci", 231 .name = "ppc-of-ohci",
232 .owner = THIS_MODULE,
233 .of_match_table = ohci_hcd_ppc_of_match, 232 .of_match_table = ohci_hcd_ppc_of_match,
234 }, 233 },
235}; 234};
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 095113ea1fcb..7a1919ca543a 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -249,14 +249,14 @@ static int ohci_s3c2410_hub_control(
249 */ 249 */
250 250
251 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); 251 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
252 desc->wHubCharacteristics |= cpu_to_le16(0x0001); 252 desc->wHubCharacteristics |= cpu_to_le16(
253 HUB_CHAR_INDV_PORT_LPSM);
253 254
254 if (info->enable_oc) { 255 if (info->enable_oc) {
255 desc->wHubCharacteristics &= ~cpu_to_le16( 256 desc->wHubCharacteristics &= ~cpu_to_le16(
256 HUB_CHAR_OCPM); 257 HUB_CHAR_OCPM);
257 desc->wHubCharacteristics |= cpu_to_le16( 258 desc->wHubCharacteristics |= cpu_to_le16(
258 0x0008 | 259 HUB_CHAR_INDV_PORT_OCPM);
259 0x0001);
260 } 260 }
261 261
262 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", 262 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 4e81c804c73e..a8b8d8b8d9f3 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -265,7 +265,6 @@ static struct platform_driver ohci_hcd_sm501_driver = {
265 .suspend = ohci_sm501_suspend, 265 .suspend = ohci_sm501_suspend,
266 .resume = ohci_sm501_resume, 266 .resume = ohci_sm501_resume,
267 .driver = { 267 .driver = {
268 .owner = THIS_MODULE,
269 .name = "sm501-usb", 268 .name = "sm501-usb",
270 }, 269 },
271}; 270};
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index bef6dfb0405a..e1b208da460a 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -199,7 +199,6 @@ static struct platform_driver ohci_hcd_tilegx_driver = {
199 .shutdown = ohci_hcd_tilegx_drv_shutdown, 199 .shutdown = ohci_hcd_tilegx_drv_shutdown,
200 .driver = { 200 .driver = {
201 .name = "tilegx-ohci", 201 .name = "tilegx-ohci",
202 .owner = THIS_MODULE,
203 } 202 }
204}; 203};
205 204
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index bb409588d39c..e9a6eec39142 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -368,6 +368,5 @@ static struct platform_driver ohci_hcd_tmio_driver = {
368 .resume = ohci_hcd_tmio_drv_resume, 368 .resume = ohci_hcd_tmio_drv_resume,
369 .driver = { 369 .driver = {
370 .name = "tmio-ohci", 370 .name = "tmio-ohci",
371 .owner = THIS_MODULE,
372 }, 371 },
373}; 372};
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 036924e640f5..ef7efb278b15 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -457,11 +457,11 @@ static void ehci_hub_descriptor(struct oxu_hcd *oxu,
457 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 457 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
458 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 458 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
459 459
460 temp = 0x0008; /* per-port overcurrent reporting */ 460 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
461 if (HCS_PPC(oxu->hcs_params)) 461 if (HCS_PPC(oxu->hcs_params))
462 temp |= 0x0001; /* per-port power control */ 462 temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
463 else 463 else
464 temp |= 0x0002; /* no power switching */ 464 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
465 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp); 465 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
466} 466}
467 467
@@ -2598,9 +2598,7 @@ static int oxu_hcd_init(struct usb_hcd *hcd)
2598 2598
2599 spin_lock_init(&oxu->lock); 2599 spin_lock_init(&oxu->lock);
2600 2600
2601 init_timer(&oxu->watchdog); 2601 setup_timer(&oxu->watchdog, oxu_watchdog, (unsigned long)oxu);
2602 oxu->watchdog.function = oxu_watchdog;
2603 oxu->watchdog.data = (unsigned long) oxu;
2604 2602
2605 /* 2603 /*
2606 * hw default: 1K periodic list heads, one per frame. 2604 * hw default: 1K periodic list heads, one per frame.
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index ce636466edb7..f9400564cb72 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -603,9 +603,9 @@ static void quirk_usb_handoff_ohci(struct pci_dev *pdev)
603 msleep(10); 603 msleep(10);
604 } 604 }
605 if (wait_time <= 0) 605 if (wait_time <= 0)
606 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed" 606 dev_warn(&pdev->dev,
607 " (BIOS bug?) %08x\n", 607 "OHCI: BIOS handoff failed (BIOS bug?) %08x\n",
608 readl(base + OHCI_CONTROL)); 608 readl(base + OHCI_CONTROL));
609 } 609 }
610#endif 610#endif
611 611
@@ -733,8 +733,9 @@ static void ehci_bios_handoff(struct pci_dev *pdev,
733 * and hope nothing goes too wrong 733 * and hope nothing goes too wrong
734 */ 734 */
735 if (try_handoff) 735 if (try_handoff)
736 dev_warn(&pdev->dev, "EHCI: BIOS handoff failed" 736 dev_warn(&pdev->dev,
737 " (BIOS bug?) %08x\n", cap); 737 "EHCI: BIOS handoff failed (BIOS bug?) %08x\n",
738 cap);
738 pci_write_config_byte(pdev, offset + 2, 0); 739 pci_write_config_byte(pdev, offset + 2, 0);
739 } 740 }
740 741
@@ -781,8 +782,9 @@ static void quirk_usb_disable_ehci(struct pci_dev *pdev)
781 case 0: /* Illegal reserved cap, set cap=0 so we exit */ 782 case 0: /* Illegal reserved cap, set cap=0 so we exit */
782 cap = 0; /* then fallthrough... */ 783 cap = 0; /* then fallthrough... */
783 default: 784 default:
784 dev_warn(&pdev->dev, "EHCI: unrecognized capability " 785 dev_warn(&pdev->dev,
785 "%02x\n", cap & 0xff); 786 "EHCI: unrecognized capability %02x\n",
787 cap & 0xff);
786 } 788 }
787 offset = (cap >> 8) & 0xff; 789 offset = (cap >> 8) & 0xff;
788 } 790 }
@@ -893,8 +895,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
893 */ 895 */
894 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) { 896 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
895 dev_warn(&xhci_pdev->dev, 897 dev_warn(&xhci_pdev->dev,
896 "CONFIG_USB_XHCI_HCD is turned off, " 898 "CONFIG_USB_XHCI_HCD is turned off, defaulting to EHCI.\n");
897 "defaulting to EHCI.\n");
898 dev_warn(&xhci_pdev->dev, 899 dev_warn(&xhci_pdev->dev,
899 "USB 3.0 devices will work at USB 2.0 speeds.\n"); 900 "USB 3.0 devices will work at USB 2.0 speeds.\n");
900 usb_disable_xhci_ports(xhci_pdev); 901 usb_disable_xhci_ports(xhci_pdev);
@@ -919,8 +920,9 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
919 920
920 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 921 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
921 &ports_available); 922 &ports_available);
922 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " 923 dev_dbg(&xhci_pdev->dev,
923 "under xHCI: 0x%x\n", ports_available); 924 "USB 3.0 ports that are now enabled under xHCI: 0x%x\n",
925 ports_available);
924 926
925 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register 927 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register
926 * Indicate the USB 2.0 ports to be controlled by the xHCI host. 928 * Indicate the USB 2.0 ports to be controlled by the xHCI host.
@@ -941,8 +943,9 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
941 943
942 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 944 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
943 &ports_available); 945 &ports_available);
944 dev_dbg(&xhci_pdev->dev, "USB 2.0 ports that are now switched over " 946 dev_dbg(&xhci_pdev->dev,
945 "to xHCI: 0x%x\n", ports_available); 947 "USB 2.0 ports that are now switched over to xHCI: 0x%x\n",
948 ports_available);
946} 949}
947EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports); 950EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports);
948 951
@@ -1010,8 +1013,9 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
1010 1013
1011 /* Assume a buggy BIOS and take HC ownership anyway */ 1014 /* Assume a buggy BIOS and take HC ownership anyway */
1012 if (timeout) { 1015 if (timeout) {
1013 dev_warn(&pdev->dev, "xHCI BIOS handoff failed" 1016 dev_warn(&pdev->dev,
1014 " (BIOS bug ?) %08x\n", val); 1017 "xHCI BIOS handoff failed (BIOS bug ?) %08x\n",
1018 val);
1015 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset); 1019 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
1016 } 1020 }
1017 } 1021 }
@@ -1039,8 +1043,8 @@ hc_init:
1039 if (timeout) { 1043 if (timeout) {
1040 val = readl(op_reg_base + XHCI_STS_OFFSET); 1044 val = readl(op_reg_base + XHCI_STS_OFFSET);
1041 dev_warn(&pdev->dev, 1045 dev_warn(&pdev->dev,
1042 "xHCI HW not ready after 5 sec (HC bug?) " 1046 "xHCI HW not ready after 5 sec (HC bug?) status = 0x%x\n",
1043 "status = 0x%x\n", val); 1047 val);
1044 } 1048 }
1045 1049
1046 /* Send the halt and disable interrupts command */ 1050 /* Send the halt and disable interrupts command */
@@ -1054,8 +1058,8 @@ hc_init:
1054 if (timeout) { 1058 if (timeout) {
1055 val = readl(op_reg_base + XHCI_STS_OFFSET); 1059 val = readl(op_reg_base + XHCI_STS_OFFSET);
1056 dev_warn(&pdev->dev, 1060 dev_warn(&pdev->dev,
1057 "xHCI HW did not halt within %d usec " 1061 "xHCI HW did not halt within %d usec status = 0x%x\n",
1058 "status = 0x%x\n", XHCI_MAX_HALT_USEC, val); 1062 XHCI_MAX_HALT_USEC, val);
1059 } 1063 }
1060 1064
1061 iounmap(base); 1065 iounmap(base);
@@ -1075,8 +1079,8 @@ static void quirk_usb_early_handoff(struct pci_dev *pdev)
1075 return; 1079 return;
1076 1080
1077 if (pci_enable_device(pdev) < 0) { 1081 if (pci_enable_device(pdev) < 0) {
1078 dev_warn(&pdev->dev, "Can't enable PCI device, " 1082 dev_warn(&pdev->dev,
1079 "BIOS handoff failed.\n"); 1083 "Can't enable PCI device, BIOS handoff failed.\n");
1080 return; 1084 return;
1081 } 1085 }
1082 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI) 1086 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index c4bcfaedeec9..bdc82fea0a1f 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2141,7 +2141,8 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597,
2141 desc->bNbrPorts = r8a66597->max_root_hub; 2141 desc->bNbrPorts = r8a66597->max_root_hub;
2142 desc->bDescLength = 9; 2142 desc->bDescLength = 9;
2143 desc->bPwrOn2PwrGood = 0; 2143 desc->bPwrOn2PwrGood = 0;
2144 desc->wHubCharacteristics = cpu_to_le16(0x0011); 2144 desc->wHubCharacteristics =
2145 cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM);
2145 desc->u.hs.DeviceRemovable[0] = 2146 desc->u.hs.DeviceRemovable[0] =
2146 ((1 << r8a66597->max_root_hub) - 1) << 1; 2147 ((1 << r8a66597->max_root_hub) - 1) << 1;
2147 desc->u.hs.DeviceRemovable[1] = ~0; 2148 desc->u.hs.DeviceRemovable[1] = ~0;
@@ -2483,9 +2484,8 @@ static int r8a66597_probe(struct platform_device *pdev)
2483 r8a66597->max_root_hub = 2; 2484 r8a66597->max_root_hub = 2;
2484 2485
2485 spin_lock_init(&r8a66597->lock); 2486 spin_lock_init(&r8a66597->lock);
2486 init_timer(&r8a66597->rh_timer); 2487 setup_timer(&r8a66597->rh_timer, r8a66597_timer,
2487 r8a66597->rh_timer.function = r8a66597_timer; 2488 (unsigned long)r8a66597);
2488 r8a66597->rh_timer.data = (unsigned long)r8a66597;
2489 r8a66597->reg = reg; 2489 r8a66597->reg = reg;
2490 2490
2491 /* make sure no interrupts are pending */ 2491 /* make sure no interrupts are pending */
@@ -2496,9 +2496,8 @@ static int r8a66597_probe(struct platform_device *pdev)
2496 2496
2497 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) { 2497 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) {
2498 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]); 2498 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]);
2499 init_timer(&r8a66597->td_timer[i]); 2499 setup_timer(&r8a66597->td_timer[i], r8a66597_td_timer,
2500 r8a66597->td_timer[i].function = r8a66597_td_timer; 2500 (unsigned long)r8a66597);
2501 r8a66597->td_timer[i].data = (unsigned long)r8a66597;
2502 setup_timer(&r8a66597->interval_timer[i], 2501 setup_timer(&r8a66597->interval_timer[i],
2503 r8a66597_interval_timer, 2502 r8a66597_interval_timer,
2504 (unsigned long)r8a66597); 2503 (unsigned long)r8a66597);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 25fb1da8d3d7..4f4ba1ea9e9b 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1103,12 +1103,12 @@ sl811h_hub_descriptor (
1103 desc->bPwrOn2PwrGood = sl811->board->potpg; 1103 desc->bPwrOn2PwrGood = sl811->board->potpg;
1104 if (!desc->bPwrOn2PwrGood) 1104 if (!desc->bPwrOn2PwrGood)
1105 desc->bPwrOn2PwrGood = 10; 1105 desc->bPwrOn2PwrGood = 10;
1106 temp = 0x0001; 1106 temp = HUB_CHAR_INDV_PORT_LPSM;
1107 } else 1107 } else
1108 temp = 0x0002; 1108 temp = HUB_CHAR_NO_LPSM;
1109 1109
1110 /* no overcurrent errors detection/handling */ 1110 /* no overcurrent errors detection/handling */
1111 temp |= 0x0010; 1111 temp |= HUB_CHAR_NO_OCPM;
1112 1112
1113 desc->wHubCharacteristics = cpu_to_le16(temp); 1113 desc->wHubCharacteristics = cpu_to_le16(temp);
1114 1114
@@ -1691,9 +1691,7 @@ sl811h_probe(struct platform_device *dev)
1691 spin_lock_init(&sl811->lock); 1691 spin_lock_init(&sl811->lock);
1692 INIT_LIST_HEAD(&sl811->async); 1692 INIT_LIST_HEAD(&sl811->async);
1693 sl811->board = dev_get_platdata(&dev->dev); 1693 sl811->board = dev_get_platdata(&dev->dev);
1694 init_timer(&sl811->timer); 1694 setup_timer(&sl811->timer, sl811h_timer, (unsigned long)sl811);
1695 sl811->timer.function = sl811h_timer;
1696 sl811->timer.data = (unsigned long) sl811;
1697 sl811->addr_reg = addr_reg; 1695 sl811->addr_reg = addr_reg;
1698 sl811->data_reg = data_reg; 1696 sl811->data_reg = data_reg;
1699 1697
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 2894e54e5b9c..ad97e8a1ad1c 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -2590,15 +2590,15 @@ static int u132_roothub_descriptor(struct u132 *u132,
2590 desc->bNbrPorts = u132->num_ports; 2590 desc->bNbrPorts = u132->num_ports;
2591 temp = 1 + (u132->num_ports / 8); 2591 temp = 1 + (u132->num_ports / 8);
2592 desc->bDescLength = 7 + 2 * temp; 2592 desc->bDescLength = 7 + 2 * temp;
2593 temp = 0; 2593 temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
2594 if (rh_a & RH_A_NPS) 2594 if (rh_a & RH_A_NPS)
2595 temp |= 0x0002; 2595 temp |= HUB_CHAR_NO_LPSM;
2596 if (rh_a & RH_A_PSM) 2596 if (rh_a & RH_A_PSM)
2597 temp |= 0x0001; 2597 temp |= HUB_CHAR_INDV_PORT_LPSM;
2598 if (rh_a & RH_A_NOCP) 2598 if (rh_a & RH_A_NOCP)
2599 temp |= 0x0010; 2599 temp |= HUB_CHAR_NO_OCPM;
2600 else if (rh_a & RH_A_OCPM) 2600 else if (rh_a & RH_A_OCPM)
2601 temp |= 0x0008; 2601 temp |= HUB_CHAR_INDV_PORT_OCPM;
2602 desc->wHubCharacteristics = cpu_to_le16(temp); 2602 desc->wHubCharacteristics = cpu_to_le16(temp);
2603 retval = u132_read_pcimem(u132, roothub.b, &rh_b); 2603 retval = u132_read_pcimem(u132, roothub.b, &rh_b);
2604 if (retval) 2604 if (retval)
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index 05f57ffdf9ab..0342991c9507 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -188,7 +188,6 @@ static struct platform_driver uhci_grlib_driver = {
188 .shutdown = uhci_hcd_grlib_shutdown, 188 .shutdown = uhci_hcd_grlib_shutdown,
189 .driver = { 189 .driver = {
190 .name = "grlib-uhci", 190 .name = "grlib-uhci",
191 .owner = THIS_MODULE,
192 .of_match_table = uhci_hcd_grlib_of_match, 191 .of_match_table = uhci_hcd_grlib_of_match,
193 }, 192 },
194}; 193};
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index cf8f46003f62..3a3e3eeba291 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -147,7 +147,6 @@ static struct platform_driver uhci_platform_driver = {
147 .shutdown = uhci_hcd_platform_shutdown, 147 .shutdown = uhci_hcd_platform_shutdown,
148 .driver = { 148 .driver = {
149 .name = "platform-uhci", 149 .name = "platform-uhci",
150 .owner = THIS_MODULE,
151 .of_match_table = platform_uhci_ids, 150 .of_match_table = platform_uhci_ids,
152 }, 151 },
153}; 152};
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index bb89175ca6e5..745717ec9c89 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -552,7 +552,7 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci,
552 552
553 if (ctx->type == XHCI_CTX_TYPE_INPUT) { 553 if (ctx->type == XHCI_CTX_TYPE_INPUT) {
554 struct xhci_input_control_ctx *ctrl_ctx = 554 struct xhci_input_control_ctx *ctrl_ctx =
555 xhci_get_input_control_ctx(xhci, ctx); 555 xhci_get_input_control_ctx(ctx);
556 if (!ctrl_ctx) { 556 if (!ctrl_ctx) {
557 xhci_warn(xhci, "Could not get input context, bad type.\n"); 557 xhci_warn(xhci, "Could not get input context, bad type.\n");
558 return; 558 return;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 5cb3d7a10017..f8336408ef07 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -535,7 +535,7 @@ static void xhci_free_container_ctx(struct xhci_hcd *xhci,
535 kfree(ctx); 535 kfree(ctx);
536} 536}
537 537
538struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, 538struct xhci_input_control_ctx *xhci_get_input_control_ctx(
539 struct xhci_container_ctx *ctx) 539 struct xhci_container_ctx *ctx)
540{ 540{
541 if (ctx->type != XHCI_CTX_TYPE_INPUT) 541 if (ctx->type != XHCI_CTX_TYPE_INPUT)
@@ -784,8 +784,7 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark, 784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark,
785 * not at the beginning of the ring). 785 * not at the beginning of the ring).
786 */ 786 */
787void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 787void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx,
788 struct xhci_ep_ctx *ep_ctx,
789 struct xhci_virt_ep *ep) 788 struct xhci_virt_ep *ep)
790{ 789{
791 dma_addr_t addr; 790 dma_addr_t addr;
@@ -833,9 +832,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
833static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, 832static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
834 struct xhci_virt_ep *ep) 833 struct xhci_virt_ep *ep)
835{ 834{
836 init_timer(&ep->stop_cmd_timer); 835 setup_timer(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
837 ep->stop_cmd_timer.data = (unsigned long) ep; 836 (unsigned long)ep);
838 ep->stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog;
839 ep->xhci = xhci; 837 ep->xhci = xhci;
840} 838}
841 839
@@ -1342,8 +1340,7 @@ static u32 xhci_get_endpoint_mult(struct usb_device *udev,
1342 return ep->ss_ep_comp.bmAttributes; 1340 return ep->ss_ep_comp.bmAttributes;
1343} 1341}
1344 1342
1345static u32 xhci_get_endpoint_type(struct usb_device *udev, 1343static u32 xhci_get_endpoint_type(struct usb_host_endpoint *ep)
1346 struct usb_host_endpoint *ep)
1347{ 1344{
1348 int in; 1345 int in;
1349 u32 type; 1346 u32 type;
@@ -1376,8 +1373,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev,
1376 * Basically, this is the maxpacket size, multiplied by the burst size 1373 * Basically, this is the maxpacket size, multiplied by the burst size
1377 * and mult size. 1374 * and mult size.
1378 */ 1375 */
1379static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, 1376static u32 xhci_get_max_esit_payload(struct usb_device *udev,
1380 struct usb_device *udev,
1381 struct usb_host_endpoint *ep) 1377 struct usb_host_endpoint *ep)
1382{ 1378{
1383 int max_burst; 1379 int max_burst;
@@ -1418,7 +1414,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1418 ep_index = xhci_get_endpoint_index(&ep->desc); 1414 ep_index = xhci_get_endpoint_index(&ep->desc);
1419 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1415 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
1420 1416
1421 endpoint_type = xhci_get_endpoint_type(udev, ep); 1417 endpoint_type = xhci_get_endpoint_type(ep);
1422 if (!endpoint_type) 1418 if (!endpoint_type)
1423 return -EINVAL; 1419 return -EINVAL;
1424 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type); 1420 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type);
@@ -1484,7 +1480,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1484 } 1480 }
1485 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) | 1481 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) |
1486 MAX_BURST(max_burst)); 1482 MAX_BURST(max_burst));
1487 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); 1483 max_esit_payload = xhci_get_max_esit_payload(udev, ep);
1488 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); 1484 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload));
1489 1485
1490 /* 1486 /*
@@ -1773,7 +1769,7 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1773 return command; 1769 return command;
1774} 1770}
1775 1771
1776void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) 1772void xhci_urb_free_priv(struct urb_priv *urb_priv)
1777{ 1773{
1778 if (urb_priv) { 1774 if (urb_priv) {
1779 kfree(urb_priv->td[0]); 1775 kfree(urb_priv->td[0]);
@@ -1926,7 +1922,7 @@ static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
1926} 1922}
1927 1923
1928/* TRB math checks for xhci_trb_in_td(), using the command and event rings. */ 1924/* TRB math checks for xhci_trb_in_td(), using the command and event rings. */
1929static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) 1925static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
1930{ 1926{
1931 struct { 1927 struct {
1932 dma_addr_t input_dma; 1928 dma_addr_t input_dma;
@@ -2452,7 +2448,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2452 flags); 2448 flags);
2453 if (!xhci->event_ring) 2449 if (!xhci->event_ring)
2454 goto fail; 2450 goto fail;
2455 if (xhci_check_trb_in_td_math(xhci, flags) < 0) 2451 if (xhci_check_trb_in_td_math(xhci) < 0)
2456 goto fail; 2452 goto fail;
2457 2453
2458 xhci->erst.entries = dma_alloc_coherent(dev, 2454 xhci->erst.entries = dma_alloc_coherent(dev,
@@ -2509,9 +2505,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2509 xhci_print_ir_set(xhci, 0); 2505 xhci_print_ir_set(xhci, 0);
2510 2506
2511 /* init command timeout timer */ 2507 /* init command timeout timer */
2512 init_timer(&xhci->cmd_timer); 2508 setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
2513 xhci->cmd_timer.data = (unsigned long) xhci; 2509 (unsigned long)xhci);
2514 xhci->cmd_timer.function = xhci_handle_command_timeout;
2515 2510
2516 /* 2511 /*
2517 * XXX: Might need to set the Interrupter Moderation Register to 2512 * XXX: Might need to set the Interrupter Moderation Register to
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index e692e769c50c..88da8d629820 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -299,7 +299,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
299 * seconds), then it should assume that the there are 299 * seconds), then it should assume that the there are
300 * larger problems with the xHC and assert HCRST. 300 * larger problems with the xHC and assert HCRST.
301 */ 301 */
302 ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring, 302 ret = xhci_handshake(&xhci->op_regs->cmd_ring,
303 CMD_RING_RUNNING, 0, 5 * 1000 * 1000); 303 CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
304 if (ret < 0) { 304 if (ret < 0) {
305 xhci_err(xhci, "Stopped the command ring failed, " 305 xhci_err(xhci, "Stopped the command ring failed, "
@@ -609,7 +609,7 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
609 609
610 spin_unlock(&xhci->lock); 610 spin_unlock(&xhci->lock);
611 usb_hcd_giveback_urb(hcd, urb, status); 611 usb_hcd_giveback_urb(hcd, urb, status);
612 xhci_urb_free_priv(xhci, urb_priv); 612 xhci_urb_free_priv(urb_priv);
613 spin_lock(&xhci->lock); 613 spin_lock(&xhci->lock);
614 } 614 }
615} 615}
@@ -1110,7 +1110,7 @@ static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id,
1110 * is not waiting on the configure endpoint command. 1110 * is not waiting on the configure endpoint command.
1111 */ 1111 */
1112 virt_dev = xhci->devs[slot_id]; 1112 virt_dev = xhci->devs[slot_id];
1113 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 1113 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
1114 if (!ctrl_ctx) { 1114 if (!ctrl_ctx) {
1115 xhci_warn(xhci, "Could not get input context, bad type.\n"); 1115 xhci_warn(xhci, "Could not get input context, bad type.\n");
1116 return; 1116 return;
@@ -2354,8 +2354,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2354 status = 0; 2354 status = 0;
2355 break; 2355 break;
2356 } 2356 }
2357 xhci_warn(xhci, "ERROR Unknown event condition, HC probably " 2357 xhci_warn(xhci, "ERROR Unknown event condition %u, HC probably busted\n",
2358 "busted\n"); 2358 trb_comp_code);
2359 goto cleanup; 2359 goto cleanup;
2360 } 2360 }
2361 2361
@@ -2497,7 +2497,7 @@ cleanup:
2497 urb = td->urb; 2497 urb = td->urb;
2498 urb_priv = urb->hcpriv; 2498 urb_priv = urb->hcpriv;
2499 2499
2500 xhci_urb_free_priv(xhci, urb_priv); 2500 xhci_urb_free_priv(urb_priv);
2501 2501
2502 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); 2502 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);
2503 if ((urb->actual_length != urb->transfer_buffer_length && 2503 if ((urb->actual_length != urb->transfer_buffer_length &&
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c50d8d202618..ec8ac1674854 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -60,8 +60,7 @@ MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
60 * handshake done). There are two failure modes: "usec" have passed (major 60 * handshake done). There are two failure modes: "usec" have passed (major
61 * hardware flakeout), or the register reads as all-ones (hardware removed). 61 * hardware flakeout), or the register reads as all-ones (hardware removed).
62 */ 62 */
63int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, 63int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
64 u32 mask, u32 done, int usec)
65{ 64{
66 u32 result; 65 u32 result;
67 66
@@ -111,7 +110,7 @@ int xhci_halt(struct xhci_hcd *xhci)
111 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC"); 110 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC");
112 xhci_quiesce(xhci); 111 xhci_quiesce(xhci);
113 112
114 ret = xhci_handshake(xhci, &xhci->op_regs->status, 113 ret = xhci_handshake(&xhci->op_regs->status,
115 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 114 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
116 if (!ret) { 115 if (!ret) {
117 xhci->xhc_state |= XHCI_STATE_HALTED; 116 xhci->xhc_state |= XHCI_STATE_HALTED;
@@ -140,7 +139,7 @@ static int xhci_start(struct xhci_hcd *xhci)
140 * Wait for the HCHalted Status bit to be 0 to indicate the host is 139 * Wait for the HCHalted Status bit to be 0 to indicate the host is
141 * running. 140 * running.
142 */ 141 */
143 ret = xhci_handshake(xhci, &xhci->op_regs->status, 142 ret = xhci_handshake(&xhci->op_regs->status,
144 STS_HALT, 0, XHCI_MAX_HALT_USEC); 143 STS_HALT, 0, XHCI_MAX_HALT_USEC);
145 if (ret == -ETIMEDOUT) 144 if (ret == -ETIMEDOUT)
146 xhci_err(xhci, "Host took too long to start, " 145 xhci_err(xhci, "Host took too long to start, "
@@ -175,7 +174,7 @@ int xhci_reset(struct xhci_hcd *xhci)
175 command |= CMD_RESET; 174 command |= CMD_RESET;
176 writel(command, &xhci->op_regs->command); 175 writel(command, &xhci->op_regs->command);
177 176
178 ret = xhci_handshake(xhci, &xhci->op_regs->command, 177 ret = xhci_handshake(&xhci->op_regs->command,
179 CMD_RESET, 0, 10 * 1000 * 1000); 178 CMD_RESET, 0, 10 * 1000 * 1000);
180 if (ret) 179 if (ret)
181 return ret; 180 return ret;
@@ -186,7 +185,7 @@ int xhci_reset(struct xhci_hcd *xhci)
186 * xHCI cannot write to any doorbells or operational registers other 185 * xHCI cannot write to any doorbells or operational registers other
187 * than status until the "Controller Not Ready" flag is cleared. 186 * than status until the "Controller Not Ready" flag is cleared.
188 */ 187 */
189 ret = xhci_handshake(xhci, &xhci->op_regs->status, 188 ret = xhci_handshake(&xhci->op_regs->status,
190 STS_CNR, 0, 10 * 1000 * 1000); 189 STS_CNR, 0, 10 * 1000 * 1000);
191 190
192 for (i = 0; i < 2; ++i) { 191 for (i = 0; i < 2; ++i) {
@@ -473,10 +472,8 @@ static void compliance_mode_recovery(unsigned long arg)
473static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) 472static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci)
474{ 473{
475 xhci->port_status_u0 = 0; 474 xhci->port_status_u0 = 0;
476 init_timer(&xhci->comp_mode_recovery_timer); 475 setup_timer(&xhci->comp_mode_recovery_timer,
477 476 compliance_mode_recovery, (unsigned long)xhci);
478 xhci->comp_mode_recovery_timer.data = (unsigned long) xhci;
479 xhci->comp_mode_recovery_timer.function = compliance_mode_recovery;
480 xhci->comp_mode_recovery_timer.expires = jiffies + 477 xhci->comp_mode_recovery_timer.expires = jiffies +
481 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS); 478 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS);
482 479
@@ -929,7 +926,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
929 /* Some chips from Fresco Logic need an extraordinary delay */ 926 /* Some chips from Fresco Logic need an extraordinary delay */
930 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; 927 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1;
931 928
932 if (xhci_handshake(xhci, &xhci->op_regs->status, 929 if (xhci_handshake(&xhci->op_regs->status,
933 STS_HALT, STS_HALT, delay)) { 930 STS_HALT, STS_HALT, delay)) {
934 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); 931 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
935 spin_unlock_irq(&xhci->lock); 932 spin_unlock_irq(&xhci->lock);
@@ -944,7 +941,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
944 command = readl(&xhci->op_regs->command); 941 command = readl(&xhci->op_regs->command);
945 command |= CMD_CSS; 942 command |= CMD_CSS;
946 writel(command, &xhci->op_regs->command); 943 writel(command, &xhci->op_regs->command);
947 if (xhci_handshake(xhci, &xhci->op_regs->status, 944 if (xhci_handshake(&xhci->op_regs->status,
948 STS_SAVE, 0, 10 * 1000)) { 945 STS_SAVE, 0, 10 * 1000)) {
949 xhci_warn(xhci, "WARN: xHC save state timeout\n"); 946 xhci_warn(xhci, "WARN: xHC save state timeout\n");
950 spin_unlock_irq(&xhci->lock); 947 spin_unlock_irq(&xhci->lock);
@@ -1011,7 +1008,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1011 command = readl(&xhci->op_regs->command); 1008 command = readl(&xhci->op_regs->command);
1012 command |= CMD_CRS; 1009 command |= CMD_CRS;
1013 writel(command, &xhci->op_regs->command); 1010 writel(command, &xhci->op_regs->command);
1014 if (xhci_handshake(xhci, &xhci->op_regs->status, 1011 if (xhci_handshake(&xhci->op_regs->status,
1015 STS_RESTORE, 0, 10 * 1000)) { 1012 STS_RESTORE, 0, 10 * 1000)) {
1016 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 1013 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
1017 spin_unlock_irq(&xhci->lock); 1014 spin_unlock_irq(&xhci->lock);
@@ -1082,7 +1079,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1082 command = readl(&xhci->op_regs->command); 1079 command = readl(&xhci->op_regs->command);
1083 command |= CMD_RUN; 1080 command |= CMD_RUN;
1084 writel(command, &xhci->op_regs->command); 1081 writel(command, &xhci->op_regs->command);
1085 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT, 1082 xhci_handshake(&xhci->op_regs->status, STS_HALT,
1086 0, 250 * 1000); 1083 0, 250 * 1000);
1087 1084
1088 /* step 5: walk topology and initialize portsc, 1085 /* step 5: walk topology and initialize portsc,
@@ -1276,7 +1273,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
1276 return -ENOMEM; 1273 return -ENOMEM;
1277 1274
1278 command->in_ctx = xhci->devs[slot_id]->in_ctx; 1275 command->in_ctx = xhci->devs[slot_id]->in_ctx;
1279 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 1276 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
1280 if (!ctrl_ctx) { 1277 if (!ctrl_ctx) {
1281 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1278 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1282 __func__); 1279 __func__);
@@ -1374,7 +1371,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
1374 ret = xhci_check_maxpacket(xhci, slot_id, 1371 ret = xhci_check_maxpacket(xhci, slot_id,
1375 ep_index, urb); 1372 ep_index, urb);
1376 if (ret < 0) { 1373 if (ret < 0) {
1377 xhci_urb_free_priv(xhci, urb_priv); 1374 xhci_urb_free_priv(urb_priv);
1378 urb->hcpriv = NULL; 1375 urb->hcpriv = NULL;
1379 return ret; 1376 return ret;
1380 } 1377 }
@@ -1440,7 +1437,7 @@ dying:
1440 urb->ep->desc.bEndpointAddress, urb); 1437 urb->ep->desc.bEndpointAddress, urb);
1441 ret = -ESHUTDOWN; 1438 ret = -ESHUTDOWN;
1442free_priv: 1439free_priv:
1443 xhci_urb_free_priv(xhci, urb_priv); 1440 xhci_urb_free_priv(urb_priv);
1444 urb->hcpriv = NULL; 1441 urb->hcpriv = NULL;
1445 spin_unlock_irqrestore(&xhci->lock, flags); 1442 spin_unlock_irqrestore(&xhci->lock, flags);
1446 return ret; 1443 return ret;
@@ -1553,7 +1550,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1553 usb_hcd_unlink_urb_from_ep(hcd, urb); 1550 usb_hcd_unlink_urb_from_ep(hcd, urb);
1554 spin_unlock_irqrestore(&xhci->lock, flags); 1551 spin_unlock_irqrestore(&xhci->lock, flags);
1555 usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN); 1552 usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN);
1556 xhci_urb_free_priv(xhci, urb_priv); 1553 xhci_urb_free_priv(urb_priv);
1557 return ret; 1554 return ret;
1558 } 1555 }
1559 if ((xhci->xhc_state & XHCI_STATE_DYING) || 1556 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
@@ -1660,7 +1657,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1660 1657
1661 in_ctx = xhci->devs[udev->slot_id]->in_ctx; 1658 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1662 out_ctx = xhci->devs[udev->slot_id]->out_ctx; 1659 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1663 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1660 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
1664 if (!ctrl_ctx) { 1661 if (!ctrl_ctx) {
1665 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1662 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1666 __func__); 1663 __func__);
@@ -1676,8 +1673,10 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1676 cpu_to_le32(EP_STATE_DISABLED)) || 1673 cpu_to_le32(EP_STATE_DISABLED)) ||
1677 le32_to_cpu(ctrl_ctx->drop_flags) & 1674 le32_to_cpu(ctrl_ctx->drop_flags) &
1678 xhci_get_endpoint_flag(&ep->desc)) { 1675 xhci_get_endpoint_flag(&ep->desc)) {
1679 xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", 1676 /* Do not warn when called after a usb_device_reset */
1680 __func__, ep); 1677 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL)
1678 xhci_warn(xhci, "xHCI %s called with disabled ep %p\n",
1679 __func__, ep);
1681 return 0; 1680 return 0;
1682 } 1681 }
1683 1682
@@ -1714,7 +1713,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1714 struct usb_host_endpoint *ep) 1713 struct usb_host_endpoint *ep)
1715{ 1714{
1716 struct xhci_hcd *xhci; 1715 struct xhci_hcd *xhci;
1717 struct xhci_container_ctx *in_ctx, *out_ctx; 1716 struct xhci_container_ctx *in_ctx;
1718 unsigned int ep_index; 1717 unsigned int ep_index;
1719 struct xhci_input_control_ctx *ctrl_ctx; 1718 struct xhci_input_control_ctx *ctrl_ctx;
1720 u32 added_ctxs; 1719 u32 added_ctxs;
@@ -1745,8 +1744,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1745 1744
1746 virt_dev = xhci->devs[udev->slot_id]; 1745 virt_dev = xhci->devs[udev->slot_id];
1747 in_ctx = virt_dev->in_ctx; 1746 in_ctx = virt_dev->in_ctx;
1748 out_ctx = virt_dev->out_ctx; 1747 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
1749 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
1750 if (!ctrl_ctx) { 1748 if (!ctrl_ctx) {
1751 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1749 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1752 __func__); 1750 __func__);
@@ -1758,8 +1756,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1758 * to add it again without dropping it, reject the addition. 1756 * to add it again without dropping it, reject the addition.
1759 */ 1757 */
1760 if (virt_dev->eps[ep_index].ring && 1758 if (virt_dev->eps[ep_index].ring &&
1761 !(le32_to_cpu(ctrl_ctx->drop_flags) & 1759 !(le32_to_cpu(ctrl_ctx->drop_flags) & added_ctxs)) {
1762 xhci_get_endpoint_flag(&ep->desc))) {
1763 xhci_warn(xhci, "Trying to add endpoint 0x%x " 1760 xhci_warn(xhci, "Trying to add endpoint 0x%x "
1764 "without dropping it.\n", 1761 "without dropping it.\n",
1765 (unsigned int) ep->desc.bEndpointAddress); 1762 (unsigned int) ep->desc.bEndpointAddress);
@@ -1769,8 +1766,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1769 /* If the HCD has already noted the endpoint is enabled, 1766 /* If the HCD has already noted the endpoint is enabled,
1770 * ignore this request. 1767 * ignore this request.
1771 */ 1768 */
1772 if (le32_to_cpu(ctrl_ctx->add_flags) & 1769 if (le32_to_cpu(ctrl_ctx->add_flags) & added_ctxs) {
1773 xhci_get_endpoint_flag(&ep->desc)) {
1774 xhci_warn(xhci, "xHCI %s called with enabled ep %p\n", 1770 xhci_warn(xhci, "xHCI %s called with enabled ep %p\n",
1775 __func__, ep); 1771 __func__, ep);
1776 return 0; 1772 return 0;
@@ -1816,7 +1812,7 @@ static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *vir
1816 struct xhci_slot_ctx *slot_ctx; 1812 struct xhci_slot_ctx *slot_ctx;
1817 int i; 1813 int i;
1818 1814
1819 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 1815 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
1820 if (!ctrl_ctx) { 1816 if (!ctrl_ctx) {
1821 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1817 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1822 __func__); 1818 __func__);
@@ -2542,7 +2538,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
2542 if (virt_dev->tt_info) 2538 if (virt_dev->tt_info)
2543 old_active_eps = virt_dev->tt_info->active_eps; 2539 old_active_eps = virt_dev->tt_info->active_eps;
2544 2540
2545 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 2541 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
2546 if (!ctrl_ctx) { 2542 if (!ctrl_ctx) {
2547 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2543 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2548 __func__); 2544 __func__);
@@ -2639,7 +2635,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
2639 spin_lock_irqsave(&xhci->lock, flags); 2635 spin_lock_irqsave(&xhci->lock, flags);
2640 virt_dev = xhci->devs[udev->slot_id]; 2636 virt_dev = xhci->devs[udev->slot_id];
2641 2637
2642 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 2638 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
2643 if (!ctrl_ctx) { 2639 if (!ctrl_ctx) {
2644 spin_unlock_irqrestore(&xhci->lock, flags); 2640 spin_unlock_irqrestore(&xhci->lock, flags);
2645 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2641 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -2758,7 +2754,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2758 command->in_ctx = virt_dev->in_ctx; 2754 command->in_ctx = virt_dev->in_ctx;
2759 2755
2760 /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */ 2756 /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */
2761 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 2757 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
2762 if (!ctrl_ctx) { 2758 if (!ctrl_ctx) {
2763 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2759 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2764 __func__); 2760 __func__);
@@ -2883,7 +2879,7 @@ static void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
2883 dma_addr_t addr; 2879 dma_addr_t addr;
2884 2880
2885 in_ctx = xhci->devs[slot_id]->in_ctx; 2881 in_ctx = xhci->devs[slot_id]->in_ctx;
2886 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 2882 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
2887 if (!ctrl_ctx) { 2883 if (!ctrl_ctx) {
2888 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2884 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2889 __func__); 2885 __func__);
@@ -3173,7 +3169,7 @@ int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
3173 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 3169 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
3174 return -ENOMEM; 3170 return -ENOMEM;
3175 } 3171 }
3176 ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); 3172 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx);
3177 if (!ctrl_ctx) { 3173 if (!ctrl_ctx) {
3178 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3174 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
3179 __func__); 3175 __func__);
@@ -3328,7 +3324,7 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3328 */ 3324 */
3329 ep_index = xhci_get_endpoint_index(&eps[0]->desc); 3325 ep_index = xhci_get_endpoint_index(&eps[0]->desc);
3330 command = vdev->eps[ep_index].stream_info->free_streams_command; 3326 command = vdev->eps[ep_index].stream_info->free_streams_command;
3331 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 3327 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
3332 if (!ctrl_ctx) { 3328 if (!ctrl_ctx) {
3333 spin_unlock_irqrestore(&xhci->lock, flags); 3329 spin_unlock_irqrestore(&xhci->lock, flags);
3334 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3330 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -3346,7 +3342,7 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3346 3342
3347 xhci_endpoint_copy(xhci, command->in_ctx, 3343 xhci_endpoint_copy(xhci, command->in_ctx,
3348 vdev->out_ctx, ep_index); 3344 vdev->out_ctx, ep_index);
3349 xhci_setup_no_streams_ep_input_ctx(xhci, ep_ctx, 3345 xhci_setup_no_streams_ep_input_ctx(ep_ctx,
3350 &vdev->eps[ep_index]); 3346 &vdev->eps[ep_index]);
3351 } 3347 }
3352 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx, 3348 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx,
@@ -3820,7 +3816,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3820 command->completion = &xhci->addr_dev; 3816 command->completion = &xhci->addr_dev;
3821 3817
3822 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); 3818 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
3823 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 3819 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
3824 if (!ctrl_ctx) { 3820 if (!ctrl_ctx) {
3825 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3821 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
3826 __func__); 3822 __func__);
@@ -4003,7 +3999,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
4003 3999
4004 /* Attempt to issue an Evaluate Context command to change the MEL. */ 4000 /* Attempt to issue an Evaluate Context command to change the MEL. */
4005 command = xhci->lpm_command; 4001 command = xhci->lpm_command;
4006 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 4002 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
4007 if (!ctrl_ctx) { 4003 if (!ctrl_ctx) {
4008 spin_unlock_irqrestore(&xhci->lock, flags); 4004 spin_unlock_irqrestore(&xhci->lock, flags);
4009 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 4005 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -4741,7 +4737,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
4741 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 4737 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
4742 return -ENOMEM; 4738 return -ENOMEM;
4743 } 4739 }
4744 ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); 4740 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx);
4745 if (!ctrl_ctx) { 4741 if (!ctrl_ctx) {
4746 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 4742 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
4747 __func__); 4743 __func__);
@@ -4910,6 +4906,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4910 if (retval) 4906 if (retval)
4911 goto error; 4907 goto error;
4912 xhci_dbg(xhci, "Called HCD init\n"); 4908 xhci_dbg(xhci, "Called HCD init\n");
4909
4910 xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%08x\n",
4911 xhci->hcc_params, xhci->hci_version, xhci->quirks);
4912
4913 return 0; 4913 return 0;
4914error: 4914error:
4915 kfree(xhci); 4915 kfree(xhci);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index cc7c5bb7cbcf..974514762a14 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1605,6 +1605,8 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci)
1605 dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args) 1605 dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1606#define xhci_warn_ratelimited(xhci, fmt, args...) \ 1606#define xhci_warn_ratelimited(xhci, fmt, args...) \
1607 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args) 1607 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1608#define xhci_info(xhci, fmt, args...) \
1609 dev_info(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1608 1610
1609/* 1611/*
1610 * Registers should always be accessed with double word or quad word accesses. 1612 * Registers should always be accessed with double word or quad word accesses.
@@ -1712,8 +1714,7 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
1712void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, 1714void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
1713 struct xhci_ep_ctx *ep_ctx, 1715 struct xhci_ep_ctx *ep_ctx,
1714 struct xhci_stream_info *stream_info); 1716 struct xhci_stream_info *stream_info);
1715void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 1717void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx,
1716 struct xhci_ep_ctx *ep_ctx,
1717 struct xhci_virt_ep *ep); 1718 struct xhci_virt_ep *ep);
1718void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci, 1719void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci,
1719 struct xhci_virt_device *virt_dev, bool drop_control_ep); 1720 struct xhci_virt_device *virt_dev, bool drop_control_ep);
@@ -1727,14 +1728,13 @@ struct xhci_ring *xhci_stream_id_to_ring(
1727struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1728struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1728 bool allocate_in_ctx, bool allocate_completion, 1729 bool allocate_in_ctx, bool allocate_completion,
1729 gfp_t mem_flags); 1730 gfp_t mem_flags);
1730void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv); 1731void xhci_urb_free_priv(struct urb_priv *urb_priv);
1731void xhci_free_command(struct xhci_hcd *xhci, 1732void xhci_free_command(struct xhci_hcd *xhci,
1732 struct xhci_command *command); 1733 struct xhci_command *command);
1733 1734
1734/* xHCI host controller glue */ 1735/* xHCI host controller glue */
1735typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); 1736typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1736int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, 1737int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
1737 u32 mask, u32 done, int usec);
1738void xhci_quiesce(struct xhci_hcd *xhci); 1738void xhci_quiesce(struct xhci_hcd *xhci);
1739int xhci_halt(struct xhci_hcd *xhci); 1739int xhci_halt(struct xhci_hcd *xhci);
1740int xhci_reset(struct xhci_hcd *xhci); 1740int xhci_reset(struct xhci_hcd *xhci);
@@ -1864,7 +1864,7 @@ int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
1864void xhci_ring_device(struct xhci_hcd *xhci, int slot_id); 1864void xhci_ring_device(struct xhci_hcd *xhci, int slot_id);
1865 1865
1866/* xHCI contexts */ 1866/* xHCI contexts */
1867struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1867struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_ctx *ctx);
1868struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1868struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
1869struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index); 1869struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index);
1870 1870
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 37b44b04a701..6431d08c8d9d 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -299,9 +299,7 @@ static inline void mts_show_command(struct scsi_cmnd *srb)
299 MTS_DEBUG( "Command %s (%d bytes)\n", what, srb->cmd_len); 299 MTS_DEBUG( "Command %s (%d bytes)\n", what, srb->cmd_len);
300 300
301 out: 301 out:
302 MTS_DEBUG( " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 302 MTS_DEBUG( " %10ph\n", srb->cmnd);
303 srb->cmnd[0], srb->cmnd[1], srb->cmnd[2], srb->cmnd[3], srb->cmnd[4], srb->cmnd[5],
304 srb->cmnd[6], srb->cmnd[7], srb->cmnd[8], srb->cmnd[9]);
305} 303}
306 304
307#else 305#else
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 40ef40affe83..588d62a73e1a 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -124,12 +124,8 @@ static void async_complete(struct urb *urb)
124 } else if (rq->dr->bRequest == 3) { 124 } else if (rq->dr->bRequest == 3) {
125 memcpy(priv->reg, rq->reg, sizeof(priv->reg)); 125 memcpy(priv->reg, rq->reg, sizeof(priv->reg));
126#if 0 126#if 0
127 dev_dbg(&priv->usbdev->dev, 127 dev_dbg(&priv->usbdev->dev, "async_complete regs %7ph\n",
128 "async_complete regs %02x %02x %02x %02x %02x %02x %02x\n", 128 priv->reg);
129 (unsigned int)priv->reg[0], (unsigned int)priv->reg[1],
130 (unsigned int)priv->reg[2], (unsigned int)priv->reg[3],
131 (unsigned int)priv->reg[4], (unsigned int)priv->reg[5],
132 (unsigned int)priv->reg[6]);
133#endif 129#endif
134 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */ 130 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
135 if (rq->reg[2] & rq->reg[1] & 0x10 && pp) 131 if (rq->reg[2] & rq->reg[1] & 0x10 && pp)
@@ -742,9 +738,7 @@ static int uss720_probe(struct usb_interface *intf,
742 set_1284_register(pp, 2, 0x0c, GFP_KERNEL); 738 set_1284_register(pp, 2, 0x0c, GFP_KERNEL);
743 /* debugging */ 739 /* debugging */
744 get_1284_register(pp, 0, &reg, GFP_KERNEL); 740 get_1284_register(pp, 0, &reg, GFP_KERNEL);
745 dev_dbg(&intf->dev, "reg: %02x %02x %02x %02x %02x %02x %02x\n", 741 dev_dbg(&intf->dev, "reg: %7ph\n", priv->reg);
746 priv->reg[0], priv->reg[1], priv->reg[2], priv->reg[3],
747 priv->reg[4], priv->reg[5], priv->reg[6]);
748 742
749 endpoint = &interface->endpoint[2]; 743 endpoint = &interface->endpoint[2];
750 dev_dbg(&intf->dev, "epaddr %d interval %d\n", 744 dev_dbg(&intf->dev, "epaddr %d interval %d\n",
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index b072420e44f5..b79e5be7aa97 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -349,9 +349,10 @@ int musb_hub_control(
349 desc->bDescriptorType = 0x29; 349 desc->bDescriptorType = 0x29;
350 desc->bNbrPorts = 1; 350 desc->bNbrPorts = 1;
351 desc->wHubCharacteristics = cpu_to_le16( 351 desc->wHubCharacteristics = cpu_to_le16(
352 0x0001 /* per-port power switching */ 352 HUB_CHAR_INDV_PORT_LPSM /* per-port power switching */
353 | 0x0010 /* no overcurrent reporting */ 353
354 ); 354 | HUB_CHAR_NO_OCPM /* no overcurrent reporting */
355 );
355 desc->bPwrOn2PwrGood = 5; /* msec/2 */ 356 desc->bPwrOn2PwrGood = 5; /* msec/2 */
356 desc->bHubContrCurrent = 0; 357 desc->bHubContrCurrent = 0;
357 358
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index f0d323125871..96eead619282 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1234,7 +1234,8 @@ static int __usbhsh_hub_get_status(struct usbhsh_hpriv *hpriv,
1234 desc->bNbrPorts = roothub_id; 1234 desc->bNbrPorts = roothub_id;
1235 desc->bDescLength = 9; 1235 desc->bDescLength = 9;
1236 desc->bPwrOn2PwrGood = 0; 1236 desc->bPwrOn2PwrGood = 0;
1237 desc->wHubCharacteristics = cpu_to_le16(0x0011); 1237 desc->wHubCharacteristics =
1238 cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM);
1238 desc->u.hs.DeviceRemovable[0] = (roothub_id << 1); 1239 desc->u.hs.DeviceRemovable[0] = (roothub_id << 1);
1239 desc->u.hs.DeviceRemovable[1] = ~0; 1240 desc->u.hs.DeviceRemovable[1] = ~0;
1240 dev_dbg(dev, "%s :: GetHubDescriptor\n", __func__); 1241 dev_dbg(dev, "%s :: GetHubDescriptor\n", __func__);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index f4c56fc1a9f6..f40c856ff758 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -56,6 +56,7 @@ static const struct usb_device_id id_table[] = {
56 { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */ 56 { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */
57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
58 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ 58 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
59 { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
59 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */ 60 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
60 { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */ 61 { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
61 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 62 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 220b4be89641..e4473a9109cf 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1309,35 +1309,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1309 const unsigned char *current_position = data; 1309 const unsigned char *current_position = data;
1310 unsigned char *data1; 1310 unsigned char *data1;
1311 1311
1312#ifdef NOTMOS7840
1313 Data = 0x00;
1314 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
1315 mos7840_port->shadowLCR = Data;
1316 dev_dbg(&port->dev, "%s: LINE_CONTROL_REGISTER is %x\n", __func__, Data);
1317 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1318
1319 /* Data = 0x03; */
1320 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
1321 /* mos7840_port->shadowLCR=Data;//Need to add later */
1322
1323 Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */
1324 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1325
1326 /* Data = 0x0c; */
1327 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
1328 Data = 0x00;
1329 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
1330 dev_dbg(&port->dev, "%s: DLL value is %x\n", __func__, Data);
1331
1332 Data = 0x0;
1333 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
1334 dev_dbg(&port->dev, "%s: DLM value is %x\n", __func__, Data);
1335
1336 Data = Data & ~SERIAL_LCR_DLAB;
1337 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1338 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1339#endif
1340
1341 if (mos7840_port_paranoia_check(port, __func__)) 1312 if (mos7840_port_paranoia_check(port, __func__))
1342 return -1; 1313 return -1;
1343 1314
@@ -1614,37 +1585,6 @@ static int mos7840_calc_baud_rate_divisor(struct usb_serial_port *port,
1614 *clk_sel_val = 0x70; 1585 *clk_sel_val = 0x70;
1615 } 1586 }
1616 return 0; 1587 return 0;
1617
1618#ifdef NOTMCS7840
1619
1620 for (i = 0; i < ARRAY_SIZE(mos7840_divisor_table); i++) {
1621 if (mos7840_divisor_table[i].BaudRate == baudrate) {
1622 *divisor = mos7840_divisor_table[i].Divisor;
1623 return 0;
1624 }
1625 }
1626
1627 /* After trying for all the standard baud rates *
1628 * Try calculating the divisor for this baud rate */
1629
1630 if (baudrate > 75 && baudrate < 230400) {
1631 /* get the divisor */
1632 custom = (__u16) (230400L / baudrate);
1633
1634 /* Check for round off */
1635 round1 = (__u16) (2304000L / baudrate);
1636 round = (__u16) (round1 - (custom * 10));
1637 if (round > 4)
1638 custom++;
1639 *divisor = custom;
1640
1641 dev_dbg(&port->dev, " Baud %d = %d\n", baudrate, custom);
1642 return 0;
1643 }
1644
1645 dev_dbg(&port->dev, "%s", " Baud calculation Failed...\n");
1646 return -1;
1647#endif
1648} 1588}
1649 1589
1650/***************************************************************************** 1590/*****************************************************************************
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index efdcee15b520..f0c0c53359ad 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -507,18 +507,10 @@ static void option_instat_callback(struct urb *urb);
507#define VIATELECOM_VENDOR_ID 0x15eb 507#define VIATELECOM_VENDOR_ID 0x15eb
508#define VIATELECOM_PRODUCT_CDS7 0x0001 508#define VIATELECOM_PRODUCT_CDS7 0x0001
509 509
510/* some devices interfaces need special handling due to a number of reasons */
511enum option_blacklist_reason {
512 OPTION_BLACKLIST_NONE = 0,
513 OPTION_BLACKLIST_SENDSETUP = 1,
514 OPTION_BLACKLIST_RESERVED_IF = 2
515};
516
517#define MAX_BL_NUM 11
518struct option_blacklist_info { 510struct option_blacklist_info {
519 /* bitfield of interface numbers for OPTION_BLACKLIST_SENDSETUP */ 511 /* bitmask of interface numbers blacklisted for send_setup */
520 const unsigned long sendsetup; 512 const unsigned long sendsetup;
521 /* bitfield of interface numbers for OPTION_BLACKLIST_RESERVED_IF */ 513 /* bitmask of interface numbers that are reserved */
522 const unsigned long reserved; 514 const unsigned long reserved;
523}; 515};
524 516
@@ -1822,36 +1814,13 @@ struct option_private {
1822 1814
1823module_usb_serial_driver(serial_drivers, option_ids); 1815module_usb_serial_driver(serial_drivers, option_ids);
1824 1816
1825static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason,
1826 const struct option_blacklist_info *blacklist)
1827{
1828 unsigned long num;
1829 const unsigned long *intf_list;
1830
1831 if (blacklist) {
1832 if (reason == OPTION_BLACKLIST_SENDSETUP)
1833 intf_list = &blacklist->sendsetup;
1834 else if (reason == OPTION_BLACKLIST_RESERVED_IF)
1835 intf_list = &blacklist->reserved;
1836 else {
1837 BUG_ON(reason);
1838 return false;
1839 }
1840
1841 for_each_set_bit(num, intf_list, MAX_BL_NUM + 1) {
1842 if (num == ifnum)
1843 return true;
1844 }
1845 }
1846 return false;
1847}
1848
1849static int option_probe(struct usb_serial *serial, 1817static int option_probe(struct usb_serial *serial,
1850 const struct usb_device_id *id) 1818 const struct usb_device_id *id)
1851{ 1819{
1852 struct usb_interface_descriptor *iface_desc = 1820 struct usb_interface_descriptor *iface_desc =
1853 &serial->interface->cur_altsetting->desc; 1821 &serial->interface->cur_altsetting->desc;
1854 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1822 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
1823 const struct option_blacklist_info *blacklist;
1855 1824
1856 /* Never bind to the CD-Rom emulation interface */ 1825 /* Never bind to the CD-Rom emulation interface */
1857 if (iface_desc->bInterfaceClass == 0x08) 1826 if (iface_desc->bInterfaceClass == 0x08)
@@ -1862,10 +1831,9 @@ static int option_probe(struct usb_serial *serial,
1862 * the same class/subclass/protocol as the serial interfaces. Look at 1831 * the same class/subclass/protocol as the serial interfaces. Look at
1863 * the Windows driver .INF files for reserved interface numbers. 1832 * the Windows driver .INF files for reserved interface numbers.
1864 */ 1833 */
1865 if (is_blacklisted( 1834 blacklist = (void *)id->driver_info;
1866 iface_desc->bInterfaceNumber, 1835 if (blacklist && test_bit(iface_desc->bInterfaceNumber,
1867 OPTION_BLACKLIST_RESERVED_IF, 1836 &blacklist->reserved))
1868 (const struct option_blacklist_info *) id->driver_info))
1869 return -ENODEV; 1837 return -ENODEV;
1870 /* 1838 /*
1871 * Don't bind network interface on Samsung GT-B3730, it is handled by 1839 * Don't bind network interface on Samsung GT-B3730, it is handled by
@@ -1876,8 +1844,8 @@ static int option_probe(struct usb_serial *serial,
1876 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) 1844 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
1877 return -ENODEV; 1845 return -ENODEV;
1878 1846
1879 /* Store device id so we can use it during attach. */ 1847 /* Store the blacklist info so we can use it during attach. */
1880 usb_set_serial_data(serial, (void *)id); 1848 usb_set_serial_data(serial, (void *)blacklist);
1881 1849
1882 return 0; 1850 return 0;
1883} 1851}
@@ -1885,7 +1853,7 @@ static int option_probe(struct usb_serial *serial,
1885static int option_attach(struct usb_serial *serial) 1853static int option_attach(struct usb_serial *serial)
1886{ 1854{
1887 struct usb_interface_descriptor *iface_desc; 1855 struct usb_interface_descriptor *iface_desc;
1888 const struct usb_device_id *id; 1856 const struct option_blacklist_info *blacklist;
1889 struct usb_wwan_intf_private *data; 1857 struct usb_wwan_intf_private *data;
1890 struct option_private *priv; 1858 struct option_private *priv;
1891 1859
@@ -1899,16 +1867,16 @@ static int option_attach(struct usb_serial *serial)
1899 return -ENOMEM; 1867 return -ENOMEM;
1900 } 1868 }
1901 1869
1902 /* Retrieve device id stored at probe. */ 1870 /* Retrieve blacklist info stored at probe. */
1903 id = usb_get_serial_data(serial); 1871 blacklist = usb_get_serial_data(serial);
1872
1904 iface_desc = &serial->interface->cur_altsetting->desc; 1873 iface_desc = &serial->interface->cur_altsetting->desc;
1905 1874
1906 priv->bInterfaceNumber = iface_desc->bInterfaceNumber; 1875 priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
1907 data->private = priv; 1876 data->private = priv;
1908 1877
1909 if (!is_blacklisted(iface_desc->bInterfaceNumber, 1878 if (!blacklist || !test_bit(iface_desc->bInterfaceNumber,
1910 OPTION_BLACKLIST_SENDSETUP, 1879 &blacklist->sendsetup)) {
1911 (struct option_blacklist_info *)id->driver_info)) {
1912 data->send_setup = option_send_setup; 1880 data->send_setup = option_send_setup;
1913 } 1881 }
1914 spin_lock_init(&data->susp_lock); 1882 spin_lock_init(&data->susp_lock);
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 1ae9d40f96bf..11f6f61c2381 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -218,7 +218,8 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
218 memset(desc, 0, sizeof(*desc)); 218 memset(desc, 0, sizeof(*desc));
219 desc->bDescriptorType = 0x29; 219 desc->bDescriptorType = 0x29;
220 desc->bDescLength = 9; 220 desc->bDescLength = 9;
221 desc->wHubCharacteristics = (__constant_cpu_to_le16(0x0001)); 221 desc->wHubCharacteristics = __constant_cpu_to_le16(
222 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
222 desc->bNbrPorts = VHCI_NPORTS; 223 desc->bNbrPorts = VHCI_NPORTS;
223 desc->u.hs.DeviceRemovable[0] = 0xff; 224 desc->u.hs.DeviceRemovable[0] = 0xff;
224 desc->u.hs.DeviceRemovable[1] = 0xff; 225 desc->u.hs.DeviceRemovable[1] = 0xff;
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index fe8bc777ab88..aa5af817f31c 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -185,9 +185,9 @@ static int wusbhc_rh_get_hub_descr(struct wusbhc *wusbhc, u16 wValue,
185 descr->bDescriptorType = 0x29; /* HUB type */ 185 descr->bDescriptorType = 0x29; /* HUB type */
186 descr->bNbrPorts = wusbhc->ports_max; 186 descr->bNbrPorts = wusbhc->ports_max;
187 descr->wHubCharacteristics = cpu_to_le16( 187 descr->wHubCharacteristics = cpu_to_le16(
188 0x00 /* All ports power at once */ 188 HUB_CHAR_COMMON_LPSM /* All ports power at once */
189 | 0x00 /* not part of compound device */ 189 | 0x00 /* not part of compound device */
190 | 0x10 /* No overcurrent protection */ 190 | HUB_CHAR_NO_OCPM /* No overcurrent protection */
191 | 0x00 /* 8 FS think time FIXME ?? */ 191 | 0x00 /* 8 FS think time FIXME ?? */
192 | 0x00); /* No port indicators */ 192 | 0x00); /* No port indicators */
193 descr->bPwrOn2PwrGood = 0; 193 descr->bPwrOn2PwrGood = 0;
diff --git a/drivers/uwb/lc-dev.c b/drivers/uwb/lc-dev.c
index 8c7cfab5cee3..72033589db19 100644
--- a/drivers/uwb/lc-dev.c
+++ b/drivers/uwb/lc-dev.c
@@ -43,13 +43,6 @@ static inline void uwb_mac_addr_init(struct uwb_mac_addr *addr)
43 memset(&addr->data, 0xff, sizeof(addr->data)); 43 memset(&addr->data, 0xff, sizeof(addr->data));
44} 44}
45 45
46/* @returns !0 if a device @addr is a broadcast address */
47static inline int uwb_dev_addr_bcast(const struct uwb_dev_addr *addr)
48{
49 static const struct uwb_dev_addr bcast = { .data = { 0xff, 0xff } };
50 return !uwb_dev_addr_cmp(addr, &bcast);
51}
52
53/* 46/*
54 * Add callback @new to be called when an event occurs in @rc. 47 * Add callback @new to be called when an event occurs in @rc.
55 */ 48 */
diff --git a/include/linux/mfd/syscon/exynos4-pmu.h b/include/linux/mfd/syscon/exynos4-pmu.h
new file mode 100644
index 000000000000..278b1b1549e9
--- /dev/null
+++ b/include/linux/mfd/syscon/exynos4-pmu.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (C) 2015 Samsung Electronics Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_
10#define _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_
11
12/* Exynos4 PMU register definitions */
13
14/* MIPI_PHYn_CONTROL register offset: n = 0..1 */
15#define EXYNOS4_MIPI_PHY_CONTROL(n) (0x710 + (n) * 4)
16#define EXYNOS4_MIPI_PHY_ENABLE (1 << 0)
17#define EXYNOS4_MIPI_PHY_SRESETN (1 << 1)
18#define EXYNOS4_MIPI_PHY_MRESETN (1 << 2)
19#define EXYNOS4_MIPI_PHY_RESET_MASK (3 << 1)
20
21#endif /* _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_ */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 745def862580..470a240f66a1 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -53,9 +53,9 @@ struct ieee1394_device_id {
53 53
54/** 54/**
55 * struct usb_device_id - identifies USB devices for probing and hotplugging 55 * struct usb_device_id - identifies USB devices for probing and hotplugging
56 * @match_flags: Bit mask controlling of the other fields are used to match 56 * @match_flags: Bit mask controlling which of the other fields are used to
57 * against new devices. Any field except for driver_info may be used, 57 * match against new devices. Any field except for driver_info may be
58 * although some only make sense in conjunction with other fields. 58 * used, although some only make sense in conjunction with other fields.
59 * This is usually set by a USB_DEVICE_*() macro, which sets all 59 * This is usually set by a USB_DEVICE_*() macro, which sets all
60 * other fields in this structure except for driver_info. 60 * other fields in this structure except for driver_info.
61 * @idVendor: USB vendor ID for a device; numbers are assigned 61 * @idVendor: USB vendor ID for a device; numbers are assigned
diff --git a/include/linux/usb.h b/include/linux/usb.h
index f89c24a03bd9..7ee1b5c3b4cb 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -82,7 +82,7 @@ struct usb_host_interface {
82 int extralen; 82 int extralen;
83 unsigned char *extra; /* Extra descriptors */ 83 unsigned char *extra; /* Extra descriptors */
84 84
85 /* array of desc.bNumEndpoint endpoints associated with this 85 /* array of desc.bNumEndpoints endpoints associated with this
86 * interface setting. these will be in no particular order. 86 * interface setting. these will be in no particular order.
87 */ 87 */
88 struct usb_host_endpoint *endpoint; 88 struct usb_host_endpoint *endpoint;
@@ -127,10 +127,6 @@ enum usb_interface_condition {
127 * to the sysfs representation for that device. 127 * to the sysfs representation for that device.
128 * @pm_usage_cnt: PM usage counter for this interface 128 * @pm_usage_cnt: PM usage counter for this interface
129 * @reset_ws: Used for scheduling resets from atomic context. 129 * @reset_ws: Used for scheduling resets from atomic context.
130 * @reset_running: set to 1 if the interface is currently running a
131 * queued reset so that usb_cancel_queued_reset() doesn't try to
132 * remove from the workqueue when running inside the worker
133 * thread. See __usb_queue_reset_device().
134 * @resetting_device: USB core reset the device, so use alt setting 0 as 130 * @resetting_device: USB core reset the device, so use alt setting 0 as
135 * current; needs bandwidth alloc after reset. 131 * current; needs bandwidth alloc after reset.
136 * 132 *
@@ -181,7 +177,6 @@ struct usb_interface {
181 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 177 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
182 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ 178 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
183 unsigned needs_binding:1; /* needs delayed unbind/rebind */ 179 unsigned needs_binding:1; /* needs delayed unbind/rebind */
184 unsigned reset_running:1;
185 unsigned resetting_device:1; /* true: bandwidth alloc after reset */ 180 unsigned resetting_device:1; /* true: bandwidth alloc after reset */
186 181
187 struct device dev; /* interface specific device info */ 182 struct device dev; /* interface specific device info */
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index 7eb4dcd0d386..db0431b39a63 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -34,6 +34,8 @@ struct usb_hcd;
34 * after initialization. 34 * after initialization.
35 * @no_io_watchdog: set to 1 if the controller does not need the I/O 35 * @no_io_watchdog: set to 1 if the controller does not need the I/O
36 * watchdog to run. 36 * watchdog to run.
37 * @reset_on_resume: set to 1 if the controller needs to be reset after
38 * a suspend / resume cycle (but can't detect that itself).
37 * 39 *
38 * These are general configuration options for the EHCI controller. All of 40 * These are general configuration options for the EHCI controller. All of
39 * these options are activating more or less workarounds for some hardware. 41 * these options are activating more or less workarounds for some hardware.
@@ -45,6 +47,8 @@ struct usb_ehci_pdata {
45 unsigned big_endian_desc:1; 47 unsigned big_endian_desc:1;
46 unsigned big_endian_mmio:1; 48 unsigned big_endian_mmio:1;
47 unsigned no_io_watchdog:1; 49 unsigned no_io_watchdog:1;
50 unsigned reset_on_resume:1;
51 unsigned dma_mask_64:1;
48 52
49 /* Turn on all power and clocks */ 53 /* Turn on all power and clocks */
50 int (*power_on)(struct platform_device *pdev); 54 int (*power_on)(struct platform_device *pdev);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 086bf13307e6..68b1e836dff1 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -146,6 +146,8 @@ struct usb_hcd {
146 unsigned amd_resume_bug:1; /* AMD remote wakeup quirk */ 146 unsigned amd_resume_bug:1; /* AMD remote wakeup quirk */
147 unsigned can_do_streams:1; /* HC supports streams */ 147 unsigned can_do_streams:1; /* HC supports streams */
148 unsigned tpl_support:1; /* OTG & EH TPL support */ 148 unsigned tpl_support:1; /* OTG & EH TPL support */
149 unsigned cant_recv_wakeups:1;
150 /* wakeup requests from downstream aren't received */
149 151
150 unsigned int irq; /* irq allocated */ 152 unsigned int irq; /* irq allocated */
151 void __iomem *regs; /* device memory/io */ 153 void __iomem *regs; /* device memory/io */
@@ -453,6 +455,7 @@ extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
453#endif /* CONFIG_PCI */ 455#endif /* CONFIG_PCI */
454 456
455/* pci-ish (pdev null is ok) buffer alloc/mapping support */ 457/* pci-ish (pdev null is ok) buffer alloc/mapping support */
458void usb_init_pool_max(void);
456int hcd_buffer_create(struct usb_hcd *hcd); 459int hcd_buffer_create(struct usb_hcd *hcd);
457void hcd_buffer_destroy(struct usb_hcd *hcd); 460void hcd_buffer_destroy(struct usb_hcd *hcd);
458 461
diff --git a/include/uapi/linux/usbdevice_fs.h b/include/uapi/linux/usbdevice_fs.h
index abe5f4bd4d82..019ba1e0799a 100644
--- a/include/uapi/linux/usbdevice_fs.h
+++ b/include/uapi/linux/usbdevice_fs.h
@@ -128,11 +128,12 @@ struct usbdevfs_hub_portinfo {
128 char port [127]; /* e.g. port 3 connects to device 27 */ 128 char port [127]; /* e.g. port 3 connects to device 27 */
129}; 129};
130 130
131/* Device capability flags */ 131/* System and bus capability flags */
132#define USBDEVFS_CAP_ZERO_PACKET 0x01 132#define USBDEVFS_CAP_ZERO_PACKET 0x01
133#define USBDEVFS_CAP_BULK_CONTINUATION 0x02 133#define USBDEVFS_CAP_BULK_CONTINUATION 0x02
134#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04 134#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
135#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08 135#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
136#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
136 137
137/* USBDEVFS_DISCONNECT_CLAIM flags & struct */ 138/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
138 139