Commit Graph

345 Commits (317ddd256b9c24b0d78fa8018f80f1e495481a10)

Author SHA1 Message Date
George Cherian 5bf8fae33d usb: dwc3: gadget: free trb pool only from epnum 2
we never allocate a TRB pool for physical endpoints
0 and 1 so trying to free it (a invalid TRB pool pointer)
will lead us in a warning while removing dwc3.ko module.

In order to fix the situation, all we have to do is skip
dwc3_free_trb_pool() for physical endpoints 0 and 1 just
as we while deleting endpoints from the endpoints list.

Cc: stable@vger.kernel.org
Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-05-28 22:17:20 +03:00
Peter Chen 022d0547aa usb: dwc3: exynos: PHY should be deleted later than dwc3 core
If the glue layer is removed first (core layer later),
it deletes the phy device first, then the core device.
But at core's removal, it still uses PHY's resources, it may
cause kernel's oops. It is much like the problem
Paul Zimmerman reported at:
http://marc.info/?l=linux-usb&m=136547502011472&w=2.

Besides, it is reasonable the PHY is deleted at last as
the controller is the PHY's user.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-05-28 22:17:08 +03:00
Peter Chen f28c42c576 usb: dwc3: pci: PHY should be deleted later than dwc3 core
If the glue layer is removed first (core layer later),
it deletes the phy device first, then the core device.
But at core's removal, it still uses PHY's resources, it may
cause kernel's oops. It is much like the problem
Paul Zimmerman reported at:
http://marc.info/?l=linux-usb&m=136547502011472&w=2.

Besides, it is reasonable the PHY is deleted at last as
the controller is the PHY's user.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-05-28 22:16:49 +03:00
Stephen Warren 3b9561e9d9 USB: set device dma_mask without reference to global data
Many USB host drivers contain code such as:

if (!pdev->dev.dma_mask)
        pdev->dev.dma_mask = &tegra_ehci_dma_mask;

... where tegra_ehci_dma_mask is a global. I suspect this code originated
in commit 4a53f4e "USB: ehci-tegra: add probing through device tree" and
was simply copied everywhere else.

This works fine when the code is built-in, but can cause a crash when the
code is in a module. The first module load sets up the dma_mask pointer,
but if the module is removed and re-inserted, the value is now non-NULL,
and hence is not updated to point at the new location, and hence points
at a stale location within the previous module load address, which in
turn causes a crash if the pointer is de-referenced.

The simplest way of solving this seems to be to copy the code from
ehci-platform.c, which uses the coherent_dma_mask as the target for the
dma_mask pointer.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-16 17:30:52 -07:00
Vivek Gautam 1bc0d92689 usb: dwc3: Fix compilation break when building with USB_DWC3_DUAL_ROLE=y
The commit:
388e5c5 usb: dwc3: remove dwc3 dependency on host AND gadget
breaks compilation when
USB=y, USB_GADGET=m, USB_DWC3=y and USB_DWC3_DUAL_ROLE=y.

drivers/built-in.o: In function `dwc3_gadget_giveback':
drivers/usb/dwc3/gadget.c:271: undefined reference to `usb_gadget_unmap_request'
drivers/built-in.o: In function `__dwc3_gadget_kick_transfer':
drivers/usb/dwc3/gadget.c:1005: undefined reference to `usb_gadget_unmap_request'
drivers/built-in.o: In function `__dwc3_gadget_ep_queue':
drivers/usb/dwc3/gadget.c:1073: undefined reference to `usb_gadget_map_request'
drivers/built-in.o: In function `dwc3_gadget_reset_interrupt':
drivers/usb/dwc3/gadget.c:2165: undefined reference to `usb_gadget_set_state'
drivers/built-in.o: In function `dwc3_gadget_init':
drivers/usb/dwc3/gadget.c:2647: undefined reference to `usb_add_gadget_udc'
drivers/built-in.o: In function `dwc3_gadget_exit':
drivers/usb/dwc3/gadget.c:2681: undefined reference to `usb_del_gadget_udc'
drivers/built-in.o: In function `__dwc3_ep0_do_control_data':
drivers/usb/dwc3/ep0.c:929: undefined reference to `usb_gadget_map_request'
drivers/usb/dwc3/ep0.c:906: undefined reference to `usb_gadget_map_request'
drivers/built-in.o: In function `dwc3_ep0_set_config':
drivers/usb/dwc3/ep0.c:575: undefined reference to `usb_gadget_set_state'
drivers/built-in.o: In function `dwc3_ep0_set_address':
drivers/usb/dwc3/ep0.c:520: undefined reference to `usb_gadget_set_state'
drivers/usb/dwc3/ep0.c:522: undefined reference to `usb_gadget_set_state'
drivers/built-in.o: In function `dwc3_ep0_set_config':
drivers/usb/dwc3/ep0.c:556: undefined reference to `usb_gadget_set_state'

Making changes similar to patch:
71a5e61 usb: chipidea: fix and improve dependencies if usb host or gadget support is built as module

Let us limit the DWC3 mode to depend on corresponding usb-subsystem
and USB_DWC3.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-05-15 17:26:00 +03:00
Jingoo Han 19fda7cd59 usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
when the CONFIG_PM_SLEEP is enabled. Unnecessary CONFIG_PM ifdefs
are removed.

drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined but not used [-Wunused-function]

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-04-02 11:42:51 +03:00
Felipe Balbi d105e7f86f usb: dwc3: fix PHY error handling
PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:28 +02:00
Felipe Balbi a33bb21208 usb: dwc3: omap: fix sparse warning
our global '_omap' pointer wasn't marked
static. This patch solves the following sparse
warning:

	warning: symbol '_omap' was not declared. \
	Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:24 +02:00
Vivek Gautam ddb5147cea usb: dwc3: exynos: use clk_prepare_enable and clk_disable_unprepare
Convert clk_enable/clk_disable to clk_prepare_enable/clk_disable_unprepare
calls as required by common clock framework.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
CC: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:16 +02:00
Vivek Gautam adcf20dcd2 usb: dwc3: exynos: Use of_platform API to create dwc3 core pdev
Used of_platform_populate() to create dwc3 core platform_device
from device tree data. Additionally some cleanup is also done.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
CC: Felipe Balbi <balbi@ti.com>
CC: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:16 +02:00
Kishon Vijay Abraham I 2ba7943af0 usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
dwc3-omap has not yet been executed or failed.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:14 +02:00
Kishon Vijay Abraham I ddff14f1ab usb: dwc3: set dma_mask for dwc3_omap device
*dma_mask* is not set for devices created from dt data. So filled dma_mask
for dwc3_omap device here. And dwc3 core will copy the dma_mask from its
parent.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:14 +02:00
George Cherian d4436c3a6e usb: dwc3: core: fix wrong OTG event regitser offset
This patch fixes the wrong OTG_EVT,OTG_EVTEN and OTG_STS register
offsets.

While at that, also add a missing register to debugfs regdump
utility.

Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:13 +02:00
Felipe Balbi fd89149875 usb: phy: remove CONFIG_USB_OTG_UTILS
there are no more users of CONFIG_USB_OTG_UTILS
left in tree, we can remove it just fine.

[ kishon@ti.com : fixed a linking error due
	to original patch forgetting to change
	drivers/usb/Makefile ]

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:08 +02:00
Felipe Balbi 6a1e3ef45f usb: dwc3: gadget: use num_(in|out)_eps from HW params
that way we will only tell gadget framework about
the endpoints we actually have.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:02 +02:00
Felipe Balbi 789451f6c6 usb: dwc3: calculate the number of endpoints
hwparams2 holds the number of endpoints which
were selected during RTL generation, we can
use that on our driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:02 +02:00
Vivek Gautam cd051da2c8 usb: dwc3: set 'mode' based on selected Kconfig choices
Now that machines may select dwc3's working mode (HOST only,
GADGET only or DUAL_ROLE) via Kconfig, let's set dwc3's mode
based on that, rather than fixing it to whatever hardware
says.

This way we can skip initializing Gadget/Host in case
we are using Host-only/Gadget-only mode respectively.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:00 +02:00
Felipe Balbi 0b0cc1cd31 usb: dwc3: workaround: unexpected transtion U3 -> RESUME
In DWC3 versions < 2.50a configured without
Hibernation mode enabled, there will be an
extra link status change interrupt if device
detects host-initiated U3 exit.

In that case, core will generate an unnecessary
U3 -> RESUME transition which should be ignored
by the driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:57 +02:00
Felipe Balbi 7ac6a593d5 usb: dwc3: core: define more revisions
Some new revisions of the DWC3 core have
been released, let's add our defines to help
implementing known erratas.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:57 +02:00
Felipe Balbi e5caff6831 usb: dwc3: gadget: don't assign gadget.dev.release directly
udc-core provides a better way to handle release
methods, let's use it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:45 +02:00
Felipe Balbi 180cc68ed8 usb: dwc3: gadget: don't touch gadget.dev.driver
udc-core now handles that for us, which means
we can remove it from our driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:31 +02:00
Felipe Balbi 1048d83d5b usb: dwc3: gadget: remove unnecessary initializations
udc-core now sets dma-related and parent fields
for us, we don't need to do it ourselves.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:22 +02:00
Felipe Balbi 67d0b500eb usb: dwc3: core: avoid checkpatch.pl warning
trivial patch to avoid "over 80-chars" rule
break. No functional changes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:15 +02:00
Felipe Balbi dbfff05d7c usb: dwc3: debugfs: improve debugfs file creation
when commit 388e5c5 (usb: dwc3: remove dwc3
dependency on host AND gadget.) changed the
way debugfs files are created, it failed to
note that 'mode' is necessary in Dual Role
mode only while 'testmode' and 'link_state'
are valid in Dual Role and Peripheral-only
builds. Fix this while also converting pre-
processor conditional to C conditionals.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:15 +02:00
Felipe Balbi 4ec0ddb1b4 usb: dwc3: debugfs: mark our regset structure const
nobody should be modifying that structure and
debugfs has already being fixed to take const
arguments, so we won't cause any new compile
warnings.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:14 +02:00
Felipe Balbi 5b9ec339e4 usb: dwc3: debugfs: when unknown, print only the state value
whenever we grab an unknown link_state we
were printing the entire register value as
a integer but that's hardly useful; instead,
let's print only the bogus state value.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:14 +02:00
Felipe Balbi 6b2a0eb854 usb: dwc3: debugfs: add two missing Link States
for Reset and Resume we were going to print
"UNKNOWN" when we actually knew what those
were.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:13 +02:00
Felipe Balbi fdba5aa54c usb: dwc3: remove our homebrew state mechanism
We can reuse the generic implementation via
our struct usb_gadget.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:13 +02:00
Felipe Balbi 14cd592f72 usb: dwc3: gadget: implement gadget state tracking
make use of the previously introduced gadget->state
field.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:12 +02:00
Felipe Balbi b15a762f02 usb: dwc3: gadget: move to threaded IRQ
by moving to threaded IRQs, we allow our IRQ
priorities to be configurable when running with
realtime patch. Also, since we're running in
thread context, we can call functions which
might sleep, such as sysfs_notify() without
problems.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:11 +02:00
Felipe Balbi 60d04bbee0 usb: dwc3: add count field to event buffer
we can cache the last read value of the event
buffer count register on this field, for later
handling.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:10 +02:00
Felipe Balbi abed411869 usb: dwc3: add a flags field to event buffer
that way we know if a particular event buffer
has pending events, or not.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:10 +02:00
Felipe Balbi 9e86e71bce usb: dwc3: core: remove bogus comment to our structure
that irq field has been removed already. This
patch just removes its documentation.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:09 +02:00
Felipe Balbi 68907a7743 usb: dwc3: pci: add basic suspend/resume support
this patch adds basic PM support for the
PCI glue layer.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:03 +02:00
Vikas Sajjan 0646caf754 usb: dwc3: exynos: add basic suspend/resume support
Adds suspend and resume callbacks to exynos dwc3 driver as part of
power management support.

This change does gating of dwc3 clock during suspend/resume cycles.

Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
Signed-off-by: Vikas C Sajjan <vikas.sajjan@linaro.org>
CC: Doug Anderson <dianders@chromium.org>
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>

[ balbi@ti.com : refreshed to current linus/master ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:03 +02:00
Felipe Balbi f3e117f443 usb: dwc3: omap: add basic suspend/resume support
this patch implements basic suspend/resume
functionality for the OMAP glue layer.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:02 +02:00
Felipe Balbi 1d9a00eeca usb: dwc3: omap: remove unused fields from private structure
we're not using those fields of the structure,
might as well remove them.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:02 +02:00
Felipe Balbi 9a4b5dab91 usb: dwc3: omap: introduce enable/disable IRQ methods
they will be re-used on suspend/resume implementation.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:01 +02:00
Felipe Balbi 7415f17c95 usb: dwc3: core: add power management support
Add support for basic power management on
the dwc3 driver. While there is still lots
to improve for full PM support, this minimal
patch will already make sure that we survive
suspend-to-ram and suspend-to-disk without
major issues.

Cc: Vikas C Sajjan <vikas.sajjan@linaro.org>
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:01 +02:00
Felipe Balbi 9fcb3bd8d1 usb: dwc3: gadget: save state of pullups
This will be used during resume to verify
if we should reconnect our pullups or not.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:00 +02:00
Felipe Balbi 8698e2acf3 usb: dwc3: gadget: introduce and use enable/disable irq methods
we don't need to enable IRQs until we have
a gadget driver loaded and ready to work,
so let's delay IRQ enable to ->udc_start()
and IRQ disable to ->udc_stop().

While at that, also move the related use of
request_irq() and free_irq().

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:17:00 +02:00
Felipe Balbi f122d33e4b usb: dwc3: core: explicitly setup and cleanup event buffers
Make the call to dwc3_event_buffers_setup()
and dwc3_event_buffers_cleanup() explicit,
so it's easier to implement PM.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:59 +02:00
Felipe Balbi 7bce401cc6 usb: gadget: drop now unnecessary flag
We don't need the ->register_my_device flag
anymore because all UDC drivers have been
properly converted.

Let's remove every history of it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:55 +02:00
Felipe Balbi 1e1930bd3d usb: dwc3: gadget: let udc-core manage gadget->dev
We don't need to register that device ourselves
if we simply set gadget->register_my_device.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:40 +02:00
Kishon Vijay Abraham I 7eaf8f2a7d usb: dwc3: omap: stop using nop-usb-xceiv
Now that we have drivers for omap-usb2 phy and omap-usb3 phy, stop
using nop-usb-xceiv.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:39 +02:00
Kishon Vijay Abraham I 4495afcf71 usb: dwc3: omap: remove platform data associated with dwc3-omap
omap5 is not going to have support for non-dt boot making the platform
data associated with dwc3 useless. Removed it here.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:38 +02:00
Kishon Vijay Abraham I e36a0c870f usb: dwc3: omap: minor fixes to get dt working
Includes few minor fixes in dwc3-omap like populating the compatible
string in a correct way, extracting the utmi-mode property properly and
changing the index of get_irq since irq of core is removed from hwmod
entry.

Also updated the documentation with dwc3-omap device tree binding
information.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

[ balbi@ti.com : fix a compile warning introduced by
	this commit ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:16:33 +02:00
Andrew Morton c390b0363d usb: dwc3: ep0: fix sparc64 build
drivers/usb/dwc3/ep0.c: In function `__dwc3_ep0_do_control_data':
drivers/usb/dwc3/ep0.c:905: error: `typeof' applied to a bit-field

Looks like a gcc-3.4.5/sparc64 bug.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-08 09:42:50 +02:00
Felipe Balbi e5b29b25f8 usb: dwc3: gadget: remove unnecessary code
the params variables on dwc3_gadget_conndone_interrupt()
is only memset() to zero but never used in
that function, so we can safely drop the variable
and memset() call.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-04 09:33:25 +02:00
Felipe Balbi d82f3e3cd8 usb: dwc3: glue layers shouldn't know about the core IP
remove inclusion of "core.h" from all glue
layers as they don't need to know details
about the core IP.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-04 09:33:24 +02:00