Skip to content

Commit 4a8573a

Browse files
Andy Grossbroonie
Andy Gross
authored andcommitted
spi: qup: Remove chip select function
This patch removes the chip select function. Chip select should instead be supported using GPIOs, defining the DT entry "cs-gpios", and letting the SPI core assert/deassert the chip select as it sees fit. The chip select control inside the controller is buggy. It is supposed to automatically assert the chip select based on the activity in the controller, but it is buggy and doesn't work at all. So instead we elect to use GPIOs. Signed-off-by: Andy Gross <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 045c243 commit 4a8573a

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

Documentation/devicetree/bindings/spi/qcom,spi-qup.txt

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Optional properties:
2323
- spi-max-frequency: Specifies maximum SPI clock frequency,
2424
Units - Hz. Definition as per
2525
Documentation/devicetree/bindings/spi/spi-bus.txt
26+
- num-cs: total number of chipselects
27+
- cs-gpios: should specify GPIOs used for chipselects.
28+
The gpios will be referred to as reg = <index> in the SPI child
29+
nodes. If unspecified, a single SPI device without a chip
30+
select can be used.
31+
2632

2733
SPI slave nodes must be children of the SPI master node and can contain
2834
properties described in Documentation/devicetree/bindings/spi/spi-bus.txt

drivers/spi/spi-qup.c

+6-27
Original file line numberDiff line numberDiff line change
@@ -424,31 +424,6 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
424424
return 0;
425425
}
426426

427-
static void spi_qup_set_cs(struct spi_device *spi, bool enable)
428-
{
429-
struct spi_qup *controller = spi_master_get_devdata(spi->master);
430-
431-
u32 iocontol, mask;
432-
433-
iocontol = readl_relaxed(controller->base + SPI_IO_CONTROL);
434-
435-
/* Disable auto CS toggle and use manual */
436-
iocontol &= ~SPI_IO_C_MX_CS_MODE;
437-
iocontol |= SPI_IO_C_FORCE_CS;
438-
439-
iocontol &= ~SPI_IO_C_CS_SELECT_MASK;
440-
iocontol |= SPI_IO_C_CS_SELECT(spi->chip_select);
441-
442-
mask = SPI_IO_C_CS_N_POLARITY_0 << spi->chip_select;
443-
444-
if (enable)
445-
iocontol |= mask;
446-
else
447-
iocontol &= ~mask;
448-
449-
writel_relaxed(iocontol, controller->base + SPI_IO_CONTROL);
450-
}
451-
452427
static int spi_qup_transfer_one(struct spi_master *master,
453428
struct spi_device *spi,
454429
struct spi_transfer *xfer)
@@ -571,12 +546,16 @@ static int spi_qup_probe(struct platform_device *pdev)
571546
return -ENOMEM;
572547
}
573548

549+
/* use num-cs unless not present or out of range */
550+
if (of_property_read_u16(dev->of_node, "num-cs",
551+
&master->num_chipselect) ||
552+
(master->num_chipselect > SPI_NUM_CHIPSELECTS))
553+
master->num_chipselect = SPI_NUM_CHIPSELECTS;
554+
574555
master->bus_num = pdev->id;
575556
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
576-
master->num_chipselect = SPI_NUM_CHIPSELECTS;
577557
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
578558
master->max_speed_hz = max_freq;
579-
master->set_cs = spi_qup_set_cs;
580559
master->transfer_one = spi_qup_transfer_one;
581560
master->dev.of_node = pdev->dev.of_node;
582561
master->auto_runtime_pm = true;

0 commit comments

Comments
 (0)