Re: [PATCH 1/2] I2C: EMMA Mobile I2C master driver

2014-01-08 Thread Ian Molton

On 11/12/13 11:59, Wolfram Sang wrote:

No need to resend. I have it on my todo-list. Yet, by glimpsing at it I
found some issues which need a proper review for which I didn't have the
time so far. I hope to have it done by this week.


Ping :)

-Ian
--
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 1/2] I2C: EMMA Mobile I2C master driver

2013-12-06 Thread Ian Molton

On 25/09/13 05:45, Simon Horman wrote:


Hi Ian,

I spoke with Magnus and in turn Ben about this at LinuxCon in New Orleans
last week.

Basically the position of Magnus and I is that any support for this
hardware is an incremental improvement on the current situation: no
support.

With this in mind from an shmobile point of view I am happy for this code.
And there is no need to wait for a review from Magnus.


Has anyone merged this for upstream yet? If not, where should I send it?

-Ian
--
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] EMMA: Add em i2c driver

2013-09-03 Thread Ian Molton
Add a driver for the EMMA mobile I2C block.

The driver supports low and high-speed interrupt driven PIO transfers.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
---
 drivers/i2c/busses/Kconfig  |   10 +
 drivers/i2c/busses/Makefile |1 +
 drivers/i2c/busses/i2c-em.c |  534 +++
 3 files changed, 545 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-em.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index dc6dea6..e5cda34 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -777,6 +777,16 @@ config I2C_RCAR
  This driver can also be built as a module.  If so, the module
  will be called i2c-rcar.
 
+config I2C_EM
+   tristate EMMA Mobile series I2C adapter
+   depends on I2C  HAVE_CLK
+   help
+ If you say yes to this option, support will be included for the
+ I2C interface on the Renesas Electronics EM/EV of processors.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-em
+
 comment External I2C/SMBus adapter drivers
 
 config I2C_DIOLAN_U2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index d00997f..f7022ab 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_I2C_OCTEON)  += i2c-octeon.o
 obj-$(CONFIG_I2C_XILINX)   += i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)  += i2c-xlr.o
 obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o
+obj-$(CONFIG_I2C_EM)+= i2c-em.o
 
 # External I2C/SMBus adapter drivers
 obj-$(CONFIG_I2C_DIOLAN_U2C)   += i2c-diolan-u2c.o
diff --git a/drivers/i2c/busses/i2c-em.c b/drivers/i2c/busses/i2c-em.c
new file mode 100644
index 000..e8fc7aa
--- /dev/null
+++ b/drivers/i2c/busses/i2c-em.c
@@ -0,0 +1,534 @@
+/*
+ * (c) 2013 Ian Molton ian.mol...@codethink.co.uk
+ * Parts (c) 2010 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/of_i2c.h
+#include linux/clk.h
+#include linux/io.h
+#include linux/sched.h
+
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/of_device.h
+#include linux/platform_device.h
+
+/* INT Reg */
+#define EMXX_I2C_INT_RAW   (IO_ADDRESS(EMXX_INTA_D_BASE) + 0x014)
+#define EMXX_I2C_INT_IIR   (IO_ADDRESS(EMXX_INTA_D_BASE) + 0x024)
+
+/* INT Reg bit */
+#define EMXX_I2C0_INTC_MST (1  0)
+#define EMXX_I2C1_INTC_MST (1  1)
+#define EMXX_I2C0_INTC_IIR (1  16)
+#define EMXX_I2C1_INTC_IIR (1  17)
+
+/* I2C Registers */
+
+#define I2C_OFS_IICACT00x00/* start */
+#define I2C_OFS_IIC0   0x04/* shift */
+#define I2C_OFS_IICC0  0x08/* control */
+#define I2C_OFS_SVA0   0x0c/* slave address */
+#define I2C_OFS_IICCL0 0x10/* clock select */
+#define I2C_OFS_IICX0  0x14/* extention */
+#define I2C_OFS_IICS0  0x18/* status */
+#define I2C_OFS_IICSE0 0x1c/* status For emulation */
+#define I2C_OFS_IICF0  0x20/* IIC flag */
+
+
+/* I2C IICACT0 Masks */
+#define I2C_BIT_IICE0  0x0001
+
+/* I2C IICC0 Masks */
+#define I2C_BIT_LREL0  0x0040
+#define I2C_BIT_WREL0  0x0020
+#define I2C_BIT_SPIE0  0x0010
+#define I2C_BIT_WTIM0  0x0008
+#define I2C_BIT_ACKE0  0x0004
+#define I2C_BIT_STT0   0x0002
+#define I2C_BIT_SPT0   0x0001
+
+/* I2C IICCL0 Masks */
+#define I2C_BIT_CLD0   0x0020
+#define I2C_BIT_DAD0   0x0010
+#define I2C_BIT_SMC0   0x0008
+#define I2C_BIT_DFC0   0x0004
+#define I2C_BIT_CLO1   0x0002
+#define I2C_BIT_CLO0   0x0001
+
+/* I2C IICSE0 Masks */
+#define I2C_BIT_MSTS0  0x0080
+#define I2C_BIT_ALD0   0x0040
+#define I2C_BIT_EXC0   0x0020
+#define I2C_BIT_COI0   0x0010
+#define I2C_BIT_TRC0   0x0008
+#define I2C_BIT_ACKD0  0x0004
+#define I2C_BIT_STD0   0x0002
+#define I2C_BIT_SPD0   0x0001
+
+/* I2C IICF0 Masks */
+#define I2C_BIT_STCF   0x0080
+#define I2C_BIT_IICBSY 0x0040
+#define I2C_BIT_STCEN  0x0002
+#define I2C_BIT_IICRSV 0x0001
+
+/* For setting of sending

[PATCH 1/2] I2C: EMMA Mobile I2C master driver

2013-09-03 Thread Ian Molton
Add a driver for the EMMA mobile I2C block.

The driver supports low and high-speed interrupt driven PIO transfers.

Signed-off-by: Ian Molton ian.mol...@codethink.co.uk
---
 drivers/i2c/busses/Kconfig  |   10 +
 drivers/i2c/busses/Makefile |1 +
 drivers/i2c/busses/i2c-em.c |  501 +++
 3 files changed, 512 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-em.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index dc6dea6..d66d4b4 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -777,6 +777,16 @@ config I2C_RCAR
  This driver can also be built as a module.  If so, the module
  will be called i2c-rcar.
 
+config I2C_EM
+   tristate EMMA Mobile series I2C adapter
+   depends on I2C  HAVE_CLK
+   help
+ If you say yes to this option, support will be included for the
+ I2C interface on the Renesas Electronics EM/EV family of processors.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-em
+
 comment External I2C/SMBus adapter drivers
 
 config I2C_DIOLAN_U2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index d00997f..d330706 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -42,6 +42,7 @@ i2c-designware-platform-objs := i2c-designware-platdrv.o
 obj-$(CONFIG_I2C_DESIGNWARE_PCI)   += i2c-designware-pci.o
 i2c-designware-pci-objs := i2c-designware-pcidrv.o
 obj-$(CONFIG_I2C_EG20T)+= i2c-eg20t.o
+obj-$(CONFIG_I2C_EM)+= i2c-em.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-em.c b/drivers/i2c/busses/i2c-em.c
new file mode 100644
index 000..d7e91b4
--- /dev/null
+++ b/drivers/i2c/busses/i2c-em.c
@@ -0,0 +1,501 @@
+/*
+ * Copyright 2013 Codethink Ltd.
+ * Parts Copyright 2010 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/of_i2c.h
+#include linux/clk.h
+#include linux/io.h
+#include linux/sched.h
+
+#include linux/interrupt.h
+#include linux/device.h
+#include linux/of_device.h
+#include linux/platform_device.h
+
+/* I2C Registers */
+#define I2C_OFS_IICACT00x00/* start */
+#define I2C_OFS_IIC0   0x04/* shift */
+#define I2C_OFS_IICC0  0x08/* control */
+#define I2C_OFS_SVA0   0x0c/* slave address */
+#define I2C_OFS_IICCL0 0x10/* clock select */
+#define I2C_OFS_IICX0  0x14/* extention */
+#define I2C_OFS_IICS0  0x18/* status */
+#define I2C_OFS_IICSE0 0x1c/* status For emulation */
+#define I2C_OFS_IICF0  0x20/* IIC flag */
+
+/* I2C IICACT0 Masks */
+#define I2C_BIT_IICE0  0x0001
+
+/* I2C IICC0 Masks */
+#define I2C_BIT_LREL0  0x0040
+#define I2C_BIT_WREL0  0x0020
+#define I2C_BIT_SPIE0  0x0010
+#define I2C_BIT_WTIM0  0x0008
+#define I2C_BIT_ACKE0  0x0004
+#define I2C_BIT_STT0   0x0002
+#define I2C_BIT_SPT0   0x0001
+
+/* I2C IICCL0 Masks */
+#define I2C_BIT_SMC0   0x0008
+#define I2C_BIT_DFC0   0x0004
+
+/* I2C IICSE0 Masks */
+#define I2C_BIT_MSTS0  0x0080
+#define I2C_BIT_ALD0   0x0040
+#define I2C_BIT_EXC0   0x0020
+#define I2C_BIT_COI0   0x0010
+#define I2C_BIT_TRC0   0x0008
+#define I2C_BIT_ACKD0  0x0004
+#define I2C_BIT_STD0   0x0002
+#define I2C_BIT_SPD0   0x0001
+
+/* I2C IICF0 Masks */
+#define I2C_BIT_STCF   0x0080
+#define I2C_BIT_IICBSY 0x0040
+#define I2C_BIT_STCEN  0x0002
+#define I2C_BIT_IICRSV 0x0001
+
+static int em_i2c_xfer(struct i2c_adapter *, struct i2c_msg[], int);
+
+struct em_i2c_device {
+   struct i2c_adapter  adap;
+   wait_queue_head_t   i2c_wait;
+   void __iomem*membase;
+   struct clk  *clk;
+   struct clk  *sclk;
+   int irq;
+   int flags;
+   int pending;
+   spinlock_t

[Patch v3]EMMA I2C driver

2013-09-03 Thread Ian Molton
All comments fixed up, version 3.

--
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] EMMA: Add em i2c driver

2013-08-29 Thread Ian Molton

On 29/08/13 11:24, Ben Dooks wrote:

On 29/08/13 06:33, Magnus Damm wrote:

Hi Ian,

Thanks for submitting this patch. I have one comment only, please see 
below.

+#ifdef CONFIG_I2C_EMXX_SMC
+   i2c_dev-flags |= I2C_BIT_SMC0;
+#endif


I think CONFIG_I2C_EMXX_SMC probably want to be reworked somehow. I
assume it's an old left over in this particular case. But if you need
to have some special configuration method then please consider some
other way than CONFIG_ variables that are not very compatible with
future multi-platform kernel images.


Is it something that needs to be passed through the device tree binding
or something we can detect from the SoC itself?



Probably. Its the switch to select between 100 and 400kHz modes.

I wonder if theres a standard binding for it?


-Ian
--
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