Commit Graph

854451 Commits

Author SHA1 Message Date
Jianqun Xu
f27d8c9975 spi: rockchip: get pinctrl for lookup pinctrl state
Fix system crash issue when spi dev has no correct pinctrl handle.

Fixes: 87dbea63d5 ("spi: rockchip: set higher io driver when sclk higher than 24MHz")
Change-Id: I603fe8f74681b576fe7fcd404a386ec2b2c03da4
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2020-07-17 10:38:30 +08:00
Elaine Zhang
6d1fd05b9d net: can: add rockchip CANFD driver
Change-Id: Ie49293531038583e7d0d4b8055dba3e8f026d734
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2020-07-16 15:10:00 +08:00
Elaine Zhang
ebe6e465c4 dt-bindings: can: rockchip_canfd: add canfd support for rockchip
This patch add the rockchip canfd to the device tree bindings
documentation.

Change-Id: Ief6ffeeda87e28e8b70a706c92eba526e0db0686
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2020-07-16 15:10:00 +08:00
Jianqun Xu
389fe61846 ARM: dts: rv11xx-evb-v10.dtsi export wireless-wlan node
Since wireless-wlan node uses gpio as:
WIFI,host_wake_irq = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>;

It should allow to disable the node.

Change-Id: I27cc8acbb84025ae5f8e76e4c3e7aee36907729e
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2020-07-16 15:01:13 +08:00
Liang Chen
51d4aae73f sched/fair: optimize scheduler for performance
1. init util_avg of new task to half the util of big core.
2. treat task wait time as busy time.
3. do not put task to the cpu whose max util can not fit the task.
4. boost cpufreq when a task is wakeup.

if prefer powersave, we can disable this optimization by command:

echo 0 > /proc/sys/kernel/sched_performance_bias

Change-Id: I937d1cc2295645a1d044e0735ef575b6507bb752
Signed-off-by: Liang Chen <cl@rock-chips.com>
2020-07-16 14:50:45 +08:00
Liang Chen
2d367d61e8 cpufreq: interactive: introduce boost cpufreq interface for task
boost cpufreq for a task if current capacity is not fit for the task.

Change-Id: I85cfeaeb6d8fcface8f6534bb95b5baf3bfc839f
Signed-off-by: Liang Chen <cl@rock-chips.com>
2020-07-16 14:49:37 +08:00
Finley Xiao
f555437199 clk: rockchip: rv1126: Fix some clks' parent when CONFIG_ROCKCHIP_THUNDER_BOOT=y
Fixes: 1980c11fab ("clk: rockchip: rv1126: Remove more clks when CONFIG_ROCKCHIP_THUNDER_BOOT=y")
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: Ic9dce77658aa613fc5f0ff41261a43ca5884dab5
2020-07-16 11:37:32 +08:00
Wyon Bi
7c959b40c9 drm/bridge: analogix_dp: Fix the logic of prepare/unprepare the panel
This patch avoids frequent prepare/unprepare the panel, and keep
the current state until the panel is disabled.

Change-Id: I0148ab85779df6ef447796d2f07eb46315813d56
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2020-07-15 09:34:08 +08:00
Wyon Bi
14fbe98150 drm/bridge: analogix_dp: allows to get edid for the panel
Change-Id: I7caba18fb979ad2b8f419c58f989b27d3e756ebf
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2020-07-15 09:34:08 +08:00
Wyon Bi
c49c170321 drm/bridge: analogix_dp: Fix aux not work before modeset
Change-Id: I8b00df83d5c3a17b0c73dba66d06a20c55575209
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2020-07-15 09:34:08 +08:00
zain wang
53a9ebd3b3 FROMLIST: drm/bridge: analogix_dp: Don't return -EBUSY when msg->size is 0 in aux transaction
The analogix_dp_transfer() will return -EBUSY if num_transferred is zero.
But sometimes we will send a bare address packet to start the transaction,
like drm_dp_i2c_xfer() show:
	......
	/* Send a bare address packet to start the transaction.
	 * Zero sized messages specify an address only (bare
	 * address) transaction.
	 */
	msg.buffer = NULL;
	msg.size = 0;
	err = drm_dp_i2c_do_msg(aux, &msg);
	......

In this case, the msg->size is zero, so the num_transferred will be zero too.
We can't return -EBUSY here, let's we return num_transferred if num_transferred
equals msg->size.

BUG=chrome-os-partner:57501
TEST="gooftool probe --comps display_panel"

Change-Id: Ie09f26b2c31e2406d21233afd8677337de5e77f2
Signed-off-by: zain wang <wzz@rock-chips.com>
(am from https://patchwork.kernel.org/patch/9569045/)
Reviewed-on: https://chromium-review.googlesource.com/414674
Commit-Ready: Caesar Wang <wxt@rock-chips.com>
Tested-by: 征增 王 <wzz@rock-chips.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
2020-07-15 09:34:08 +08:00
Wyon Bi
d72fbd047b drm/panel: simple: allows mode info not to be described in the device tree
Change-Id: I4a5048dd9d590011216966817c3109dbbbde3164
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2020-07-15 09:34:08 +08:00
Wyon Bi
5beeda4a26 drm/bridge: analogix_dp: Add loader protect for psr function
Change-Id: Iffb651d3dbb11797b82ed2679e990b8c9610b200
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2020-07-15 09:34:08 +08:00
Ren Jianing
55c7a54911 usb: gadget: u_audio: add uevent for set_alt and set_srate
This patch add uevent to notify the application layer when it should
playback or capture and setting the accuration sample rate.

The event consists of three parts, namely USB_STATE, STREAM_DIRECTION
and STREAM_STATE. For example:

g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=IN STREAM_STATE=OFF
g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=OUT STREAM_STATE=ON
g_audio_work: sent uac uevent USB_STATE=SET_SAMPLE_RATE STREAM_DIRECTION=OUT SAMPLE_RATE=44100

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: Ia01572d92d0c3ae40b19e772571282b8806da9e5
2020-07-15 09:31:34 +08:00
Ren Jianing
a322b6c50d FROMLIST: usb: gadget: f_uac*: Support multiple sampling rates
Implement support for multiple sampling rates in the USB Audio gadgets.
A list of sampling rates can be specified via configfs. All enabled
sampling rates are sent to the USB host on request. When the host
selects a sampling rate the internal active rate is updated. The
currently configured rates are exposed through amixer controls. Also on
pcm open from userspace the requested rated is checked against the
currently configured rate of the host.

Link: https://lore.kernel.org/patchwork/patch/805286/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: I43dc28462062c9aa179c2b9c8e7e50c307137874
2020-07-15 09:31:34 +08:00
Ren Jianing
9de5fa6df1 FROMLIST: usb: gadget: f_uac*: Reduce code duplication
This replaces the dedicated headers for uac1 and uac2 functions with a
shared header for both of them. Apart from unifying the struct names,
further duplicated code for configfs setup is moved out of the function
files into the shared header.

Link: https://lore.kernel.org/patchwork/patch/805285/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: Ie866bd02f174dc91168fe0bc49b571a77d849a42
2020-07-15 09:31:34 +08:00
Julian Scheel
9cc791ff36 FROMLIST: usb: gadget: f_uac1: Fix endpoint reading
The endpoint is stored in the lower byte of wIndex, according to USB
Audio 1.0 specification, section 5.2.1.1.

Link: https://lore.kernel.org/patchwork/patch/805284/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: I16634151e98cfb0f7107e96463a20b8fa8d7072f
2020-07-15 09:31:34 +08:00
William Wu
10e9abc766 ARM: dts: rockchip: enable txfifo resize for rv1126 usb
RV1126 EVB USB gadget maybe used as UVC function which
needs to resize txfifo to improve isoc ep throughput,
so this patch adds "snps,tx-fifo-resize" property to
enable txfifo resize.

Change-Id: I00447fb252a093acb24525b12479f67662d9dfe3
Signed-off-by: William Wu <william.wu@rock-chips.com>
2020-07-14 19:25:26 +08:00
William Wu
5d4fc6626d usb: dwc3: gadget: fix the txfifo resize for isoc ep
The dwc3 driver sets the mult to 6 and alloc 0x307 * 8 Bytes
for each isoc ep txfifo. It aims to improve isoc ep throughput,
but it's wasteful.

This patch sets the mult to dep->endpoint.mult * 2 for each isoc
ep, it's enough to improve isoc ep throughput, and it can avoid
exceeding the total size of txfifo if multiple isoc eps are used
at the same time.

Change-Id: I01d77d19b85e5f5930ff94ef40714129afe10b54
Signed-off-by: William Wu <william.wu@rock-chips.com>
2020-07-14 19:18:03 +08:00
XiaoDong Huang
50151fc7a3 regulator: tps549b22: add TI TPS549b22 support
Change-Id: I7550fc9f78a30b5d8ff705403ad91cfd8727fad6
Signed-off-by: XiaoDong Huang <derrick.huang@rock-chips.com>
2020-07-14 16:17:40 +08:00
William Wu
432a0d89dd usb: dwc3: core: reset the whole controller during probe
This patch reset the dwc3 controller at the beginning of
probe. Without this patch, it may fail in enumeration phase
if the dwc3 has been initialized and used before kernel.

Typically, we use usb to download image and boot directly
on RV1126 board, it will fail to connect to host with the
following error log:

[2.029506] read descriptors
[2.029597] read strings
[3.038749] dwc3 ffd00000.dwc3: unexpected direction for Data Phase
[3.077445] android_work: did not send uevent (0 0   (null))
[3.282586] vendor storage:20190527 ret = -1
[3.335505] usb0: HOST MAC 16:ba:52:5a:90:28
[3.335566] usb0: MAC 6a:73:d9:da:da:ce
[3.335597] configfs-gadget gadget: uvc_function_bind
[5.052086] dwc3 ffd00000.dwc3: unexpected direction for Data Phase
[5.052431] dwc3 ffd00000.dwc3: unexpected direction for Data Phase

Change-Id: I7eede4685a26cff5fc9460233291757edf18e430
Signed-off-by: William Wu <william.wu@rock-chips.com>
2020-07-14 16:16:34 +08:00
Yiqing Zeng
82f893648d media: i2c: os04a10 changed supported mode to 10bit@30fps by default
Signed-off-by: Yiqing Zeng <zack.zeng@rock-chips.com>
Change-Id: I1a6e94bd36ff09c2964251d1c0ad83ed7f577c47
2020-07-14 14:28:13 +08:00
Sandy Huang
af3bfcd5cf drm/rockchip: add rockchip_drm_get_sub_dev_type
1. before this, the DMC driver use drm_device_get_by_name() to get drm
connector info, now we use rockchip_drm_get_sub_dev_type() to instead of
it.
2. export rockchip drm sub dev functions.

Change-Id: Ief6546d933fbb49e46e6e8d2a99464eb5951e069
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
2020-07-13 20:47:09 +08:00
David Wu
42f500840d i2c: rk3x: Remove start state and irq
Let configuration start and count be performed at the
same time as much as possible, which can reduce the
interval between the start signal and the data signal,
and can also reduce a start irq.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Change-Id: I529300a083dcd264cc5f25a2069b88601cade83e
2020-07-13 20:28:00 +08:00
Jon Lin
ab08158001 spi: rockchip: Fix error in SPI slave pio read
Maybe RXFLR is larger than rx_left

Change-Id: Ic851d68250ba9cbe73c00ba40a925542e5505265
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2020-07-13 20:23:29 +08:00
Mark Brown
ce3a66e6df UPSTREAM: spi: Fix core transfer waits after slave support
The refactoring done as part of adding the core support for handling
waiting for slave transfer dropped a conditional which meant that we
started waiting for completion of all transfers, not just those that the
controller asked for.  This caused hangs and massive delays on platforms
that don't need the core delay.  Re-add the delay to fix this.

Fixes: 810923f3bf (spi: Deal with slaves that return from transfer_one() unfinished)
Change-Id: I8fe4c6d42bc7c64d9c9b6803d154ec169752283f
Reported-by: Tony Lindgren <tony@atomide.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d57e79601b)
2020-07-13 20:22:07 +08:00
Lubomir Rintel
da31d8c6af UPSTREAM: spi: Deal with slaves that return from transfer_one() unfinished
Some drivers, such as spi-pxa2xx return from the transfer_one callback
immediately, idicating that the transfer will be finished asynchronously.

Normally, spi_transfer_one_message() synchronously waits for the
transfer to finish with wait_for_completion_timeout(). For slaves, we
don't want the transaction to time out as it can complete in a long time
in future. Use wait_for_completion_interruptible() instead.

Change-Id: I166415911f30fc821fca73b0250f6350b835e8c0
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 810923f3bf)
2020-07-13 20:22:07 +08:00
Phil Elwell
4c5472af2c UPSTREAM: spi: Make GPIO CSs honour the SPI_NO_CS flag
The SPI configuration state includes an SPI_NO_CS flag that disables
all CS line manipulation, for applications that want to manage their
own chip selects. However, this flag is ignored by the GPIO CS code
in the SPI framework.

Correct this omission with a trivial patch.

Change-Id: I75e69b1eb5068357d9abfe8236cfbd2188c626f1
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 25972d0c33)
2020-07-13 20:22:07 +08:00
Trent Piepho
93f999e60a UPSTREAM: spi: Add driver_override SPI device attribute
This attribute works the same was as the identically named attribute
for PCI, AMBA, and platform devices.  For reference, see:

commit 3cf3857134 ("ARM: 8256/1: driver coamba: add device binding
path 'driver_override'")
commit 3d713e0e38 ("driver core: platform: add device binding path
'driver_override'")
commit 782a985d7a ("PCI: Introduce new device binding path using
pci_dev.driver_override")

If the name of a driver is written to this attribute, then the device
will bind to the named driver and only the named driver.

The device will bind to the driver even if the driver does not list the
device in its id table.  This behavior is different than the driver's
bind attribute, which only allows binding to devices that are listed as
supported by the driver.

It can be used to bind a generic driver, like spidev, to a device.

Change-Id: Ieb82f7cf3c17b6b928588a5a17f35481ac6b3338
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Tested-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 5039563e7c)
2020-07-13 20:22:07 +08:00
Marco Felsch
2cc2663961 UPSTREAM: spi: make OF helper available for others
The of_find_spi_device_by_node() helper function is useful for other
modules too. Export the funciton as GPL like all other spi helper
functions and make it available if CONFIG_OF is enabled, because it isn't
related to the CONFIG_OF_DYNAMIC context. Finally add a stub if
CONFIG_OF isn't enabled, so others must not care about it.

Change-Id: If74acbf7ccefa3cec88dfb8fa1d4f39b333c5c48
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 5f143af750)
2020-07-13 20:22:07 +08:00
Marco Felsch
f4364459a4 UPSTREAM: spi: switch to SPDX license identifier
Use the appropriate SPDX license identifier and drop the previous
license text.

Change-Id: Ie3b822af5c7ddc9ae515a36713d407fe4725e3dc
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b445bfcb90)
2020-07-13 20:22:07 +08:00
David Lechner
361d08ea0f UPSTREAM: spi: always use software fallback for SPI_CS_WORD when using cs_gio
This modifies the condition for using the software fallback
implementation for SPI_CS_WORD when the SPI controller is using a GPIO
for the CS line. When using a GPIO for CS, the hardware implementation
won't work, so we just enable the software fallback globally in this
case.

Change-Id: I6d8320e51bd786ffa834f2ce8dd3a6799bec9b19
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 71388b2156)
2020-07-13 20:22:07 +08:00
David Lechner
4353a70bdb UPSTREAM: spi: add software implementation for SPI_CS_WORD
This adds a default software implementation for the SPI_CS_WORD flag for
controllers that don't have such a feature.

The SPI_CS_WORD flag indicates that the CS line should be toggled
between each word sent, not just between each transfer. The
implementation works by using existing functions to split transfers into
one-word-sized transfers and sets the cs_change bit for each of the
new transfers.

Change-Id: Iaf210b28f14ae7319e689ef5c411d8a17fdd04ce
Signed-off-by: David Lechner <david@lechnology.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit cbaa62e009)
2020-07-13 20:22:07 +08:00
David Lechner
d41a1fe15e UPSTREAM: spi: add new SPI_CS_WORD flag
This adds a new SPI mode flag, SPI_CS_WORD, that is used to indicate
that a SPI device requires the chip select to be toggled after each
word that is transferred.

Change-Id: I967cbbef8f8c31bb40d52f74f9ae0b2297553819
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 0baf9eb255)
2020-07-13 20:22:07 +08:00
Baolin Wang
cc62f47077 UPSTREAM: spi: Introduce one new field to set word delay
For some SPI controllers, after each word size (specified by bits_per_word)
transimission, the hardware need some delay to make sure the slave has enough
time to receive the whole data.

So introducing one new 'word_delay' field of struct spi_tansfer for slave
devices to set this inter word delay time.

Change-Id: I1329a3cfa3818d43bea7d316b452d6f2becae6f7
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit eeaceb8b7d)
2020-07-13 20:22:07 +08:00
Chris Ruehl
a2149a6781 UPSTREAM: spi: spi-rockchip: add support for spi slave mode
Add support for spi slave mode in spi-rockchip. The register map has an entry
for it. If spi-slave is set in dts, set this corresponding bit and add to
mode_bits the SPI_NO_CS, allow slave mode without explicit CS use.
Slave abort function had been added.

Change-Id: I964fa2f1ada1bc5ad7e421d5ad617fa22a51128e
Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Link: https://lore.kernel.org/r/20200511083022.23678-3-chris.ruehl@gtsys.com.hk
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d065f41a3f)
2020-07-13 20:11:19 +08:00
Chris Ruehl
ef5f97a27d UPSTREAM: spi: spi-rockchip: cleanup use struct spi_controller
Cleanup, move from the compatibily layer struct spi_master over
to struct spi_controller, and rename the related function calls.

Change-Id: I7b999ff4aa43ed30b892c93d318859f5ad1934bd
Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Link: https://lore.kernel.org/r/20200511083022.23678-2-chris.ruehl@gtsys.com.hk
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d66571a20f)
2020-07-13 20:11:10 +08:00
Emil Renner Berthing
7d7c262975 UPSTREAM: spi: rockchip: turn down tx dma bursts
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)
2020-07-13 20:10:45 +08:00
Emil Renner Berthing
891bf112bd UPSTREAM: spi: rockchip: support lsb-first mode
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)
2020-07-13 20:10:11 +08:00
Emil Renner Berthing
351b34607e UPSTREAM: spi: rockchip: support 4bit words
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)
2020-07-13 20:10:03 +08:00
Emil Renner Berthing
bd3464ceb3 UPSTREAM: spi: rockchip: use irq rather than polling
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)
2020-07-13 20:09:52 +08:00
Emil Renner Berthing
f6d739b0da UPSTREAM: spi: rockchip: precompute rx sample delay
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)
2020-07-13 20:09:40 +08:00
Emil Renner Berthing
39bce059c0 UPSTREAM: spi: rockchip: set min/max speed
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)
2020-07-13 20:09:30 +08:00
Emil Renner Berthing
5f8bf41df5 UPSTREAM: spi: rockchip: simplify use_dma logic
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)
2020-07-13 20:09:20 +08:00
Emil Renner Berthing
9378f64680 UPSTREAM: spi: rockchip: remove master pointer from dev data
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)
2020-07-13 20:09:06 +08:00
Emil Renner Berthing
ea2f9daa4c UPSTREAM: spi: rockchip: don't store dma channels twice
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)
2020-07-13 20:08:48 +08:00
Emil Renner Berthing
2f8a03b661 UPSTREAM: spi: rockchip: read transfer info directly
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)
2020-07-13 20:06:19 +08:00
Emil Renner Berthing
da6324822d UPSTREAM: spi: rockchip: disable spi on error
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)
2020-07-13 20:06:06 +08:00
Emil Renner Berthing
9729a03ade UPSTREAM: spi: rockchip: use atomic_t state
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)
2020-07-13 20:05:51 +08:00
Emil Renner Berthing
6097c07d90 UPSTREAM: spi: rockchip: always use SPI mode
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)
2020-07-13 20:05:02 +08:00