Commit Graph

839896 Commits

Author SHA1 Message Date
William Wu
c16f9cf81e usb: dwc3: rockchip: fix NULL pointer dereference in async probe
In dwc3_rockchip_async_probe(), if it tries to get hcd in
peripheral only mode (dr_mode = "peripheral"), a NULL pointer
deference will happen. Because hcd only be allocated and
initialized in host mode or otg mode.

We can reproduce this issue when set dr_mode to peripheral
in DTS, like rk3399pro-npu.dtsi, and get the following panic
log on RK1808 EVB:

Unable to handle kernel NULL pointer dereference at virtual address 000000b0
pgd = ffffff8008b0b000
[000000b0] *pgd=000000007fffe003, *pud=000000007fffe003, *pmd=0000000000000000
Internal error: Oops: 96000005 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 29 Comm: kworker/u4:1 Not tainted 4.4.167 #493
Hardware name: Rockchip RK1808 EVB V10 Board (DT)
Workqueue: events_unbound async_run_entry_fn
task: ffffffc07cd29580 task.stack: ffffffc07cd40000
PC is at dwc3_rockchip_async_probe+0x28/0x1c8
LR is at async_run_entry_fn+0x48/0x100
pc : [<ffffff80083adf5c>] lr : [<ffffff80080b445c>] pstate: 60000045
sp : ffffffc07cd43d10
...
[<ffffff80083adf5c>] dwc3_rockchip_async_probe+0x28/0x1c8
[<ffffff80080b445c>] async_run_entry_fn+0x48/0x100
[<ffffff80080acca8>] process_one_work+0x1b8/0x2b8
[<ffffff80080ad94c>] worker_thread+0x304/0x418
[<ffffff80080b206c>] kthread+0xd0/0xd8
[<ffffff8008082e80>] ret_from_fork+0x10/0x50

Fixes: f2a2b34e45 ("usb: dwc3: rockchip: use async_schedule for initial dwc3")
Change-Id: I740936e43bc4ea2b5a056d6d9dcaf18466006f0c
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:55 +08:00
William Wu
b1d6e7cbf8 usb: dwc3: rockchip: use devm_extcon_register_notifier
This patch uses the devm_extcon_register_notifier to
manage the resource automatically.

Change-Id: I427c54d59283ee97623ad829e42dac40516c3df4
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:47 +08:00
William Wu
dd937ee864 usb: dwc3: rockchip: fix rk3399 dwc3 host power on fail
RK3399 Excavator Board has an USB 3.0 PHY power on issue
when Type-A USB 3.0 Host port connects with an USB 3.0
device and do system PM suspend/resume test.

When the issue happens, we gets the following error log:

phy phy-ff800000.phy.4: phy poweron failed --> -110
dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -110
PM: Device fe900000.dwc3 failed to resume: error -110
xhci-hcd xhci-hcd.12.auto: port 0 resume PLC timeout

It's because that the Type-C PHY docs say that the DWC3
controller "needs to be held in reset to set the PIPE
power state in P2 before initializing the Type-C PHY",
but actually the PIPE is in P0 state because an USB 3.0
device is connected, and the current code doesn't reset
the DWC3 controller upon PM resume.

This patch prevents powering off the USB 3.0 PHY of
RK3399 Type-A USB 3.0 Host port when system enters
syspend. As a side effect, the power consumption in
standby mode will increase. However, if you want to
optimize the power consumption in standby mode and
allow the USB device to be reenumerated upon PM resume,
you can add a property "needs-reset-on-resume" in
DWC3 DTS like this:

&usbdrd3_1 {
	needs-reset-on-resume;
};

Change-Id: Ia1cdf6e09cac520e99931a15423b8de7be2ba52b
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:41 +08:00
William Wu
ecb82b10b0 arm64: dts: rockchip: fix pd_usb3 power domain for rk3399 dwc3
This patch assigns the pd_usb3 power domain to the parent of
dwc3 node.

Change-Id: I2074539c23f958041d8829f7b3826a7813c3631a
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:36 +08:00
William Wu
023c496347 phy: rockchip-inno-usb2: add basic runtime PM support
Adds pm_runtime support for some rockchip SoCs (e.g. rk3399)
which support power domain for USB 2.0 PHY.

Change-Id: I4c78075c884b3baf6d709e08e3464b214524d685
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:21 +08:00
William Wu
c76cb97fe5 arm64: dts: rockchip: add pd_perihp power-domain for rk3399 u2phy
Assign the pd_perihp power-domain to the USB 2.0 PHY node.

Change-Id: I9fda0a4391a6fb3823293b3dd36cae7cd6da0fb5
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:21 +08:00
William Wu
a08d915e89 phy: rockchip-inno-usb2: select EXTCON directly
Instead of indirectly selecting EXTCON via depending on
EXTCON, just select EXTCON. It is possible to avoid modify
lots of defconfig.

Change-Id: Id4a633404d543b87dda86b126fd6aab1d53c1415
Signed-off-by: William Wu <william.wu@rock-chips.com>
2019-04-09 19:59:21 +08:00
Liang Chen
f7130ff5bc arm64: dts: rockchip: disable uart2 for rk3328-evb
uart2 is used by fiq debugger, and we use ttyFIQ as console,
so do not enable uart2, or it enable ttyS2 as console.

Change-Id: Ib1b01f14c553da75830efa5b4e11933ef997e446
Signed-off-by: Liang Chen <cl@rock-chips.com>
2019-04-09 17:50:06 +08:00
Joseph Chen
83bb9ed30c mfd: rk808: support power off system in syscore shutdown
For PMIC that power off supplies by write register via i2c bus,
it's better to do power off at syscore shutdown.

Because when run to kernel's "pm_power_off" call, i2c may has
been stopped or PMIC may not be able to get i2c transfer while
there are too many devices are competiting.

This patch effects on PMIC: RK808/RK818/RK816, not including RK805
which power off system by pull up pmic sleep pin in ATF.

Change-Id: I2eb139f75abf32a9c239b56a8e65e76c42927e87
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:47 +08:00
Joseph Chen
9eaa22bc79 mfd: rk808: set fall event higher priority than rise event
When PMIC irq occurs, regmap-irq.c will traverse all PMIC child
interrupts from low index 0 to high index, we give fall interrupt
high priority to be called earlier than rise, so that it can be
override by late rise event. This can helps to solve key release
glitch which make a wrongly fall event immediately after rise.

Change-Id: Ieda1d6fd3c50cc36742a4740504ec7ce12ea509b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:42 +08:00
Joseph Chen
db1243d054 mfd: rk808: initialize rk808_i2c_client by default
Even "rockchip,system-power-controller" is not found,
rk808_i2c_client is needed for suspend/resume and the
other.

Change-Id: I17ebb3a1d1e7ec8dc9f4a3ee2dbdcd9ae4c1648b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:37 +08:00
Joseph Chen
adb91abb82 mfd: rk808: add rk818 suspend/resume registers setting
set 3.4v interrupt signal assert when suspend, set 3.0v shutdown
signal assert when resume.

Change-Id: Id15b721bbdc9665a18cf9946b92c435a23f1666c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:30 +08:00
Joseph Chen
2518489472 mfd: rk808: add rk816 suspend/resume registers setting
set 3.4v interrupt signal assert when suspend, set 3.0v shutdown
signal assert when resume.

Change-Id: Ie91d8ce6a79e5ea50b654ea52c3ed8acf047f8fb
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:26 +08:00
Joseph Chen
c6daa5b4ef regulator: rk808: fix rk816 regulators register failed
fix commit: 45a046e.
regulator framework requires continuous regulator id.

Change-Id: I2e2b789c3ab9126e793d9e304ef2a44d8f46eacd
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:22 +08:00
Joseph Chen
2665487b6c mfd: rk808: add rk816 battery regmap irq chip
Due to different irq_reg_stride of register, add individual
irq chip for battery.

Change-Id: Ic37b136ebc543d4f7bd22d5748b59df73526ccbe
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:16 +08:00
Joseph Chen
029602d504 mfd: rk808: add suspend and resume register setting for rk805
Because Buck3 don't have sleep state register, so we need a manual
switch: set BUCK3 suspend as Auto PWM mode and resume as FPWM mode.

This is for power saving in system suspend.

Change-Id: I67db458e650b6e85ed4267f0b0dcdb01dff4c635
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:09:08 +08:00
Joseph Chen
f4c9927c91 mfd: rk808: add sysfs debug node "/sys/rk8xx/rk8xx_dbg"
Change-Id: I197dc97b7337414a7d52426da0e0cb8c7480c917
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:08:22 +08:00
Joseph Chen
4fc215bafe regulator: fan53555: rename tcs "4525" to "452x"
It supports both tcs4525 and tcs4526 chip. The tcs4525
i2c addr is 0x1c and tcs4526 i2c addr is 0x10.

Change-Id: I01cf8384032b2c805b8a55fa6686ca98ea2355e0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:04:44 +08:00
Joseph Chen
53c2d6c169 regulator: fan53555: add TCS4525 DCDC support
TCS4525 main features:

- 2.7V to 5.5V Input Voltage Range;
- 3MHz Constant Switching Frequency;
- 5A Available Load Current;
- Programmable Output Voltage: 0.6V to 1.4V in 6.25mV Steps;
- PFM/PWM Operation for Optimum Increased Efficiency;

Change-Id: I7d4b8bbf38a5c74174b16ae4cb64d04f903a2902
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 18:04:39 +08:00
Huibin Hong
9d0ed3f2d4 fiq debugger: ttyS2 and fiq debugger don't use the same uart2
Someone may enable uart2 and fiq debugger, which is illegal.

&uart2 {
	status = "okay";
};

&fiq_debugger {
	status = "okay";
};

Change-Id: Ibecd3c3ca69de1216103d7c373a4d282cf93cb30
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-04-04 19:07:26 +08:00
Huibin Hong
3c04924a04 fiq debugger: support dummy console
Maybe you need to use uart2 as normal ttyS2, firstly disable the
uart2 debug function. Set "rockchip,serial-id" as -1, it means
fiq debugger still have a /dev/ttyFIQ0, but it doesn't have any uart
hardware.

&fiq_debugger {
	rockchip,serial-id = <0xffffffff>;
	status = "okay";
};

Change-Id: I80065eed852eb50139520c5c1fdceb882773d79d
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-04-04 19:06:58 +08:00
David Wu
199f9ec5ea arm64: dts: rockchip: rk1808: Correct the drive strength for rgmii/rmii
According to the hardware test, change the tx pin drive strength
to 4ma, and mdc/mdio 2ma.

Change-Id: Ia5ab1728c9e9ecbfa7207217649588f600070ae4
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:46:00 +08:00
David Wu
dcc17105cd dt-bindings: net: rockchip-dwmac: Add gmac support for rk1808
This patch adds devicetree support to gmac of rk1808 with proper
devicetree compatible strings.

Change-Id: Id35523a10f987cbb9b9c33ad32ab23cb3c6d4e2b
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:44:46 +08:00
David Wu
e81268ce6a iio: adc: rockchip: Don't return fail at probe when the regulator is dummy
If the referenced regulator is a dummy, the voltage is invalid,
but someone doesn't need the voltage, just need the adc value,
so don't return fail at probe when the regulator is dummy. If
he wants the voltage, configures the actual referenced regulator
at dts.

Change-Id: I8eaecc1a8e7e57c3a87aa69b9b852735bf4a025a
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:38:16 +08:00
David Wu
bae3a3d951 iio: adc: rockchip_saradc: Just get referenced voltage once at probe
The referenced voltage is not changed after initiation, so just only
get referenced voltage once.

Change-Id: I1eeab03f68855fafe010db328ec7bbcfa7d52310
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:38:16 +08:00
David Wu
18944a5f2d i2c: rk3x: Fix the smatch warning
This patch fixes the following warning:
drivers/i2c/busses/i2c-rk3x.c:1136 rk3x_i2c_xfer() error: uninitialized symbol 'timeout'.

Fixes: d5635ca05b ("i2c: rk3x: Disable irq after i2c transfer finished")
Change-Id: I7618ae660a62e8e3fc5b7b5d00cff1264bd18663
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
3a0964387b i2c: rk3x: Disable irq after i2c transfer finished
In some case,log like this:

[   12.393926] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51
[   12.416592] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51

The i2c clock is disabled, so the pending irq clean is not
worked. Disable the interrupt after the i2c jobs were done,
the error log would not happen.

Change-Id: If04a2e2214d675410c67db0f131ee7ef635ddcb4
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
3c56fbfb4c i2c: rk3x: Disable i2c controller after i2c transfer finished
If the slave hold the scl low for a long time, we will send
the stop because the i2c transfer is timeout. Then reset the
slave, the scl will be released to high by slave, the data
hold low, but the controller's state is messy now, need to
diable i2c controller, it is better to reset i2c controller,
it will go back to normal state.

The log like this:

[ 117.444700] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x93, state: 2
[ 118.466410] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x00, state: 1
[ 119.486217] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x00, state: 1

or

[  91.733176] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x80, state: 1
[ 103.406776] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x00, state: 2
[ 104.426636] rk3x-i2c ff3d0000.i2c: timeout, ipd: 0x00, state: 2

Change-Id: I53e6e383c849cea22d870f9488c23720e74115df
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
c9327186f6 i2c: rk3x: Leave the irq handle if received nack irq
In the TRX mode, if there was a nack signal at the hardware's
tx, we can get start and nack ipd from the I2C_IPD register,
which will enter nack process, send stop command, change the
state to stop, and enter the handler of stop irq, but the stop
irq may not be generated, it has a latency. So the log will like
this:

[ 69.961944] rk3x-i2c ff650000.i2c: unexpected irq in STOP: 0x10
[ 70.959690] rk3x-i2c ff650000.i2c: timeout, ipd: 0x00, state: 4

This error log will confuse us, it is not easier to locate the problem,
we should get nack error at this time, and processing stop interrupt at
the next, then complete this i2c job.

Change-Id: I073ef288557b1b6f525d936e8f32d9d165c81ec4
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
33293aa551 i2c: rk3x: Add slave_hold_scl ipd clean
The bit7 of I2C_IPD register also needs to be clean, otherwise,
it will always exist.

Change-Id: Iee01bffd83909e84ed99c9fab821e621c970efd3
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
4efbd51c48 i2c: rk3x: Add "suspended" flag to forbid access I2C bus during suspend/resume noirq
Add "suspended" flag in suspend_noirq()/resume_noirq() callback
to prevent new i2c job started, and use i2c_lock_adapter() to wait
for current i2c transfer finished.

If any i2c client try to access I2C after suspend_noirq() or
before resume_noirq() callback, return the error, and they
should fix it, not to start i2c access at this moment.

Change-Id: Idd1142058d10547d085895a498201c2ade6b9e96
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:37:31 +08:00
zah
b97a325b33 i2c: Devices which have some i2c addr can work in same i2c bus
If i2c slave devices don't work at the same time, which have
the same i2c addr, this patch can make them working.

Change-Id: I1bfb7783924b08bdc6e12bf47c2de01bdac7c2e2
Signed-off-by: Zhang aihui <zah@rock-chips.com>
2019-04-04 18:37:31 +08:00
David Wu
0dbdb29de2 i2c: rk3x: Make sure the i2c transfer to be finished before system reboot
If the system rebooted, there might be i2c transfer at the
same time, it will make something unpredictable, because
the i2c host was reseted, but the slave device wasn't, such
as rk808 pmic, so make sure the i2c transfer to be finished
before system shutdown at the reset mode.

Change-Id: I3c09f3acbe86595c295edc191aa38351adb7d5dc
Signed-off-by: David Wu <david.wu@rock-chips.com>
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2019-04-04 18:37:31 +08:00
Jianqun Xu
e818f13f6c i2c: rk3x: fix to dev_warn_ratelimited
In some case, the log will look bad such as:
[   12.393926] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51
[[[[[[[[[[[[.[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

Let's limit the printk:
[  180.446547] rk3x_i2c_irq: 1726030 callbacks suppressed
[  180.446592] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51

Change-Id: Ie91163ad3085e5dba127790b50e3beb359510120
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2019-04-04 18:37:31 +08:00
Wadim Egorov
70d9feffcd net: phy: dp83867: Check if the phy is in an internal testing mode
The DP83867 seems to be always in an internal mode on our Board.
This mode can cause connection problems. We disable this mode.

Unfortunately, Register 0x31 Bit 7 is not documented and marked as reserved.
If Bit 7 is set, phy is in the internal testing mode.

Change-Id: I5d3435fcfea0e1af7c4d5ee510c249f41211f223
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
2019-04-04 18:23:34 +08:00
Wadim Egorov
988a354947 net: phy: dp83867: Disable FORCE_LINK_GOOD in PHYCTRL
With FORCE_LINK_GOOD we are not able to get a link.
According to the TRM this bit should be 0 (Normal operation) in default.

Set FORCE_LINK_GOOD to default.

Change-Id: Iaa30bef20fc6f8313c018d18646879f62db49004
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
2019-04-04 18:23:34 +08:00
David Wu
fa48ce6f4b net: ethernet: stmmac: dwmac-rk: Add gmac support for rk1808
Add constants and callback functions for the dwmac on rk1808 soc.
As can be seen, the base structure is the same, only registers
and the bits in them moved slightly.

Change-Id: I39a75b89cd17331bb4373b9b249ae206e1420e71
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:13:10 +08:00
David Wu
e178f7fa48 ethernet: stmmac: dwmac-rk: Add MAC driver support for rk3308
Add constants and callback functions for the dwmac on rk3308 soc.
The base structure is the same, but registers and the bits in
them moved slightly, and add the clk_mac_speed for the select
of mac speed.

Change-Id: Ieaea3ade9e51d5118f0eb855d8e02febfb2275d1
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:13:02 +08:00
David Wu
4abe2873ce ethernet: stmmac: rockchip: Fix the correct clock for mdc divider
The MDC clock is divider from APB Clock for rockchip's socs, if it
was from mac_clk, the mdc clk range might not be between the frequency
range 1.0 MHz - 2.5 MHz.

Change-Id: I4e4fcb1be239a8d78a39fc1f4e2af5bb87258798
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:12:54 +08:00
Zhangbin Tong
c2a7dbb9c7 net: stmmac: dwmac-rk: read mac address from devinfo first
Change-Id: I2888dcfc57c2e5a266fdf1058f9ab70e04034f22
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
2019-04-04 18:12:46 +08:00
David Wu
fa3b8e0c40 net: stmmac: The netif_device_attach() should be called after napi_enable()
If the netif_device_attach() is called earlier, the state of dev_queue is
waked, txtimer might be modified, and the txtimer is added at same time.
It might make run_timer_softirq crashed, because the timer is be detached
twice together.

Change-Id: I31dde4e940bddcc36372ca1f4a8313c0389d4e6b
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:12:37 +08:00
Weiguo Hu
a493c7f14f ethernet: rockchip: get and save eth addr in vendor storage
Change-Id: I83d8bc81ca8d33e6f2575d0d90a3dc5978500a64
Signed-off-by: Weiguo Hu <hwg@rock-chips.com>
2019-04-04 18:12:21 +08:00
Sugar Zhang
46020da40c dmaengine: pl330: _loop_cyclic: fixup loopcnt is too large
This patch fixup dma transfer data lost if loop cnt is larger
than 256.

Change-Id: Id49302cdcc1ac871d03070ce07eaa7653e54408c
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
2019-04-04 18:06:28 +08:00
Sugar Zhang
4e3b147bc1 dmaengine: pl330: _stop: clear interrupt status
This patch kill instructs the DMAC to immediately terminate
execution of a thread. and then clear the interrupt status,
at last, stop generating interrupts for DMA_SEV. to guarantee
the next dma start is clean. otherwise, one interrupt maybe leave
to next start and make some mistake.

we can reporduce the problem as follows:

DMASEV: modify the event-interrupt resource, and if the INTEN sets
function as interrupt, the DMAC will set irq<event_num> HIGH to
generate interrupt. write INTCLR to clear interrupt.

	DMA EXECUTING INSTRUCTS		DMA TERMINATE
		|				|
		|				|
	       ...			      _stop
		|				|
		|			spin_lock_irqsave
	     DMASEV				|
		|				|
		|			    mask INTEN
		|				|
		|			     DMAKILL
		|				|
		|			spin_unlock_irqrestore

in above case, a interrupt was left, and if we unmask INTEN, the DMAC
will set irq<event_num> HIGH to generate interrupt.

to fix this, do as follows:

	DMA EXECUTING INSTRUCTS		DMA TERMINATE
		|				|
		|				|
	       ...			      _stop
		|				|
		|			spin_lock_irqsave
	     DMASEV				|
		|				|
		|			     DMAKILL
		|				|
		|			   clear INTCLR
		|			    mask INTEN
		|				|
		|			spin_unlock_irqrestore

Change-Id: I5d452cad70964c519b53711a292d2d2714b811a1
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
2019-04-04 18:06:28 +08:00
Huibin Hong
c03395df9c dmaengine: pl330: fix bug that chan descdone is null
The pl330 irq may come after terminal chan, and desc is
set null. It can't be avoided by disabling irq, because
other chans use the common irq. If the chan is terminaled,
we needn't call its callback or restart it.

Change-Id: I73201eaa4dbdd09c765129f9f3f41573c73faf73
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-04-04 18:06:28 +08:00
Huibin Hong
1b69a6a2e8 dmaengine: pl330: pl330_tasklet init power_down by pch->active
To fix issue like this:
dma-pl330 ff6d0000.dma-controller: pl330_update:1733 Unexpected!
dma-pl330 ff6d0000.dma-controller: DMAC halted!

The root cause is DMA clk is closed when DMA interrupt is
in service. This may happen, as follow:

1. When pl330_terminate_all is called, and set pch->active false,
power_down is true, call pm_runtime_put_autosuspend.
2. Then pl330_tasklet is called, if power_down is also true, call
pm_runtime_put_autosuspend again.
3. DMA is opened again, because the autosuspend is asyn, it may close
the DMA clk. If DMA interrupt is coming, it causes the issue.

Change-Id: Ib1feb508c16afb4bc9ced0c3660f2b6b4a19c068
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-04-04 18:06:28 +08:00
Sugar Zhang
6b420297ef dmaengine: pl330: redefine the cyclic transfer
dmaengine_prep_dma_cyclic, to use buf_addr with size buf_len,
generate an interrupt every period_len. But DMA must restart
every period_len, it may be blocked. If i2s use it, it may
cause sound break. Infiniteloop is helpful to solve this
issue. In infiniteloop mode, when DMA transfers all buf_len
data, it goes back to the start of buf_addr and continue to
transfer endless.

Change-Id: Ibbc92c416d0a9dd58633e7991176c86300c3da98
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
2019-04-04 18:06:28 +08:00
Shuyu Wei
789095fa46 FROMLIST: net: arc/emac: Move arc_emac_tx_clean() into arc_emac_tx() and disable tx interrut
Doing tx_clean() inside poll() may scramble the tx ring buffer if
tx() is running. This will cause tx to stop working, which can be
reproduced by simultaneously downloading two large files at high speed.

Moving tx_clean() into tx() will prevent this. And tx interrupt is no
longer needed now.

Picked the Shuyu's patch up, the patch is sent on
https://patchwork.kernel.org/patch/8356821/, since that make sense for
rockchip platform.
Note: Many people feedback the cransh problems with rk3036/rk3188 emac when
download the heavy loading and this patch is indeed can fix the crash.

The crash log as the followings:
...
[ 2191.996127 ] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.0-rc6 #114
[ 2192.002475 ] Hardware name: Rockchip (Device Tree)
[ 2192.007174 ] Backtrace:
[ 2192.009658 ] [<c00134d4>] (dump_backtrace) from [<c0013680>]
    (show_stack+0x18/0x1c)
[ 2192.017220 ]  r7:c051c4f8 r6:ef463180 r5:c05b7000 r4:00000000
[ 2192.022948 ] [<c0013668>] (show_stack) from [<c0219d90>]
    (dump_stack+0x90/0xa0)
[ 2192.030176 ] [<c0219d00>] (dump_stack) from [<c00b2cd4>]
    (bad_page+0xdc/0x12c)
[ 2192.037302 ]  r5:c059a100 r4:c05f430c
[ 2192.040913 ] [<c00b2bf8>] (bad_page) from [<c00b606c>]
    (get_page_from_freelist+0x388/0x95c)
[ 2192.049166 ]  r9:00000008 r8:ef463180 r7:c051c4d0 r6:00000000
    r5:00000000 r4:c051c4e4
[ 2192.056982 ] [<c00b5ce4>] (get_page_from_freelist) from
[<c00b6880>] (__alloc_pages_nodemask+0xd8/0x8e8)
[ 2192.066362 ]  r10:c001b068 r9:00000000 r8:ee0b02b0 r7:60000113
    r6:00000003 r5:02095220
[ 2192.074254 ]  r4:c05ca1c0
[ 2192.076809 ] [<c00b67a8>] (__alloc_pages_nodemask) from
[<c00b7140>] (__alloc_page_frag+0xb0/0x160)
[ 2192.085757 ]  r10:c001b068 r9:00000000 r8:ee0b02b0 r7:60000113
    r6:02080020 r5:00000740
[ 2192.093650 ]  r4:eedbc884
[ 2192.096207 ] [<c00b7090>] (__alloc_page_frag) from [<c03273b4>]
    (__netdev_alloc_skb+0xa0/0x104)
[ 2192.104806 ]  r7:60000113 r6:eedbc884 r5:ee0b0000 r4:00000740
[ 2192.110525 ] [<c0327314>] (__netdev_alloc_skb) from [<c02aac00>]
    (arc_emac_poll+0x318/0x57c)
[ 2192.118865 ]  r9:00000000 r8:ee0b02b0 r7:0000019c r6:ee163780
    r5:00000670 r4:ee0b0000
[ 2192.126683 ] [<c02aa8e8>] (arc_emac_poll) from [<c0339ed8>]
    (net_rx_action+0x1f0/0x2ec)
[ 2192.134590 ]  r10:c0599df8 r9:c059a100 r8:00073760 r7:0000012c
    r6:00000028 r5:c02aa8e8
[ 2192.142483 ]  r4:ee0b04e0
[ 2192.145040 ] [<c0339ce8>] (net_rx_action) from [<c0026f5c>]
    (__do_softirq+0x134/0x258)
[ 2192.152860 ]  r10:c059a080 r9:40000003 r8:00000003 r7:00000100
    r6:c0598000 r5:c059a08c
[ 2192.160751 ]  r4:00000000
...

Change-Id: Ie7c161809d511bda5d65af7b48fefffff30c07e8
Signed-off-by: Shuyu Wei <sy.w@outlook.com>
Tested-by: Michael Niewoehner <linux@mniewoehner.de>
Tested-by: Xing Zheng <zhengxing@rock-chips.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexander Kochetkov <al.kochet@gmail.com>
Cc: netdev@vger.kernel.org
(am from https://patchwork.kernel.org/patch/9032581/)
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
2019-04-04 18:04:56 +08:00
David Wu
906cea2b56 pwm: rockchip: Disable irq for pwm config
Add irq disabled protection at the PWM configuration, which can
speed up the PWM configuration and reduce the possibility of
interrupting the configuration.

Change-Id: I8ca3c4b9790b747c12804fa82b51456a0de7fb92
Signed-off-by: David Wu <david.wu@rock-chips.com>
2019-04-04 18:04:12 +08:00
Sandy Huang
aff06ee422 pwm: rockchip: add pwm en for voppwm
voppwm is frame effect, so we need add vop pwm en to
indicate the pwm en state.

Change-Id: I1492322f99b638c8dc6cf03c87035f28dca3de8f
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
2019-04-04 18:04:12 +08:00