Search code examples
linux-device-drivercpugpio

How can I access GPIO with physical address?


I have a requirement that is accessing GPIO with ubuntu 14.04LTS.

Below information is my device information:

  • OS:Ubuntu 14.04 LTS 64bits
  • CPU:Intel® Celeron(R) CPU J1900 @ 1.99GHz × 4

And bleow link is datasheet and driver code

code and datasheet here.


First I was checked the chip is it8785, and GPIO port is 32 to 39. PIN of port GPIO 32 is 117, so I type the command:

echo 32 > /sys/class/gpio/export

and

echo 117 > /sys/class/gpio/export

but both show the error "bash - echo: write error: invalid argument"

I don't have any idea for this, so I contect with manufacturer.

They told me that if i want access GPIO, I must direct access CPU address like :

GPIO PORT   Adderss
32          0xfed0e388
33          0xfed0e368
34          0xfed0e318
35          0xfed0e378
36          0xfed0e308
37          0xfed0e398
38          0xfed0e328
39          0xfed0e3A8

I have googled for a while, quantity of data are rarly. It's thanksful for any advice.


Solution

  • Can you try and use sudo while exporting and see if the gpio could exported.

    As the manufacturer has provided with register address you can map them to user space and access. On how to access them in user space you can have a look at dev2mem. Hope that helps.