]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
spi/pl022: Devicetree support w/o platform data
authorRoland Stigge <stigge@antcom.de>
Tue, 18 Sep 2012 13:53:53 +0000 (15:53 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 25 Sep 2012 11:06:16 +0000 (07:06 -0400)
Even with devicetree support, we needed platform data to provide some data,
leading to mixed device tree and platform data. This patch makes it possible to
provide all that information via device tree. Now, the data must be provided
via platform data _or_ device tree completely.

Only in case of DMA where a callback specification is necessary (dma_filter()),
platform data is the only option.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Documentation/devicetree/bindings/spi/spi_pl022.txt
drivers/spi/spi-pl022.c

index 877f832c30ae9d31e763230bdf1ff5544bb6f959..f158fd31cfda71a3ab69984c54cbeab3fa22bc61 100644 (file)
@@ -10,6 +10,13 @@ Optional properties:
 - cs-gpios : should specify GPIOs used for chipselects.
   The gpios will be referred to as reg = <index> in the SPI child nodes.
   If unspecified, a single SPI device without a chip select can be used.
+- pl022,autosuspend-delay : delay in ms following transfer completion before
+                           the runtime power management system suspends the
+                           device. A setting of 0 indicates no delay and the
+                            device will be suspended immediately
+- pl022,rt : indicates the controller should run the message pump with realtime
+             priority to minimise the transfer latency on the bus (boolean)
+
 
 SPI slave nodes must be children of the SPI master node and can
 contain the following properties.
index b6cfb7b3a59954b618eb00f099bbc17c25d2b6af..3f2f36c79ab818f0998a302f05fc13365ff4413c 100644 (file)
@@ -2029,6 +2029,34 @@ static void pl022_cleanup(struct spi_device *spi)
        kfree(chip);
 }
 
+static struct pl022_ssp_controller *
+pl022_platform_data_dt_get(struct device *dev)
+{
+       struct device_node *np = dev->of_node;
+       struct pl022_ssp_controller *pd;
+       u32 tmp;
+
+       if (!np) {
+               dev_err(dev, "no dt node defined\n");
+               return NULL;
+       }
+
+       pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
+       if (!pd) {
+               dev_err(dev, "cannot allocate platform data memory\n");
+               return NULL;
+       }
+
+       pd->bus_id = -1;
+       of_property_read_u32(np, "num-cs", &tmp);
+       pd->num_chipselect = tmp;
+       of_property_read_u32(np, "pl022,autosuspend-delay",
+                            &pd->autosuspend_delay);
+       pd->rt = of_property_read_bool(np, "pl022,rt");
+
+       return pd;
+}
+
 static int __devinit
 pl022_probe(struct amba_device *adev, const struct amba_id *id)
 {
@@ -2041,18 +2069,19 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 
        dev_info(&adev->dev,
                 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
-       if (platform_info == NULL) {
-               dev_err(&adev->dev, "probe - no platform data supplied\n");
+       if (!platform_info && IS_ENABLED(CONFIG_OF))
+               platform_info = pl022_platform_data_dt_get(dev);
+
+       if (!platform_info) {
+               dev_err(dev, "probe: no platform data defined\n");
                status = -ENODEV;
                goto err_no_pdata;
        }
 
        if (platform_info->num_chipselect) {
                num_cs = platform_info->num_chipselect;
-       } else if (IS_ENABLED(CONFIG_OF)) {
-               of_property_read_u32(np, "num-cs", &num_cs);
        } else {
-               dev_err(&adev->dev, "probe: no chip select defined\n");
+               dev_err(dev, "probe: no chip select defined\n");
                status = -ENODEV;
                goto err_no_pdata;
        }