Error using at91-i2c driver in kernel 4.4.x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been using kernel version 3.10.x for a couple years and I am in the process of upgrading to kernel version 4.4.  I am using an Atmel AT91SAM9G25 and I am using Atmel's stable fork of the kernel at github.com/linux4sam/linux-at91.  I last pulled the linux-4.4-at91 branch about two weeks ago.  Today I noticed that I can no longer talk to an I2C EEPROM that I could with kernel version 3.10.  I verified the EEPROM still worked with kernel version 3.10 on my hardware, updated my kernel, and now I can't talk to the EEPROM.

First, for the ARM device tree the i2c section looks like this for my build:

			i2c0: i2c@f8010000 {
				status = "okay";

				wm8731: wm8731@1a {
					compatible = "wm8731";
					reg = <0x1a>;
				};

				ov2640: camera@0x30 {
					compatible = "ovti,ov2640";
					reg = <0x30>;
					pinctrl-names = "default";
					pinctrl-0 = <&pinctrl_pck0_as_isi_mck &pinctrl_sensor_power &pinctrl_sensor_reset>;
					resetb-gpios = <&pioA 7 GPIO_ACTIVE_LOW>;
					pwdn-gpios = <&pioA 13 GPIO_ACTIVE_HIGH>;
					clocks = <&pck0>;
					clock-names = "xvclk";
					assigned-clocks = <&pck0>;
					assigned-clock-rates = <25000000>;
					status = "disabled";

					port {
						ov2640_0: endpoint {
							remote-endpoint = <&isi_0>;
							bus-width = <8>;
						};
					};
				};
				24c02@50 {
					compatible = "atmel,24c02";
					reg = <0x50>;
					pagesize = <0x08>;
					status = "okay";
				};
			};

I see the following messages in dmesg:

[    0.234375] at91_i2c f8010000.i2c: using dma0chan0 (tx) and dma0chan1 (rx) for DMA transfers
[    0.234375] at91_i2c f8010000.i2c: AT91 i2c bus driver (hw version: 0x402).
[    0.742187] at24 0-0050: 256 byte 24c02 EEPROM, writable, 8 bytes/write
[    1.343750] i2c /dev entries driver

To me it appears the i2c driver and the EEPROM driver have been loaded and populated.  I see that /dev/i2c-0 and /sys/class/i2c-dev/i2c-0 are populated on my system.  I then try to read all 256 bytes from the EEPROM as follows from my C program:

    int file;
    char filename[] = "/dev/i2c-0";
    int addr = 0x50;
    char buf[256];
    ssize_t readBytes;
    
    /* Open the I2C dev interface file */
    file = open(filename, O_RDWR);
    if (file < 0)
    {
        printf("Can't open device\n");
        exit(EXIT_FAILURE);
    }

    /* Set the I2C slave address */
    if (ioctl(file, I2C_SLAVE, addr) < 0)
    {
        printf("Can't set slave address - %m\n");
    }

    /* Attempt to read out the entire EEPROM */
    readBytes = read(file, buf, sizeof(buf));
    if(readBytes != (ssize_t)sizeof(buf))
    {
        printf("Only read %d bytes\n - %m", readBytes);
    }
    else
    {
        /* Do something with the data... */
    }

When I run the above code with the 4.4 kernel running, I get the following output:

    Can't set slave address - Device or resource busy
    Only read -1 bytes - Remote I/O error

Any thoughts as to what I should be checking to figure out why i2c isn't working for me anymore?

Thanks,
Bryan

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux