]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.9/spi-rockchip-make-sure-spi-clk-is-on-in-rockchip_spi_set_cs.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.9 / spi-rockchip-make-sure-spi-clk-is-on-in-rockchip_spi_set_cs.patch
1 From b920cc3191d7612f26f36ee494e05b5ffd9044c0 Mon Sep 17 00:00:00 2001
2 From: Huibin Hong <huibin.hong@rock-chips.com>
3 Date: Wed, 24 Feb 2016 18:00:04 +0800
4 Subject: spi/rockchip: Make sure spi clk is on in rockchip_spi_set_cs
5
6 From: Huibin Hong <huibin.hong@rock-chips.com>
7
8 commit b920cc3191d7612f26f36ee494e05b5ffd9044c0 upstream.
9
10 Rockchip_spi_set_cs could be called by spi_setup, but
11 spi_setup may be called by device driver after runtime suspend.
12 Then the spi clock is closed, rockchip_spi_set_cs may access the
13 spi registers, which causes cpu block in some socs.
14
15 Fixes: 64e36824b32 ("spi/rockchip: add driver for Rockchip RK3xxx")
16 Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
17 Signed-off-by: Mark Brown <broonie@kernel.org>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 drivers/spi/spi-rockchip.c | 7 ++++++-
22 1 file changed, 6 insertions(+), 1 deletion(-)
23
24 --- a/drivers/spi/spi-rockchip.c
25 +++ b/drivers/spi/spi-rockchip.c
26 @@ -265,7 +265,10 @@ static inline u32 rx_max(struct rockchip
27 static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
28 {
29 u32 ser;
30 - struct rockchip_spi *rs = spi_master_get_devdata(spi->master);
31 + struct spi_master *master = spi->master;
32 + struct rockchip_spi *rs = spi_master_get_devdata(master);
33 +
34 + pm_runtime_get_sync(rs->dev);
35
36 ser = readl_relaxed(rs->regs + ROCKCHIP_SPI_SER) & SER_MASK;
37
38 @@ -290,6 +293,8 @@ static void rockchip_spi_set_cs(struct s
39 ser &= ~(1 << spi->chip_select);
40
41 writel_relaxed(ser, rs->regs + ROCKCHIP_SPI_SER);
42 +
43 + pm_runtime_put_sync(rs->dev);
44 }
45
46 static int rockchip_spi_prepare_message(struct spi_master *master,