This fixes tx and bi-directional dma transfers on rk3399-gru-kevin.
It seems the SPI fifo must have room for 2 bursts when the dma_tx_req
signal is generated or it might skip some words. This in turn makes
the rx dma channel never complete for bi-directional transfers.
Fix it by setting tx burst length to fifo_len / 4 and the dma
watermark to fifo_len / 2.
However the rk3399 TRM says (sic):
"DMAC support incrementing-address burst and fixed-address burst. But in
the case of access SPI and UART at byte or halfword size, DMAC only
support fixed-address burst and the address must be aligned to word."
So this relies on fifo_len being a multiple of 16 such that the
burst length (= fifo_len / 4) is a multiple of 4 and the addresses
will be word-aligned.
Change-Id: I7dd843e85e4d888af79ec57a73d1561f8402635e
Fixes: dcfc861d24 ("spi: rockchip: adjust dma watermark and burstlen")
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 47300728fb)
Add missing support for lsb-first mode.
Change-Id: Ifad8eca549ef0652303e98f1306a1e8a3c2fb6a3
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 04290192f7)
The hardware supports 4, 8 and 16bit spi words,
so add the missing support for 4bit words.
Change-Id: Iae796f362fa01bc20ae6cc7e2f1e87498b65db39
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 65498c6ae2)
Register an interrupt handler to fill/empty the
tx and rx fifos rather than busy-looping.
Change-Id: I7da7080a4e9c4d7d72c1d8ca43a3cf3b918cdd6a
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 01b59ce5da)
Now that we no longer potentially change spi clock
at runtime we can precompute the rx sample delay
at probe time rather than for each transfer.
Change-Id: I96e98c97aa8791938689d09e84128617c0dd2b69
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 74b7efa82b)
The driver previously checked each transfer if the
requested speed was higher than possible with the
current spi clock rate and raised the clock rate
accordingly.
However, there is no check to see if the spi clock
was actually set that high and no way to dynamically
lower the spi clock rate again.
So it seems any potiential users of this functionality
are better off just setting the spi clock rate at init
using the assigned-clock-rates devicetree property.
Removing this dynamic spi clock rate raising allows
us let the spi framework handle min/max speeds
for us.
Change-Id: I26366d6149e4c3edaa4587088828e0eb49ff9f38
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 420b82f842)
We only need to know if we're using dma when setting
up the transfer, so just use a local variable for
that.
Change-Id: Id5e755186278f8cf4aff6e0f175bd522aee324ae
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit eff0275e52)
In almost all cases we already have a pointer to the
spi master structure where we have the driver data.
The only exceptions are the dma callbacks which are
easily fixed by passing them the master and using
spi_master_get_devdata to retrieve the driver data.
Change-Id: Ia821c4924ca243447c0aa6c1a61ea4ef6319ff0a
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d790c342e6)
The spi master (aka spi controller) structure already
has two fields for storing the rx and tx dma channels.
Just use them rather than duplicating them in driver data.
Change-Id: I077108d25ac09dd89c6c795df181fb499b7a1211
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit eee06a9ee2)
Just read transfer info directly from the spi device
and transfer structures rather than storing it in
driver data first.
Change-Id: I919be5488196e6ad5e2fbac211d64c9fb2a38ec7
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit fc1ad8ee33)
Successful transfers leave the spi disabled, so if
we just make sure to disable the spi on error
there should be no need to disable the spi from
master->unprepare_message.
This also flushes the tx and rx fifos,
so no need to do that manually.
Change-Id: I5e357ab8852d615fee5d4ec1bc94d6f4aa7add7d
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit ce386100d9)
The state field is currently only used to make sure
only the last of the tx and rx dma callbacks issue
an spi_finalize_current_transfer.
Rather than using a spinlock we can get away
with just turning the state field into an atomic_t.
Change-Id: Ic39ce28e8261a622dbd6e035bbc5c116efd433c9
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit fab3e4871f)
The hardware supports 3 different variants of SPI
and there were some code around it, but nothing
to actually set it to anything but "Motorola SPI".
Just drop that code and always use that mode.
Change-Id: I53d65943b80abea21f3bf35b440d56dc8a1190de
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 2410d6a3c3)
Use C99 designated initializers for dma slave config
structures. This also makes sure uninitialized fields
are zeroed so we don't need an explicit memset.
Change-Id: I306513287454ca38db8dde680a57ebec82965395
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 31bcb57be1)
The spi_enable_chip function takes a boolean
argument. Change the type to reflect that.
Change-Id: I71f016d0cbbb6a77cda3e10e8bb7da45b227b1c9
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 30688e4e67)
Let the dma/non-dma code paths handle the spi enable
flag themselves. This removes some logic to determine
if the flag should be turned on before or after dma
and also don't leave the spi enabled if the dma path
fails.
Change-Id: I406fc1726fa6e6f5a2e82f05e3313f0ee4dc415c
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit a3c174021c)
The dma direction for the tx and rx dma channels never
change, so just use the constants directly rather
than storing them in device data.
Change-Id: Ic6a45d38d076b6c73177dc6dde78e62b0de2ce42
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d9071b7e9f)
The driver data has a u32 field use_dma which is
only ever used as a boolean, so change its type
to reflect that.
Change-Id: Icf9aa668cc86b9ea87e2eb6e2d7eef6fed530cda
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit f340b92051)
We no longer need the dma_caps since the dma driver
already clamps the burst length to the hardware limit,
so don't request and store dma_caps in device data.
Change-Id: I10782f7ffb700322929f819703c41e6c63ff8d78
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 058f7c509e)
This reverts commit 87ec170ff7 which is
commit d065f41a3f upstream.
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Change-Id: If48d08ec8e51829bb6bf8050d377c7060b75e140
This reverts commit 846019f5fa which is
commit 810923f3bf upstream.
Upstream add wait_for_completion_interruptible to hold SPI transfer
in SPI slave work, so it support SPI slave IRQ or DMA transfer.
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Change-Id: Ie0202b0d2d7b9ff7bfc462587c2fc643155549f1
This patch handle the clk by pm runtime mechanism to simplify
the clk management.
Change-Id: I38ddb6345599ab737b42d787209d01c2d3f82483
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Fixes: a109506620 ("drm/rocckhip: driver: add support dmc and use rockchip atomic_commit")
Change-Id: I5c16f4bc6887910e2f752ba29c618d0e583f616f
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
The USB2.0 OTG PHY of RV1126/1109 which is designed for lower power
consumption provides only 8.8mA current source on DM. Multiplied
by 45 Ohm host termination resistance, voltage is about 400mV.
If the threshold voltage of host is greater than 400mV, the high
speed handshake will fail and SoC communicate at full speed. So
swing calibration is necessary.
We use gpio to control the 220 Ohm pull-up resistor to provide additional
current. Experiments show that the voltage of chirpK can be increases
to about 600mV.
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: Ibb0cba2b166f0370d2822ca5a3a7277ffacde8c1
There is no uboot in the thunder boot flow,
So disable logo for kernel display drivers fully initialized
Signed-off-by: Nickey Yang <nickey.yang@rock-chips.com>
Change-Id: Ib6d36fc606dd8a4170a0a12c0800768d4f2af64a
If the regulator is enabled, don't have to enable it again.
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: I293b9002b6373f977313b410709b0e9ad916243d
When initcall_nr_threads=-1, the number of threads set to
num_online_cpus() * 2.
Save boot time about 16ms on rv1126-evb-ddr3-v12 board.
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: I907d03ac21f9e7a74a71ff06385543c0f0fc8c47