Huang Rui [Tue, 28 Oct 2014 11:54:26 +0000 (19:54 +0800)]
usb: dwc3: add lpm erratum support
When parameter DWC_USB3_LPM_ERRATA_ENABLE is enabled in Andvanced
Configuration of coreConsultant, it supports of xHCI BESL Errata Dated
10/19/2011 is enabled in host mode. In device mode it adds the capability
to send NYET response threshold based on the BESL value received in the LPM
token, and the threhold is configurable for each soc platform.
This patch adds an entry that soc platform is able to define the lpm
capacity with their own device tree or bus glue layer.
[ balbi@ti.com : added devicetree documentation, spelled threshold
completely, made sure threshold is only applied to
proper core revisions. ]
Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Huang Rui [Tue, 28 Oct 2014 11:54:24 +0000 (19:54 +0800)]
usb: dwc3: initialize platform data at pci glue layer
This patch initializes platform data at pci glue layer, and SoCs x86-based
platform vendor is able to define their flags in platform data at bus glue
layer. Then do some independent behaviors at dwc3 core level.
Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Huang Rui [Tue, 28 Oct 2014 11:54:23 +0000 (19:54 +0800)]
usb: dwc3: add a flag to check if it is fpga board
Some chip vendor is on pre-silicon phase, which needs to use the simulation
board. It should have the same product and vendor id with the true soc, but
might have some minor different configurations.
Below thread discussion proposes to find a method to distinguish between
simulation board and soc.
In Andvanced Configuration of coreConsultant, there is the parameter of
DWC_USB_EN_FPGA. This bit has the function we need. And it would response as 7
bit of GHWPARAMS6 register. So it's able to check this functional bit to confirm
if works on FPGA board.
Reported-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Antoine Tenart [Thu, 30 Oct 2014 17:41:19 +0000 (18:41 +0100)]
usb: chipidea: add support to the generic PHY framework
This patch adds support of the PHY framework for ChipIdea drivers.
Changes are done in both the ChipIdea common code and in the drivers
accessing the PHY. This is done by adding a new PHY member in
ChipIdea's structures and by taking care of it in the code.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Antoine Tenart [Thu, 30 Oct 2014 17:41:16 +0000 (18:41 +0100)]
usb: allow to supply the PHY in the drivers when using HCD
This patch modify the generic code handling PHYs to allow them to be
supplied from the drivers. This adds checks to ensure no PHY was already
there when looking for one in the generic code. This also makes sure we
do not modify its state in the generic HCD functions, it was provided by
the driver.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <balbi@ti.com>
Antoine Tenart [Thu, 30 Oct 2014 17:41:15 +0000 (18:41 +0100)]
usb: add support to the generic PHY framework in OTG
This patch adds support of the PHY framework in OTG and keeps the USB
PHY compatibility. Here the only modification is to add PHY member in
the OTG structure, along with the USB PHY one.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Antoine Tenart [Thu, 30 Oct 2014 17:41:14 +0000 (18:41 +0100)]
usb: rename phy to usb_phy in OTG
This patch prepares the introduction of the generic PHY support in the
USB OTG common functions. The USB PHY member of the OTG structure is
renamed to 'usb_phy' and modifications are done in all drivers accessing
it. Renaming this pointer will allow to keep the compatibility for USB
PHY drivers.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Antoine Tenart [Thu, 30 Oct 2014 17:41:13 +0000 (18:41 +0100)]
usb: move the OTG state from the USB PHY to the OTG structure
Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.
[ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c,
phy-isp1301-omap, and chipidea's debug.c ]
Acked-by: Kishon Vijay Abraham I <kishon@ti.com> Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Added failure check for usb_assign_descriptors call in bind function.
Acked-By: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Pavitrakumar Managutte <pavitra1729@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: core: use ->resume instead ->resume_noirq
In commit 0ec8fd70fb ("USB: musb: fix possible panic while resuming")
musb_resume() became musb_resume_early() in order to enable the clocks
early on resume. This piece of the resume code was removed later in
commit 034917612 ("usb: musb: move clock handling to glue layer").
In between the function was renamed from musb_resume_early() to
musb_resume_noirq() by commit commit 48fea9659e ("USB: Rework musb
suspend()/resume_early()").
Now I see that first musb_core is resumed followed by phy and glue
layer and I ask myself is this really what we intend to do? This kind
of revoked the purpose of the first commit (0ec8fd70fb).
Because of this and because it looks wrong to resume (core) before the
glue layer I push it to the ->resume callback.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 20 Oct 2014 10:45:39 +0000 (12:45 +0200)]
usb: dwc2: gadget: fix calls to phy control functions in suspend/resume code
This patch moves calls to phy enable/disable out of spinlock protected
blocks in device suspend/resume to fix incorrect caller context. Phy
related functions must not be called from atomic context. To protect
device internal state from a race during suspend, a call to
s3c_hsotg_core_disconnect() is added under a spinlock, what prevents any
further activity on the usb bus.
Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 20 Oct 2014 10:45:38 +0000 (12:45 +0200)]
usb: dwc2: gadget: use soft-disconnect udc feature in pullup() method
This patch moves udc initialization from pullup() method to
s3c_hsotg_udc_start(), so that method ends with hardware fully
initialized and left in soft-disconnected state. After this change, the
pullup() method simply clears soft-disconnect start() when called with
is_on=1. For completeness, a call to s3c_hsotg_core_disconnect() has
been added when pullup() method is called with is_on=0, what puts the
udc hardware back to soft-disconnected state.
Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 20 Oct 2014 10:45:37 +0000 (12:45 +0200)]
usb: dwc2: gadget: move phy control calls out of pullup() method
This patch moves phy enable/disable calls from pullup() method to
udc_start/stop functions. This solves the issue related to limited caller
context for PHY functions, because they cannot be called from non-sleeping
context. This is also a preparation for using soft-disconnect feature of
udc controller in pullup() method.
Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Marek Szyprowski [Mon, 20 Oct 2014 10:45:36 +0000 (12:45 +0200)]
usb: dwc2: gadget: decouple setting soft-disconnect from s3c_hsotg_core_init
This patch changes s3c_hsotg_core_init function to leave hardware in
soft disconnect mode, so the moment of coupling the hardware to the usb
bus can be later controlled by the separate functions for enabling and
disabling soft disconnect mode. This patch is a preparation to rework
pullup() method.
Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Jarzmik [Fri, 17 Oct 2014 20:43:06 +0000 (22:43 +0200)]
usb: gadget: pxa27x_udc: fix clock prepare and enable
As the udc clock controls both the output signals and the internal IP,
it must be enabled before any UDC register is touched.
The bug is revealed when the clock framework disables the clock for a
couple of milliseconds during the boot sequence, and the endpoint
configuration is lost. The bug is hidden when clock framework is not
used, because no "unused clocks disable" occurs.
This patch fixes the wrong behaviour by ensuring that :
- whenever a UDC register is read or written, the clock is enabled
- reworks the endpoints programming to have it done under running clock
- reworks suspend/resume to ensure the same thing
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Jarzmik [Fri, 17 Oct 2014 20:43:05 +0000 (22:43 +0200)]
usb: gadget: pxa27x_udc: use devm_* helpers
Use devm_* helpers in the probe function to simplify the error path and
the remove path.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Fri, 17 Oct 2014 17:05:12 +0000 (12:05 -0500)]
usb: gadget: remove unnecessary 'driver' argument
now that no UDC driver relies on the extra
'driver' argument to ->udc_stop(), we can
safely remove it.
This commit is based on previous work by
Robert Baldyga <r.baldyga@samsung.com> which
can be found at [1]; however that patch turned
out to have a high probability of regressing
many UDC drivers because of a blind search & replace
s/driver/$udc->driver/ which caused the 'driver'
argument to stop_activity() to be a valid non-NULL
pointer when it should be NULL, thus causing UDCs
to mistakenly call gadget driver's ->disconnect()
callback.
[1] http://markmail.org/message/x5zneg4xea4zntab
Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Mon, 13 Oct 2014 20:36:16 +0000 (15:36 -0500)]
usb: dwc3: gadget: WARN() on bogus usb_ep_queue()
Some gadget/function drivers might want to do
improper request recycling by allocating a single
request from one particular endpoint and queueing
it to another completely unrelated endpoint.
One such case was found with f_loopback.c.
To prevent such cases from happening again, let's
WARN() so we get a loud enough failure and persuade
users to report errors.
USB gadgets composed with configfs lack suspend and resume
methods. This patch uses composite_suspend()/composite_resume()
the same way e.g. composite_setup() or composite_disconnect()
are used in a configfs-based gadget.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Dan Carpenter [Wed, 8 Oct 2014 10:40:37 +0000 (13:40 +0300)]
usb: gadget: f_uac1: remove an unneeded NULL check
This NULL check sets off a static checker warning because we already
dereferenced "card" earlier in the function. However, since "card" is
never NULL so we can just remove the check.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Thu, 9 Oct 2014 15:12:24 +0000 (10:12 -0500)]
usb: gadget: udc-core: call ->disconnect() when soft disconnecting
when disconnecting from host using our soft_connect
sysfs interface, also let the gadget driver know about
it by calling the gadget driver's ->disconnect()
method.
No problems have been found while not calling ->disconnect()
so far, it's just good convention.
Felipe Balbi [Tue, 7 Oct 2014 15:19:23 +0000 (10:19 -0500)]
usb: dwc3: get rid of ->prepare()/->complete()
Using ->prepare()/->complete() to mask/unmask
IRQs is wrong at least for dwc3. We need to
make sure that by the end of ->resume(), IRQs
are working and ready to fire because a child
device may need working IRQs for its own ->resume()
method.
George Cherian [Tue, 17 Dec 2013 13:17:54 +0000 (18:47 +0530)]
usb: dwc3: dwc3-omap: get rid of ->prepare()/->complete()
Enabling the core interrupts in complete is too late for
XHCI, and stops it from proper operation. The root of the
problem is due to a disagreement between dwc3-omap and XHCI
about when IRQs should be enabled.
As it turns out, ->resume's documentation states that:
"... generally the driver is expected to start working
again, responding to hardware events and software requests
(the device itself may be left in a low-power state, waiting
for a runtime resume to occur) ..."
From that we infer that IRQs must be unmasked by the end of
->resume().
Due to that, we will remove ->prepare() and ->complete() and
disable/enable interrupts in ->suspend()/->resume().
Acked-by: Roger Quadros <rogerq@ti.com> Signed-off-by: George Cherian <george.cherian@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Jarzmik [Wed, 1 Oct 2014 20:06:15 +0000 (22:06 +0200)]
usb: gadget: pxa27x_udc: transfer mach_info into pxa_udc
Convert the mach info, and store the udc_command in the pxa_udc control
structure.
It is to be noticed that the udc_is_connected() in mach info is not
transfered. This was not used, as mioa701 machine doesn't need it,
balloon3 doesn't really use it, and most importantly the current driver
never uses it.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Jarzmik [Wed, 1 Oct 2014 20:06:14 +0000 (22:06 +0200)]
usb: gadget: pxa27x_udc: prepare device-tree support
For this preparation, a preliminary cleanup is done :
- convert the probing of pxa27x_udc to gpio_desc.
The conversion is partial because :
- the platform data still provides a gpio number, not a gpio desc
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
This patch adds support for the generic PHY. The generic PHY will be
used in multiplatform environment.
Acked-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Felipe Balbi [Thu, 18 Sep 2014 15:01:55 +0000 (10:01 -0500)]
usb: gadget: composite: conditionally dequeue os_desc and setup requests
In case we unload a gadget driver while any of
os_desc_req or req are still pending, we need
to make sure to dequeue them.
By using our setup_pending and os_desc_pending
flags we achieve that in a way that doesn't
cause any regressions because we won't dequeue
a request which was already completed.
The original idea came from Li Jun's commit f2267089ea17fa97b796b1b4247e3f8957655df3
(usb: gadget: composite: dequeue cdev->req
before free it in composite_dev_cleanup) which,
unfortunately, caused two regressions (kfree()
being called before usb_ep_dequeue() and calling
usb_ep_dequeue() when the request was already
completed). That commit also didn't take care
of os_desc_req which can fall into the same
situation so we must care for that one too.
Note that in order to make code slightly easier
to read, we introduce composite_ep_queue() which
hides details about how to fiddle with our pending
flags.
Felipe Balbi [Fri, 19 Sep 2014 20:51:11 +0000 (15:51 -0500)]
usb: dwc3: core: write LINUX_VERSION_CODE to our GUID register
DWC3's GUID register is supposed to be used to write
any sort of version we might want. It helps when getting
bug reports for platforms you don't have HW to know
which kernel version of the driver was running on the
platform.
Because we don't really track driver version, but we _do_
track the kernel version, let's write LINUX_VERSION_CODE to
that register and use it for debugging.
Reviewed-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Linus Torvalds [Sun, 2 Nov 2014 22:45:52 +0000 (14:45 -0800)]
Merge tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd
Pull MTD fixes from Brian Norris:
"Three main MTD fixes for 3.18:
- A regression from 3.16 which was noticed in 3.17. With the
restructuring of the m25p80.c driver and the SPI NOR library
framework, we omitted proper listing of the SPI device IDs. This
means m25p80.c wouldn't auto-load (modprobe) properly when built as
a module. For now, we duplicate the device IDs into both modules.
- The OMAP / ELM modules were depending on an implicit link ordering.
Use deferred probing so that the new link order (in 3.18-rc) can
still allow for successful probing.
- Fix suspend/resume support for LH28F640BF NOR flash"
* tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd:
mtd: cfi_cmdset_0001.c: fix resume for LH28F640BF chips
mtd: omap: fix mtd devices not showing up
mtd: m25p80,spi-nor: Fix module aliases for m25p80
mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id
mtd: m25p80: get rid of spi_get_device_id