linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	john.williams-g5w7nrANp4BDPfheJLI6IQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	John.Linn-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org,
	Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
Subject: [PATCH v3 1/2] i2c: xiic: Add OF support for Xilinx i2c bus interface
Date: Tue, 22 Feb 2011 18:49:30 +0100	[thread overview]
Message-ID: <1298396971-611-1-git-send-email-monstr@monstr.eu> (raw)

Add OF support to Xilinx i2c bus interface.
It is used on Microblaze systems.

Signed-off-by: Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
---
 drivers/i2c/busses/i2c-xiic.c |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index a9c419e..0b7647b 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -41,6 +41,11 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_i2c.h>
+#include <linux/of_address.h>
+
 #define DRIVER_NAME "xiic-i2c"
 
 enum xilinx_i2c_state {
@@ -426,7 +431,7 @@ static void xiic_process(struct xiic_i2c *i2c)
 			xiic_wakeup(i2c, STATE_ERROR);
 
 	} else if (pend & (XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_HALF_MASK)) {
-		/* Transmit register/FIFO is empty or ½ empty */
+		/* Transmit register/FIFO is empty or 1/2 empty */
 
 		clr = pend &
 			(XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_HALF_MASK);
@@ -704,10 +709,6 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
 	if (irq < 0)
 		goto resource_missing;
 
-	pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data;
-	if (!pdata)
-		return -EINVAL;
-
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
 		return -ENOMEM;
@@ -730,6 +731,7 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
 	i2c->adap = xiic_adapter;
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = &pdev->dev;
+	i2c->adap.dev.of_node = of_node_get(pdev->dev.of_node);
 
 	xiic_reinit(i2c);
 
@@ -748,9 +750,16 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
 		goto add_adapter_failed;
 	}
 
-	/* add in known devices to the bus */
-	for (i = 0; i < pdata->num_devices; i++)
-		i2c_new_device(&i2c->adap, pdata->devices + i);
+	dev_info(&pdev->dev, "mapped to 0x%08X, irq=%d\n",
+					(unsigned int)i2c->base, irq);
+
+	pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data;
+	if (pdata) {
+		/* add in known devices to the bus */
+		for (i = 0; i < pdata->num_devices; i++)
+			i2c_new_device(&i2c->adap, pdata->devices + i);
+	}
+	of_i2c_register_devices(&i2c->adap);
 
 	return 0;
 
@@ -799,12 +808,24 @@ static int __devexit xiic_i2c_remove(struct platform_device* pdev)
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:"DRIVER_NAME);
 
+#ifdef CONFIG_OF
+/* Match table for of_platform binding */
+static struct of_device_id __devinitdata xilinx_iic_of_match[] = {
+	{ .compatible = "xlnx,xps-iic-2.00.a", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, xilinx_iic_of_match);
+#else
+# define xilinx_iic_of_match NULL
+#endif
+
 static struct platform_driver xiic_i2c_driver = {
 	.probe   = xiic_i2c_probe,
 	.remove  = __devexit_p(xiic_i2c_remove),
 	.driver  = {
 		.owner = THIS_MODULE,
 		.name = DRIVER_NAME,
+		.of_match_table = xilinx_iic_of_match,
 	},
 };
 
-- 
1.5.5.6

             reply	other threads:[~2011-02-22 17:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 17:49 Michal Simek [this message]
     [not found] ` <1298396971-611-1-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-02-22 17:49   ` [PATCH v3 2/2] i2c: xiic: Use 32bit accesses only Michal Simek
     [not found]     ` <1298396971-611-2-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-02-22 18:08       ` Grant Likely
     [not found]         ` <AANLkTinRVKMdOU-8DYLHe5q92nb3ysKnnG-jq8f++AEs-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-23  8:08           ` Michal Simek
2011-02-23  8:36             ` Arnd Bergmann
     [not found]               ` <201102230936.09921.arnd-r2nGTMty4D4@public.gmane.org>
2011-02-23  9:37                 ` Michal Simek
     [not found]                   ` <4D64D55B.50405-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-02-23 17:49                     ` Arnd Bergmann
     [not found]             ` <4D64C08F.5030604-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-02-23 16:56               ` Grant Likely
2011-02-22 18:11   ` [PATCH v3 1/2] i2c: xiic: Add OF support for Xilinx i2c bus interface Grant Likely

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=1298396971-611-1-git-send-email-monstr@monstr.eu \
    --to=monstr-psz03upnqpehxe+lvdladg@public.gmane.org \
    --cc=John.Linn-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=john.williams-g5w7nrANp4BDPfheJLI6IQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-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
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).