27 May, 2019
1 commit
-
Common code will do spi_set_cs() if cs-gpios has been initialized
whether controller is in master or slave mode. So remove allocating
memory for cs-gpios operation to avoid cs control in slave sending
sequence.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
23 Apr, 2019
3 commits
-
Replace fsl_lpspi->chipselect by controller->cs_gpios. Clean up the
code.Signed-off-by: Clark Wang
Acked-by: Fugang Duan -
Add "fsl,spi-num-chipselects" check to support multi SS function in PIO
mode.Signed-off-by: Clark Wang
Acked-by: Fugang Duan -
Add a NULL check for device node and lpspi_platform_info when lpspi
device probe.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
18 Apr, 2019
32 commits
-
Add the missing complete operations for dma_completion to fix the
problem of blocking at the wait_for_completion_interruptible()
function in some situations.Signed-off-by: Clark Wang
(cherry picked from commit a19a00c51df5c3ead4d64ea3136f5bce60b2e6af) -
Fixes: 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi")
Signed-off-by: kbuild test robot
Signed-off-by: Mark Brown
(cherry picked from commit 04f7ee7c9e9b9e0aad42001c0bae54af3997297c) -
Related issues have been fixed by (e0e542aeb46a MLK-20060-1 spi: lpspi:
fix wrong transmission when don't use CONT). However, the delay between
sending and receiving in slave mode. This causes the value of
FSR_RXCOUNT cannot reflect whether there is still data not sent timely.
So do this judgement by FSR_TXCOUNT.Signed-off-by: Clark Wang
(cherry picked from commit 1a260d13aa3724b9919a2d8e2f53b4ad26ccf372) -
The spi_transfer *t will be used in one transfer whatever. If t is NULL,
there has no need to try sending data, so add an error return here.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
(cherry picked from commit 68b253138f23754706d3ec16007f2327e1910654) -
Add dma mode support for LPSPI. Any frame longer than half txfifosize will
be sent by dma mode.For now, there are some limits:
1. The maximum transfer speed in master mode depends on the slave device,
at least 40MHz(tested by spi-nor on 8qm-lpddr4-arm2 base board);
2. The maximum transfer speed in slave mode is 15MHz(imx7ulp),
22MHz(8qm/qxp).Signed-off-by: Clark Wang
Acked-by: Fugang Duan
(cherry picked from commit 1693fd1628108e47fa7700218fc2b3aa1e9b83ee) -
Use the default implementation of transfer_one_msg/chipselect/setup
functions in spi core to implement cs-gpio control.
Use fsl_lpspi_prepare_message to init the cs_gpio pin.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
(cherry picked from commit 8f0f0df824fc113eade82f929e3e78b8f4d2ac55) -
Add a error info when set a speed which greater than half of per-clk of
spi module.The minimum SCK period is 2 cycles(CCR[SCKDIV]). So the maximum transfer
speed is half of spi per-clk.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
(cherry picked from commit d13f9515c1378d778e82a72c24a99892389710c4) -
Add judgment on SR_MBF and FSR_RXCOUNT.
In PIO mode, if don't use CONT to keep cs selected in one transfer, the
transfer will go wrong. FCIE will be set after one frame transfer
finish. If use CONT, the frame refer to the whole data in one transfer.
If don't use CONT, the frame refer to one byte of whole data. This will
cause the transfer ending early.This patch add a register reading in isr function, it might lead to a
slight decrease in the max transmission speed in PIO mode.Signed-off-by: Clark Wang
Acked-by: Fugang Duan
(cherry picked from commit 0e31af06088acb5751e0ecfef4ae2acc38f6c749) -
Add cs-gpio feature. Use fsl_lpspi_prepare_message() and
fsl_lpspi_unprepare_message() to enable and control cs line.
These two functions will be only called at the beginning and the ending
of a message transfer.Still can use the mode without cs-gpio. The two ways can refer to
fsl-imx8qm-lpddr4-arm2-lpspi.dts for setting the lpspi configration in
dts file.Signed-off-by: Clark Wang
(cherry picked from commit 245d353cdf0a461ddcd2dcc36793571aae1069b0) -
Add pio spi slave mode support for imx6ul which is based on the patch
cherry-pick from community(71abd29057cb17b6b9532421821dc443427399ed).Because the original imx6ul is bound to mx51 in the dts file.
However, in the slave mode, the patch in the community only adds two
functions mx53_ecspi_rx_slave/mx53_ecspi_tx_slave. Therefore, configure
mx51/6ul to use these two functions for data transmission and reception
in slave mode.Acked-by: Fugang Duan
Signed-off-by: Clark Wang
Signed-off-by: Arulpandiyan Vadivel -
Use SR_TDF to judge if need send data, and SR_FCF to judge if
transmission end to replace the waiting after transmission end. This
waiting has no actual meaning, for the real end will set the FCF
flag.Resolved an issue that could cause a transmission timeout when
transferring large amounts of data.After making these changes, there is no need to use
fsl_lpspi_txfifo_empty(), so remove it.Signed-off-by: Xiaoning Wang
Reviewed-by: Fugang Duan
Signed-off-by: Arulpandiyan Vadivel -
Remove Reset operation in fsl_lpspi_config(). This RST may cause both CLK and
CS pins go from high to low level under cs-gpio mode.
Add fsl_lpspi_reset() function after one message transfer to clear all
flags in use.Signed-off-by: Xiaoning Wang
Reviewed-by: Fugang Duan
Signed-off-by: Arulpandiyan Vadivel -
enable the runtime pm for lpspi module
BuildInfo:
- U-Boot 2018.03-imx_4.14.ySigned-off-by: Han Xu
Reviewed-by: Frank Li
Signed-off-by: Xiaoning Wang
Signed-off-by: Vipul Kumar -
Add both ipg and per clock for lpspi to support i.MX8QM/QXP boards.
Signed-off-by: Xiaoning Wang
Signed-off-by: Vipul Kumar -
Add new setup_wml() for i.mx6ul, otherwise, kernel crash triggered
since no such function on i.mx6ul.This issue is brought by
commit 85c124bbc1c4 ("MLK-18983-1: spi: imx: move wml setting to
later than setup_transfer").Signed-off-by: Robin Gong
(cherry picked from commit b9d8546a41ad4b3698f273e640bd757897471767)
Signed-off-by: Vipul Kumar -
Correct wml as the last rx sg length instead of the whole transfer
length.Signed-off-by: Robin Gong
(cherry picked from commit bf4c5b4d29a0ef5279e57ddba146eafe3325fcac)
(Vipul: Fixed merge conflicts)
Signed-off-by: Vipul Kumar -
Current dynamic burst lengt
h is based on the whole transfer length,
that's ok if there is only one sg, but not correct in case multi sgs
in one transfer,because the tail data should based on the last sg
length instead of the whole transfer length. Move wml setting for DMA
to the later place, thus, the next patch could get the right last sg
length for wml setting. This patch is a preparation one, no any
function change involved.Signed-off-by: Robin Gong
(cherry picked from commit 85c124bbc1c45b43137343481089b6b7c63f208d)
(Vipul: Fixed merge conflicts)
Signed-off-by: Vipul Kumar -
Add SPI slave mode for imx7ulp.
Need use imx7ulp-evk-spi-slave.dtb to boot.
Slave has to send the message which is same as the length of message
master sent.Wire connection:
GND, SCK, MISO(to MISO of slave), MOSI(to MOSI of slave), SCSSigned-off-by: Xiaoning Wang
Signed-off-by: Vipul Kumar -
fsl,spi-num-chipselects may not assigned in DT, don't return EINVALID in
this case.Signed-off-by: Han Xu
Signed-off-by: Vipul Kumar -
Below description copied from RM:
"RX_THRESHOLD. This field defines the FIFO threshold that triggers
a RX DMA/INT request.A RX DMA/INT request is issued when the number
of data entries in the RXFIFO is greater than RX_THRESHOLD."
Then, the RX_THRESHOLD of ECSPIx_DMAREG should be set as 'wml-1',
otherwise, the last 'wml' number of data in rxfifo will never be pulled
out.Signed-off-by: Robin Gong
Reviewed-by: Han Xu
Signed-off-by: Vipul Kumar -
Upstreaming code already support dynamically adjust watermark with
the transfer count, so in case 'wml=1', tx wml will be set to 0
after divided by 2, which cause tx dma never start.Actually, don't
need promise tx_wml=rx_wml/2 any more, because the max wml for tx/rx
is half of fifo size and sdma script have already check the data count
in RXFIFO, if more than half of rxfifo data remain in rxfifo, tx dma
will never start transfer next 'watermark'(the max count maybe the half
of fifo size) data until the data in rxfifo less than half of rxfifo.
So never any data loss happen. Remove 'wml/2'.Signed-off-by: Robin Gong
Reviewed-by: Han Xu
Signed-off-by: Vipul Kumar -
This patch revert "MLK-17619: spi: ecspi: request gpio resources
before setting the value", because spi_imx_setup() will be called
several times accroding to the spc definition. So remove the gpio
request operation out from spi_imx_setup(), and back to probe(),
and move up the location, just incase set the cs gpio value before
request gpio resources.This reverts commit aba5f6342002ffe1f13a71dbddf30ec15ee1edba.
(Vipul: Fixed merge conflicts)
Signed-off-by: Vipul Kumar -
gpio controller ignored all values were set before request resources,
move the devm_gpio_request to spi_imx_setup to fix the issue.Signed-off-by: Han Xu
Suggested-and-reviewed-by: Fugang Duan
(Vipul: Fixed merge conflicts)
Signed-off-by: Vipul Kumar -
Use PIO if transfer length is smaller than wml instead of DMA mode.
That means some spi-nor driver such as m25p32 may setup one small size
transfer to probe device id from external spi-nor devicee by PIO mode
instead of DMA which can avoid checking sdma firmware ready during spi-nor
driver probe.Signed-off-by: Robin Gong
Acked-by: Fugang Duan
(Vipul: Fixed merge conflicts)
Signed-off-by: Vipul Kumar -
1. Fix code error of changing lpspi clock polarity.
2. Set one SPI clock period for DBT parameter.
Signed-off-by: Gao Pan
Reviewed-by: Han Xu
Signed-off-by: Vipul Kumar -
Add imx6ul device type in spi driver to enable the ERR008517 workaround
or not by dts easily.Signed-off-by: Robin Gong
TODO: checkpatch warnings
Signed-off-by: Vipul Kumar -
To workaroud the TKT238285, the safe way is use XCH mode in SDMA
script to simulate as PIO mode which never report such issue. Meanwhile,
set tx threashold as 0. But this workaroud will bring performance impacted,
below performance data is collected by 'dd' with SPI-NOR flash on i.mx6dl
sabresd board:mode write data read data
--PIO 194KB/s 644KB/s
--DMA normal
(SMC, tx_thresh=32) 222KB/s 1.4MB/s
--DMA(XCH, tx_thresh=0) 210KB/s 1.0MB/sSigned-off-by: Robin Gong
(cherry picked from commit 01be65fa5617aa192307ca38b6fc6128f3f0c3f7)
(cherry picked from commit 646a751a4d1d0e227a762b461d9b8f92605c26b1)
(cherry picked from commit b334993950b24ced30fcfc70c126b65bf4cb4cff)Conflicts:
drivers/spi/spi-imx.c
Signed-off-by: Vipul Kumar -
On i.MX7ULP sillicon, system suspend go through VLLS mode that gate
off pinctrl and modules power, then all registers are reset to HW
default value. To support the feature, driver needs to recover all
registers status.Signed-off-by: Gao Pan
Vipul: Fixes for 4.19 kernel.
Signed-off-by: Vipul Kumar -
SPI IOMUX is changed into reset state in LPSR mode. As a result,
spi can't work again.This patch sets spi IOMUX to default state.
(cherry-picked from commit 2c8603c31831bb355f6be5b015377fb8fbd89844)
Signed-off-by: Gao Pan
Signed-off-by: Vipul Kumar -
This is done in preparation for low power mode. Convert all clk_enable
to clk_prepare_enable and clk_disable to clk_disable_unprepare. Make sure
PLL3 power down when entering low power mode.Signed-off-by: Bai Ping
(cherry picked from commit 1808b31fdae576e775159a05cde9b45e404bb6e2)
Signed-off-by: Vipul Kumar -
There is official workaound for TKT238285, so remove the limitation
for i.mx6dl.Signed-off-by: Robin Gong
Signed-off-by: Vipul Kumar -
We set both wartermark of txfifo and rxfifo 32 as half of fifo length 64.
That will cause easy rxfifo overflow:
If there is 31 bytes in rxfifo, rx script will wait the next dma request
(the 32th data come into the rxfifo) and schedule out to tx script. Once
tx script start to run, the rx script need to wait tx script finish even
if its priority higher than tx. Meanwhile, spi slave device may input
data continuous, plus the rx data which triggered by new tx
script(32 bytes).
That will quickly consume whole 64 bytes fifo, so we keep 16bytes availbale
even in the worst case new tx script triggered during two rx transfer. That
may slow down tx slightly, but better than overflow and RX DMA timeout.Signed-off-by: Robin Gong
(cherry picked from commit 16043ad0ad96aa04a90614e473aa17980af4b8af)
(cherry picked from commit 819efee83b7b1f47685dca6fad6bbe17f1c42092)
(cherry picked from commit 5c4c7d05bbba0ea2b26ef2f3ae83119d5eada235)
Signed-off-by: Vipul Kumar
24 Mar, 2019
2 commits
-
commit ef070b4e4aa25bb5f8632ad196644026c11903bf upstream.
When the commit b6ced294fb61
("spi: pxa2xx: Switch to SPI core DMA mapping functionality")
switches to SPI core provided DMA helpers, it missed to setup maximum
supported DMA transfer length for the controller and thus users
mistakenly try to send more data than supported with the following
warning:ili9341 spi-PRP0001:01: DMA disabled for transfer length 153600 greater than 65536
Setup maximum supported DMA transfer length in order to make users know
the limit.Fixes: b6ced294fb61 ("spi: pxa2xx: Switch to SPI core DMA mapping functionality")
Signed-off-by: Andy Shevchenko
Signed-off-by: Mark Brown
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman -
commit 673c865efbdc5fec3cc525c46d71844d42c60072 upstream.
Commit 4dea6c9b0b64 ("spi: spi-ti-qspi: add mmap mode read support") has
has got order of parameter wrong when calling regmap_update_bits() to
select CS for mmap access. Mask and value arguments are interchanged.
Code will work on a system with single slave, but fails when more than
one CS is in use. Fix this by correcting the order of parameters when
calling regmap_update_bits().Fixes: 4dea6c9b0b64 ("spi: spi-ti-qspi: add mmap mode read support")
Cc: stable@vger.kernel.org
Signed-off-by: Vignesh R
Signed-off-by: Mark Brown
Signed-off-by: Greg Kroah-Hartman
10 Jan, 2019
2 commits
-
commit 29bdedfd9cf40e59456110ca417a8cb672ac9b92 upstream.
Commit e82b0b382845 ("spi: bcm2835: Fix race on DMA termination") broke
the build with COMPILE_TEST=y on arches whose cmpxchg() requires 32-bit
operands (xtensa, older arm ISAs).Fix by changing the dma_pending flag's type from bool to unsigned int.
Fixes: e82b0b382845 ("spi: bcm2835: Fix race on DMA termination")
Signed-off-by: Lukas Wunner
Signed-off-by: Mark Brown
Cc: Frank Pavlic
Cc: Martin Sperl
Cc: Noralf Trønnes
Cc: Sudip Mukherjee
Signed-off-by: Greg Kroah-Hartman -
commit 56c1723426d3cfd4723bfbfce531d7b38bae6266 upstream.
The IRQ handler bcm2835_spi_interrupt() first reads as much as possible
from the RX FIFO, then writes as much as possible to the TX FIFO.
Afterwards it decides whether the transfer is finished by checking if
the TX FIFO is empty.If very few bytes were written to the TX FIFO, they may already have
been transmitted by the time the FIFO's emptiness is checked. As a
result, the transfer will be declared finished and the chip will be
reset without reading the corresponding received bytes from the RX FIFO.The odds of this happening increase with a high clock frequency (such
that the TX FIFO drains quickly) and either passing "threadirqs" on the
command line or enabling CONFIG_PREEMPT_RT_BASE (such that the IRQ
handler may be preempted between filling the TX FIFO and checking its
emptiness).Fix by instead checking whether rx_len has reached zero, which means
that the transfer has been received in full. This is also more
efficient as it avoids one bus read access per interrupt. Note that
bcm2835_spi_transfer_one_poll() likewise uses rx_len to determine
whether the transfer has finished.Signed-off-by: Lukas Wunner
Fixes: e34ff011c70e ("spi: bcm2835: move to the transfer_one driver model")
Cc: stable@vger.kernel.org # v4.1+
Cc: Mathias Duckeck
Cc: Frank Pavlic
Cc: Martin Sperl
Cc: Noralf Trønnes
Signed-off-by: Mark Brown
Signed-off-by: Greg Kroah-Hartman