LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   How are devices addressed in a custom embedded board (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/how-are-devices-addressed-in-a-custom-embedded-board-904810/)

saichaitanya 09-24-2011 12:30 PM

How are devices addressed in a custom embedded board
 
Lets say there is a ARM application processor based custom board and it has three I2C interfaces and i were porting linux kernel to it. If i were to connect a I2C device like a digital thermometer from "I2C interface 1" then how does the linux kernel know through which pins it is connected to the system. where should the pin multiplexing and addressing be set. Is it done by editing I/O and memory registers in the device drivers? if yes then does that mean if i connect it via other pins then the same driver wouldn't work? or am i missing something? I worked with PIC microcontrollers before but in it all of the code is just written into JUST 1 single FILE, so i just write the pin addressing in it. In a linux kernel how is this done? where should i edit the code? is it in the device driver or somewhere else like a separate configuration file?

bastl 09-25-2011 10:00 AM

GPIO support in the kernel should controll it.
The driver (LKM) should support the connected device.
A driver don't have to know at which pin the device is connected to.

saichaitanya 09-26-2011 07:28 AM

Quote:

Originally Posted by bastl (Post 4481763)
GPIO support in the kernel should controll it.
The driver (LKM) should support the connected device.
A driver don't have to know at which pin the device is connected to.

Thanks. searching in that direction led me to this and i found what i was looking for in the board's .c file and pin multiplexing in mux.h header file. the pins are defined as
#define pin_name <pin_number>
in the board.c file. So my new question is are the pins defined in the above mentioned file used to develop the drivers? like
if (pin_name == 1){....code};
else{..code};
is that how drivers work irrespective of how the device is connected?

bastl 09-26-2011 10:30 AM

No, drivers should use an interface (file) to talk to the device.
If the kernel needs a special device file (block, char) in /dev it can be created with mknod.
Have a look to Linux Device Drivers, Third Edition.


All times are GMT -5. The time now is 05:10 PM.