Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39a6ac1

Browse files
stiggebroonie
authored andcommitted
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 <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 5bee3b9 commit 39a6ac1

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

Documentation/devicetree/bindings/spi/spi_pl022.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Optional properties:
1010
- cs-gpios : should specify GPIOs used for chipselects.
1111
The gpios will be referred to as reg = <index> in the SPI child nodes.
1212
If unspecified, a single SPI device without a chip select can be used.
13+
- pl022,autosuspend-delay : delay in ms following transfer completion before
14+
the runtime power management system suspends the
15+
device. A setting of 0 indicates no delay and the
16+
device will be suspended immediately
17+
- pl022,rt : indicates the controller should run the message pump with realtime
18+
priority to minimise the transfer latency on the bus (boolean)
19+
1320

1421
SPI slave nodes must be children of the SPI master node and can
1522
contain the following properties.

drivers/spi/spi-pl022.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,34 @@ static void pl022_cleanup(struct spi_device *spi)
20292029
kfree(chip);
20302030
}
20312031

2032+
static struct pl022_ssp_controller *
2033+
pl022_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+
20322060
static int __devinit
20332061
pl022_probe(struct amba_device *adev, const struct amba_id *id)
20342062
{
@@ -2041,18 +2069,19 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
20412069

20422070
dev_info(&adev->dev,
20432071
"ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
2044-
if (platform_info == NULL) {
2045-
dev_err(&adev->dev, "probe - no platform data supplied\n");
2072+
if (!platform_info && IS_ENABLED(CONFIG_OF))
2073+
platform_info = pl022_platform_data_dt_get(dev);
2074+
2075+
if (!platform_info) {
2076+
dev_err(dev, "probe: no platform data defined\n");
20462077
status = -ENODEV;
20472078
goto err_no_pdata;
20482079
}
20492080

20502081
if (platform_info->num_chipselect) {
20512082
num_cs = platform_info->num_chipselect;
2052-
} else if (IS_ENABLED(CONFIG_OF)) {
2053-
of_property_read_u32(np, "num-cs", &num_cs);
20542083
} else {
2055-
dev_err(&adev->dev, "probe: no chip select defined\n");
2084+
dev_err(dev, "probe: no chip select defined\n");
20562085
status = -ENODEV;
20572086
goto err_no_pdata;
20582087
}

0 commit comments

Comments
 (0)