From: <dinguyen-EIB2kfCEclfQT0dZR+AlfA@public.gmane.org>
To: <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
dinh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
Nguyen <dinguyen-EIB2kfCEclfQT0dZR+AlfA@public.gmane.org>,
Dinh
Subject: [PATCH] spi/designware: Add device tree bindings
Date: Tue, 11 Sep 2012 18:31:19 -0600 [thread overview]
Message-ID: <1347409879-12394-1-git-send-email-dinguyen@altera.com> (raw)
From: Dinh Nguyen <dinguyen-EIB2kfCEclfQT0dZR+AlfA@public.gmane.org>
Add device tree bindings for designware spi modules,
specifically, spi-dw-mmio and spi-dw-pci.
Signed-off-by: Dinh Nguyen <dinguyen-EIB2kfCEclfQT0dZR+AlfA@public.gmane.org>
---
Documentation/devicetree/bindings/spi/spi-dw.txt | 20 +++++++++++++++
drivers/spi/spi-dw-mmio.c | 24 +++++++++++++++---
drivers/spi/spi-dw-pci.c | 29 +++++++++++++++++++---
3 files changed, 66 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt
diff --git a/Documentation/devicetree/bindings/spi/spi-dw.txt b/Documentation/devicetree/bindings/spi/spi-dw.txt
new file mode 100644
index 0000000..10a6e9d
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-dw.txt
@@ -0,0 +1,20 @@
+DesignWare SPI device
+
+Required properties:
+- compatible : should be "snps,dw-spi-mmio" or "snps,dw-spi-pci"
+- reg : offset and length of the register set for the device
+- interrupts: The interrupt number to the cpu. The interrupt specifier format
+ depends on the interrupt controller.
+- num-chipselect: Contains the number of the chipselect
+- bus-num: Bus number
+
+Example:
+ spi: spi@fff00000 {
+ compatible = "snps,dw-spi-mmio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0xfff00000 0x1000>;
+ interrupts = <0 154 4>;
+ num-chipselect = <4>;
+ bus-num = <0>;
+ };
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index db2f1ba..555c47a 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -16,6 +16,7 @@
#include <linux/spi/spi.h>
#include <linux/scatterlist.h>
#include <linux/module.h>
+#include <linux/of.h>
#include "spi-dw.h"
@@ -31,7 +32,7 @@ static int __devinit dw_spi_mmio_probe(struct platform_device *pdev)
struct dw_spi_mmio *dwsmmio;
struct dw_spi *dws;
struct resource *mem, *ioarea;
- int ret;
+ int ret, num_cs, bus_num;
dwsmmio = kzalloc(sizeof(struct dw_spi_mmio), GFP_KERNEL);
if (!dwsmmio) {
@@ -78,9 +79,19 @@ static int __devinit dw_spi_mmio_probe(struct platform_device *pdev)
}
clk_enable(dwsmmio->clk);
+ ret = of_property_read_u32(pdev->dev.of_node, "num-chipselect", &num_cs);
+ if (ret < 0)
+ dws->num_cs = 4;
+ else
+ dws->num_cs = num_cs;
+
+ ret = of_property_read_u32(pdev->dev.of_node, "bus-num", &bus_num);
+ if (ret < 0)
+ dws->bus_num = 0;
+ else
+ dws->bus_num = bus_num;
+
dws->parent_dev = &pdev->dev;
- dws->bus_num = 0;
- dws->num_cs = 4;
dws->max_freq = clk_get_rate(dwsmmio->clk);
ret = dw_spi_add_host(dws);
@@ -127,12 +138,19 @@ static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
return 0;
}
+static struct of_device_id dw_spi_mmio_of_match[] __devinitdata = {
+ { .compatible = "snps,dw-spi-mmio", },
+ { /* sentinel */}
+};
+MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
+
static struct platform_driver dw_spi_mmio_driver = {
.probe = dw_spi_mmio_probe,
.remove = __devexit_p(dw_spi_mmio_remove),
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
+ .of_match_table = dw_spi_mmio_of_match,
},
};
module_platform_driver(dw_spi_mmio_driver);
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index ff81abb..d6d9d77 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/module.h>
+#include <linux/of.h>
#include "spi-dw.h"
@@ -38,7 +39,7 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev,
struct dw_spi_pci *dwpci;
struct dw_spi *dws;
int pci_bar = 0;
- int ret;
+ int ret, num_cs, bus_num;
printk(KERN_INFO "DW: found PCI SPI controller(ID: %04x:%04x)\n",
pdev->vendor, pdev->device);
@@ -71,9 +72,19 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev,
goto err_release_reg;
}
+ ret = of_property_read_u32(pdev->dev.of_node, "num-chipselect", &num_cs);
+ if (ret < 0)
+ dws->num_cs = 4;
+ else
+ dws->num_cs = num_cs;
+
+ ret = of_property_read_u32(pdev->dev.of_node, "bus-num", &bus_num);
+ if (ret < 0)
+ dws->bus_num = 0;
+ else
+ dws->bus_num = bus_num;
+
dws->parent_dev = &pdev->dev;
- dws->bus_num = 0;
- dws->num_cs = 4;
dws->irq = pdev->irq;
/*
@@ -155,13 +166,23 @@ static DEFINE_PCI_DEVICE_TABLE(pci_ids) = {
{},
};
+static struct of_device_id dw_spi_pci_of_match[] __devinitdata = {
+ { .compatible = "snps,dw-spi-pci", },
+ { /* sentinel */}
+};
+MODULE_DEVICE_TABLE(of, dw_spi_pci_of_match);
+
static struct pci_driver dw_spi_driver = {
- .name = DRIVER_NAME,
.id_table = pci_ids,
.probe = spi_pci_probe,
.remove = __devexit_p(spi_pci_remove),
.suspend = spi_suspend,
.resume = spi_resume,
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ .of_match_table = dw_spi_pci_of_match,
+ },
};
module_pci_driver(dw_spi_driver);
--
1.7.9.5
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
reply other threads:[~2012-09-12 0:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347409879-12394-1-git-send-email-dinguyen@altera.com \
--to=dinguyen-eib2kfceclfqt0dzr+alfa@public.gmane.org \
--cc=dinh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).