104-spi-img-spfi-use-device-0-configuration-for-all-devi.patch 2.4 KB

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