* [PATCH 1/4] spi/omap: Add DT support to McSPI driver
2012-02-15 17:37 [PATCH 0/4] spi/omap: Adaptation to Device Tree Benoit Cousson
@ 2012-02-15 17:37 ` Benoit Cousson
2012-02-15 19:34 ` Rob Herring
2012-02-15 17:37 ` [PATCH 2/4] arm/dts: OMAP4: Add SPI controller nodes Benoit Cousson
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Benoit Cousson @ 2012-02-15 17:37 UTC (permalink / raw)
To: grant.likely
Cc: linux-omap, linux-arm-kernel, devicetree-discuss, Benoit Cousson,
Rajendra Nayak
Add device tree support to the OMAP2+ McSPI driver.
Add the bindings documentation.
Based on original code from Rajendra.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rajendra Nayak <rnayak@ti.com>
---
Documentation/devicetree/bindings/spi/omap-spi.txt | 20 +++++++
drivers/spi/spi-omap2-mcspi.c | 56 +++++++++++++++++---
2 files changed, 68 insertions(+), 8 deletions(-)
create mode 100644 Documentation/devicetree/bindings/spi/omap-spi.txt
diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt b/Documentation/devicetree/bindings/spi/omap-spi.txt
new file mode 100644
index 0000000..81df374
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/omap-spi.txt
@@ -0,0 +1,20 @@
+OMAP2+ McSPI device
+
+Required properties:
+- compatible :
+ - "ti,omap2-spi" for OMAP2 & OMAP3.
+ - "ti,omap4-spi" for OMAP4+.
+- ti,spi-num-cs : Number of chipselect supported by the instance.
+- ti,hwmods: Name of the hwmod associated to the McSPI
+
+
+Example:
+
+mcspi1: mcspi@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "ti,omap4-mcspi";
+ ti,hwmods = "mcspi1";
+ ti,spi-num-cs = <4>;
+};
+
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0b0dfb7..bb9274c 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -34,6 +34,8 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/spi/spi.h>
@@ -1079,15 +1081,39 @@ static int omap_mcspi_runtime_resume(struct device *dev)
return 0;
}
+static struct omap2_mcspi_platform_config omap2_pdata = {
+ .regs_offset = 0,
+};
+
+static struct omap2_mcspi_platform_config omap4_pdata = {
+ .regs_offset = OMAP4_MCSPI_REG_OFFSET,
+};
+
+static const struct of_device_id omap_mcspi_of_match[] = {
+ {
+ .compatible = "ti,omap2-mcspi",
+ .data = &omap2_pdata,
+ },
+ {
+ .compatible = "ti,omap4-mcspi",
+ .data = &omap4_pdata,
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
static int __init omap2_mcspi_probe(struct platform_device *pdev)
{
struct spi_master *master;
- struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
+ struct omap2_mcspi_platform_config *pdata;
struct omap2_mcspi *mcspi;
struct resource *r;
int status = 0, i;
char wq_name[20];
+ u32 regs_offset = 0;
+ static int bus_num = 1;
+ struct device_node *node = pdev->dev.of_node;
+ const struct of_device_id *match;
master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
if (master == NULL) {
@@ -1098,13 +1124,26 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
/* the spi->mode bits understood by this driver: */
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
- if (pdev->id != -1)
- master->bus_num = pdev->id;
-
master->setup = omap2_mcspi_setup;
master->transfer = omap2_mcspi_transfer;
master->cleanup = omap2_mcspi_cleanup;
- master->num_chipselect = pdata->num_cs;
+ master->dev.of_node = node;
+
+ match = of_match_device(omap_mcspi_of_match, &pdev->dev);
+ if (match) {
+ u32 num_cs = 1; /* default number of chipselect */
+ pdata = match->data;
+
+ of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
+ master->num_chipselect = num_cs;
+ master->bus_num = bus_num++;
+ } else {
+ pdata = pdev->dev.platform_data;
+ master->num_chipselect = pdata->num_cs;
+ if (pdev->id != -1)
+ master->bus_num = pdev->id;
+ }
+ regs_offset = pdata->regs_offset;
dev_set_drvdata(&pdev->dev, master);
@@ -1124,8 +1163,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
goto free_master;
}
- r->start += pdata->regs_offset;
- r->end += pdata->regs_offset;
+ r->start += regs_offset;
+ r->end += regs_offset;
mcspi->phys = r->start;
if (!request_mem_region(r->start, resource_size(r),
dev_name(&pdev->dev))) {
@@ -1285,7 +1324,8 @@ static struct platform_driver omap2_mcspi_driver = {
.driver = {
.name = "omap2_mcspi",
.owner = THIS_MODULE,
- .pm = &omap2_mcspi_pm_ops
+ .pm = &omap2_mcspi_pm_ops,
+ .of_match_table = omap_mcspi_of_match,
},
.remove = __exit_p(omap2_mcspi_remove),
};
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] spi/omap: Add DT support to McSPI driver
2012-02-15 17:37 ` [PATCH 1/4] spi/omap: Add DT support to McSPI driver Benoit Cousson
@ 2012-02-15 19:34 ` Rob Herring
2012-02-15 20:04 ` Grant Likely
2012-02-15 21:10 ` Cousson, Benoit
0 siblings, 2 replies; 11+ messages in thread
From: Rob Herring @ 2012-02-15 19:34 UTC (permalink / raw)
To: Benoit Cousson
Cc: grant.likely, devicetree-discuss, linux-omap, linux-arm-kernel
On 02/15/2012 11:37 AM, Benoit Cousson wrote:
> Add device tree support to the OMAP2+ McSPI driver.
> Add the bindings documentation.
>
> Based on original code from Rajendra.
>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rajendra Nayak <rnayak@ti.com>
> ---
> Documentation/devicetree/bindings/spi/omap-spi.txt | 20 +++++++
> drivers/spi/spi-omap2-mcspi.c | 56 +++++++++++++++++---
> 2 files changed, 68 insertions(+), 8 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/spi/omap-spi.txt
>
> diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt b/Documentation/devicetree/bindings/spi/omap-spi.txt
> new file mode 100644
> index 0000000..81df374
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/spi/omap-spi.txt
> @@ -0,0 +1,20 @@
> +OMAP2+ McSPI device
> +
> +Required properties:
> +- compatible :
> + - "ti,omap2-spi" for OMAP2 & OMAP3.
> + - "ti,omap4-spi" for OMAP4+.
> +- ti,spi-num-cs : Number of chipselect supported by the instance.
> +- ti,hwmods: Name of the hwmod associated to the McSPI
> +
> +
> +Example:
> +
> +mcspi1: mcspi@1 {
I don't recall if there's a generic name defined but just "spi" would
probably be better. Also, shouldn't this be the base address?
Otherwise, for the series:
Acked-by: Rob Herring <rob.herring@calxeda.com>
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "ti,omap4-mcspi";
> + ti,hwmods = "mcspi1";
> + ti,spi-num-cs = <4>;
> +};
> +
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 0b0dfb7..bb9274c 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -34,6 +34,8 @@
> #include <linux/io.h>
> #include <linux/slab.h>
> #include <linux/pm_runtime.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>
> #include <linux/spi/spi.h>
>
> @@ -1079,15 +1081,39 @@ static int omap_mcspi_runtime_resume(struct device *dev)
> return 0;
> }
>
> +static struct omap2_mcspi_platform_config omap2_pdata = {
> + .regs_offset = 0,
> +};
> +
> +static struct omap2_mcspi_platform_config omap4_pdata = {
> + .regs_offset = OMAP4_MCSPI_REG_OFFSET,
> +};
> +
> +static const struct of_device_id omap_mcspi_of_match[] = {
> + {
> + .compatible = "ti,omap2-mcspi",
> + .data = &omap2_pdata,
> + },
> + {
> + .compatible = "ti,omap4-mcspi",
> + .data = &omap4_pdata,
> + },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
>
> static int __init omap2_mcspi_probe(struct platform_device *pdev)
> {
> struct spi_master *master;
> - struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
> + struct omap2_mcspi_platform_config *pdata;
> struct omap2_mcspi *mcspi;
> struct resource *r;
> int status = 0, i;
> char wq_name[20];
> + u32 regs_offset = 0;
> + static int bus_num = 1;
> + struct device_node *node = pdev->dev.of_node;
> + const struct of_device_id *match;
>
> master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
> if (master == NULL) {
> @@ -1098,13 +1124,26 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> /* the spi->mode bits understood by this driver: */
> master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
>
> - if (pdev->id != -1)
> - master->bus_num = pdev->id;
> -
> master->setup = omap2_mcspi_setup;
> master->transfer = omap2_mcspi_transfer;
> master->cleanup = omap2_mcspi_cleanup;
> - master->num_chipselect = pdata->num_cs;
> + master->dev.of_node = node;
> +
> + match = of_match_device(omap_mcspi_of_match, &pdev->dev);
> + if (match) {
> + u32 num_cs = 1; /* default number of chipselect */
> + pdata = match->data;
> +
> + of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
> + master->num_chipselect = num_cs;
> + master->bus_num = bus_num++;
> + } else {
> + pdata = pdev->dev.platform_data;
> + master->num_chipselect = pdata->num_cs;
> + if (pdev->id != -1)
> + master->bus_num = pdev->id;
> + }
> + regs_offset = pdata->regs_offset;
>
> dev_set_drvdata(&pdev->dev, master);
>
> @@ -1124,8 +1163,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> goto free_master;
> }
>
> - r->start += pdata->regs_offset;
> - r->end += pdata->regs_offset;
> + r->start += regs_offset;
> + r->end += regs_offset;
> mcspi->phys = r->start;
> if (!request_mem_region(r->start, resource_size(r),
> dev_name(&pdev->dev))) {
> @@ -1285,7 +1324,8 @@ static struct platform_driver omap2_mcspi_driver = {
> .driver = {
> .name = "omap2_mcspi",
> .owner = THIS_MODULE,
> - .pm = &omap2_mcspi_pm_ops
> + .pm = &omap2_mcspi_pm_ops,
> + .of_match_table = omap_mcspi_of_match,
> },
> .remove = __exit_p(omap2_mcspi_remove),
> };
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] spi/omap: Add DT support to McSPI driver
2012-02-15 19:34 ` Rob Herring
@ 2012-02-15 20:04 ` Grant Likely
2012-02-15 21:10 ` Cousson, Benoit
1 sibling, 0 replies; 11+ messages in thread
From: Grant Likely @ 2012-02-15 20:04 UTC (permalink / raw)
To: Rob Herring
Cc: Benoit Cousson, devicetree-discuss, linux-omap, linux-arm-kernel
On Wed, Feb 15, 2012 at 01:34:46PM -0600, Rob Herring wrote:
> On 02/15/2012 11:37 AM, Benoit Cousson wrote:
> > Add device tree support to the OMAP2+ McSPI driver.
> > Add the bindings documentation.
> >
> > Based on original code from Rajendra.
> >
> > Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > Cc: Rajendra Nayak <rnayak@ti.com>
> > ---
> > Documentation/devicetree/bindings/spi/omap-spi.txt | 20 +++++++
> > drivers/spi/spi-omap2-mcspi.c | 56 +++++++++++++++++---
> > 2 files changed, 68 insertions(+), 8 deletions(-)
> > create mode 100644 Documentation/devicetree/bindings/spi/omap-spi.txt
> >
> > diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt b/Documentation/devicetree/bindings/spi/omap-spi.txt
> > new file mode 100644
> > index 0000000..81df374
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/spi/omap-spi.txt
> > @@ -0,0 +1,20 @@
> > +OMAP2+ McSPI device
> > +
> > +Required properties:
> > +- compatible :
> > + - "ti,omap2-spi" for OMAP2 & OMAP3.
> > + - "ti,omap4-spi" for OMAP4+.
> > +- ti,spi-num-cs : Number of chipselect supported by the instance.
> > +- ti,hwmods: Name of the hwmod associated to the McSPI
> > +
> > +
> > +Example:
> > +
> > +mcspi1: mcspi@1 {
>
> I don't recall if there's a generic name defined but just "spi" would
> probably be better. Also, shouldn't this be the base address?
>
> Otherwise, for the series:
>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
Yes, use the generic names recommended practice and name the node spi@<address>.
g.
>
>
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + compatible = "ti,omap4-mcspi";
> > + ti,hwmods = "mcspi1";
> > + ti,spi-num-cs = <4>;
> > +};
> > +
> > diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> > index 0b0dfb7..bb9274c 100644
> > --- a/drivers/spi/spi-omap2-mcspi.c
> > +++ b/drivers/spi/spi-omap2-mcspi.c
> > @@ -34,6 +34,8 @@
> > #include <linux/io.h>
> > #include <linux/slab.h>
> > #include <linux/pm_runtime.h>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
> >
> > #include <linux/spi/spi.h>
> >
> > @@ -1079,15 +1081,39 @@ static int omap_mcspi_runtime_resume(struct device *dev)
> > return 0;
> > }
> >
> > +static struct omap2_mcspi_platform_config omap2_pdata = {
> > + .regs_offset = 0,
> > +};
> > +
> > +static struct omap2_mcspi_platform_config omap4_pdata = {
> > + .regs_offset = OMAP4_MCSPI_REG_OFFSET,
> > +};
> > +
> > +static const struct of_device_id omap_mcspi_of_match[] = {
> > + {
> > + .compatible = "ti,omap2-mcspi",
> > + .data = &omap2_pdata,
> > + },
> > + {
> > + .compatible = "ti,omap4-mcspi",
> > + .data = &omap4_pdata,
> > + },
> > + { },
> > +};
> > +MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
> >
> > static int __init omap2_mcspi_probe(struct platform_device *pdev)
> > {
> > struct spi_master *master;
> > - struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
> > + struct omap2_mcspi_platform_config *pdata;
> > struct omap2_mcspi *mcspi;
> > struct resource *r;
> > int status = 0, i;
> > char wq_name[20];
> > + u32 regs_offset = 0;
> > + static int bus_num = 1;
> > + struct device_node *node = pdev->dev.of_node;
> > + const struct of_device_id *match;
> >
> > master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
> > if (master == NULL) {
> > @@ -1098,13 +1124,26 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> > /* the spi->mode bits understood by this driver: */
> > master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
> >
> > - if (pdev->id != -1)
> > - master->bus_num = pdev->id;
> > -
> > master->setup = omap2_mcspi_setup;
> > master->transfer = omap2_mcspi_transfer;
> > master->cleanup = omap2_mcspi_cleanup;
> > - master->num_chipselect = pdata->num_cs;
> > + master->dev.of_node = node;
> > +
> > + match = of_match_device(omap_mcspi_of_match, &pdev->dev);
> > + if (match) {
> > + u32 num_cs = 1; /* default number of chipselect */
> > + pdata = match->data;
> > +
> > + of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
> > + master->num_chipselect = num_cs;
> > + master->bus_num = bus_num++;
> > + } else {
> > + pdata = pdev->dev.platform_data;
> > + master->num_chipselect = pdata->num_cs;
> > + if (pdev->id != -1)
> > + master->bus_num = pdev->id;
> > + }
> > + regs_offset = pdata->regs_offset;
> >
> > dev_set_drvdata(&pdev->dev, master);
> >
> > @@ -1124,8 +1163,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> > goto free_master;
> > }
> >
> > - r->start += pdata->regs_offset;
> > - r->end += pdata->regs_offset;
> > + r->start += regs_offset;
> > + r->end += regs_offset;
> > mcspi->phys = r->start;
> > if (!request_mem_region(r->start, resource_size(r),
> > dev_name(&pdev->dev))) {
> > @@ -1285,7 +1324,8 @@ static struct platform_driver omap2_mcspi_driver = {
> > .driver = {
> > .name = "omap2_mcspi",
> > .owner = THIS_MODULE,
> > - .pm = &omap2_mcspi_pm_ops
> > + .pm = &omap2_mcspi_pm_ops,
> > + .of_match_table = omap_mcspi_of_match,
> > },
> > .remove = __exit_p(omap2_mcspi_remove),
> > };
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] spi/omap: Add DT support to McSPI driver
2012-02-15 19:34 ` Rob Herring
2012-02-15 20:04 ` Grant Likely
@ 2012-02-15 21:10 ` Cousson, Benoit
1 sibling, 0 replies; 11+ messages in thread
From: Cousson, Benoit @ 2012-02-15 21:10 UTC (permalink / raw)
To: Rob Herring
Cc: grant.likely, devicetree-discuss, linux-omap, linux-arm-kernel
On 2/15/2012 8:34 PM, Rob Herring wrote:
> On 02/15/2012 11:37 AM, Benoit Cousson wrote:
>> Add device tree support to the OMAP2+ McSPI driver.
>> Add the bindings documentation.
>>
>> Based on original code from Rajendra.
>>
>> Signed-off-by: Benoit Cousson<b-cousson@ti.com>
>> Cc: Grant Likely<grant.likely@secretlab.ca>
>> Cc: Rajendra Nayak<rnayak@ti.com>
>> ---
>> Documentation/devicetree/bindings/spi/omap-spi.txt | 20 +++++++
>> drivers/spi/spi-omap2-mcspi.c | 56 +++++++++++++++++---
>> 2 files changed, 68 insertions(+), 8 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/spi/omap-spi.txt
>>
>> diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt b/Documentation/devicetree/bindings/spi/omap-spi.txt
>> new file mode 100644
>> index 0000000..81df374
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/spi/omap-spi.txt
>> @@ -0,0 +1,20 @@
>> +OMAP2+ McSPI device
>> +
>> +Required properties:
>> +- compatible :
>> + - "ti,omap2-spi" for OMAP2& OMAP3.
>> + - "ti,omap4-spi" for OMAP4+.
>> +- ti,spi-num-cs : Number of chipselect supported by the instance.
>> +- ti,hwmods: Name of the hwmod associated to the McSPI
>> +
>> +
>> +Example:
>> +
>> +mcspi1: mcspi@1 {
>
> I don't recall if there's a generic name defined but just "spi" would
> probably be better.
I was wondering as well, but based on Grant further comment it looks it
is the case.
I couldn't find any list of generic name in the bindings documentation.
Is there some place we can get that?
> Also, shouldn't this be the base address?
Yeah, it should, I've just explained the reason of this OMAP
irregularity in my answer to Grant. Let see if he'll be convinced or not :-)
> Otherwise, for the series:
>
> Acked-by: Rob Herring<rob.herring@calxeda.com>
Thanks,
Benoit
>
>
>> + #address-cells =<1>;
>> + #size-cells =<0>;
>> + compatible = "ti,omap4-mcspi";
>> + ti,hwmods = "mcspi1";
>> + ti,spi-num-cs =<4>;
>> +};
>> +
>> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
>> index 0b0dfb7..bb9274c 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -34,6 +34,8 @@
>> #include<linux/io.h>
>> #include<linux/slab.h>
>> #include<linux/pm_runtime.h>
>> +#include<linux/of.h>
>> +#include<linux/of_device.h>
>>
>> #include<linux/spi/spi.h>
>>
>> @@ -1079,15 +1081,39 @@ static int omap_mcspi_runtime_resume(struct device *dev)
>> return 0;
>> }
>>
>> +static struct omap2_mcspi_platform_config omap2_pdata = {
>> + .regs_offset = 0,
>> +};
>> +
>> +static struct omap2_mcspi_platform_config omap4_pdata = {
>> + .regs_offset = OMAP4_MCSPI_REG_OFFSET,
>> +};
>> +
>> +static const struct of_device_id omap_mcspi_of_match[] = {
>> + {
>> + .compatible = "ti,omap2-mcspi",
>> + .data =&omap2_pdata,
>> + },
>> + {
>> + .compatible = "ti,omap4-mcspi",
>> + .data =&omap4_pdata,
>> + },
>> + { },
>> +};
>> +MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
>>
>> static int __init omap2_mcspi_probe(struct platform_device *pdev)
>> {
>> struct spi_master *master;
>> - struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
>> + struct omap2_mcspi_platform_config *pdata;
>> struct omap2_mcspi *mcspi;
>> struct resource *r;
>> int status = 0, i;
>> char wq_name[20];
>> + u32 regs_offset = 0;
>> + static int bus_num = 1;
>> + struct device_node *node = pdev->dev.of_node;
>> + const struct of_device_id *match;
>>
>> master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
>> if (master == NULL) {
>> @@ -1098,13 +1124,26 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
>> /* the spi->mode bits understood by this driver: */
>> master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
>>
>> - if (pdev->id != -1)
>> - master->bus_num = pdev->id;
>> -
>> master->setup = omap2_mcspi_setup;
>> master->transfer = omap2_mcspi_transfer;
>> master->cleanup = omap2_mcspi_cleanup;
>> - master->num_chipselect = pdata->num_cs;
>> + master->dev.of_node = node;
>> +
>> + match = of_match_device(omap_mcspi_of_match,&pdev->dev);
>> + if (match) {
>> + u32 num_cs = 1; /* default number of chipselect */
>> + pdata = match->data;
>> +
>> + of_property_read_u32(node, "ti,spi-num-cs",&num_cs);
>> + master->num_chipselect = num_cs;
>> + master->bus_num = bus_num++;
>> + } else {
>> + pdata = pdev->dev.platform_data;
>> + master->num_chipselect = pdata->num_cs;
>> + if (pdev->id != -1)
>> + master->bus_num = pdev->id;
>> + }
>> + regs_offset = pdata->regs_offset;
>>
>> dev_set_drvdata(&pdev->dev, master);
>>
>> @@ -1124,8 +1163,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
>> goto free_master;
>> }
>>
>> - r->start += pdata->regs_offset;
>> - r->end += pdata->regs_offset;
>> + r->start += regs_offset;
>> + r->end += regs_offset;
>> mcspi->phys = r->start;
>> if (!request_mem_region(r->start, resource_size(r),
>> dev_name(&pdev->dev))) {
>> @@ -1285,7 +1324,8 @@ static struct platform_driver omap2_mcspi_driver = {
>> .driver = {
>> .name = "omap2_mcspi",
>> .owner = THIS_MODULE,
>> - .pm = &omap2_mcspi_pm_ops
>> + .pm = &omap2_mcspi_pm_ops,
>> + .of_match_table = omap_mcspi_of_match,
>> },
>> .remove = __exit_p(omap2_mcspi_remove),
>> };
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/4] arm/dts: OMAP4: Add SPI controller nodes
2012-02-15 17:37 [PATCH 0/4] spi/omap: Adaptation to Device Tree Benoit Cousson
2012-02-15 17:37 ` [PATCH 1/4] spi/omap: Add DT support to McSPI driver Benoit Cousson
@ 2012-02-15 17:37 ` Benoit Cousson
2012-02-15 20:02 ` Grant Likely
2012-02-15 17:37 ` [PATCH 3/4] arm/dts: OMAP3: " Benoit Cousson
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Benoit Cousson @ 2012-02-15 17:37 UTC (permalink / raw)
To: grant.likely
Cc: devicetree-discuss, linux-omap, Benoit Cousson, linux-arm-kernel
Add the 4 McSPI controller nodes present in an OMAP4 device.
Remove SPI static device initialisation if DT is populated.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
arch/arm/boot/dts/omap4.dtsi | 32 ++++++++++++++++++++++++++++++++
arch/arm/mach-omap2/devices.c | 4 +++-
2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 4b81f03..7fc0cbe 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -209,5 +209,37 @@
#size-cells = <0>;
ti,hwmods = "i2c4";
};
+
+ mcspi1: mcspi@1 {
+ compatible = "ti,omap4-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi1";
+ ti,spi-num-cs = <4>;
+ };
+
+ mcspi2: mcspi@2 {
+ compatible = "ti,omap4-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi2";
+ ti,spi-num-cs = <2>;
+ };
+
+ mcspi3: mcspi@3 {
+ compatible = "ti,omap4-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi3";
+ ti,spi-num-cs = <2>;
+ };
+
+ mcspi4: mcspi@4 {
+ compatible = "ti,omap4-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi4";
+ ti,spi-num-cs = <1>;
+ };
};
};
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 283d11e..8a489ba 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -725,7 +725,9 @@ static int __init omap2_init_devices(void)
omap_init_dmic();
omap_init_camera();
omap_init_mbox();
- omap_init_mcspi();
+ /* If dtb is there, the devices will be created dynamically */
+ if (!of_have_populated_dt())
+ omap_init_mcspi();
omap_init_pmu();
omap_hdq_init();
omap_init_sti();
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] arm/dts: OMAP4: Add SPI controller nodes
2012-02-15 17:37 ` [PATCH 2/4] arm/dts: OMAP4: Add SPI controller nodes Benoit Cousson
@ 2012-02-15 20:02 ` Grant Likely
[not found] ` <20120215200240.GA25779-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Grant Likely @ 2012-02-15 20:02 UTC (permalink / raw)
To: Benoit Cousson; +Cc: devicetree-discuss, linux-omap, linux-arm-kernel
On Wed, Feb 15, 2012 at 06:37:35PM +0100, Benoit Cousson wrote:
> Add the 4 McSPI controller nodes present in an OMAP4 device.
>
> Remove SPI static device initialisation if DT is populated.
>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> ---
> arch/arm/boot/dts/omap4.dtsi | 32 ++++++++++++++++++++++++++++++++
> arch/arm/mach-omap2/devices.c | 4 +++-
> 2 files changed, 35 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> index 4b81f03..7fc0cbe 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -209,5 +209,37 @@
> #size-cells = <0>;
> ti,hwmods = "i2c4";
> };
> +
> + mcspi1: mcspi@1 {
> + compatible = "ti,omap4-mcspi";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + ti,hwmods = "mcspi1";
> + ti,spi-num-cs = <4>;
No reg or interrupts properties? And the @<num> in the name must match the
first entry in a reg property. This looks wrong.
> + };
> +
> + mcspi2: mcspi@2 {
> + compatible = "ti,omap4-mcspi";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + ti,hwmods = "mcspi2";
> + ti,spi-num-cs = <2>;
> + };
> +
> + mcspi3: mcspi@3 {
> + compatible = "ti,omap4-mcspi";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + ti,hwmods = "mcspi3";
> + ti,spi-num-cs = <2>;
> + };
> +
> + mcspi4: mcspi@4 {
> + compatible = "ti,omap4-mcspi";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + ti,hwmods = "mcspi4";
> + ti,spi-num-cs = <1>;
> + };
> };
> };
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 283d11e..8a489ba 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -725,7 +725,9 @@ static int __init omap2_init_devices(void)
> omap_init_dmic();
> omap_init_camera();
> omap_init_mbox();
> - omap_init_mcspi();
> + /* If dtb is there, the devices will be created dynamically */
> + if (!of_have_populated_dt())
> + omap_init_mcspi();
> omap_init_pmu();
> omap_hdq_init();
> omap_init_sti();
> --
> 1.7.0.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/4] arm/dts: OMAP3: Add SPI controller nodes
2012-02-15 17:37 [PATCH 0/4] spi/omap: Adaptation to Device Tree Benoit Cousson
2012-02-15 17:37 ` [PATCH 1/4] spi/omap: Add DT support to McSPI driver Benoit Cousson
2012-02-15 17:37 ` [PATCH 2/4] arm/dts: OMAP4: Add SPI controller nodes Benoit Cousson
@ 2012-02-15 17:37 ` Benoit Cousson
2012-02-15 17:37 ` [PATCH 4/4] arm/dts: omap4-sdp: Add ks8851 ethernet SPI device Benoit Cousson
2012-02-15 20:03 ` [PATCH 0/4] spi/omap: Adaptation to Device Tree Grant Likely
4 siblings, 0 replies; 11+ messages in thread
From: Benoit Cousson @ 2012-02-15 17:37 UTC (permalink / raw)
To: grant.likely
Cc: linux-omap, linux-arm-kernel, devicetree-discuss, Benoit Cousson
Add the 4 McSPI controller nodes present in an OMAP3 device.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
arch/arm/boot/dts/omap3.dtsi | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 8eb181e..97079fe 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -167,5 +167,37 @@
#size-cells = <0>;
ti,hwmods = "i2c3";
};
+
+ mcspi1: mcspi@1 {
+ compatible = "ti,omap2-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi1";
+ ti,spi-num-cs = <4>;
+ };
+
+ mcspi2: mcspi@2 {
+ compatible = "ti,omap2-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi2";
+ ti,spi-num-cs = <2>;
+ };
+
+ mcspi3: mcspi@3 {
+ compatible = "ti,omap2-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi3";
+ ti,spi-num-cs = <2>;
+ };
+
+ mcspi4: mcspi@4 {
+ compatible = "ti,omap2-mcspi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ti,hwmods = "mcspi4";
+ ti,spi-num-cs = <1>;
+ };
};
};
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] arm/dts: omap4-sdp: Add ks8851 ethernet SPI device
2012-02-15 17:37 [PATCH 0/4] spi/omap: Adaptation to Device Tree Benoit Cousson
` (2 preceding siblings ...)
2012-02-15 17:37 ` [PATCH 3/4] arm/dts: OMAP3: " Benoit Cousson
@ 2012-02-15 17:37 ` Benoit Cousson
2012-02-15 20:03 ` [PATCH 0/4] spi/omap: Adaptation to Device Tree Grant Likely
4 siblings, 0 replies; 11+ messages in thread
From: Benoit Cousson @ 2012-02-15 17:37 UTC (permalink / raw)
To: grant.likely
Cc: linux-omap, linux-arm-kernel, devicetree-discuss, Benoit Cousson,
Rajendra Nayak
Add an ethernet SPI chip in the OMAP4 SDP/Blaze board DTS file.
Add a fixed regulator node controlled by a GPIO line to supply
the ethernet chip.
Based on original code from Rajendra.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
arch/arm/boot/dts/omap4-sdp.dts | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index 01db8b7..31938c1 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -17,6 +17,16 @@
device_type = "memory";
reg = <0x80000000 0x40000000>; /* 1 GB */
};
+
+ vdd_eth: fixedregulator@0 {
+ compatible = "regulator-fixed";
+ regulator-name = "VDD_ETH";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ gpio = <&gpio2 16 0>; /* gpio line 48 */
+ enable-active-high;
+ regulator-boot-on;
+ };
};
&i2c1 {
@@ -70,3 +80,14 @@
reg = <0x1e>;
};
};
+
+&mcspi1 {
+ eth@0 {
+ compatible = "ks8851";
+ spi-max-frequency = <24000000>;
+ reg = <0>;
+ interrupt-parent = <&gpio2>;
+ interrupts = <2>; /* gpio line 34 */
+ vdd-supply = <&vdd_eth>;
+ };
+};
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] spi/omap: Adaptation to Device Tree
2012-02-15 17:37 [PATCH 0/4] spi/omap: Adaptation to Device Tree Benoit Cousson
` (3 preceding siblings ...)
2012-02-15 17:37 ` [PATCH 4/4] arm/dts: omap4-sdp: Add ks8851 ethernet SPI device Benoit Cousson
@ 2012-02-15 20:03 ` Grant Likely
4 siblings, 0 replies; 11+ messages in thread
From: Grant Likely @ 2012-02-15 20:03 UTC (permalink / raw)
To: Benoit Cousson; +Cc: linux-omap, linux-arm-kernel, devicetree-discuss
On Wed, Feb 15, 2012 at 06:37:33PM +0100, Benoit Cousson wrote:
> Hi Grant,
>
> You might think I'm harassing you with all these series, but it looks like
> you are the maintainer of all the stuff I care about for the moment :-)
>
> Here are a couple of SPI patches + the addition of a SPI ethernet device
> needed for sdp4430 board.
>
> This driver is still relying on a valid bus_number which is clearly bad.
> A cleanup is definitively needed, and will be done later.
>
> This series is based on lo/master (a37cdd9) + for_3.4/dt_base branch to get
> the needed cleanup and fixes for OMAP.
>
> Please note that due to the changes in the various OMAP DTS files, I have
> to base this series on top of my other DT series (gpio for example), otherwise
> the merge of the two series will generate some merge conflict in the DTS since
> they are both adding some new nodes at the exact same location.
Merge conflicts of this type are just fine when they are both adding new stuff.
The resolution of such conflicts are easy.
g.
^ permalink raw reply [flat|nested] 11+ messages in thread