Search code examples
linuxlinux-kernelarmlinux-device-driverdevice-tree

Writing Device Driver in Linux


I'm a newbie to writing device drivers.

I want to write a device driver for a peripheral on an ARM platform.

1st question: Is it different to write a device driver for a peripheral on ARM platform than on x86 in Linux?

2nd question: I checked /proc/iomem file to view current address map of the processor. However, not all peripherals including the one to which I want to access do not exist in that file. How can I include the address range of a peripheral?

3rd question: What is the importance of a device tree in writing a device driver?


Solution

  • 1. As long as the peripheral is interfaced similarly to the SoC(i.e. uses the same hardware interface on both the platforms), the same driver can be used on both x86 and ARM. This is the advantage of developing modular drivers independent from the Linux kernel core.


    2. If your particular peripheral does NOT exist in the current address map(/proc/iomem) then it could mean one of two possibilities :

    • The device driver is not loaded yet.
    • The device uses other form of addressing (NOT memory mapped I/O)

    Any additional info about the peripheral? How is it connected to the SoC?


    3. A device-tree in the Linux kernel is used to describe the numerous hardware (both-on-chip and peripherals), their inter-connectivity and the basic params applicable for their proper configuration and initialisation on a specific platform/board for which the device-tree is written.

    Essentially it performs the same functions and the "board-file" found in current Linux kernel. It also reduces the dependency of bootargs for initial configuration as the same can be provided in the device-tree. More info on device trees.