All of lore.kernel.org
 help / color / mirror / Atom feed
* Howto read I2C on MPC5200 Lite
@ 2007-03-07 12:24 Matthias Fechner
  2007-03-07 21:17 ` John Rigby
  0 siblings, 1 reply; 19+ messages in thread
From: Matthias Fechner @ 2007-03-07 12:24 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

I started playing with I2C on my MPC5200 Lite board now.
For this a attached a MAX6633 to the I2C bus.
With u-boot I can read the chip so I think in hardware is everything ok.

Now I booted my board and loaded the module i2c-mpc and i2c-dev.
Create the devices with major number 89 and minor number 0 and 1.

I checked now for the kernel docu the file dev-interface.
They suggested to use i2c_smbus_read_word_data, but with this I was
not successfully.

So i tried to open the device and read with read from the device, but
no success.

Here is the final code i tried:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <linux/i2c.h>
#include <linux/i2c-dev.h>

int main(void)
{
   int file;
   int adapter_nr=0;
   char filename[20];
	    
   // open connection to device driver
   sprintf(filename,"/dev/i2c-%d",adapter_nr);
   if((file=open(filename,O_RDWR)) < 0)
   {
     printf("Cannot open i2c device\n");
     exit(1);
   }
	          
   // open connection to I2C device with address addr
   int addr=0x40;
   if(ioctl(file,I2C_SLAVE,addr) <0)
   {
     printf("Cannot access slave device\n");
     exit(1);
   }
	   
   // comunicate with the I2C device
   // device register to access
   __u8 memToRead = 0x0;
   __s32 res;
   char buf[10];
   if(read(file,buf,1) != 1)
   {
     printf("Cannot read from device\n");
   }else{
     printf("Got %s\n",buf[0]);
   }
   close(file);
   return 0;
}

But I always got Cannot read from device.

Can anyone help me here please?

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-07 12:24 Howto read I2C on MPC5200 Lite Matthias Fechner
@ 2007-03-07 21:17 ` John Rigby
  2007-03-09 11:35   ` Matthias Fechner
  0 siblings, 1 reply; 19+ messages in thread
From: John Rigby @ 2007-03-07 21:17 UTC (permalink / raw)
  To: linuxppc-embedded, Matthias Fechner

I use i2c-tools which once lived at http://secure.netroedge.com/~lm78/
it is to be a subset of lm_sensors www.lm-sensors.org.

You can get a copy of i2c-tools from:
http://www.bitshrine.org/gpp/i2c_tools-2jun05.tar.gz
and a patch
http://www.bitshrine.org/gpp/i2c-tools-device.patch

Once you compile it and have created the device nodes
you should be able to scan with i2cdetect <busnum>.

On a stock lite5200b the only thing that shows up is a serial
eeprom at address 0x50.

You can then use i2cdump <busnum> <addr> to dump the device
and i2cset <busnum> <addr> <offset> <value> to write to it.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-07 21:17 ` John Rigby
@ 2007-03-09 11:35   ` Matthias Fechner
  2007-03-09 17:11     ` John Rigby
  0 siblings, 1 reply; 19+ messages in thread
From: Matthias Fechner @ 2007-03-09 11:35 UTC (permalink / raw)
  To: linuxppc-embedded

Hello John,

* John Rigby <jrigby@freescale.com> [07-03-07 14:17]:
> On a stock lite5200b the only thing that shows up is a serial
> eeprom at address 0x50.

thx a lot, that tool helped me a lot.
I have written a very small c-program to access the I2C bus to read the
temperature of my MAX6633 and convert it to °C.

That worked fine, but after reading the value some time, the I2C bus
is dead. The kernel says:
i2c_adapter i2c-1: ioctl, cmd=0x705, arg=0x7feaf8ec
i2c_adapter i2c-1: ioctl, cmd=0x706, arg=0x40
i2c_adapter i2c-1: ioctl, cmd=0x720, arg=0x7feaf8f0
i2c_adapter i2c-1: master_xfer[0] W, addr=0x40, len=1
i2c_adapter i2c-1: master_xfer[1] R, addr=0x40, len=2
I2C: timeout

Is that maybe a bug in the I2C driver (i2c-mpc) or is my programm
faulty?
If it helps I can attach the programm.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-09 11:35   ` Matthias Fechner
@ 2007-03-09 17:11     ` John Rigby
  2007-03-09 23:42       ` Matthias Fechner
  0 siblings, 1 reply; 19+ messages in thread
From: John Rigby @ 2007-03-09 17:11 UTC (permalink / raw)
  To: linuxppc-embedded

The some 5200's have had a problem with
a missing clock pulse on scl.

The latest ppc tree plus Doman Puncer's i2c patch of a few
days ago
http://article.gmane.org/gmane.linux.ports.ppc.embedded/15718/match=3Di2c
should fix the problem if that is it.

On 3/9/07, Matthias Fechner <idefix@fechner.net> wrote:
> Hello John,
>
> * John Rigby <jrigby@freescale.com> [07-03-07 14:17]:
> > On a stock lite5200b the only thing that shows up is a serial
> > eeprom at address 0x50.
>
> thx a lot, that tool helped me a lot.
> I have written a very small c-program to access the I2C bus to read the
> temperature of my MAX6633 and convert it to =B0C.
>
> That worked fine, but after reading the value some time, the I2C bus
> is dead. The kernel says:
> i2c_adapter i2c-1: ioctl, cmd=3D0x705, arg=3D0x7feaf8ec
> i2c_adapter i2c-1: ioctl, cmd=3D0x706, arg=3D0x40
> i2c_adapter i2c-1: ioctl, cmd=3D0x720, arg=3D0x7feaf8f0
> i2c_adapter i2c-1: master_xfer[0] W, addr=3D0x40, len=3D1
> i2c_adapter i2c-1: master_xfer[1] R, addr=3D0x40, len=3D2
> I2C: timeout
>
> Is that maybe a bug in the I2C driver (i2c-mpc) or is my programm
> faulty?
> If it helps I can attach the programm.
>
> Best regards,
> Matthias
>
> --
>
> "Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs, and the universe trying to
> produce bigger and better idiots. So far, the universe is winning." --
> Rich Cook
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-09 17:11     ` John Rigby
@ 2007-03-09 23:42       ` Matthias Fechner
  2007-03-10  2:18         ` where and how to get the latest 2.6 kernel Nick Droogh
  2007-03-11  0:55         ` Howto read I2C on MPC5200 Lite Matthias Fechner
  0 siblings, 2 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-03-09 23:42 UTC (permalink / raw)
  To: linuxppc-embedded

Hello John,

* John Rigby <jcrigby@gmail.com> [09-03-07 10:11]:
> The some 5200's have had a problem with
> a missing clock pulse on scl.
> 
> The latest ppc tree plus Doman Puncer's i2c patch of a few
> days ago
> http://article.gmane.org/gmane.linux.ports.ppc.embedded/15718/match=i2c
> should fix the problem if that is it.

thx a lot for this tip.
I checked out the current git version of kernel 2.6, added Xenomai
patch and the i2c patch.
It seems now that everything works fine. I will check it for the next
days. And will give some feedback.

Thx a lot!

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* where and how to get the latest 2.6 kernel
  2007-03-09 23:42       ` Matthias Fechner
@ 2007-03-10  2:18         ` Nick Droogh
  2007-03-11  1:01           ` Matthias Fechner
  2007-03-11  0:55         ` Howto read I2C on MPC5200 Lite Matthias Fechner
  1 sibling, 1 reply; 19+ messages in thread
From: Nick Droogh @ 2007-03-10  2:18 UTC (permalink / raw)
  To: linuxppc-embedded

I have a mpc5200b based board and I would like to upgrade to the 2.6 
kernel from 2.4.  Is there a document explaining where to get the 
latests git version, and where to find the xenomai patch?

Thanks
Nick

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-09 23:42       ` Matthias Fechner
  2007-03-10  2:18         ` where and how to get the latest 2.6 kernel Nick Droogh
@ 2007-03-11  0:55         ` Matthias Fechner
  2007-03-15  9:57           ` Domen Puncer
  1 sibling, 1 reply; 19+ messages in thread
From: Matthias Fechner @ 2007-03-11  0:55 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

Hi,

* Matthias Fechner <idefix@fechner.net> [10-03-07 00:42]:
> It seems now that everything works fine. I will check it for the next
> days. And will give some feedback.

ok, I checked now the driver some time at it failed. So it seems that
that the patch had not solved the problem.

I have attached the programm to check it.

I changed the time to 2 seconds but that didn't help.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

[-- Attachment #2: readMax6633.c --]
[-- Type: text/x-csrc, Size: 2176 bytes --]

/* read the data from max6633 */

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "i2c-dev.h"
#include "version.h"

static __inline__ unsigned short swap_bytes(unsigned short val)
{
   return(val >> 8) | (val << 8);
}

int main(void)
{
   int res,address,file;
   char filename[20];
   unsigned short temp;
   long funcs;
   int i2cbus;
   int errorCount,successfullCount;
   errorCount=successfullCount=0;
   i2cbus=1;
   address=0x40;
   
   sprintf(filename,"/dev/i2c-%d",i2cbus);
   if((file=open(filename,O_RDWR))<0)
   {
      fprintf(stderr,"Error: could not open file %s: %s\n",filename,strerror(errno));
      exit(1);
   }
   
   /* check adapter functionality */
   if(ioctl(file,I2C_FUNCS,&funcs) < 0)
   {
      fprintf(stderr, "Error: could not get the adapter functionality matrix: %s\n",strerror(errno));
      goto ERROR0;
   }
   if(!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA))
   {
      fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
      fprintf(stderr," does not have byte read capability\n");
      goto ERROR0;
   }
   if(!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA))
   {
      fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
      fprintf(stderr," does not have word read capability\n");
      goto ERROR0;
   }
      
   
   /* use FORCE so that we can look at registers even when a driver
      is also running */
   if(ioctl(file,I2C_SLAVE,address) <0)
   {
      fprintf(stderr,"Error: Could not set address to %d: %s\n",address, strerror(errno));
      goto ERROR0;
   }
   
   fprintf(stderr,"Read with word_data\n");
   while(1)
   {
      
      temp=res=i2c_smbus_read_word_data(file,0);
      if(res<0)
      {
	 fprintf(stderr,"Error: Could not read the value from the i2c device\n");
	 errorCount++;
      }else
      {
	 successfullCount++;
      }
      
      temp=swap_bytes(temp);
      temp=temp >> 3;
      
      printf("Succes: %i, Errorcount: %i, Temp: %f\n",successfullCount,errorCount,(float)(temp*0.0625));
      sleep(1);
   }
   
   printf("\nCalculate temp\n");
  
   close(file);
   exit(0);

  ERROR0:
   close(file);
   exit(1);
}


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: where and how to get the latest 2.6 kernel
  2007-03-10  2:18         ` where and how to get the latest 2.6 kernel Nick Droogh
@ 2007-03-11  1:01           ` Matthias Fechner
  0 siblings, 0 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-03-11  1:01 UTC (permalink / raw)
  To: linuxppc-embedded

Hello Nick,

* Nick Droogh <ndroogh@rogers.com> [09-03-07 21:18]:
> I have a mpc5200b based board and I would like to upgrade to the 2.6 
> kernel from 2.4.  Is there a document explaining where to get the 
> latests git version, and where to find the xenomai patch?

I used the git version from denx.de.
To get the Xenomai patch into the kernel I have to edit one file
manually but it was quit easy.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-11  0:55         ` Howto read I2C on MPC5200 Lite Matthias Fechner
@ 2007-03-15  9:57           ` Domen Puncer
  2007-03-16  4:33             ` Matthias Fechner
  2007-03-17  8:57             ` Matthias Fechner
  0 siblings, 2 replies; 19+ messages in thread
From: Domen Puncer @ 2007-03-15  9:57 UTC (permalink / raw)
  To: linuxppc-embedded

On 11/03/07 01:55 +0100, Matthias Fechner wrote:
> Hi,
> 
> * Matthias Fechner <idefix@fechner.net> [10-03-07 00:42]:
> > It seems now that everything works fine. I will check it for the next
> > days. And will give some feedback.
> 
> ok, I checked now the driver some time at it failed. So it seems that
> that the patch had not solved the problem.
> 
> I have attached the programm to check it.

But not for built-in eeprom :-P
Anyway, I managed to reproduce some problems, and hopefully "fix" them.
One problem seems to be fixed by disabling i2c on stop,
another looks like it's:
http://ozlabs.org/pipermail/linuxppc-embedded/2005-July/019038.html

Can you please try following patch.


	Domen


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ee65aa1..522f485 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -75,6 +75,20 @@ static irqreturn_t mpc_i2c_isr(int irq, 
 	return IRQ_HANDLED;
 }
 
+static void mpc_i2c_fixup(struct mpc_i2c *i2c)
+{
+	writeccr(i2c, 0);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+}
+
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
 	unsigned long orig_jiffies = jiffies;
@@ -154,6 +168,9 @@ static void mpc_i2c_start(struct mpc_i2c
 static void mpc_i2c_stop(struct mpc_i2c *i2c)
 {
 	writeccr(i2c, CCR_MEN);
+	mb();
+	writeccr(i2c, 0);
+	mb();
 }
 
 static int mpc_write(struct mpc_i2c *i2c, int target,
@@ -246,6 +263,8 @@ static int mpc_xfer(struct i2c_adapter *
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {
 			pr_debug("I2C: timeout\n");
+			if (readb(i2c->base + MPC_I2C_SR) == (CSR_MCF | CSR_MBB | CSR_RXAK))
+				mpc_i2c_fixup(i2c);
 			return -EIO;
 		}
 		schedule();

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-15  9:57           ` Domen Puncer
@ 2007-03-16  4:33             ` Matthias Fechner
  2007-03-17  8:57             ` Matthias Fechner
  1 sibling, 0 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-03-16  4:33 UTC (permalink / raw)
  To: linuxppc-embedded

Hello Domen,

* Domen Puncer <domen.puncer@telargo.com> [15-03-07 10:57]:
> Can you please try following patch.

ok, I patched the kernel now and was able to read the ic2 chip 100
times successfully. I will run the programm the next 20 hours and give
then a shot feedback.
But the first impression is good.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-15  9:57           ` Domen Puncer
  2007-03-16  4:33             ` Matthias Fechner
@ 2007-03-17  8:57             ` Matthias Fechner
  2007-03-18 19:06               ` Charles Krinke
  2007-03-21  8:34               ` Howto read I2C on MPC5200 Lite Matthias Fechner
  1 sibling, 2 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-03-17  8:57 UTC (permalink / raw)
  To: linuxppc-embedded

Hello Domen,

* Domen Puncer <domen.puncer@telargo.com> [15-03-07 10:57]:
> Anyway, I managed to reproduce some problems, and hopefully "fix" them.
> One problem seems to be fixed by disabling i2c on stop,
> another looks like it's:
> http://ozlabs.org/pipermail/linuxppc-embedded/2005-July/019038.html

ok, I can confirm that this patch fixes the problem for me too.
I was now able to read my I2C sensor 97388 successfully and only 2814
readfailures happened.
That means an errorrate of 2.8% that is ok for me.

Thx a lot for your great work!

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: Howto read I2C on MPC5200 Lite
  2007-03-17  8:57             ` Matthias Fechner
@ 2007-03-18 19:06               ` Charles Krinke
  2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
                                   ` (2 more replies)
  2007-03-21  8:34               ` Howto read I2C on MPC5200 Lite Matthias Fechner
  1 sibling, 3 replies; 19+ messages in thread
From: Charles Krinke @ 2007-03-18 19:06 UTC (permalink / raw)
  To: linuxppc-embedded, linuxppc-embedded

I have an embedded system with a PPC8541 using remote debugging across =
the serial port. I am using Fedora Core 6 on my host along with gdb 6.3 =
cross compiled for the ppc target and Linux 2.6.17.11 on the PPC8541 =
target.
=20
I can stop the kernel boot with 'kgdbwait' on the command line, startup =
gdb or ddd/gdb and set a breakpoint on do_fork which triggers reliably.
=20
>From there, I can delete that breakpoint, set a breakpoint further along =
in do_fork or continue using ddd to a location further along, but I =
cannot execute 'step'.
=20
When I execute a cont from either the gdb window or the ddd window, I do =
see the message:
=20
"Can't send signals to this remote system. SIGILL not sent.
=20
This problem occurs with or without ddd running the inferior debugger, =
so I suspect it is a gdb/target issue and not necessarily a ddd issue.
=20
Mostly, I am trying to understand what is going on.
=20
Charles

=20

^ permalink raw reply	[flat|nested] 19+ messages in thread

* gdb question regarding step vs breakpoint
  2007-03-18 19:06               ` Charles Krinke
@ 2007-03-18 19:11                 ` Charles Krinke
  2007-03-18 23:28                   ` Matthias Fechner
  2007-03-19  0:14                 ` Howto read I2C on MPC5200 Lite Wolfgang Denk
  2007-03-19  1:11                 ` A question regarding step and breakpoints Charles Krinke
  2 siblings, 1 reply; 19+ messages in thread
From: Charles Krinke @ 2007-03-18 19:11 UTC (permalink / raw)
  To: linuxppc-embedded

My apologies for not changing the subject in my gdb email.
=20
Charles

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: gdb question regarding step vs breakpoint
  2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
@ 2007-03-18 23:28                   ` Matthias Fechner
  0 siblings, 0 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-03-18 23:28 UTC (permalink / raw)
  To: linuxppc-embedded

Hello Charles,

* Charles Krinke <ckrinke@istor.com> [18-03-07 12:11]:
> My apologies for not changing the subject in my gdb email.

and you should start a new threat and not answering to an existing one.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-18 19:06               ` Charles Krinke
  2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
@ 2007-03-19  0:14                 ` Wolfgang Denk
  2007-03-19  1:11                 ` A question regarding step and breakpoints Charles Krinke
  2 siblings, 0 replies; 19+ messages in thread
From: Wolfgang Denk @ 2007-03-19  0:14 UTC (permalink / raw)
  To: Charles Krinke; +Cc: linuxppc-embedded

In message <9F3F0A752CAEBE4FA7E906CC2FBFF57C069B4B@MERCURY.inside.istor.com> you wrote:
> I have an embedded system with a PPC8541 using remote debugging across the serial port. I am using Fedora Core 6 on my host along with gdb 6.3 cross compiled for the ppc target and Linux 2.6.17.11 on the PPC8541 target.

And what has this to do with "Howto read I2C on MPC5200 Lite" ???


Wolfgang Denk

-- 
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"Probably the best operating system in the world  is  the  [operating
system] made for the PDP-11 by Bell Laboratories."
                                           - Ted Nelson, October 1977

^ permalink raw reply	[flat|nested] 19+ messages in thread

* A question regarding step and breakpoints
  2007-03-18 19:06               ` Charles Krinke
  2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
  2007-03-19  0:14                 ` Howto read I2C on MPC5200 Lite Wolfgang Denk
@ 2007-03-19  1:11                 ` Charles Krinke
  2 siblings, 0 replies; 19+ messages in thread
From: Charles Krinke @ 2007-03-19  1:11 UTC (permalink / raw)
  To: linuxppc-embedded

Gentlemen:

I have an embedded system with a PPC8541 using remote debugging across =
the serial port. I am using Fedora Core 6 on my host along with gdb 6.3 =
cross compiled for the ppc target and Linux 2.6.17.11 on the PPC8541 =
target.

I can stop the kernel boot with 'kgdbwait' on the command line, startup =
gdb or ddd/gdb and set a breakpoint on do_fork which triggers reliably.

>From there, I can delete that breakpoint, set a breakpoint further along =
in do_fork or continue using ddd to a location further along, but I =
cannot execute 'step'.

When I execute a continue from either the gdb window or the ddd window, =
I do see the message:

"Can't send signals to this remote system. SIGILL not sent.

Even with this message, I can still breakpoint, just not step.

Some insight would be appreciated.

Charles

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-17  8:57             ` Matthias Fechner
  2007-03-18 19:06               ` Charles Krinke
@ 2007-03-21  8:34               ` Matthias Fechner
  2007-04-04  8:49                 ` Domen Puncer
  1 sibling, 1 reply; 19+ messages in thread
From: Matthias Fechner @ 2007-03-21  8:34 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

* Matthias Fechner <idefix@fechner.net> [17-03-07 09:57]:
> ok, I can confirm that this patch fixes the problem for me too.
> I was now able to read my I2C sensor 97388 successfully and only 2814
> readfailures happened.
> That means an errorrate of 2.8% that is ok for me.

I found now when it happens or better when it not happens.

I boot my icecube board via NFS. If the board is up and I unplug the
network I get no read errors.
If the network is connected (NFS server responding) I got read errors
on I2C with a rate of approximatly 3-4%.
Seems to be a problem with the network driver.

Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-03-21  8:34               ` Howto read I2C on MPC5200 Lite Matthias Fechner
@ 2007-04-04  8:49                 ` Domen Puncer
  2007-04-25 18:48                   ` Matthias Fechner
  0 siblings, 1 reply; 19+ messages in thread
From: Domen Puncer @ 2007-04-04  8:49 UTC (permalink / raw)
  To: linuxppc-embedded

On 21/03/07 09:34 +0100, Matthias Fechner wrote:
> Hi,
> 
> * Matthias Fechner <idefix@fechner.net> [17-03-07 09:57]:
> > ok, I can confirm that this patch fixes the problem for me too.
> > I was now able to read my I2C sensor 97388 successfully and only 2814
> > readfailures happened.
> > That means an errorrate of 2.8% that is ok for me.
> 
> I found now when it happens or better when it not happens.
> 
> I boot my icecube board via NFS. If the board is up and I unplug the
> network I get no read errors.
> If the network is connected (NFS server responding) I got read errors
> on I2C with a rate of approximatly 3-4%.
> Seems to be a problem with the network driver.

I can't reproduce your no-errors behaviour. I tried unplugging network
cable and compiling out the fec driver.


	Domen

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Howto read I2C on MPC5200 Lite
  2007-04-04  8:49                 ` Domen Puncer
@ 2007-04-25 18:48                   ` Matthias Fechner
  0 siblings, 0 replies; 19+ messages in thread
From: Matthias Fechner @ 2007-04-25 18:48 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]

Hi Domen,

Domen Puncer wrote:
> I can't reproduce your no-errors behaviour. I tried unplugging network
> cable and compiling out the fec driver.

i did the last weeks some tests and it seems that the "problem" persists.
I boot my system like descripted below and I have an error rate of about
5%. If I reboot my system, start start the program and then unplug the
networkcable the error rate is much lower.

This is my configuration:
Board MPC5200 Lite5200 Evaluation board (not version b)
U-Boot 1.2.0-gfdd1d6dc (Mar  6 2007 - 12:52:10)

Kernel is loaded via tftp and the complete filesystem is mounted via NFS.
Crosscompile/basesystem is ELDK 4.1.

You can see exactly what I did under:
http://wiki.idefix.fechner.net/index.php/IceCube

Kernel is Linux-2.6.21-mpc52xx-g7e5e3d6f-d with some patches from the
mailinglist (I2C patches and powermanagement patches you submitted on
the ML) and Xenomai support.

I attach my kernel config and a small program with which i read my Maxim
6633 temperatur sensor you can order it as sample on the maxim website.

Maybe something is wrong with the program or it is a problem with the
MPC5200 which is fixed with the 5200b.

Thx a lot
Matthias

[-- Attachment #2: config --]
[-- Type: text/plain, Size: 23245 bytes --]

#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.21-rc2
# Wed Mar 21 21:18:10 2007
#
CONFIG_MMU=y
CONFIG_GENERIC_HARDIRQS=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_ARCH_HAS_ILOG2_U32=y
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_PPC=y
CONFIG_PPC32=y
CONFIG_GENERIC_NVRAM=y
CONFIG_GENERIC_FIND_NEXT_BIT=y
CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_GENERIC_BUG=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32

#
# General setup
#
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
# CONFIG_IPC_NS is not set
CONFIG_SYSVIPC_SYSCTL=y
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_BSD_PROCESS_ACCT is not set
# CONFIG_TASKSTATS is not set
# CONFIG_UTS_NS is not set
# CONFIG_AUDIT is not set
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_SYSFS_DEPRECATED=y
# CONFIG_RELAY is not set
CONFIG_INITRAMFS_SOURCE=""
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y
# CONFIG_EMBEDDED is not set
CONFIG_SYSCTL_SYSCALL=y
CONFIG_KALLSYMS=y
# CONFIG_KALLSYMS_ALL is not set
# CONFIG_KALLSYMS_EXTRA_PASS is not set
CONFIG_HOTPLUG=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SHMEM=y
CONFIG_SLAB=y
CONFIG_VM_EVENT_COUNTERS=y
CONFIG_RT_MUTEXES=y
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0
# CONFIG_SLOB is not set

#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
CONFIG_MODVERSIONS=y
# CONFIG_MODULE_SRCVERSION_ALL is not set
CONFIG_KMOD=y

#
# Block layer
#
CONFIG_BLOCK=y
# CONFIG_LBD is not set
# CONFIG_BLK_DEV_IO_TRACE is not set
# CONFIG_LSF is not set

#
# IO Schedulers
#
CONFIG_IOSCHED_NOOP=y
CONFIG_IOSCHED_AS=y
CONFIG_IOSCHED_DEADLINE=y
CONFIG_IOSCHED_CFQ=y
# CONFIG_DEFAULT_AS is not set
# CONFIG_DEFAULT_DEADLINE is not set
CONFIG_DEFAULT_CFQ=y
# CONFIG_DEFAULT_NOOP is not set
CONFIG_DEFAULT_IOSCHED="cfq"

#
# Real-time sub-system
#
CONFIG_XENOMAI=y
CONFIG_XENO_OPT_NUCLEUS=y
CONFIG_XENO_OPT_PERVASIVE=y
# CONFIG_XENO_OPT_ISHIELD is not set
CONFIG_XENO_OPT_PRIOCPL=y
CONFIG_XENO_OPT_SECURITY_ACCESS=y
CONFIG_XENO_OPT_PIPELINE_HEAD=y
CONFIG_XENO_OPT_PIPE=y
CONFIG_XENO_OPT_PIPE_NRDEV=32
CONFIG_XENO_OPT_REGISTRY=y
CONFIG_XENO_OPT_REGISTRY_NRSLOTS=512
CONFIG_XENO_OPT_SYS_HEAPSZ=128
CONFIG_XENO_OPT_STATS=y
# CONFIG_XENO_OPT_DEBUG is not set

#
# Timing
#
# CONFIG_XENO_OPT_TIMING_PERIODIC is not set
CONFIG_XENO_OPT_TIMING_TIMERLAT=0
CONFIG_XENO_OPT_TIMING_SCHEDLAT=0

#
# Scalability
#
# CONFIG_XENO_OPT_SCALABLE_SCHED is not set
CONFIG_XENO_OPT_TIMER_LIST=y
# CONFIG_XENO_OPT_TIMER_HEAP is not set
# CONFIG_XENO_OPT_TIMER_WHEEL is not set

#
# Shared interrupts
#
# CONFIG_XENO_OPT_SHIRQ_LEVEL is not set
# CONFIG_XENO_OPT_SHIRQ_EDGE is not set

#
# Machine
#
CONFIG_XENO_HW_FPU=y

#
# Interfaces
#
CONFIG_XENO_SKIN_NATIVE=y
CONFIG_XENO_OPT_NATIVE_PERIOD=0
CONFIG_XENO_OPT_NATIVE_PIPE=y
CONFIG_XENO_OPT_NATIVE_PIPE_BUFSZ=4096
CONFIG_XENO_OPT_NATIVE_REGISTRY=y
CONFIG_XENO_OPT_NATIVE_SEM=y
CONFIG_XENO_OPT_NATIVE_EVENT=y
CONFIG_XENO_OPT_NATIVE_MUTEX=y
CONFIG_XENO_OPT_NATIVE_COND=y
CONFIG_XENO_OPT_NATIVE_QUEUE=y
CONFIG_XENO_OPT_NATIVE_HEAP=y
CONFIG_XENO_OPT_NATIVE_ALARM=y
CONFIG_XENO_OPT_NATIVE_MPS=y
# CONFIG_XENO_OPT_NATIVE_INTR is not set
CONFIG_XENO_SKIN_POSIX=y
CONFIG_XENO_OPT_POSIX_PERIOD=0
# CONFIG_XENO_OPT_POSIX_SHM is not set
# CONFIG_XENO_OPT_POSIX_INTR is not set
CONFIG_XENO_OPT_DEBUG_POSIX=y
# CONFIG_XENO_SKIN_PSOS is not set
# CONFIG_XENO_SKIN_UITRON is not set
# CONFIG_XENO_SKIN_VRTX is not set
# CONFIG_XENO_SKIN_VXWORKS is not set
# CONFIG_XENO_SKIN_RTAI is not set
CONFIG_XENO_SKIN_RTDM=y
CONFIG_XENO_OPT_RTDM_PERIOD=0
CONFIG_XENO_OPT_RTDM_FILDES=128

#
# Drivers
#

#
# Serial drivers
#
# CONFIG_XENO_DRIVERS_16550A is not set

#
# Testing drivers
#
CONFIG_XENO_DRIVERS_TIMERBENCH=m
CONFIG_XENO_DRIVERS_IRQBENCH=m
CONFIG_XENO_DRIVERS_SWITCHTEST=m

#
# CAN drivers
#
# CONFIG_XENO_DRIVERS_CAN is not set

#
# Processor
#
CONFIG_6xx=y
# CONFIG_40x is not set
# CONFIG_44x is not set
# CONFIG_8xx is not set
# CONFIG_E200 is not set
# CONFIG_E500 is not set
CONFIG_PPC_FPU=y
# CONFIG_PPC_DCR_NATIVE is not set
# CONFIG_ALTIVEC is not set
# CONFIG_TAU is not set
# CONFIG_KEXEC is not set
# CONFIG_CPU_FREQ is not set
# CONFIG_WANT_EARLY_SERIAL is not set
CONFIG_PPC_STD_MMU=y

#
# Platform options
#
# CONFIG_PPC_PREP is not set
# CONFIG_APUS is not set
# CONFIG_KATANA is not set
# CONFIG_WILLOW is not set
# CONFIG_CPCI690 is not set
# CONFIG_POWERPMC250 is not set
# CONFIG_CHESTNUT is not set
# CONFIG_SPRUCE is not set
# CONFIG_HDPU is not set
# CONFIG_EV64260 is not set
# CONFIG_LOPEC is not set
# CONFIG_MVME5100 is not set
# CONFIG_PPLUS is not set
# CONFIG_PRPMC750 is not set
# CONFIG_PRPMC800 is not set
# CONFIG_SANDPOINT is not set
# CONFIG_RADSTONE_PPC7D is not set
# CONFIG_PAL4 is not set
# CONFIG_EST8260 is not set
# CONFIG_SBC82xx is not set
# CONFIG_SBS8260 is not set
# CONFIG_RPX8260 is not set
# CONFIG_TQM8260 is not set
# CONFIG_PM82X is not set
# CONFIG_ADS8272 is not set
# CONFIG_PQ2FADS is not set
CONFIG_LITE5200=y
# CONFIG_LITE5200B is not set
# CONFIG_MPC834x_SYS is not set
# CONFIG_EV64360 is not set
# CONFIG_P3M750 is not set
# CONFIG_TQM834x is not set
# CONFIG_TQM8272 is not set
CONFIG_PPC_MPC52xx=y
CONFIG_PPC_BESTCOMM=y
# CONFIG_SMP is not set
CONFIG_IPIPE=y
# CONFIG_HIGHMEM is not set
CONFIG_ARCH_POPULATES_NODE_MAP=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y
# CONFIG_HZ_300 is not set
# CONFIG_HZ_1000 is not set
CONFIG_HZ=250
CONFIG_PREEMPT_NONE=y
# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT is not set
CONFIG_SELECT_MEMORY_MODEL=y
CONFIG_FLATMEM_MANUAL=y
# CONFIG_DISCONTIGMEM_MANUAL is not set
# CONFIG_SPARSEMEM_MANUAL is not set
CONFIG_FLATMEM=y
CONFIG_FLAT_NODE_MEM_MAP=y
# CONFIG_SPARSEMEM_STATIC is not set
CONFIG_SPLIT_PTLOCK_CPUS=4
# CONFIG_RESOURCES_64BIT is not set
CONFIG_ZONE_DMA_FLAG=1
CONFIG_BINFMT_ELF=y
# CONFIG_BINFMT_MISC is not set
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="console=ttyS0 root=/dev/ram0 rw"
CONFIG_PM=y
CONFIG_PM_LEGACY=y
# CONFIG_PM_DEBUG is not set
# CONFIG_PM_SYSFS_DEPRECATED is not set
# CONFIG_SOFTWARE_SUSPEND is not set
CONFIG_SECCOMP=y
CONFIG_ISA_DMA_API=y

#
# Bus options
#
CONFIG_ZONE_DMA=y
CONFIG_GENERIC_ISA_DMA=y
# CONFIG_PPC_I8259 is not set
# CONFIG_PPC_INDIRECT_PCI is not set
CONFIG_PCI=y
CONFIG_PCI_DOMAINS=y
# CONFIG_PCI_DEBUG is not set

#
# PCCARD (PCMCIA/CardBus) support
#
# CONFIG_PCCARD is not set

#
# PCI Express support
#

#
# Advanced setup
#
CONFIG_ADVANCED_OPTIONS=y
CONFIG_HIGHMEM_START=0xfe000000
# CONFIG_LOWMEM_SIZE_BOOL is not set
CONFIG_LOWMEM_SIZE=0x30000000
# CONFIG_KERNEL_START_BOOL is not set
CONFIG_KERNEL_START=0xc0000000
# CONFIG_TASK_SIZE_BOOL is not set
CONFIG_TASK_SIZE=0x80000000
# CONFIG_BOOT_LOAD_BOOL is not set
CONFIG_BOOT_LOAD=0x00800000

#
# Networking
#
CONFIG_NET=y

#
# Networking options
#
# CONFIG_NETDEBUG is not set
CONFIG_PACKET=y
# CONFIG_PACKET_MMAP is not set
CONFIG_UNIX=y
CONFIG_XFRM=y
# CONFIG_XFRM_USER is not set
# CONFIG_XFRM_SUB_POLICY is not set
# CONFIG_XFRM_MIGRATE is not set
# CONFIG_NET_KEY is not set
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
CONFIG_IP_FIB_HASH=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
# CONFIG_NET_IPIP is not set
# CONFIG_NET_IPGRE is not set
# CONFIG_ARPD is not set
# CONFIG_SYN_COOKIES is not set
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_INET_IPCOMP is not set
# CONFIG_INET_XFRM_TUNNEL is not set
# CONFIG_INET_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
CONFIG_INET_XFRM_MODE_BEET=y
CONFIG_INET_DIAG=y
CONFIG_INET_TCP_DIAG=y
# CONFIG_TCP_CONG_ADVANCED is not set
CONFIG_TCP_CONG_CUBIC=y
CONFIG_DEFAULT_TCP_CONG="cubic"
# CONFIG_TCP_MD5SIG is not set
# CONFIG_IPV6 is not set
# CONFIG_INET6_XFRM_TUNNEL is not set
# CONFIG_INET6_TUNNEL is not set
# CONFIG_NETWORK_SECMARK is not set
# CONFIG_NETFILTER is not set

#
# DCCP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_DCCP is not set

#
# SCTP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_SCTP is not set

#
# TIPC Configuration (EXPERIMENTAL)
#
# CONFIG_TIPC is not set
# CONFIG_ATM is not set
# CONFIG_BRIDGE is not set
# CONFIG_VLAN_8021Q is not set
# CONFIG_DECNET is not set
# CONFIG_LLC2 is not set
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
# CONFIG_X25 is not set
# CONFIG_LAPB is not set
# CONFIG_ECONET is not set
# CONFIG_WAN_ROUTER is not set

#
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set

#
# Network testing
#
# CONFIG_NET_PKTGEN is not set
# CONFIG_HAMRADIO is not set
# CONFIG_IRDA is not set
# CONFIG_BT is not set
# CONFIG_IEEE80211 is not set

#
# Device Drivers
#

#
# Generic Driver Options
#
CONFIG_STANDALONE=y
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
# CONFIG_FW_LOADER is not set
# CONFIG_DEBUG_DRIVER is not set
# CONFIG_DEBUG_DEVRES is not set
# CONFIG_SYS_HYPERVISOR is not set

#
# Connector - unified userspace <-> kernelspace linker
#
# CONFIG_CONNECTOR is not set

#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set

#
# Plug and Play support
#
# CONFIG_PNPACPI is not set

#
# Block devices
#
# CONFIG_BLK_DEV_FD is not set
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_BLK_DEV_DAC960 is not set
# CONFIG_BLK_DEV_UMEM is not set
# CONFIG_BLK_DEV_COW_COMMON is not set
CONFIG_BLK_DEV_LOOP=m
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
# CONFIG_BLK_DEV_NBD is not set
# CONFIG_BLK_DEV_SX8 is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
CONFIG_BLK_DEV_INITRD=y
# CONFIG_CDROM_PKTCDVD is not set
# CONFIG_ATA_OVER_ETH is not set

#
# Misc devices
#
# CONFIG_SGI_IOC4 is not set
# CONFIG_TIFM_CORE is not set

#
# ATA/ATAPI/MFM/RLL support
#
# CONFIG_IDE is not set

#
# SCSI device support
#
# CONFIG_RAID_ATTRS is not set
# CONFIG_SCSI is not set
# CONFIG_SCSI_NETLINK is not set

#
# Serial ATA (prod) and Parallel ATA (experimental) drivers
#
# CONFIG_ATA is not set

#
# Multi-device support (RAID and LVM)
#
# CONFIG_MD is not set

#
# Fusion MPT device support
#
# CONFIG_FUSION is not set

#
# IEEE 1394 (FireWire) support
#
# CONFIG_IEEE1394 is not set

#
# I2O device support
#
# CONFIG_I2O is not set

#
# Macintosh device drivers
#
# CONFIG_MAC_EMUMOUSEBTN is not set
# CONFIG_WINDFARM is not set

#
# Network device support
#
CONFIG_NETDEVICES=y
# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set

#
# ARCnet devices
#
# CONFIG_ARCNET is not set

#
# PHY device support
#
# CONFIG_PHYLIB is not set

#
# Ethernet (10 or 100Mbit)
#
CONFIG_NET_ETHERNET=y
CONFIG_MII=y
# CONFIG_HAPPYMEAL is not set
# CONFIG_SUNGEM is not set
# CONFIG_CASSINI is not set
# CONFIG_NET_VENDOR_3COM is not set

#
# Tulip family network device support
#
# CONFIG_NET_TULIP is not set
# CONFIG_HP100 is not set
# CONFIG_NET_PCI is not set

#
# MPC5200 Networking Options
#
CONFIG_FEC_MPC52xx=y
CONFIG_USE_MDIO=y

#
# Ethernet (1000 Mbit)
#
# CONFIG_ACENIC is not set
# CONFIG_DL2K is not set
# CONFIG_E1000 is not set
# CONFIG_NS83820 is not set
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
# CONFIG_R8169 is not set
# CONFIG_SIS190 is not set
# CONFIG_SKGE is not set
# CONFIG_SKY2 is not set
# CONFIG_SK98LIN is not set
# CONFIG_TIGON3 is not set
# CONFIG_BNX2 is not set
# CONFIG_QLA3XXX is not set
# CONFIG_ATL1 is not set

#
# Ethernet (10000 Mbit)
#
# CONFIG_CHELSIO_T1 is not set
# CONFIG_CHELSIO_T3 is not set
# CONFIG_IXGB is not set
# CONFIG_S2IO is not set
# CONFIG_MYRI10GE is not set
# CONFIG_NETXEN_NIC is not set

#
# Token Ring devices
#
# CONFIG_TR is not set

#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set

#
# Wan interfaces
#
# CONFIG_WAN is not set
# CONFIG_FDDI is not set
# CONFIG_HIPPI is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set
# CONFIG_SHAPER is not set
# CONFIG_NETCONSOLE is not set
# CONFIG_NETPOLL is not set
# CONFIG_NET_POLL_CONTROLLER is not set

#
# ISDN subsystem
#
# CONFIG_ISDN is not set

#
# Telephony Support
#
# CONFIG_PHONE is not set

#
# Input device support
#
CONFIG_INPUT=y
# CONFIG_INPUT_FF_MEMLESS is not set

#
# Userland interfaces
#
CONFIG_INPUT_MOUSEDEV=y
CONFIG_INPUT_MOUSEDEV_PSAUX=y
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
# CONFIG_INPUT_JOYDEV is not set
# CONFIG_INPUT_TSDEV is not set
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_EVBUG=y

#
# Input Device Drivers
#
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_JOYSTICK is not set
# CONFIG_INPUT_TOUCHSCREEN is not set
# CONFIG_INPUT_MISC is not set

#
# Hardware I/O ports
#
CONFIG_SERIO=y
# CONFIG_SERIO_I8042 is not set
CONFIG_SERIO_SERPORT=y
# CONFIG_SERIO_PCIPS2 is not set
# CONFIG_SERIO_RAW is not set
# CONFIG_GAMEPORT is not set

#
# Character devices
#
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_HW_CONSOLE=y
# CONFIG_VT_HW_CONSOLE_BINDING is not set
# CONFIG_SERIAL_NONSTANDARD is not set

#
# Serial drivers
#
# CONFIG_SERIAL_8250 is not set

#
# Non-8250 serial port support
#
# CONFIG_SERIAL_UARTLITE is not set
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_SERIAL_MPC52xx=y
CONFIG_SERIAL_MPC52xx_CONSOLE=y
CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=9600
# CONFIG_SERIAL_JSM is not set
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256

#
# IPMI
#
# CONFIG_IPMI_HANDLER is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
CONFIG_HW_RANDOM=y
# CONFIG_NVRAM is not set
# CONFIG_GEN_RTC is not set
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set
# CONFIG_AGP is not set
# CONFIG_DRM is not set
# CONFIG_RAW_DRIVER is not set

#
# TPM devices
#
# CONFIG_TCG_TPM is not set

#
# I2C support
#
CONFIG_I2C=m
CONFIG_I2C_CHARDEV=m

#
# I2C Algorithms
#
CONFIG_I2C_ALGOBIT=m
CONFIG_I2C_ALGOPCF=m
CONFIG_I2C_ALGOPCA=m

#
# I2C Hardware Bus support
#
# CONFIG_I2C_ALI1535 is not set
# CONFIG_I2C_ALI1563 is not set
# CONFIG_I2C_ALI15X3 is not set
# CONFIG_I2C_AMD756 is not set
# CONFIG_I2C_AMD8111 is not set
# CONFIG_I2C_I801 is not set
# CONFIG_I2C_I810 is not set
# CONFIG_I2C_PIIX4 is not set
CONFIG_I2C_MPC=m
# CONFIG_I2C_MPC8260 is not set
# CONFIG_I2C_NFORCE2 is not set
# CONFIG_I2C_OCORES is not set
# CONFIG_I2C_PARPORT_LIGHT is not set
# CONFIG_I2C_PASEMI is not set
# CONFIG_I2C_PROSAVAGE is not set
# CONFIG_I2C_SAVAGE4 is not set
# CONFIG_I2C_SIS5595 is not set
# CONFIG_I2C_SIS630 is not set
# CONFIG_I2C_SIS96X is not set
CONFIG_I2C_STUB=m
# CONFIG_I2C_VIA is not set
# CONFIG_I2C_VIAPRO is not set
# CONFIG_I2C_VOODOO3 is not set
# CONFIG_I2C_PCA_ISA is not set

#
# Miscellaneous I2C Chip support
#
CONFIG_SENSORS_DS1337=m
CONFIG_SENSORS_DS1374=m
CONFIG_SENSORS_EEPROM=m
# CONFIG_SENSORS_MAX6900 is not set
CONFIG_SENSORS_PCF8574=m
CONFIG_SENSORS_PCA9539=m
CONFIG_SENSORS_PCF8591=m
CONFIG_SENSORS_M41T00=m
CONFIG_SENSORS_MAX6875=m
CONFIG_I2C_DEBUG_CORE=y
CONFIG_I2C_DEBUG_ALGO=y
CONFIG_I2C_DEBUG_BUS=y
CONFIG_I2C_DEBUG_CHIP=y

#
# SPI support
#
# CONFIG_SPI is not set
# CONFIG_SPI_MASTER is not set

#
# Dallas's 1-wire bus
#
# CONFIG_W1 is not set

#
# Hardware Monitoring support
#
CONFIG_HWMON=y
# CONFIG_HWMON_VID is not set
# CONFIG_SENSORS_ABITUGURU is not set
# CONFIG_SENSORS_AD7414 is not set
# CONFIG_SENSORS_ADM1021 is not set
# CONFIG_SENSORS_ADM1025 is not set
# CONFIG_SENSORS_ADM1026 is not set
# CONFIG_SENSORS_ADM1029 is not set
# CONFIG_SENSORS_ADM1031 is not set
# CONFIG_SENSORS_ADM9240 is not set
# CONFIG_SENSORS_ASB100 is not set
# CONFIG_SENSORS_ATXP1 is not set
# CONFIG_SENSORS_DS1621 is not set
# CONFIG_SENSORS_F71805F is not set
# CONFIG_SENSORS_FM75 is not set
# CONFIG_SENSORS_FSCHER is not set
# CONFIG_SENSORS_FSCPOS is not set
# CONFIG_SENSORS_GL518SM is not set
# CONFIG_SENSORS_GL520SM is not set
# CONFIG_SENSORS_IT87 is not set
# CONFIG_SENSORS_LM63 is not set
# CONFIG_SENSORS_LM75 is not set
# CONFIG_SENSORS_LM77 is not set
# CONFIG_SENSORS_LM78 is not set
# CONFIG_SENSORS_LM80 is not set
# CONFIG_SENSORS_LM83 is not set
# CONFIG_SENSORS_LM85 is not set
# CONFIG_SENSORS_LM87 is not set
# CONFIG_SENSORS_LM90 is not set
# CONFIG_SENSORS_LM92 is not set
# CONFIG_SENSORS_MAX1619 is not set
# CONFIG_SENSORS_PC87360 is not set
# CONFIG_SENSORS_PC87427 is not set
# CONFIG_SENSORS_SIS5595 is not set
# CONFIG_SENSORS_SMSC47M1 is not set
# CONFIG_SENSORS_SMSC47M192 is not set
# CONFIG_SENSORS_SMSC47B397 is not set
# CONFIG_SENSORS_VIA686A is not set
# CONFIG_SENSORS_VT1211 is not set
# CONFIG_SENSORS_VT8231 is not set
# CONFIG_SENSORS_W83781D is not set
# CONFIG_SENSORS_W83791D is not set
# CONFIG_SENSORS_W83792D is not set
# CONFIG_SENSORS_W83793 is not set
# CONFIG_SENSORS_W83L785TS is not set
# CONFIG_SENSORS_W83627HF is not set
# CONFIG_SENSORS_W83627EHF is not set
# CONFIG_HWMON_DEBUG_CHIP is not set

#
# Multifunction device drivers
#
# CONFIG_MFD_SM501 is not set

#
# Multimedia devices
#
# CONFIG_VIDEO_DEV is not set

#
# Digital Video Broadcasting Devices
#
# CONFIG_DVB is not set

#
# Graphics support
#
# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
# CONFIG_FB is not set
# CONFIG_FB_IBM_GXT4500 is not set

#
# Console display driver support
#
CONFIG_VGA_CONSOLE=y
# CONFIG_VGACON_SOFT_SCROLLBACK is not set
CONFIG_DUMMY_CONSOLE=y

#
# Sound
#
# CONFIG_SOUND is not set

#
# HID Devices
#
CONFIG_HID=y
# CONFIG_HID_DEBUG is not set

#
# USB support
#
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
CONFIG_USB_ARCH_HAS_EHCI=y
# CONFIG_USB is not set

#
# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
#

#
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set

#
# MMC/SD Card support
#
# CONFIG_MMC is not set

#
# LED devices
#
# CONFIG_NEW_LEDS is not set

#
# LED drivers
#

#
# LED Triggers
#

#
# InfiniBand support
#
# CONFIG_INFINIBAND is not set

#
# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
#

#
# Real Time Clock
#
# CONFIG_RTC_CLASS is not set

#
# DMA Engine support
#
# CONFIG_DMA_ENGINE is not set

#
# DMA Clients
#

#
# DMA Devices
#

#
# Auxiliary Display support
#

#
# Virtualization
#

#
# File systems
#
CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS_XATTR is not set
# CONFIG_EXT2_FS_XIP is not set
# CONFIG_EXT3_FS is not set
# CONFIG_EXT4DEV_FS is not set
# CONFIG_REISERFS_FS is not set
# CONFIG_JFS_FS is not set
# CONFIG_FS_POSIX_ACL is not set
# CONFIG_XFS_FS is not set
# CONFIG_GFS2_FS is not set
# CONFIG_OCFS2_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_INOTIFY=y
CONFIG_INOTIFY_USER=y
# CONFIG_QUOTA is not set
CONFIG_DNOTIFY=y
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set
# CONFIG_FUSE_FS is not set

#
# CD-ROM/DVD Filesystems
#
# CONFIG_ISO9660_FS is not set
# CONFIG_UDF_FS is not set

#
# DOS/FAT/NT Filesystems
#
# CONFIG_MSDOS_FS is not set
# CONFIG_VFAT_FS is not set
# CONFIG_NTFS_FS is not set

#
# Pseudo filesystems
#
CONFIG_PROC_FS=y
CONFIG_PROC_KCORE=y
CONFIG_PROC_SYSCTL=y
CONFIG_SYSFS=y
CONFIG_TMPFS=y
# CONFIG_TMPFS_POSIX_ACL is not set
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y
# CONFIG_CONFIGFS_FS is not set

#
# Miscellaneous filesystems
#
# CONFIG_ADFS_FS is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BFS_FS is not set
# CONFIG_EFS_FS is not set
# CONFIG_CRAMFS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_HPFS_FS is not set
# CONFIG_QNX4FS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_UFS_FS is not set

#
# Network File Systems
#
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
# CONFIG_NFS_V3_ACL is not set
# CONFIG_NFS_V4 is not set
# CONFIG_NFS_DIRECTIO is not set
# CONFIG_NFSD is not set
CONFIG_ROOT_NFS=y
CONFIG_LOCKD=y
CONFIG_LOCKD_V4=y
CONFIG_NFS_COMMON=y
CONFIG_SUNRPC=y
# CONFIG_RPCSEC_GSS_KRB5 is not set
# CONFIG_RPCSEC_GSS_SPKM3 is not set
# CONFIG_SMB_FS is not set
# CONFIG_CIFS is not set
# CONFIG_NCP_FS is not set
# CONFIG_CODA_FS is not set
# CONFIG_AFS_FS is not set
# CONFIG_9P_FS is not set

#
# Partition Types
#
# CONFIG_PARTITION_ADVANCED is not set
CONFIG_MSDOS_PARTITION=y

#
# Native Language Support
#
CONFIG_NLS=y
CONFIG_NLS_DEFAULT="iso8859-1"
# CONFIG_NLS_CODEPAGE_437 is not set
# CONFIG_NLS_CODEPAGE_737 is not set
# CONFIG_NLS_CODEPAGE_775 is not set
# CONFIG_NLS_CODEPAGE_850 is not set
# CONFIG_NLS_CODEPAGE_852 is not set
# CONFIG_NLS_CODEPAGE_855 is not set
# CONFIG_NLS_CODEPAGE_857 is not set
# CONFIG_NLS_CODEPAGE_860 is not set
# CONFIG_NLS_CODEPAGE_861 is not set
# CONFIG_NLS_CODEPAGE_862 is not set
# CONFIG_NLS_CODEPAGE_863 is not set
# CONFIG_NLS_CODEPAGE_864 is not set
# CONFIG_NLS_CODEPAGE_865 is not set
# CONFIG_NLS_CODEPAGE_866 is not set
# CONFIG_NLS_CODEPAGE_869 is not set
# CONFIG_NLS_CODEPAGE_936 is not set
# CONFIG_NLS_CODEPAGE_950 is not set
# CONFIG_NLS_CODEPAGE_932 is not set
# CONFIG_NLS_CODEPAGE_949 is not set
# CONFIG_NLS_CODEPAGE_874 is not set
# CONFIG_NLS_ISO8859_8 is not set
# CONFIG_NLS_CODEPAGE_1250 is not set
# CONFIG_NLS_CODEPAGE_1251 is not set
# CONFIG_NLS_ASCII is not set
CONFIG_NLS_ISO8859_1=m
# CONFIG_NLS_ISO8859_2 is not set
# CONFIG_NLS_ISO8859_3 is not set
# CONFIG_NLS_ISO8859_4 is not set
# CONFIG_NLS_ISO8859_5 is not set
# CONFIG_NLS_ISO8859_6 is not set
# CONFIG_NLS_ISO8859_7 is not set
# CONFIG_NLS_ISO8859_9 is not set
# CONFIG_NLS_ISO8859_13 is not set
# CONFIG_NLS_ISO8859_14 is not set
# CONFIG_NLS_ISO8859_15 is not set
# CONFIG_NLS_KOI8_R is not set
# CONFIG_NLS_KOI8_U is not set
# CONFIG_NLS_UTF8 is not set

#
# Distributed Lock Manager
#
# CONFIG_DLM is not set

#
# Library routines
#
CONFIG_BITREVERSE=y
# CONFIG_CRC_CCITT is not set
# CONFIG_CRC16 is not set
CONFIG_CRC32=y
# CONFIG_LIBCRC32C is not set
CONFIG_PLIST=y
CONFIG_HAS_IOMEM=y
CONFIG_HAS_IOPORT=y
# CONFIG_PROFILING is not set

#
# Kernel hacking
#
# CONFIG_PRINTK_TIME is not set
CONFIG_ENABLE_MUST_CHECK=y
CONFIG_MAGIC_SYSRQ=y
# CONFIG_UNUSED_SYMBOLS is not set
# CONFIG_DEBUG_FS is not set
# CONFIG_HEADERS_CHECK is not set
# CONFIG_IPIPE_DEBUG is not set
CONFIG_IPIPE_TRACE_ENABLE_VALUE=0
CONFIG_DEBUG_KERNEL=y
# CONFIG_DEBUG_SHIRQ is not set
CONFIG_LOG_BUF_SHIFT=14
CONFIG_DETECT_SOFTLOCKUP=y
# CONFIG_SCHEDSTATS is not set
# CONFIG_TIMER_STATS is not set
# CONFIG_DEBUG_SLAB is not set
# CONFIG_DEBUG_RT_MUTEXES is not set
# CONFIG_RT_MUTEX_TESTER is not set
# CONFIG_DEBUG_SPINLOCK is not set
# CONFIG_DEBUG_MUTEXES is not set
CONFIG_DEBUG_SPINLOCK_SLEEP=y
# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
# CONFIG_DEBUG_KOBJECT is not set
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_VM is not set
# CONFIG_DEBUG_LIST is not set
CONFIG_FORCED_INLINING=y
# CONFIG_RCU_TORTURE_TEST is not set
# CONFIG_FAULT_INJECTION is not set
# CONFIG_XMON is not set
# CONFIG_BDI_SWITCH is not set
CONFIG_SERIAL_TEXT_DEBUG=y

#
# Security options
#
# CONFIG_KEYS is not set
# CONFIG_SECURITY is not set

#
# Cryptographic options
#
# CONFIG_CRYPTO is not set

[-- Attachment #3: CMakeLists.txt --]
[-- Type: text/plain, Size: 149 bytes --]


add_executable (readMax6633 readMax6633.c)
add_executable (bitOperation bitOperation.c)

INSTALL(PROGRAMS readMax6633 bitOperation DESTINATION bin)

[-- Attachment #4: readMax6633.c --]
[-- Type: text/x-csrc, Size: 2384 bytes --]

/* read the data from max6633 */

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "i2c-dev.h"
#include "version.h"

static __inline__ unsigned short swap_bytes(unsigned short val)
{
   return(val >> 8) | (val << 8);
}

int main(void)
{
   int res,address,file;
   char filename[20];
   unsigned short temp;
   long funcs;
   int i2cbus;
   int errorCount,successfullCount;
   double errorRate;
   errorCount=0;
   successfullCount=0;
   errorRate=0;
   i2cbus=1;
   address=0x40;
   
   sprintf(filename,"/dev/i2c-%d",i2cbus);
   if((file=open(filename,O_RDWR))<0)
   {
      fprintf(stderr,"Error: could not open file %s: %s\n",filename,strerror(errno));
      exit(1);
   }
   
   /* check adapter functionality */
   if(ioctl(file,I2C_FUNCS,&funcs) < 0)
   {
      fprintf(stderr, "Error: could not get the adapter functionality matrix: %s\n",strerror(errno));
      goto ERROR0;
   }
   if(!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA))
   {
      fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
      fprintf(stderr," does not have byte read capability\n");
      goto ERROR0;
   }
   if(!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA))
   {
      fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
      fprintf(stderr," does not have word read capability\n");
      goto ERROR0;
   }
      
   
   /* use FORCE so that we can look at registers even when a driver
      is also running */
   if(ioctl(file,I2C_SLAVE,address) <0)
   {
      fprintf(stderr,"Error: Could not set address to %d: %s\n",address, strerror(errno));
      goto ERROR0;
   }
   
   fprintf(stderr,"Read with word_data\n");
   while(1)
   {
      
      temp=res=i2c_smbus_read_word_data(file,0);
      if(res<0)
      {
	 fprintf(stderr,"Error: Could not read the value from the i2c device\n");
	 errorCount++;
      }else
      {
	 successfullCount++;
      }
      
      temp=swap_bytes(temp);
      temp=temp >> 3;
      
      if(errorCount>0 && successfullCount>0)
      {
	 errorRate=(double)errorCount/(double)successfullCount*(double)100;
      }
      
      printf("Success: %i, Errorcount: %i, Errorrate: %f%, Temp: %f\n",successfullCount,errorCount, errorRate,(float)(temp*0.0625));
      sleep(1);
   }
   
   printf("\nCalculate temp\n");
  
   close(file);
   exit(0);

  ERROR0:
   close(file);
   exit(1);
}


[-- Attachment #5: i2c-dev.h --]
[-- Type: text/x-chdr, Size: 12375 bytes --]

/*
    i2c-dev.h - i2c-bus driver, char device interface

    Copyright (C) 1995-97 Simon G. Vogl
    Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>

    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.
*/

/* $Id: i2c-dev.h,v 1.1.1.1 2005/01/21 17:09:47 drlove Exp $ */

#ifndef LIB_I2CDEV_H
#define LIB_I2CDEV_H

#include <linux/types.h>
#include <sys/ioctl.h>


/* -- i2c.h -- */


/*
 * I2C Message - used for pure i2c transaction, also from /dev interface
 */
struct i2c_msg {
	__u16 addr;	/* slave address			*/
	unsigned short flags;		
#define I2C_M_TEN	0x10	/* we have a ten bit chip address	*/
#define I2C_M_RD	0x01
#define I2C_M_NOSTART	0x4000
#define I2C_M_REV_DIR_ADDR	0x2000
#define I2C_M_IGNORE_NAK	0x1000
#define I2C_M_NO_RD_ACK		0x0800
	short len;		/* msg length				*/
	char *buf;		/* pointer to msg data			*/
	int err;
	short done;
};

/* To determine what functionality is present */

#define I2C_FUNC_I2C			0x00000001
#define I2C_FUNC_10BIT_ADDR		0x00000002
#define I2C_FUNC_PROTOCOL_MANGLING	0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
#define I2C_FUNC_SMBUS_HWPEC_CALC	0x00000008 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC  0x00000800 /* SMBus 2.0 */ 
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */ 
#define I2C_FUNC_SMBUS_PROC_CALL_PEC	0x00002000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL	0x00008000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_QUICK		0x00010000 
#define I2C_FUNC_SMBUS_READ_BYTE	0x00020000 
#define I2C_FUNC_SMBUS_WRITE_BYTE	0x00040000 
#define I2C_FUNC_SMBUS_READ_BYTE_DATA	0x00080000 
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA	0x00100000 
#define I2C_FUNC_SMBUS_READ_WORD_DATA	0x00200000 
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA	0x00400000 
#define I2C_FUNC_SMBUS_PROC_CALL	0x00800000 
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA	0x01000000 
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK	0x04000000 /* I2C-like block xfer  */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK	0x08000000 /* w/ 1-byte reg. addr. */
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2	 0x10000000 /* I2C-like block xfer  */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC  0x40000000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */

#define I2C_FUNC_SMBUS_BYTE I2C_FUNC_SMBUS_READ_BYTE | \
                            I2C_FUNC_SMBUS_WRITE_BYTE
#define I2C_FUNC_SMBUS_BYTE_DATA I2C_FUNC_SMBUS_READ_BYTE_DATA | \
                                 I2C_FUNC_SMBUS_WRITE_BYTE_DATA
#define I2C_FUNC_SMBUS_WORD_DATA I2C_FUNC_SMBUS_READ_WORD_DATA | \
                                 I2C_FUNC_SMBUS_WRITE_WORD_DATA
#define I2C_FUNC_SMBUS_BLOCK_DATA I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
                                  I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
#define I2C_FUNC_SMBUS_I2C_BLOCK I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
                                  I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
#define I2C_FUNC_SMBUS_I2C_BLOCK_2 I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
                                   I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2
#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
                                      I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC
#define I2C_FUNC_SMBUS_WORD_DATA_PEC  I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
                                      I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC

#define I2C_FUNC_SMBUS_READ_BYTE_PEC		I2C_FUNC_SMBUS_READ_BYTE_DATA
#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC		I2C_FUNC_SMBUS_WRITE_BYTE_DATA
#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC	I2C_FUNC_SMBUS_READ_WORD_DATA
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC	I2C_FUNC_SMBUS_WRITE_WORD_DATA
#define I2C_FUNC_SMBUS_BYTE_PEC			I2C_FUNC_SMBUS_BYTE_DATA
#define I2C_FUNC_SMBUS_BYTE_DATA_PEC		I2C_FUNC_SMBUS_WORD_DATA

#define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \
                            I2C_FUNC_SMBUS_BYTE | \
                            I2C_FUNC_SMBUS_BYTE_DATA | \
                            I2C_FUNC_SMBUS_WORD_DATA | \
                            I2C_FUNC_SMBUS_PROC_CALL | \
                            I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
                            I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \
                            I2C_FUNC_SMBUS_I2C_BLOCK

/* 
 * Data for SMBus Messages 
 */
#define I2C_SMBUS_BLOCK_MAX	32	/* As specified in SMBus standard */	
#define I2C_SMBUS_I2C_BLOCK_MAX	32	/* Not specified but we use same structure */
union i2c_smbus_data {
	__u8 byte;
	__u16 word;
	__u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */
                          /* one more for read length in block process call */
	                                            /* and one more for PEC */
};

/* smbus_access read or write markers */
#define I2C_SMBUS_READ	1
#define I2C_SMBUS_WRITE	0

/* SMBus transaction types (size parameter in the above functions) 
   Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
#define I2C_SMBUS_QUICK		    0
#define I2C_SMBUS_BYTE		    1
#define I2C_SMBUS_BYTE_DATA	    2 
#define I2C_SMBUS_WORD_DATA	    3
#define I2C_SMBUS_PROC_CALL	    4
#define I2C_SMBUS_BLOCK_DATA	    5
#define I2C_SMBUS_I2C_BLOCK_DATA    6
#define I2C_SMBUS_BLOCK_PROC_CALL   7		/* SMBus 2.0 */
#define I2C_SMBUS_BLOCK_DATA_PEC    8		/* SMBus 2.0 */
#define I2C_SMBUS_PROC_CALL_PEC     9		/* SMBus 2.0 */
#define I2C_SMBUS_BLOCK_PROC_CALL_PEC  10	/* SMBus 2.0 */
#define I2C_SMBUS_WORD_DATA_PEC	   11		/* SMBus 2.0 */


/* ----- commands for the ioctl like i2c_command call:
 * note that additional calls are defined in the algorithm and hw 
 *	dependent layers - these can be listed here, or see the 
 *	corresponding header files.
 */
				/* -> bit-adapter specific ioctls	*/
#define I2C_RETRIES	0x0701	/* number of times a device address      */
				/* should be polled when not            */
                                /* acknowledging 			*/
#define I2C_TIMEOUT	0x0702	/* set timeout - call with int 		*/


/* this is for i2c-dev.c	*/
#define I2C_SLAVE	0x0703	/* Change slave address			*/
				/* Attn.: Slave address is 7 or 10 bits */
#define I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
				/* Attn.: Slave address is 7 or 10 bits */
				/* This changes the address, even if it */
				/* is already taken!			*/
#define I2C_TENBIT	0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit	*/

#define I2C_FUNCS	0x0705	/* Get the adapter functionality */
#define I2C_RDWR	0x0707	/* Combined R/W transfer (one stop only)*/
#define I2C_PEC		0x0708	/* != 0 for SMBus PEC                   */
#if 0
#define I2C_ACK_TEST	0x0710	/* See if a slave is at a specific address */
#endif

#define I2C_SMBUS	0x0720	/* SMBus-level access */

/* -- i2c.h -- */


/* Note: 10-bit addresses are NOT supported! */

/* This is the structure as used in the I2C_SMBUS ioctl call */
struct i2c_smbus_ioctl_data {
	char read_write;
	__u8 command;
	int size;
	union i2c_smbus_data *data;
};

/* This is the structure as used in the I2C_RDWR ioctl call */
struct i2c_rdwr_ioctl_data {
	struct i2c_msg *msgs;	/* pointers to i2c_msgs */
	int nmsgs;		/* number of i2c_msgs */
};


static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, 
                                     int size, union i2c_smbus_data *data)
{
	struct i2c_smbus_ioctl_data args;

	args.read_write = read_write;
	args.command = command;
	args.size = size;
	args.data = data;
	return ioctl(file,I2C_SMBUS,&args);
}


static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
{
	return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
}
	
static inline __s32 i2c_smbus_read_byte(int file)
{
	union i2c_smbus_data data;
	if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
		return -1;
	else
		return 0x0FF & data.byte;
}

static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
{
	return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
	                        I2C_SMBUS_BYTE,NULL);
}

static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
{
	union i2c_smbus_data data;
	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
	                     I2C_SMBUS_BYTE_DATA,&data))
		return -1;
	else
		return 0x0FF & data.byte;
}

static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, 
                                              __u8 value)
{
	union i2c_smbus_data data;
	data.byte = value;
	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                        I2C_SMBUS_BYTE_DATA, &data);
}

static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
{
	union i2c_smbus_data data;
	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
	                     I2C_SMBUS_WORD_DATA,&data))
		return -1;
	else
		return 0x0FFFF & data.word;
}

static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, 
                                              __u16 value)
{
	union i2c_smbus_data data;
	data.word = value;
	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                        I2C_SMBUS_WORD_DATA, &data);
}

static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
{
	union i2c_smbus_data data;
	data.word = value;
	if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                     I2C_SMBUS_PROC_CALL,&data))
		return -1;
	else
		return 0x0FFFF & data.word;
}


/* Returns the number of read bytes */
static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, 
                                              __u8 *values)
{
	union i2c_smbus_data data;
	int i;
	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
	                     I2C_SMBUS_BLOCK_DATA,&data))
		return -1;
	else {
		for (i = 1; i <= data.block[0]; i++)
			values[i-1] = data.block[i];
		return data.block[0];
	}
}

static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, 
                                               __u8 length, __u8 *values)
{
	union i2c_smbus_data data;
	int i;
	if (length > 32)
		length = 32;
	for (i = 1; i <= length; i++)
		data.block[i] = values[i-1];
	data.block[0] = length;
	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                        I2C_SMBUS_BLOCK_DATA, &data);
}

/* Returns the number of read bytes */
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
                                                  __u8 *values)
{
	union i2c_smbus_data data;
	int i;
	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
	                      I2C_SMBUS_I2C_BLOCK_DATA,&data))
		return -1;
	else {
		for (i = 1; i <= data.block[0]; i++)
			values[i-1] = data.block[i];
		return data.block[0];
	}
}

static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
                                               __u8 length, __u8 *values)
{
	union i2c_smbus_data data;
	int i;
	if (length > 32)
		length = 32;
	for (i = 1; i <= length; i++)
		data.block[i] = values[i-1];
	data.block[0] = length;
	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                        I2C_SMBUS_I2C_BLOCK_DATA, &data);
}

/* Returns the number of read bytes */
static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
                                                 __u8 length, __u8 *values)
{
	union i2c_smbus_data data;
	int i;
	if (length > 32)
		length = 32;
	for (i = 1; i <= length; i++)
		data.block[i] = values[i-1];
	data.block[0] = length;
	if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
	                     I2C_SMBUS_BLOCK_PROC_CALL,&data))
		return -1;
	else {
		for (i = 1; i <= data.block[0]; i++)
			values[i-1] = data.block[i];
		return data.block[0];
	}
}


#endif /* LIB_I2CDEV_H */

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2007-04-25 18:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 12:24 Howto read I2C on MPC5200 Lite Matthias Fechner
2007-03-07 21:17 ` John Rigby
2007-03-09 11:35   ` Matthias Fechner
2007-03-09 17:11     ` John Rigby
2007-03-09 23:42       ` Matthias Fechner
2007-03-10  2:18         ` where and how to get the latest 2.6 kernel Nick Droogh
2007-03-11  1:01           ` Matthias Fechner
2007-03-11  0:55         ` Howto read I2C on MPC5200 Lite Matthias Fechner
2007-03-15  9:57           ` Domen Puncer
2007-03-16  4:33             ` Matthias Fechner
2007-03-17  8:57             ` Matthias Fechner
2007-03-18 19:06               ` Charles Krinke
2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
2007-03-18 23:28                   ` Matthias Fechner
2007-03-19  0:14                 ` Howto read I2C on MPC5200 Lite Wolfgang Denk
2007-03-19  1:11                 ` A question regarding step and breakpoints Charles Krinke
2007-03-21  8:34               ` Howto read I2C on MPC5200 Lite Matthias Fechner
2007-04-04  8:49                 ` Domen Puncer
2007-04-25 18:48                   ` Matthias Fechner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.