usb: otg: tegra: Add builtin host support to tegra OTG

bug 947300

Change-Id: Ib9f1b796faa94d8424cfca41c7ec29d5360ef60c
Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com>
Reviewed-on: http://git-master/r/106983
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
GVS: Gerrit_Virtual_Submit
usb: serial: baseband_usb_chr kernel panic

Two threads race for two resources when baseband_usb_close()
get called from a user process

Bug 988188

Change-Id: Ic962640b6414e576d34b7ff6870b21b644837434
Signed-off-by: pyu <pyu@nvidia.com>
Reviewed-on: http://git-master/r/107088
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-by: Steve Lin <stlin@nvidia.com>
USB: tegra: otg: Enable host by default

Host support should be disabled only when there is platform
data specifying proper setting.

Bug 998001

Change-Id: I99ff534074dd7ebbf12b53dcf53d6286925965d2
Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/108760
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
usb: tegra: otg: fix unbalanced suspend/resume

Becasue of a previous workaround, suspend/resume pair is implemented as
suspend/complete pair in the driver's dev_pm_ops field.

If any driver suspend routine (which is called before otg suspend)
failed, then tegra_otg_resume() will be called even tegra_otg_suspend()
is not called. This will cause disable the OTG clock, and OTG will not
generate any more IRQ.

Ideal fix would be use suspend/resume pair to implement the dev_pm_ops,
but this might break previous workaround. This patch check suspend()
routine is called or not in the resume routine; even we use suspend/
resume pair in the future, it will not cause bad behaviour.

BUG 999759

Change-Id: I88f9c28bb76c5ff9e32917904017f291456cb933
Signed-off-by: Xin Xie <xxie@nvidia.com>
Reviewed-on: http://git-master/r/108444
(cherry picked from commit c751aeea65f126d8e2df7f8a9ba02a631f958dc1)
Reviewed-on: http://git-master/r/108945
Reviewed-by: Lokesh Pathak <lpathak@nvidia.com>
Tested-by: Lokesh Pathak <lpathak@nvidia.com>
usb: gadget: tegra_udc: include pm_qos header file

Include pm_qos_params header file to avail pm_qos
apis.

Bug 923594

Change-Id: Icbaad45e83a688b537159eea22ddd7356565fabf
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/113438
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
ARM: tegra: usb: turn off power during suspend

Turn off regulators along with clocks during suspend

Bug 991262

Reviewed-on: http://git-master/r/108820
(cherry picked from commit 41ae7ac21a2c08da0e4312b8395b380a704fa16c)

Change-Id: Ib49eec5d91571d75881f4d252d956dece1d37d60
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/105364
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

Conflicts:
	arch/arm/mach-tegra/tegra_usb_phy.h
usb: host: tegra: code clean up

Addressed below items with this patch:
1. Using devm_kzalloc in place of kzalloc.
2. Correcting platform_get_irq return value check

Change-Id: I68225fe40adbb4be98e16ee2e0a4fccefadd8626
Reviewed-on: http://git-master/r/105843
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
usb: otg: remove otg callback

Previously the callback was added to control USB VBUS.
The standard way is to use regulator.

Bug 997805

Change-Id: I88b15befaf4e162478da19ead50695978b2c5f4b
Signed-off-by: Chandler Zhang <chazhang@nvidia.com>
Reviewed-on: http://git-master/r/112901
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
usb: otg: tegra: wake enabled

Wake sources usb VBUS or ID detect enabled

bug 980993
bug 936982

Change-Id: Iea36d308c1a118abdb7815212d749bd058d0054f
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: http://git-master/r/103141
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

Conflicts:
	drivers/usb/gadget/tegra_udc.c
	drivers/usb/otg/tegra-otg.c
usb: ehci: tegra: prevent illegal register access

Make sure phy is turned ON before reading USB
registers.

Bug 993380
Bug 1006579

Reviewed-on: http://git-master/r/116045
(cherry picked from commit a1a6db7dc88880fb3d4bca0036ce421e4032adae)
Change-Id: If94e691bf9b5b46dd8f8562f27cf86e59a4d6353
Reviewed-on: http://git-master/r/117257
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Rakesh Bodla <rbodla@nvidia.com>
Tested-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
usb: ehci: tegra: HSIC remote wakeup support

1) Returning in irq after remote wakeup resume handled
   in ehci irq function.
2) Removed the unused variables.

Bug 889618

Change-Id: I9a1fd25c753a53462bf7742065fa618caae501ab
Signed-off-by: Vinod Atyam <vatyam@nvidia.com>
Reviewed-on: http://git-master/r/111192
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
usb: cdc-acm: fix packet loss issue

There is race between acm_suspend and acm_read_bulk_callback. Host may
receive bulk transfer right before suspend. The packet will be discarded
if this urb is killed in acm_suspend. This patch checks the actual length
of urb and processes it in this case.

Bug 996268

Signed-off-by: Steve Lin <stlin@nvidia.com>

Change-Id: Ief2b42708160b67903f976ec60da825d46c4720b
Reviewed-on: http://git-master/r/117135
(cherry picked from commit af3e96c987fbae8a135d1ff18872b9c32e09b67f)
Reviewed-on: http://git-master/r/118105
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Steve Lin <stlin@nvidia.com>
Reviewed-by: Steve Lin <stlin@nvidia.com>
USB: gadget: tegra: SW WAR for dTD issue

SW WAR implementation for h/w issue observed on all tegra platforms
Adding a dTD to a Primed Endpoint May Not Get Recognized

TD freeing will be delayed until next TD is completed

Bug 1002166

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/109562
(cherry picked from commit 8603480606af20444ed91e3010a22cc02edacb78)

Change-Id: I875d06eb2db78a18858590645df631478f3201bb
Reviewed-on: http://git-master/r/116972
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Tested-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
usb: ehci: DMA buffer sync for qh/qtd descriptors

When EHCI host controller driver examines qh/qtd descriptors, driver
might see stale data in cache on some ARM CPU. This patch introduces
two helper functions, ehci_sync_qh() and ehci_sync_qtd(), to
invalidate cached descriptors so that driver can always read
up-to-date descriptors from memory.

Bug 1005403

Change-Id: I2345bda7dfe29c5fe7f9550066b518cd6624d263
Signed-off-by: JC Kuo <jckuo@nvidia.com>
Reviewed-on: http://git-master/r/116406
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: WK Tsai <wtsai@nvidia.com>
Reviewed-by: ChihMin Cheng <ccheng@nvidia.com>
Reviewed-by: Joy Wang <joyw@nvidia.com>
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-by: Michael Hsu <mhsu@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
usb: ehci: tegra: Update RUN bit properly.

Read the RUN bit and update it properly.
Remove unused variable.

Change-Id: I1df5dc99ce40e2ca15f0ade28d156a7262467519
Signed-off-by: Suresh Mangipudi <smangipudi@nvidia.com>
Reviewed-on: http://git-master/r/117958
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
usb: otg: tegra: correct improper register update

Value of WAKEUP register is not updated
properly. Correcting it to take appropriate
value.

Bug 1008660

Change-Id: Ic1dcfed6639c8e8c686bc6931216fd268e4521ed
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
usb: gadget: treat warning as errors for tegra_udc.c

bug 949219

Change-Id: If76cece9a5c929216024b165f48f37c4046faffc
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/118037
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
usb: otg: tegra: enable warning as error flag

-enable warnings as errors compilation flag
-handle errors of missing semicolon and mismatched argument type

bug 949219

Change-Id: I29b1c08c590c94fa1aa43a9e37abf0385e3597d5
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/118235
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
USB: gadget: f_accessory: change prototype of create_bluk_endpoints

Changing prototype of create_bluk_endpoints since
function can called during runtime.

Bug 1026235

Change-Id: I9a39abb4de4548f18e6c6482e56a9126fe4122a3
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/120277
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
usb: gadget: Don't build USB_FSL_MP_DR_OF on Tegra

This config option only builds on PPC platforms.

Change-Id: Ibe7ebdc2dd5b9aa46e8f887570481a11a373c417
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-on: http://git-master/r/95475
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Stephen Warren <swarren@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Nitin Kumbhar <nkumbhar@nvidia.com>