mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 23:20:58 +07:00
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>
This commit is contained in:
parent
f114040e3e
commit
d1d8180252
@ -8,8 +8,10 @@ Required properties:
|
|||||||
- gpio-sck: GPIO spec for the SCK line to use
|
- gpio-sck: GPIO spec for the SCK line to use
|
||||||
- gpio-miso: GPIO spec for the MISO line to use
|
- gpio-miso: GPIO spec for the MISO line to use
|
||||||
- gpio-mosi: GPIO spec for the MOSI line to use
|
- gpio-mosi: GPIO spec for the MOSI line to use
|
||||||
- cs-gpios: GPIOs to use for chipselect lines
|
- cs-gpios: GPIOs to use for chipselect lines.
|
||||||
- num-chipselects: number of chipselect lines
|
Not needed if num-chipselects = <0>.
|
||||||
|
- num-chipselects: Number of chipselect lines. Should be <0> if a single device
|
||||||
|
with no chip select is connected.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -413,6 +413,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
|
|||||||
struct spi_gpio_platform_data *pdata;
|
struct spi_gpio_platform_data *pdata;
|
||||||
u16 master_flags = 0;
|
u16 master_flags = 0;
|
||||||
bool use_of = 0;
|
bool use_of = 0;
|
||||||
|
int num_devices;
|
||||||
|
|
||||||
status = spi_gpio_probe_dt(pdev);
|
status = spi_gpio_probe_dt(pdev);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
@ -422,16 +423,21 @@ static int spi_gpio_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
pdata = dev_get_platdata(&pdev->dev);
|
pdata = dev_get_platdata(&pdev->dev);
|
||||||
#ifdef GENERIC_BITBANG
|
#ifdef GENERIC_BITBANG
|
||||||
if (!pdata || !pdata->num_chipselect)
|
if (!pdata || (!use_of && !pdata->num_chipselect))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (use_of && !SPI_N_CHIPSEL)
|
||||||
|
num_devices = 1;
|
||||||
|
else
|
||||||
|
num_devices = SPI_N_CHIPSEL;
|
||||||
|
|
||||||
status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags);
|
status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) +
|
master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) +
|
||||||
(sizeof(int) * SPI_N_CHIPSEL));
|
(sizeof(int) * num_devices));
|
||||||
if (!master) {
|
if (!master) {
|
||||||
status = -ENOMEM;
|
status = -ENOMEM;
|
||||||
goto gpio_free;
|
goto gpio_free;
|
||||||
@ -446,7 +452,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
|
|||||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||||
master->flags = master_flags;
|
master->flags = master_flags;
|
||||||
master->bus_num = pdev->id;
|
master->bus_num = pdev->id;
|
||||||
master->num_chipselect = SPI_N_CHIPSEL;
|
master->num_chipselect = num_devices;
|
||||||
master->setup = spi_gpio_setup;
|
master->setup = spi_gpio_setup;
|
||||||
master->cleanup = spi_gpio_cleanup;
|
master->cleanup = spi_gpio_cleanup;
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
@ -461,9 +467,12 @@ static int spi_gpio_probe(struct platform_device *pdev)
|
|||||||
* property of the node.
|
* property of the node.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < SPI_N_CHIPSEL; i++)
|
if (!SPI_N_CHIPSEL)
|
||||||
spi_gpio->cs_gpios[i] =
|
spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT;
|
||||||
of_get_named_gpio(np, "cs-gpios", i);
|
else
|
||||||
|
for (i = 0; i < SPI_N_CHIPSEL; i++)
|
||||||
|
spi_gpio->cs_gpios[i] =
|
||||||
|
of_get_named_gpio(np, "cs-gpios", i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user