linux syscon and regmap study note
来源:互联网 发布:梦幻西游mac版是什么 编辑:程序博客网 时间:2024/05/13 06:10
linux syscon and regmap study note
-v0.1 2015.9.19 Sherlock draft
1. 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/*
2. 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:
/* drivers/base/regmap/regmap-mmio.c */__devm_regmap_init_mmio_clk --> __devm_regmap_init /* regmap_bus(regmap_mmio), config as input, create regmap */ --> __regmap_init /* if don't have bus->read or bus->write */ --> map->reg_read = _regmap_bus_reg_read; --> map->reg_write = _regmap_bus_reg_write; ... /* if have bus->read */ --> map->reg_read = _regmap_bus_read; --> map->bus->read/* drivers/base/regmap/regmap.c */regmap_read(struct regmap *map, unsigned int reg, unsigned int *val) --> _regmap_read /* _regmap_bus_reg_read */ --> map->reg_read(context, reg, val); --> map->bus->reg_read(map->bus_context, reg, val)/* drivers/base/regmap/regmap.c */regmap_update_bits --> _regmap_update_bits --> _regmap_read --> _regmap_write --> map->reg_write
basic structure of syscon:
struct syscon: include a strutct regmap; an element in list belowstatic LIST_HEAD(syscon_list)syscon driver init a regmap:syscon->regmap = devm_regmap_init_mmio(dev, base, &syscon_regmap_config);
3. 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.
4. how to use syscon to access a misc device
e.g.
need dts node: pcie_sas: pcie_sas@0xb0000000 { compatible = "hisilicon,pcie-sas-subctrl", "syscon"; reg = <0xb0000000 0x10000>; };
use below function read/write:
regmap_read(hisi_pcie->subctrl, PCIE_SUBCTRL_SYS_STATE4_REG + 0x100 * hisi_pcie->port_id, &val); regmap_update_bits(pcie->subctrl, reg, bit_mask, mode << bit_shift);
use below function create struct regmap:
hisi_pcie->subctrl = syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl");
reference:
- Documentation/devicetree/bindings/regmap/regmap.txt
- ../mfd/mfd.txt
- ./syscon.txt
- linux syscon and regmap study note
- struct regmap *syscon;初始化
- Linux study Note
- Linux (ubuntu) Study Note
- linux-0.11 study note
- Linux Shell study note
- My Linux Study Note(一)
- My Linux Study Note (三)
- My Linux Study Note (四)
- Note for linux dirver study
- My Linux Study Note (五)
- My Linux Study Note (六)
- My Linux Study Note (七)
- My Linux Study Note (八)
- Note for linux dirver study
- Java Study Note:Reference and Object
- Study note about bulk import and export data in MSSQL
- Study Note: Schedule Optimisation and math_intrinsic in CUDA Programming
- 构建完整的机器人应用系统
- hihoCoder 1228 Mission Impossible 6 2015北京网络赛 大模拟
- 员工管理-遍历(递归)
- http协议
- 潘鹏整理WPF(5)滚动条ScrollViewer
- linux syscon and regmap study note
- google如何恢复误删除书签
- 23设计模式之组合模式(Composite)
- OCP-V13-702
- java注解(1)
- 【软考之路】操作系统—进程
- 黑马程序员-关于配置环境变量
- Git 相关
- LibRTMP源代码分析4