This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PCF8574: After setting up PCF8574 in board file, I cannot see GPIOs registered in the kernel

Part Number: PCF8574

Tool/software: Linux

I am integrating a PCF857r GPIO-expander driver into my Linux kernel (Version ~3.2 Linux). As this is built on an older version of the Linux kernel, I use a board file to setup this driver. Below is a piece of my code in the board file (../mach-exynos/mach-u1.c) where I setup this expander: 

/* PCF8574 GPIO expander platform data */

static struct pcf857x_platform_data pcf857x_data[] = {

   {

           .gpio_base = 300,  

   },};

 /* I2C1 */

static struct i2c_board_info i2c_devs1[] __initdata = {

   {

       I2C_BOARD_INFO("pcf857x", 0x20),

           .type = "pcf8574",

           .platform_data = &pcf857x_data[0],

   },};

I see the PCF8574 registered on the appropriate I2C bus at the correct address (I2C1 at 0x20). However, I do not see any GPIOs being registered. For now, I have not actually connected my expander to my I2C1 bus yet, but I think I should still be able to see the GPIOs registered. Specifically, I should see GPIO 300-307 registered (as it is an 8 bit expander). But I do not.

The GPIOs that I do see from the hardware (Exynos 4210 SoC) via "cat /sys/kernel/debug/gpio" range from 0-287. Since I don't want to conflict with any physical GPIO, I chose my expander GPIOs to be out of this range (300+). Part of the problem I believe is that GPIOs out of this range don't exist. Do I need to somehow create “virtual” GPIOs so that the PCF8574 can recognize and take? I’m not sure how to proceed. Thank you.

  • Hi Joe,

    Our expertise on this forum is more on the hardware/chip side, and so unfortunately it may be a bit difficult for us to debug what appears to be a driver issue (since the PCF8574 device itself seems to be recognized by your system). We can try to help, though. What does it take for a GPIO to be considered "registered"? Have you tried assigning the expander IO ports as lower values just as an experiment to confirm your theory that values greater than 300 cause issues?

    Regards,
    Max
  • Hi Max,

    Thank you for your reply! 

    By "registered," I meant that I would be able to see the GPIOs in the Linux kernel via the sysfs interface. For example, if GPIO 300 were registered in the kernel, I would think that I would be able to successfully export that GPIO (echo 300 > /sys/class/gpio/export).

    I did try to associate my expander GPIOs to the 0-287 range but that didn't work. I thought perhaps it didn't work there because those GPIOs were tied to physical, SoC GPIOs. 

    I've been reading around a bit and it might be possible that for Linux kernel versions beyond a particular version (version 3.0 perhaps) that I won't see the expander GPIOs unless my PCF8574 expander is physically connected to my hardware (before booting). Does this sound possible? I haven't tried this yet but will try it soon. To me however, it sounds as if I should see the GPIOs regardless of whether or not the physical device is present. But I read that during booting that if the physical devices are not present, they may not be probed and hence no corresponding entries in sysfs would be created. Not sure about this but worth a try.

    What do you think overall? Thanks again Max!

    Best,

    Joe

  • Hey Joe,

    "I've been reading around a bit and it might be possible that for Linux kernel versions beyond a particular version (version 3.0 perhaps) that I won't see the expander GPIOs unless my PCF8574 expander is physically connected to my hardware (before booting). Does this sound possible?"

    -This kind of question falls a bit outside of our expertise as we focus more on the analog side of support in this thread and not the software side. I can speak from the analog side a bit better: If you are trying to see if the device is being recognized by your software, in I2C we send the device address with a read or write bit which the device needs to acknowledge in order to let the master (person sending the address) know it has heard the command to read/write. In this case, it sounds like you need to know the states of the GPIO which requires a read of the device. So in this case you do need to have the device physically connected.

    What may help us more is if you can send us the SDA/SCL o-scope shots of when you try to communicate with the device. This is usually the easiest way for us to see what is actually happening as we can see what the device sees and how it responds to it's address.

    Thanks,
    -Bobby