History log of /linux-master/drivers/usb/renesas_usbhs/mod_gadget.c
Revision Date Author Comments
# 0d9b6d49 07-Jul-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

usb: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200707195607.GA4198@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e92f30ac 15-Oct-2019 Ben Dooks (Codethink) <ben.dooks@codethink.co.uk>

usb: renesas_usbhs: fix type of buf

Fix the type of buf in __usbhsg_recip_send_status to
be __le16 to avoid the following sparse warning:

drivers/usb/renesas_usbhs/mod_gadget.c:335:14: warning: incorrect type in assignment (different base types)
drivers/usb/renesas_usbhs/mod_gadget.c:335:14: expected unsigned short
drivers/usb/renesas_usbhs/mod_gadget.c:335:14: got restricted __le16 [usertype]

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 20ee71cc 15-Oct-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: Fix warnings in usbhsg_recip_handler_std_set_device()

This patch fixes the following sparse warnings by shifting 8-bits after
le16_to_cpu().

drivers/usb/renesas_usbhs/mod_gadget.c:268:47: warning: restricted __le16 degrades to integer
drivers/usb/renesas_usbhs/mod_gadget.c:268:47: warning: cast to restricted __le16

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# f2b06c95 08-Sep-2019 Veeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>

usb: renesas_usbhs: add suspend event support in gadget mode

When R-Car Gen3 USB 2.0 is in Gadget mode, if host is detached an interrupt
will be generated and Suspended state bit is set in interrupt status
register. Interrupt handler will call driver->suspend(composite_suspend)
if suspended state bit is set. composite_suspend will call
ffs_func_suspend which will post FUNCTIONFS_SUSPEND and will be consumed
by user space application via /dev/ep0.

To be able to detect host detach, extend the DVSQ_MASK to cover the
Suspended bit of the DVSQ[2:0] bitfield from the Interrupt Status
Register 0 (INTSTS0) register and perform appropriate action in the
DVST interrupt handler (usbhsg_irq_dev_state).

Without this commit, disconnection of the phone from R-Car H3 ES2.0
Salvator-X CN9 port is not recognized and reverse role switch does
not not happen. If phone is connected again it does not enumerate.

With this commit, disconnection will be recognized and reverse role
switch will happen by a user space application. If phone is connected
again it will enumerate properly and will become visible in the output
of 'lsusb'.

Signed-off-by: Veeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 67f19580 15-Oct-2019 Ben Dooks (Codethink) <ben.dooks@codethink.co.uk>

usb: renesas_usbhs: fix type of buf

Fix the type of buf in __usbhsg_recip_send_status to
be __le16 to avoid the following sparse warning:

drivers/usb/renesas_usbhs/mod_gadget.c:335:14: warning: incorrect type in assignment (different base types)
drivers/usb/renesas_usbhs/mod_gadget.c:335:14: expected unsigned short
drivers/usb/renesas_usbhs/mod_gadget.c:335:14: got restricted __le16 [usertype]

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Link: https://lore.kernel.org/r/20191015153017.10858-1-ben.dooks@codethink.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4d599cd3 01-Oct-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: Fix usb_ep_set_{halt,wedge}() behavior

According to usb_ep_set_halt()'s description,
__usbhsg_ep_set_halt_wedge() should return -EAGAIN if the IN endpoint
has any queue or data. Otherwise, this driver is possible to cause
just STALL without sending a short packet data on g_mass_storage driver,
and then a few resetting a device happens on a host side during
a usb enumaration.

Fixes: 2f98382dcdfe ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
Cc: <stable@vger.kernel.org> # v3.0+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1569924633-322-3-git-send-email-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1aae1394 01-Oct-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: Do not discard queues in usb_ep_set_{halt,wedge}()

The commit 97664a207bc2 ("usb: renesas_usbhs: shrink spin lock area")
had added a usbhsg_pipe_disable() calling into
__usbhsg_ep_set_halt_wedge() accidentally. But, this driver should
not call the usbhsg_pipe_disable() because the function discards
all queues. So, this patch removes it.

Fixes: 97664a207bc2 ("usb: renesas_usbhs: shrink spin lock area")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1569924633-322-2-git-send-email-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 39abcc84 11-Sep-2019 Veeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>

usb: renesas_usbhs: add suspend event support in gadget mode

When R-Car Gen3 USB 2.0 is in Gadget mode, if host is detached an interrupt
will be generated and Suspended state bit is set in interrupt status
register. Interrupt handler will call driver->suspend(composite_suspend)
if suspended state bit is set. composite_suspend will call
ffs_func_suspend which will post FUNCTIONFS_SUSPEND and will be consumed
by user space application via /dev/ep0.

To be able to detect host detach, extend the DVSQ_MASK to cover the
Suspended bit of the DVSQ[2:0] bitfield from the Interrupt Status
Register 0 (INTSTS0) register and perform appropriate action in the
DVST interrupt handler (usbhsg_irq_dev_state).

Without this commit, disconnection of the phone from R-Car-H3 ES2.0
Salvator-X CN9 port is not recognized and reverse role switch does
not happen. If phone is connected again it does not enumerate.

With this commit, disconnection will be recognized and reverse role
switch will happen by a user space application. If phone is connected
again it will enumerate properly and will become visible in the output
of 'lsusb'.

Signed-off-by: Veeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1568207756-22325-3-git-send-email-external.veeraiyan.c@de.adit-jv.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ccc3264c 24-Jun-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: Avoid to write platform_data's value

The very old commit 482982062f1b ("usb: gadget: renesas_usbhs:
bugfix: don't modify platform data") changed to use copied whole
structures values to fix the "hung-up" issue. However, we also
can fix the issue if the driver copies the get_vbus function
pointer to the driver's value.

So, this patch adds get_vbus member into struct usbhs_mod_info and
use the pointer instead of struct renesas_usbhs_platform_callback.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0966648d 24-Jun-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: remove notify_hotplug callback

The notify_hotplug callback was supported in v3.10, but the last user
(armadillo800eva) was removed by the commit 1fa59bda21c7 ("ARM: shmobile:
Remove legacy board code for Armadillo-800 EVA"). So, this patch
removes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 25b22e35 28-Jun-2018 Gustavo A. R. Silva <gustavo@embeddedor.com>

USB: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6396bb22 12-Jun-2018 Kees Cook <keescook@chromium.org>

treewide: kzalloc() -> kcalloc()

The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:

kzalloc(a * b, gfp)

with:
kcalloc(a * b, gfp)

as well as handling cases of:

kzalloc(a * b * c, gfp)

with:

kzalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

kzalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

kzalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>


# 1250413a 06-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: renesas_usbhs: Remove redundant license text

Now that the SPDX tag is in all USB files, that identifies the license
in a specific and legally-defined manner. So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Rob Herring <robh@kernel.org>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Cc: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5fd54ace 03-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: add SPDX identifiers to all remaining files in drivers/usb/

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/usb/ and include/linux/usb* files with the correct
SPDX license identifier based on the license text in the file itself.
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 14a8d4bf 09-Aug-2017 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: fix spin_lock_init() for &uep->lock

This patch fixes an issue that the spin_lock_init() is not called
for almost all pipes. Otherwise, the lockdep output the following
message when we connect a usb cable using g_ncm:

INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.

Reported-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Fixes: b8b9c974afee ("usb: renesas_usbhs: gadget: disable all eps when the driver stops")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 7fc46137 12-Aug-2017 Bhumika Goyal <bhumirks@gmail.com>

usb: renesas_usbhs: gadget: make usb_ep_ops const

Make the structure const as it is only stored in the ops field of a
usb_ep structure, which is of type const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# b7d44c36 28-Jul-2017 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: fix unused-but-set-variable warning

The commit b8b9c974afee ("usb: renesas_usbhs: gadget: disable all eps
when the driver stops") causes the unused-but-set-variable warning.
But, if the usbhsg_ep_disable() will return non-zero value, udc/core.c
doesn't clear the ep->enabled flag. So, this driver should not return
non-zero value, if the pipe is zero because this means the pipe is
already disabled. Otherwise, the ep->enabled flag is never cleared
when the usbhsg_ep_disable() is called by the renesas_usbhs driver first.

Fixes: b8b9c974afee ("usb: renesas_usbhs: gadget: disable all eps when the driver stops")
Fixes: 11432050f070 ("usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable()")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# b8b9c974 19-Jul-2017 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: disable all eps when the driver stops

A gadget driver will not disable eps immediately when ->disconnect()
is called. But, since this driver assumes all eps stop after
the ->disconnect(), unexpected behavior happens (especially in system
suspend).
So, this patch disables all eps in usbhsg_try_stop(). After disabling
eps by renesas_usbhs driver, since some functions will be called by
both a gadget and renesas_usbhs driver, renesas_usbhs driver should
protect uep->pipe. To protect uep->pipe easily, this patch adds a new
lock in struct usbhsg_uep.

Fixes: 2f98382dc ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
Cc: <stable@vger.kernel.org> # v3.0+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# ee5acabf 22-Aug-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: set quirk_avoids_skb_reserve if USB-DMAC is used

This patch sets the quirk_avoids_skb_reserve flag to improve performance
of a network gadget driver (e.g. f_ncm.c) if USB-DMAC is used.

For example (on r8a7795 board + f_ncm.c + iperf udp mode / receiving):
- without this patch: 90.3 Mbits/sec
- with this patch: 273 Mbits/sec

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 7d80e4be 25-Aug-2016 Wolfram Sang <wsa-dev@sang-engineering.com>

usb: renesas_usbhs: mod_gadget: don't print on ENOMEM

All kmalloc-based functions print enough information on failures.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cb73db7d 25-Aug-2016 Wolfram Sang <wsa-dev@sang-engineering.com>

usb: renesas_usbhs: mod_gadget: don't print on ENOMEM

All kmalloc-based functions print enough information on failures.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 3295235f 12-Aug-2016 Wei Yongjun <weiyj.lk@gmail.com>

usb: renesas_usbhs: gadget: fix return value check in usbhs_mod_gadget_probe()

In case of error, the function usb_get_phy() returns ERR_PTR() and never
returns NULL. The NULL test in the return value check should be replaced
with IS_ERR().

Fixes: b5a2875605ca ("usb: renesas_usbhs: Allow an OTG PHY driver to
provide VBUS")
Cc: <stable@vger.kernel.org> # v4.3+
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 9ab967e6 08-Aug-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable()

This patch fixes an issue that unexpected BRDY interruption happens
when the usb_ep_{enable,disable}() are called with different direction.
In this case, the driver will cause the following message:

renesas_usbhs e6590000.usb: irq_ready run_error 1 : -16

This issue causes the followings:
1) A pipe is enabled as transmission
2) The pipe sent a data
3) The pipe is disabled and re-enabled as reception.
4) The pipe got a queue

Since the driver doesn't clear the BRDYSTS flags after 2) above, the issue
happens. If we add such clearing the flags into the driver, the code will
become complicate. So, this patch clears the BRDYSTS flag of reception in
usbhsg_ep_enable() to avoid complicate.

Cc: <stable@vger.kernel.org> # v4.1+ (usbhs_xxxsts_clear() is needed)
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 15e4292a 08-Jun-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()

This patch fixes an issue that the CFIFOSEL register value is possible
to be changed by usbhsg_ep_enable() wrongly. And then, a data transfer
using CFIFO may not work correctly.

For example:
# modprobe g_multi file=usb-storage.bin
# ifconfig usb0 192.168.1.1 up
(During the USB host is sending file to the mass storage)
# ifconfig usb0 down

In this case, since the u_ether.c may call usb_ep_enable() in
eth_stop(), if the renesas_usbhs driver is also using CFIFO for
mass storage, the mass storage may not work correctly.

So, this patch adds usbhs_lock() and usbhs_unlock() calling in
usbhsg_ep_enable() to protect CFIFOSEL register. This is because:
- CFIFOSEL.CURPIPE = 0 is also needed for the pipe configuration
- The CFIFOSEL (fifo->sel) is already protected by usbhs_lock()

Fixes: 97664a207bc2 ("usb: renesas_usbhs: shrink spin lock area")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# b41d8a6a 18-Apr-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: use usb_gadget_{un}map_request_by_dev() for IPMMU

The previous code could use the first USB-DMAC with IPMMU if iommus
property was set into this device node. However, in this case, it
could not control the second USB-DMAC with IPMMU because a parameter
of IPMMU (micro-TLB id) is different with each USB-DMAC.

So, this patch uses the usb_gadget_{un}map_request_by_dev() APIs for
IPMMU. (Then, iommus property should be set into USB-DMAC node(s).)

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# c3cdcac7 18-Apr-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: change arguments of dma_map_ctrl()

Since usbhsg_dma_map_ctrl() needs DMA device structure in the near future,
this patch changes arguments of dma_map_ctrl() to give such data.
(This patch is only change the argument.)

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 4fccb076 04-Apr-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: fix to avoid using a disabled ep in usbhsg_queue_done()

This patch fixes an issue that usbhsg_queue_done() may cause kernel
panic when dma callback is running and usb_ep_disable() is called
by interrupt handler. (Especially, we can reproduce this issue using
g_audio with usb-dmac driver.)

For example of a flow:
usbhsf_dma_complete (on tasklet)
--> usbhsf_pkt_handler (on tasklet)
--> usbhsg_queue_done (on tasklet)
*** interrupt happened and usb_ep_disable() is called ***
--> usbhsg_queue_pop (on tasklet)
Then, oops happened.

Fixes: e73a989 ("usb: renesas_usbhs: add DMAEngine support")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 11ebf3ad 03-Mar-2016 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: fix giveback status code in usbhsg_pipe_disable()

A udc driver should set the giveback status to -ESHUTDOWN in
usb_ep_disable(). Otherwise, a gadget driver (e.g. g_serial) might
request next data wrongly and it is possible to cause kernel panic.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>


# 64c5f48b 17-Nov-2015 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: Modify ep.caps.type_xxx and usb_ep_maxpacket_limit()

This patch modifies the ep.caps.type_{iso,bulk,int} setting and
the second argument of usb_ep_maxpacket_limit() using
the dparam.pipe_configs.

In the previous code, all the type_{iso,bulk,int} were set to true.
However, to avoid waste time for finding suitable pipe in usb_ep_enable(),
this driver should set correct type.
Also the second argument of usb_ep_maxpacket_limit() was set to 512
even if the pipe is isochronous or interrupt. So, this driver could
not bind a gadget driver like the g_audio driver.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# c9eb2950 17-Nov-2015 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: Fix NULL pointer dereference in usbhsg_ep_dequeue()

This patch fixes an issue that NULL pointer dereference happens when
a gadget driver calls usb_ep_dequeue() for ep0 after disconnected
a usb cable. This is because that usbhsg_try_stop() will call
usbhsg_ep_disable(&dcp->ep) when a usb cable is disconnected and
the pipe of dcp (ep0) is set to NULL.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 916f7ac5 31-Jul-2015 Robert Baldyga <r.baldyga@samsung.com>

usb: renesas: gadget: add ep capabilities support

Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# b5a28756 13-Jul-2015 Phil Edworthy <phil.edworthy@renesas.com>

usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS

These changes allow a PHY driver to trigger a VBUS interrupt and
to provide the value of VBUS.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 5fd3fc1c 13-Jul-2015 Phil Edworthy <phil.edworthy@renesas.com>

usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS

These changes allow a PHY driver to trigger a VBUS interrupt and
to provide the value of VBUS.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 00f30d29 16-Mar-2015 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: fix spinlock suspected in a gadget complete function

According to the gadget.h, a "complete" function will always be called
with interrupts disabled. However, sometimes usbhsg_queue_pop() function
is called with interrupts enabled. So, this function should be held by
usbhs_lock() to disable interruption. Also, this driver has to call
spin_unlock() to avoid spinlock recursion by this driver before calling
usb_gadget_giveback_request().
Otherwise, there is possible to cause a spinlock suspected in a gadget
complete function.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# a17fd412 28-Jan-2015 Peter Chen <peter.chen@freescale.com>

usb: renesas_usbhs: gadget: set value for common is_selfpowered

Set value for common is_selfpowered.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# cdeb7943 03-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: fix usbhs_pipe_clear() for DCP PIPE

Since the DCPCTR doesn't have the ACLRM bit, the usbus_pipe_clear()
should not call the usbhsp_pipectrl_set() with ACLRM.
So, this patch fixes this issue to add the usbhs_fifo_clear_dcp()
in fifo.c because the controller needs the CFIFO to clear the
the DCP PIPE.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 4ef35b10 03-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: fix the timing of dcp_control_transfer_done

According to the datasheet, this driver should clear the INTSTS0.CTRT
bit before this controller detects the next stage transition. Otherwise,
the driver may not be able to clear the bit after the controller went to
the next stage transition. After that, the driver will not be able to
clear the INTSTS0.VALID, and a usb control transfer will not finish
finally.

If we use the testusb tool, it is easy to reproduce this issue:

# testusb -a -t 10

Since the previous code handled a data stage and a status stage in
the usbhsf_pio_try_push(), it may not clear the INTSTS0.CTRT at the
right timing.
So, this patch change the timing of usbhs_dcp_control_transfer_done()
to the usbhsg_irq_ctrl_stage().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 04a5def3 03-Nov-2014 Takeshi Kihara <takeshi.kihara.df@renesas.com>

usb: renesas_usbhs: gadget: fix the behavior of pullup

This patch fixes an issue that this driver always enable the D+ pullup
after it detected the VBUS connection even though this usb controller
can control the D+ pullup timing by software. So, this driver should
enable the D+ pullup after a gadget driver called usb_gadget_connect().

Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 11432050 03-Nov-2014 Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>

usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable()

This patch fixes an issue that the NULL pointer dereference happens
when we uses g_audio driver. Since the g_audio driver will call
usb_ep_disable() in afunc_set_alt() before it calls usb_ep_enable(),
the uep->pipe of renesas usbhs driver will be NULL. So, this patch
adds a condition to avoid the oops.

Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Fixes: 2f98382dc (usb: renesas_usbhs: Add Renesas USBHS Gadget)
Cc: <stable@vger.kernel.org> # v3.0+
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 22835b80 16-Oct-2014 Felipe Balbi <balbi@ti.com>

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>


# 304f7e5e 24-Sep-2014 Michal Sojka <sojka@merica.cz>

usb: gadget: Refactor request completion

Use the recently introduced usb_gadget_giveback_request() in favor of
direct invocation of the completion routine.

All places in drivers/usb/ matching "[-.]complete(" were replaced with a
call to usb_gadget_giveback_request(). This was compile-tested with all
ARM drivers enabled and runtime-tested for musb.

Signed-off-by: Michal Sojka <sojka@merica.cz>
Acked-by: Felipe Balbi <balbi@ti.com>
Tested-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dfb87b8b 09-Jul-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: fix re-enabling pipe without re-connecting

This patch fixes an issue that the renesas_usbhs driver in gadget mode
cannot work correctly even if I disabled DMAC of the driver when I used
the g_zero driver and the testusb tool.

When a usb cable is re-connected, the renesas_usbhs driver calls the
usbhsp_flags_init() (via usbhs_hotplug() --> usbhs_mod_call(start) -->
usbhsg_try_start() --> usbhs_pipe_init()). However, the driver doesn't
call the usbhsp_flags_init() when usbhsg_ep_disable() is called.
So, if a gadget driver calls usb_ep_enable() and usb_ep_disable() again
and again, the renesas_usbhs driver will output the following log:

renesas_usbhs renesas_usbhs: can't get pipe (BULK)
renesas_usbhs renesas_usbhs: wrong recip request

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# e117e742 12-Dec-2013 Robert Baldyga <r.baldyga@samsung.com>

usb: gadget: add "maxpacket_limit" field to struct usb_ep

This patch adds "maxpacket_limit" to struct usb_ep. This field contains
maximum value of maxpacket supported by driver, and is set in driver probe.
This value should be used by autoconfig() function, because value of field
"maxpacket" is set to value from endpoint descriptor when endpoint becomes
enabled. So when autoconfig() function will be called again for this endpoint,
"maxpacket" value will contain wMaxPacketSize from descriptior instead of
maximum packet size for this endpoint.

For this reason this patch adds new field "maxpacket_limit" which contains
value of maximum packet size (which defines maximum endpoint capabilities).
This value is used in ep_matches() function used by autoconfig().

Value of "maxpacket_limit" should be set in UDC driver probe function, using
usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function
set choosen value to both "maxpacket_limit" and "maxpacket" fields.

This patch modifies UDC drivers by adding support for maxpacket_limit.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 925403f4 11-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro

Current usbhsx_for_each_xxx macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the binary which was
compiled by (at least) gcc 4.8.1 is broken
This patch tidyup these issues

Reported-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Reviewed-by: Takashi Yoshii <takashi.yoshii.zj@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 8047806e 08-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: gadget: remove extra check on udc_stop

usb_gadget_ops :: udc_stop might be called with driver = NULL since
511f3c5326eabe1ece35202a404c24c0aeacc246
(usb: gadget: udc-core: fix a regression during gadget driver unbinding)

Because of that, 2nd times insmod goes fail.
This patch fixes it up.

Reported-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 225da3e3 31-Mar-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup sparse errors for common.c

This patch fixup below sparse errors

CHECK ${RENESAS_USB}/common.c
${RENESAS_USB}/common.c:313:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:322:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:384:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:524:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:545:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:574:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:606:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/mod_gadget.c:233:28: warning: symbol 'req_clear_feature' was not declared. Should it be static?
${RENESAS_USB}/mod_gadget.c:274:28: warning: symbol 'req_set_feature' was not declared. Should it be static?
${RENESAS_USB}/mod_gadget.c:375:28: warning: symbol 'req_get_status' was not declared. Should it be static?

[ balbi@ti.com : added three sparse fixes to mod_gadget.c ]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3920193d 26-Feb-2013 Felipe Balbi <balbi@ti.com>

usb: renesas: 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>


# 8707d5ab 26-Feb-2013 Felipe Balbi <balbi@ti.com>

usb: renesas: 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>


# 7bce401c 24-Jan-2013 Felipe Balbi <balbi@ti.com>

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>


# 0972ef71 24-Jan-2013 Felipe Balbi <balbi@ti.com>

usb: renesas_usbhs: gadget: let udc-core manage gadget->dev

By simply setting a flag, we can drop some
boilerplate code.

Signed-off-by: Felipe Balbi <balbi@ti.com>


# eeef4587 24-Jan-2013 Felipe Balbi <balbi@ti.com>

usb: gadget: constify all struct usb_gadget_ops

Add the missing 'const' keyword to all struct
usb_gadget_ops in the gadget framework.

Signed-off-by: Felipe Balbi <balbi@ti.com>


# d9fa298f 10-Dec-2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: gadget: usbhsg_ep_disable() care pipe settings

Current usbhsg_ep_disable() didn't care
uep->pipe and pipe->mod_private variable which is used on usbhsg_ep_enable().
It breaks renesas_usbhs gadget when resume.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 58482945 10-Dec-2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: gadget: remove usbhsg_uep_init()

Current driver always initialized uep->pipe to NULL on usbhsg_try_start().
But it breaks relationship with
usb_ep_ops :: enable/disable functions when suspend/resume.
This patch solved this issue by initializing uep->pipe on probe()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 4cd2f599 16-Oct-2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: gadget: add usb_gadget_ops :: pullup support

This patch adds usbhs_sys_function_pullup() to control
D+ line for USB function, and enabled pullup support on mod_gadget.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# cac402dd 15-Mar-2012 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: add support for set_selfpowered

The previous code always set to USB_DEVICE_SELF_POWERED in GET_STATUS.
So, this patch adds set_selfpowered().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# ade78f9f 19-Dec-2011 Felipe Balbi <balbi@ti.com>

usb: renesas: gadget: use generic map/unmap routines

those routines have everything we need to map/unmap
USB requests and it's better to use them.

Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3b2a2e47 20-Feb-2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: bugfix: add .release function to gpriv->gadget.dev

This patch fixup below warning on device_unregister()

renesas_usbhs renesas_usbhs.1: host probed
renesas_usbhs renesas_usbhs.1: gadget probed
renesas_usbhs renesas_usbhs.1: irq request err
------------[ cut here ]------------
WARNING: at ${LINUX}/drivers/base/core.c:1)
Device 'gadget' does not have a release() function, it is broken and must be fi.
Modules linked in:
[<c000e25c>] (unwind_backtrace+0x0/0xe4) from [<c0016960>] (warn_slowpath_commo)
[<c0016960>] (warn_slowpath_common+0x4c/0x64) from [<c00169f8>] (warn_slowpath_)
[<c00169f8>] (warn_slowpath_fmt+0x2c/0x3c) from [<c0185b80>] (device_release+0x)
[<c0185b80>] (device_release+0x70/0x84) from [<c013e300>] (kobject_cleanup+0x58)
[<c013e300>] (kobject_cleanup+0x58/0x6c) from [<c01cba14>] (usbhs_mod_gadget_re)
[<c01cba14>] (usbhs_mod_gadget_remove+0x3c/0x6c) from [<c01c8384>] (usbhs_mod_p)
[<c01c8384>] (usbhs_mod_probe+0x68/0x80) from [<c01c7f84>] (usbhs_probe+0x1cc/0)
...

Cc: stable@vger.kernel.org
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 7983bc74 16-Jan-2012 Jesper Juhl <jj@chaosbits.net>

usb: renesas: silence uninitialized variable report in usbhsg_recip_run_handle()

In drivers/usb/renesas_usbhs/mod_gadget.c::usbhsg_recip_run_handle()
the Coverity Prevent checker currently flags a warning about possibly
uninitialized use of 'ret' i usbhsg_recip_run_handle(). It does this
since it assumes we take one of the non-default branches in the switch
and then subsequently take the false branch in the 'if (func)' case
below. This exact scenario will never happen, but Coverity can't see
that for some reason. This patch initializes 'ret' to '0' when it is
declared which should shut up this report and won't really hurt - so
why not? At least then it's clear that 'ret' is always initialized..

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 8418153a 15-Dec-2011 Dan Carpenter <dan.carpenter@oracle.com>

usb: renesas_usbhs: silence a gcc warning

Gcc complains about this printk:
drivers/usb/renesas_usbhs/mod_gadget.c:188:3: warning: format ‘%x’
expects argument of type ‘unsigned int’, but argument 3 has type
‘dma_addr_t’ [-Wformat]

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3edeee38 08-Dec-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: care pipe sequence

driver has to re-use the limited pipe for each device/endpoint
when it is USB host hub mode, since number of pipe has limitation.

Then, each pipe should care own pipe sequence for next packet.
This patch adds sequence control.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# b294b203 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: remove the_controller_link

current renesas_usbhs is using new style udc_start/stop from
af1d7056a5c1e5eaaf807ddd1423101db84668d0
(usb: gadget: renesas: convert to new style).

with this patch we can finally remove the global "the_controller_link"

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# dfbb7f4f 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add test-mode support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 91b158f4 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: call usbhsg_queue_pop() when pipe disable.

When poping packet from queue, it needs correct end procedure.
This patch call usbhsg_queue_pop() in usbhsg_pipe_disable().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 25fa7079 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: send packet in necessary timing.

Current renesas_usbhs driver always tries to send packet in end of recip handler.
But it breaks chapter 9 EndpointHalt test.
This patch fixup this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 17f7f769 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add basic USB_REQ_GET_STATUS support

This patch adds basic get-status support for chapter 9 test.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# ced6e09e 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add basic USB_REQ_SET_FEATURE support

This patch adds basic set-feature support for chapter 9 test.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 4b815932 24-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: remove superfluous usbhs_lock from recip handler

recip handler will call various functions which are holding
usbhs_lock.

This patch removes superfluous usbhs_lock from recip handler
to escape double lock.

[ balbi@ti.com : brushed up commit log a bit ]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 7177aed4 19-Nov-2011 Michal Nazarewicz <mina86@mina86.com>

usb: gadget: rename usb_gadget_driver::speed to max_speed

This commit renames the “speed” field of the usb_gadget_driver
structure to “max_speed”. This is so that to make it more
apparent that the field represents the maximum speed gadget
driver can support.

This also make the field look more like fields with the same
name in usb_gadget and usb_composite_driver structures. All
of those represent the *maximal* speed given entity supports.

After this commit, there are the following fields in various
structures:
* usb_gadget::speed - the current connection speed,
* usb_gadget::max_speed - maximal speed UDC supports,
* usb_gadget_driver::max_speed - maximal speed gadget driver
supports, and
* usb_composite_driver::max_speed - maximal speed composite
gadget supports.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# d327ab5b 19-Nov-2011 Michal Nazarewicz <mina86@mina86.com>

usb: gadget: replace usb_gadget::is_dualspeed with max_speed

This commit replaces usb_gadget's is_dualspeed field with
a max_speed field.

[ balbi@ti.com : Fixed DWC3 driver ]

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3244a7b4 23-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: remove usbhs_sys_usb_ctrl()

usbhs_sys_usb_ctrl() can collect into usbhs_sys_host/function_ctrl().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 2288e109 23-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: remove usbhs_sys_hispeed_ctrl()

usbhs_sys_hispeed_ctrl() can collect into usbhs_sys_host/function_ctrl().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 89f829a5 17-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup driver speed

This patch cares latest USB_SPEED_SUPER support.
renesas_usbhs can not use super-speed, but can use full/high speed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0cdd7d4b 17-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup gadget.dev.driver when udc_stop.

current renesas_usbhs is using new style udc_start/stop from
af1d7056a5c1e5eaaf807ddd1423101db84668d0
(usb: gadget: renesas: convert to new style).

But current renesas_usbhs driver didn't care about gadget.dev.driver
when udc_stop. it cause rmmod oops.
This patch care it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8885a897 17-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup signal the driver that cable was disconnected

current renesas_usbhs is using new style udc_start/stop from
af1d7056a5c1e5eaaf807ddd1423101db84668d0
(usb: gadget: renesas: convert to new style).

cable disconnected signal was needed.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# f8eff0a0 17-Nov-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup device_register timing

current renesas_usbhs is using new style udc_start/stop from
af1d7056a5c1e5eaaf807ddd1423101db84668d0
(usb: gadget: renesas: convert to new style).

But bind() function will fail if it was called before
device_register() (or device_add()).
This patch modifies this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# b7a8d17d 26-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: fixup section mismatch warning

Fix up the following section mismatch warnings:

WARNING: drivers/usb/renesas_usbhs/renesas_usbhs.o(.text+0xf5d): Section
mismatch in reference from the function usbhs_mod_probe() to the function
.devinit.text:usbhs_mod_host_probe() The function usbhs_mod_probe() references
the function __devinit usbhs_mod_host_probe(). This is often because
usbhs_mod_probe lacks a __devinit annotation or the annotation of
usbhs_mod_host_probe is wrong.

WARNING: drivers/usb/renesas_usbhs/renesas_usbhs.o(.text+0xfd7): Section
mismatch in reference from the function usbhs_mod_probe() to the function
.devexit.text:usbhs_mod_host_remove() The function usbhs_mod_probe() references
a function in an exit section. Often the function usbhs_mod_host_remove() has
valid usage outside the exit section and the fix is to remove the __devexit
annotation of usbhs_mod_host_remove.

WARNING: drivers/usb/renesas_usbhs/renesas_usbhs.o(.text+0x1005): Section
mismatch in reference from the function usbhs_mod_remove() to the function
.devexit.text:usbhs_mod_host_remove() The function usbhs_mod_remove()
references a function in an exit section. Often the function
usbhs_mod_host_remove() has valid usage outside the exit section and the fix is
to remove the __devexit annotation of usbhs_mod_host_remove.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6e6db82b 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: modify pipe sequence settings

renesas_usbhs can manually set DATA0/DATA1.
This patch is prepare for mod_host support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 654c35ab 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: disable auto paket start on usbhs_pkt_push()

Automatically packet start by usbhs_pkt_push() was useful.
But the pushed packet will be called twice
if new packet was pushed on usbhs_pkt :: done callback.
(1st is called by usbhs_pkt_push(), 2nd is called by usbhsf_pkt_handler())

This patch disables automatic packet start,
and clarified packet start timing.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# b331872b 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: move done callback to struct usbhs_pkt

transfer done function was registered in struct struct usbhs_pipe_info.
It was good for mod_gadget, but not good for mod_host.
This function move it to struct usbhs_pkt.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# bc6fbf59 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: add device select support in usbhs_pipe_config_update()

device select method will be used on mod_host

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 2cc97197 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: add struct usbhs_priv to packet done function

There was no method to get struct usbhs_priv when
packet transfer done function was called.
This patch allow that callback function receive it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 75587f52 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: add usbhs_bus_get_speed()

current mod_gadget had got usb speed on
usbhsg_irq_dev_state() which is status change interrupt callback function.
And the usb speed data was included in its parameter.

But this style works for mod_gadget,
but doesn't work for mod_host which
isn't interrupted when device status was changed.

This patch add usbhs_bus_get_speed() to solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 0c6ef985 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: struct usbhs_pipe hold handler

packet handler had moved to struct usbhs_pipe from struct usbhsg_uep.
it is preparation of mod_host support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# f5aa889f 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: remove desc from usbhs_pipe_malloc

Current usbhs_pipe_malloc() used usb_endpoint_descriptor to
get necessary information.
It was very good for mod_gadget which allocate pipe in runtime,
but is not good for mod_host which allocate pipe in initial timing.
This patch remove usb_endpoint_descriptor from usbhs_pipe_malloc()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# af1d7056 10-Oct-2011 Felipe Balbi <balbi@ti.com>

usb: gadget: renesas: convert to new style

using udc_start()/udc_stop() as we should.

Signed-off-by: Felipe Balbi <balbi@ti.com>


# cf6808cb 03-Aug-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: fix DMA build by including dma-mapping.h

Include dma-mapping.h to fix build of the renesas_usbhs driver

| CC drivers/usb/renesas_usbhs/mod_gadget.o
| drivers/usb/renesas_usbhs/mod_gadget.c: In function 'usbhsg_dma_map':
| drivers/usb/renesas_usbhs/mod_gadget.c:190: error: implicit declaration of function 'dma_map_single'
| drivers/usb/renesas_usbhs/mod_gadget.c:192: error: implicit declaration of function 'dma_sync_single_for_device'
| drivers/usb/renesas_usbhs/mod_gadget.c:196: error: implicit declaration of function 'dma_mapping_error'
| drivers/usb/renesas_usbhs/mod_gadget.c: In function 'usbhsg_dma_unmap':
| drivers/usb/renesas_usbhs/mod_gadget.c:217: error: implicit declaration of function 'dma_unmap_single'
| drivers/usb/renesas_usbhs/mod_gadget.c:219: error: implicit declaration of function 'dma_sync_single_for_cpu'
| make[5]: *** [drivers/usb/renesas_usbhs/mod_gadget.o] Error 1
| make[4]: *** [drivers/usb/renesas_usbhs] Error 2

Reported-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# e94c587e 12-Jul-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup usbhsg_for_each_uep 1st pos

1st pos of __usbhsg_for_each_uep() was wrong.
Expected uep were ep1, ep2, ep3...
but each uep were ep0, ep2, ep3 ...
This patch modify it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d128a259 03-Aug-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fix DMA build by including dma-mapping.h

Include dma-mapping.h to fix build of the renesas_usbhs driver

CC drivers/usb/renesas_usbhs/mod_gadget.o
drivers/usb/renesas_usbhs/mod_gadget.c: In function 'usbhsg_dma_map':
drivers/usb/renesas_usbhs/mod_gadget.c:190: error: implicit declaration of function 'dma_map_single'
drivers/usb/renesas_usbhs/mod_gadget.c:192: error: implicit declaration of function 'dma_sync_single_for_device'
drivers/usb/renesas_usbhs/mod_gadget.c:196: error: implicit declaration of function 'dma_mapping_error'
drivers/usb/renesas_usbhs/mod_gadget.c: In function 'usbhsg_dma_unmap':
drivers/usb/renesas_usbhs/mod_gadget.c:217: error: implicit declaration of function 'dma_unmap_single'
drivers/usb/renesas_usbhs/mod_gadget.c:219: error: implicit declaration of function 'dma_sync_single_for_cpu'
make[5]: *** [drivers/usb/renesas_usbhs/mod_gadget.o] Error 1
make[4]: *** [drivers/usb/renesas_usbhs] Error 2

Reported-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 3b872188 03-Jul-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: support multi driver

Some SuperH/board has multi USBHS on it.
This patch supports multi register for renesas_usbhs

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 233f519d 07-Jul-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fixup comment-out

This patch add/modify comment-out of renesas_usbhs.
On this process, usbhs_pkt_init was moved because it was placed under
usbhsf_null_handler which has no relationship it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6d721b29 21-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: use dma handler

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0f91349b 28-Jun-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb: gadget: convert all users to the new udc infrastructure

peripheral drivers are using usb_add_gadget()/usb_del_gadget() to
register/unregister to the udc-core.

The udc-core will take the first available gadget driver and attach
function driver which is calling usb_gadget_register_driver(). This is
the same behaviour we have right now.

Only dummy_hcd was tested, the others were compiled tested.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Li Yang <leoli@freescale.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Pavankumar Kondeti <pkondeti@codeaurora.org>
Cc: Roy Huang <roy.huang@analog.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>
Cc: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: cxie4 <cxie4@marvell.com>
Cc: linux-geode@lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 08e6c611 09-Jun-2011 Kuninori Morimoto <morimoto.kuninori@renesas.com>

usb: renesas_usbhs: fixup connection fail

Sometimes the connection fail happen on renesas_usbhs.
This patch fix it up.

Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e73a9891 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add DMAEngine support

USB DMA was installed on "normal DMAC" when SH7724 or older SuperH,
but the "USB-DMAC" was prepared on recent SuperH.
These 2 DMAC have a little bit different behavior.

This patch add DMAEngine code for "normal DMAC",
but it is still using PIO fifo.
The DMA fifo will be formally supported in the future.

You can enable DMA fifo by local fixup
usbhs_fifo_pio_push_handler -> usbhs_fifo_dma_push_handler
usbhs_fifo_pio_pop_handler -> usbhs_fifo_dma_pop_handler
on usbhsg_ep_enable.

This DMAEngine was tested by g_file_storage on SH7724 Ecovec board

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0cb7e61d 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: tidyup pio handler name

This patch tidyup PIO packet handler name.
This is a preparation for DMAEngine support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0432eed0 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: tifyup packet start timing

packet transfer timing are controlled in mod_gadget on current renesas_usbhs,
and this style will be imitated on mod_host.
But it need not be managed with host/gadget if it is general transfer.
By this patch, the packet transfer timing is managed in fifo.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 97664a20 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: shrink spin lock area

spin lock was very effective while doing 1 packet send/recv on
current renesas_usbhs driver.
But this lock is enough only
- modify packet/pipe link
- modify interrpt mask
- modify fifo access
This patch shrink spin lock area

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8a2c225d 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: remove usbhsg_queue_get

usbhsg_queue_get is no longer needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# dad67397 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify data transfer interrupt

On current driver, overall data transfer method was implemented in fifo.c,
but its interrupt which is member of packet queue control
was still in mod_gadget.c.
This patch move it into fifo.c.
By this patch, the packet/fifo control is independent from mod_gadget.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 659d4954 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify data transfer method

On current driver, main data transfer function was implemented in fifo.c,
but the overall controlling was implementing in mod_gadget.c.
This style is not useful to support host and DMAEngine in the future.

But the interrupt for data transfer cannot separate easily for now,
because it is deeply related to mod_gadget.

This patch move the overall data transfer method
into fifo.c except interrupt.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6acb95d4 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify packet queue control method

Current renesas_usbhs driver is controlling packet queue on mod_gadget.c.
But it has relationship with pipe/fifo, not host/gadget.
So, controlling USB packet queue in pipe.c/fifo.c is
more convenient than in mod_gadget.c.
This patch modify it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 4bd04811 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: divide data transfer functions

DMAEngine will be supported to this driver in the future.
Then, both PIO and DMA data transfer method should be supported.
But, the transfer function can returns the result immediately
in PIO version, but it can't in DMA version.
This patch divides data transfer functions into top/bottom half
in preparation for DMAEngine support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e8d548d5 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fifo became independent from pipe.

Current renesas_usbhs has PIO data transfer mode which controls CFIFO.
And it was implemented in pipe.c.
But, fifo control method needs more flexible implementation
to support DMAEngine.
This patch create fifo.c, and it became independent from pipe.c.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 3af51ac9 03-Jun-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb/renesas_usbhs: free uep on removal

Can't find evidence that this is actually done.

Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 9a28b7bd 20-Apr-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: return error if wrong recip request

There are some USB Host which doesn't notice disconnection at once.
And it might try some request after reconnection with old settings.
Current renesas_usbhs will crash in such case.
This patch prevent this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# cb96632c 20-Apr-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify spinlock method

Current renesas_usbhs driver was using spin_trylock to avoid
dead lock / nest lock.
But acording to CONFIG_DEBUG_SPINLOCK, it is BUG under UP environment.
This patch add usbhsg_trylock to avoid this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 409ba9e7 25-Apr-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: don't re-allocation pipe buffer

Because pipe buffer allocation is very picky and difficult,
current renesas_usbhs driver is not caring pipe re-allocation.

In this situation, driver will create new pipe without caring old pipe
if "usbhsg_ep_enable" is called after "usbhsg_ep_disable" on current driver.
This mean the limited pipe and buffer will be used as waste.
But it is possible to re-use same buffer to same pipe.

By this patch, driver will initialize pipe when it detected new connection or
new gadget, and doesn't try re-allocation for same pipe in above case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2f98382d 04-Apr-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: Add Renesas USBHS Gadget

This patch add usb gadget code to SuperH USBHS.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>