* [PATCH] spi/pl022: Devicetree support w/o platform data
@ 2012-09-18 12:49 Roland Stigge
2012-09-18 13:03 ` Alexandre Pereira da Silva
[not found] ` <1347972540-29667-1-git-send-email-stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
0 siblings, 2 replies; 6+ messages in thread
From: Roland Stigge @ 2012-09-18 12:49 UTC (permalink / raw)
To: broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
lee.jones-QSEj5FYQhm4dnm+yROfE0A,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
STEricsson_nomadik_linux-nkJGhpqTU55BDgjK7y7TUQ,
arnd-r2nGTMty4D4, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
aletes.xgr-Re5JQEeQqe8AvxtiuMwx3w, kevin.wells-3arQi8VN3Tc,
srinivas.bakki-3arQi8VN3Tc
Cc: Roland Stigge
Even with devicetree support, we needed platform data to provide some data like
bus_id and enable_dma, 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 callback specification (dma_filter()), platform data is
necessary.
Signed-off-by: Roland Stigge <stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
Acked-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
Documentation/devicetree/bindings/spi/spi_pl022.txt | 9 ++++
drivers/spi/spi-pl022.c | 41 +++++++++++++++++---
2 files changed, 45 insertions(+), 5 deletions(-)
--- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt
+++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt
@@ -10,6 +10,15 @@ 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,bus-id : Bus ID (0, 1, ...)
+- pl022,enable-dma : enables DMA driven transfers (boolean)
+- 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.
--- linux-2.6.orig/drivers/spi/spi-pl022.c
+++ linux-2.6/drivers/spi/spi-pl022.c
@@ -2024,6 +2024,36 @@ static void pl022_cleanup(struct spi_dev
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;
+ }
+
+ of_property_read_u32(np, "pl022,bus-id", &tmp);
+ pd->bus_id = tmp;
+ of_property_read_u32(np, "num-cs", &tmp);
+ pd->num_chipselect = tmp;
+ pd->enable_dma = of_property_read_bool(np, "pl022,enable-dma") ? 1 : 0;
+ 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)
{
@@ -2036,18 +2066,19 @@ pl022_probe(struct amba_device *adev, co
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi/pl022: Devicetree support w/o platform data
2012-09-18 12:49 [PATCH] spi/pl022: Devicetree support w/o platform data Roland Stigge
@ 2012-09-18 13:03 ` Alexandre Pereira da Silva
[not found] ` <1347972540-29667-1-git-send-email-stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
1 sibling, 0 replies; 6+ messages in thread
From: Alexandre Pereira da Silva @ 2012-09-18 13:03 UTC (permalink / raw)
To: Roland Stigge
Cc: broonie, grant.likely, linus.walleij, lee.jones,
linux-arm-kernel, linux-kernel, STEricsson_nomadik_linux, arnd,
devicetree-discuss, kevin.wells, srinivas.bakki
On Tue, Sep 18, 2012 at 9:49 AM, Roland Stigge <stigge@antcom.de> wrote:
> Even with devicetree support, we needed platform data to provide some data like
> bus_id and enable_dma, 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 callback specification (dma_filter()), platform data is
> necessary.
>
> Signed-off-by: Roland Stigge <stigge@antcom.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com>
> ---
> Documentation/devicetree/bindings/spi/spi_pl022.txt | 9 ++++
> drivers/spi/spi-pl022.c | 41 +++++++++++++++++---
> 2 files changed, 45 insertions(+), 5 deletions(-)
>
> --- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt
> +++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt
> @@ -10,6 +10,15 @@ 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,bus-id : Bus ID (0, 1, ...)
> +- pl022,enable-dma : enables DMA driven transfers (boolean)
> +- 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.
> --- linux-2.6.orig/drivers/spi/spi-pl022.c
> +++ linux-2.6/drivers/spi/spi-pl022.c
> @@ -2024,6 +2024,36 @@ static void pl022_cleanup(struct spi_dev
> 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;
> + }
> +
> + of_property_read_u32(np, "pl022,bus-id", &tmp);
> + pd->bus_id = tmp;
> + of_property_read_u32(np, "num-cs", &tmp);
> + pd->num_chipselect = tmp;
> + pd->enable_dma = of_property_read_bool(np, "pl022,enable-dma") ? 1 : 0;
> + 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)
> {
> @@ -2036,18 +2066,19 @@ pl022_probe(struct amba_device *adev, co
>
> 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;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi/pl022: Devicetree support w/o platform data
[not found] ` <1347972540-29667-1-git-send-email-stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
@ 2012-09-18 13:13 ` Arnd Bergmann
2012-09-18 13:52 ` Roland Stigge
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2012-09-18 13:13 UTC (permalink / raw)
To: Roland Stigge
Cc: srinivas.bakki-3arQi8VN3Tc,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, kevin.wells-3arQi8VN3Tc,
aletes.xgr-Re5JQEeQqe8AvxtiuMwx3w,
STEricsson_nomadik_linux-nkJGhpqTU55BDgjK7y7TUQ,
lee.jones-QSEj5FYQhm4dnm+yROfE0A,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Tuesday 18 September 2012, Roland Stigge wrote:
> --- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt
> +++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt
> @@ -10,6 +10,15 @@ 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,bus-id : Bus ID (0, 1, ...)
I don't understand why we need the bus-id here. My understanding is that
this is a linux-specific number that should not be necessary when all
devices are described in the device tree rather than through spi_board_info.
Can't you just set master->bus_num to -1 when using the DT for probing?
> +- pl022,enable-dma : enables DMA driven transfers (boolean)
Similar thing here: Can't you just set the enable_dma flag when
a dma channel is provided in the device tree and unset it otherwise?
It also seems a bit pointless to enable DMA mode when you don't provide
a way to specify the channel at the same time.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi/pl022: Devicetree support w/o platform data
2012-09-18 13:13 ` Arnd Bergmann
@ 2012-09-18 13:52 ` Roland Stigge
0 siblings, 0 replies; 6+ messages in thread
From: Roland Stigge @ 2012-09-18 13:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: broonie, grant.likely, linus.walleij, lee.jones,
linux-arm-kernel, linux-kernel, STEricsson_nomadik_linux,
devicetree-discuss, aletes.xgr, kevin.wells, srinivas.bakki
Hi!
On 09/18/2012 03:13 PM, Arnd Bergmann wrote:
> On Tuesday 18 September 2012, Roland Stigge wrote:
>> --- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt
>> +++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt
>> @@ -10,6 +10,15 @@ 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,bus-id : Bus ID (0, 1, ...)
>
> I don't understand why we need the bus-id here. My understanding is that
> this is a linux-specific number that should not be necessary when all
> devices are described in the device tree rather than through spi_board_info.
>
> Can't you just set master->bus_num to -1 when using the DT for probing?
>
>> +- pl022,enable-dma : enables DMA driven transfers (boolean)
>
> Similar thing here: Can't you just set the enable_dma flag when
> a dma channel is provided in the device tree and unset it otherwise?
>
> It also seems a bit pointless to enable DMA mode when you don't provide
> a way to specify the channel at the same time.
Completely right! I'm removing pl022,bus-id, setting bus_id to -1 in the
dt case. And removing pl022,enable-dma since dma is anyway only useful
in the platform data case where the dma_filter() callback is specified.
Thanks for pointing this out,
Roland
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] spi/pl022: Devicetree support w/o platform data
2012-09-17 16:59 Roland Stigge
@ 2012-09-18 12:03 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2012-09-18 12:03 UTC (permalink / raw)
To: Roland Stigge, Mark Brown, Grant Likely
Cc: lee.jones, linux-arm-kernel, linux-kernel,
STEricsson_nomadik_linux, linus.walleij, arnd,
devicetree-discuss
On Mon, Sep 17, 2012 at 6:59 PM, Roland Stigge <stigge@antcom.de> wrote:
> Even with devicetree support, we needed platform data to provide some data like
> bus_id and enable_dma, 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 callback specification (dma_filter()), platform data is
> necessary.
>
> Signed-off-by: Roland Stigge <stigge@antcom.de>
This looks good so:
Acked-by: Linus Walleij <linus.walleij@linaro.org>
But I think you need to page Mark Brown so it
gets picked to the stuff queued for the next merge window.
I think the dependent patch is in his SPI tree.
So I'd resend it to mark+grant with my ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] spi/pl022: Devicetree support w/o platform data
@ 2012-09-17 16:59 Roland Stigge
2012-09-18 12:03 ` Linus Walleij
0 siblings, 1 reply; 6+ messages in thread
From: Roland Stigge @ 2012-09-17 16:59 UTC (permalink / raw)
To: linus.walleij, lee.jones, linux-arm-kernel, linux-kernel,
STEricsson_nomadik_linux, linus.walleij, arnd,
devicetree-discuss
Cc: Roland Stigge
Even with devicetree support, we needed platform data to provide some data like
bus_id and enable_dma, 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 callback specification (dma_filter()), platform data is
necessary.
Signed-off-by: Roland Stigge <stigge@antcom.de>
---
Documentation/devicetree/bindings/spi/spi_pl022.txt | 9 ++++
drivers/spi/spi-pl022.c | 41 +++++++++++++++++---
2 files changed, 45 insertions(+), 5 deletions(-)
--- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt
+++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt
@@ -10,6 +10,15 @@ 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,bus-id : Bus ID (0, 1, ...)
+- pl022,enable-dma : enables DMA driven transfers (boolean)
+- 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.
--- linux-2.6.orig/drivers/spi/spi-pl022.c
+++ linux-2.6/drivers/spi/spi-pl022.c
@@ -2024,6 +2024,36 @@ static void pl022_cleanup(struct spi_dev
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;
+ }
+
+ of_property_read_u32(np, "pl022,bus-id", &tmp);
+ pd->bus_id = tmp;
+ of_property_read_u32(np, "num-cs", &tmp);
+ pd->num_chipselect = tmp;
+ pd->enable_dma = of_property_read_bool(np, "pl022,enable-dma") ? 1 : 0;
+ 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)
{
@@ -2036,18 +2066,19 @@ pl022_probe(struct amba_device *adev, co
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-18 13:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-18 12:49 [PATCH] spi/pl022: Devicetree support w/o platform data Roland Stigge
2012-09-18 13:03 ` Alexandre Pereira da Silva
[not found] ` <1347972540-29667-1-git-send-email-stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
2012-09-18 13:13 ` Arnd Bergmann
2012-09-18 13:52 ` Roland Stigge
-- strict thread matches above, loose matches on Subject: below --
2012-09-17 16:59 Roland Stigge
2012-09-18 12:03 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).