2011-02-08 03:46:07     PCF8574 as GPIO expander

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-02-08 03:46:07     PCF8574 as GPIO expander

Yuriy Urasinov (RUSSIAN FEDERATION)

Message: 97992   

 

My custom board has 4 ICs PCF8574. I want to use these ICs for IO ports.

 

I tested from u-boot it works. I can write data to these ICs.

 

I want to see these ICs pins like other GPIO of blackfin here /sys/class/gpio/export in uCLinux.

 

Right now I see only blackfin GPIO pins.

 

Please give me link where I can read about it.

 

QuoteReplyEditDelete

 

 

2011-02-08 04:15:45     PCF8574 as GPIO expander

Michael Hennerich (GERMANY)

Message: 97993    Read linux/Documentation/gpio.txt

 

You need to enable the pcf8574 driver during kernel configuration,

and need to provide suitable i2c_board_info.

 

Take arch/arm/mach-imx/mach-mx1ads.c as an example.

QuoteReplyEditDelete

 

 

2011-02-14 04:19:23     Re: PCF8574 as GPIO expander

Yuriy Urasinov (RUSSIAN FEDERATION)

Message: 98152   

 

I try to add GPIO.

 

I didn't found enough information.

 

static struct pcf857x_platform_data pcf857x_data[] = {

{

     .gpio_base = 4 * 32,

}, {

     .gpio_base = 4 * 32 + 16,

}

};

 

 

What is it .gpio_base ?

 

Thanks.

QuoteReplyEditDelete

 

 

2011-02-14 12:35:08     Re: PCF8574 as GPIO expander

Mike Frysinger (UNITED STATES)

Message: 98159   

 

please read the documentation in linux-2.6.x/include/linux/i2c/pcf857x.h

 

otherwise, you're asking about a part ADI has nothing to do with.  it would make more sense to ask the vendor who does make that part how to connect it to a Linux system.

QuoteReplyEditDelete

 

 

2011-02-15 02:42:09     Re: PCF8574 as GPIO expander

Yuriy Urasinov (RUSSIAN FEDERATION)

Message: 98164   

 

Thank you.

 

I understood what is it .gpio_base.

 

Now I can use GPIO expander from kernel.

 

Below message from startup

 

bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

pcf857x 0-0020: gpios 49..56 on a pcf8574

pcf857x 0-0021: gpios 57..64 on a pcf8574

pcf857x 0-0026: gpios 65..72 on a pcf8574

pcf857x 0-0027: gpios 73..80 on a pcf8574

i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller, regs_base@ffc01400

 

In board file I used function as described here   docs.blackfin.uclinux.org/doku.php?id=gpio

 

I can switch on and swich off LEDs connected to PCF8574.

 

But I can not use this GPIOs from userspace.

 

At first I write source code as described here   docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs

 

gpio_export(65);

gpio_dir_out(65);

gpio_value(65, 1);

 

When I run my programm I see message in console

 

gpio/direction: No such file or directory

gpio/value: No such file or directory

 

Than I try to export GPIO manualy from console

 

root:/sys/class/gpio> ls

export gpiochip49 gpiochip65 unexport

gpiochip0 gpiochip57 gpiochip73

root:/sys/class/gpio>

 

I want to export GPIO 65 but ucLinux told me that GPIO 6 is busy. Why?

 

root:/sys/class/gpio> echo 65 > export

bfin-gpio: GPIO 6 is already reserved as Peripheral by bf5xx-nand !

bfin-gpio: GPIO 6 is already reserved as Peripheral by bf5xx-nand !

6root:/sys/class/gpio>

 

In cat/proc GPIO from 49 to 80 also are not present.

 

root: /> cat /proc/gpio

GPIO_0: bf5xx-nand Peripheral

GPIO_1: bf5xx-nand Peripheral

GPIO_2: bf5xx-nand Peripheral

GPIO_3: bf5xx-nand Peripheral

GPIO_4: bf5xx-nand Peripheral

GPIO_5: bf5xx-nand Peripheral

GPIO_6: bf5xx-nand Peripheral

GPIO_7: bf5xx-nand Peripheral

GPIO_8: soc-audio Peripheral

GPIO_9: soc-audio Peripheral

GPIO_10: soc-audio Peripheral

GPIO_11: soc-audio Peripheral

GPIO_12: soc-audio Peripheral

GPIO_13: soc-audio Peripheral

GPIO_14: bfin-uart Peripheral

GPIO_15: bfin-uart Peripheral

GPIO_17: m25p80 Peripheral

GPIO_18: bfin-spi Peripheral

GPIO_19: bfin-spi Peripheral

GPIO_20: bfin-spi Peripheral

GPIO_23: bfin-uart Peripheral

GPIO_24: bfin-uart Peripheral

GPIO_30: bfin_mac Peripheral

GPIO_31: bfin_mac Peripheral

GPIO_32: bfin_mac Peripheral

GPIO_33: bfin_mac Peripheral

GPIO_34: bfin_mac Peripheral

GPIO_35: bfin_mac Peripheral

GPIO_36: bfin_mac Peripheral

GPIO_37: bfin_mac Peripheral

GPIO_38: bfin_mac Peripheral

GPIO_39: bfin_mac Peripheral

GPIO_40: bfin_mac Peripheral

GPIO_42: bf5xx-nand Peripheral

GPIO_43: bf5xx-nand Peripheral

GPIO_44: bf5xx-nand Peripheral

GPIO_45: bf5xx-nand Peripheral

GPIO_46: bf5xx-nand Peripheral

GPIO_47: bf5xx-nand Peripheral

 

Why I have not access to this GPIOs from user space?

 

Thank you again for help.

QuoteReplyEditDelete

 

 

2011-02-15 03:04:17     Re: PCF8574 as GPIO expander

Mike Frysinger (UNITED STATES)

Message: 98165   

 

/proc/gpio only shows gpios that have been allocated from the Blackfin on-chip GPIOs.  it does not show every single gpio available.

 

your output there shows you've already exported gpio65.  you cannot export it again.  the output you're seeing is due to misbehavior in the shell where it attempts to resume writes that failed.  it is not a bug in the kernel.

QuoteReplyEditDelete

 

 

2011-02-15 08:37:44     Re: PCF8574 as GPIO expander

Yuriy Urasinov (RUSSIAN FEDERATION)

Message: 98184   

 

Mike, sorry I don't understand you.

 

I didn't export gpio65.

 

Maybe you mean this:

 

root:/sys/class/gpio> ls

export gpiochip0 gpiochip57 gpiochip73

gpio16 gpiochip49 gpiochip65 unexport

root:/sys/class/gpio>

 

This is not gpio65 this is gpiochip65. For example I export gpio16. gpio16 pin is present.

 

root:/sys/class/gpio> ls -al

drwxr-xr-x 2 root root 0 Jan 1 00:43 .

drwxr-xr-x 22 root root 0 Jan 1 00:43 ..

--w------- 1 root root 4096 Jan 1 00:59 export

lrwxrwxrwx 1 root root 0 Jan 1 00:59 gpio16 -> ../../devices/virtual/gpio/gpio16

lrwxrwxrwx 1 root root 0 Jan 1 00:43 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:43 gpiochip49 -> ../../devices/platform/i2c-bfin-twi.0/i2c-0/0-0020/gpio/gpiochip49

lrwxrwxrwx 1 root root 0 Jan 1 00:43 gpiochip57 -> ../../devices/platform/i2c-bfin-twi.0/i2c-0/0-0021/gpio/gpiochip57

lrwxrwxrwx 1 root root 0 Jan 1 00:43 gpiochip65 -> ../../devices/platform/i2c-bfin-twi.0/i2c-0/0-0026/gpio/gpiochip65

lrwxrwxrwx 1 root root 0 Jan 1 00:43 gpiochip73 -> ../../devices/platform/i2c-bfin-twi.0/i2c-0/0-0027/gpio/gpiochip73

--w------- 1 root root 4096 Jan 1 00:43 unexport

 

gpiochip49, gpiochip57, gpiochip65 and gpiochip73 this is only .gpio_base addreses.

 

How to use gpiochipXX to read and write data?

 

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0026/gpio/gpiochip65> ls

base device label ngpio subsystem uevent

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0026/gpio/gpiochip65>

QuoteReplyEditDelete

 

 

2011-02-17 07:20:36     Re: PCF8574 as GPIO expander

Yuriy Urasinov (RUSSIAN FEDERATION)

Message: 98220   

 

it seems nobody know how to use PCF8574 from user space. I already use I2C read write functions. It works properly.

 

thanks for all.

QuoteReplyEditDelete

 

 

2011-02-17 13:57:01     Re: PCF8574 as GPIO expander

michael allen (UNITED STATES)

Message: 98231   

 

you're asking about a device we've never used, never developed for, and have nothing to do with the actual creation of the hardware.  so of course you're going to get "our best guess".  if you expect bullet proof answers about the PCF8574, you should obviously be asking the manufacturer of the PCF8574 part about it -- and that is not ADI.

QuoteReplyEditDelete

Attachments

    Outcomes