Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Problem about i2c driver and test

I add opencore i2c to Nios II, and tested by i2ctools under uClinux( Microtronix nios2linux 1.4)

1.

3 chips in /dev/i2c-0

_________ typical read (they are different)

EEPROM_: S Addr Wr [A] Reg_addr [A]______________S Addr Rd [A] [Data] A.......[Data] NA P

FRAM___: S Addr Wr [A] Reg_addr_H [A] Reg_addr_L [A] S Addr Rd [A] [Data] A.......[Data] NA P

Realtime : S Addr Rd [A] _____________________________________[Data] A.......[Data] NA P

2.

Here is the result of i2cdetect

0 1 2 3 4 5 6 7 8 9 a b c d e f

00: XX XX XX XX XX XX XX XX XX XX XX XX XX

10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

30: 30 31 32 33 34 35 36 37 XX XX XX XX XX XX XX XX

40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

50: 50 51 XX XX XX XX XX XX XX XX XX XX XX XX XX XX

60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

70: XX XX XX XX XX XX XX XX

which indicates the adress of them correctly:

EEPROM : 50

FRAM : 51

Realtimer : 30---37

3. problem

3.1

I see only "ioctl" in i2ctools. Could I using "read" "write" method? (As the compiler tells me errors in :

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

3.2

How can I access 3-different types of i2c chips via oc-i2c drivers?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Could I modify i2c-oc.c and i2c-algo-oc.c to implement or add new 3 i2c-eeprom.c, i2c-fram.c and i2c-realtime.c ?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    I see only "ioctl" in i2ctools. Could I using "read" "write" method?[/b]

    --- Quote End ---

    you can use ioctl to read/write those devices, the command you need is I2C_RDWR.

    <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    How can I access 3-different types of i2c chips via oc-i2c drivers?[/b]

    --- Quote End ---

    You can have different utilities. The device address is specified in the message passed with this ioctl command.

    <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    Could I modify i2c-oc.c and i2c-algo-oc.c to implement or add new 3 i2c-eeprom.c, i2c-fram.c and i2c-realtime.c[/b]

    --- Quote End ---

    If your kernel does not utilize those devices, you don&#39;t have to implement something in kernel.