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

2008-05-21 Thread Wolfram Sang
Hi Jochen,

On Wed, May 21, 2008 at 12:43:22PM +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]
 ---
Works on MPC8260.

Tested-by: Wolfram Sang [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:
 - fixed copy and paste bug (I2COM_MASTER - I2COM_START)
 - changed dev_err() to dev_dbg() for NACK
 - changed dev_dbg() to dev_err() for Timeout
 - added explanation for brg formular
Typo: formula

 - added bus-frequency OF attribute to be able to override i2c clock
\o/ Cool feature. Worked nicely.

 - support for numbered adapter (it was already documented in
   my booting-without-of patch but not yet implemented)
 - finally changed i2c pseudo address 0xfe to 0x7f  1
 - get rid of the fsl,cpm-i2c name. This logic was screwed
 - fixed the error patch for request_irq failure
path instead of patch? But well, I assume typos in this section do not
matter much anyhow as they are not imported into git. Am I right, Jean?

 - s/IIC/I2C/g
 - fixed error output read timeout - transfer timeout
 
 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
 index 48438cc..c627b94 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -117,6 +117,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 e8c882a..1ccd5ba 100644
 --- a/drivers/i2c/busses/Makefile
 +++ b/drivers/i2c/busses/Makefile
 @@ -11,6 +11,7 @@ obj-$(CONFIG_I2C_AMD8111)   += i2c-amd8111.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..305159c
 --- /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 linux/kernel.h
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/errno.h
 +#include linux/stddef.h
 +#include linux/i2c.h
 +#include linux/io.h
 +#include linux/dma-mapping.h
 +#include linux/of_device.h
 +#include linux/of_platform.h
 +#include linux/of_i2c.h
 +#include sysdev/fsl_soc.h
 +#include asm/cpm.h
 +
 +/* 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_READ

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

2008-05-21 Thread Jean Delvare
On Wed, 21 May 2008 16:33:07 +0200, Wolfram Sang wrote:
 Hi Jochen,
 
 On Wed, May 21, 2008 at 12:43:22PM +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]
  ---
 Works on MPC8260.
 
 Tested-by: Wolfram Sang [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:
  - fixed copy and paste bug (I2COM_MASTER - I2COM_START)
  - changed dev_err() to dev_dbg() for NACK
  - changed dev_dbg() to dev_err() for Timeout
  - added explanation for brg formular
 Typo: formula
 
  - added bus-frequency OF attribute to be able to override i2c clock
 \o/ Cool feature. Worked nicely.
 
  - support for numbered adapter (it was already documented in
my booting-without-of patch but not yet implemented)
  - finally changed i2c pseudo address 0xfe to 0x7f  1
  - get rid of the fsl,cpm-i2c name. This logic was screwed
  - fixed the error patch for request_irq failure

 path instead of patch? But well, I assume typos in this section do not
 matter much anyhow as they are not imported into git. Am I right, Jean?

Yes you are.

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


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

2008-05-20 Thread Boris Shteinbock
I am currently doing port for already working PQ2 board (MPC8270) from ppc to 
powerpc architecture.
When initial port took place, the driver i2c-cpm that appeared on linuxppc list 
in the beginning of 2006 was used,
and it is working perfectly all this time.

However, when I am trying to use  the driver in your patch, I encountered the 
following  problem :
Your driver loads and probes perfectly well, however any attempt to read 
anything from the bus times out.
Receive never takes place. To make things works, If a user-space program is 
interrupted by ctrl-c while waiting for data, the driver enters an endless 
loop, that effectively kills the kernel.
can you suggest any solution for this problem?

I, also, suggest  moving BRG setup values  to the device tree instead of 
hard-coding them into the driver.


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