From: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>, Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>, Jean-Hugues Deschenes <jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org> Subject: [PATCH v3 3/5] spi: dw-mmio: add device tree support Date: Fri, 31 Jan 2014 12:07:46 +0200 Message-ID: <d9d868430ae3cecc0be8faecf5d188d160966533.1391162172.git.baruch@tkos.co.il> (raw) In-Reply-To: <cover.1391162172.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> Cc: Jean-Hugues Deschenes <jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org> Signed-off-by: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> --- drivers/spi/spi-dw-mmio.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 1492f5ee9aaa..86d247ecd2d2 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" @@ -32,6 +33,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) struct dw_spi *dws; struct resource *mem; int ret; + u32 tmp; dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), GFP_KERNEL); @@ -67,7 +69,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) return ret; dws->bus_num = pdev->id; - dws->num_cs = 4; + if (pdev->dev.of_node == NULL) + dws->num_cs = 4; + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &tmp); + if (ret == 0) + dws->num_cs = tmp; + if (dws->num_cs == 0) { + dev_err(&pdev->dev, "missing or wrong num-cs property\n"); + goto out; + } dws->max_freq = clk_get_rate(dwsmmio->clk); ret = dw_spi_add_host(&pdev->dev, dws); @@ -92,12 +102,21 @@ static int dw_spi_mmio_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static struct of_device_id dw_spi_dt_ids[] = { + { .compatible = "snps,designware-spi" }, + {} +}; +MODULE_DEVICE_TABLE(of, dw_spi_dt_ids); +#endif + static struct platform_driver dw_spi_mmio_driver = { .probe = dw_spi_mmio_probe, .remove = dw_spi_mmio_remove, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(dw_spi_dt_ids), }, }; module_platform_driver(dw_spi_mmio_driver); -- 1.8.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply index Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-01-31 10:07 [PATCH v3 0/5] spi: dw: device tree and generic queue support Baruch Siach [not found] ` <cover.1391162172.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> 2014-01-31 10:07 ` [PATCH v3 1/5] spi: dw: migrate to generic queue infrastructure Baruch Siach 2014-01-31 10:07 ` [PATCH v3 2/5] spi: dw: document device tree binding Baruch Siach [not found] ` <a978b266a9b8827747054a689e014ca9efbec235.1391162172.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> 2014-02-02 12:23 ` Gerhard Sittig [not found] ` <20140202122320.GQ20094-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org> 2014-02-03 5:30 ` Baruch Siach 2014-01-31 10:07 ` Baruch Siach [this message] 2014-01-31 10:07 ` [PATCH v3 4/5] spi: dw: add support for gpio controlled chip select Baruch Siach 2014-01-31 10:07 ` [PATCH v3 5/5] spi: dw-mmio: remove HAVE_CLK build dependecy Baruch Siach [not found] ` <207f4522cbabac73422b54006ead761f25380013.1391162172.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> 2014-01-31 16:46 ` Mark Brown 2014-01-31 16:49 ` [PATCH v3 0/5] spi: dw: device tree and generic queue support Mark Brown 2014-02-02 12:49 ` Gerhard Sittig [not found] ` <20140202124941.GS20094-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org> 2014-02-02 13:32 ` Baruch Siach 2014-02-02 14:31 ` Gerhard Sittig [not found] ` <20140202143148.GT20094-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org> 2014-02-02 15:24 ` Baruch Siach 2014-02-05 16:49 ` Gerhard Sittig [not found] ` <20140205164908.GF20094-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org> 2014-04-14 21:05 ` Mark Brown [not found] ` <20140414210547.GK25182-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> 2014-04-16 18:41 ` Gerhard Sittig [not found] ` <20140416184159.GH3528-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org> 2014-04-24 16:40 ` Mark Brown
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=d9d868430ae3cecc0be8faecf5d188d160966533.1391162172.git.baruch@tkos.co.il \ --to=baruch-nswtu9s1w3p6gbpvegmw2w@public.gmane.org \ --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \ --cc=feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \ --cc=jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org \ --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@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
Linux-SPI Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-spi/0 linux-spi/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-spi linux-spi/ https://lore.kernel.org/linux-spi \ linux-spi@vger.kernel.org public-inbox-index linux-spi Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-spi AGPL code for this site: git clone https://public-inbox.org/public-inbox.git