[PATCH 4/4] i2c: i2c-ocores: support for 16bit and 32bit IO

2012-07-09 Thread Jayachandran C
From: Ganesan Ramalingam 

Some architectures supports only 16-bit or 32-bit read/write access to
their IO space. Add a 'reg-io-width' platform and OF parameter which
specifies the IO width to support these platforms.

reg-io-width can be specified as 1, 2 or 4, and has a default value
of 1 if it is unspecified.

Signed-off-by: Ganesan Ramalingam 
Signed-off-by: Jayachandran C 
---
 .../devicetree/bindings/i2c/i2c-ocores.txt |2 ++
 drivers/i2c/busses/i2c-ocores.c|   21 ++--
 include/linux/i2c-ocores.h |1 +
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt 
b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
index 1c9334b..c15781f 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
@@ -10,6 +10,7 @@ Required properties:
 
 Optional properties:
 - reg-shift   : device register offsets are shifted by this value
+- reg-io-width: io register width in bytes (1, 2 or 4)
 - regstep : deprecated, use reg-shift above
 
 Example:
@@ -23,6 +24,7 @@ Example:
clock-frequency = <2000>;
 
reg-shift = <0>;/* 8 bit registers */
+   reg-io-width = <1>; /* 8 bit read/write */
 
dummy@60 {
compatible = "dummy";
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 9617ec1..034d1d5 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -30,6 +30,7 @@
 struct ocores_i2c {
void __iomem *base;
int reg_shift;
+   int reg_io_width;
wait_queue_head_t wait;
struct i2c_adapter adap;
struct i2c_msg *msg;
@@ -72,12 +73,22 @@ struct ocores_i2c {
 
 static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
 {
-   iowrite8(value, i2c->base + (reg << i2c->reg_shift));
+   if (i2c->reg_io_width == 4)
+   iowrite32(value, i2c->base + (reg << i2c->reg_shift));
+   else if (i2c->reg_io_width == 2)
+   iowrite16(value, i2c->base + (reg << i2c->reg_shift));
+   else
+   iowrite8(value, i2c->base + (reg << i2c->reg_shift));
 }
 
 static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg)
 {
-   return ioread8(i2c->base + (reg << i2c->reg_shift));
+   if (i2c->reg_io_width == 4)
+   return ioread32(i2c->base + (reg << i2c->reg_shift));
+   else if (i2c->reg_io_width == 2)
+   return ioread16(i2c->base + (reg << i2c->reg_shift));
+   else
+   return ioread8(i2c->base + (reg << i2c->reg_shift));
 }
 
 static void ocores_process(struct ocores_i2c *i2c)
@@ -244,6 +255,8 @@ static int ocores_i2c_of_probe(struct platform_device *pdev,
}
i2c->clock_khz = val / 1000;
 
+   of_property_read_u32(pdev->dev.of_node, "reg-io-width",
+   &i2c->reg_io_width);
return 0;
 }
 #else
@@ -286,6 +299,7 @@ static int __devinit ocores_i2c_probe(struct 
platform_device *pdev)
pdata = pdev->dev.platform_data;
if (pdata) {
i2c->reg_shift = pdata->reg_shift;
+   i2c->reg_io_width = pdata->reg_io_width;
i2c->clock_khz = pdata->clock_khz;
} else {
ret = ocores_i2c_of_probe(pdev, i2c);
@@ -293,6 +307,9 @@ static int __devinit ocores_i2c_probe(struct 
platform_device *pdev)
return ret;
}
 
+   if (i2c->reg_io_width == 0)
+   i2c->reg_io_width = 1; /* Set to default value */
+
ocores_init(i2c);
 
init_waitqueue_head(&i2c->wait);
diff --git a/include/linux/i2c-ocores.h b/include/linux/i2c-ocores.h
index bb58c7d..1d99ebd 100644
--- a/include/linux/i2c-ocores.h
+++ b/include/linux/i2c-ocores.h
@@ -13,6 +13,7 @@
 
 struct ocores_i2c_platform_data {
u32 reg_shift;  /* register offset shift value */
+   u32 reg_io_width;   /* register io read/write width */
u32 clock_khz;  /* input clock in kHz */
u8 num_devices; /* number of devices in the devices list */
struct i2c_board_info const *devices; /* devices connected to the bus */
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] i2c: i2c-ocores: Use reg-shift property

2012-07-09 Thread Jayachandran C
From: Ganesan Ramalingam 

Deprecate 'regstep' property and use the standard 'reg-shift' property
for register offset shifts. 'regstep' will still be supported as an
optional property, but will give a warning when used.

Signed-off-by: Ganesan Ramalingam 
Signed-off-by: Jayachandran C 
---
 .../devicetree/bindings/i2c/i2c-ocores.txt |8 +++--
 drivers/i2c/busses/i2c-ocores.c|   36 
 include/linux/i2c-ocores.h |6 ++--
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt 
b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
index bfec894..1c9334b 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
@@ -4,11 +4,14 @@ Required properties:
 - compatible  : "opencores,i2c-ocores"
 - reg : bus address start and address range size of device
 - interrupts  : interrupt number
-- regstep : size of device registers in bytes
 - clock-frequency : frequency of bus clock in Hz
 - #address-cells  : should be <1>
 - #size-cells : should be <0>
 
+Optional properties:
+- reg-shift   : device register offsets are shifted by this value
+- regstep : deprecated, use reg-shift above
+
 Example:
 
i2c0: ocores@a000 {
@@ -17,9 +20,10 @@ Example:
compatible = "opencores,i2c-ocores";
reg = <0xa000 0x8>;
interrupts = <10>;
-   regstep = <1>;
clock-frequency = <2000>;
 
+   reg-shift = <0>;/* 8 bit registers */
+
dummy@60 {
compatible = "dummy";
reg = <0x60>;
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index e8159db..9617ec1 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -25,10 +25,11 @@
 #include 
 #include 
 #include 
+#include 
 
 struct ocores_i2c {
void __iomem *base;
-   int regstep;
+   int reg_shift;
wait_queue_head_t wait;
struct i2c_adapter adap;
struct i2c_msg *msg;
@@ -71,12 +72,12 @@ struct ocores_i2c {
 
 static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
 {
-   iowrite8(value, i2c->base + reg * i2c->regstep);
+   iowrite8(value, i2c->base + (reg << i2c->reg_shift));
 }
 
 static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg)
 {
-   return ioread8(i2c->base + reg * i2c->regstep);
+   return ioread8(i2c->base + (reg << i2c->reg_shift));
 }
 
 static void ocores_process(struct ocores_i2c *i2c)
@@ -219,22 +220,29 @@ static struct i2c_adapter ocores_adapter = {
 static int ocores_i2c_of_probe(struct platform_device *pdev,
struct ocores_i2c *i2c)
 {
-   const __be32* val;
-
-   val = of_get_property(pdev->dev.of_node, "regstep", NULL);
-   if (!val) {
-   dev_err(&pdev->dev, "Missing required parameter 'regstep'\n");
-   return -ENODEV;
+   struct device_node *np = pdev->dev.of_node;
+   u32 val;
+
+   if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) {
+   /* no 'reg-shift', check for deprecated 'regstep' */
+   if (!of_property_read_u32(np, "regstep", &val)) {
+   if (!is_power_of_2(val)) {
+   dev_err(&pdev->dev, "invalid regstep %d\n",
+   val);
+   return -EINVAL;
+   }
+   i2c->reg_shift = ilog2(val);
+   dev_warn(&pdev->dev,
+   "regstep property deprecated, use reg-shift\n");
+   }
}
-   i2c->regstep = be32_to_cpup(val);
 
-   val = of_get_property(pdev->dev.of_node, "clock-frequency", NULL);
-   if (!val) {
+   if (of_property_read_u32(np, "clock-frequency", &val)) {
dev_err(&pdev->dev,
"Missing required parameter 'clock-frequency'\n");
return -ENODEV;
}
-   i2c->clock_khz = be32_to_cpup(val) / 1000;
+   i2c->clock_khz = val / 1000;
 
return 0;
 }
@@ -277,7 +285,7 @@ static int __devinit ocores_i2c_probe(struct 
platform_device *pdev)
 
pdata = pdev->dev.platform_data;
if (pdata) {
-   i2c->regstep = pdata->regstep;
+   i2c->reg_shift = pdata->reg_shift;
i2c->clock_khz = pdata->clock_khz;
} else {
ret = ocores_i2c_of_probe(pdev, i2c);
diff --git a/include/linux/i2c-ocores.h b/include/linux/i2c-ocores.h
index 4d5e57f..bb58c7d 100644
--- a/include/linux/i2c-ocores.h
+++ b/include/linux/i2c-ocores.h
@@ -12,9 +12,9 @@
 #define _LINUX_I2C_OCORES_H
 
 struct ocores_i2c_platform_data {
-   u32 regstep;   /* distance between register

[PATCH 3/4] V4L/DVB: mfd: use reg_shift instead of regstep

2012-07-09 Thread Jayachandran C
Update for change in i2c-ocores.h which uses reg_shift to
specify the register offset shifts instead of regstep.

Signed-off-by: Jayachandran C 
---
 drivers/mfd/timberdale.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index 0ba26fb..a447f4e 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -83,7 +83,7 @@ timberdale_xiic_platform_data = {
 
 static __devinitdata struct ocores_i2c_platform_data
 timberdale_ocores_platform_data = {
-   .regstep = 4,
+   .reg_shift = 2,
.clock_khz = 62500,
.devices = timberdale_i2c_board_info,
.num_devices = ARRAY_SIZE(timberdale_i2c_board_info)
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND 0/4] I2C Ocores updates

2012-07-09 Thread Jayachandran C
[Sending this out again - the changes are straight-forward and I 
 do not see any reason for not merging them.  Comments welcome]

While trying to add reg-io-width property to i2c-ocores, we noticed
a few things that needs to fixed up in i2c-ocores device tree code.

The changes are to: 
 * use the standard 'reg-shift' property instead of 'regstep'
 * fix the fallout of the about change in drivers/mfd/timberdale.c
 * move bindings documentation to under Documentation/, 
 * fix up formatting, and add \n to a few dev_* messages,
 * and finally to add reg-io-width optional property.

Regards,
JC.

Ganesan Ramalingam (2):
  i2c: i2c-ocores: Use reg-shift property
  i2c: i2c-ocores: support for 16bit and 32bit IO

Jayachandran C (2):
  i2c: i2c-ocores - DT bindings and minor fixes.
  V4L/DVB: mfd: use reg_shift instead of regstep

 .../devicetree/bindings/i2c/i2c-ocores.txt |   33 +++
 drivers/i2c/busses/i2c-ocores.c|   96 +---
 drivers/mfd/timberdale.c   |2 +-
 include/linux/i2c-ocores.h |7 +-
 4 files changed, 83 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-ocores.txt

-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] i2c: i2c-ocores - DT bindings and minor fixes.

2012-07-09 Thread Jayachandran C
Cleanups to i2c-cores, no change in logic, changes are:
* Move i2c-ocores device tree documentation from source file to
  Documentation/devicetree/bindings/i2c/i2c-ocores.txt.
* Add \n to dev_warn and dev_err messages where missing
* Minor updates to the text and formatting fixes.

Signed-off-by: Jayachandran C 
---
 .../devicetree/bindings/i2c/i2c-ocores.txt |   27 
 drivers/i2c/busses/i2c-ocores.c|   45 +++-
 2 files changed, 34 insertions(+), 38 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-ocores.txt

diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt 
b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
new file mode 100644
index 000..bfec894
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
@@ -0,0 +1,27 @@
+Device tree configuration for i2c-ocores
+
+Required properties:
+- compatible  : "opencores,i2c-ocores"
+- reg : bus address start and address range size of device
+- interrupts  : interrupt number
+- regstep : size of device registers in bytes
+- clock-frequency : frequency of bus clock in Hz
+- #address-cells  : should be <1>
+- #size-cells : should be <0>
+
+Example:
+
+   i2c0: ocores@a000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "opencores,i2c-ocores";
+   reg = <0xa000 0x8>;
+   interrupts = <10>;
+   regstep = <1>;
+   clock-frequency = <2000>;
+
+   dummy@60 {
+   compatible = "dummy";
+   reg = <0x60>;
+   };
+   };
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 75194c5..e8159db 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -10,40 +10,9 @@
  */
 
 /*
- * Device tree configuration:
- *
- * Required properties:
- * - compatible  : "opencores,i2c-ocores"
- * - reg : bus address start and address range size of device
- * - interrupts  : interrupt number
- * - regstep : size of device registers in bytes
- * - clock-frequency : frequency of bus clock in Hz
- * 
- * Example:
- *
- *  i2c0: ocores@a000 {
- *  compatible = "opencores,i2c-ocores";
- *  reg = <0xa000 0x8>;
- *  interrupts = <10>;
- *
- *  regstep = <1>;
- *  clock-frequency = <2000>;
- *
- * -- Devices connected on this I2C bus get
- * -- defined here; address- and size-cells
- * -- apply to these child devices
- *
- *  #address-cells = <1>;
- *  #size-cells = <0>;
- *
- *  dummy@60 {
- * compatible = "dummy";
- * reg = <60>;
- *  };
- *  };
- *
+ * This driver can be used from the device tree, see
+ * Documentation/devicetree/bindings/i2c/ocore-i2c.txt
  */
-
 #include 
 #include 
 #include 
@@ -247,14 +216,14 @@ static struct i2c_adapter ocores_adapter = {
 };
 
 #ifdef CONFIG_OF
-static int ocores_i2c_of_probe(struct platform_device* pdev,
-   struct ocores_i2c* i2c)
+static int ocores_i2c_of_probe(struct platform_device *pdev,
+   struct ocores_i2c *i2c)
 {
const __be32* val;
 
val = of_get_property(pdev->dev.of_node, "regstep", NULL);
if (!val) {
-   dev_err(&pdev->dev, "Missing required parameter 'regstep'");
+   dev_err(&pdev->dev, "Missing required parameter 'regstep'\n");
return -ENODEV;
}
i2c->regstep = be32_to_cpup(val);
@@ -262,7 +231,7 @@ static int ocores_i2c_of_probe(struct platform_device* pdev,
val = of_get_property(pdev->dev.of_node, "clock-frequency", NULL);
if (!val) {
dev_err(&pdev->dev,
-   "Missing required parameter 'clock-frequency'");
+   "Missing required parameter 'clock-frequency'\n");
return -ENODEV;
}
i2c->clock_khz = be32_to_cpup(val) / 1000;
@@ -351,7 +320,7 @@ static int __devinit ocores_i2c_probe(struct 
platform_device *pdev)
return 0;
 }
 
-static int __devexit ocores_i2c_remove(struct platform_device* pdev)
+static int __devexit ocores_i2c_remove(struct platform_device *pdev)
 {
struct ocores_i2c *i2c = platform_get_drvdata(pdev);
 
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 4/4] input: add onkey support to 88PM80X PMIC

2012-07-09 Thread Qiao Zhou
add onkey support to MARVELL 88PM80X PMIC.

Signed-off-by: Qiao Zhou 
---
 drivers/input/misc/88pm80x_onkey.c |  176 
 drivers/input/misc/Kconfig |   10 ++
 drivers/input/misc/Makefile|1 +
 3 files changed, 187 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/88pm80x_onkey.c

diff --git a/drivers/input/misc/88pm80x_onkey.c 
b/drivers/input/misc/88pm80x_onkey.c
new file mode 100644
index 000..807587f
--- /dev/null
+++ b/drivers/input/misc/88pm80x_onkey.c
@@ -0,0 +1,176 @@
+/*
+ * 88pm80x_onkey.c - Marvell 88PM80x ONKEY driver
+ *
+ * Copyright (C) 2012 Marvell International Ltd.
+ * Haojian Zhuang 
+ * Qiao Zhou 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PM800_LONG_ONKEY_EN(1 << 0)
+#define PM800_LONG_KEY_DELAY   (8) /* 1 .. 16 seconds */
+#define PM800_LONKEY_PRESS_TIME((PM800_LONG_KEY_DELAY-1) << 4)
+#define PM800_LONKEY_PRESS_TIME_MASK   (0xF0)
+#define PM800_SW_PDOWN (1 << 5)
+
+struct pm80x_onkey_info {
+   struct input_dev *idev;
+   struct pm80x_chip *pm80x;
+   struct regmap *map;
+   int irq;
+};
+
+/* 88PM80x gives us an interrupt when ONKEY is held */
+static irqreturn_t pm80x_onkey_handler(int irq, void *data)
+{
+   struct pm80x_onkey_info *info = data;
+   int ret = 0;
+
+   regmap_read(info->map, PM800_STATUS_1, &ret);
+   ret &= PM800_ONKEY_STS1;
+
+   input_report_key(info->idev, KEY_POWER, ret);
+   input_sync(info->idev);
+
+   return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_PM
+static int pm80x_onkey_suspend(struct device *dev)
+{
+   return pm80x_dev_suspend(dev);
+}
+
+static int pm80x_onkey_resume(struct device *dev)
+{
+   return pm80x_dev_resume(dev);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(pm80x_onkey_pm_ops, pm80x_onkey_suspend,
+pm80x_onkey_resume);
+
+static int __devinit pm80x_onkey_probe(struct platform_device *pdev)
+{
+
+   void *chip = dev_get_drvdata(pdev->dev.parent);
+   struct pm80x_onkey_info *info;
+   int ret;
+
+   info =
+   devm_kzalloc(&pdev->dev, sizeof(struct pm80x_onkey_info),
+GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
+
+   info->pm80x = (struct pm80x_chip *)chip;
+
+   info->irq = platform_get_irq(pdev, 0);
+   if (info->irq < 0) {
+   dev_err(&pdev->dev, "No IRQ resource!\n");
+   return -EINVAL;
+   }
+
+   info->map = info->pm80x->regmap;
+   if (!info->map) {
+   dev_err(&pdev->dev, "no regmap!\n");
+   ret = -EINVAL;
+   goto out;
+   }
+
+   info->idev = input_allocate_device();
+   if (!info->idev) {
+   dev_err(&pdev->dev, "Failed to allocate input dev\n");
+   ret = -ENOMEM;
+   goto out;
+   }
+
+   info->idev->name = "88pm80x_on";
+   info->idev->phys = "88pm80x_on/input0";
+   info->idev->id.bustype = BUS_I2C;
+   info->idev->dev.parent = &pdev->dev;
+   info->idev->evbit[0] = BIT_MASK(EV_KEY);
+   info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
+
+   ret = input_register_device(info->idev);
+   if (ret) {
+   dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
+   goto out_reg;
+   }
+
+   ret = pm80x_request_irq(info->pm80x, info->irq, pm80x_onkey_handler,
+   IRQF_ONESHOT, "onkey", info);
+   if (ret < 0) {
+   dev_err(&pdev->dev, "Failed to request IRQ: #%d: %d\n",
+   info->irq, ret);
+   goto out_irq;
+   }
+
+   platform_set_drvdata(pdev, info);
+
+   /* Enable long onkey detection */
+   regmap_update_bits(info->map, PM800_RTC_MISC4, PM800_LONG_ONKEY_EN,
+  PM800_LONG_ONKEY_EN);
+   /* Set 8-second interval */
+   regmap_update_bits(info->map, PM800_RTC_MISC3,
+  PM800_LONKEY_PRESS_TIME_MASK,
+  PM800_LONKEY_PRESS_TIME);
+
+   device_init_wakeup(&pdev->dev, 1);
+   return 0;
+
+out_irq:
+   input_unregister_device(info->idev);
+out_reg:
+   input_free_device(info->idev);
+out

[PATCH V6 3/4] rtc: add rtc support to 88PM80X PMIC

2012-07-09 Thread Qiao Zhou
add rtc driver for MARVELL 88PM80X PMIC and enable rtc function.

Signed-off-by: Qiao Zhou 
---
 drivers/rtc/Kconfig   |   10 ++
 drivers/rtc/Makefile  |1 +
 drivers/rtc/rtc-88pm80x.c |  371 +
 3 files changed, 382 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-88pm80x.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 08cbdb9..f049c02 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -135,6 +135,16 @@ config RTC_DRV_88PM860X
  This driver can also be built as a module. If so, the module
  will be called rtc-88pm860x.
 
+config RTC_DRV_88PM80X
+   tristate "Marvell 88PM80x"
+   depends on RTC_CLASS && I2C && MFD_88PM800
+   help
+ If you say yes here you get support for RTC function in Marvell
+ 88PM80x chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-88pm80x.
+
 config RTC_DRV_DS1307
tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025"
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 2973921..0d5b2b6 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -16,6 +16,7 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
 # Keep the list ordered.
 
 obj-$(CONFIG_RTC_DRV_88PM860X)  += rtc-88pm860x.o
+obj-$(CONFIG_RTC_DRV_88PM80X)  += rtc-88pm80x.o
 obj-$(CONFIG_RTC_DRV_AB3100)   += rtc-ab3100.o
 obj-$(CONFIG_RTC_DRV_AB8500)   += rtc-ab8500.o
 obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
new file mode 100644
index 000..a2f956d
--- /dev/null
+++ b/drivers/rtc/rtc-88pm80x.c
@@ -0,0 +1,371 @@
+/*
+ * Real Time Clock driver for Marvell 88PM80x PMIC
+ *
+ * Copyright (c) 2012 Marvell International Ltd.
+ *  Wenzeng Chen
+ *  Qiao Zhou 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PM800_RTC_COUNTER1 (0xD1)
+#define PM800_RTC_COUNTER2 (0xD2)
+#define PM800_RTC_COUNTER3 (0xD3)
+#define PM800_RTC_COUNTER4 (0xD4)
+#define PM800_RTC_EXPIRE1_1(0xD5)
+#define PM800_RTC_EXPIRE1_2(0xD6)
+#define PM800_RTC_EXPIRE1_3(0xD7)
+#define PM800_RTC_EXPIRE1_4(0xD8)
+#define PM800_RTC_TRIM1(0xD9)
+#define PM800_RTC_TRIM2(0xDA)
+#define PM800_RTC_TRIM3(0xDB)
+#define PM800_RTC_TRIM4(0xDC)
+#define PM800_RTC_EXPIRE2_1(0xDD)
+#define PM800_RTC_EXPIRE2_2(0xDE)
+#define PM800_RTC_EXPIRE2_3(0xDF)
+#define PM800_RTC_EXPIRE2_4(0xE0)
+
+#define PM800_POWER_DOWN_LOG1  (0xE5)
+#define PM800_POWER_DOWN_LOG2  (0xE6)
+
+struct pm80x_rtc_info {
+   struct pm80x_chip *chip;
+   struct regmap *map;
+   struct rtc_device *rtc_dev;
+   struct device *dev;
+   struct delayed_work calib_work;
+
+   int irq;
+   int vrtc;
+};
+
+static irqreturn_t rtc_update_handler(int irq, void *data)
+{
+   struct pm80x_rtc_info *info = (struct pm80x_rtc_info *)data;
+   int mask;
+
+   mask = PM800_ALARM | PM800_ALARM_WAKEUP;
+   regmap_update_bits(info->map, PM800_RTC_CONTROL, mask | PM800_ALARM1_EN,
+  mask);
+   rtc_update_irq(info->rtc_dev, 1, RTC_AF);
+   return IRQ_HANDLED;
+}
+
+static int pm80x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+   struct pm80x_rtc_info *info = dev_get_drvdata(dev);
+
+   if (enabled)
+   regmap_update_bits(info->map, PM800_RTC_CONTROL,
+  PM800_ALARM1_EN, PM800_ALARM1_EN);
+   else
+   regmap_update_bits(info->map, PM800_RTC_CONTROL,
+  PM800_ALARM1_EN, 0);
+   return 0;
+}
+
+/*
+ * Calculate the next alarm time given the requested alarm time mask
+ * and the current time.
+ */
+static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
+   struct rtc_time *alrm)
+{
+   unsigned long next_time;
+   unsigned long now_time;
+
+   next->tm_year = now->tm_year;
+   next->tm_mon = now->tm_mon;
+   next->tm_mday = now->tm

[PATCH V6 2/4] mfd: workaround: add companion chip in 88pm80x

2012-07-09 Thread Qiao Zhou
in hw design, 800 is mainly for pmic control, while 805 for audio.
but there are 3 registers which controls class D speaker property,
and they are defined in 800 i2c client domain. so 805 codec driver
needs to use 800 i2c client to access class D speaker reg for
audio path management. so add this workaround for the purpose to
let 805 access 800 i2c in some scenario.

Signed-off-by: Qiao Zhou 
---
 drivers/mfd/88pm80x.c   |   28 
 include/linux/mfd/88pm80x.h |1 +
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c
index 5d73531..62da342 100644
--- a/drivers/mfd/88pm80x.c
+++ b/drivers/mfd/88pm80x.c
@@ -18,6 +18,12 @@
 #include 
 #include 
 
+/*
+ * workaround: some registers needed by pm805 are defined in pm800, so
+ * need to use this global variable to maintain the relation between
+ * pm800 and pm805. would remove it after HW chip fixes the issue.
+ */
+static struct pm80x_chip *g_pm80x_chip;
 
 const struct regmap_config pm80x_regmap_config = {
.reg_bits = 8,
@@ -62,6 +68,19 @@ int __devinit pm80x_init(struct i2c_client *client,
 
device_init_wakeup(&client->dev, 1);
 
+   /*
+* workaround: set g_pm80x_chip to the first probed chip. if the
+* second chip is probed, just point to the companion to each
+* other so that pm805 can access those specific register. would
+* remove it after HW chip fixes the issue.
+*/
+   if (!g_pm80x_chip)
+   g_pm80x_chip = chip;
+   else {
+   chip->companion = g_pm80x_chip->client;
+   g_pm80x_chip->companion = chip->client;
+   }
+
return 0;
 
 err_chip_id:
@@ -76,6 +95,15 @@ int __devexit pm80x_deinit(struct i2c_client *client)
 {
struct pm80x_chip *chip = i2c_get_clientdata(client);
 
+   /*
+* workaround: clear the dependency between pm800 and pm805.
+* would remove it after HW chip fixes the issue.
+*/
+   if (g_pm80x_chip->companion)
+   g_pm80x_chip->companion = NULL;
+   else
+   g_pm80x_chip = NULL;
+
regmap_exit(chip->regmap);
devm_kfree(&client->dev, chip);
 
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
index 6c126e9..103f06d 100644
--- a/include/linux/mfd/88pm80x.h
+++ b/include/linux/mfd/88pm80x.h
@@ -295,6 +295,7 @@ struct pm80x_chip {
struct pm80x_subchip *subchip;
struct device *dev;
struct i2c_client *client;
+   struct i2c_client *companion;
struct regmap *regmap;
struct regmap_irq_chip *regmap_irq_chip;
struct regmap_irq_chip_data *irq_data;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 1/4] mfd: support 88pm80x in 80x driver

2012-07-09 Thread Qiao Zhou
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.

88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.

88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.

88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.

the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.

Signed-off-by: Qiao Zhou 
---
 drivers/mfd/88pm800.c   |  593 +++
 drivers/mfd/88pm805.c   |  299 ++
 drivers/mfd/88pm80x.c   |  117 +
 drivers/mfd/Kconfig |   24 ++
 drivers/mfd/Makefile|2 +
 include/linux/mfd/88pm80x.h |  368 +++
 6 files changed, 1403 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/88pm800.c
 create mode 100644 drivers/mfd/88pm805.c
 create mode 100644 drivers/mfd/88pm80x.c
 create mode 100644 include/linux/mfd/88pm80x.h

diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
new file mode 100644
index 000..fe479cc
--- /dev/null
+++ b/drivers/mfd/88pm800.c
@@ -0,0 +1,593 @@
+/*
+ * Base driver for Marvell 88PM800
+ *
+ * Copyright (C) 2012 Marvell International Ltd.
+ * Haojian Zhuang 
+ * Joseph(Yossi) Hanin 
+ * Qiao Zhou 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PM800_CHIP_ID  (0x00)
+
+/* Interrupt Registers */
+#define PM800_INT_STATUS1  (0x05)
+#define PM800_ONKEY_INT_STS1   (1 << 0)
+#define PM800_EXTON_INT_STS1   (1 << 1)
+#define PM800_CHG_INT_STS1 (1 << 2)
+#define PM800_BAT_INT_STS1 (1 << 3)
+#define PM800_RTC_INT_STS1 (1 << 4)
+#define PM800_CLASSD_OC_INT_STS1   (1 << 5)
+
+#define PM800_INT_STATUS2  (0x06)
+#define PM800_VBAT_INT_STS2(1 << 0)
+#define PM800_VSYS_INT_STS2(1 << 1)
+#define PM800_VCHG_INT_STS2(1 << 2)
+#define PM800_TINT_INT_STS2(1 << 3)
+#define PM800_GPADC0_INT_STS2  (1 << 4)
+#define PM800_TBAT_INT_STS2(1 << 5)
+#define PM800_GPADC2_INT_STS2  (1 << 6)
+#define PM800_GPADC3_INT_STS2  (1 << 7)
+
+#define PM800_INT_STATUS3  (0x07)
+
+#define PM800_INT_STATUS4  (0x08)
+#define PM800_GPIO0_INT_STS4   (1 << 0)
+#define PM800_GPIO1_INT_STS4   (1 << 1)
+#define PM800_GPIO2_INT_STS4   (1 << 2)
+#define PM800_GPIO3_INT_STS4   (1 << 3)
+#define PM800_GPIO4_INT_STS4   (1 << 4)
+
+#define PM800_INT_ENA_1(0x09)
+#define PM800_ONKEY_INT_ENA1   (1 << 0)
+#define PM800_EXTON_INT_ENA1   (1 << 1)
+#define PM800_CHG_INT_ENA1 (1 << 2)
+#define PM800_BAT_INT_ENA1 (1 << 3)
+#define PM800_RTC_INT_ENA1 (1 << 4)
+#define PM800_CLASSD_OC_INT_ENA1   (1 << 5)
+
+#define PM800_INT_ENA_2(0x0A)
+#define PM800_VBAT_INT_ENA2(1 << 0)
+#define PM800_VSYS_INT_ENA2(1 << 1)
+#define PM800_VCHG_INT_ENA2(1 << 2)
+#define PM800_TINT_INT_ENA2(1 << 3)
+
+#define PM800_INT_ENA_3(0x0B)
+#define PM800_GPADC0_INT_ENA3  (1 << 0)
+#define PM800_GPADC1_INT_ENA3  (1 << 1)
+#define PM800_GPADC2_INT_ENA3  (1 << 2)
+#define PM800_GPADC3_INT_ENA3  (1 << 3)
+#define PM800_GPADC4_INT_ENA3  (1 << 4)
+
+#define PM800_INT_ENA_4(0x0C)
+#define PM800_GPIO0_INT_ENA4   (1 << 0)
+#define PM800_GPIO1_INT_ENA4   (1 << 1)
+#define PM800_GPIO2_INT_ENA4   (1 << 2)
+#define PM800_GPIO3_INT_ENA4   (1 << 3)
+#define PM800_GPIO4_INT_ENA4   (1 << 4)
+
+/* number of INT_ENA & INT_STATUS regs */
+#define PM800_INT_REG_NUM  (4)
+
+/* Interrupt Number in 88PM800 */
+enum {
+  

[PATCH V6 0/4] add 88pm80x mfd driver

2012-07-09 Thread Qiao Zhou
change log [v6->v5]:
export_symbol_gpl for pm80x_regmap_config to fix build issue for module.

change log [v5->v4]:
1, change the file name, from 88pm800-core.c, 88pm805-core.c, 88pm80x-i2c.c
to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
2, replace the spinlock used to protect wakeup flag, with using set_bit/
clear_bit, which is suitable adn enough in SMP env.
3, add the version number in each patch.

change log [v4->v3]:
1, provide unified suspend/resume api for all sub-devices, and add
protection for 800 & 805 wakeup flag in SMP case.
2, clean register definition in 88pm80x.h, and thanks Arnd's help.
3, some minor changes in mfd Kconfig/Makefile.

change log [v3->v2]:
1, dynamically get the irq_base, for both regmap_add_irq_chip and
mfd_add_devices. add pm80x_request_irq & pm80x_free_irq for sub-driver
facility, and modify related irq thread operation. remove irq_base member
from 80x_chip & platform data.
2, split 88pm80x.o into 3 separate modules.
3, remove the 88pm80x r/w API, and directly use open-coded regmap api.
4, minor change: move pm80x_id_table from 80x-i2c.c to 800/805-core.c,
exported pm80x_init, pm80x_deinit, and pm80x_bulk_read, add callback in
pdata.

change log [v2->v1]:
1, split 88pm80x-core.c into 88pm800-core.c and 88pm805.c, per Arnd's
suggestion. after the re-arch, 88pm80x-i2c handles the 800 & 805 common
parts, while 800-core.c & 805-core.c handle the specific parts in each
chip.
2, add details about the workaround adding a i2c companion between 800 &
805, and make a separate patch for it, per Arnd's suggestion.
3, remove callback in pdata. but still keep the pdata currently.
4, only keep necessary register in 88pm80x.h, including registers for
regulator/rtc/onkey/power/codec etc, and remove other registers from global
visibility.
5, exported r/w API which requires regmap handle. as currently the pm800
chip has 3 i2c device, only passing a pm80x_chip info can't ensure r/w the
register in correct i2c device.

change log [v1]:
1, pm800 and pm805 are decoupled and probed separately;
2, re-used the most of API for pm800 and pm805 per Arnd's comments;
3, use regmap_irq, instead of previous 88pm80x_irq_data per Mark's comments.
use regmap_add_irq_chip, and remove previous 88pm80x irq handling.
4, remove callback function in rtc pdata per Arnd's comments.
5, updated some coding style issue.


Qiao Zhou (4):
  mfd: support 88pm80x in 80x driver
  mfd: workaround: add companion chip in 88pm80x
  rtc: add rtc support to 88PM80X PMIC
  input: add onkey support to 88PM80X PMIC

 drivers/input/misc/88pm80x_onkey.c |  176 +++
 drivers/input/misc/Kconfig |   10 +
 drivers/input/misc/Makefile|1 +
 drivers/mfd/88pm800.c  |  593 
 drivers/mfd/88pm805.c  |  299 ++
 drivers/mfd/88pm80x.c  |  145 +
 drivers/mfd/Kconfig|   24 ++
 drivers/mfd/Makefile   |2 +
 drivers/rtc/Kconfig|   10 +
 drivers/rtc/Makefile   |1 +
 drivers/rtc/rtc-88pm80x.c  |  371 ++
 include/linux/mfd/88pm80x.h|  369 ++
 12 files changed, 2001 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/88pm80x_onkey.c
 create mode 100644 drivers/mfd/88pm800.c
 create mode 100644 drivers/mfd/88pm805.c
 create mode 100644 drivers/mfd/88pm80x.c
 create mode 100644 drivers/rtc/rtc-88pm80x.c
 create mode 100644 include/linux/mfd/88pm80x.h

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] i2c: imx: make bitrate an u32 type

2012-07-09 Thread Richard Zhao
On Tue, Jul 10, 2012 at 12:28:30AM +0200, Wolfram Sang wrote:
> sparse found this assignment of u32 to an int. Fix it:
> 
> drivers/i2c/busses/i2c-imx.c:540:56: warning: incorrect type in argument 3 
> (different signedness)
> 
> and also fix the type in platform_data. All current users use values
> which fit into the old and new type, so it is a safe change.
> 
> Signed-off-by: Wolfram Sang 
> Cc: Richard Zhao 
> Cc: Sascha Hauer 
Reviewed-by: Richard Zhao 
> ---
> 
> Changes since V1: also change type in platform_data. Thanks to Richard.
> 
>  arch/arm/plat-mxc/include/mach/i2c.h |2 +-
>  drivers/i2c/busses/i2c-imx.c |4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/include/mach/i2c.h 
> b/arch/arm/plat-mxc/include/mach/i2c.h
> index 375cdd0..8289d91 100644
> --- a/arch/arm/plat-mxc/include/mach/i2c.h
> +++ b/arch/arm/plat-mxc/include/mach/i2c.h
> @@ -15,7 +15,7 @@
>   *
>   **/
>  struct imxi2c_platform_data {
> - int bitrate;
> + u32 bitrate;
>  };
>  
>  #endif /* __ASM_ARCH_I2C_H_ */
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index dd2a083..90460dd 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -471,8 +471,8 @@ static int __init i2c_imx_probe(struct platform_device 
> *pdev)
>   struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>   struct pinctrl *pinctrl;
>   void __iomem *base;
> - int irq, bitrate;
> - int ret;
> + int irq, ret;
> + u32 bitrate;
>  
>   dev_dbg(&pdev->dev, "<%s>\n", __func__);
>  
> -- 
> 1.7.10.4
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2] i2c: imx: make bitrate an u32 type

2012-07-09 Thread Wolfram Sang
sparse found this assignment of u32 to an int. Fix it:

drivers/i2c/busses/i2c-imx.c:540:56: warning: incorrect type in argument 3 
(different signedness)

and also fix the type in platform_data. All current users use values
which fit into the old and new type, so it is a safe change.

Signed-off-by: Wolfram Sang 
Cc: Richard Zhao 
Cc: Sascha Hauer 
---

Changes since V1: also change type in platform_data. Thanks to Richard.

 arch/arm/plat-mxc/include/mach/i2c.h |2 +-
 drivers/i2c/busses/i2c-imx.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-mxc/include/mach/i2c.h 
b/arch/arm/plat-mxc/include/mach/i2c.h
index 375cdd0..8289d91 100644
--- a/arch/arm/plat-mxc/include/mach/i2c.h
+++ b/arch/arm/plat-mxc/include/mach/i2c.h
@@ -15,7 +15,7 @@
  *
  **/
 struct imxi2c_platform_data {
-   int bitrate;
+   u32 bitrate;
 };
 
 #endif /* __ASM_ARCH_I2C_H_ */
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dd2a083..90460dd 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -471,8 +471,8 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
struct pinctrl *pinctrl;
void __iomem *base;
-   int irq, bitrate;
-   int ret;
+   int irq, ret;
+   u32 bitrate;
 
dev_dbg(&pdev->dev, "<%s>\n", __func__);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] i2c: stu300: use devm managed resources

2012-07-09 Thread Linus Walleij
Allocate memory for device state using devm_kzalloc(), get the
clock using devm_clk_get(), get the IRQ using devm_request_irq(),
request and remap memory using devm_request_and_ioremap().
All to simplify accounting and letting the kernel do the
garbage-collection.

Signed-off-by: Linus Walleij 
---
ChangeLog v1->v2:
- Use more devm* stuff, at Wolfram's request.
- Note: based on a clean v3.5-rc6, may need some patch -p1 < patch
  to apply on the i2c tree, if you want me to rebase it, just tell
  me where to find the baseline.
---
 drivers/i2c/busses/i2c-stu300.c |   75 +-
 1 files changed, 18 insertions(+), 57 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
index 4d44af1..dc4c518 100644
--- a/drivers/i2c/busses/i2c-stu300.c
+++ b/drivers/i2c/busses/i2c-stu300.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2009 ST-Ericsson AB
+ * Copyright (C) 2007-2012 ST-Ericsson AB
  * License terms: GNU General Public License (GPL) version 2
  * ST DDC I2C master mode driver, used in e.g. U300 series platforms.
  * Author: Linus Walleij 
@@ -873,64 +873,46 @@ stu300_probe(struct platform_device *pdev)
int ret = 0;
char clk_name[] = "I2C0";
 
-   dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL);
+   dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL);
if (!dev) {
dev_err(&pdev->dev, "could not allocate device struct\n");
-   ret = -ENOMEM;
-   goto err_no_devmem;
+   return -ENOMEM;
}
 
bus_nr = pdev->id;
clk_name[3] += (char)bus_nr;
-   dev->clk = clk_get(&pdev->dev, clk_name);
+   dev->clk = devm_clk_get(&pdev->dev, clk_name);
if (IS_ERR(dev->clk)) {
-   ret = PTR_ERR(dev->clk);
dev_err(&pdev->dev, "could not retrieve i2c bus clock\n");
-   goto err_no_clk;
+   return PTR_ERR(dev->clk);
}
 
dev->pdev = pdev;
-   platform_set_drvdata(pdev, dev);
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   ret = -ENOENT;
-   goto err_no_resource;
-   }
+   if (!res)
+   return -ENOENT;
 
dev->phybase = res->start;
dev->physize = resource_size(res);
-
-   if (request_mem_region(dev->phybase, dev->physize,
-  NAME " I/O Area") == NULL) {
-   ret = -EBUSY;
-   goto err_no_ioregion;
-   }
-
-   dev->virtbase = ioremap(dev->phybase, dev->physize);
+   dev->virtbase = devm_request_and_ioremap(&pdev->dev, res);
dev_dbg(&pdev->dev, "initialize bus device I2C%d on virtual "
"base %p\n", bus_nr, dev->virtbase);
-   if (!dev->virtbase) {
-   ret = -ENOMEM;
-   goto err_no_ioremap;
-   }
+   if (!dev->virtbase)
+   return -ENOMEM;
 
dev->irq = platform_get_irq(pdev, 0);
-   if (request_irq(dev->irq, stu300_irh, 0,
-   NAME, dev)) {
-   ret = -EIO;
-   goto err_no_irq;
-   }
+   ret = devm_request_irq(&pdev->dev, dev->irq, stu300_irh, 0, NAME, dev);
+   if (ret < 0)
+   return ret;
 
dev->speed = scl_frequency;
 
clk_enable(dev->clk);
ret = stu300_init_hw(dev);
clk_disable(dev->clk);
-
if (ret != 0) {
dev_err(&dev->pdev->dev, "error initializing hardware.\n");
-   goto err_init_hw;
+   return -EIO;
}
 
/* IRQ event handling initialization */
@@ -952,29 +934,13 @@ stu300_probe(struct platform_device *pdev)
/* i2c device drivers may be active on return from add_adapter() */
ret = i2c_add_numbered_adapter(adap);
if (ret) {
-   dev_err(&dev->pdev->dev, "failure adding ST Micro DDC "
+   dev_err(&pdev->dev, "failure adding ST Micro DDC "
   "I2C adapter\n");
-   goto err_add_adapter;
+   return ret;
}
-   return 0;
 
- err_add_adapter:
- err_init_hw:
-   free_irq(dev->irq, dev);
- err_no_irq:
-   iounmap(dev->virtbase);
- err_no_ioremap:
-   release_mem_region(dev->phybase, dev->physize);
- err_no_ioregion:
-   platform_set_drvdata(pdev, NULL);
- err_no_resource:
-   clk_put(dev->clk);
- err_no_clk:
-   kfree(dev);
- err_no_devmem:
-   dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n",
-   pdev->id);
-   return ret;
+   platform_set_drvdata(pdev, dev);
+   return 0;
 }
 
 #ifdef CONFIG_PM
@@ -1013,12 +979,7 @@ stu300_remove(struct platform_device *pdev)
i2c_del_adapter(&dev->adapter);
/* Turn off everything */
stu300_wr8(0x00, dev->virtbase + I2C_CR);
-   free_irq(dev->irq, dev);
-   iounmap(dev->virtbase);
-   release_mem_region(dev->phybase, dev->physize

Re: [PATCH V3 0/3] i2c-nomadik changes

2012-07-09 Thread Lee Jones

On 09/07/12 21:40, Linus Walleij wrote:

On Mon, Jul 9, 2012 at 11:48 AM, Wolfram Sang  wrote:

On Mon, Jun 11, 2012 at 11:37:15PM +0200, Linus Walleij wrote:

On Mon, Jun 11, 2012 at 10:56 PM, Alessandro Rubini  wrote:


V3:
- fixed according to Linusw feedback (merged the patch he posted)
- added Tested-by: Linusw on his permission


I'm happy with this version, Wolfram if it looks OK to you,
can you please merge this into the I2C tree?


Done now, thanks.

Is the latest version of Lee's patches for DT sent on 20/06 suitable to
go on top of that?


No clue on that, Lee'd have to comment.


All my i2c stuff is in -next.

Feel free to pull it in and base on that.

--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
M: +44 77 88 633 515
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 0/3] i2c-nomadik changes

2012-07-09 Thread Linus Walleij
On Mon, Jul 9, 2012 at 11:48 AM, Wolfram Sang  wrote:
> On Mon, Jun 11, 2012 at 11:37:15PM +0200, Linus Walleij wrote:
>> On Mon, Jun 11, 2012 at 10:56 PM, Alessandro Rubini  wrote:
>>
>> > V3:
>> >- fixed according to Linusw feedback (merged the patch he posted)
>> >- added Tested-by: Linusw on his permission
>>
>> I'm happy with this version, Wolfram if it looks OK to you,
>> can you please merge this into the I2C tree?
>
> Done now, thanks.
>
> Is the latest version of Lee's patches for DT sent on 20/06 suitable to
> go on top of that?

No clue on that, Lee'd have to comment.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2 V3] MXS: Implement DMA support into mxs-i2c

2012-07-09 Thread Marek Vasut
This patch implements DMA support into mxs-i2c. DMA transfers are now enabled
via DT. The DMA operation is enabled by default.

Signed-off-by: Marek Vasut 
Cc: Detlev Zundel 
CC: Dong Aisheng 
CC: Fabio Estevam 
Cc: Linux ARM kernel 
Cc: linux-i2c@vger.kernel.org
CC: Sascha Hauer 
CC: Shawn Guo 
Cc: Stefano Babic 
CC: Uwe Kleine-König 
Cc: Wolfgang Denk 
Cc: Wolfram Sang 
---
 Documentation/devicetree/bindings/i2c/i2c-mxs.txt |5 +
 arch/arm/boot/dts/imx28.dtsi  |2 +
 drivers/i2c/busses/i2c-mxs.c  |  267 +++--
 3 files changed, 252 insertions(+), 22 deletions(-)

V2: Fixed return value from mxs_i2c_dma_setup_xfer().
Fixed coding style nitpicks
Call mxs_i2c_dma_finish() in failpath only if DMA is active
V3: Align with changes in previous patch

diff --git a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
index 30ac3a0..45b6307 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
@@ -6,6 +6,10 @@ Required properties:
 - interrupts: Should contain ERROR and DMA interrupts
 - clock-frequency: Desired I2C bus clock frequency in Hz.
Only 10Hz and 40Hz modes are supported.
+- fsl,i2c-dma-channel: APBX DMA channel for the I2C
+
+Optional properties:
+- fsl,use-pio: Use PIO transfers instead of DMA, useful for debug
 
 Examples:
 
@@ -16,4 +20,5 @@ i2c0: i2c@80058000 {
reg = <0x80058000 2000>;
interrupts = <111 68>;
clock-frequency = <10>;
+   fsl,i2c-dma-channel = <6>;
 };
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index e2e9a2b..99bd037 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -587,6 +587,7 @@
reg = <0x80058000 2000>;
interrupts = <111 68>;
clock-frequency = <10>;
+   fsl,i2c-dma-channel = <6>;
status = "disabled";
};
 
@@ -597,6 +598,7 @@
reg = <0x8005a000 2000>;
interrupts = <110 69>;
clock-frequency = <10>;
+   fsl,i2c-dma-channel = <7>;
status = "disabled";
};
 
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 877b169..20290a6 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -7,8 +7,6 @@
  *
  * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  *
- * TODO: add dma-support if platform-support for it is available
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -31,6 +29,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #define DRIVER_NAME "mxs-i2c"
 
@@ -146,6 +147,16 @@ struct mxs_i2c_dev {
u32 cmd_err;
struct i2c_adapter adapter;
const struct mxs_i2c_speed_config *speed;
+
+   /* DMA support components */
+   booldma_mode;
+   int dma_channel;
+   struct dma_chan *dmach;
+   struct mxs_dma_data dma_data;
+   uint32_tpio_data[2];
+   uint32_taddr_data;
+   struct scatterlist  sg_io[2];
+   booldma_read;
 };
 
 static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
@@ -157,7 +168,11 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2);
 
writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
-   writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
+   if (i2c->dma_mode)
+   writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
+   i2c->regs + MXS_I2C_QUEUECTRL_CLR);
+   else
+   writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
i2c->regs + MXS_I2C_QUEUECTRL_SET);
 }
 
@@ -248,6 +263,150 @@ static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, 
u8 *buf, int len)
return 0;
 }
 
+static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
+{
+   if (i2c->dma_read) {
+   dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE);
+   dma_unmap_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE);
+   } else {
+   dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);
+   }
+}
+
+static void mxs_i2c_dma_irq_callback(void *param)
+{
+   struct mxs_i2c_dev *i2c = param;
+
+   complete(&i2c->cmd_complete);
+   mxs_i2c_dma_finish(i2c);
+}
+
+static int mxs_

[PATCH 1/2 V3] MXS: Set I2C timing registers for mxs-i2c

2012-07-09 Thread Marek Vasut
This patch configures the I2C bus timing registers according
to information passed via DT. Currently, 100kHz and 400kHz
modes are supported.

The TIMING2 register value is wrong in the documentation for
i.MX28! This was found and fixed by:
  Shawn Guo 

Signed-off-by: Marek Vasut 
Cc: Detlev Zundel 
CC: Dong Aisheng 
CC: Fabio Estevam 
Cc: Linux ARM kernel 
Cc: linux-i2c@vger.kernel.org
CC: Sascha Hauer 
CC: Shawn Guo 
Cc: Stefano Babic 
CC: Uwe Kleine-König 
Cc: Wolfgang Denk 
Cc: Wolfram Sang 
---
 Documentation/devicetree/bindings/i2c/i2c-mxs.txt |3 +
 arch/arm/boot/dts/imx28.dtsi  |2 +
 drivers/i2c/busses/i2c-mxs.c  |   66 +
 3 files changed, 71 insertions(+)

V2: Fixed static const struct mxs_i2c_speed_config
V3: Use 100kHz by default
Document support only for 100kHz and 400kHz
Document why the bus is configured to 95kHz instead of 100kHz
Replace "Invalid speed ..." message with "Unsupported speed ..." message

diff --git a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
index 1bfc02d..30ac3a0 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
@@ -4,6 +4,8 @@ Required properties:
 - compatible: Should be "fsl,-i2c"
 - reg: Should contain registers location and length
 - interrupts: Should contain ERROR and DMA interrupts
+- clock-frequency: Desired I2C bus clock frequency in Hz.
+   Only 10Hz and 40Hz modes are supported.
 
 Examples:
 
@@ -13,4 +15,5 @@ i2c0: i2c@80058000 {
compatible = "fsl,imx28-i2c";
reg = <0x80058000 2000>;
interrupts = <111 68>;
+   clock-frequency = <10>;
 };
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index adb5ffc..e2e9a2b 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -586,6 +586,7 @@
compatible = "fsl,imx28-i2c";
reg = <0x80058000 2000>;
interrupts = <111 68>;
+   clock-frequency = <10>;
status = "disabled";
};
 
@@ -595,6 +596,7 @@
compatible = "fsl,imx28-i2c";
reg = <0x8005a000 2000>;
interrupts = <110 69>;
+   clock-frequency = <10>;
status = "disabled";
};
 
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 04eb441..877b169 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -46,6 +46,10 @@
 #define MXS_I2C_CTRL0_DIRECTION0x0001
 #define MXS_I2C_CTRL0_XFER_COUNT(v)((v) & 0x)
 
+#define MXS_I2C_TIMING0(0x10)
+#define MXS_I2C_TIMING1(0x20)
+#define MXS_I2C_TIMING2(0x30)
+
 #define MXS_I2C_CTRL1  (0x40)
 #define MXS_I2C_CTRL1_SET  (0x44)
 #define MXS_I2C_CTRL1_CLR  (0x48)
@@ -97,6 +101,35 @@
 #define MXS_CMD_I2C_READ   (MXS_I2C_CTRL0_SEND_NAK_ON_LAST | \
 MXS_I2C_CTRL0_MASTER_MODE)
 
+struct mxs_i2c_speed_config {
+   uint32_ttiming0;
+   uint32_ttiming1;
+   uint32_ttiming2;
+};
+
+/*
+ * Timing values for the default 24MHz clock supplied into the i2c block.
+ *
+ * The bus can operate at 95kHz or at 400kHz with the following timing
+ * register configurations. The 100kHz mode isn't present because it's
+ * values are not stated in the i.MX233/i.MX28 datasheet. The 95kHz mode
+ * shall be close enough replacement. Therefore when the bus is configured
+ * for 100kHz operation, 95kHz timing settings are actually loaded.
+ *
+ * For details, see i.MX233 [25.4.2 - 25.4.4] and i.MX28 [27.5.2 - 27.5.4].
+ */
+static const struct mxs_i2c_speed_config mxs_i2c_95kHz_config = {
+   .timing0= 0x00780030,
+   .timing1= 0x00800030,
+   .timing2= 0x00300030,
+};
+
+static const struct mxs_i2c_speed_config mxs_i2c_400kHz_config = {
+   .timing0= 0x000f0007,
+   .timing1= 0x001f000f,
+   .timing2= 0x00300030,
+};
+
 /**
  * struct mxs_i2c_dev - per device, private MXS-I2C data
  *
@@ -112,11 +145,17 @@ struct mxs_i2c_dev {
struct completion cmd_complete;
u32 cmd_err;
struct i2c_adapter adapter;
+   const struct mxs_i2c_speed_config *speed;
 };
 
 static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
 {
stmp_reset_block(i2c->regs);
+
+   writel(i2c->speed->timing0, i2c->regs + MXS_I2C_TIMING0);
+   writel(i2c->speed->timing1, i2c->regs + MXS_I2C_TIMING1);
+   writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2);
+
writel(MXS_I2C_IRQ_MASK << 8, i2c->r

Re: [PATCH 1/2 V2] MXS: Set I2C timing registers for mxs-i2c

2012-07-09 Thread Marek Vasut
Dear Wolfram Sang,

> > > > diff --git a/arch/arm/boot/dts/imx28.dtsi
> > > > b/arch/arm/boot/dts/imx28.dtsi index ee3778a..832d30a 100644
> > > > --- a/arch/arm/boot/dts/imx28.dtsi
> > > > +++ b/arch/arm/boot/dts/imx28.dtsi
> > 
> > [...]
> > 
> > > > @@ -428,6 +429,7 @@
> > > > 
> > > > compatible = "fsl,imx28-i2c";
> > > > reg = <0x8005a000 2000>;
> > > > interrupts = <110 69>;
> > > > 
> > > > +   clock-frequency = <40>;
> > > 
> > > NACK on that. Not all slaves can do 400KHz, so this is not a sensible
> > > default.
> > 
> > How many of such chips are there and how many of the chips can do 400kHz
> > ? I believe the majority shouldn't suffer because of minority.
> 
> The kernel should work for all users, not only for the majority, so:
> Better safe than sorry.
> 
> Also, defaults should make the system work. Tuning can be done later by
> somebody who understands what is needed.
> 
> And frankly, this attitude which made you add a potential regression is
> worrisome. I'd suggest to give stability a higher priority.

I believe you misunderstood my intention. Setting it to 400kHz was done because 
it's what most people will use, therefore avoiding duplication (most of the 
board files will override this setting now). All right, your sane defaults here 
can be applied, I won't argue.

And frankly, you could have left the last jab out. Let's avoid attacking each 
other, I'm not in the mood for it today.

> Regards,
> 
>Wolfram

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Qiao Zhou

On 07/09/2012 09:21 PM, Samuel Ortiz wrote:

Hi Mark,

On Mon, Jul 09, 2012 at 11:55:33AM +0100, Mark Brown wrote:

On Mon, Jul 09, 2012 at 12:55:51PM +0200, Samuel Ortiz wrote:


I applied the first 2 patches, I'd like to get an ACK from the respective
maintainers for the rtc and the input ones. They can even take it as both
drivers are protected by the MFD symbol.


Alessandro's been mostly offline recently so it might be as well to
apply the RTC patch anyway.

Fair enough, applied now. Neither Alessandro nor the rtc ml wer not cc'ed on 
this
thread, but that's another problem.
Zhou, could you please send at least the rtc patch to Alessandro so that he
could have a look at it if time permits ?

Cheers,
Samuel.


Samuel, Mark, Arnd,

deeply appreciate your review, and I'll send the patch to Alessandro and 
rtc mainline. thanks!



--

Best Regards
Qiao


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c-s3c2410: Convert to devm_request_and_ioremap()

2012-07-09 Thread Mark Brown
On Mon, Jul 09, 2012 at 03:52:29PM +0200, Wolfram Sang wrote:
> On Thu, Jun 28, 2012 at 01:55:38PM +0100, Mark Brown wrote:
> > A small code saving and less error handling to worry about.

> > Signed-off-by: Mark Brown 

> What about devm for the clocks, too?

The devm_ versions of the API aren't exported there yet and there's a
bug fix pending too but Russell and Mike have ignored the patches thus
far.


signature.asc
Description: Digital signature


Re: [PATCH] i2c-s3c2410: Convert to devm_request_and_ioremap()

2012-07-09 Thread Wolfram Sang
On Thu, Jun 28, 2012 at 01:55:38PM +0100, Mark Brown wrote:
> A small code saving and less error handling to worry about.
> 
> Signed-off-by: Mark Brown 

What about devm for the clocks, too?


Thanks,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


RE: [PATCH] i2c_dw: deadlock happening when system is trying to suspend

2012-07-09 Thread Liu, Chuansheng
Sorry, I found the latest kernel code has some difference with my analysis.
I need more thoughts, then update this issue.

> -Original Message-
> From: Wolfram Sang [mailto:w.s...@pengutronix.de]
> Sent: Monday, July 09, 2012 9:32 PM
> To: Liu, Chuansheng
> Cc: linux-ker...@vger.kernel.org; linux-i2c@vger.kernel.org; 
> kh...@linux-fr.org;
> ben-li...@fluff.org; Yanmin Zhang 
> (yanmin_zh...@linux.intel.com); Srivatsa S. Bhat; Tu, Xiaobing
> Subject: Re: [PATCH] i2c_dw: deadlock happening when system is trying to
> suspend
> 
> On Tue, Jun 26, 2012 at 02:29:13PM +, Liu, Chuansheng wrote:
> > From: liu chuansheng 
> > Subject: [PATCH] i2c_dw: deadlock happening when system is trying to
> > suspend
> >
> > In i2c_dw code, there is a race condition that causes pm suspend
> > thread blocking there always. The scenerio is as below:
> >
> > PM thread:
> > suspend -->
> > pm_suspend -->
> > enter_state -->
> > dpm_suspend_start(will call i2c_dw_pci_suspend(), and the
> > dw_i2c_dev->lock is hold) ...
> > suspend_enter -->
> > dpm_suspend_noirq -->
> > suspend_device_irqs -->
> > synchronize_irq()
> >
> > synchronize_irq will wait for any pending irq is handled, and the
> > correpsonding irq thread is finished.
> >
> > In this case, there is a i2c device interrupt is pending, the irq
> > thread do the below things:
> > IRQ thread:
> > i2c_smbus_read_byte_data -->
> > i2c_smbus_xfer -->
> > i2c_transfer -->
> > i2c_dw_xfer -->
> > down()
> >
> > The irq thread blocked at down dw_i2c_dev->lock, because in PM thread,
> > it has been hold after calling i2c_dw_pci_suspend(), but PM thread is
> > waiting for IRQ thread, then deadlock happened.
> >
> > The solution is moving the down() action after pm_runtime_get_sync().
> >
> > Signed-off-by: liu chuansheng 
> > ---
> >  drivers/i2c/busses/i2c-designware-core.c |2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-designware-core.c
> > b/drivers/i2c/busses/i2c-designware-core.c
> > index 1e48bec..748ecb1 100644
> > --- a/drivers/i2c/busses/i2c-designware-core.c
> > +++ b/drivers/i2c/busses/i2c-designware-core.c
> > @@ -512,8 +512,8 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct
> > i2c_msg msgs[], int num)
> >
> > dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num);
> >
> > -   mutex_lock(&dev->lock);
> > pm_runtime_get_sync(dev->dev);
> > +   mutex_lock(&dev->lock);
> >
> > INIT_COMPLETION(dev->cmd_complete);
> > dev->msgs = msgs;
> 
> Don't you need to place the mutex_unlock() before pm_runtime_put then?
> 
> Thanks,
> 
>Wolfram
> 
> --
> Pengutronix e.K.   | Wolfram Sang
> |
> Industrial Linux Solutions | http://www.pengutronix.de/
> |
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c_dw: deadlock happening when system is trying to suspend

2012-07-09 Thread Wolfram Sang
On Tue, Jun 26, 2012 at 02:29:13PM +, Liu, Chuansheng wrote:
> From: liu chuansheng 
> Subject: [PATCH] i2c_dw: deadlock happening when system is trying to suspend
> 
> In i2c_dw code, there is a race condition that causes pm suspend
> thread blocking there always. The scenerio is as below:
> 
> PM thread:
> suspend -->
> pm_suspend -->
> enter_state -->
> dpm_suspend_start(will call i2c_dw_pci_suspend(),
> and the dw_i2c_dev->lock is hold)
> ...
> suspend_enter -->
> dpm_suspend_noirq -->
> suspend_device_irqs -->
> synchronize_irq()
> 
> synchronize_irq will wait for any pending irq is handled, and
> the correpsonding irq thread is finished.
> 
> In this case, there is a i2c device interrupt is pending, the irq
> thread do the below things:
> IRQ thread:
> i2c_smbus_read_byte_data -->
> i2c_smbus_xfer -->
> i2c_transfer -->
> i2c_dw_xfer -->
> down()
> 
> The irq thread blocked at down dw_i2c_dev->lock, because in PM thread,
> it has been hold after calling i2c_dw_pci_suspend(), but PM thread is
> waiting for IRQ thread, then deadlock happened.
> 
> The solution is moving the down() action after pm_runtime_get_sync().
> 
> Signed-off-by: liu chuansheng 
> ---
>  drivers/i2c/busses/i2c-designware-core.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-core.c 
> b/drivers/i2c/busses/i2c-designware-core.c
> index 1e48bec..748ecb1 100644
> --- a/drivers/i2c/busses/i2c-designware-core.c
> +++ b/drivers/i2c/busses/i2c-designware-core.c
> @@ -512,8 +512,8 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg 
> msgs[], int num)
>  
> dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num);
>  
> -   mutex_lock(&dev->lock);
> pm_runtime_get_sync(dev->dev);
> +   mutex_lock(&dev->lock);
>  
> INIT_COMPLETION(dev->cmd_complete);
> dev->msgs = msgs;

Don't you need to place the mutex_unlock() before pm_runtime_put then?

Thanks,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Samuel Ortiz
Hi Mark,

On Mon, Jul 09, 2012 at 11:55:33AM +0100, Mark Brown wrote:
> On Mon, Jul 09, 2012 at 12:55:51PM +0200, Samuel Ortiz wrote:
> 
> > I applied the first 2 patches, I'd like to get an ACK from the respective
> > maintainers for the rtc and the input ones. They can even take it as both
> > drivers are protected by the MFD symbol.
> 
> Alessandro's been mostly offline recently so it might be as well to
> apply the RTC patch anyway.
Fair enough, applied now. Neither Alessandro nor the rtc ml wer not cc'ed on 
this
thread, but that's another problem.
Zhou, could you please send at least the rtc patch to Alessandro so that he
could have a look at it if time permits ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Samuel Ortiz
Hi Arnd,

On Mon, Jul 09, 2012 at 11:46:03AM +, Arnd Bergmann wrote:
> On Monday 09 July 2012, Samuel Ortiz wrote:
> > On Mon, Jul 09, 2012 at 02:37:31PM +0800, Qiao Zhou wrote:
> > > change log [v5->v4]:
> > > 1, change the file name, from 88pm800-core.c, 88pm805-core.c, 
> > > 88pm80x-i2c.c
> > > to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
> > > 2, replace the spinlock used to protect wakeup flag, with using set_bit/
> > > clear_bit, which is suitable adn enough in SMP env.
> > > 3, add the version number in each patch.
> > I applied the first 2 patches, I'd like to get an ACK from the respective
> > maintainers for the rtc and the input ones. They can even take it as both
> > drivers are protected by the MFD symbol.
> > 
> 
> Please add my
> 
> Reviewed-by: Arnd Bergmann 
> 
> comment to these two patches as well.
Sure. Thanks a lot for your code review.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: i2c-imx: Adapt the clock name to the new clock framework

2012-07-09 Thread Wolfram Sang
On Fri, Jul 06, 2012 at 03:31:32PM -0300, Fabio Estevam wrote:
> With the new i.mx clock framework the i2c clock is registered as:
> 
> clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx-i2c.0")
> 
> So we do not need to pass "i2c_clk" string and can use NULL instead.
> 
> Signed-off-by: Fabio Estevam 

Applied to next after fixing it up because we now use devm.

Thanks!

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 2/2] i2c: stu300: use devm allocation

2012-07-09 Thread Wolfram Sang
On Tue, Jun 12, 2012 at 07:33:37PM +0200, Linus Walleij wrote:
> From: Linus Walleij 
> 
> Allocate memory for device state using devm_kzalloc() to
> simplify accounting.
> 
> Signed-off-by: Linus Walleij 

Please use devm_* for resource allocation, too, then...

> ---
>  drivers/i2c/busses/i2c-stu300.c |4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
> index 79b7851..e5c10c5 100644
> --- a/drivers/i2c/busses/i2c-stu300.c
> +++ b/drivers/i2c/busses/i2c-stu300.c
> @@ -873,7 +873,7 @@ stu300_probe(struct platform_device *pdev)
>   int ret = 0;
>   char clk_name[] = "I2C0";
>  
> - dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL);
> + dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL);
>   if (!dev) {
>   dev_err(&pdev->dev, "could not allocate device struct\n");
>   ret = -ENOMEM;
> @@ -971,7 +971,6 @@ stu300_probe(struct platform_device *pdev)
>   err_no_resource:
>   clk_put(dev->clk);
>   err_no_clk:
> - kfree(dev);
>   err_no_devmem:
>   dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n",
>   pdev->id);
> @@ -1020,7 +1019,6 @@ stu300_remove(struct platform_device *pdev)
>   clk_unprepare(dev->clk);
>   clk_put(dev->clk);
>   platform_set_drvdata(pdev, NULL);
> - kfree(dev);
>   return 0;
>  }
>  
> -- 
> 1.7.9.2
> 

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 1/2] i2c: stu300: use clk_prepare/unprepare

2012-07-09 Thread Wolfram Sang
On Tue, Jun 12, 2012 at 07:33:30PM +0200, Linus Walleij wrote:
> From: Linus Walleij 
> 
> Make sure we prepare/unprepare the clock for the ST U300
> I2C driver as is required by the clk API especially if you
> use common clock.
> 
> Signed-off-by: Linus Walleij 

Applied to next.

BTW sparse throws this for me, maybe you are interested:

drivers/i2c/busses/i2c-stu300.c:464:55: warning: cast removes address space of 
expression

Thanks,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 1/2 V2] MXS: Set I2C timing registers for mxs-i2c

2012-07-09 Thread Wolfram Sang

> > > diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
> > > index ee3778a..832d30a 100644
> > > --- a/arch/arm/boot/dts/imx28.dtsi
> > > +++ b/arch/arm/boot/dts/imx28.dtsi
> [...]
> > > @@ -428,6 +429,7 @@
> > > 
> > >   compatible = "fsl,imx28-i2c";
> > >   reg = <0x8005a000 2000>;
> > >   interrupts = <110 69>;
> > > 
> > > + clock-frequency = <40>;
> > 
> > NACK on that. Not all slaves can do 400KHz, so this is not a sensible
> > default.
> 
> How many of such chips are there and how many of the chips can do 400kHz ? I 
> believe the majority shouldn't suffer because of minority.

The kernel should work for all users, not only for the majority, so:
Better safe than sorry.

Also, defaults should make the system work. Tuning can be done later by
somebody who understands what is needed.

And frankly, this attitude which made you add a potential regression is
worrisome. I'd suggest to give stability a higher priority.

Regards,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCHv11 0/6] I2C cleanups

2012-07-09 Thread Shubhrajyoti Datta
On Thu, Jun 28, 2012 at 8:41 PM, Shubhrajyoti D  wrote:
> This is a minimal cleanup series.

If there are no further comments can this series be queued?


>
> The patch series does the following
>
> - Bus busy recovery mechanism.
> - Make the i2c use SET_RUNTIME_PM_OPS
> - Use INIT_COMPLETION instead of init_completion
> - the reset patch is dropped will try to rework it as per the
>  review comments recieved.
>
>
> This applies on Wolfram's i2c-embedded/for-next branch.
>
> Functional testing on omap4430 , 4460 panda and omap3sdp.
>
>
> The following changes since commit 0f009a914b40be8786fa67b1f4345cacc263b48c:
>
>   i2c: tegra: make all resource allocation through devm_* (2012-06-13 
> 16:01:38 +0200)
>
> are available in the git repository at:
>   git://gitorious.org/linus-tree/linus-tree.git for_next/omap/minimal_cleanup
>
> Jon Hunter (1):
>   i2c: omap: Correct I2C revision for OMAP3
>
> Shubhrajyoti D (4):
>   i2c: omap: Optimise the remove code
>   i2c: omap: Use SET_RUNTIME_PM_OPS
>   i2c: omap: Do not initialise the completion everytime
>   i2c: omap: Remove the definition of SYSS_RESETDONE_MASK
>
> Vikram Pandita (1):
>   i2c: omap: Recover from Bus Busy condition
>
>  drivers/i2c/busses/i2c-omap.c |   60 
>  1 files changed, 42 insertions(+), 18 deletions(-)
>
> --
> 1.7.5.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Arnd Bergmann
On Monday 09 July 2012, Samuel Ortiz wrote:
> On Mon, Jul 09, 2012 at 02:37:31PM +0800, Qiao Zhou wrote:
> > change log [v5->v4]:
> > 1, change the file name, from 88pm800-core.c, 88pm805-core.c, 88pm80x-i2c.c
> > to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
> > 2, replace the spinlock used to protect wakeup flag, with using set_bit/
> > clear_bit, which is suitable adn enough in SMP env.
> > 3, add the version number in each patch.
> I applied the first 2 patches, I'd like to get an ACK from the respective
> maintainers for the rtc and the input ones. They can even take it as both
> drivers are protected by the MFD symbol.
> 

Please add my

Reviewed-by: Arnd Bergmann 

comment to these two patches as well.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: mxs: mxs_i2c_finish_read: mute flase positive uninitialized var

2012-07-09 Thread Wolfram Sang
On Sun, Jul 01, 2012 at 11:34:30PM +0200, Marc Kleine-Budde wrote:
> This patch mutes the false positive compiler warning:
> 
> drivers/i2c/busses/i2c-mxs.c: In function 'mxs_i2c_xfer_msg':
> drivers/i2c/busses/i2c-mxs.c:206:8: warning: 'data' may be used uninitialized 
> in this function [-Wuninitialized]
> drivers/i2c/busses/i2c-mxs.c:196:6: note: 'data' was declared here
> 
> Cc: "Wolfram Sang" 

FYI: Checkpatch complains about the position of the quotes above.

> Signed-off-by: Marc Kleine-Budde 

Applied. I didn't know the exact intention of 'uninitialized_var'
before. Its commit message (9490991482a2091a828d997adbc088e24c310a4d)
convinces me to accept this compromise. It will silence the warning, but
it can be disabled if such warnings want to be seen. Also, there is no
extra code added like with '= 0'.

I still do think however, gcc should be able to find out what happens.
There is no pointer magic involved here...

> ---
>  drivers/i2c/busses/i2c-mxs.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
> index 04eb441..02ce1fa 100644
> --- a/drivers/i2c/busses/i2c-mxs.c
> +++ b/drivers/i2c/busses/i2c-mxs.c
> @@ -193,7 +193,7 @@ static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c)
>  
>  static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len)
>  {
> - u32 data;
> + u32 uninitialized_var(data);
>   int i;
>  
>   for (i = 0; i < len; i++) {
> -- 
> 1.7.10
> 

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 1/2 V2] MXS: Set I2C timing registers for mxs-i2c

2012-07-09 Thread Marek Vasut
Dear Wolfram Sang,

[...]

> > diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
> > index ee3778a..832d30a 100644
> > --- a/arch/arm/boot/dts/imx28.dtsi
> > +++ b/arch/arm/boot/dts/imx28.dtsi
[...]
> > @@ -428,6 +429,7 @@
> > 
> > compatible = "fsl,imx28-i2c";
> > reg = <0x8005a000 2000>;
> > interrupts = <110 69>;
> > 
> > +   clock-frequency = <40>;
> 
> NACK on that. Not all slaves can do 400KHz, so this is not a sensible
> default.

How many of such chips are there and how many of the chips can do 400kHz ? I 
believe the majority shouldn't suffer because of minority.

[...]

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Mark Brown
On Mon, Jul 09, 2012 at 12:55:51PM +0200, Samuel Ortiz wrote:

> I applied the first 2 patches, I'd like to get an ACK from the respective
> maintainers for the rtc and the input ones. They can even take it as both
> drivers are protected by the MFD symbol.

Alessandro's been mostly offline recently so it might be as well to
apply the RTC patch anyway.


signature.asc
Description: Digital signature


Re: [PATCH 1/2 V2] MXS: Set I2C timing registers for mxs-i2c

2012-07-09 Thread Wolfram Sang
Hi Marek,

thanks for the submission.

On Fri, Jul 06, 2012 at 08:09:15AM +0200, Marek Vasut wrote:
> This patch configures the I2C bus timing registers according
> to information passed via DT. Currently, 100kHz and 400kHz
> modes are supported.

That limitation should be mentioned in the documentation.

> 
> The TIMING2 register value is wrong in the documentation for
> i.MX28! This was found and fixed by:
>   Shawn Guo 
> 
> Signed-off-by: Marek Vasut 
> Cc: Detlev Zundel 
> CC: Dong Aisheng 
> CC: Fabio Estevam 
> Cc: Linux ARM kernel 
> Cc: linux-i2c@vger.kernel.org
> CC: Sascha Hauer 
> CC: Shawn Guo 
> Cc: Stefano Babic 
> CC: Uwe Kleine-König 
> Cc: Wolfgang Denk 
> Cc: Wolfram Sang 
> ---
>  Documentation/devicetree/bindings/i2c/i2c-mxs.txt |2 +
>  arch/arm/boot/dts/imx28.dtsi  |2 +
>  drivers/i2c/busses/i2c-mxs.c  |   56 
> +
>  3 files changed, 60 insertions(+)
> 
> V2: (even though technically V, I really need to start doing this
>  patch management properly, it's quite a mess now)

Yup, it was :) Thanks for resending.

> Fixed static const struct mxs_i2c_speed_config ... pointed by Dong.
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt 
> b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
> index 1bfc02d..2ed5332 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
> @@ -4,6 +4,7 @@ Required properties:
>  - compatible: Should be "fsl,-i2c"
>  - reg: Should contain registers location and length
>  - interrupts: Should contain ERROR and DMA interrupts
> +- clock-frequency: desired I2C bus clock frequency in Hz.
>  
>  Examples:
>  
> @@ -13,4 +14,5 @@ i2c0: i2c@80058000 {
>   compatible = "fsl,imx28-i2c";
>   reg = <0x80058000 2000>;
>   interrupts = <111 68>;
> + clock-frequency = <40>;
>  };
> diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
> index ee3778a..832d30a 100644
> --- a/arch/arm/boot/dts/imx28.dtsi
> +++ b/arch/arm/boot/dts/imx28.dtsi
> @@ -419,6 +419,7 @@
>   compatible = "fsl,imx28-i2c";
>   reg = <0x80058000 2000>;
>   interrupts = <111 68>;
> + clock-frequency = <40>;
>   status = "disabled";
>   };
>  
> @@ -428,6 +429,7 @@
>   compatible = "fsl,imx28-i2c";
>   reg = <0x8005a000 2000>;
>   interrupts = <110 69>;
> + clock-frequency = <40>;

NACK on that. Not all slaves can do 400KHz, so this is not a sensible
default.

>   status = "disabled";
>   };
>  
> diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
> index 04eb441..47a7e20 100644
> --- a/drivers/i2c/busses/i2c-mxs.c
> +++ b/drivers/i2c/busses/i2c-mxs.c
> @@ -46,6 +46,10 @@
>  #define MXS_I2C_CTRL0_DIRECTION  0x0001
>  #define MXS_I2C_CTRL0_XFER_COUNT(v)  ((v) & 0x)
>  
> +#define MXS_I2C_TIMING0  (0x10)
> +#define MXS_I2C_TIMING1  (0x20)
> +#define MXS_I2C_TIMING2  (0x30)
> +
>  #define MXS_I2C_CTRL1(0x40)
>  #define MXS_I2C_CTRL1_SET(0x44)
>  #define MXS_I2C_CTRL1_CLR(0x48)
> @@ -97,6 +101,25 @@
>  #define MXS_CMD_I2C_READ (MXS_I2C_CTRL0_SEND_NAK_ON_LAST | \
>MXS_I2C_CTRL0_MASTER_MODE)
>  
> +struct mxs_i2c_speed_config {
> + uint32_ttiming0;
> + uint32_ttiming1;
> + uint32_ttiming2;
> +};
> +
> +/* Timing values for the default 24MHz clock supplied into the i2c block. */
> +static const struct mxs_i2c_speed_config mxs_i2c_95kHz_config = {

Hmm, the 100KHz vs 95KHz issue is confusing. My suggestion would be to
name this mxs_i2c_100kHz_config and write a comment that this is
technically 95Khz due to limitation of the docs (or whatever). If you
want to keep the name, then a similar comment should be placed...


> + .timing0= 0x00780030,
> + .timing1= 0x00800030,
> + .timing2= 0x00300030,
> +};
> +
> +static const struct mxs_i2c_speed_config mxs_i2c_400kHz_config = {
> + .timing0= 0x000f0007,
> + .timing1= 0x001f000f,
> + .timing2= 0x00300030,
> +};
> +
>  /**
>   * struct mxs_i2c_dev - per device, private MXS-I2C data
>   *
> @@ -112,11 +135,17 @@ struct mxs_i2c_dev {
>   struct completion cmd_complete;
>   u32 cmd_err;
>   struct i2c_adapter adapter;
> + const struct mxs_i2c_speed_config *speed;
>  };
>  
>  static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
>  {
>   stmp_reset_block(i2c->regs);
> +
> + writel(i2c->speed->timing0, i2c->regs + MXS_I2C_TIMING0);
> + writel(i2c->speed->timing1, i2c->regs +

Re: [PATCH 0/4 V5] add 88pm80x mfd driver

2012-07-09 Thread Samuel Ortiz
Hi Zhou,

On Mon, Jul 09, 2012 at 02:37:31PM +0800, Qiao Zhou wrote:
> change log [v5->v4]:
> 1, change the file name, from 88pm800-core.c, 88pm805-core.c, 88pm80x-i2c.c
> to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
> 2, replace the spinlock used to protect wakeup flag, with using set_bit/
> clear_bit, which is suitable adn enough in SMP env.
> 3, add the version number in each patch.
I applied the first 2 patches, I'd like to get an ACK from the respective
maintainers for the rtc and the input ones. They can even take it as both
drivers are protected by the MFD symbol.

Cheers,
Samuel. 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c-nomadik: Add 10-bit addressing support

2012-07-09 Thread Wolfram Sang
On Mon, Jun 25, 2012 at 05:56:07PM +0530, Srinidhi KASAGAR wrote:
> From: Virupax Sadashivpetimath 
> 
> Signed-off-by: Virupax Sadashivpetimath 
> 
> Signed-off-by: Srinidhi KASAGAR 

Applied to next, thanks!

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH V3 0/3] i2c-nomadik changes

2012-07-09 Thread Wolfram Sang
On Mon, Jun 11, 2012 at 11:37:15PM +0200, Linus Walleij wrote:
> On Mon, Jun 11, 2012 at 10:56 PM, Alessandro Rubini  wrote:
> 
> > V3:
> >        - fixed according to Linusw feedback (merged the patch he posted)
> >        - added Tested-by: Linusw on his permission
> 
> I'm happy with this version, Wolfram if it looks OK to you,
> can you please merge this into the I2C tree?

Done now, thanks.

Is the latest version of Lee's patches for DT sent on 20/06 suitable to
go on top of that?

Regards,

   Wolfram

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH] i2c: imx: make bitrate unsigned int

2012-07-09 Thread Wolfram Sang
On Mon, Jul 09, 2012 at 02:24:29PM +0800, Richard Zhao wrote:
> On Sun, Jul 08, 2012 at 01:24:47PM +0200, Wolfram Sang wrote:
> > sparse found this assignment of u32 to an int. Fix it:
> > 
> > drivers/i2c/busses/i2c-imx.c:540:56: warning: incorrect type in argument 3 
> > (different signedness)
> Could you change imxi2c_platform_data.bitrate to unsigned int too?

Good point, thanks!

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: Fwd: Hid over I2C and ACPI interaction

2012-07-09 Thread Mika Westerberg
On Mon, Jul 09, 2012 at 11:24:45AM +0800, Lan Tianyu wrote:
> I think we can add new interface to get acpi specific resources. e.g
> struct acpi_resource pnp_get_acpi_resource(...). When the pnp acpi devices
> were initialized, put those acpi specific resources into a new resource list
> pnpdev->acpi_resources. What pnp_get_acpi_resource does is to get specified
> type acpi resources and return. We also need to define some acpi resource 
> types.

Yeah, that sounds good to me.
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fwd: Hid over I2C and ACPI interaction

2012-07-09 Thread Lan Tianyu
On 2012年07月09日 12:02, Moore, Robert wrote:
> These are already defined in acpica - in the file acrestyp.h
> 
>  ACPI_RESOURCE_FIXED_DMA FixedDma;
> 
>  ACPI_RESOURCE_GPIO  Gpio;
>  ACPI_RESOURCE_I2C_SERIALBUS I2cSerialBus;
>  ACPI_RESOURCE_SPI_SERIALBUS SpiSerialBus;
>  ACPI_RESOURCE_UART_SERIALBUSUartSerialBus;
>  ACPI_RESOURCE_COMMON_SERIALBUS  CommonSerialBus;
> 
Yeah. Thanks for Bob's reminder. We can reuse these macros.

> 
> 
>> -Original Message-
>> From: linux-acpi-ow...@vger.kernel.org [mailto:linux-acpi-
>> ow...@vger.kernel.org] On Behalf Of Lan Tianyu
>> Sent: Sunday, July 08, 2012 8:25 PM
>> To: Mika Westerberg
>> Cc: Zhang, Rui; kh...@linux-fr.org; ben-li...@fluff.org;
>> w.s...@pengutronix.de; l...@kernel.org; linux-a...@vger.kernel.org; linux-
>> i...@vger.kernel.org; linux-ker...@vger.kernel.org; jkos...@suse.cz;
>> cha...@enac.fr; jj_d...@emc.com.tw; bhelg...@google.com; abe...@mit.edu
>> Subject: Re: Fwd: Hid over I2C and ACPI interaction
>>
>> On 2012年07月06日 13:52, Mika Westerberg wrote:
>>> On Thu, Jul 05, 2012 at 03:01:57PM +0800, Zhang Rui wrote:
 +Note that although these are ACPI devices, we prefer to use PnP drivers
 for them,
 +this is because:
 +1. all the non-ACPI-predefined Devices are exported as PnP devices as
 well
 +2. PnP bus is a well designed bus. Probing via PnP layer saves a lot of
 work
 +   for the device driver, e.g. getting&   parsing ACPI resources.
>>>
>>> (Nice BKM, thanks for sharing)
>>>
>>> I have few questions about using PnP drivers instead of pure ACPI
>> drivers.
>>>
>>> ACPI 5.0 defined some new resources, for example "Fixed DMA descriptor"
>>> that has information about the request line + channel for the device to
>>> use. Hovewer, PnP drivers pass resources as 'struct resource', which
>>> basically only has start and end - how do you represent all this new
>> stuff
>>> using 'struct resource'?
>>>
>> I think we can add new interface to get acpi specific resources. e.g
>> struct acpi_resource pnp_get_acpi_resource(...). When the pnp acpi devices
>> were initialized, put those acpi specific resources into a new resource
>> list
>> pnpdev->acpi_resources. What pnp_get_acpi_resource does is to get specified
>> type acpi resources and return. We also need to define some acpi resource
>> types.
>>
>> ACPI_RESOURCE_DMA
>> ACPI_RESOURCE_I2C_SERIALBUS
>> ACPI_RESOURCE_SPI_SERIALBUS
>> ACPI_RESOURCE_UART_SERIALBUS
>> ACPI_RESOURCE_COMMON_SERIALBUS
>> ...
>>
>> How about this? welcome to comments.
>>
>>> Or should we use acpi_walk_resources() where 'struct resource' is not
>>> suitable?
>>>
>>
>> --
>> Best Regards
>> Tianyu Lan
>> linux kernel enabling team
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: i2c-imx: Adapt the clock name to the new clock framework

2012-07-09 Thread Sascha Hauer
On Fri, Jul 06, 2012 at 03:31:32PM -0300, Fabio Estevam wrote:
> With the new i.mx clock framework the i2c clock is registered as:
> 
> clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx-i2c.0")
> 
> So we do not need to pass "i2c_clk" string and can use NULL instead.
> 
> Signed-off-by: Fabio Estevam 

Acked-by: Sascha Hauer 

Sascha

> ---
>  drivers/i2c/busses/i2c-imx.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 370031a..a8709b1 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -528,7 +528,7 @@ static int __init i2c_imx_probe(struct platform_device 
> *pdev)
>   }
>  
>   /* Get I2C clock */
> - i2c_imx->clk = clk_get(&pdev->dev, "i2c_clk");
> + i2c_imx->clk = clk_get(&pdev->dev, NULL);
>   if (IS_ERR(i2c_imx->clk)) {
>   ret = PTR_ERR(i2c_imx->clk);
>   dev_err(&pdev->dev, "can't get I2C clock\n");
> -- 
> 1.7.1
> 
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html