firefly-linux-kernel-4.4.55.git
7 years agoUPSTREAM: usb: dwc2: Add functions to set and clear force mode
John Youn [Thu, 17 Dec 2015 19:17:12 +0000 (11:17 -0800)]
UPSTREAM: usb: dwc2: Add functions to set and clear force mode

Added functions to set force mode for host and device. These functions
will check the current mode and only force if needed thus avoiding
unnecessary force mode delays. However clearing the mode is currently
done unconditionally and with the delay in place. This is needed during
the connector ID status change interrupt in order to ensure that the
mode has changed properly. This preserves the old behavior only for this
case. The warning comment about this is moved into the clear mode
condition.

Change-Id: I9f7f1056071e2bb4ac1f6482d355241f1c827469
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 09c96980dc723462ed2eeacc945fed5bcb278f85)

7 years agoUPSTREAM: usb: dwc2: Move reset into dwc2_get_hwparams()
John Youn [Thu, 17 Dec 2015 19:16:58 +0000 (11:16 -0800)]
UPSTREAM: usb: dwc2: Move reset into dwc2_get_hwparams()

The reset is required to get reset values of the hardware parameters but
the force mode is not. Move the base reset into dwc2_get_hwparams() and
do the reset and force mode afterwards.

Change-Id: I6ff12abe95a1dc9205496cb140c8c61958088c0e
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 263b7fb557f797d9d4d1dcf93fb6bb2efc3f1d46)

7 years agoUPSTREAM: usb: dwc2: Move mode querying functions into core.h
John Youn [Thu, 17 Dec 2015 19:16:45 +0000 (11:16 -0800)]
UPSTREAM: usb: dwc2: Move mode querying functions into core.h

These functions should go in core.h where they can be called from core,
device, or host.

Change-Id: I03e22ee0f6819998d152fab25c5b0b47e76275e1
Signed-off-by: John Youn <johnyoun@synopsys.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 1696d5ab99ef885ae62da5ad58f9eff16da7ff78)

7 years agoUPSTREAM: usb: dwc2: Fix dr_mode validation
John Youn [Thu, 17 Dec 2015 19:16:31 +0000 (11:16 -0800)]
UPSTREAM: usb: dwc2: Fix dr_mode validation

The dr_mode parameter was being checked against how the dwc2 module
was being configured at compile time. But it wasn't checked against
the hardware capabilities, nor were the hardware capabilities checked
against the compilation parameters.

This commit adds those checks and adjusts dr_mode to an appropriate
value, if needed. If the hardware capabilities and module compilation
do not match then we fail as it wouldn't be possible to run properly.

The hardware, module, and dr_mode, can each be set to host, device,
or otg. Check that all these values are compatible and adjust the
value of dr_mode if possible.

The following table summarizes the behavior:

                     actual
   HW  MOD dr_mode   dr_mode
 ------------------------------
  HST  HST  any    :  HST
  HST  DEV  any    :  ---
  HST  OTG  any    :  HST

  DEV  HST  any    :  ---
  DEV  DEV  any    :  DEV
  DEV  OTG  any    :  DEV

  OTG  HST  any    :  HST
  OTG  DEV  any    :  DEV
  OTG  OTG  any    :  dr_mode

Change-Id: I46f3925adffdea510366ff5d61c1faa23d8190a3
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 5268ed9d2e3b52f703f3661eef14cecbb2b572d4)

7 years agoUPSTREAM: usb: dwc2: Add functions to check the HW OTG config
John Youn [Thu, 17 Dec 2015 19:16:17 +0000 (11:16 -0800)]
UPSTREAM: usb: dwc2: Add functions to check the HW OTG config

Added functions to query the GHWCFG2.OTG_MODE. This tells us whether the
controller hardware is configured for OTG, device-only, or host-only.

Change-Id: I8f927d130a675ceb598b118d0c9a4e5d5b698739
Signed-off-by: John Youn <johnyoun@synopsys.com>
Tested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 6bea962053e76a4407f0d138184a8737eea960ee)

7 years agoUPSTREAM: usb: dwc2: Add dwc2_core_reset()
John Youn [Thu, 17 Dec 2015 19:16:03 +0000 (11:16 -0800)]
UPSTREAM: usb: dwc2: Add dwc2_core_reset()

dwc2_core_reset() was previously renamed to
dwc2_core_reset_and_dr_force_mode(). Now add back dwc2_core_reset() which
performs only a basic core reset without forcing the mode.

Change-Id: Id29e7e5d7bb473dd9f904a1a07cc544ba418805e
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit b5d308abef1c5c0f24128845e41d414a8f8438f6)

7 years agoUPSTREAM: usb: dwc2: Rename dwc2_core_reset()
John Youn [Thu, 17 Dec 2015 19:15:49 +0000 (11:15 -0800)]
UPSTREAM: usb: dwc2: Rename dwc2_core_reset()

Renamed dwc2_core_reset() to dwc2_core_reset_and_force_dr_mode(). This
describes what it is doing more accurately. This is in preparation of
introducing a plain dwc2_core_reset() function that only performs the
reset and doesn't force the mode.

Change-Id: I1c0c17ed45cfcffe30561eaccd773d489e3c980c
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 6d58f346a61ff50eda740e6216e9829e572d75c8)

7 years agoUPSTREAM: usb: dwc2: gadget: don't overwrite DCTL register on NAKEFF interrupts
Gregory Herrero [Mon, 7 Dec 2015 11:07:31 +0000 (12:07 +0100)]
UPSTREAM: usb: dwc2: gadget: don't overwrite DCTL register on NAKEFF interrupts

When receiving GINTSTS_GINNAKEFF or GINTSTS_GOUTNAKEFF interrupt,
DCTL will be overwritten with DCTL_CGOUTNAK or DCTL_CGNPINNAK values.
Instead of overwriting it, write only needed bits.

It could cause an issue if GINTSTS_GINNAKEFF or GINTSTS_GOUTNAKEFF
interrupt is received after dwc2 disabled pullup by writing
DCTL_SFTDISCON bit.
Pullup will then be re-enabled whereas it should not.

Change-Id: Idd93b20c3d780fffdf03cc30481eb4aed9aafe1e
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3be99cd0e882dd2127b8cfe3942f5e464915aeba)

7 years agoUPSTREAM: usb: dwc2: fix transfer stop programming for out endpoint
Du, Changbin [Fri, 4 Dec 2015 07:38:23 +0000 (15:38 +0800)]
UPSTREAM: usb: dwc2: fix transfer stop programming for out endpoint

To stop an out endpoint, software should set sets the Global OUT NAK,
but not the Global Non-periodic IN NAK. This driver bug leads the out-ep
failed be in disabled state with below error.

dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable

Change-Id: I5f8cc03a2a8c33311d9caf76fd028d15c66e58a8
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Du, Changbin <changbin.du@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 0676c7e734e3807f4e91f5d0edcaeed1f5ff412a)

7 years agoUPSTREAM: usb: dwc2: host: Clear interrupts before handling them
Douglas Anderson [Fri, 20 Nov 2015 17:06:28 +0000 (09:06 -0800)]
UPSTREAM: usb: dwc2: host: Clear interrupts before handling them

In general it is wise to clear interrupts before processing them.  If
you don't do that, you can get:
 1. Interrupt happens
 2. You look at system state and process interrupt
 3. A new interrupt happens
 4. You clear interrupt without processing it.

This patch was actually a first attempt to fix missing device insertions
as described in (usb: dwc2: host: Fix missing device insertions) and it
did solve some of the signal bouncing problems but not all of
them (which is why I submitted the other patch).  Specifically, this
patch itself would sometimes change:
 1. hardware sees connect
 2. hardware sees disconnect
 3. hardware sees connect
 4. dwc2_port_intr() - clears connect interrupt
 5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()

...to:
 1. hardware sees connect
 2. hardware sees disconnect
 3. dwc2_port_intr() - clears connect interrupt
 4. hardware sees connect
 5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()

...but with different timing then sometimes we'd still miss cable
insertions.

In any case, though this patch doesn't fix any (known) problems, it
still seems wise as a general policy to clear interrupt before handling
them.

Note that for dwc2_handle_usb_port_intr(), instead of moving the clear
of PRTINT to the beginning of the function we remove it completely.  The
only way to clear PRTINT is to clear the sources that set it in the
first place.

Change-Id: I94b427aa819f477930287c8c3e85d14e80891f86
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 29539019b46f0e5f64f80f2e9dc8f9bb34d16b4b)

7 years agoUPSTREAM: usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func()
Douglas Anderson [Fri, 20 Nov 2015 17:06:27 +0000 (09:06 -0800)]
UPSTREAM: usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func()

The dwc2_hcd_reset_func() function is only ever called directly by a
delayed work function.  As such no locks are already held when the
function is called.

Doing a read-modify-write of CPU registers and setting fields in the
main hsotg data structure is a bad idea without locks.  Let's add
locks.

The bug was found by code inspection only.  It turns out that the
dwc2_hcd_reset_func() is only ever called today if the
"host_support_fs_ls_low_power" parameter is enabled and no code in
mainline enables that parameter.  Thus no known issues in mainline are
fixed by this patch, but it's still probably wise to fix the function.

Change-Id: I14ff93f64f1fd405d4911d67c7d0b20e50be4f53
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 4a065c7bdbec9536f7b899241b125b9c3b5ba97a)

7 years agoUPSTREAM: usb: dwc2: host: Support immediate retries for split transactions
Douglas Anderson [Wed, 11 Nov 2015 18:33:52 +0000 (10:33 -0800)]
UPSTREAM: usb: dwc2: host: Support immediate retries for split transactions

In some cases, like when you've got a "Microsoft Wireless Keyboard 2000"
connected to dwc2 with a hub, expected that we'll get some transfer
errors sometimes.  The controller is expected to try at least 3 times
before giving up.  See figure "Figure A-67. Normal HS CSPLIT 3 Strikes
Smash" in the USB spec.

The dwc2 controller has a way to support this by using the "EC_MC"
field.  The Raspberry Pi driver has logic for setting this right.  See
fiq_fsm_queue_split_transaction() in their "dwc_otg_hcd.c".  Let's use
the same logic.

After making this change, we no longer get dropped characters from the
above mentioned keyboard.  Other devices on the same bus as the keyboard
also behave more properly.

Thanks for Julius Werner for the expert analysis and suggestions.

Change-Id: I2351f95a0c6db1ca24c54edce574c42e073b7211
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 69b76cdff592058ea445cd40e18c75dffaba4cb9)

7 years agoUPSTREAM: usb: dwc2: host: Fix missing device insertions
Douglas Anderson [Thu, 19 Nov 2015 21:23:14 +0000 (13:23 -0800)]
UPSTREAM: usb: dwc2: host: Fix missing device insertions

If you've got your interrupt signals bouncing a bit as you insert your
USB device, you might end up in a state when the device is connected but
the driver doesn't know it.

Specifically, the observed order is:
 1. hardware sees connect
 2. hardware sees disconnect
 3. hardware sees connect
 4. dwc2_port_intr() - clears connect interrupt
 5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()

Now you'll be stuck with the cable plugged in and no further interrupts
coming in but the driver will think we're disconnected.

We'll fix this by checking for the missing connect interrupt and
re-connecting after the disconnect is posted.  We don't skip the
disconnect because if there is a transitory disconnect we really want to
de-enumerate and re-enumerate.

Notes:
1. As part of this change we add a "force" parameter to
   dwc2_hcd_disconnect() so that when we're unloading the module we
   avoid the new behavior.  The need for this was pointed out by John
   Youn.
2. The bit of code needed at the end of dwc2_hcd_disconnect() is
   exactly the same bit of code from dwc2_port_intr().  To avoid
   duplication, we refactor that code out into a new function
   dwc2_hcd_connect().

Change-Id: Ibe9c7d62b2b35f5666ffcde75a65e7fca9f6805a
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: John Youn <johnyoun@synopsys.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 6a6595318ac2dd169d2931a1d9431a64f4ada75c)

7 years agoUPSTREAM: usb: dwc2: add support of hi6220
Zhangfei Gao [Wed, 18 Nov 2015 07:39:47 +0000 (15:39 +0800)]
UPSTREAM: usb: dwc2: add support of hi6220

Support hisilicon,hi6220-usb for HiKey board

Change-Id: Ib3ca531022f812851566b11fc2174be57eb1d02b
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 37dd9d65cc41fcc7e77645a1cdf2659472809b96)

7 years agoUPSTREAM: usb: dwc2: host: use kmem cache to allocate descriptors
Gregory Herrero [Fri, 20 Nov 2015 10:49:31 +0000 (11:49 +0100)]
UPSTREAM: usb: dwc2: host: use kmem cache to allocate descriptors

Kmem caches help to get correct boundary for descriptor buffers
which need to be 512 bytes aligned for dwc2 controller.
Two kmem caches are needed for generic descriptors and for
hs isochronous descriptors which doesn't have same size.

Change-Id: Ic5af8b3871a32d51942aad35e0968ddbd803a73e
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3b5fcc9ac2f4453a5609cc89ac7618b1b27ccb01)

7 years agoUPSTREAM: usb: dwc2: host: fix descriptor list address masking
Mian Yousaf Kaukab [Fri, 20 Nov 2015 10:49:30 +0000 (11:49 +0100)]
UPSTREAM: usb: dwc2: host: fix descriptor list address masking

Masks for HCDMA.CTD and HCDMA.DMAAddr are incorrect. As we always
start from first descriptor, no need to mask the address anyway.

Change-Id: Iaeb063357dc4ffa905a9e1081793648ce1153d59
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit e23b8a54a440a2b8ee5c9dc3eb2099ecf813ef70)

7 years agoUPSTREAM: usb: dwc2: host: avoid usage of dma_alloc_coherent with irqs disabled
Gregory Herrero [Fri, 20 Nov 2015 10:49:29 +0000 (11:49 +0100)]
UPSTREAM: usb: dwc2: host: avoid usage of dma_alloc_coherent with irqs disabled

Use Streaming DMA mappings to handle cache coherency of frame list and
descriptor list. Cache are always flushed before controller access it
or before cpu access it.

Change-Id: I369dfb990bcef4aa0cb16b00539011bcab9732df
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 95105a998dff0747327f11708ea24480ee0eca54)

7 years agoUPSTREAM: usb: dwc2: host: enable descriptor dma for fs devices
Mian Yousaf Kaukab [Fri, 20 Nov 2015 10:49:28 +0000 (11:49 +0100)]
UPSTREAM: usb: dwc2: host: enable descriptor dma for fs devices

As descriptor dma mode does not support split transfers, it can't be
enabled for high speed devices. Add a core parameter to enable it for
full speed devices.

Ensure frame list and descriptor list are correctly freed during
disconnect.

Change-Id: I3793f7d00d5c791469daa1e4eb39bfff7a2a5c65
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit fbb9e22b15ad3c9a98c66bad801b4d1366e8bf20)

7 years agoUPSTREAM: usb: dwc2: host: process all completed urbs
Gregory Herrero [Thu, 5 Nov 2015 08:41:45 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: process all completed urbs

Process all completed urbs, if more urbs are complete by the time
driver processes completion interrupt.

Change-Id: I04813bea1208637824e1bfb36ab43fd939763324
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 762d3a1a9cd7438a8453e005ee5b2bab3203d9c3)

7 years agoUPSTREAM: usb: dwc2: host: always increment available host channel during release
Gregory Herrero [Thu, 5 Nov 2015 08:41:44 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: always increment available host channel during release

When releasing a channel, increment hsotg->available_host_channels even
in case a periodic channel is released.

Change-Id: I436f6b2db2a823e3479e7f1cd0a8c97ee498a64b
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3f808bdae75eaf464b1b2710894950772a3784f8)

7 years agoUPSTREAM: usb: dwc2: host: program descriptor for next frame
Gregory Herrero [Thu, 5 Nov 2015 08:41:43 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: program descriptor for next frame

Isochronous descriptor is currently programmed for the frame
after the last descriptor was programmed.

If the last descriptor frame underrun, then current descriptor must
take this into account and must be programmed on the current frame + 1.
This overrun usually happens when system is loaded and dwc2 can't init
descriptor list in time.

Change-Id: Ic1a50ef6c3325cbf171cc370e43569c8a3b7bd69
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit c17b337c1ea4c681595531912585a94f4bd7f8e7)

7 years agoUPSTREAM: usb: dwc2: host: add function to compare frame index
Gregory Herrero [Thu, 5 Nov 2015 08:41:42 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: add function to compare frame index

This function allow comparing frame index used for
descriptor list which has 64 entries.

Change-Id: I72ac09aff8a8ca14d52d56c07f582df993a67c32
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit b9392d9920fdce50abbe4af758cd1a24b922c81c)

7 years agoUPSTREAM: usb: dwc2: host: spinlock release channel
Gregory Herrero [Thu, 5 Nov 2015 08:41:41 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: spinlock release channel

Prevent dwc2 driver from accessing channel while it frees it.

Change-Id: Ia3c1593d84f3bb164ca165c1f35e574fd6afbb8b
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 2b046bc5aaefd4aba7195e6a73afe14f7f786692)

7 years agoUPSTREAM: usb: dwc2: host: fix use of qtd after free in desc dma mode
Gregory Herrero [Thu, 5 Nov 2015 08:41:40 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: fix use of qtd after free in desc dma mode

When completing non isoc xfer, dwc2_complete_non_isoc_xfer_ddma()
is relying on qtd->n_desc to process the corresponding number of
descriptors.

During the processing of these descriptors, qtd could be unlinked
and freed if xfer is done and urb is no more in progress.

In this case, dwc2_complete_non_isoc_xfer_ddma() will read again
qtd->n_desc whereas qtd has been freed. This will lead to unpredictable
results since qtd->n_desc is no more valid value.

To avoid this error, return a result != 0 in dwc2_process_non_isoc_desc(),
so that dwc2_complete_non_isoc_xfer_ddma() stops desc processing.

This has been seen with Slub debug enabled.

Change-Id: I375ddf56fbf4b4e19610d24891491868872d0e84
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 26a19ea699060fded98257e65b0ae5272a5ea1da)

7 years agoUPSTREAM: usb: dwc2: host: rework isochronous halt path
Gregory Herrero [Thu, 5 Nov 2015 08:41:39 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: rework isochronous halt path

When a channel is halted because of urb dequeue during transfer
completion, no other qtds must be scheduled until halt is done.
Moreover, all in progress qtds must be given back.

Change-Id: I87d6a92372046f34fd66713db75690b4a096fc66
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit c503b38153852d88774b54ae17f7723f68c6dc33)

7 years agoUPSTREAM: usb: dwc2: host: set active bit in isochronous descriptors
Gregory Herrero [Thu, 5 Nov 2015 08:41:38 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: set active bit in isochronous descriptors

Active bit must be enabled in all scheduled descriptors. Else transfer
never start.
Remove previous code which was not correctly configuring descriptors.
Active bit was set before calling dwc2_fill_host_isoc_dma_desc() which
is erasing dma_desc->status.

Change-Id: Ifee640205fc2af53c2f7859153209cb5de289988
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit dde4c1bf5df0f852e497e5644d3578885b969fdb)

7 years agoUPSTREAM: usb: dwc2: host: ensure filling of isoc desc is correctly done
Gregory Herrero [Thu, 5 Nov 2015 08:41:37 +0000 (09:41 +0100)]
UPSTREAM: usb: dwc2: host: ensure filling of isoc desc is correctly done

Increment qtd->isoc_frame_index_last before testing it, else below
check will never be true and IOC (Interrupt On Complete) bit for
last frame will never be set in descriptor status.

  /* Set IOC for each descriptor corresponding to last frame of URB */
  if (qtd->isoc_frame_index_last == qtd->urb->packet_count)
dma_desc->status |= HOST_DMA_IOC;

Change-Id: Ie4d30f20a3990d16cb27d0e137bb693fd7426376
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3ac38d260fa5dc8ec26ee5b6f5330d726ec00065)

7 years agoRevert "UPSTREAM: usb: dwc2: host: Always add to the tail of queuesa"
Jacob Chen [Thu, 3 Nov 2016 07:50:13 +0000 (15:50 +0800)]
Revert "UPSTREAM: usb: dwc2: host: Always add to the tail of queuesa"

This reverts commit abda71220e727633ad5dd404e0e09f04f0eb2d1b.

Change-Id: I71b3064a6a9439ab7b3893dcd20b8df4c4fad742
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoarm64: rockchip_defconfig: add NVMe support
Shawn Lin [Tue, 3 Jan 2017 09:11:26 +0000 (17:11 +0800)]
arm64: rockchip_defconfig: add NVMe support

Change-Id: Ib943c7ee92fb18444fd8c69440a0ae4cf29f00f0
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
7 years agopower_supply: bq25700: add dual type-c charge
Shunqing Chen [Thu, 15 Dec 2016 12:27:16 +0000 (20:27 +0800)]
power_supply: bq25700: add dual type-c charge

Change-Id: I97e4962229ed337752134aaf31b3f3e75b113440
Signed-off-by: Shunqing Chen <csq@rock-chips.com>
7 years agoFROMLIST: PCI: rockchip: Add system PM support
Shawn Lin [Tue, 3 Jan 2017 07:35:28 +0000 (15:35 +0800)]
FROMLIST: PCI: rockchip: Add system PM support

This patch adds system PM support for Rockchip's RC.
For pre S3, the EP is configured into D3 state which guarantees
the link state should be in L1. So we could send PME_Turn_Off message
to the EP and wait for its ACK to make the link state into L2 or L3
without the aux-supply. This could help save more power which I think
should be very important for mobile devices.

As note that there is a 5s timeout for RC to wait for the PMA_ACK
aftering send PME_Turn_Off. Technically it should depends on the
hierarchy of devices but seems PCIe core framework doesn't handle the
L2/3 for S3 at all. So that means we should presume to set a default
value for PME_ACK. From the bug report[1], we could find a statement that
Microsoft Windows versions typically wait for 5 seconds. So we are prone
to take 5s for this timeout here.

Change-Id: I3500911daaad07dfd632cda0f2f4b62cfc2909a2
[1] https://lists.launchpad.net/kernel-packages/msg123315.html
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
(cherry picked from https://patchwork.kernel.org/patch/9470515/)

7 years agodt-bindings: iommu: Add clock and pd for rockchip iommu
Simon [Mon, 19 Dec 2016 12:24:02 +0000 (20:24 +0800)]
dt-bindings: iommu: Add clock and pd for rockchip iommu

Change-Id: I7762dc71253aed0f5e06c0bf66e0bd668b3b4821
Signed-off-by: Simon <xxm@rock-chips.com>
7 years agoiommu/rockchip: Add pd/clk operation in iommu
Simon [Fri, 16 Dec 2016 03:48:06 +0000 (11:48 +0800)]
iommu/rockchip: Add pd/clk operation in iommu

Rk iommus share pd and clk with their masters, to make iommus independent,
iommus need to manage pd and clk by using pm_runtime_get_sync API who is
not atomic save, might lead to sleep, we change the spin lock to mutex to
satisfy the pm_runtime_get_sync, callers of rk_iommu_attach_device
and rk_iommu_map should guarantee not in a atomic path.

Change-Id: Icbe175030d36572e19740d23eae94f49fe59eb10
Signed-off-by: Simon <xxm@rock-chips.com>
7 years agousb: xhci-plat: check hcc_params after add hcd
William Wu [Fri, 30 Dec 2016 11:45:49 +0000 (19:45 +0800)]
usb: xhci-plat: check hcc_params after add hcd

The commit 4ac53087d6d4 ("usb: xhci: plat: Create both
HCDs before adding them") move add hcd to the end of
probe, this cause hcc_params uninitiated, because xHCI
driver sets hcc_params in xhci_gen_setup() called from
usb_add_hcd().

This patch checks the Maximum Primary Stream Array Size
in the hcc_params register after add hcd.

Change-Id: I5a05ca6a8ac25e914752914abb70612849cc175e
Signed-off-by: William Wu <wulf@rock-chips.com>
7 years agoUPSTREAM: PCI: rockchip: move the deassert of pm/aclk/pclk after phy_init
Shawn Lin [Thu, 24 Nov 2016 01:54:21 +0000 (09:54 +0800)]
UPSTREAM: PCI: rockchip: move the deassert of pm/aclk/pclk after phy_init

Move them after phy_init as we want to optimize the logic
of reset control and reuse rockchip_pcie_init_port later
which should fully follow the cold boot procedure of ROM
code.

Change-Id: I0a826a6de91a7c413e42e36ea5ceea5007ee7b73
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
(cherry picked from 0722bdd2962a4a0f6d5e8973b0d274d147adacfb)

7 years agoUPSTREAM: PCI: rockchip: split out rockchip_cfg_atu
Shawn Lin [Thu, 24 Nov 2016 01:54:20 +0000 (09:54 +0800)]
UPSTREAM: PCI: rockchip: split out rockchip_cfg_atu

We split out a new function, rockchip_cfg_atu, in order to
re-configure the atu when missing these information after
wakeup from S3.

Change-Id: I515b1bc5b8bc9be17b5d9858e17a05835d2fd144
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
(cherry picked from 9e663d3f11ee34dfe92dcea98992151cae55e1ea)

7 years agoarm64: dts: rockchip: add PCIe stuff for rk3399-tve1205g
Shawn Lin [Tue, 27 Dec 2016 07:20:23 +0000 (15:20 +0800)]
arm64: dts: rockchip: add PCIe stuff for rk3399-tve1205g

Add PCIe dt-bindings for rk3399-tve1205g and keep them as
disabled status currently.

Change-Id: Ie92c6e330a6588ff88d69306674429d69b971b58
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
7 years agovideo/rockchip: rga2 can be used dma coherent
Zikim,Wei [Fri, 23 Dec 2016 12:20:51 +0000 (20:20 +0800)]
video/rockchip: rga2 can be used dma coherent

Change-Id: I123bec313212ae2a9682e1d6f219a2f705c25187
Signed-off-by: Zikim,Wei <wzq@rock-chips.com>
7 years agodrm/rockchip: add mm dump debugfs
Mark Yao [Tue, 3 Jan 2017 03:50:55 +0000 (11:50 +0800)]
drm/rockchip: add mm dump debugfs

shell# cat /sys/kernel/debug/dri/0/mm_dump

0x0000000000000000-0x00000000000a6000: 679936: free
0x00000000000a6000-0x0000000000970000: 9216000: used
0x0000000000970000-0x000000000123a000: 9216000: used
0x000000000123a000-0x0000000001b04000: 9216000: used
0x0000000001b04000-0x00000000023ce000: 9216000: used
0x00000000023ce000-0x0000000002c98000: 9216000: used
0x0000000002c98000-0x0000000003562000: 9216000: used
0x0000000003562000-0x0000000003e2c000: 9216000: used
0x0000000003e2c000-0x0000000100000000: 4229775360: free
total: 4294967296, used 64512000 free 4230455296

Change-Id: I39cb5b12a63418c050b3bd890829f831f898db4e
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: add drm summary debugfs node
Mark Yao [Fri, 30 Dec 2016 09:03:51 +0000 (17:03 +0800)]
drm/rockchip: add drm summary debugfs node

With the summary debug node, show current display status would be easier.

Using step:
shell# cat /sys/kernel/debug/dri/0/summary

vop name: ff900000.vop status=active
Display mode: 1200x1920 fps[60] clk[160000] type[8] flag[a]
        H: 1200 1320 1340 1361
        V: 1920 1941 1944 1962
win0-0: status=active
        format: AB24 little-endian (0x34324241)
        zpos: 0
        src: pos[0x0] rect[1200x1920]
        dst: pos[0x0] rect[1200x1920]
        buf[0]: addr: 0x9e19000 pitch: 4800 offset: 0
win1-0: status=disabled
win2-0: status=disabled
win2-0: status=disabled
win2-1: status=disabled
win2-2: status=disabled
win3-0: status=disabled
win3-0: status=disabled
win3-1: status=disabled
win3-2: status=disabled
vop name: ff8f0000.vop status=disabled

Change-Id: I386398b0617f0c18902c4cadad5906be343cc4de
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agovideo: rockchip: dp: modify the function names for fb-based dp driver.
wenping.zhang [Tue, 3 Jan 2017 05:48:48 +0000 (13:48 +0800)]
video: rockchip: dp: modify the function names for fb-based dp driver.

change the name of functions for fb-based dp driver in order to fix
the compile errors of drm-based dp driver.

Change-Id: I6544c82d81bf4d8e5a7b936c7959349765d55049
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
7 years agoARM64: dts: rk3399: sapphire-excavator enabled pcie audio ir
wuliangqing [Fri, 16 Dec 2016 03:12:41 +0000 (11:12 +0800)]
ARM64: dts: rk3399: sapphire-excavator enabled pcie audio ir

Change-Id: Idba0460db911d45a2b546bfa6aabf2a4f8ca7dcd
Signed-off-by: Wu Liangqing <wlq@rock-chips.com>
7 years agoUPSTREAM: drm/mm: avoid possible null pointer dereference
Heinrich Schuchardt [Wed, 18 May 2016 20:17:19 +0000 (22:17 +0200)]
UPSTREAM: drm/mm: avoid possible null pointer dereference

Do not dereference node before the check if node is NULL.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1463602639-4861-1-git-send-email-xypron.glpk@gmx.de
(cherry picked from commit b80d3942329dcd43580adc3f7c0a098515b5feec)

Change-Id: I672ce10214e1268a043e6a11268ff400024cc883
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm/rockchip: Finish initialization before registering DRM device
Tomasz Figa [Tue, 21 Jun 2016 04:27:34 +0000 (13:27 +0900)]
UPSTREAM: drm/rockchip: Finish initialization before registering DRM device

Currently the driver calls drm_dev_register() directly after allocating
the DRM device and then continues with further initialization. This is
incorrect, because drm_dev_register() is supposed to be called after all
initialization is done. This problem was masked by the fact that
drm_dev_register() did not use to do anything special before, but
recently it started to call drm_connector_register_all(), which leads to
a crash if the driver is not fully initialized.

This patch fixes the problem by moving the call to drm_dev_register() to
the end of the initialization sequence and also removing the, now
unnecessary, call to drm_connector_register_all() from driver code.

Fixes: f706974a69b6 ("drm/rockchip: Drop drm_driver.load/unload callbacks")
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
[danvet: Fix up cleanup labels a bit.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466483254-35373-1-git-send-email-tfiga@chromium.org
(cherry picked from commit 9127f99c4801f323ffbb3b755259f3a679f66c7c)

Change-Id: Ie6d56242507c413db5e1b93e587d89a3a2200db6
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm/rockchip: Drop drm_driver.load/unload callbacks
Tomeu Vizoso [Fri, 10 Jun 2016 11:14:13 +0000 (13:14 +0200)]
UPSTREAM: drm/rockchip: Drop drm_driver.load/unload callbacks

They are deprecated and by moving their implementations to bind/unbind
we can call drm_connector_register_all instead of open-coding it.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1465557253-10670-1-git-send-email-tomeu.vizoso@collabora.com
(cherry picked from commit f706974a69b6e2be8f69fb4dc89158a6297338f9)

Change-Id: I9e97e25f1bf84609ba1dd7040478dee0686e665b
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Paper over locking inversion after registration rework
Daniel Vetter [Thu, 4 Aug 2016 16:35:48 +0000 (18:35 +0200)]
UPSTREAM: drm: Paper over locking inversion after registration rework

drm_connector_register_all requires a few too many locks because our
connector_list locking is busted. Add another FIXME+hack to work
around this. This should address the below lockdep splat:

======================================================
[ INFO: possible circular locking dependency detected ]
4.7.0-rc5+ #524 Tainted: G           O
-------------------------------------------------------
kworker/u8:0/6 is trying to acquire lock:
 (&dev->mode_config.mutex){+.+.+.}, at: [<ffffffff815afde0>] drm_modeset_lock_all+0x40/0x120

but task is already holding lock:
 ((fb_notifier_list).rwsem){++++.+}, at: [<ffffffff810ac195>] __blocking_notifier_call_chain+0x35/0x70

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #1 ((fb_notifier_list).rwsem){++++.+}:
       [<ffffffff810df611>] lock_acquire+0xb1/0x200
       [<ffffffff819a55b4>] down_write+0x44/0x80
       [<ffffffff810abf91>] blocking_notifier_chain_register+0x21/0xb0
       [<ffffffff814c7448>] fb_register_client+0x18/0x20
       [<ffffffff814c6c86>] backlight_device_register+0x136/0x260
       [<ffffffffa0127eb2>] intel_backlight_device_register+0xa2/0x160 [i915]
       [<ffffffffa00f46be>] intel_connector_register+0xe/0x10 [i915]
       [<ffffffffa0112bfb>] intel_dp_connector_register+0x1b/0x80 [i915]
       [<ffffffff8159dfea>] drm_connector_register+0x4a/0x80
       [<ffffffff8159fe44>] drm_connector_register_all+0x64/0xf0
       [<ffffffff815a2a64>] drm_modeset_register_all+0x174/0x1c0
       [<ffffffff81599b72>] drm_dev_register+0xc2/0xd0
       [<ffffffffa00621d7>] i915_driver_load+0x1547/0x2200 [i915]
       [<ffffffffa006d80f>] i915_pci_probe+0x4f/0x70 [i915]
       [<ffffffff814a2135>] local_pci_probe+0x45/0xa0
       [<ffffffff814a349b>] pci_device_probe+0xdb/0x130
       [<ffffffff815c07e3>] driver_probe_device+0x223/0x440
       [<ffffffff815c0ad5>] __driver_attach+0xd5/0x100
       [<ffffffff815be386>] bus_for_each_dev+0x66/0xa0
       [<ffffffff815c002e>] driver_attach+0x1e/0x20
       [<ffffffff815bf9be>] bus_add_driver+0x1ee/0x280
       [<ffffffff815c1810>] driver_register+0x60/0xe0
       [<ffffffff814a1a10>] __pci_register_driver+0x60/0x70
       [<ffffffffa01a905b>] i915_init+0x5b/0x62 [i915]
       [<ffffffff8100042d>] do_one_initcall+0x3d/0x150
       [<ffffffff811a935b>] do_init_module+0x5f/0x1d9
       [<ffffffff81124416>] load_module+0x20e6/0x27e0
       [<ffffffff81124d63>] SYSC_finit_module+0xc3/0xf0
       [<ffffffff81124dae>] SyS_finit_module+0xe/0x10
       [<ffffffff819a83a9>] entry_SYSCALL_64_fastpath+0x1c/0xac

-> #0 (&dev->mode_config.mutex){+.+.+.}:
       [<ffffffff810df0ac>] __lock_acquire+0x10fc/0x1260
       [<ffffffff810df611>] lock_acquire+0xb1/0x200
       [<ffffffff819a3097>] mutex_lock_nested+0x67/0x3c0
       [<ffffffff815afde0>] drm_modeset_lock_all+0x40/0x120
       [<ffffffff8158f79b>] drm_fb_helper_restore_fbdev_mode_unlocked+0x2b/0x80
       [<ffffffff8158f81d>] drm_fb_helper_set_par+0x2d/0x50
       [<ffffffffa0105f7a>] intel_fbdev_set_par+0x1a/0x60 [i915]
       [<ffffffff814c13c6>] fbcon_init+0x586/0x610
       [<ffffffff8154d16a>] visual_init+0xca/0x130
       [<ffffffff8154e611>] do_bind_con_driver+0x1c1/0x3a0
       [<ffffffff8154eaf6>] do_take_over_console+0x116/0x180
       [<ffffffff814bd3a7>] do_fbcon_takeover+0x57/0xb0
       [<ffffffff814c1e48>] fbcon_event_notify+0x658/0x750
       [<ffffffff810abcae>] notifier_call_chain+0x3e/0xb0
       [<ffffffff810ac1ad>] __blocking_notifier_call_chain+0x4d/0x70
       [<ffffffff810ac1e6>] blocking_notifier_call_chain+0x16/0x20
       [<ffffffff814c748b>] fb_notifier_call_chain+0x1b/0x20
       [<ffffffff814c86b1>] register_framebuffer+0x251/0x330
       [<ffffffff8158fa9f>] drm_fb_helper_initial_config+0x25f/0x3f0
       [<ffffffffa0106b48>] intel_fbdev_initial_config+0x18/0x30 [i915]
       [<ffffffff810adfd8>] async_run_entry_fn+0x48/0x150
       [<ffffffff810a3947>] process_one_work+0x1e7/0x750
       [<ffffffff810a3efb>] worker_thread+0x4b/0x4f0
       [<ffffffff810aad4f>] kthread+0xef/0x110
       [<ffffffff819a85ef>] ret_from_fork+0x1f/0x40

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((fb_notifier_list).rwsem);
                               lock(&dev->mode_config.mutex);
                               lock((fb_notifier_list).rwsem);
  lock(&dev->mode_config.mutex);

 *** DEADLOCK ***

6 locks held by kworker/u8:0/6:
 #0:  ("events_unbound"){.+.+.+}, at: [<ffffffff810a38c9>] process_one_work+0x169/0x750
 #1:  ((&entry->work)){+.+.+.}, at: [<ffffffff810a38c9>] process_one_work+0x169/0x750
 #2:  (registration_lock){+.+.+.}, at: [<ffffffff814c8487>] register_framebuffer+0x27/0x330
 #3:  (console_lock){+.+.+.}, at: [<ffffffff814c86ce>] register_framebuffer+0x26e/0x330
 #4:  (&fb_info->lock){+.+.+.}, at: [<ffffffff814c78dd>] lock_fb_info+0x1d/0x40
 #5:  ((fb_notifier_list).rwsem){++++.+}, at: [<ffffffff810ac195>] __blocking_notifier_call_chain+0x35/0x70

stack backtrace:
CPU: 2 PID: 6 Comm: kworker/u8:0 Tainted: G           O    4.7.0-rc5+ #524
Hardware name: Intel Corp. Broxton P/NOTEBOOK, BIOS APLKRVPA.X64.0138.B33.1606250842 06/25/2016
Workqueue: events_unbound async_run_entry_fn
 0000000000000000 ffff8800758577f0 ffffffff814507a5 ffffffff828b9900
 ffffffff828b9900 ffff880075857830 ffffffff810dc6fa ffff880075857880
 ffff88007584d688 0000000000000005 0000000000000006 ffff88007584d6b0
Call Trace:
 [<ffffffff814507a5>] dump_stack+0x67/0x92
 [<ffffffff810dc6fa>] print_circular_bug+0x1aa/0x200
 [<ffffffff810df0ac>] __lock_acquire+0x10fc/0x1260
 [<ffffffff810df611>] lock_acquire+0xb1/0x200
 [<ffffffff815afde0>] ? drm_modeset_lock_all+0x40/0x120
 [<ffffffff815afde0>] ? drm_modeset_lock_all+0x40/0x120
 [<ffffffff819a3097>] mutex_lock_nested+0x67/0x3c0
 [<ffffffff815afde0>] ? drm_modeset_lock_all+0x40/0x120
 [<ffffffff810fa85f>] ? rcu_read_lock_sched_held+0x7f/0x90
 [<ffffffff81208218>] ? kmem_cache_alloc_trace+0x248/0x2b0
 [<ffffffff815afdc5>] ? drm_modeset_lock_all+0x25/0x120
 [<ffffffff815afde0>] drm_modeset_lock_all+0x40/0x120
 [<ffffffff8158f79b>] drm_fb_helper_restore_fbdev_mode_unlocked+0x2b/0x80
 [<ffffffff8158f81d>] drm_fb_helper_set_par+0x2d/0x50
 [<ffffffffa0105f7a>] intel_fbdev_set_par+0x1a/0x60 [i915]
 [<ffffffff814c13c6>] fbcon_init+0x586/0x610
 [<ffffffff8154d16a>] visual_init+0xca/0x130
 [<ffffffff8154e611>] do_bind_con_driver+0x1c1/0x3a0
 [<ffffffff8154eaf6>] do_take_over_console+0x116/0x180
 [<ffffffff814bd3a7>] do_fbcon_takeover+0x57/0xb0
 [<ffffffff814c1e48>] fbcon_event_notify+0x658/0x750
 [<ffffffff810abcae>] notifier_call_chain+0x3e/0xb0
 [<ffffffff810ac1ad>] __blocking_notifier_call_chain+0x4d/0x70
 [<ffffffff810ac1e6>] blocking_notifier_call_chain+0x16/0x20
 [<ffffffff814c748b>] fb_notifier_call_chain+0x1b/0x20
 [<ffffffff814c86b1>] register_framebuffer+0x251/0x330
 [<ffffffff815b7e8d>] ? vga_switcheroo_client_fb_set+0x5d/0x70
 [<ffffffff8158fa9f>] drm_fb_helper_initial_config+0x25f/0x3f0
 [<ffffffffa0106b48>] intel_fbdev_initial_config+0x18/0x30 [i915]
 [<ffffffff810adfd8>] async_run_entry_fn+0x48/0x150
 [<ffffffff810a3947>] process_one_work+0x1e7/0x750
 [<ffffffff810a38c9>] ? process_one_work+0x169/0x750
 [<ffffffff810a3efb>] worker_thread+0x4b/0x4f0
 [<ffffffff810a3eb0>] ? process_one_work+0x750/0x750
 [<ffffffff810aad4f>] kthread+0xef/0x110
 [<ffffffff819a85ef>] ret_from_fork+0x1f/0x40
 [<ffffffff810aac60>] ? kthread_stop+0x2e0/0x2e0

v2: Rebase onto the right branch (hand-editing patches ftw) and add more
reporters.

Reported-by: Imre Deak <imre.deak@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Reported-by: Jiri Kosina <jikos@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 5c6c201ccbaf9d3901f829441d457293f7ca8ef4)

Change-Id: I24bc8426dafa81dc1f1de31aea527d75060ed68f
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Add callbacks for late registering
Benjamin Gaignard [Tue, 21 Jun 2016 14:37:09 +0000 (16:37 +0200)]
UPSTREAM: drm: Add callbacks for late registering

Like what has been done for connectors add callbacks on encoder,
crtc and plane to let driver do actions after drm device registration.

Correspondingly, add callbacks called before unregister drm device.

version 2:
add drm_modeset_register_all() and drm_modeset_unregister_all()
to centralize all calls

version 3:
in error case unwind registers in drm_modeset_register_all
fix uninitialed return value
inverse order of unregistration in drm_modeset_unregister_all

version 4:
move function definitions in drm_crtc_internal.h
remove not needed documentation

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466519829-4000-1-git-send-email-benjamin.gaignard@linaro.org
(cherry picked from commit 79190ea2658a93818791335aa99969ca779161c6)

Change-Id: I836e8ea62b46c0eae89cf8c70bcf3ea4e10068f5
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Protect drm_connector_register_all() under DRIVER_MODESET
Chris Wilson [Sat, 18 Jun 2016 13:46:41 +0000 (14:46 +0100)]
UPSTREAM: drm: Protect drm_connector_register_all() under DRIVER_MODESET

0-day kbuilder found

[    1.360244] BUG: unable to handle kernel NULL pointer dereference at   (null)
[    1.360972] IP: [<c14db9ad>] mutex_lock_nested+0x11f/0x2c3
[    1.361512] *pde = 00000000
[    1.361827] Oops: 0002 [#1]
[    1.362123] Modules linked in:
[    1.362451] CPU: 0 PID: 1 Comm: swapper Not tainted 4.7.0-rc2-00564-ge28cd4d #1
[    1.363202] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Debian-1.8.2-1 04/01/2014
[    1.364105] task: c03d0000 ti: d28da000 task.ti: d28da000
[    1.364636] EIP: 0060:[<c14db9ad>] EFLAGS: 00210096 CPU: 0
[    1.365215] EIP is at mutex_lock_nested+0x11f/0x2c3
[    1.365703] EAX: 00000000 EBX: d39e8ae8 ECX: d39e8b14 EDX: c1361cf9
[    1.366351] ESI: c03d0000 EDI: d28dbed0 EBP: d28dbeec ESP: d28dbec0
[    1.367010]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
[    1.367534] CR0: 80050033 CR2: 00000000 CR3: 019a9000 CR4: 00000690
[    1.368152] Stack:
[    1.368356]  d39e8b14 d39e8b24 c1361cf9 00200246 d39e8b14 00000000 11111111 d28dbed0
[    1.369235]  d39e8800 d39e8ae8 00000000 d28dbf08 c1361cf9 d28dbf0c c10b25be d39e8800
[    1.370087]  00000000 00000000 d28dbf1c c135e37d fffffff4 ffffffff 00000000 d28dbf28
[    1.371012] Call Trace:
[    1.371272]  [<c1361cf9>] ? drm_connector_register_all+0x1a/0x92
[    1.371847]  [<c1361cf9>] drm_connector_register_all+0x1a/0x92
[    1.372421]  [<c10b25be>] ? kstrdup+0x25/0x3a
[    1.372863]  [<c135e37d>] drm_dev_register+0x59/0x99
[    1.373358]  [<c195ea3e>] vgem_init+0x34/0x49
[    1.373770]  [<c195ea0a>] ? mipi_dsi_bus_init+0xf/0xf
[    1.374257]  [<c100048f>] do_one_initcall+0x7c/0xfd
[    1.374754]  [<c104b409>] ? parse_args+0x1fd/0x314
[    1.375259]  [<c1939c10>] ? kernel_init_freeable+0xd0/0x179
[    1.375837]  [<c1939c2c>] kernel_init_freeable+0xec/0x179
[    1.376371]  [<c14d66ea>] kernel_init+0x8/0xcb
[    1.376806]  [<c14debce>] ret_from_kernel_thread+0xe/0x30
[    1.377322]  [<c14d66e2>] ? rest_init+0x10e/0x10e
[    1.377754] Code: 89 fa e8 71 c5 b7 ff 8b 4e 04 89 fa 89 d8 e8 8e c6 b7 ff 8d 43 2c 89 45 d4 8b 43 30 8d 4b 2c 89 45 e8 89 7b 30 89 4d e4 8b 55 dc <89> 38 8d 43 3c 89 75 ec e8 c9 dd b7 ff eb 0c 31 c0 87 03 48
+75
[    1.380442] EIP: [<c14db9ad>] mutex_lock_nested+0x11f/0x2c3 SS:ESP 0068:d28dbec0
[    1.381174] CR2: 0000000000000000

when loading the non-modesetting vGEM module. To prevent use of the
uninitialised dev->mode_config from drm_dev_register() we move the
drm_connector_register_all() under a DRIVER_MODESET guard. Longer term,
we probably want to initialise the embedded dev->mode_config automatically
from drm_dev_init() for all DRIVER_MODESET drivers.

v2: Also protect drm_dev_unregister.

Fixes: e28cd4d0a223 ("drm: Automatically register/unregister all connectors")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Testcase: igt/vgem_reload_basic
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466257601-5656-1-git-send-email-chris@chris-wilson.co.uk
(cherry picked from commit bee7fb158f40c4ab27af352d5e9826ef2b9f4432)

Change-Id: I5387cd16d163573dcb14028be5234da12fb0cdab
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Automatically register/unregister all connectors
Chris Wilson [Fri, 17 Jun 2016 08:25:17 +0000 (09:25 +0100)]
UPSTREAM: drm: Automatically register/unregister all connectors

As the drm_connector is now safe for multiple calls to
register/unregister, automatically perform a registration on all known
connectors drm drv_register (and unregister from drm_drv_unregister).
Drivers can still call drm_connector_register() and
drm_connector_unregister() individually, or defer as required.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466151923-1572-2-git-send-email-chris@chris-wilson.co.uk
(cherry picked from commit e28cd4d0a223e1bcea616326e2281900e7e7e9a2)

Change-Id: I30a4e2e65a88e824597774f8c59671fcf4cd0384
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Introduce drm_connector_register_all() helper
Alexey Brodkin [Tue, 19 Apr 2016 12:24:51 +0000 (15:24 +0300)]
UPSTREAM: drm: Introduce drm_connector_register_all() helper

As a pair to already existing drm_connector_unregister_all() we're adding
generic implementation of what is already done in some drivers.

Once this helper is implemented we'll be ready to switch existing
driver-specific implementations with the generic one.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1461068693-11260-2-git-send-email-abrodkin@synopsys.com
(cherry-pick from commit 54d2c2da0946368b96b63e6daed7920f3681243e)

Change-Id: Ibfeeebe5d02b77b9a670f7c303417a8d20677376
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Rename drm_connector_unplug_all() to drm_connector_unregister_all()
Alexey Brodkin [Wed, 23 Mar 2016 08:42:54 +0000 (11:42 +0300)]
UPSTREAM: drm: Rename drm_connector_unplug_all() to drm_connector_unregister_all()

Current name is a bit misleading because what that helper function
really does it calls drm_connector_unregister() for all connectors.

This all has nothing to do with hotplugging so let's name things
properly.

And while at it remove potentially dangerous locking around
drm_connector_unregister() in rcar_du_remove() as mentioned
in kerneldoc for drm_connector_unregister_all().

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1458722577-20283-2-git-send-email-abrodkin@synopsys.com
(cherry-pick from commit 6c87e5c3ec6db052f3744804a517b6fb003906e1)

Change-Id: I42a56d8d2b8bef8f062ca9ecc478d0348e738ea7
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm: Add a callback from connector registering
Chris Wilson [Wed, 15 Jun 2016 12:17:47 +0000 (13:17 +0100)]
UPSTREAM: drm: Add a callback from connector registering

If a driver wants to more precisely control its initialisation and in
particular, defer registering its interfaces with userspace until after
everything is setup, it also needs to defer registering the connectors.
As some devices need more work during registration, add a callback so
that drivers can do additional work if required for a connector.

Correspondingly, we also require an unregister callback.

Cc: Dave Airlie <airlied@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
[danvet: go ocd and remvoe unecessary empty kerneldoc line.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1465993109-19523-3-git-send-email-chris@chris-wilson.co.uk
(cherry-pick from commit aaf285e2e0ff490e924dbcdfd08e8274c3093354)

Change-Id: Ifb7513fb7eea2293d0f3705c0c00923c5f7fde0c
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
7 years agoarm64: dts: rk3399: dual display for hdmi and dp
xubilv [Fri, 30 Dec 2016 11:29:40 +0000 (19:29 +0800)]
arm64: dts: rk3399: dual display for hdmi and dp

hdmi connect vopb and dp connect vopl

Change-Id: Ib6a4771ab86ebe5dbfc21d1401e6768bcac7d36b
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agoarm64: dts: rockchip: Add rk3399 box dts for drm
Zhangbin Tong [Thu, 29 Dec 2016 07:12:47 +0000 (15:12 +0800)]
arm64: dts: rockchip: Add rk3399 box dts for drm

Change-Id: I7a518826c7d6701dc68f2eb5cca629f82fb92365
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agoARM64: dts: rk3399: support for box rev2
Zhangbin Tong [Thu, 29 Dec 2016 06:35:08 +0000 (14:35 +0800)]
ARM64: dts: rk3399: support for box rev2

rk3399 box rev1 and rev2 use gpio control for enable/disable vdd_cpu_b
rev1 use GPIO1_C1(default pull-down), rev2 use GPIO_C2(default pull-up)

Change-Id: I9ddbcff688905386d2d52f680cbb5f93d6c8d526
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agoMALI: midgard: RK: manual define configs
Jacob Chen [Thu, 29 Dec 2016 04:56:59 +0000 (12:56 +0800)]
MALI: midgard: RK: manual define configs

otherwise it won't defined since we don't include it in kconfig

Change-Id: I6886068f89d53f3ecf47846ed7435131fdd7960f
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoarm: dts: correct cpu opp point for rk3288
Jacob Chen [Thu, 29 Dec 2016 03:31:38 +0000 (11:31 +0800)]
arm: dts: correct cpu opp point for rk3288

Change-Id: I7f0a6cfe68d91faee492ceac4fb2e02827205317
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoMALI: midgard: RK: add separate src dir of Midgard driver for RK Linux device
Jacob Chen [Thu, 29 Dec 2016 04:57:42 +0000 (12:57 +0800)]
MALI: midgard: RK: add separate src dir of Midgard driver for RK Linux device

The version of Midgard DDK used in RK Linux device is different from the one
used in Android platforms.
It might be convenient to have a separate src directory for it.

The new directory drivers/gpu/arm/midgard_for_linux is copied from
drivers/gpu/arm/midgard of commit 206f372ede.
It's on DDK r9p0-05rel0
There are also a few modifications in some 'Kbuild' files.

A new config MALI_MIDGARD_FOR_LINUX is introduced to specify which directory
of Midgard to use.
If defined, kbuild will compile src files under
drivers/gpu/arm/midgard_for_rk_linux_device,
otherwise, drivers/gpu/arm/midgard.

There is already a source directory of Midgard driver,
the 'Kconfig' file of the new directory is not be involved
in kconfig process.
Otherwise, there are problems caused by configs
with the same names in the two directories.
So, "midgard_for_rk_linux_device" could not be configured via menuconfig.

In the new directory, all the default configs are defined in default_config.mk.
'Kbuild' files include it.

Change-Id: I54f61cc50f7a168a742db7a11c6b6eebe21528f8
Signed-off-by: chenzhen <chenzhen@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoARM64: dts: rk3399-box: Use gpio control for enable/disable of syr82x buck
Zhangbin Tong [Tue, 27 Dec 2016 02:40:35 +0000 (10:40 +0800)]
ARM64: dts: rk3399-box: Use gpio control for enable/disable of syr82x buck

Change-Id: I9e03084c93ffff5d8ea79ed037656ce8d6615226
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agoARM64: dts: rk3399-tve1205g: retain battery led state in suspend
Zhou weixin [Wed, 28 Dec 2016 12:53:01 +0000 (20:53 +0800)]
ARM64: dts: rk3399-tve1205g: retain battery led state in suspend

Change-Id: Ie605d3d3e0275812f5a360bbcd533c8b954a9159
Signed-off-by: Zhou weixin <zwx@rock-chips.com>
7 years agoHID: i2c-hid: do not reset hid if device support wakeup when resume
Zhou weixin [Wed, 28 Dec 2016 06:28:54 +0000 (14:28 +0800)]
HID: i2c-hid: do not reset hid if device support wakeup when resume

The host will trigger the hid interrupt to after reset hid, then send
wakeup key to light up screen,so any wakeupirq source will light up
screen due to reset hid in resume, and hid hwreset is not necessary.

Change-Id: I920239eeb4b57b0f594cc67cb8f4c1649c5125bd
Signed-off-by: Zhou weixin <zwx@rock-chips.com>
7 years agoarm64: rockchip_cros_defconfig: enable cdn dp machine driver
Chris Zhong [Tue, 27 Dec 2016 13:04:14 +0000 (21:04 +0800)]
arm64: rockchip_cros_defconfig: enable cdn dp machine driver

Change-Id: Ia4755126ca13c8c389a498a0c87e66d6357888b6
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
7 years agoarm64: dts: rockchip: enable cdn dp machine driver for rk3399-evb-cros
Chris Zhong [Tue, 27 Dec 2016 13:05:16 +0000 (21:05 +0800)]
arm64: dts: rockchip: enable cdn dp machine driver for rk3399-evb-cros

Change-Id: I97bebe09b83d5a3d9a964cf7dbaf63dbb11daffb
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
7 years agoASoC: rockchip: Add machine driver for cdn DP
Chris Zhong [Fri, 25 Nov 2016 05:18:07 +0000 (13:18 +0800)]
ASoC: rockchip: Add machine driver for cdn DP

Change-Id: Id5fe7eee2bf1e73103d71f61a2b98aeaf0ea48b1
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
7 years agovideo: rockchip: mipi-dsi: Dynamic allocation command buf size
Xubilv [Tue, 27 Dec 2016 07:34:55 +0000 (15:34 +0800)]
video: rockchip: mipi-dsi: Dynamic allocation command buf size

Change-Id: Ieb2ce472dc137ecf83f588e68b5e747dcbca3a20
Signed-off-by: Xubilv <xbl@rock-chips.com>
7 years agoion: reorder pages for scatterlist
Simon [Fri, 23 Dec 2016 10:07:30 +0000 (18:07 +0800)]
ion: reorder pages for scatterlist

Change-Id: I3a25eba9d65ac1345471321f61ae9d7a959a1be6
Signed-off-by: Simon <xxm@rock-chips.com>
7 years agoinput: touchscreen: fix tp gslx680 irq number bug
wlq [Tue, 27 Dec 2016 07:36:21 +0000 (15:36 +0800)]
input: touchscreen: fix tp gslx680 irq number bug

Change-Id: Ic0addb0064dea5ef86741119557fd4945d1aed13
Signed-off-by: Wu Liangqing <wlq@rock-chips.com>
7 years agovideo: hdmi: remove unuse dp timing for Rk3399 disvr
wjh [Tue, 27 Dec 2016 07:37:43 +0000 (15:37 +0800)]
video: hdmi: remove unuse dp timing for Rk3399 disvr

Change-Id: I783b4b7b3cdfad321b8c5bed2ce9b80fecbb3688
Signed-off-by: wjh <wjh@rock-chips.com>
7 years agophy: rockchip-inno-usb2: select USB_COMMON
Arnd Bergmann [Wed, 16 Nov 2016 14:22:39 +0000 (15:22 +0100)]
phy: rockchip-inno-usb2: select USB_COMMON

When USB is disabled, we get a link error for this driver
because of the added OTG support

drivers/phy/phy-rockchip-inno-usb2.o: In function `rockchip_usb2phy_otg_sm_work':
phy-rockchip-inno-usb2.c:(.text.rockchip_usb2phy_otg_sm_work+0x1f4): undefined reference to `usb_otg_state_string'
drivers/phy/phy-rockchip-inno-usb2.o: In function `rockchip_usb2phy_probe':
phy-rockchip-inno-usb2.c:(.text.rockchip_usb2phy_probe+0x2c8): undefined reference to `of_usb_get_dr_mode_by_phy'

Other phy drivers select USB_COMMON for this, so let's do the same
here.

Change-Id: I088b5862157d35360a30f21c8ed56a2a85792d53
Fixes: 0c42fe48fd23 ("phy: rockchip-inno-usb2: support otg-port for rk3399")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: William Wu <wulf@rock-chips.com>
7 years agophy: rockchip-inno-usb2: add COMMON_CLK dependency
Frank Wang [Tue, 16 Aug 2016 06:13:42 +0000 (14:13 +0800)]
phy: rockchip-inno-usb2: add COMMON_CLK dependency

On kernel builds without COMMON_CLK, the newly added rockchip-inno-usb2
driver fails to build:

drivers/phy/phy-rockchip-inno-usb2.c:124:16: error: field 'clk480m_hw'
has incomplete type
   struct clk_hw clk480m_hw;

In file included from include/linux/clk.h:16:0
                 from drivers/phy/phy-rockchip-inno-usb2.c:17:
include/linux/kernel.h:831:48: error: initialization from incompatible
pointer type [-Werror=incompatible-pointer-types]
   const typeof( ((type *)0)->member ) *__mptr = (ptr); \

  ... ...

Change-Id: I951d89ee34625dea5dfc6eeca841f9a5c44bc951
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: William Wu <wulf@rock-chips.com>
7 years agophy: rockchip-inno-usb2: correct 480MHz output clock stable time
William Wu [Tue, 15 Nov 2016 03:54:07 +0000 (11:54 +0800)]
phy: rockchip-inno-usb2: correct 480MHz output clock stable time

We found that the system crashed due to 480MHz output clock of
USB2 PHY was unstable after clock had been enabled by gpu module.

Theoretically, 1 millisecond is a critical value for 480MHz
output clock stable time, so we try to change the delay time
to 1.2 millisecond to avoid this issue.

And the commit ed907fb1d7c3 ("phy: rockchip-inno-usb2: correct
clk_ops callback") used prepare callbacks instead of enable
callbacks to support gate a clk if the operation may sleep. So
we can switch from delay to sleep functions.

Also fix a spelling error from "waitting" to "waiting".

Change-Id: Ie9883e5e9a3f0c2edec9d259b844ca536348c9cf
Signed-off-by: William Wu <wulf@rock-chips.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: rockchip-inno-usb2: correct clk_ops callback
William Wu [Tue, 15 Nov 2016 03:54:06 +0000 (11:54 +0800)]
phy: rockchip-inno-usb2: correct clk_ops callback

Since we needs to delay ~1ms to wait for 480MHz output clock
of USB2 PHY to become stable after turn on it, the delay time
is pretty long for something that's supposed to be "atomic"
like a clk_enable(). Consider that clk_enable() will disable
interrupt and that a 1ms interrupt latency is not sensible.

The 480MHz output clock should be handled in prepare callbacks
which support gate a clk if the operation may sleep.

Change-Id: I943e17f8a97d1229fefd8c1ada706e0c450c98eb
Signed-off-by: William Wu <wulf@rock-chips.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoarm64: configs: add vpu related config for rk3399 linux
WeiYong Bi [Tue, 20 Dec 2016 06:54:36 +0000 (14:54 +0800)]
arm64: configs: add vpu related config for rk3399 linux

Change-Id: I599940d16b7e3f9777221f31d1bca4f9e4e206e4
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agonet: rkwifi: enable CONFIG_BCMDHD_AG=y by default
huweiguo [Mon, 26 Dec 2016 06:25:12 +0000 (14:25 +0800)]
net: rkwifi: enable CONFIG_BCMDHD_AG=y by default

Change-Id: Ibe8c13252a134672f4cdaa1c62d82092378b2eb5
Signed-off-by: huweiguo <hwg@rock-chips.com>
7 years agoARM: dts: rk3288: use operating-points-v2
Finley Xiao [Mon, 26 Dec 2016 06:10:28 +0000 (14:10 +0800)]
ARM: dts: rk3288: use operating-points-v2

Change-Id: I3cb938fbfaf0ae5957d4832f4ad5671ab9631409
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agovideo/rockchip: fix rga2 get version from reg
Zikim,Wei [Thu, 22 Dec 2016 07:15:34 +0000 (15:15 +0800)]
video/rockchip: fix rga2 get version from reg

Change-Id: Ia960791f8346a132389cb7f43f0f7ff801465abc
Signed-off-by: Zikim,Wei <wzq@rock-chips.com>
7 years agoarm64: dts: rk3399-tve1205g: deploy audio configurations
zhangjun [Tue, 20 Dec 2016 01:44:32 +0000 (09:44 +0800)]
arm64: dts: rk3399-tve1205g: deploy audio configurations

Change-Id: I41ebc8a11c74536ed51720c07fbfe1817342907d
Signed-off-by: zhangjun <zhangjun@rock-chips.com>
7 years agoarm64: dts: rockchip: add usb camera pd pin control for rk3399-tve1205g
Bin Yang [Thu, 15 Dec 2016 10:47:50 +0000 (18:47 +0800)]
arm64: dts: rockchip: add usb camera pd pin control for rk3399-tve1205g

Change-Id: Iee039f3085832861dee5a99da2cbbbec2a08f509
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
7 years agoarm64: rockchip_defconfig: add usb camera pd pin control support
Bin Yang [Thu, 15 Dec 2016 10:39:41 +0000 (18:39 +0800)]
arm64: rockchip_defconfig: add usb camera pd pin control support

Change-Id: If7542a913eab0e36c586005d5bcfbb2b9cabb5d7
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
7 years agomisc: add usb camera pd pin control driver
Bin Yang [Thu, 15 Dec 2016 10:29:07 +0000 (18:29 +0800)]
misc: add usb camera pd pin control driver

Change-Id: Id6ad835c2fff43167a52f90c19e7e6dfe93a4655
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
7 years agoASoC: rockchip: i2s: add support for i2s bclk fs configuration
Sugar Zhang [Mon, 26 Dec 2016 06:11:45 +0000 (14:11 +0800)]
ASoC: rockchip: i2s: add support for i2s bclk fs configuration

this patch add support for i2s bclk fs configuration, we can
configure bclk_fs by devicetree as required.

Change-Id: I7e034e0466793b5b9eab6566a43e90213f219bb0
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
7 years agovideo: rockchip: dp: fix dp connected issue which caused by hpd signal.
wenping.zhang [Mon, 26 Dec 2016 02:04:14 +0000 (10:04 +0800)]
video: rockchip: dp: fix dp connected issue which caused by hpd signal.

some device will triggered hpd after dp is connected, so we don't do
traning if dp lanes is not changed.

Change-Id: I3e329e7d2db33138f283ad6584b966ebd0619f65
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
7 years agousb: dwc3: rockchip: support to set testmodes via debugfs
William Wu [Thu, 22 Dec 2016 06:58:39 +0000 (14:58 +0800)]
usb: dwc3: rockchip: support to set testmodes via debugfs

This patch create host_testmode file in debugfs for
USB HOST. It's useful for us to use a scope to verify
signal integrity for USB2/USB3 HOST.

For example, set testmodes for RK3399 board USB:
1. set Test packet for Type-C0 USB2 HOST:
   echo test_packet > /sys/kernel/debug/usb@fe800000/host_testmode

2. set compliance mode for Type-C0 USB3 HOST normal orientation:
   echo test_u3 > /sys/kernel/debug/usb@fe800000/host_testmode

3. set compliance mode for Type-C0 USB3 HOST flip orientation:
   echo test_flip_u3 > /sys/kernel/debug/usb@fe800000/host_testmode

4. check the testmode status:
   cat /sys/kernel/debug/usb@fe800000/host_testmode

   The log maybe like this:
   U2: test_packet     /* means that U2 in test mode */
   U3: compliance mode /* means that U3 in test mode */

Change-Id: Ic7e464b0443c792848846246b782ffba30bf2120
Signed-off-by: William Wu <wulf@rock-chips.com>
7 years agoPM / AVS: rockchip-cpu-avs: use a new way to get cluster id
Finley Xiao [Sun, 25 Dec 2016 02:48:34 +0000 (10:48 +0800)]
PM / AVS: rockchip-cpu-avs: use a new way to get cluster id

The returned value of topology_physical_package_id is socket id
on ARM32 system(for example, RK3288), it's not like the cluster id
on ARM64 system(for example, RK3366), so use a new way.

Change-Id: I5b2cdfdcdaa56c71df394caa2588f6e83931a293
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agoUPSTREAM: cpufreq: Send START policy notification after sending CREATE
Viresh Kumar [Tue, 24 May 2016 04:56:50 +0000 (10:26 +0530)]
UPSTREAM: cpufreq: Send START policy notification after sending CREATE

The sequence got a bit wrong as we are sending CPUFREQ_START
notifications even before we have sent CPUFREQ_CREATE_POLICY.

Fix it.

Change-Id: I7d1fba317314bb5e5601b1354494398def156424
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
(cherry picked from commit 388612baba201bdcedfa66782f524dcc507d9f12)

7 years agoarm64: dts: rockchip: rk3366: add cpu avs node
Finley Xiao [Sun, 25 Dec 2016 09:21:17 +0000 (17:21 +0800)]
arm64: dts: rockchip: rk3366: add cpu avs node

Change-Id: I7d984bf44e04d205c243eb2012cd06ba7c7fe548
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agoARM64: dts: rk3399-tve1205g: host state notify ec module through gpio
Shunqing Chen [Sat, 24 Dec 2016 08:25:50 +0000 (16:25 +0800)]
ARM64: dts: rk3399-tve1205g: host state notify ec module through gpio

Change-Id: I3716de0618394de010000a0497de1b3c83cd88ab
Signed-off-by: Shunqing Chen <csq@rock-chips.com>
7 years agopower: host state notify ec module through gpio
Shunqing Chen [Sat, 24 Dec 2016 08:16:00 +0000 (16:16 +0800)]
power: host state notify ec module through gpio

Change-Id: I6b1401c6959a05fce1d6d7ca7a5fb581782fd30d
Signed-off-by: Shunqing Chen <csq@rock-chips.com>
7 years agomfd: fusb302: fix fusb302 disconnect error.
wenping.zhang [Tue, 20 Dec 2016 10:22:46 +0000 (18:22 +0800)]
mfd: fusb302: fix fusb302 disconnect error.

shift the time of vbus enable before attach debounce started,
and merge the code of get_cc from chrome ec driver, which used
to fix connection disconnected issue.

Change-Id: I2fd1f83d0265b3770d75a59d622d0f650d737c5b
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
7 years agonet: rkwifi: enable GET_CUSTOM_MAC_ENABLE
huweiguo [Mon, 26 Dec 2016 00:50:00 +0000 (08:50 +0800)]
net: rkwifi: enable GET_CUSTOM_MAC_ENABLE

Change-Id: I8ea15be317e4bbe1d9cf0834e42536fc4dc4b9d7
Signed-off-by: huweiguo <hwg@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3399: Rename OPP nodes as opp@<opp-hz>
Finley Xiao [Sun, 25 Dec 2016 08:09:44 +0000 (16:09 +0800)]
arm64: dts: rockchip: rk3399: Rename OPP nodes as opp@<opp-hz>

It would be better to name OPP nodes as opp@<opp-hz> as that will ensure
that multiple DT nodes don't contain the same frequency. Of course we
expect the writer to name the node with its opp-hz frequency and not any
other frequency.

And that will let the compile error out if multiple nodes are using the
same opp-hz frequency.

Change-Id: I8c77646329e39390fb135d4d75d34893a8168876
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agoarm64: dts: rk3399: modify opp table according to latest chips
Finley Xiao [Tue, 20 Dec 2016 09:10:35 +0000 (17:10 +0800)]
arm64: dts: rk3399: modify opp table according to latest chips

Change-Id: I2a1b5fac74617cf57a5655411f0326800a6a990d
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agoarm64: dts: rockchip: support use drm on rk3399 excavator linux
WeiYong Bi [Wed, 21 Dec 2016 07:20:03 +0000 (15:20 +0800)]
arm64: dts: rockchip: support use drm on rk3399 excavator linux

1. fixup edp enable gpio.
2. add backlight enable gpio.
3. enable route_edp node.

Change-Id: I4b4792abe3c8eb7dba0c2f5c0d3ddffff74478d1
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoarm64: dts: rk3399_linux: support use drm on rk3399 linux
WeiYong Bi [Wed, 21 Dec 2016 07:15:48 +0000 (15:15 +0800)]
arm64: dts: rk3399_linux: support use drm on rk3399 linux

Change-Id: I9b248af7d86d34a669219fbe62a195ee2b49e516
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agonet: rfkill-wlan: prior to use wifi addr store in vendor storage
huweiguo [Thu, 22 Dec 2016 08:24:26 +0000 (16:24 +0800)]
net: rfkill-wlan: prior to use wifi addr store in vendor storage

Change-Id: I32ef43e1f47ee658675b26d54fa834ae9362382f
Signed-off-by: huweiguo <hwg@rock-chips.com>
7 years agoARM64: dts: rockchip: add power domain node for RK3328 Soc
Elaine Zhang [Fri, 23 Dec 2016 03:04:56 +0000 (11:04 +0800)]
ARM64: dts: rockchip: add power domain node for RK3328 Soc

add pd node for RK3328 Soc
create power domain tree

Change-Id: I0ef5729d397105a7992cb4b7440cdc2b251bd1af
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
7 years agoarm64: dts: rk3399-android: add core reset for dp.
wenping.zhang [Thu, 22 Dec 2016 01:45:36 +0000 (09:45 +0800)]
arm64: dts: rk3399-android: add core reset for dp.

Change-Id: I7c86cfbf28cb278bcadebbb08ba31a8b81bdd290
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
7 years agovideo: rockchip: dp: fix dp fw load error.
wenping.zhang [Thu, 22 Dec 2016 01:44:55 +0000 (09:44 +0800)]
video: rockchip: dp: fix dp fw load error.

Do dptx/apb/core reset on every dp clock enabling, otherwise dp
will fail to load the firmware sometimes.

Change-Id: Ied0caad99d865ec86162dead2b4769a53f8db12a
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
7 years agoarm64: dts: rockchip: support use vpu on rk3399 excavator linux
WeiYong Bi [Wed, 21 Dec 2016 07:07:01 +0000 (15:07 +0800)]
arm64: dts: rockchip: support use vpu on rk3399 excavator linux

Change-Id: I5ea28cd4539140a149f1725a1622fd1dcae3e020
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agodrm/rockchip: gem: add mutex lock for drm mm
Mark Yao [Thu, 22 Dec 2016 04:44:14 +0000 (12:44 +0800)]
drm/rockchip: gem: add mutex lock for drm mm

drm_mm_insert_node_generic and drm_mm_remove_node may access same
resource with list ops, it's not threads safe, so protect this context
with mutex lock.

Fix bug:
[49451.856244] ==================================================================
[49451.856350] BUG: KASAN: wild-memory-access on address dead000000000108
[49451.856379] Write of size 8 by task Binder:218_4/683
[49451.856417] CPU: 2 PID: 683 Comm: Binder:218_4 Not tainted 4.4.36 #62
[49451.856443] Hardware name: Rockchip RK3399 Excavator Board edp (Android) (DT)
[49451.856469] Call trace:
[49451.856519] [<ffffff900808a9d0>] dump_backtrace+0x0/0x230
[49451.856556] [<ffffff900808ac14>] show_stack+0x14/0x1c
[49451.856592] [<ffffff90084a4de0>] dump_stack+0xa0/0xc8
[49451.856633] [<ffffff900821b700>] kasan_report+0x110/0x4dc
[49451.856670] [<ffffff900821aa84>] __asan_store8+0x24/0x7c
[49451.856715] [<ffffff90086158c4>] drm_mm_insert_node_generic+0x2dc/0x464
[49451.856760] [<ffffff90086406a8>] rockchip_gem_iommu_map+0x60/0x158
[49451.856794] [<ffffff9008640bb4>] rockchip_gem_create_object+0x278/0x488
[49451.856827] [<ffffff9008641020>] rockchip_gem_create_with_handle+0x24/0x10c
[49451.856862] [<ffffff9008641364>] rockchip_gem_create_ioctl+0x3c/0x50
[49451.856896] [<ffffff900860aee4>] drm_ioctl+0x354/0x52c
[49451.856939] [<ffffff900823d948>] do_vfs_ioctl+0x670/0x78c
[49451.856976] [<ffffff900823dac4>] SyS_ioctl+0x60/0x88
[49451.857009] [<ffffff9008082ef0>] el0_svc_naked+0x24/0x28

Change-Id: I2ea377aa9ca24f70c59e2d86f2a6ad5ccb9c0891
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>