aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2012-09-18 09:53:53 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-25 07:06:16 -0400
commit39a6ac11df6579df0361922f05c43f0fac8daa37 (patch)
tree6e8838fc000f9ff56d3f09e9beeb8ea561455e16 /drivers
parent5bee3b94d945851d6cb624a5e6808d9a815ebca0 (diff)
spi/pl022: Devicetree support w/o platform data
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-pl022.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index b6cfb7b3a59..3f2f36c79ab 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2029,6 +2029,34 @@ static void pl022_cleanup(struct spi_device *spi)
2029 kfree(chip); 2029 kfree(chip);
2030} 2030}
2031 2031
2032static struct pl022_ssp_controller *
2033pl022_platform_data_dt_get(struct device *dev)
2034{
2035 struct device_node *np = dev->of_node;
2036 struct pl022_ssp_controller *pd;
2037 u32 tmp;
2038
2039 if (!np) {
2040 dev_err(dev, "no dt node defined\n");
2041 return NULL;
2042 }
2043
2044 pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
2045 if (!pd) {
2046 dev_err(dev, "cannot allocate platform data memory\n");
2047 return NULL;
2048 }
2049
2050 pd->bus_id = -1;
2051 of_property_read_u32(np, "num-cs", &tmp);
2052 pd->num_chipselect = tmp;
2053 of_property_read_u32(np, "pl022,autosuspend-delay",
2054 &pd->autosuspend_delay);
2055 pd->rt = of_property_read_bool(np, "pl022,rt");
2056
2057 return pd;
2058}
2059
2032static int __devinit 2060static int __devinit
2033pl022_probe(struct amba_device *adev, const struct amba_id *id) 2061pl022_probe(struct amba_device *adev, const struct amba_id *id)
2034{ 2062{
@@ -2041,18 +2069,19 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
2041 2069
2042 dev_info(&adev->dev, 2070 dev_info(&adev->dev,
2043 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid); 2071 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
2044 if (platform_info == NULL) { 2072 if (!platform_info && IS_ENABLED(CONFIG_OF))
2045 dev_err(&adev->dev, "probe - no platform data supplied\n"); 2073 platform_info = pl022_platform_data_dt_get(dev);
2074
2075 if (!platform_info) {
2076 dev_err(dev, "probe: no platform data defined\n");
2046 status = -ENODEV; 2077 status = -ENODEV;
2047 goto err_no_pdata; 2078 goto err_no_pdata;
2048 } 2079 }
2049 2080
2050 if (platform_info->num_chipselect) { 2081 if (platform_info->num_chipselect) {
2051 num_cs = platform_info->num_chipselect; 2082 num_cs = platform_info->num_chipselect;
2052 } else if (IS_ENABLED(CONFIG_OF)) {
2053 of_property_read_u32(np, "num-cs", &num_cs);
2054 } else { 2083 } else {
2055 dev_err(&adev->dev, "probe: no chip select defined\n"); 2084 dev_err(dev, "probe: no chip select defined\n");
2056 status = -ENODEV; 2085 status = -ENODEV;
2057 goto err_no_pdata; 2086 goto err_no_pdata;
2058 } 2087 }