pistachio: add 4.9 kernel support
[librecmc/librecmc.git] / target / linux / pistachio / patches-4.9 / 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 diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
17 index 0d73d31..231b59c 100644
18 --- a/drivers/spi/spi-img-spfi.c
19 +++ b/drivers/spi/spi-img-spfi.c
20 @@ -437,18 +437,23 @@ static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg)
21         struct img_spfi *spfi = spi_master_get_devdata(master);
22         u32 val;
23  
24 +       /*
25 +        * The chip select line is controlled externally so
26 +        * we can use the CS0 configuration for all devices
27 +        */
28         val = spfi_readl(spfi, SPFI_PORT_STATE);
29 +
30 +       /* 0 for device selection */
31         val &= ~(SPFI_PORT_STATE_DEV_SEL_MASK <<
32                  SPFI_PORT_STATE_DEV_SEL_SHIFT);
33 -       val |= msg->spi->chip_select << SPFI_PORT_STATE_DEV_SEL_SHIFT;
34         if (msg->spi->mode & SPI_CPHA)
35 -               val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
36 +               val |= SPFI_PORT_STATE_CK_PHASE(0);
37         else
38 -               val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
39 +               val &= ~SPFI_PORT_STATE_CK_PHASE(0);
40         if (msg->spi->mode & SPI_CPOL)
41 -               val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
42 +               val |= SPFI_PORT_STATE_CK_POL(0);
43         else
44 -               val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
45 +               val &= ~SPFI_PORT_STATE_CK_POL(0);
46         spfi_writel(spfi, val, SPFI_PORT_STATE);
47  
48         return 0;
49 @@ -548,11 +553,15 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi,
50         div = DIV_ROUND_UP(clk_get_rate(spfi->spfi_clk), xfer->speed_hz);
51         div = clamp(512 / (1 << get_count_order(div)), 1, 128);
52  
53 -       val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi->chip_select));
54 +       /*
55 +        * The chip select line is controlled externally so
56 +        * we can use the CS0 parameters for all devices
57 +        */
58 +       val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(0));
59         val &= ~(SPFI_DEVICE_PARAMETER_BITCLK_MASK <<
60                  SPFI_DEVICE_PARAMETER_BITCLK_SHIFT);
61         val |= div << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT;
62 -       spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi->chip_select));
63 +       spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(0));
64  
65         if (!list_is_last(&xfer->transfer_list, &master->cur_msg->transfers) &&
66                 /*
67 -- 
68 2.7.4
69