001-4.12-06-spi-bcm63xx-hsspi-add-support-for-probing-through-de.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From 776041498c2b285a7f745c924e10fc11ef720eae Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <[email protected]>
  3. Date: Thu, 10 Sep 2015 14:53:53 +0200
  4. Subject: [PATCH 3/3] spi/bcm63xx-hsspi: allow for probing through devicetree
  5. Add required binding support to probe through device tree.
  6. Signed-off-by: Jonas Gorski <[email protected]>
  7. ---
  8. drivers/spi/spi-bcm63xx-hsspi.c | 23 ++++++++++++++++++++---
  9. 1 file changed, 20 insertions(+), 3 deletions(-)
  10. --- a/drivers/spi/spi-bcm63xx-hsspi.c
  11. +++ b/drivers/spi/spi-bcm63xx-hsspi.c
  12. @@ -19,6 +19,7 @@
  13. #include <linux/interrupt.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/mutex.h>
  16. +#include <linux/of.h>
  17. #define HSSPI_GLOBAL_CTRL_REG 0x0
  18. #define GLOBAL_CTRL_CS_POLARITY_SHIFT 0
  19. @@ -91,6 +92,7 @@
  20. #define HSSPI_MAX_SYNC_CLOCK 30000000
  21. +#define HSSPI_SPI_MAX_CS 8
  22. #define HSSPI_BUS_NUM 1 /* 0 is legacy SPI */
  23. struct bcm63xx_hsspi {
  24. @@ -332,7 +334,7 @@ static int bcm63xx_hsspi_probe(struct pl
  25. struct device *dev = &pdev->dev;
  26. struct clk *clk;
  27. int irq, ret;
  28. - u32 reg, rate;
  29. + u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
  30. irq = platform_get_irq(pdev, 0);
  31. if (irq < 0) {
  32. @@ -382,8 +384,17 @@ static int bcm63xx_hsspi_probe(struct pl
  33. mutex_init(&bs->bus_mutex);
  34. init_completion(&bs->done);
  35. - master->bus_num = HSSPI_BUS_NUM;
  36. - master->num_chipselect = 8;
  37. + master->dev.of_node = dev->of_node;
  38. + if (!dev->of_node)
  39. + master->bus_num = HSSPI_BUS_NUM;
  40. +
  41. + of_property_read_u32(dev->of_node, "num-cs", &num_cs);
  42. + if (num_cs > 8) {
  43. + dev_warn(dev, "unsupported number of cs (%i), reducing to 8\n",
  44. + num_cs);
  45. + num_cs = HSSPI_SPI_MAX_CS;
  46. + }
  47. + master->num_chipselect = num_cs;
  48. master->setup = bcm63xx_hsspi_setup;
  49. master->transfer_one_message = bcm63xx_hsspi_transfer_one;
  50. master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
  51. @@ -469,10 +480,16 @@ static int bcm63xx_hsspi_resume(struct d
  52. static SIMPLE_DEV_PM_OPS(bcm63xx_hsspi_pm_ops, bcm63xx_hsspi_suspend,
  53. bcm63xx_hsspi_resume);
  54. +static const struct of_device_id bcm63xx_hsspi_of_match[] = {
  55. + { .compatible = "brcm,bcm6328-hsspi", },
  56. + { },
  57. +};
  58. +
  59. static struct platform_driver bcm63xx_hsspi_driver = {
  60. .driver = {
  61. .name = "bcm63xx-hsspi",
  62. .pm = &bcm63xx_hsspi_pm_ops,
  63. + .of_match_table = bcm63xx_hsspi_of_match,
  64. },
  65. .probe = bcm63xx_hsspi_probe,
  66. .remove = bcm63xx_hsspi_remove,