All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
@ 2010-10-14 16:19 Grant Likely
  2010-10-14 16:19 ` [RFC PATCH 1/3] spi/xilinx: Eliminate pdata references from common code Grant Likely
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:19 UTC (permalink / raw)
  To: spi-devel-general, richard.rojfors, john.linn, monstr; +Cc: linux-kernel

Since of_platform_bus_type has been merged with the platform_bus_type,
a single platform driver can now support both use cases.  This patch
series merges the two halves of the xilinx_spi device driver.

Compile tested only.  I haven't booted this yet.

---

Grant Likely (3):
      spi/xilinx: Eliminate pdata references from common code.
      spi/xilinx: fold platform_driver support into main body
      spi/xilinx: merge OF support code into main driver


 drivers/spi/Kconfig            |   14 ----
 drivers/spi/Makefile           |    2 -
 drivers/spi/xilinx_spi.c       |  133 ++++++++++++++++++++++++++++++++++------
 drivers/spi/xilinx_spi.h       |   32 ----------
 drivers/spi/xilinx_spi_of.c    |  133 ----------------------------------------
 drivers/spi/xilinx_spi_pltfm.c |  102 -------------------------------
 6 files changed, 114 insertions(+), 302 deletions(-)
 delete mode 100644 drivers/spi/xilinx_spi.h
 delete mode 100644 drivers/spi/xilinx_spi_of.c
 delete mode 100644 drivers/spi/xilinx_spi_pltfm.c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC PATCH 1/3] spi/xilinx: Eliminate pdata references from common code.
  2010-10-14 16:19 [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers Grant Likely
@ 2010-10-14 16:19 ` Grant Likely
  2010-10-14 16:20   ` Grant Likely
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:19 UTC (permalink / raw)
  To: spi-devel-general, richard.rojfors, john.linn, monstr; +Cc: linux-kernel

The current code has the OF binding modifying the platform_data
pointer which it must not do, and the common code doesn't really need
to use a pdata pointer.  This patch eliminates the platform_data
references from the common part of the driver in preparation for
merging the OF and non-OF versions.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/spi/xilinx_spi.c       |   14 ++++----------
 drivers/spi/xilinx_spi.h       |    2 +-
 drivers/spi/xilinx_spi_of.c    |   17 ++++-------------
 drivers/spi/xilinx_spi_pltfm.c |    4 +++-
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 80f2db5..efb28ba 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -351,18 +351,12 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 }
 
 struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
-	u32 irq, s16 bus_num)
+	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
 {
 	struct spi_master *master;
 	struct xilinx_spi *xspi;
-	struct xspi_platform_data *pdata = dev->platform_data;
 	int ret;
 
-	if (!pdata) {
-		dev_err(dev, "No platform data attached\n");
-		return NULL;
-	}
-
 	master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
 	if (!master)
 		return NULL;
@@ -389,21 +383,21 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
 	}
 
 	master->bus_num = bus_num;
-	master->num_chipselect = pdata->num_chipselect;
+	master->num_chipselect = num_cs;
 #ifdef CONFIG_OF
 	master->dev.of_node = dev->of_node;
 #endif
 
 	xspi->mem = *mem;
 	xspi->irq = irq;
-	if (pdata->little_endian) {
+	if (little_endian) {
 		xspi->read_fn = xspi_read32;
 		xspi->write_fn = xspi_write32;
 	} else {
 		xspi->read_fn = xspi_read32_be;
 		xspi->write_fn = xspi_write32_be;
 	}
-	xspi->bits_per_word = pdata->bits_per_word;
+	xspi->bits_per_word = bits_per_word;
 	if (xspi->bits_per_word == 8) {
 		xspi->tx_fn = xspi_tx8;
 		xspi->rx_fn = xspi_rx8;
diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h
index d211acc..d710a33 100644
--- a/drivers/spi/xilinx_spi.h
+++ b/drivers/spi/xilinx_spi.h
@@ -26,7 +26,7 @@
 #define XILINX_SPI_NAME "xilinx_spi"
 
 struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
-	u32 irq, s16 bus_num);
+	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word);
 
 void xilinx_spi_deinit(struct spi_master *master);
 #endif
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c
index b66c2db..c2d8ade 100644
--- a/drivers/spi/xilinx_spi_of.c
+++ b/drivers/spi/xilinx_spi_of.c
@@ -42,12 +42,11 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
 	const struct of_device_id *match)
 {
 	struct spi_master *master;
-	struct xspi_platform_data *pdata;
 	struct resource r_mem;
 	struct resource r_irq;
 	int rc = 0;
 	const u32 *prop;
-	int len;
+	int len, num_cs;
 
 	rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
 	if (rc) {
@@ -61,21 +60,15 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
 		return -ENODEV;
 	}
 
-	ofdev->dev.platform_data =
-		kzalloc(sizeof(struct xspi_platform_data), GFP_KERNEL);
-	pdata = ofdev->dev.platform_data;
-	if (!pdata)
-		return -ENOMEM;
-
 	/* number of slave select bits is required */
 	prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len);
 	if (!prop || len < sizeof(*prop)) {
 		dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
 		return -EINVAL;
 	}
-	pdata->num_chipselect = *prop;
-	pdata->bits_per_word = 8;
-	master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1);
+	num_cs = __be32_to_cpup(prop);
+	master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1,
+				 num_cs, 0, 8);
 	if (!master)
 		return -ENODEV;
 
@@ -88,8 +81,6 @@ static int __devexit xilinx_spi_remove(struct platform_device *ofdev)
 {
 	xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
 	dev_set_drvdata(&ofdev->dev, 0);
-	kfree(ofdev->dev.platform_data);
-	ofdev->dev.platform_data = NULL;
 	return 0;
 }
 
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c
index 24debac..a16722a 100644
--- a/drivers/spi/xilinx_spi_pltfm.c
+++ b/drivers/spi/xilinx_spi_pltfm.c
@@ -54,7 +54,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
 	if (irq < 0)
 		return -ENXIO;
 
-	master = xilinx_spi_init(&dev->dev, r, irq, dev->id);
+	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
+				 pdata->num_chipselect, pdata->little_endian,
+				 pdata->bits_per_word);
 	if (!master)
 		return -ENODEV;
 


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 2/3] spi/xilinx: fold platform_driver support into main body
@ 2010-10-14 16:20   ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:20 UTC (permalink / raw)
  To: spi-devel-general, richard.rojfors, john.linn, monstr; +Cc: linux-kernel

This patch merges the platform driver support into the main body of
xilinx_spi.c in preparation for merging the OF and non-OF support
code.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/spi/Kconfig            |    7 ---
 drivers/spi/Makefile           |    1 
 drivers/spi/xilinx_spi.c       |   79 ++++++++++++++++++++++++++++--
 drivers/spi/xilinx_spi_pltfm.c |  104 ----------------------------------------
 4 files changed, 73 insertions(+), 118 deletions(-)
 delete mode 100644 drivers/spi/xilinx_spi_pltfm.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9949c25..cebe425 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -345,13 +345,6 @@ config SPI_XILINX_OF
 	help
 	  This is the OF driver for the SPI controller IP from the Xilinx EDK.
 
-config SPI_XILINX_PLTFM
-	tristate "Xilinx SPI controller platform device"
-	depends on SPI_XILINX
-	help
-	  This is the platform driver for the SPI controller IP
-	  from the Xilinx EDK.
-
 config SPI_NUC900
 	tristate "Nuvoton NUC900 series SPI"
 	depends on ARCH_W90X900 && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 557aaad..90e0e6a 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -43,7 +43,6 @@ obj-$(CONFIG_SPI_TOPCLIFF_PCH)		+= spi_topcliff_pch.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
 obj-$(CONFIG_SPI_XILINX_OF)		+= xilinx_spi_of.o
-obj-$(CONFIG_SPI_XILINX_PLTFM)		+= xilinx_spi_pltfm.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
 obj-$(CONFIG_SPI_SH_MSIOF)		+= spi_sh_msiof.o
 obj-$(CONFIG_SPI_STMP3XXX)		+= spi_stmp.o
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index efb28ba..bb3b520 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -1,20 +1,22 @@
 /*
- * xilinx_spi.c
- *
  * Xilinx SPI controller driver (master mode only)
  *
  * Author: MontaVista Software, Inc.
  *	source@mvista.com
  *
- * 2002-2007 (c) MontaVista Software, Inc.  This file is licensed under the
- * terms of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
+ * Copyright (c) 2010 Secret Lab Technologies, Ltd.
+ * Copyright (c) 2009 Intel Corporation
+ * 2002-2007 (c) MontaVista Software, Inc.
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
  */
 
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-
+#include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/io.h>
@@ -456,6 +458,71 @@ void xilinx_spi_deinit(struct spi_master *master)
 }
 EXPORT_SYMBOL(xilinx_spi_deinit);
 
+static int __devinit xilinx_spi_probe(struct platform_device *dev)
+{
+	struct xspi_platform_data *pdata;
+	struct resource *r;
+	int irq;
+	struct spi_master *master;
+	u8 i;
+
+	pdata = dev->dev.platform_data;
+	if (!pdata)
+		return -ENODEV;
+
+	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;
+
+	irq = platform_get_irq(dev, 0);
+	if (irq < 0)
+		return -ENXIO;
+
+	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
+				 pdata->num_chipselect, pdata->little_endian,
+				 pdata->bits_per_word);
+	if (!master)
+		return -ENODEV;
+
+	for (i = 0; i < pdata->num_devices; i++)
+		spi_new_device(master, pdata->devices + i);
+
+	platform_set_drvdata(dev, master);
+	return 0;
+}
+
+static int __devexit xilinx_spi_remove(struct platform_device *dev)
+{
+	xilinx_spi_deinit(platform_get_drvdata(dev));
+	platform_set_drvdata(dev, 0);
+
+	return 0;
+}
+
+/* work with hotplug and coldplug */
+MODULE_ALIAS("platform:" XILINX_SPI_NAME);
+
+static struct platform_driver xilinx_spi_driver = {
+	.probe = xilinx_spi_probe,
+	.remove = __devexit_p(xilinx_spi_remove),
+	.driver = {
+		.name = XILINX_SPI_NAME,
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init xilinx_spi_pltfm_init(void)
+{
+	return platform_driver_register(&xilinx_spi_driver);
+}
+module_init(xilinx_spi_pltfm_init);
+
+static void __exit xilinx_spi_pltfm_exit(void)
+{
+	platform_driver_unregister(&xilinx_spi_driver);
+}
+module_exit(xilinx_spi_pltfm_exit);
+
 MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
 MODULE_DESCRIPTION("Xilinx SPI driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c
deleted file mode 100644
index a16722a..0000000
--- a/drivers/spi/xilinx_spi_pltfm.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Support for Xilinx SPI platform devices
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* Supports:
- * Xilinx SPI devices as platform devices
- *
- * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-
-#include <linux/spi/spi.h>
-#include <linux/spi/spi_bitbang.h>
-#include <linux/spi/xilinx_spi.h>
-
-#include "xilinx_spi.h"
-
-static int __devinit xilinx_spi_probe(struct platform_device *dev)
-{
-	struct xspi_platform_data *pdata;
-	struct resource *r;
-	int irq;
-	struct spi_master *master;
-	u8 i;
-
-	pdata = dev->dev.platform_data;
-	if (!pdata)
-		return -ENODEV;
-
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!r)
-		return -ENODEV;
-
-	irq = platform_get_irq(dev, 0);
-	if (irq < 0)
-		return -ENXIO;
-
-	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
-				 pdata->num_chipselect, pdata->little_endian,
-				 pdata->bits_per_word);
-	if (!master)
-		return -ENODEV;
-
-	for (i = 0; i < pdata->num_devices; i++)
-		spi_new_device(master, pdata->devices + i);
-
-	platform_set_drvdata(dev, master);
-	return 0;
-}
-
-static int __devexit xilinx_spi_remove(struct platform_device *dev)
-{
-	xilinx_spi_deinit(platform_get_drvdata(dev));
-	platform_set_drvdata(dev, 0);
-
-	return 0;
-}
-
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:" XILINX_SPI_NAME);
-
-static struct platform_driver xilinx_spi_driver = {
-	.probe	= xilinx_spi_probe,
-	.remove	= __devexit_p(xilinx_spi_remove),
-	.driver = {
-		.name = XILINX_SPI_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init xilinx_spi_pltfm_init(void)
-{
-	return platform_driver_register(&xilinx_spi_driver);
-}
-module_init(xilinx_spi_pltfm_init);
-
-static void __exit xilinx_spi_pltfm_exit(void)
-{
-	platform_driver_unregister(&xilinx_spi_driver);
-}
-module_exit(xilinx_spi_pltfm_exit);
-
-MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
-MODULE_DESCRIPTION("Xilinx SPI platform driver");
-MODULE_LICENSE("GPL v2");


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 2/3] spi/xilinx: fold platform_driver support into main body
@ 2010-10-14 16:20   ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:20 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	richard.rojfors-l7gf1WXxx3uGw+nKnLezzg,
	john.linn-gjFFaj9aHVfQT0dZR+AlfA, monstr-pSz03upnqPeHXe+LvDLADg
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA

This patch merges the platform driver support into the main body of
xilinx_spi.c in preparation for merging the OF and non-OF support
code.

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 drivers/spi/Kconfig            |    7 ---
 drivers/spi/Makefile           |    1 
 drivers/spi/xilinx_spi.c       |   79 ++++++++++++++++++++++++++++--
 drivers/spi/xilinx_spi_pltfm.c |  104 ----------------------------------------
 4 files changed, 73 insertions(+), 118 deletions(-)
 delete mode 100644 drivers/spi/xilinx_spi_pltfm.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9949c25..cebe425 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -345,13 +345,6 @@ config SPI_XILINX_OF
 	help
 	  This is the OF driver for the SPI controller IP from the Xilinx EDK.
 
-config SPI_XILINX_PLTFM
-	tristate "Xilinx SPI controller platform device"
-	depends on SPI_XILINX
-	help
-	  This is the platform driver for the SPI controller IP
-	  from the Xilinx EDK.
-
 config SPI_NUC900
 	tristate "Nuvoton NUC900 series SPI"
 	depends on ARCH_W90X900 && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 557aaad..90e0e6a 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -43,7 +43,6 @@ obj-$(CONFIG_SPI_TOPCLIFF_PCH)		+= spi_topcliff_pch.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
 obj-$(CONFIG_SPI_XILINX_OF)		+= xilinx_spi_of.o
-obj-$(CONFIG_SPI_XILINX_PLTFM)		+= xilinx_spi_pltfm.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
 obj-$(CONFIG_SPI_SH_MSIOF)		+= spi_sh_msiof.o
 obj-$(CONFIG_SPI_STMP3XXX)		+= spi_stmp.o
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index efb28ba..bb3b520 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -1,20 +1,22 @@
 /*
- * xilinx_spi.c
- *
  * Xilinx SPI controller driver (master mode only)
  *
  * Author: MontaVista Software, Inc.
  *	source-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org
  *
- * 2002-2007 (c) MontaVista Software, Inc.  This file is licensed under the
- * terms of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
+ * Copyright (c) 2010 Secret Lab Technologies, Ltd.
+ * Copyright (c) 2009 Intel Corporation
+ * 2002-2007 (c) MontaVista Software, Inc.
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
  */
 
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-
+#include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/io.h>
@@ -456,6 +458,71 @@ void xilinx_spi_deinit(struct spi_master *master)
 }
 EXPORT_SYMBOL(xilinx_spi_deinit);
 
+static int __devinit xilinx_spi_probe(struct platform_device *dev)
+{
+	struct xspi_platform_data *pdata;
+	struct resource *r;
+	int irq;
+	struct spi_master *master;
+	u8 i;
+
+	pdata = dev->dev.platform_data;
+	if (!pdata)
+		return -ENODEV;
+
+	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;
+
+	irq = platform_get_irq(dev, 0);
+	if (irq < 0)
+		return -ENXIO;
+
+	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
+				 pdata->num_chipselect, pdata->little_endian,
+				 pdata->bits_per_word);
+	if (!master)
+		return -ENODEV;
+
+	for (i = 0; i < pdata->num_devices; i++)
+		spi_new_device(master, pdata->devices + i);
+
+	platform_set_drvdata(dev, master);
+	return 0;
+}
+
+static int __devexit xilinx_spi_remove(struct platform_device *dev)
+{
+	xilinx_spi_deinit(platform_get_drvdata(dev));
+	platform_set_drvdata(dev, 0);
+
+	return 0;
+}
+
+/* work with hotplug and coldplug */
+MODULE_ALIAS("platform:" XILINX_SPI_NAME);
+
+static struct platform_driver xilinx_spi_driver = {
+	.probe = xilinx_spi_probe,
+	.remove = __devexit_p(xilinx_spi_remove),
+	.driver = {
+		.name = XILINX_SPI_NAME,
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init xilinx_spi_pltfm_init(void)
+{
+	return platform_driver_register(&xilinx_spi_driver);
+}
+module_init(xilinx_spi_pltfm_init);
+
+static void __exit xilinx_spi_pltfm_exit(void)
+{
+	platform_driver_unregister(&xilinx_spi_driver);
+}
+module_exit(xilinx_spi_pltfm_exit);
+
 MODULE_AUTHOR("MontaVista Software, Inc. <source-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>");
 MODULE_DESCRIPTION("Xilinx SPI driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c
deleted file mode 100644
index a16722a..0000000
--- a/drivers/spi/xilinx_spi_pltfm.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Support for Xilinx SPI platform devices
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* Supports:
- * Xilinx SPI devices as platform devices
- *
- * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-
-#include <linux/spi/spi.h>
-#include <linux/spi/spi_bitbang.h>
-#include <linux/spi/xilinx_spi.h>
-
-#include "xilinx_spi.h"
-
-static int __devinit xilinx_spi_probe(struct platform_device *dev)
-{
-	struct xspi_platform_data *pdata;
-	struct resource *r;
-	int irq;
-	struct spi_master *master;
-	u8 i;
-
-	pdata = dev->dev.platform_data;
-	if (!pdata)
-		return -ENODEV;
-
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!r)
-		return -ENODEV;
-
-	irq = platform_get_irq(dev, 0);
-	if (irq < 0)
-		return -ENXIO;
-
-	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
-				 pdata->num_chipselect, pdata->little_endian,
-				 pdata->bits_per_word);
-	if (!master)
-		return -ENODEV;
-
-	for (i = 0; i < pdata->num_devices; i++)
-		spi_new_device(master, pdata->devices + i);
-
-	platform_set_drvdata(dev, master);
-	return 0;
-}
-
-static int __devexit xilinx_spi_remove(struct platform_device *dev)
-{
-	xilinx_spi_deinit(platform_get_drvdata(dev));
-	platform_set_drvdata(dev, 0);
-
-	return 0;
-}
-
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:" XILINX_SPI_NAME);
-
-static struct platform_driver xilinx_spi_driver = {
-	.probe	= xilinx_spi_probe,
-	.remove	= __devexit_p(xilinx_spi_remove),
-	.driver = {
-		.name = XILINX_SPI_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init xilinx_spi_pltfm_init(void)
-{
-	return platform_driver_register(&xilinx_spi_driver);
-}
-module_init(xilinx_spi_pltfm_init);
-
-static void __exit xilinx_spi_pltfm_exit(void)
-{
-	platform_driver_unregister(&xilinx_spi_driver);
-}
-module_exit(xilinx_spi_pltfm_exit);
-
-MODULE_AUTHOR("Mocean Laboratories <info-l7gf1WXxx3uGw+nKnLezzg@public.gmane.org>");
-MODULE_DESCRIPTION("Xilinx SPI platform driver");
-MODULE_LICENSE("GPL v2");


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 3/3] spi/xilinx: merge OF support code into main driver
@ 2010-10-14 16:20   ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:20 UTC (permalink / raw)
  To: spi-devel-general, richard.rojfors, john.linn, monstr; +Cc: linux-kernel

Now that the of_platform_bus_type has been merged with the platform
bus type, a single platform driver can handle both OF and non-OF use
cases.  This patch merges the OF support into the platform driver.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/spi/Kconfig         |    7 --
 drivers/spi/Makefile        |    1 
 drivers/spi/xilinx_spi.c    |   56 ++++++++++++++++---
 drivers/spi/xilinx_spi.h    |   32 -----------
 drivers/spi/xilinx_spi_of.c |  124 -------------------------------------------
 5 files changed, 45 insertions(+), 175 deletions(-)
 delete mode 100644 drivers/spi/xilinx_spi.h
 delete mode 100644 drivers/spi/xilinx_spi_of.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index cebe425..6660deb 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -330,7 +330,6 @@ config SPI_XILINX
 	tristate "Xilinx SPI controller common module"
 	depends on HAS_IOMEM && EXPERIMENTAL
 	select SPI_BITBANG
-	select SPI_XILINX_OF if (XILINX_VIRTEX || MICROBLAZE)
 	help
 	  This exposes the SPI controller IP from the Xilinx EDK.
 
@@ -339,12 +338,6 @@ config SPI_XILINX
 
 	  Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
 
-config SPI_XILINX_OF
-	tristate "Xilinx SPI controller OF device"
-	depends on SPI_XILINX && (XILINX_VIRTEX || MICROBLAZE)
-	help
-	  This is the OF driver for the SPI controller IP from the Xilinx EDK.
-
 config SPI_NUC900
 	tristate "Nuvoton NUC900 series SPI"
 	depends on ARCH_W90X900 && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 90e0e6a..dadb6b5 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -42,7 +42,6 @@ obj-$(CONFIG_SPI_S3C64XX)		+= spi_s3c64xx.o
 obj-$(CONFIG_SPI_TOPCLIFF_PCH)		+= spi_topcliff_pch.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
-obj-$(CONFIG_SPI_XILINX_OF)		+= xilinx_spi_of.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
 obj-$(CONFIG_SPI_SH_MSIOF)		+= spi_sh_msiof.o
 obj-$(CONFIG_SPI_STMP3XXX)		+= spi_stmp.o
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index bb3b520..7adaef6 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -16,13 +16,12 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
-#include <linux/io.h>
-
-#include "xilinx_spi.h"
 #include <linux/spi/xilinx_spi.h>
+#include <linux/io.h>
 
 #define XILINX_SPI_NAME "xilinx_spi"
 
@@ -352,6 +351,15 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id xilinx_spi_of_match[] = {
+	{ .compatible = "xlnx,xps-spi-2.00.a", },
+	{ .compatible = "xlnx,xps-spi-2.00.b", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
+#endif
+
 struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
 	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
 {
@@ -462,13 +470,35 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
 {
 	struct xspi_platform_data *pdata;
 	struct resource *r;
-	int irq;
+	int irq, num_cs = 0, little_endian = 0, bits_per_word = 8;
 	struct spi_master *master;
 	u8 i;
 
 	pdata = dev->dev.platform_data;
-	if (!pdata)
-		return -ENODEV;
+	if (pdata) {
+		num_cs = pdata->num_chipselect;
+		little_endian = pdata->little_endian;
+		bits_per_word = pdata->bits_per_word;
+	}
+
+#ifdef CONFIG_OF
+	if (dev->dev.of_node) {
+		const __be32 *prop;
+		int len;
+
+		/* number of slave select bits is required */
+		prop = of_get_property(dev->dev.of_node, "xlnx,num-ss-bits",
+				       &len);
+		if (prop && len >= sizeof(*prop))
+			num_cs = __be32_to_cpup(prop);
+	}
+#endif
+
+	if (!num_cs) {
+		dev_err(&dev->dev, "Missing slave select configuration data\n");
+		return -EINVAL;
+	}
+
 
 	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!r)
@@ -478,14 +508,15 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
 	if (irq < 0)
 		return -ENXIO;
 
-	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
-				 pdata->num_chipselect, pdata->little_endian,
-				 pdata->bits_per_word);
+	master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs,
+				 little_endian, bits_per_word);
 	if (!master)
 		return -ENODEV;
 
-	for (i = 0; i < pdata->num_devices; i++)
-		spi_new_device(master, pdata->devices + i);
+	if (pdata) {
+		for (i = 0; i < pdata->num_devices; i++)
+			spi_new_device(master, pdata->devices + i);
+	}
 
 	platform_set_drvdata(dev, master);
 	return 0;
@@ -508,6 +539,9 @@ static struct platform_driver xilinx_spi_driver = {
 	.driver = {
 		.name = XILINX_SPI_NAME,
 		.owner = THIS_MODULE,
+#ifdef CONFIG_OF
+		.of_match_table = xilinx_spi_of_match,
+#endif
 	},
 };
 
diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h
deleted file mode 100644
index d710a33..0000000
--- a/drivers/spi/xilinx_spi.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Xilinx SPI device driver API and platform data header file
- *
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef _XILINX_SPI_H_
-#define _XILINX_SPI_H_
-
-#include <linux/spi/spi.h>
-#include <linux/spi/spi_bitbang.h>
-
-#define XILINX_SPI_NAME "xilinx_spi"
-
-struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
-	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word);
-
-void xilinx_spi_deinit(struct spi_master *master);
-#endif
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c
deleted file mode 100644
index c2d8ade..0000000
--- a/drivers/spi/xilinx_spi_of.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Xilinx SPI OF device driver
- *
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* Supports:
- * Xilinx SPI devices as OF devices
- *
- * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
-#include <linux/of_device.h>
-#include <linux/of_spi.h>
-
-#include <linux/spi/xilinx_spi.h>
-#include "xilinx_spi.h"
-
-
-static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
-	const struct of_device_id *match)
-{
-	struct spi_master *master;
-	struct resource r_mem;
-	struct resource r_irq;
-	int rc = 0;
-	const u32 *prop;
-	int len, num_cs;
-
-	rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
-	if (rc) {
-		dev_warn(&ofdev->dev, "invalid address\n");
-		return rc;
-	}
-
-	rc = of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq);
-	if (rc == NO_IRQ) {
-		dev_warn(&ofdev->dev, "no IRQ found\n");
-		return -ENODEV;
-	}
-
-	/* number of slave select bits is required */
-	prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len);
-	if (!prop || len < sizeof(*prop)) {
-		dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
-		return -EINVAL;
-	}
-	num_cs = __be32_to_cpup(prop);
-	master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1,
-				 num_cs, 0, 8);
-	if (!master)
-		return -ENODEV;
-
-	dev_set_drvdata(&ofdev->dev, master);
-
-	return 0;
-}
-
-static int __devexit xilinx_spi_remove(struct platform_device *ofdev)
-{
-	xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
-	dev_set_drvdata(&ofdev->dev, 0);
-	return 0;
-}
-
-static int __exit xilinx_spi_of_remove(struct platform_device *op)
-{
-	return xilinx_spi_remove(op);
-}
-
-static const struct of_device_id xilinx_spi_of_match[] = {
-	{ .compatible = "xlnx,xps-spi-2.00.a", },
-	{ .compatible = "xlnx,xps-spi-2.00.b", },
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
-
-static struct of_platform_driver xilinx_spi_of_driver = {
-	.probe = xilinx_spi_of_probe,
-	.remove = __exit_p(xilinx_spi_of_remove),
-	.driver = {
-		.name = "xilinx-xps-spi",
-		.owner = THIS_MODULE,
-		.of_match_table = xilinx_spi_of_match,
-	},
-};
-
-static int __init xilinx_spi_of_init(void)
-{
-	return of_register_platform_driver(&xilinx_spi_of_driver);
-}
-module_init(xilinx_spi_of_init);
-
-static void __exit xilinx_spi_of_exit(void)
-{
-	of_unregister_platform_driver(&xilinx_spi_of_driver);
-}
-module_exit(xilinx_spi_of_exit);
-
-MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
-MODULE_DESCRIPTION("Xilinx SPI platform driver");
-MODULE_LICENSE("GPL v2");


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 3/3] spi/xilinx: merge OF support code into main driver
@ 2010-10-14 16:20   ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-10-14 16:20 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	richard.rojfors-l7gf1WXxx3uGw+nKnLezzg,
	john.linn-gjFFaj9aHVfQT0dZR+AlfA, monstr-pSz03upnqPeHXe+LvDLADg
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA

Now that the of_platform_bus_type has been merged with the platform
bus type, a single platform driver can handle both OF and non-OF use
cases.  This patch merges the OF support into the platform driver.

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 drivers/spi/Kconfig         |    7 --
 drivers/spi/Makefile        |    1 
 drivers/spi/xilinx_spi.c    |   56 ++++++++++++++++---
 drivers/spi/xilinx_spi.h    |   32 -----------
 drivers/spi/xilinx_spi_of.c |  124 -------------------------------------------
 5 files changed, 45 insertions(+), 175 deletions(-)
 delete mode 100644 drivers/spi/xilinx_spi.h
 delete mode 100644 drivers/spi/xilinx_spi_of.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index cebe425..6660deb 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -330,7 +330,6 @@ config SPI_XILINX
 	tristate "Xilinx SPI controller common module"
 	depends on HAS_IOMEM && EXPERIMENTAL
 	select SPI_BITBANG
-	select SPI_XILINX_OF if (XILINX_VIRTEX || MICROBLAZE)
 	help
 	  This exposes the SPI controller IP from the Xilinx EDK.
 
@@ -339,12 +338,6 @@ config SPI_XILINX
 
 	  Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
 
-config SPI_XILINX_OF
-	tristate "Xilinx SPI controller OF device"
-	depends on SPI_XILINX && (XILINX_VIRTEX || MICROBLAZE)
-	help
-	  This is the OF driver for the SPI controller IP from the Xilinx EDK.
-
 config SPI_NUC900
 	tristate "Nuvoton NUC900 series SPI"
 	depends on ARCH_W90X900 && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 90e0e6a..dadb6b5 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -42,7 +42,6 @@ obj-$(CONFIG_SPI_S3C64XX)		+= spi_s3c64xx.o
 obj-$(CONFIG_SPI_TOPCLIFF_PCH)		+= spi_topcliff_pch.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
-obj-$(CONFIG_SPI_XILINX_OF)		+= xilinx_spi_of.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
 obj-$(CONFIG_SPI_SH_MSIOF)		+= spi_sh_msiof.o
 obj-$(CONFIG_SPI_STMP3XXX)		+= spi_stmp.o
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index bb3b520..7adaef6 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -16,13 +16,12 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
-#include <linux/io.h>
-
-#include "xilinx_spi.h"
 #include <linux/spi/xilinx_spi.h>
+#include <linux/io.h>
 
 #define XILINX_SPI_NAME "xilinx_spi"
 
@@ -352,6 +351,15 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id xilinx_spi_of_match[] = {
+	{ .compatible = "xlnx,xps-spi-2.00.a", },
+	{ .compatible = "xlnx,xps-spi-2.00.b", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
+#endif
+
 struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
 	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
 {
@@ -462,13 +470,35 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
 {
 	struct xspi_platform_data *pdata;
 	struct resource *r;
-	int irq;
+	int irq, num_cs = 0, little_endian = 0, bits_per_word = 8;
 	struct spi_master *master;
 	u8 i;
 
 	pdata = dev->dev.platform_data;
-	if (!pdata)
-		return -ENODEV;
+	if (pdata) {
+		num_cs = pdata->num_chipselect;
+		little_endian = pdata->little_endian;
+		bits_per_word = pdata->bits_per_word;
+	}
+
+#ifdef CONFIG_OF
+	if (dev->dev.of_node) {
+		const __be32 *prop;
+		int len;
+
+		/* number of slave select bits is required */
+		prop = of_get_property(dev->dev.of_node, "xlnx,num-ss-bits",
+				       &len);
+		if (prop && len >= sizeof(*prop))
+			num_cs = __be32_to_cpup(prop);
+	}
+#endif
+
+	if (!num_cs) {
+		dev_err(&dev->dev, "Missing slave select configuration data\n");
+		return -EINVAL;
+	}
+
 
 	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!r)
@@ -478,14 +508,15 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
 	if (irq < 0)
 		return -ENXIO;
 
-	master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
-				 pdata->num_chipselect, pdata->little_endian,
-				 pdata->bits_per_word);
+	master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs,
+				 little_endian, bits_per_word);
 	if (!master)
 		return -ENODEV;
 
-	for (i = 0; i < pdata->num_devices; i++)
-		spi_new_device(master, pdata->devices + i);
+	if (pdata) {
+		for (i = 0; i < pdata->num_devices; i++)
+			spi_new_device(master, pdata->devices + i);
+	}
 
 	platform_set_drvdata(dev, master);
 	return 0;
@@ -508,6 +539,9 @@ static struct platform_driver xilinx_spi_driver = {
 	.driver = {
 		.name = XILINX_SPI_NAME,
 		.owner = THIS_MODULE,
+#ifdef CONFIG_OF
+		.of_match_table = xilinx_spi_of_match,
+#endif
 	},
 };
 
diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h
deleted file mode 100644
index d710a33..0000000
--- a/drivers/spi/xilinx_spi.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Xilinx SPI device driver API and platform data header file
- *
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef _XILINX_SPI_H_
-#define _XILINX_SPI_H_
-
-#include <linux/spi/spi.h>
-#include <linux/spi/spi_bitbang.h>
-
-#define XILINX_SPI_NAME "xilinx_spi"
-
-struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
-	u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word);
-
-void xilinx_spi_deinit(struct spi_master *master);
-#endif
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c
deleted file mode 100644
index c2d8ade..0000000
--- a/drivers/spi/xilinx_spi_of.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Xilinx SPI OF device driver
- *
- * Copyright (c) 2009 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* Supports:
- * Xilinx SPI devices as OF devices
- *
- * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
-#include <linux/of_device.h>
-#include <linux/of_spi.h>
-
-#include <linux/spi/xilinx_spi.h>
-#include "xilinx_spi.h"
-
-
-static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev,
-	const struct of_device_id *match)
-{
-	struct spi_master *master;
-	struct resource r_mem;
-	struct resource r_irq;
-	int rc = 0;
-	const u32 *prop;
-	int len, num_cs;
-
-	rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
-	if (rc) {
-		dev_warn(&ofdev->dev, "invalid address\n");
-		return rc;
-	}
-
-	rc = of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq);
-	if (rc == NO_IRQ) {
-		dev_warn(&ofdev->dev, "no IRQ found\n");
-		return -ENODEV;
-	}
-
-	/* number of slave select bits is required */
-	prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len);
-	if (!prop || len < sizeof(*prop)) {
-		dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
-		return -EINVAL;
-	}
-	num_cs = __be32_to_cpup(prop);
-	master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1,
-				 num_cs, 0, 8);
-	if (!master)
-		return -ENODEV;
-
-	dev_set_drvdata(&ofdev->dev, master);
-
-	return 0;
-}
-
-static int __devexit xilinx_spi_remove(struct platform_device *ofdev)
-{
-	xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
-	dev_set_drvdata(&ofdev->dev, 0);
-	return 0;
-}
-
-static int __exit xilinx_spi_of_remove(struct platform_device *op)
-{
-	return xilinx_spi_remove(op);
-}
-
-static const struct of_device_id xilinx_spi_of_match[] = {
-	{ .compatible = "xlnx,xps-spi-2.00.a", },
-	{ .compatible = "xlnx,xps-spi-2.00.b", },
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
-
-static struct of_platform_driver xilinx_spi_of_driver = {
-	.probe = xilinx_spi_of_probe,
-	.remove = __exit_p(xilinx_spi_of_remove),
-	.driver = {
-		.name = "xilinx-xps-spi",
-		.owner = THIS_MODULE,
-		.of_match_table = xilinx_spi_of_match,
-	},
-};
-
-static int __init xilinx_spi_of_init(void)
-{
-	return of_register_platform_driver(&xilinx_spi_of_driver);
-}
-module_init(xilinx_spi_of_init);
-
-static void __exit xilinx_spi_of_exit(void)
-{
-	of_unregister_platform_driver(&xilinx_spi_of_driver);
-}
-module_exit(xilinx_spi_of_exit);
-
-MODULE_AUTHOR("Mocean Laboratories <info-l7gf1WXxx3uGw+nKnLezzg@public.gmane.org>");
-MODULE_DESCRIPTION("Xilinx SPI platform driver");
-MODULE_LICENSE("GPL v2");


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-10-14 16:19 [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers Grant Likely
                   ` (2 preceding siblings ...)
  2010-10-14 16:20   ` Grant Likely
@ 2010-11-08 13:29 ` Michal Simek
  2010-11-08 14:34     ` John Linn
  3 siblings, 1 reply; 14+ messages in thread
From: Michal Simek @ 2010-11-08 13:29 UTC (permalink / raw)
  To: Grant Likely; +Cc: spi-devel-general, richard.rojfors, john.linn, linux-kernel

Hi Grant,

Grant Likely wrote:
> Since of_platform_bus_type has been merged with the platform_bus_type,
> a single platform driver can now support both use cases.  This patch
> series merges the two halves of the xilinx_spi device driver.
> 
> Compile tested only.  I haven't booted this yet.

I have tested it on sp605 and works well. Have you added that patches
to your repository? Or are they somewhere else? Who is responsible for?

I would like to also discuss one change which is related mmc_spi kernel driver.
Let me describe the problem. Microblaze can use dma in all addresses
that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
which is xilinx spi driver.

Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
mmc_spi.c:~1395
	if (spi->master->dev.parent->dma_mask) {
		struct device	*dev = spi->master->dev.parent;

		host->dma_dev = dev;


Based on this one our customer came with the following solution to setup
dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.

I think that this is nice solution but I would like to be sure that I didn't miss anything.
After that i will create proper patch with description.


diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 7adaef6..3612e1b 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -519,6 +519,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
        }

        platform_set_drvdata(dev, master);
+       /* clear the dma_mask, to try to disable use of dma */
+       dev->dev.dma_mask = 0;
+
        return 0;
 }


Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-08 13:29 ` [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers Michal Simek
@ 2010-11-08 14:34     ` John Linn
  0 siblings, 0 replies; 14+ messages in thread
From: John Linn @ 2010-11-08 14:34 UTC (permalink / raw)
  To: monstr, grant.likely; +Cc: spi-devel-general, richard.rojfors, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2938 bytes --]

> -----Original Message-----
> From: Michal Simek [mailto:monstr@monstr.eu]
> Sent: Monday, November 08, 2010 6:29 AM
> To: grant.likely@secretlab.ca
> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
> kernel@vger.kernel.org
> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
> 
> Hi Grant,
> 
> Grant Likely wrote:
> > Since of_platform_bus_type has been merged with the platform_bus_type,
> > a single platform driver can now support both use cases.  This patch
> > series merges the two halves of the xilinx_spi device driver.
> >
> > Compile tested only.  I haven't booted this yet.
> 
> I have tested it on sp605 and works well. Have you added that patches
> to your repository? Or are they somewhere else? Who is responsible for?
> 
> I would like to also discuss one change which is related mmc_spi kernel driver.
> Let me describe the problem. Microblaze can use dma in all addresses
> that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
> Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
> which is xilinx spi driver.
> 
> Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
> mmc_spi.c:~1395
> 	if (spi->master->dev.parent->dma_mask) {
> 		struct device	*dev = spi->master->dev.parent;
> 
> 		host->dma_dev = dev;
> 
> 
> Based on this one our customer came with the following solution to setup
> dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.
> 
> I think that this is nice solution but I would like to be sure that I didn't miss anything.
> After that i will create proper patch with description.

Seems reasonable to me.

Thanks,
John

> 
> 
> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
> index 7adaef6..3612e1b 100644
> --- a/drivers/spi/xilinx_spi.c
> +++ b/drivers/spi/xilinx_spi.c
> @@ -519,6 +519,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
>         }
> 
>         platform_set_drvdata(dev, master);
> +       /* clear the dma_mask, to try to disable use of dma */
> +       dev->dev.dma_mask = 0;
> +
>         return 0;
>  }
> 
> 
> Thanks,
> Michal
> 
> 
> --
> Michal Simek, Ing. (M.Eng)
> w: www.monstr.eu p: +42-0-721842854
> Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
> Microblaze U-BOOT custodian


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
@ 2010-11-08 14:34     ` John Linn
  0 siblings, 0 replies; 14+ messages in thread
From: John Linn @ 2010-11-08 14:34 UTC (permalink / raw)
  To: monstr, grant.likely; +Cc: spi-devel-general, richard.rojfors, linux-kernel

> -----Original Message-----
> From: Michal Simek [mailto:monstr@monstr.eu]
> Sent: Monday, November 08, 2010 6:29 AM
> To: grant.likely@secretlab.ca
> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
> kernel@vger.kernel.org
> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
> 
> Hi Grant,
> 
> Grant Likely wrote:
> > Since of_platform_bus_type has been merged with the platform_bus_type,
> > a single platform driver can now support both use cases.  This patch
> > series merges the two halves of the xilinx_spi device driver.
> >
> > Compile tested only.  I haven't booted this yet.
> 
> I have tested it on sp605 and works well. Have you added that patches
> to your repository? Or are they somewhere else? Who is responsible for?
> 
> I would like to also discuss one change which is related mmc_spi kernel driver.
> Let me describe the problem. Microblaze can use dma in all addresses
> that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
> Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
> which is xilinx spi driver.
> 
> Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
> mmc_spi.c:~1395
> 	if (spi->master->dev.parent->dma_mask) {
> 		struct device	*dev = spi->master->dev.parent;
> 
> 		host->dma_dev = dev;
> 
> 
> Based on this one our customer came with the following solution to setup
> dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.
> 
> I think that this is nice solution but I would like to be sure that I didn't miss anything.
> After that i will create proper patch with description.

Seems reasonable to me.

Thanks,
John

> 
> 
> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
> index 7adaef6..3612e1b 100644
> --- a/drivers/spi/xilinx_spi.c
> +++ b/drivers/spi/xilinx_spi.c
> @@ -519,6 +519,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
>         }
> 
>         platform_set_drvdata(dev, master);
> +       /* clear the dma_mask, to try to disable use of dma */
> +       dev->dev.dma_mask = 0;
> +
>         return 0;
>  }
> 
> 
> Thanks,
> Michal
> 
> 
> --
> Michal Simek, Ing. (M.Eng)
> w: www.monstr.eu p: +42-0-721842854
> Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
> Microblaze U-BOOT custodian


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-08 14:34     ` John Linn
  (?)
@ 2010-11-08 18:01     ` Grant Likely
  2010-11-09  7:30       ` Michal Simek
  2010-11-10 13:18       ` Michal Simek
  -1 siblings, 2 replies; 14+ messages in thread
From: Grant Likely @ 2010-11-08 18:01 UTC (permalink / raw)
  To: John Linn; +Cc: monstr, spi-devel-general, richard.rojfors, linux-kernel

On Mon, Nov 8, 2010 at 9:34 AM, John Linn <John.Linn@xilinx.com> wrote:
>> -----Original Message-----
>> From: Michal Simek [mailto:monstr@monstr.eu]
>> Sent: Monday, November 08, 2010 6:29 AM
>> To: grant.likely@secretlab.ca
>> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
>> kernel@vger.kernel.org
>> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
>>
>> Hi Grant,
>>
>> Grant Likely wrote:
>> > Since of_platform_bus_type has been merged with the platform_bus_type,
>> > a single platform driver can now support both use cases.  This patch
>> > series merges the two halves of the xilinx_spi device driver.
>> >
>> > Compile tested only.  I haven't booted this yet.
>>
>> I have tested it on sp605 and works well. Have you added that patches
>> to your repository? Or are they somewhere else? Who is responsible for?
>>
>> I would like to also discuss one change which is related mmc_spi kernel driver.
>> Let me describe the problem. Microblaze can use dma in all addresses
>> that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
>> Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
>> which is xilinx spi driver.
>>
>> Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
>> mmc_spi.c:~1395
>>       if (spi->master->dev.parent->dma_mask) {
>>               struct device   *dev = spi->master->dev.parent;
>>
>>               host->dma_dev = dev;
>>
>>
>> Based on this one our customer came with the following solution to setup
>> dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.
>>
>> I think that this is nice solution but I would like to be sure that I didn't miss anything.
>> After that i will create proper patch with description.
>
> Seems reasonable to me.

Hmmm, that actually is not sane.  Ideally, drivers should never be
mucking with the dma mask.  It is supposed to only be set by the code
actually registering the device.  The mmc code should not be looking
at the parent's dma mask to determine if DMA is available; the spi bus
drivers should be explicitly stating whether or not it supports DMA.
The mmc_spi code is doing the wrong thing here.

That being said, until the mmc_spi code is fixed (and all the users
are fixed up so DMA still works) then this patch is probably the best
solution.  However, please note that dev->dma_mask is a pointer, so
you should actually be setting it to NULL.

g.

>
> Thanks,
> John
>
>>
>>
>> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
>> index 7adaef6..3612e1b 100644
>> --- a/drivers/spi/xilinx_spi.c
>> +++ b/drivers/spi/xilinx_spi.c
>> @@ -519,6 +519,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
>>         }
>>
>>         platform_set_drvdata(dev, master);
>> +       /* clear the dma_mask, to try to disable use of dma */
>> +       dev->dev.dma_mask = 0;
>> +
>>         return 0;
>>  }
>>
>>
>> Thanks,
>> Michal
>>
>>
>> --
>> Michal Simek, Ing. (M.Eng)
>> w: www.monstr.eu p: +42-0-721842854
>> Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
>> Microblaze U-BOOT custodian
>
>
> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-08 18:01     ` Grant Likely
@ 2010-11-09  7:30       ` Michal Simek
  2010-11-09 21:16         ` Grant Likely
  2010-11-10 13:18       ` Michal Simek
  1 sibling, 1 reply; 14+ messages in thread
From: Michal Simek @ 2010-11-09  7:30 UTC (permalink / raw)
  To: Grant Likely
  Cc: John Linn, spi-devel-general, richard.rojfors, linux-kernel, dbrownell

Hi, [cc: David Brownell]

Grant Likely wrote:
> On Mon, Nov 8, 2010 at 9:34 AM, John Linn <John.Linn@xilinx.com> wrote:
>>> -----Original Message-----
>>> From: Michal Simek [mailto:monstr@monstr.eu]
>>> Sent: Monday, November 08, 2010 6:29 AM
>>> To: grant.likely@secretlab.ca
>>> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
>>> kernel@vger.kernel.org
>>> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
>>>
>>> Hi Grant,
>>>
>>> Grant Likely wrote:
>>>> Since of_platform_bus_type has been merged with the platform_bus_type,
>>>> a single platform driver can now support both use cases.  This patch
>>>> series merges the two halves of the xilinx_spi device driver.
>>>>
>>>> Compile tested only.  I haven't booted this yet.
>>> I have tested it on sp605 and works well. Have you added that patches
>>> to your repository? Or are they somewhere else? Who is responsible for?
>>>
>>> I would like to also discuss one change which is related mmc_spi kernel driver.
>>> Let me describe the problem. Microblaze can use dma in all addresses
>>> that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
>>> Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
>>> which is xilinx spi driver.
>>>
>>> Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
>>> mmc_spi.c:~1395
>>>       if (spi->master->dev.parent->dma_mask) {
>>>               struct device   *dev = spi->master->dev.parent;
>>>
>>>               host->dma_dev = dev;
>>>
>>>
>>> Based on this one our customer came with the following solution to setup
>>> dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.
>>>
>>> I think that this is nice solution but I would like to be sure that I didn't miss anything.
>>> After that i will create proper patch with description.
>> Seems reasonable to me.
> 
> Hmmm, that actually is not sane.  Ideally, drivers should never be
> mucking with the dma mask.  It is supposed to only be set by the code
> actually registering the device.  The mmc code should not be looking
> at the parent's dma mask to determine if DMA is available; the spi bus
> drivers should be explicitly stating whether or not it supports DMA.
> The mmc_spi code is doing the wrong thing here.

I have no problem to fix mmc_spi driver but what is the standard way how to detect
DMA capability for this case? This part of code is in mmc_spi from the beginning that's why I am
wondering that none complain about.

David?

Sorry I don't have HW where I can test it. :-(

> 
> That being said, until the mmc_spi code is fixed (and all the users
> are fixed up so DMA still works) then this patch is probably the best
> solution.  However, please note that dev->dma_mask is a pointer, so
> you should actually be setting it to NULL.

Yes truth.

Michal



> 
> g.
> 
>> Thanks,
>> John
>>
>>>
>>> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
>>> index 7adaef6..3612e1b 100644
>>> --- a/drivers/spi/xilinx_spi.c
>>> +++ b/drivers/spi/xilinx_spi.c
>>> @@ -519,6 +519,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev)
>>>         }
>>>
>>>         platform_set_drvdata(dev, master);
>>> +       /* clear the dma_mask, to try to disable use of dma */
>>> +       dev->dev.dma_mask = 0;
>>> +
>>>         return 0;
>>>  }
>>>
>>>
>>> Thanks,
>>> Michal
>>>
>>>
>>> --
>>> Michal Simek, Ing. (M.Eng)
>>> w: www.monstr.eu p: +42-0-721842854
>>> Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
>>> Microblaze U-BOOT custodian
>>
>> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
>>
> 
> 
> 


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-09  7:30       ` Michal Simek
@ 2010-11-09 21:16         ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-11-09 21:16 UTC (permalink / raw)
  To: monstr
  Cc: John Linn, spi-devel-general, richard.rojfors, linux-kernel, dbrownell

On Tue, Nov 9, 2010 at 12:30 AM, Michal Simek <monstr@monstr.eu> wrote:
> Hi, [cc: David Brownell]
>
> Grant Likely wrote:
>> On Mon, Nov 8, 2010 at 9:34 AM, John Linn <John.Linn@xilinx.com> wrote:
>>>> -----Original Message-----
>>>> From: Michal Simek [mailto:monstr@monstr.eu]
>>>> Sent: Monday, November 08, 2010 6:29 AM
>>>> To: grant.likely@secretlab.ca
>>>> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
>>>> kernel@vger.kernel.org
>>>> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
>>>>
>>>> Hi Grant,
>>>>
>>>> Grant Likely wrote:
>>>>> Since of_platform_bus_type has been merged with the platform_bus_type,
>>>>> a single platform driver can now support both use cases.  This patch
>>>>> series merges the two halves of the xilinx_spi device driver.
>>>>>
>>>>> Compile tested only.  I haven't booted this yet.
>>>> I have tested it on sp605 and works well. Have you added that patches
>>>> to your repository? Or are they somewhere else? Who is responsible for?
>>>>
>>>> I would like to also discuss one change which is related mmc_spi kernel driver.
>>>> Let me describe the problem. Microblaze can use dma in all addresses
>>>> that's why dma_mask is setup to 0xffffffff in of_platform_device_create.
>>>> Xilinx spi driver doesn't support dma but mmc_spi driver is checking dma_mask in parent device
>>>> which is xilinx spi driver.
>>>>
>>>> Here is the corresponding the part of code (Expect dma_mask=zero for no dma operations).
>>>> mmc_spi.c:~1395
>>>>       if (spi->master->dev.parent->dma_mask) {
>>>>               struct device   *dev = spi->master->dev.parent;
>>>>
>>>>               host->dma_dev = dev;
>>>>
>>>>
>>>> Based on this one our customer came with the following solution to setup
>>>> dma_mask in xilinx_spi to zero and then mmc_spi doesn't setup dma operation.
>>>>
>>>> I think that this is nice solution but I would like to be sure that I didn't miss anything.
>>>> After that i will create proper patch with description.
>>> Seems reasonable to me.
>>
>> Hmmm, that actually is not sane.  Ideally, drivers should never be
>> mucking with the dma mask.  It is supposed to only be set by the code
>> actually registering the device.  The mmc code should not be looking
>> at the parent's dma mask to determine if DMA is available; the spi bus
>> drivers should be explicitly stating whether or not it supports DMA.
>> The mmc_spi code is doing the wrong thing here.
>
> I have no problem to fix mmc_spi driver but what is the standard way how to detect
> DMA capability for this case? This part of code is in mmc_spi from the beginning that's why I am
> wondering that none complain about.
>
> David?
>
> Sorry I don't have HW where I can test it. :-(

Nobody will have *all* the hardware required to test it.  The solution
is actually really hard because it requires auditing all of the spi
bus drivers, figuring out which ones of them support dma, and then
publishing that information in a way readable by the spi_device
drivers.  For the time being, you're solution is probably the most
reasonable.

g.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-08 18:01     ` Grant Likely
  2010-11-09  7:30       ` Michal Simek
@ 2010-11-10 13:18       ` Michal Simek
  2010-11-10 15:59         ` Grant Likely
  1 sibling, 1 reply; 14+ messages in thread
From: Michal Simek @ 2010-11-10 13:18 UTC (permalink / raw)
  To: Grant Likely; +Cc: John Linn, spi-devel-general, richard.rojfors, linux-kernel

Grant Likely wrote:
> On Mon, Nov 8, 2010 at 9:34 AM, John Linn <John.Linn@xilinx.com> wrote:
>>> -----Original Message-----
>>> From: Michal Simek [mailto:monstr@monstr.eu]
>>> Sent: Monday, November 08, 2010 6:29 AM
>>> To: grant.likely@secretlab.ca
>>> Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
>>> kernel@vger.kernel.org
>>> Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
>>>
>>> Hi Grant,
>>>
>>> Grant Likely wrote:
>>>> Since of_platform_bus_type has been merged with the platform_bus_type,
>>>> a single platform driver can now support both use cases.  This patch
>>>> series merges the two halves of the xilinx_spi device driver.
>>>>
>>>> Compile tested only.  I haven't booted this yet.
>>> I have tested it on sp605 and works well. Have you added that patches
>>> to your repository? Or are they somewhere else? Who is responsible for?

Grant: Can you answer my questions?

That our patch about DMA should follow your three patches.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
  2010-11-10 13:18       ` Michal Simek
@ 2010-11-10 15:59         ` Grant Likely
  0 siblings, 0 replies; 14+ messages in thread
From: Grant Likely @ 2010-11-10 15:59 UTC (permalink / raw)
  To: Michal Simek; +Cc: John Linn, spi-devel-general, richard.rojfors, linux-kernel

On Wed, Nov 10, 2010 at 02:18:38PM +0100, Michal Simek wrote:
> Grant Likely wrote:
> >On Mon, Nov 8, 2010 at 9:34 AM, John Linn <John.Linn@xilinx.com> wrote:
> >>>-----Original Message-----
> >>>From: Michal Simek [mailto:monstr@monstr.eu]
> >>>Sent: Monday, November 08, 2010 6:29 AM
> >>>To: grant.likely@secretlab.ca
> >>>Cc: spi-devel-general@lists.sourceforge.net; richard.rojfors@mocean-labs.com; John Linn; linux-
> >>>kernel@vger.kernel.org
> >>>Subject: Re: [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers
> >>>
> >>>Hi Grant,
> >>>
> >>>Grant Likely wrote:
> >>>>Since of_platform_bus_type has been merged with the platform_bus_type,
> >>>>a single platform driver can now support both use cases.  This patch
> >>>>series merges the two halves of the xilinx_spi device driver.
> >>>>
> >>>>Compile tested only.  I haven't booted this yet.
> >>>I have tested it on sp605 and works well. Have you added that patches
> >>>to your repository? Or are they somewhere else? Who is responsible for?
> 
> Grant: Can you answer my questions?
> 
> That our patch about DMA should follow your three patches.

It is in my spi/next branch which I haven't pushed out to my public
tree yet.  Sometime today I will after I've given it one more run
through.

g.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-11-10 15:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-14 16:19 [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers Grant Likely
2010-10-14 16:19 ` [RFC PATCH 1/3] spi/xilinx: Eliminate pdata references from common code Grant Likely
2010-10-14 16:20 ` [RFC PATCH 2/3] spi/xilinx: fold platform_driver support into main body Grant Likely
2010-10-14 16:20   ` Grant Likely
2010-10-14 16:20 ` [RFC PATCH 3/3] spi/xilinx: merge OF support code into main driver Grant Likely
2010-10-14 16:20   ` Grant Likely
2010-11-08 13:29 ` [RFC PATCH 0/3] spi/xilinx: Merge OF and non-OF drivers Michal Simek
2010-11-08 14:34   ` John Linn
2010-11-08 14:34     ` John Linn
2010-11-08 18:01     ` Grant Likely
2010-11-09  7:30       ` Michal Simek
2010-11-09 21:16         ` Grant Likely
2010-11-10 13:18       ` Michal Simek
2010-11-10 15:59         ` Grant Likely

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.