0133-spi-qup-Remove-chip-select-function.patch 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 9bc674f40f22596ef8c2ff6d7f9e53da0baa57e9 Mon Sep 17 00:00:00 2001
  2. From: Andy Gross <[email protected]>
  3. Date: Thu, 12 Jun 2014 14:34:10 -0500
  4. Subject: [PATCH 133/182] spi: qup: Remove chip select function
  5. This patch removes the chip select function. Chip select should instead be
  6. supported using GPIOs, defining the DT entry "cs-gpios", and letting the SPI
  7. core assert/deassert the chip select as it sees fit.
  8. Signed-off-by: Andy Gross <[email protected]>
  9. ---
  10. .../devicetree/bindings/spi/qcom,spi-qup.txt | 6 ++++
  11. drivers/spi/spi-qup.c | 33 ++++----------------
  12. 2 files changed, 12 insertions(+), 27 deletions(-)
  13. --- a/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
  14. +++ b/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
  15. @@ -23,6 +23,12 @@ Optional properties:
  16. - spi-max-frequency: Specifies maximum SPI clock frequency,
  17. Units - Hz. Definition as per
  18. Documentation/devicetree/bindings/spi/spi-bus.txt
  19. +- num-cs: total number of chipselects
  20. +- cs-gpios: should specify GPIOs used for chipselects.
  21. + The gpios will be referred to as reg = <index> in the SPI child
  22. + nodes. If unspecified, a single SPI device without a chip
  23. + select can be used.
  24. +
  25. SPI slave nodes must be children of the SPI master node and can contain
  26. properties described in Documentation/devicetree/bindings/spi/spi-bus.txt
  27. --- a/drivers/spi/spi-qup.c
  28. +++ b/drivers/spi/spi-qup.c
  29. @@ -424,31 +424,6 @@ static int spi_qup_io_config(struct spi_
  30. return 0;
  31. }
  32. -static void spi_qup_set_cs(struct spi_device *spi, bool enable)
  33. -{
  34. - struct spi_qup *controller = spi_master_get_devdata(spi->master);
  35. -
  36. - u32 iocontol, mask;
  37. -
  38. - iocontol = readl_relaxed(controller->base + SPI_IO_CONTROL);
  39. -
  40. - /* Disable auto CS toggle and use manual */
  41. - iocontol &= ~SPI_IO_C_MX_CS_MODE;
  42. - iocontol |= SPI_IO_C_FORCE_CS;
  43. -
  44. - iocontol &= ~SPI_IO_C_CS_SELECT_MASK;
  45. - iocontol |= SPI_IO_C_CS_SELECT(spi->chip_select);
  46. -
  47. - mask = SPI_IO_C_CS_N_POLARITY_0 << spi->chip_select;
  48. -
  49. - if (enable)
  50. - iocontol |= mask;
  51. - else
  52. - iocontol &= ~mask;
  53. -
  54. - writel_relaxed(iocontol, controller->base + SPI_IO_CONTROL);
  55. -}
  56. -
  57. static int spi_qup_transfer_one(struct spi_master *master,
  58. struct spi_device *spi,
  59. struct spi_transfer *xfer)
  60. @@ -571,12 +546,16 @@ static int spi_qup_probe(struct platform
  61. return -ENOMEM;
  62. }
  63. + /* use num-cs unless not present or out of range */
  64. + if (of_property_read_u16(dev->of_node, "num-cs",
  65. + &master->num_chipselect) ||
  66. + (master->num_chipselect > SPI_NUM_CHIPSELECTS))
  67. + master->num_chipselect = SPI_NUM_CHIPSELECTS;
  68. +
  69. master->bus_num = pdev->id;
  70. master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
  71. - master->num_chipselect = SPI_NUM_CHIPSELECTS;
  72. master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
  73. master->max_speed_hz = max_freq;
  74. - master->set_cs = spi_qup_set_cs;
  75. master->transfer_one = spi_qup_transfer_one;
  76. master->dev.of_node = pdev->dev.of_node;
  77. master->auto_runtime_pm = true;