Thread (4 messages) 4 messages, 3 authors, 2012-08-22

Re: [PATCH v5 1/2] spi/pl022: Add chip select handling via GPIO

From: Linus Walleij <hidden>
Date: 2012-08-22 11:09:32
Also in: linux-spi, lkml

On Tue, Aug 21, 2012 at 6:00 PM, Roland Stigge [off-list ref] wrote:
This patch adds the ability for the driver to control the chip select directly.
This enables independence from cs_control callbacks.  Configurable via
platform_data, to be extended as DT in the following patch.

Based on the initial patch by Alexandre Pereira da Silva [off-list ref]

Signed-off-by: Roland Stigge <redacted>
(...)
quoted hunk ↗ jump to hunk
 /*
  * This macro is used to define some register default values.
@@ -356,6 +357,8 @@ struct vendor_data {
  * @sgt_rx: scattertable for the RX transfer
  * @sgt_tx: scattertable for the TX transfer
  * @dummypage: a dummy page used for driving data on the bus with DMA
+ * @cur_cs: current chip select (gpio)
+ * @chipselect: list of chipselects (gpios)
  */
 struct pl022 {
        struct amba_device              *adev;
@@ -389,6 +392,8 @@ struct pl022 {
        char                            *dummypage;
        bool                            dma_running;
 #endif
+       int cur_cs;
+       int *chipselect;
Since this is an array, it should be named "chipselects" (plural).

(...)
quoted hunk ↗ jump to hunk
@@ -1840,8 +1852,9 @@ static int pl022_setup(struct spi_device
        chip->xfer_type = chip_info->com_mode;
        if (!chip_info->cs_control) {
                chip->cs_control = null_cs_control;
-               dev_warn(&spi->dev,
-                        "chip select function is NULL for this chip\n");
+               if (!gpio_is_valid(pl022->chipselect[spi->chip_select]))
+                       dev_warn(&spi->dev,
+                                "chip select function is NULL for this chip\n");
This dev_warn() is wrong. Alter to a proper warning message.
quoted hunk ↗ jump to hunk
@@ -2016,6 +2030,7 @@ pl022_probe(struct amba_device *adev, co
        pl022->master_info = platform_info;
        pl022->adev = adev;
        pl022->vendor = id->data;
+       pl022->chipselect = (int *)&master[1];
That last thing looks pretty awkward, atleast a comment
explaining what is going on is necessary. I would have done
it like this:

/* Point chipselects to allocated memory beyond the main struct */
pl022->chipselects = (int *) pl022 + sizeof(struct pl022);

Maybe it's simpler to just devm_kzalloc() this array.

Thanks,
Linus Walleij
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help