pistachio: add kernel 4.14 support
[openwrt/openwrt.git] / target / linux / pistachio / patches-4.14 / 104-spi-img-spfi-use-device-0-configuration-for-all-devi.patch
1 From 905ee06a9966113fe51d6bad1819759cb30fd0bd Mon Sep 17 00:00:00 2001
2 From: Ionela Voinescu <ionela.voinescu@imgtec.com>
3 Date: Tue, 9 Feb 2016 10:18:31 +0000
4 Subject: spi: img-spfi: use device 0 configuration for all devices
5
6 Given that we control the chip select line externally
7 we can use only one parameter register (device 0 parameter
8 register) and one set of configuration bits (port configuration
9 bits for device 0) for all devices (all chip select lines).
10
11 Signed-off-by: Ionela Voinescu <ionela.voinescu@imgtec.com>
12 ---
13 drivers/spi/spi-img-spfi.c | 23 ++++++++++++++++-------
14 1 file changed, 16 insertions(+), 7 deletions(-)
15
16 --- a/drivers/spi/spi-img-spfi.c
17 +++ b/drivers/spi/spi-img-spfi.c
18 @@ -437,18 +437,23 @@ static int img_spfi_prepare(struct spi_m
19 struct img_spfi *spfi = spi_master_get_devdata(master);
20 u32 val;
21
22 + /*
23 + * The chip select line is controlled externally so
24 + * we can use the CS0 configuration for all devices
25 + */
26 val = spfi_readl(spfi, SPFI_PORT_STATE);
27 +
28 + /* 0 for device selection */
29 val &= ~(SPFI_PORT_STATE_DEV_SEL_MASK <<
30 SPFI_PORT_STATE_DEV_SEL_SHIFT);
31 - val |= msg->spi->chip_select << SPFI_PORT_STATE_DEV_SEL_SHIFT;
32 if (msg->spi->mode & SPI_CPHA)
33 - val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
34 + val |= SPFI_PORT_STATE_CK_PHASE(0);
35 else
36 - val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
37 + val &= ~SPFI_PORT_STATE_CK_PHASE(0);
38 if (msg->spi->mode & SPI_CPOL)
39 - val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
40 + val |= SPFI_PORT_STATE_CK_POL(0);
41 else
42 - val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
43 + val &= ~SPFI_PORT_STATE_CK_POL(0);
44 spfi_writel(spfi, val, SPFI_PORT_STATE);
45
46 return 0;
47 @@ -548,11 +553,15 @@ static void img_spfi_config(struct spi_m
48 div = DIV_ROUND_UP(clk_get_rate(spfi->spfi_clk), xfer->speed_hz);
49 div = clamp(512 / (1 << get_count_order(div)), 1, 128);
50
51 - val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi->chip_select));
52 + /*
53 + * The chip select line is controlled externally so
54 + * we can use the CS0 parameters for all devices
55 + */
56 + val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(0));
57 val &= ~(SPFI_DEVICE_PARAMETER_BITCLK_MASK <<
58 SPFI_DEVICE_PARAMETER_BITCLK_SHIFT);
59 val |= div << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT;
60 - spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi->chip_select));
61 + spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(0));
62
63 if (!list_is_last(&xfer->transfer_list, &master->cur_msg->transfers) &&
64 /*