Commit 752e6955 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'usb-for-v3.12-part2' of...

Merge tag 'usb-for-v3.12-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next

Felipe writes:

usb: patches for v3.12 merge window (part 2)

Here's a set of important fixes for v3.12 merge
window which have been pending in the mailing list
for quite some time.

We have use-after-free fixes, signedness fixes,
more of HAS_DMA dependencies, fixes for NULL pointer
deferences, build fixes and some other fixes to
the musb driver caused by recent patches.

Patches are quite small and contain valuable fixes
which will give us a much better -rc1 release.

Please consider merging
Signed-of-by: default avatarFelipe Balbi <balbi@ti.com>
parents f2e0ae93 0f2aa8ca
AM33XX MUSB GLUE AM33xx MUSB
- compatible : Should be "ti,musb-am33xx" ~~~~~~~~~~~~~~~
- reg : offset and length of register sets, first usbss, then for musb instances - compatible: ti,am33xx-usb
- interrupts : usbss, musb instance interrupts in order - reg: offset and length of the usbss register sets
- ti,hwmods : must be "usb_otg_hs" - ti,hwmods : must be "usb_otg_hs"
- multipoint : Should be "1" indicating the musb controller supports
multipoint. This is a MUSB configuration-specific setting. The glue layer contains multiple child nodes. It is required the have
- num-eps : Specifies the number of endpoints. This is also a at least a control module node, USB node and a PHY node. The second USB
MUSB configuration-specific setting. Should be set to "16" node and its PHY node is optional. The DMA node is also optional.
- ram-bits : Specifies the ram address size. Should be set to "12"
- port0-mode : Should be "3" to represent OTG. "1" signifies HOST and "2" Reset module
represents PERIPHERAL. ~~~~~~~~~~~~
- port1-mode : Should be "1" to represent HOST. "3" signifies OTG and "2" - compatible: ti,am335x-usb-ctrl-module
represents PERIPHERAL. - reg: offset and length of the "USB control registers" in the "Control
- power : Should be "250". This signifies the controller can supply up to Module" block. A second offset and length for the USB wake up control
500mA when operating in host mode. in the same memory block.
- reg-names: "phy_ctrl" for the "USB control registers" and "wakeup" for
the USB wake up control register.
USB PHY
~~~~~~~
compatible: ti,am335x-usb-phy
reg: offset and length of the "USB PHY" register space
ti,ctrl_mod: reference to the "reset module" node
reg-names: phy
The PHY should have a "phy" alias numbered properly in the alias
node.
USB
~~~
- compatible: ti,musb-am33xx
- reg: offset and length of "USB Controller Registers", and offset and
length of "USB Core" register space.
- reg-names: control for the ""USB Controller Registers" and "mc" for
"USB Core" register space
- interrupts: USB interrupt number
- interrupt-names: mc
- dr_mode: Should be one of "host", "peripheral" or "otg".
- mentor,multipoint: Should be "1" indicating the musb controller supports
multipoint. This is a MUSB configuration-specific setting.
- mentor,num-eps: Specifies the number of endpoints. This is also a
MUSB configuration-specific setting. Should be set to "16"
- mentor,ram-bits: Specifies the ram address size. Should be set to "12"
- mentor,power: Should be "500". This signifies the controller can supply up to
500mA when operating in host mode.
- phys: reference to the USB phy
- dmas: specifies the dma channels
- dma-names: specifies the names of the channels. Use "rxN" for receive
and "txN" for transmit endpoints. N specifies the endpoint number.
The controller should have an "usb" alias numbered properly in the alias
node.
DMA
~~~
- compatible: ti,am3359-cppi41
- reg: offset and length of the following register spaces: USBSS, USB
CPPI DMA Controller, USB CPPI DMA Scheduler, USB Queue Manager
- reg-names: glue, controller, scheduler, queuemgr
- #dma-cells: should be set to 2. The first number represents the
endpoint number (0 … 14 for endpoints 1 … 15 on instance 0 and 15 … 29
for endpoints 1 … 15 on instance 1). The second number is 0 for RX and
1 for TX transfers.
- #dma-channels: should be set to 30 representing the 15 endpoints for
each USB instance.
Example: Example:
~~~~~~~~
The following example contains all the nodes as used on am335x-evm:
aliases {
usb0 = &usb0;
usb1 = &usb1;
phy0 = &usb0_phy;
phy1 = &usb1_phy;
};
usb@47400000 { usb: usb@47400000 {
compatible = "ti,musb-am33xx"; compatible = "ti,am33xx-usb";
reg = <0x47400000 0x1000 /* usbss */ reg = <0x47400000 0x1000>;
0x47401000 0x800 /* musb instance 0 */ ranges;
0x47401800 0x800>; /* musb instance 1 */ #address-cells = <1>;
interrupts = <17 /* usbss */ #size-cells = <1>;
18 /* musb instance 0 */
19>; /* musb instance 1 */
multipoint = <1>;
num-eps = <16>;
ram-bits = <12>;
port0-mode = <3>;
port1-mode = <3>;
power = <250>;
ti,hwmods = "usb_otg_hs"; ti,hwmods = "usb_otg_hs";
ctrl_mod: control@44e10000 {
compatible = "ti,am335x-usb-ctrl-module";
reg = <0x44e10620 0x10
0x44e10648 0x4>;
reg-names = "phy_ctrl", "wakeup";
};
usb0_phy: usb-phy@47401300 {
compatible = "ti,am335x-usb-phy";
reg = <0x47401300 0x100>;
reg-names = "phy";
ti,ctrl_mod = <&ctrl_mod>;
};
usb0: usb@47401000 {
compatible = "ti,musb-am33xx";
reg = <0x47401400 0x400
0x47401000 0x200>;
reg-names = "mc", "control";
interrupts = <18>;
interrupt-names = "mc";
dr_mode = "otg"
mentor,multipoint = <1>;
mentor,num-eps = <16>;
mentor,ram-bits = <12>;
mentor,power = <500>;
phys = <&usb0_phy>;
dmas = <&cppi41dma 0 0 &cppi41dma 1 0
&cppi41dma 2 0 &cppi41dma 3 0
&cppi41dma 4 0 &cppi41dma 5 0
&cppi41dma 6 0 &cppi41dma 7 0
&cppi41dma 8 0 &cppi41dma 9 0
&cppi41dma 10 0 &cppi41dma 11 0
&cppi41dma 12 0 &cppi41dma 13 0
&cppi41dma 14 0 &cppi41dma 0 1
&cppi41dma 1 1 &cppi41dma 2 1
&cppi41dma 3 1 &cppi41dma 4 1
&cppi41dma 5 1 &cppi41dma 6 1
&cppi41dma 7 1 &cppi41dma 8 1
&cppi41dma 9 1 &cppi41dma 10 1
&cppi41dma 11 1 &cppi41dma 12 1
&cppi41dma 13 1 &cppi41dma 14 1>;
dma-names =
"rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7",
"rx8", "rx9", "rx10", "rx11", "rx12", "rx13",
"rx14", "rx15",
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15";
};
usb1_phy: usb-phy@47401b00 {
compatible = "ti,am335x-usb-phy";
reg = <0x47401b00 0x100>;
reg-names = "phy";
ti,ctrl_mod = <&ctrl_mod>;
};
usb1: usb@47401800 {
compatible = "ti,musb-am33xx";
reg = <0x47401c00 0x400
0x47401800 0x200>;
reg-names = "mc", "control";
interrupts = <19>;
interrupt-names = "mc";
dr_mode = "host"
mentor,multipoint = <1>;
mentor,num-eps = <16>;
mentor,ram-bits = <12>;
mentor,power = <500>;
phys = <&usb1_phy>;
dmas = <&cppi41dma 15 0 &cppi41dma 16 0
&cppi41dma 17 0 &cppi41dma 18 0
&cppi41dma 19 0 &cppi41dma 20 0
&cppi41dma 21 0 &cppi41dma 22 0
&cppi41dma 23 0 &cppi41dma 24 0
&cppi41dma 25 0 &cppi41dma 26 0
&cppi41dma 27 0 &cppi41dma 28 0
&cppi41dma 29 0 &cppi41dma 15 1
&cppi41dma 16 1 &cppi41dma 17 1
&cppi41dma 18 1 &cppi41dma 19 1
&cppi41dma 20 1 &cppi41dma 21 1
&cppi41dma 22 1 &cppi41dma 23 1
&cppi41dma 24 1 &cppi41dma 25 1
&cppi41dma 26 1 &cppi41dma 27 1
&cppi41dma 28 1 &cppi41dma 29 1>;
dma-names =
"rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7",
"rx8", "rx9", "rx10", "rx11", "rx12", "rx13",
"rx14", "rx15",
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15";
};
cppi41dma: dma-controller@07402000 {
compatible = "ti,am3359-cppi41";
reg = <0x47400000 0x1000
0x47402000 0x1000
0x47403000 0x1000
0x47404000 0x4000>;
reg-names = "glue", "controller", "scheduler", "queuemgr";
interrupts = <17>;
interrupt-names = "glue";
#dma-cells = <2>;
#dma-channels = <30>;
#dma-requests = <256>;
};
}; };
...@@ -127,13 +127,26 @@ control@44e10000 { ...@@ -127,13 +127,26 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay";
};
usb-phy@47401b00 {
status = "okay"; status = "okay";
}; };
usb@47401000 { usb@47401000 {
status = "okay"; status = "okay";
}; };
usb@47401800 {
status = "okay";
dr_mode = "host";
};
dma-controller@07402000 {
status = "okay";
};
}; };
i2c0: i2c@44e0b000 { i2c0: i2c@44e0b000 {
......
...@@ -178,11 +178,11 @@ control@44e10000 { ...@@ -178,11 +178,11 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay"; status = "okay";
}; };
phy@47401b00 { usb-phy@47401b00 {
status = "okay"; status = "okay";
}; };
...@@ -192,9 +192,10 @@ usb@47401000 { ...@@ -192,9 +192,10 @@ usb@47401000 {
usb@47401800 { usb@47401800 {
status = "okay"; status = "okay";
dr_mode = "host";
}; };
dma@07402000 { dma-controller@07402000 {
status = "okay"; status = "okay";
}; };
}; };
......
...@@ -214,7 +214,7 @@ control@44e10000 { ...@@ -214,7 +214,7 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay"; status = "okay";
}; };
......
...@@ -354,7 +354,7 @@ ctrl_mod: control@44e10000 { ...@@ -354,7 +354,7 @@ ctrl_mod: control@44e10000 {
status = "disabled"; status = "disabled";
}; };
usb0_phy: phy@47401300 { usb0_phy: usb-phy@47401300 {
compatible = "ti,am335x-usb-phy"; compatible = "ti,am335x-usb-phy";
reg = <0x47401300 0x100>; reg = <0x47401300 0x100>;
reg-names = "phy"; reg-names = "phy";
...@@ -364,25 +364,19 @@ usb0_phy: phy@47401300 { ...@@ -364,25 +364,19 @@ usb0_phy: phy@47401300 {
usb0: usb@47401000 { usb0: usb@47401000 {
compatible = "ti,musb-am33xx"; compatible = "ti,musb-am33xx";
ranges;
#address-cells = <1>;
#size-cells = <1>;
reg = <0x47401000 0x200>;
reg-names = "control";
status = "disabled"; status = "disabled";
reg = <0x47401400 0x400
musb0: usb@47401400 { 0x47401000 0x200>;
compatible = "mg,musbmhdrc"; reg-names = "mc", "control";
reg = <0x47401400 0x400>;
reg-names = "mc"; interrupts = <18>;
interrupts = <18>; interrupt-names = "mc";
interrupt-names = "mc"; dr_mode = "otg";
multipoint = <1>; mentor,multipoint = <1>;
num-eps = <16>; mentor,num-eps = <16>;
ram-bits = <12>; mentor,ram-bits = <12>;
port-mode = <3>; mentor,power = <500>;
power = <250>; phys = <&usb0_phy>;
phys = <&usb0_phy>;
dmas = <&cppi41dma 0 0 &cppi41dma 1 0 dmas = <&cppi41dma 0 0 &cppi41dma 1 0
&cppi41dma 2 0 &cppi41dma 3 0 &cppi41dma 2 0 &cppi41dma 3 0
...@@ -406,10 +400,9 @@ &cppi41dma 11 1 &cppi41dma 12 1 ...@@ -406,10 +400,9 @@ &cppi41dma 11 1 &cppi41dma 12 1
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15"; "tx14", "tx15";
};
}; };
usb1_phy: phy@47401b00 { usb1_phy: usb-phy@47401b00 {
compatible = "ti,am335x-usb-phy"; compatible = "ti,am335x-usb-phy";
reg = <0x47401b00 0x100>; reg = <0x47401b00 0x100>;
reg-names = "phy"; reg-names = "phy";
...@@ -419,25 +412,18 @@ usb1_phy: phy@47401b00 { ...@@ -419,25 +412,18 @@ usb1_phy: phy@47401b00 {
usb1: usb@47401800 { usb1: usb@47401800 {
compatible = "ti,musb-am33xx"; compatible = "ti,musb-am33xx";
ranges;
#address-cells = <1>;
#size-cells = <1>;
reg = <0x47401800 0x200>;
reg-names = "control";
status = "disabled"; status = "disabled";
reg = <0x47401c00 0x400
musb1: usb@47401c00 { 0x47401800 0x200>;
compatible = "mg,musbmhdrc"; reg-names = "mc", "control";
reg = <0x47401c00 0x400>; interrupts = <19>;
reg-names = "mc"; interrupt-names = "mc";
interrupts = <19>; dr_mode = "otg";
interrupt-names = "mc"; mentor,multipoint = <1>;
multipoint = <1>; mentor,num-eps = <16>;
num-eps = <16>; mentor,ram-bits = <12>;
ram-bits = <12>; mentor,power = <500>;
port-mode = <3>; phys = <&usb1_phy>;
power = <250>;
phys = <&usb1_phy>;
dmas = <&cppi41dma 15 0 &cppi41dma 16 0 dmas = <&cppi41dma 15 0 &cppi41dma 16 0
&cppi41dma 17 0 &cppi41dma 18 0 &cppi41dma 17 0 &cppi41dma 18 0
...@@ -461,16 +447,15 @@ &cppi41dma 26 1 &cppi41dma 27 1 ...@@ -461,16 +447,15 @@ &cppi41dma 26 1 &cppi41dma 27 1
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15"; "tx14", "tx15";
};
}; };
cppi41dma: dma@07402000 { cppi41dma: dma-controller@07402000 {
compatible = "ti,am3359-cppi41"; compatible = "ti,am3359-cppi41";
reg = <0x47400000 0x1000 reg = <0x47400000 0x1000
0x47402000 0x1000 0x47402000 0x1000
0x47403000 0x1000 0x47403000 0x1000
0x47404000 0x4000>; 0x47404000 0x4000>;
reg-names = "glue controller scheduler queuemgr"; reg-names = "glue", "controller", "scheduler", "queuemgr";
interrupts = <17>; interrupts = <17>;
interrupt-names = "glue"; interrupt-names = "glue";
#dma-cells = <2>; #dma-cells = <2>;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/pm_runtime.h>
#include "dmaengine.h" #include "dmaengine.h"
#define DESC_TYPE 27 #define DESC_TYPE 27
...@@ -579,7 +580,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c) ...@@ -579,7 +580,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
WARN_ON(!c->is_tx && !(pd0 & TD_DESC_IS_RX)); WARN_ON(!c->is_tx && !(pd0 & TD_DESC_IS_RX));
WARN_ON((pd0 & 0x1f) != c->port_num); WARN_ON((pd0 & 0x1f) != c->port_num);
} else { } else {
__WARN(); WARN_ON_ONCE(1);
} }
c->td_seen = 1; c->td_seen = 1;
} }
...@@ -960,6 +961,11 @@ static int cppi41_dma_probe(struct platform_device *pdev) ...@@ -960,6 +961,11 @@ static int cppi41_dma_probe(struct platform_device *pdev)
goto err_remap; goto err_remap;
} }
pm_runtime_enable(&pdev->dev);
ret = pm_runtime_get_sync(&pdev->dev);
if (ret)
goto err_get_sync;
cdd->queues_rx = glue_info->queues_rx; cdd->queues_rx = glue_info->queues_rx;
cdd->queues_tx = glue_info->queues_tx; cdd->queues_tx = glue_info->queues_tx;
cdd->td_queue = glue_info->td_queue; cdd->td_queue = glue_info->td_queue;
...@@ -1005,6 +1011,9 @@ static int cppi41_dma_probe(struct platform_device *pdev) ...@@ -1005,6 +1011,9 @@ static int cppi41_dma_probe(struct platform_device *pdev)
err_chans: err_chans:
deinit_cpii41(pdev, cdd); deinit_cpii41(pdev, cdd);
err_init_cppi: err_init_cppi:
pm_runtime_put(&pdev->dev);
err_get_sync:
pm_runtime_disable(&pdev->dev);
iounmap(cdd->usbss_mem); iounmap(cdd->usbss_mem);
iounmap(cdd->ctrl_mem); iounmap(cdd->ctrl_mem);
iounmap(cdd->sched_mem); iounmap(cdd->sched_mem);
...@@ -1029,6 +1038,8 @@ static int cppi41_dma_remove(struct platform_device *pdev) ...@@ -1029,6 +1038,8 @@ static int cppi41_dma_remove(struct platform_device *pdev)
iounmap(cdd->ctrl_mem); iounmap(cdd->ctrl_mem);
iounmap(cdd->sched_mem); iounmap(cdd->sched_mem);
iounmap(cdd->qmgr_mem); iounmap(cdd->qmgr_mem);
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
kfree(cdd); kfree(cdd);
return 0; return 0;
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/usb/otg.h>
#include <linux/usb/ch9.h> #include <linux/usb/ch9.h>
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
#include <linux/usb/of.h> #include <linux/usb/of.h>
......
...@@ -187,7 +187,7 @@ config USB_FSL_USB2 ...@@ -187,7 +187,7 @@ config USB_FSL_USB2
config USB_FUSB300 config USB_FUSB300
tristate "Faraday FUSB300 USB Peripheral Controller" tristate "Faraday FUSB300 USB Peripheral Controller"
depends on !PHYS_ADDR_T_64BIT depends on !PHYS_ADDR_T_64BIT && HAS_DMA
help help
Faraday usb device controller FUSB300 driver Faraday usb device controller FUSB300 driver
...@@ -244,6 +244,7 @@ config USB_PXA25X_SMALL ...@@ -244,6 +244,7 @@ config USB_PXA25X_SMALL
config USB_R8A66597 config USB_R8A66597
tristate "Renesas R8A66597 USB Peripheral Controller" tristate "Renesas R8A66597 USB Peripheral Controller"
depends on HAS_DMA
help help
R8A66597 is a discrete USB host and peripheral controller chip that R8A66597 is a discrete USB host and peripheral controller chip that
supports both full and high speed USB 2.0 data transfers. supports both full and high speed USB 2.0 data transfers.
...@@ -385,7 +386,7 @@ config USB_NET2272 ...@@ -385,7 +386,7 @@ config USB_NET2272
config USB_NET2272_DMA config USB_NET2272_DMA
boolean "Support external DMA controller" boolean "Support external DMA controller"
depends on USB_NET2272 depends on USB_NET2272 && HAS_DMA
help help
The NET2272 part can optionally support an external DMA The NET2272 part can optionally support an external DMA
controller, but your board has to have support in the controller, but your board has to have support in the
......
...@@ -1772,7 +1772,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) ...@@ -1772,7 +1772,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
static int atmel_usba_start(struct usb_gadget *gadget, static int atmel_usba_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
int ret = 0; int ret;
struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags; unsigned long flags;
...@@ -1784,11 +1784,11 @@ static int atmel_usba_start(struct usb_gadget *gadget, ...@@ -1784,11 +1784,11 @@ static int atmel_usba_start(struct usb_gadget *gadget,
ret = clk_prepare_enable(udc->pclk); ret = clk_prepare_enable(udc->pclk);
if (ret) if (ret)
goto out; return ret;
ret = clk_prepare_enable(udc->hclk); ret = clk_prepare_enable(udc->hclk);
if (ret) { if (ret) {
clk_disable_unprepare(udc->pclk); clk_disable_unprepare(udc->pclk);
goto out; return ret;
} }
DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name); DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name);
...@@ -1804,11 +1804,9 @@ static int atmel_usba_start(struct usb_gadget *gadget, ...@@ -1804,11 +1804,9 @@ static int atmel_usba_start(struct usb_gadget *gadget,
usba_writel(udc, CTRL, USBA_ENABLE_MASK); usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET); usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
} }
out:
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return ret; return 0;
} }
static int atmel_usba_stop(struct usb_gadget *gadget, static int atmel_usba_stop(struct usb_gadget *gadget,
......
...@@ -859,8 +859,10 @@ static int configfs_composite_bind(struct usb_gadget *gadget, ...@@ -859,8 +859,10 @@ static int configfs_composite_bind(struct usb_gadget *gadget,
list_for_each_entry_safe(f, tmp, &cfg->func_list, list) { list_for_each_entry_safe(f, tmp, &cfg->func_list, list) {
list_del(&f->list); list_del(&f->list);
ret = usb_add_function(c, f); ret = usb_add_function(c, f);
if (ret) if (ret) {
list_add(&f->list, &cfg->func_list);
goto err_purge_funcs; goto err_purge_funcs;
}
} }
usb_ep_autoconfig_reset(cdev->gadget); usb_ep_autoconfig_reset(cdev->gadget);
} }
......
...@@ -1417,8 +1417,8 @@ static void functionfs_unbind(struct ffs_data *ffs) ...@@ -1417,8 +1417,8 @@ static void functionfs_unbind(struct ffs_data *ffs)
usb_ep_free_request(ffs->gadget->ep0, ffs->ep0req); usb_ep_free_request(ffs->gadget->ep0, ffs->ep0req);
ffs->ep0req = NULL; ffs->ep0req = NULL;
ffs->gadget = NULL; ffs->gadget = NULL;
ffs_data_put(ffs);
clear_bit(FFS_FL_BOUND, &ffs->flags); clear_bit(FFS_FL_BOUND, &ffs->flags);
ffs_data_put(ffs);
} }
} }
......
...@@ -1270,10 +1270,6 @@ dev_release (struct inode *inode, struct file *fd) ...@@ -1270,10 +1270,6 @@ dev_release (struct inode *inode, struct file *fd)
dev->buf = NULL; dev->buf = NULL;
put_dev (dev); put_dev (dev);
/* other endpoints were all decoupled from this device */
spin_lock_irq(&dev->lock);
dev->state = STATE_DEV_DISABLED;
spin_unlock_irq(&dev->lock);
return 0; return 0;
} }
......
...@@ -150,8 +150,10 @@ static void cppi41_dma_callback(void *private_data) ...@@ -150,8 +150,10 @@ static void cppi41_dma_callback(void *private_data)
remain_bytes, remain_bytes,
direction, direction,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK); DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (WARN_ON(!dma_desc)) if (WARN_ON(!dma_desc)) {
spin_unlock_irqrestore(&musb->lock, flags);
return; return;
}
dma_desc->callback = cppi41_dma_callback; dma_desc->callback = cppi41_dma_callback;
dma_desc->callback_param = channel; dma_desc->callback_param = channel;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/usb/of.h>
#include "musb_core.h" #include "musb_core.h"
...@@ -230,6 +231,8 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -230,6 +231,8 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = jiffies; glue->last_timer = jiffies;
return; return;
} }
if (musb->port_mode == MUSB_PORT_MODE_HOST)
return;
if (time_after(glue->last_timer, timeout) && if (time_after(glue->last_timer, timeout) &&
timer_pending(&glue->timer)) { timer_pending(&glue->timer)) {
...@@ -313,7 +316,6 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) ...@@ -313,7 +316,6 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
jiffies + wrp->poll_seconds * HZ); jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) { } else if (drvvbus) {
musb->is_active = 1;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1; musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
...@@ -361,8 +363,8 @@ static int dsps_musb_init(struct musb *musb) ...@@ -361,8 +363,8 @@ static int dsps_musb_init(struct musb *musb)
return -EINVAL; return -EINVAL;
reg_base = devm_ioremap_resource(dev, r); reg_base = devm_ioremap_resource(dev, r);
if (!musb->ctrl_base) if (IS_ERR(reg_base))
return -EINVAL; return PTR_ERR(reg_base);
musb->ctrl_base = reg_base; musb->ctrl_base = reg_base;
/* NOP driver needs change if supporting dual instance */ /* NOP driver needs change if supporting dual instance */
...@@ -425,35 +427,51 @@ static int get_int_prop(struct device_node *dn, const char *s) ...@@ -425,35 +427,51 @@ static int get_int_prop(struct device_node *dn, const char *s)
return val; return val;
} }
static int get_musb_port_mode(struct device *dev)
{
enum usb_dr_mode mode;
mode = of_usb_get_dr_mode(dev->of_node);
switch (mode) {
case USB_DR_MODE_HOST:
return MUSB_PORT_MODE_HOST;
case USB_DR_MODE_PERIPHERAL:
return MUSB_PORT_MODE_GADGET;
case USB_DR_MODE_UNKNOWN:
case USB_DR_MODE_OTG:
default:
return MUSB_PORT_MODE_DUAL_ROLE;
};
}
static int dsps_create_musb_pdev(struct dsps_glue *glue, static int dsps_create_musb_pdev(struct dsps_glue *glue,
struct platform_device *parent) struct platform_device *parent)
{ {
struct musb_hdrc_platform_data pdata; struct musb_hdrc_platform_data pdata;
struct resource resources[2]; struct resource resources[2];
struct resource *res;
struct device *dev = &parent->dev; struct device *dev = &parent->dev;
struct musb_hdrc_config *config; struct musb_hdrc_config *config;
struct platform_device *musb; struct platform_device *musb;
struct device_node *dn = parent->dev.of_node; struct device_node *dn = parent->dev.of_node;
struct device_node *child_node;
int ret; int ret;
child_node = of_get_child_by_name(dn, "usb");
if (!child_node)
return -EINVAL;
memset(resources, 0, sizeof(resources)); memset(resources, 0, sizeof(resources));
ret = of_address_to_resource(child_node, 0, &resources[0]); res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
if (ret) { if (!res) {
dev_err(dev, "failed to get memory.\n"); dev_err(dev, "failed to get memory.\n");
return ret; return -EINVAL;
} }
resources[0] = *res;
ret = of_irq_to_resource(child_node, 0, &resources[1]); res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc");
if (ret == 0) { if (!res) {
dev_err(dev, "failed to get irq.\n"); dev_err(dev, "failed to get irq.\n");
ret = -EINVAL; return -EINVAL;
return ret;
} }
resources[1] = *res;
/* allocate the child platform device */ /* allocate the child platform device */
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
...@@ -465,7 +483,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, ...@@ -465,7 +483,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
musb->dev.parent = dev; musb->dev.parent = dev;
musb->dev.dma_mask = &musb_dmamask; musb->dev.dma_mask = &musb_dmamask;
musb->dev.coherent_dma_mask = musb_dmamask; musb->dev.coherent_dma_mask = musb_dmamask;
musb->dev.of_node = of_node_get(child_node); musb->dev.of_node = of_node_get(dn);
glue->musb = musb; glue->musb = musb;
...@@ -485,11 +503,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, ...@@ -485,11 +503,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
pdata.config = config; pdata.config = config;
pdata.platform_ops = &dsps_ops; pdata.platform_ops = &dsps_ops;
config->num_eps = get_int_prop(child_node, "num-eps"); config->num_eps = get_int_prop(dn, "mentor,num-eps");
config->ram_bits = get_int_prop(child_node, "ram-bits"); config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
pdata.mode = get_int_prop(child_node, "port-mode"); pdata.mode = get_musb_port_mode(dev);
pdata.power = get_int_prop(child_node, "power"); /* DT keeps this entry in mA, musb expects it as per USB spec */
config->multipoint = of_property_read_bool(child_node, "multipoint"); pdata.power = get_int_prop(dn, "mentor,power") / 2;
config->multipoint = of_property_read_bool(dn, "mentor,multipoint");
ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
if (ret) { if (ret) {
......
...@@ -76,13 +76,21 @@ static inline void map_dma_buffer(struct musb_request *request, ...@@ -76,13 +76,21 @@ static inline void map_dma_buffer(struct musb_request *request,
return; return;
if (request->request.dma == DMA_ADDR_INVALID) { if (request->request.dma == DMA_ADDR_INVALID) {
request->request.dma = dma_map_single( dma_addr_t dma_addr;
int ret;
dma_addr = dma_map_single(
musb->controller, musb->controller,
request->request.buf, request->request.buf,
request->request.length, request->request.length,
request->tx request->tx
? DMA_TO_DEVICE ? DMA_TO_DEVICE
: DMA_FROM_DEVICE); : DMA_FROM_DEVICE);
ret = dma_mapping_error(musb->controller, dma_addr);
if (ret)
return;
request->request.dma = dma_addr;
request->map_state = MUSB_MAPPED; request->map_state = MUSB_MAPPED;
} else { } else {
dma_sync_single_for_device(musb->controller, dma_sync_single_for_device(musb->controller,
...@@ -1804,6 +1812,8 @@ int musb_gadget_setup(struct musb *musb) ...@@ -1804,6 +1812,8 @@ int musb_gadget_setup(struct musb *musb)
void musb_gadget_cleanup(struct musb *musb) void musb_gadget_cleanup(struct musb *musb)
{ {
if (musb->port_mode == MUSB_PORT_MODE_HOST)
return;
usb_del_gadget_udc(&musb->g); usb_del_gadget_udc(&musb->g);
} }
...@@ -1929,7 +1939,8 @@ static int musb_gadget_stop(struct usb_gadget *g, ...@@ -1929,7 +1939,8 @@ static int musb_gadget_stop(struct usb_gadget *g,
stop_activity(musb, driver); stop_activity(musb, driver);
otg_set_peripheral(musb->xceiv->otg, NULL); otg_set_peripheral(musb->xceiv->otg, NULL);
dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); dev_dbg(musb->controller, "unregistering driver %s\n",
driver ? driver->function : "(removed)");
musb->is_active = 0; musb->is_active = 0;
musb->gadget_driver = NULL; musb->gadget_driver = NULL;
......
...@@ -2628,6 +2628,8 @@ int musb_host_alloc(struct musb *musb) ...@@ -2628,6 +2628,8 @@ int musb_host_alloc(struct musb *musb)
void musb_host_cleanup(struct musb *musb) void musb_host_cleanup(struct musb *musb)
{ {
if (musb->port_mode == MUSB_PORT_MODE_GADGET)
return;
usb_remove_hcd(musb->hcd); usb_remove_hcd(musb->hcd);
musb->hcd = NULL; musb->hcd = NULL;
} }
......
...@@ -333,7 +333,9 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller) ...@@ -333,7 +333,9 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
if (!ux500_channel->dma_chan) if (!ux500_channel->dma_chan)
ux500_channel->dma_chan = ux500_channel->dma_chan =
dma_request_channel(mask, dma_request_channel(mask,
data->dma_filter, data ?
data->dma_filter :
NULL,
param_array[ch_num]); param_array[ch_num]);
if (!ux500_channel->dma_chan) { if (!ux500_channel->dma_chan) {
......
...@@ -42,8 +42,8 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on) ...@@ -42,8 +42,8 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on)
reg = AM335X_USB1_CTRL; reg = AM335X_USB1_CTRL;
break; break;
default: default:
__WARN(); WARN_ON(1);
return; return;
} }
val = readl(usb_ctrl->phy_reg + reg); val = readl(usb_ctrl->phy_reg + reg);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "otg_fsm.h" #include "phy-fsm-usb.h"
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
#include "phy-otg-fsm.h" #include "phy-fsm-usb.h"
/* Change USB protocol when there is a protocol change */ /* Change USB protocol when there is a protocol change */
static int otg_set_protocol(struct otg_fsm *fsm, int protocol) static int otg_set_protocol(struct otg_fsm *fsm, int protocol)
......
...@@ -98,8 +98,8 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, ...@@ -98,8 +98,8 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
static int omap_usb2_suspend(struct usb_phy *x, int suspend) static int omap_usb2_suspend(struct usb_phy *x, int suspend)
{ {
u32 ret;
struct omap_usb *phy = phy_to_omapusb(x); struct omap_usb *phy = phy_to_omapusb(x);
int ret;
if (suspend && !phy->is_suspended) { if (suspend && !phy->is_suspended) {
omap_control_usb_phy_power(phy->control_dev, 0); omap_control_usb_phy_power(phy->control_dev, 0);
...@@ -108,8 +108,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) ...@@ -108,8 +108,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
} else if (!suspend && phy->is_suspended) { } else if (!suspend && phy->is_suspended) {
ret = pm_runtime_get_sync(phy->dev); ret = pm_runtime_get_sync(phy->dev);
if (ret < 0) { if (ret < 0) {
dev_err(phy->dev, "get_sync failed with err %d\n", dev_err(phy->dev, "get_sync failed with err %d\n", ret);
ret);
return ret; return ret;
} }
omap_control_usb_phy_power(phy->control_dev, 1); omap_control_usb_phy_power(phy->control_dev, 1);
...@@ -209,9 +208,9 @@ static int omap_usb2_runtime_suspend(struct device *dev) ...@@ -209,9 +208,9 @@ static int omap_usb2_runtime_suspend(struct device *dev)
static int omap_usb2_runtime_resume(struct device *dev) static int omap_usb2_runtime_resume(struct device *dev)
{ {
u32 ret = 0;
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct omap_usb *phy = platform_get_drvdata(pdev); struct omap_usb *phy = platform_get_drvdata(pdev);
int ret;
ret = clk_enable(phy->wkupclk); ret = clk_enable(phy->wkupclk);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment