RegMap in linux




Why RegMap 


Linux is divided into many sub-systems in order to factor out common code in different parts and to simplify driver development, which helps in code maintenance.

Linux has sub-systems such as I2C and SPI, which are used to connect to devices that reside on these buses. Both these buses have the common function of reading and writing registers from the devices connected to them. So the code to read and write these registers, cache the value of the registers, etc, will have to be present in both these sub-systems. This causes redundant code to be present in all sub-systems that have this register read and write functionality.

To avoid this and to factor out common code, as well as for easy driver maintenance and development, Linux developers introduced a new kernel API from version 3.1, which is called regmap. This infrastructure was previously present in the Linux AsoC (ALSA) sub-system but has now been made available to entire Linux through the regmap API.

Earlier, if a driver was written for a device residing on the SPI bus, then the driver directly used the SPI bus read and write calls from the SPI subsystem to talk to the device. Now, it uses the regmap API to do so. The regmap sub-system takes care of calling the relevant calls of the SPI subsystem. So two devices—one residing on the I2C bus and one on the SPI bus—will have the same regmap read and write calls to talk to their respective devices on the bus.

sources:

https://www.opensourceforu.com/2017/01/regmap-reducing-redundancy-linux-code/

Comments

Popular posts from this blog

Overview of ISO/SAE 21434 Standard

Fundamental Secure Feature I: Secure Boot

Cryptography and Encryption Basics - I