LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to contorl I2C device or GPIO device in the kernel. (https://www.linuxquestions.org/questions/linux-software-2/how-to-contorl-i2c-device-or-gpio-device-in-the-kernel-4175588834/)

poplinux 09-06-2016 12:02 AM

How to contorl I2C device or GPIO device in the kernel.
 
Dear Sir.

My env is see below
- Platform : x86 atom rangeley.
- linux kernel : 4.7.0

Linux kernel is already support I2C device driver and GPIO device driver.
And this device is successfully worked.

If i was loading the "i2c-i801.ko", created the "/dev/i2c-0" and can running.

If i was loading the "gpio-ich.ko", created the "/sys/class/gpio" and can running.

But my goal ls create the new kernel device driver.
And I must contorl i2c and gpio in the my new device driver.

Never use the file descriptor on user space. Just use the kernel APIs.

But I don't know "How to can get some descriptor for I2C, GPIO in kernel space".

Some kernel code use the special API(ex. get_deviceXXXX()).

Could you support some example code?

Thank you.

rtmistler 09-06-2016 07:11 AM

Example code would be in the kernel within the kernel driver sources for GPIO and I2C.

That is your best reference.

And you may want to request that a moderator move your thread to the Linux Kernel forum.


All times are GMT -5. The time now is 09:30 PM.