What is regmap and syscon
regmap was introduced by https://lwn.net/Articles/451789/
From my understanding, it provided us a set API to read/write non memory-map I/O
(e.g. I2C and SPI read/write) at first. Then after introduced regmap-mmio.c,
we can use regmap to access memory-map I/O.
code path: drivers/base/regmap/*
syscon was introduced by https://lkml.org/lkml/2012/9/4/568
It provides a set API to access a misc device(e.g. pci-sas subsystem registers
in P660) based on regmap, explicitly based on regmap-mmio.c I guess.
code path: drivers/mfd/*
arch of regmap and syscon
basic structure of regmap:
struct regmap: per base address per regmap
struct regmap_bus: include read/write callback, different “bus”
(e.g. I2C, SPI, mmio) have different regmap_bus
struct regmap_mmio_context: don’t know…
struct regmap_config: confiuration info.
regmap-mmio call flow:
1 | /* drivers/base/regmap/regmap-mmio.c */ |
basic structure of syscon:
1 | struct syscon: include a strutct regmap; an element in list below |
why we need a syscon to describe a misc device
To understand this, we shoudl search related discussion in community:
https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-August/018704.html
From my understanding, syscon firstly registers a syscon dts node to syscon_list,
we could find this node when we try to access related registers.
how to use syscon to access a misc device
e.g.
1 | need dts node: |
use below function read/write:
1 | regmap_read(hisi_pcie->subctrl, PCIE_SUBCTRL_SYS_STATE4_REG + |
use below function create struct regmap:
1 | hisi_pcie->subctrl = |
reference:
- Documentation/devicetree/bindings/regmap/regmap.txt
- ../mfd/mfd.txt
- ./syscon.txt