2
votes

I'm a beginner and I'm trying to understand the concept behind the device driver stack? I know the device driver stack has three layers named low level driver, bus manager and a high level driver. My question is this, Is there separate codes exist for low level driver and bus manager? If they exist, where can I find the low level drivers for hardware controllers in a Linux file system? Thanks.

2

2 Answers

3
votes

The Linux kernel has three device driver layers, that holds for most part of the device driver system of the Kernel. The bus driver, the protocol driver and the device driver. Let's take as example a SPI device you want write a driver for (e.g. some sort of sensor). Normally you will write the driver using the data sheet of the device, to see how it works and which registers holds which information. This is done in the device driver.

The device driver sends the commands to the protocol driver which basically defines how a SPI command looks like (how you have to fill the data structure to read/write a register of the device).

Normally SPI connection between your SOC and the sensor is done through some special hardware inside the SOC to send receive SPI commands. This is the bus driver. So you have something like this in software: device_driver <-> protocol_driver <-> bus_driver

in hardware it looks like this: SOC_SPI_module <-> sensor

The idea is, to encapsulate the SOC SPI module from the device driver, so when you program a device driver you don't have to care about the SOC you are using to access your device.

Hope I was able to help you.

-1
votes

In Linux Device Driver is object oriented programming in C generally. In this we are having on broader view "module_init" as the constructor & "module_exit" as the destructor.

According to my view as the "init & exit" process interacts with the device controller hardware so that can be called as "lower layer driver". After it control is passes through "file operations & working processes of driver" as "Bus Manager or Process Manager" to user controlling through "ioctl process" as "High level driver".

If user have to interact to device then "ioctl process" <--> "File operations" <--> "module_init & module_exit & partly file operations.".