aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-gpio.c
diff options
context:
space:
mode:
authorTorsten Fleischer <torfl6749@gmail.com>2014-11-03 11:17:55 -0500
committerMark Brown <broonie@kernel.org>2014-11-04 14:57:25 -0500
commitd1d81802522ade84128a2c66c0d500e372474dca (patch)
tree971fe9a68d1fcc2823d5ab6cf90b0e0c6d8a9eef /drivers/spi/spi-gpio.c
parentf114040e3ea6e07372334ade75d1ee0775c355e1 (diff)
spi: spi-gpio: Add dt support for a single device with no chip select
In order to describe a single slave device that has no chip select line the 'num-chipselects' property has to be <0> and the 'cs-gpios' property doesn't need to be set. Signed-off-by: Torsten Fleischer <torfl6749@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-gpio.c')
-rw-r--r--drivers/spi/spi-gpio.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 9f595535cf27..f0492c99d145 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -413,6 +413,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
413 struct spi_gpio_platform_data *pdata; 413 struct spi_gpio_platform_data *pdata;
414 u16 master_flags = 0; 414 u16 master_flags = 0;
415 bool use_of = 0; 415 bool use_of = 0;
416 int num_devices;
416 417
417 status = spi_gpio_probe_dt(pdev); 418 status = spi_gpio_probe_dt(pdev);
418 if (status < 0) 419 if (status < 0)
@@ -422,16 +423,21 @@ static int spi_gpio_probe(struct platform_device *pdev)
422 423
423 pdata = dev_get_platdata(&pdev->dev); 424 pdata = dev_get_platdata(&pdev->dev);
424#ifdef GENERIC_BITBANG 425#ifdef GENERIC_BITBANG
425 if (!pdata || !pdata->num_chipselect) 426 if (!pdata || (!use_of && !pdata->num_chipselect))
426 return -ENODEV; 427 return -ENODEV;
427#endif 428#endif
428 429
430 if (use_of && !SPI_N_CHIPSEL)
431 num_devices = 1;
432 else
433 num_devices = SPI_N_CHIPSEL;
434
429 status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags); 435 status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags);
430 if (status < 0) 436 if (status < 0)
431 return status; 437 return status;
432 438
433 master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) + 439 master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) +
434 (sizeof(int) * SPI_N_CHIPSEL)); 440 (sizeof(int) * num_devices));
435 if (!master) { 441 if (!master) {
436 status = -ENOMEM; 442 status = -ENOMEM;
437 goto gpio_free; 443 goto gpio_free;
@@ -446,7 +452,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
446 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); 452 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
447 master->flags = master_flags; 453 master->flags = master_flags;
448 master->bus_num = pdev->id; 454 master->bus_num = pdev->id;
449 master->num_chipselect = SPI_N_CHIPSEL; 455 master->num_chipselect = num_devices;
450 master->setup = spi_gpio_setup; 456 master->setup = spi_gpio_setup;
451 master->cleanup = spi_gpio_cleanup; 457 master->cleanup = spi_gpio_cleanup;
452#ifdef CONFIG_OF 458#ifdef CONFIG_OF
@@ -461,9 +467,12 @@ static int spi_gpio_probe(struct platform_device *pdev)
461 * property of the node. 467 * property of the node.
462 */ 468 */
463 469
464 for (i = 0; i < SPI_N_CHIPSEL; i++) 470 if (!SPI_N_CHIPSEL)
465 spi_gpio->cs_gpios[i] = 471 spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT;
466 of_get_named_gpio(np, "cs-gpios", i); 472 else
473 for (i = 0; i < SPI_N_CHIPSEL; i++)
474 spi_gpio->cs_gpios[i] =
475 of_get_named_gpio(np, "cs-gpios", i);
467 } 476 }
468#endif 477#endif
469 478