All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	STEricsson_nomadik_linux@list.st.com,
	linus.walleij@stericsson.com, arnd@arndb.de,
	linux-i2c@vger.kernel.org
Subject: Re: [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
Date: Wed, 5 Sep 2012 08:33:20 +0100	[thread overview]
Message-ID: <20120905073319.GF4233@gmail.com> (raw)
In-Reply-To: <20120831112258.GA2624@pengutronix.de>

Author: Lee Jones <lee.jones@linaro.org>
Date:   Mon Aug 6 11:09:57 2012 +0100

    i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
    
    Here we apply the bindings required for successful Device Tree
    probing of the i2c-nomadik driver.
    
    Cc: linux-i2c@vger.kernel.org
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 61b00ed..5d1a970 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -25,6 +25,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/i2c-nomadik.h>
+#include <linux/of.h>
 
 #define DRIVER_NAME "nmk-i2c"
 
@@ -920,18 +921,42 @@ static struct nmk_i2c_controller u8500_i2c = {
        .sm             = I2C_FREQ_MODE_FAST,
 };
 
+static void nmk_i2c_of_probe(struct device_node *np,
+                       struct nmk_i2c_controller *pdata)
+{
+       of_property_read_u32(np, "clock-frequency", &pdata->clk_freq);
+
+       /* This driver only supports 'standard' and 'fast' modes of operation. */
+       if (pdata->clk_freq <= 100000)
+               pdata->sm = I2C_FREQ_MODE_STANDARD;
+       else
+               pdata->sm = I2C_FREQ_MODE_FAST;
+}
+
 static atomic_t adapter_id = ATOMIC_INIT(0);
 
 static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 {
        int ret = 0;
        struct nmk_i2c_controller *pdata = adev->dev.platform_data;
+       struct device_node *np = adev->dev.of_node;
        struct nmk_i2c_dev      *dev;
        struct i2c_adapter *adap;
 
-       if (!pdata)
-               /* No i2c configuration found, using the default. */
-               pdata = &u8500_i2c;
+       if (!pdata) {
+               if (np) {
+                       pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL);
+                       if (!pdata) {
+                               ret = -ENOMEM;
+                               goto err_no_mem;
+                       }
+                       /* Provide the default configuration as a base. */
+                       memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
+                       nmk_i2c_of_probe(np, pdata);
+               } else
+                       /* No i2c configuration found, using the default. */
+                       pdata = &u8500_i2c;
+       }
 
        dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
        if (!dev) {
diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h
index c2303c3..3a8be9c 100644
--- a/include/linux/platform_data/i2c-nomadik.h
+++ b/include/linux/platform_data/i2c-nomadik.h
@@ -28,7 +28,7 @@ enum i2c_freq_mode {
  * @sm:                speed mode
  */
 struct nmk_i2c_controller {
-       unsigned long   clk_freq;
+       u32             clk_freq;
        unsigned short  slsu;
        unsigned char   tft;
        unsigned char   rft;

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	STEricsson_nomadik_linux-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org,
	linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org,
	arnd-r2nGTMty4D4@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
Date: Wed, 5 Sep 2012 08:33:20 +0100	[thread overview]
Message-ID: <20120905073319.GF4233@gmail.com> (raw)
In-Reply-To: <20120831112258.GA2624-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Author: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Date:   Mon Aug 6 11:09:57 2012 +0100

    i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
    
    Here we apply the bindings required for successful Device Tree
    probing of the i2c-nomadik driver.
    
    Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
    Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 61b00ed..5d1a970 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -25,6 +25,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/i2c-nomadik.h>
+#include <linux/of.h>
 
 #define DRIVER_NAME "nmk-i2c"
 
@@ -920,18 +921,42 @@ static struct nmk_i2c_controller u8500_i2c = {
        .sm             = I2C_FREQ_MODE_FAST,
 };
 
+static void nmk_i2c_of_probe(struct device_node *np,
+                       struct nmk_i2c_controller *pdata)
+{
+       of_property_read_u32(np, "clock-frequency", &pdata->clk_freq);
+
+       /* This driver only supports 'standard' and 'fast' modes of operation. */
+       if (pdata->clk_freq <= 100000)
+               pdata->sm = I2C_FREQ_MODE_STANDARD;
+       else
+               pdata->sm = I2C_FREQ_MODE_FAST;
+}
+
 static atomic_t adapter_id = ATOMIC_INIT(0);
 
 static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 {
        int ret = 0;
        struct nmk_i2c_controller *pdata = adev->dev.platform_data;
+       struct device_node *np = adev->dev.of_node;
        struct nmk_i2c_dev      *dev;
        struct i2c_adapter *adap;
 
-       if (!pdata)
-               /* No i2c configuration found, using the default. */
-               pdata = &u8500_i2c;
+       if (!pdata) {
+               if (np) {
+                       pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL);
+                       if (!pdata) {
+                               ret = -ENOMEM;
+                               goto err_no_mem;
+                       }
+                       /* Provide the default configuration as a base. */
+                       memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
+                       nmk_i2c_of_probe(np, pdata);
+               } else
+                       /* No i2c configuration found, using the default. */
+                       pdata = &u8500_i2c;
+       }
 
        dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
        if (!dev) {
diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h
index c2303c3..3a8be9c 100644
--- a/include/linux/platform_data/i2c-nomadik.h
+++ b/include/linux/platform_data/i2c-nomadik.h
@@ -28,7 +28,7 @@ enum i2c_freq_mode {
  * @sm:                speed mode
  */
 struct nmk_i2c_controller {
-       unsigned long   clk_freq;
+       u32             clk_freq;
        unsigned short  slsu;
        unsigned char   tft;
        unsigned char   rft;

WARNING: multiple messages have this Message-ID (diff)
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
Date: Wed, 5 Sep 2012 08:33:20 +0100	[thread overview]
Message-ID: <20120905073319.GF4233@gmail.com> (raw)
In-Reply-To: <20120831112258.GA2624@pengutronix.de>

Author: Lee Jones <lee.jones@linaro.org>
Date:   Mon Aug 6 11:09:57 2012 +0100

    i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
    
    Here we apply the bindings required for successful Device Tree
    probing of the i2c-nomadik driver.
    
    Cc: linux-i2c at vger.kernel.org
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 61b00ed..5d1a970 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -25,6 +25,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/i2c-nomadik.h>
+#include <linux/of.h>
 
 #define DRIVER_NAME "nmk-i2c"
 
@@ -920,18 +921,42 @@ static struct nmk_i2c_controller u8500_i2c = {
        .sm             = I2C_FREQ_MODE_FAST,
 };
 
+static void nmk_i2c_of_probe(struct device_node *np,
+                       struct nmk_i2c_controller *pdata)
+{
+       of_property_read_u32(np, "clock-frequency", &pdata->clk_freq);
+
+       /* This driver only supports 'standard' and 'fast' modes of operation. */
+       if (pdata->clk_freq <= 100000)
+               pdata->sm = I2C_FREQ_MODE_STANDARD;
+       else
+               pdata->sm = I2C_FREQ_MODE_FAST;
+}
+
 static atomic_t adapter_id = ATOMIC_INIT(0);
 
 static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 {
        int ret = 0;
        struct nmk_i2c_controller *pdata = adev->dev.platform_data;
+       struct device_node *np = adev->dev.of_node;
        struct nmk_i2c_dev      *dev;
        struct i2c_adapter *adap;
 
-       if (!pdata)
-               /* No i2c configuration found, using the default. */
-               pdata = &u8500_i2c;
+       if (!pdata) {
+               if (np) {
+                       pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL);
+                       if (!pdata) {
+                               ret = -ENOMEM;
+                               goto err_no_mem;
+                       }
+                       /* Provide the default configuration as a base. */
+                       memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
+                       nmk_i2c_of_probe(np, pdata);
+               } else
+                       /* No i2c configuration found, using the default. */
+                       pdata = &u8500_i2c;
+       }
 
        dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
        if (!dev) {
diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h
index c2303c3..3a8be9c 100644
--- a/include/linux/platform_data/i2c-nomadik.h
+++ b/include/linux/platform_data/i2c-nomadik.h
@@ -28,7 +28,7 @@ enum i2c_freq_mode {
  * @sm:                speed mode
  */
 struct nmk_i2c_controller {
-       unsigned long   clk_freq;
+       u32             clk_freq;
        unsigned short  slsu;
        unsigned char   tft;
        unsigned char   rft;

  parent reply	other threads:[~2012-09-05  7:33 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 15:01 [PATCH 1/3] ARM: ux500: Add i2c configurations to the Device Tree for DB8500 based devices Lee Jones
2012-08-23 15:01 ` Lee Jones
2012-08-23 15:01 ` [PATCH 2/3] Documentation: Device Tree binding information for i2c-nomadik driver Lee Jones
2012-08-23 15:01   ` Lee Jones
2012-08-23 15:01 ` [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver Lee Jones
2012-08-23 15:01   ` Lee Jones
2012-08-27 23:42   ` Linus Walleij
2012-08-27 23:42     ` Linus Walleij
2012-08-27 23:42     ` Linus Walleij
2012-08-31 10:36     ` Lee Jones
2012-08-31 10:36       ` Lee Jones
2012-08-31 10:36       ` Lee Jones
2012-08-31 11:22   ` Wolfram Sang
2012-08-31 11:22     ` Wolfram Sang
2012-08-31 11:22     ` Wolfram Sang
2012-08-31 12:04     ` Lee Jones
2012-08-31 12:04       ` Lee Jones
2012-08-31 12:04       ` Lee Jones
2012-08-31 12:23     ` Lee Jones
2012-08-31 12:23       ` Lee Jones
2012-08-31 12:23       ` Lee Jones
2012-09-03  9:22       ` Linus Walleij
2012-09-03  9:22         ` Linus Walleij
2012-09-03  9:22         ` Linus Walleij
2012-09-03  9:44         ` Wolfram Sang
2012-09-03  9:44           ` Wolfram Sang
2012-09-03  9:44           ` Wolfram Sang
2012-09-03  9:50           ` Lee Jones
2012-09-03  9:50             ` Lee Jones
2012-09-03  9:50             ` Lee Jones
2012-09-03 10:07           ` Lee Jones
2012-09-03 10:07             ` Lee Jones
2012-09-03 10:07             ` Lee Jones
2012-09-03 11:07             ` Linus Walleij
2012-09-03 11:07               ` Linus Walleij
2012-09-03 11:07               ` Linus Walleij
2012-09-03 11:11               ` Lee Jones
2012-09-03 11:11                 ` Lee Jones
2012-09-03 11:32               ` Lee Jones
2012-09-03 11:32                 ` Lee Jones
2012-09-03 11:58                 ` Linus Walleij
2012-09-03 11:58                   ` Linus Walleij
2012-09-03 11:58                   ` Linus Walleij
2012-09-03 12:34                   ` Lee Jones
2012-09-03 12:34                     ` Lee Jones
2012-09-03 12:34                     ` Lee Jones
2012-09-03 13:19                     ` Linus Walleij
2012-09-03 13:19                       ` Linus Walleij
2012-09-03 13:19                       ` Linus Walleij
2012-09-03 13:28                       ` Lee Jones
2012-09-03 13:28                         ` Lee Jones
2012-09-03 13:28                         ` Lee Jones
2012-09-03 14:33                   ` Stephen Warren
2012-09-03 14:33                     ` Stephen Warren
2012-09-03 14:35                     ` Linus Walleij
2012-09-03 14:35                       ` Linus Walleij
2012-09-03 14:35                       ` Linus Walleij
2012-09-03 15:09                       ` Rob Herring
2012-09-03 15:09                         ` Rob Herring
2012-09-03 15:09                         ` Rob Herring
2012-09-03 15:20                         ` Lee Jones
2012-09-03 15:20                           ` Lee Jones
2012-09-04 14:28                           ` Arnd Bergmann
2012-09-04 14:28                             ` Arnd Bergmann
2012-09-04 14:28                             ` Arnd Bergmann
2012-09-04 17:27                             ` Linus Walleij
2012-09-04 17:27                               ` Linus Walleij
2012-09-04 17:27                               ` Linus Walleij
2012-09-05  6:41                               ` Lee Jones
2012-09-05  6:41                                 ` Lee Jones
2012-09-05  6:41                                 ` Lee Jones
2012-09-05  6:53                                 ` Linus Walleij
2012-09-05  6:53                                   ` Linus Walleij
2012-09-05  6:53                                   ` Linus Walleij
2012-09-04 17:35                             ` Alessandro Rubini
2012-09-04 17:35                               ` Alessandro Rubini
2012-09-04 17:35                               ` Alessandro Rubini
2012-09-05  7:33     ` Lee Jones [this message]
2012-09-05  7:33       ` Lee Jones
2012-09-05  7:33       ` Lee Jones
2012-09-05  8:22       ` Linus Walleij
2012-09-05  8:22         ` Linus Walleij

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=20120905073319.GF4233@gmail.com \
    --to=lee.jones@linaro.org \
    --cc=STEricsson_nomadik_linux@list.st.com \
    --cc=arnd@arndb.de \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w.sang@pengutronix.de \
    /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 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.