Re: [PATCHv2] i2c: adds support for i2c bus on Freescale CPM1/CPM2 controllers

2008-05-29 Thread Jean Delvare
On Thu, 29 May 2008 17:52:26 +0200, Jean Delvare wrote:
> On Wed, 21 May 2008 18:39:42 +0200, Jochen Friedrich wrote:
> > This driver uses the port of 2.4 code from Vitaly Bordug
> > <[EMAIL PROTECTED]> and the actual algorithm used by the i2c
> > driver of the DBox code on cvs.tuxboc.org from Felix Domke
> > ([EMAIL PROTECTED]) and Gillem ([EMAIL PROTECTED]) converted to an
> > of_platform_driver. Tested on CPM1 (MPC823 on dbox2 hardware) and
> > CPM2 (MPC8272).
> > 
> > Signed-off-by: Jochen Friedrich <[EMAIL PROTECTED]>
> > ---
> >  drivers/i2c/busses/Kconfig   |   10 +
> >  drivers/i2c/busses/Makefile  |1 +
> >  drivers/i2c/busses/i2c-cpm.c |  745 
> > ++
> >  3 files changed, 756 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/i2c/busses/i2c-cpm.c
> > 
> > Changes since last version:
> > - change bus-frequency -> clock-frequency to comply to OF standard.
> > 
> 
> Applied, thanks. And thanks a lot to Wolfram for the review :)

Oh, I almost forgot: Jochen, would you like to be the maintainer for
this new driver? If you do, please send a patch adding yourself to
MAINTAINERS. Having dedicated driver maintainers makes my subsystem
maintainer's job easier.

Thanks,
-- 
Jean Delvare
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCHv2] i2c: adds support for i2c bus on Freescale CPM1/CPM2 controllers

2008-05-29 Thread Jean Delvare
On Wed, 21 May 2008 18:39:42 +0200, Jochen Friedrich wrote:
> This driver uses the port of 2.4 code from Vitaly Bordug
> <[EMAIL PROTECTED]> and the actual algorithm used by the i2c
> driver of the DBox code on cvs.tuxboc.org from Felix Domke
> ([EMAIL PROTECTED]) and Gillem ([EMAIL PROTECTED]) converted to an
> of_platform_driver. Tested on CPM1 (MPC823 on dbox2 hardware) and
> CPM2 (MPC8272).
> 
> Signed-off-by: Jochen Friedrich <[EMAIL PROTECTED]>
> ---
>  drivers/i2c/busses/Kconfig   |   10 +
>  drivers/i2c/busses/Makefile  |1 +
>  drivers/i2c/busses/i2c-cpm.c |  745 
> ++
>  3 files changed, 756 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/i2c/busses/i2c-cpm.c
> 
> Changes since last version:
> - change bus-frequency -> clock-frequency to comply to OF standard.
> 

Applied, thanks. And thanks a lot to Wolfram for the review :)

-- 
Jean Delvare
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCHv2] i2c: adds support for i2c bus on Freescale CPM1/CPM2 controllers

2008-05-21 Thread Jochen Friedrich
This driver uses the port of 2.4 code from Vitaly Bordug
<[EMAIL PROTECTED]> and the actual algorithm used by the i2c
driver of the DBox code on cvs.tuxboc.org from Felix Domke
([EMAIL PROTECTED]) and Gillem ([EMAIL PROTECTED]) converted to an
of_platform_driver. Tested on CPM1 (MPC823 on dbox2 hardware) and
CPM2 (MPC8272).

Signed-off-by: Jochen Friedrich <[EMAIL PROTECTED]>
---
 drivers/i2c/busses/Kconfig   |   10 +
 drivers/i2c/busses/Makefile  |1 +
 drivers/i2c/busses/i2c-cpm.c |  745 ++
 3 files changed, 756 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-cpm.c

Changes since last version:
- change bus-frequency -> clock-frequency to comply to OF standard.

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7112a50..4aeefa6 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -350,6 +350,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.

+config I2C_CPM
+   tristate "Freescale CPM1 or CPM2 (MPC8xx/826x)"
+   depends on (CPM1 || CPM2) && OF_I2C
+   help
+ This supports the use of the I2C interface on Freescale
+ processors with CPM1 or CPM2.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cpm.
+
 config I2C_DAVINCI
tristate "DaVinci I2C driver"
depends on ARCH_DAVINCI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 3c56bd9..bc6fc36 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_I2C_ACORN)   += i2c-acorn.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CPM)  += i2c-cpm.o
 obj-$(CONFIG_I2C_DAVINCI)  += i2c-davinci.o
 obj-$(CONFIG_I2C_ELEKTOR)  += i2c-elektor.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
new file mode 100644
index 000..2977dd0
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -0,0 +1,745 @@
+/*
+ * Freescale CPM1/CPM2 I2C interface.
+ * Copyright (c) 1999 Dan Malek ([EMAIL PROTECTED]).
+ *
+ * moved into proper i2c interface;
+ * Brad Parker ([EMAIL PROTECTED])
+ *
+ * Parts from dbox2_i2c.c (cvs.tuxbox.org)
+ * (C) 2000-2001 Felix Domke ([EMAIL PROTECTED]), Gillem ([EMAIL PROTECTED])
+ *
+ * (C) 2007 Montavista Software, Inc.
+ * Vitaly Bordug <[EMAIL PROTECTED]>
+ *
+ * Converted to of_platform_device. Renamed to i2c-cpm.c.
+ * (C) 2007,2008 Jochen Friedrich <[EMAIL PROTECTED]>
+ *
+ *  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
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Try to define this if you have an older CPU (earlier than rev D4) */
+/* However, better use a GPIO based bitbang driver in this case :/   */
+#undef I2C_CHIP_ERRATA
+
+#define CPM_MAX_READ513
+#define CPM_MAXBD   4
+
+#define I2C_EB (0x10) /* Big endian mode */
+#define I2C_EB_CPM2(0x30) /* Big endian mode, memory snoop */
+
+#define DPRAM_BASE ((u8 __iomem __force *)cpm_muram_addr(0))
+
+/* I2C parameter RAM. */
+struct i2c_ram {
+   ushort  rbase;  /* Rx Buffer descriptor base address */
+   ushort  tbase;  /* Tx Buffer descriptor base address */
+   u_char  rfcr;   /* Rx function code */
+   u_char  tfcr;   /* Tx function code */
+   ushort  mrblr;  /* Max receive buffer length */
+   uintrstate; /* Internal */
+   uintrdp;/* Internal */
+   ushort  rbptr;  /* Rx Buffer descriptor pointer */
+   ushort  rbc;/* Internal */
+   uintrxtmp;  /* Internal */
+   uinttstate; /* Internal */
+   uinttdp;/* Internal */
+   ushort  tbptr;  /* Tx Buffer descriptor pointer */
+   ushort  tbc;/* Internal */
+   uinttxtmp;  /* Internal */
+   charres1[4];/* Reserved */
+   ushort  rpb