Support i2c micro using 3.x kernel

Started by tcmichals, September 16, 2012, 01:06:18 AM

Previous topic - Next topic

tcmichals

Oh, OK see why USB does not work, must have:
.compatible = "fsl,imx27-usb"
defined in the device tree or the chipidea driver is not loaded.  Will fix that tonight..

Fadil Berisha

Quote from: tcmichals on October 04, 2012, 07:02:51 AM
... But should the pins be:
i2c0_pins_a: i2c0@0 {
               reg = <0>;
               fsl,pinmux-ids = <
                  0x1171 /* MX23_PAD_LCD_ENABLE__I2C_SCL */
                  0x1181 /* MX23_PAD_LCD_HSYNC__I2C_SDA  */
               >;
               fsl,drive-strength = <1>;
               fsl,voltage = <1>;
               fsl,pull-up = <1>;
            };
Yes, pins are correct, please refer to attached schematic:
https://docs.google.com/open?id=0B5yGbFXTEhQpaTRWaE1zWU0ycVU (Mozilla: right click, View Image --> Zoom).
As you can see, pins are present on GPIO Connector, but you wish, you can switch I2C pins on UEXT connector.
Please note also that device tree pin nomenclature is in format:
<PIN_NAME__PIN_FUNCTION>.
Example: PIN_NAME -> LCD_ENABLE with function I2C_SCL became LCD_ENABLE__I2C_SCL.

Regards
Fadil Berisha

tcmichals

Yes, I did that last night, still not working... Guess will reload an older kernel to validate everything is working..

tcmichals

loaded OE, Linux imx233-olinuxino-micro 2.6.35.3-10.12.01+yocto+g0ea8cb9 #1 PREEMPT Fri Oct 5 21:07:30 CDT 2012 armv5tejl GNU/Linux.  Did not move any wiring and it all worked fine.  So, guess little lost on what is wrong.

Niii

Just another test with debug output (on r3.2):

root@micro:~# dmesg | grep i2c
[    0.120000] i2c-core: driver [dummy] registered
[    0.430000] i2c i2c-0: adapter [MXS I2C adapter] registered
[    0.440000] i2c 0-000a: uevent
[    0.440000] i2c i2c-0: client [sgtl5000] registered with bus id 0-000a
[    0.440000] i2c 0-0051: uevent
[    0.440000] i2c i2c-0: client [24c32] registered with bus id 0-0051
[    1.030000] i2c /dev entries driver
[    1.030000] i2c-dev: adapter [MXS I2C adapter] registered as minor 0
[    1.120000] i2c-core: driver [sgtl5000] registered
[    4.200000] i2c 0-0051: uevent
[    5.020000] i2c 0-0051: uevent
[    5.560000] i2c 0-0051: uevent
root@micro:~# i2cdetect -l
i2c-0 i2c        MXS I2C adapter                  I2C adapter
root@micro:~# i2cdetect 0
Error: Can't use SMBus Quick Write command on this bus (ISA bus?)
root@micro:~# i2cdetect -r 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- UU -- ^C
root@micro:~# dmesg | grep i2c
[    0.120000] i2c-core: driver [dummy] registered
[    0.430000] i2c i2c-0: adapter [MXS I2C adapter] registered
[    0.440000] i2c 0-000a: uevent
[    0.440000] i2c i2c-0: client [sgtl5000] registered with bus id 0-000a
[    0.440000] i2c 0-0051: uevent
[    0.440000] i2c i2c-0: client [24c32] registered with bus id 0-0051
[    1.030000] i2c /dev entries driver
[    1.030000] i2c-dev: adapter [MXS I2C adapter] registered as minor 0
[    1.120000] i2c-core: driver [sgtl5000] registered
[    4.200000] i2c 0-0051: uevent
[    5.020000] i2c 0-0051: uevent
[    5.560000] i2c 0-0051: uevent
[  172.280000] i2c i2c-0: ioctl, cmd=0x705, arg=0xbeae8bf0
[  174.600000] i2c i2c-0: ioctl, cmd=0x705, arg=0xbe8ecc98
[  178.520000] i2c i2c-0: ioctl, cmd=0x705, arg=0xbecabc98
[  179.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x03
[  179.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  179.770000] i2c i2c-0: master_xfer[0] R, addr=0x03, len=1
[  179.770000] mxs-i2c 80058000.i2c: addr: 0x0003, len: 1, flags: 0x1, stop: 1
[  180.770000] mxs-i2c 80058000.i2c: Timeout!
[  180.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x04
[  180.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  180.770000] i2c i2c-0: master_xfer[0] R, addr=0x04, len=1
[  180.770000] mxs-i2c 80058000.i2c: addr: 0x0004, len: 1, flags: 0x1, stop: 1
[  181.770000] mxs-i2c 80058000.i2c: Timeout!
[  181.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x05
[  181.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  181.770000] i2c i2c-0: master_xfer[0] R, addr=0x05, len=1
[  181.770000] mxs-i2c 80058000.i2c: addr: 0x0005, len: 1, flags: 0x1, stop: 1
[  182.770000] mxs-i2c 80058000.i2c: Timeout!
[  182.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x06
[  182.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  182.770000] i2c i2c-0: master_xfer[0] R, addr=0x06, len=1
[  182.770000] mxs-i2c 80058000.i2c: addr: 0x0006, len: 1, flags: 0x1, stop: 1
[  183.770000] mxs-i2c 80058000.i2c: Timeout!
[  183.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x07
[  183.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  183.770000] i2c i2c-0: master_xfer[0] R, addr=0x07, len=1
[  183.770000] mxs-i2c 80058000.i2c: addr: 0x0007, len: 1, flags: 0x1, stop: 1
[  184.770000] mxs-i2c 80058000.i2c: Timeout!
[  184.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x08
[  184.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  184.770000] i2c i2c-0: master_xfer[0] R, addr=0x08, len=1
[  184.770000] mxs-i2c 80058000.i2c: addr: 0x0008, len: 1, flags: 0x1, stop: 1
[  185.770000] mxs-i2c 80058000.i2c: Timeout!
[  185.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x09
[  185.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  185.770000] i2c i2c-0: master_xfer[0] R, addr=0x09, len=1
[  185.770000] mxs-i2c 80058000.i2c: addr: 0x0009, len: 1, flags: 0x1, stop: 1
[  186.770000] mxs-i2c 80058000.i2c: Timeout!
[  186.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x0a
[  186.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x0b
[  186.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  186.770000] i2c i2c-0: master_xfer[0] R, addr=0x0b, len=1
[  186.770000] mxs-i2c 80058000.i2c: addr: 0x000b, len: 1, flags: 0x1, stop: 1
[  187.770000] mxs-i2c 80058000.i2c: Timeout!
[  187.770000] i2c i2c-0: ioctl, cmd=0x703, arg=0x0c
[  187.770000] i2c i2c-0: ioctl, cmd=0x720, arg=0xbecabc8c
[  187.770000] i2c i2c-0: master_xfer[0] R, addr=0x0c, len=1
[  187.770000] mxs-i2c 80058000.i2c: addr: 0x000c, len: 1, flags: 0x1, stop: 1
[  188.770000] mxs-i2c 80058000.i2c: Timeout!

tcmichals

Oh, found an issue with the device tree, the interrupts are backwards..

                      i2c@80058000 {
+                       i2c0: i2c@80058000 {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               compatible = "fsl,imx23-i2c";
                                reg = <0x80058000 0x2000>;
+                               interrupts = <26 27>;  <-----  needs to be 27, 26  Error first, DMA second.. this is with 3.6 I have no idea about linux-next with DMA... the ERROR int 27 and DMA is 26...
+                               clock-frequency = <100000>;
                                status = "disabled";
                        };

Oh course that did not do anything, I'm tracing multiple issues..
1) USB, think it is a voltage/phy..
2) I2c, I was using linux-mainline.. and that is where I found the issue with the ISR... so.. moving to 3.6, because there are fixes about the data rate..

tcmichals

OK found out the issue with usb on 3.6:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-June/105247.html
Need this patch... but now it will not enumerate.. does this over and over..
There must be another patch somewhere because the linux-mainline has this fixed.. so.. hope some one can point that out..

tcmichals

Where is the latest driver i2c-mxs.c with DMA support?  the old 2.6.35 driver, I cannot find where the ABPX timings are set.  I see clocks.. but I think these are to slow.. need to figure out if this is the issue..

earny

[V4] MXS: Implement DMA support into mxs-i2c

https://patchwork.kernel.org/patch/1369781/

"On a mx28evk: Tested-by: Fabio Estevam <fabio.estevam@freescale.com>"
:-)

Niii

Same result with DMA patch and interrupts backwards on 3.6-rc2.

tcmichals

OK.. I move the I2C to the default pins, 127/128 and nothing... So to me it has to be the APBX clock.. A lot of the code is different so.. maybe that is it..

tcmichals

The imx233 support is being added and should be complete in 3.7-rc1, in a couple of weeks. So, I'm going to wait until then or when i2c-mxs.c changes in the linux-next tree.

Here is a thread on google groups.
https://groups.google.com/forum/#!topic/meta-fsl-arm/rxoukULHqZQ

tcmichals

Well Linux version 3.6.0-next-20121012 is a lot better then the 3.2, reboots, USB works out of the box. Can unplug/replug etc.  SPI driver, but i2c is still having issues:
-- [  100.630000] mxs-i2c 80058000.i2c: Failed to get PIO reg. write descriptor.

But, posted email back to the kernel people see what I did wrong...

tcmichals

Finally my message got posted to the linux-arm group on why the following message appears using i2c...
Testing i2c in 3.6.0-next-20121012 for i.mx233
Even with the 3.7-rc2 I get the same message...

Using the 3.6.0-next-20121012  to test i2c DMA support on a imx233-Olinuxino-micro board.  When using the i2cdetect -r 0 to scan a devices on the i2c bus,  the following message is displayed on the console:

-- [  129.130000] mxs-i2c 80058000.i2c: Failed to get PIO reg. write descriptor.

imx23.dtsi support for i2c:
i2c0_pins_a: i2c0@0 {
reg = <0>;
fsl,pinmux-ids = <
0x1171 /* MX23_PAD_LCD_ENABLE__LCD_ENABLE */
0x1181 /* MX23_PAD_LCD_HSYNC__LCD_HSYNC */
>;
fsl,drive-strength = <1>;
fsl,voltage = <1>;
fsl,pull-up = <1>;
};
...
i2c@80058000 {
#address-cells = <1>;
                               #size-cells = <0>;
compatible = "fsl,imx28-i2c";
reg = <0x80058000 0x2000>;
interrupts = <27 26>;
clock-frequency = <400000>;
fsl,i2c-dma-channel = <3>;
status = "disabled";
};
imx23-olinuxino.dts
i2c0: i2c@80058000 {
     pinctrl-names = "default";
                               pinctrl-0 = <&i2c0_pins_a>;
                               status = "okay";
                       };

Niii

Hi,

There are news about i2c on kernel 3.x on micro board ?
It's still not working ?