Skip to content

regmap debugfs

Russ Weight edited this page Dec 9, 2021 · 13 revisions

The DFL driver makes extensive use of the regmap framework in the linux kernel. The following are some examples of regmaps used by DFL drivers:

If the kernel is configured with CONFIG_DEBUG_FS enabled, a directory under /sys/kernel/debug/regmap will be created for each suitably configured regmap object that is created in the kernel. The created directory will have the following file entries:

  • name - the driver name associated with the regmap
  • range - the valid register ranges of the regmap
  • registers - the file used to read and write the actual registers associated with the regmap
  • access - an encoding of the various access permissions to each register

At a minimum, a regmap created in the kernel must have a non-zero max_register field in its configuration. Additionally access tables can be provided to give a more detailed description of the regmap.

By default, the registers are read only, and one can read all the registers in the regmap by simply cat'ng the registers file. However, cat'ng the registers file of a very large or very slow regmap can take a long time (e.g. cat'ng the Intel Max10 BMC regmap can take an hour). The regmap_debugfs python module can be used to more precisely and programmatically interact with large regmaps by providing API to read and write individual registers in a regmap.

Giving write access to regmaps via debugfs is considered somewhat dangerous. Therefore one must manually enable writing from debugfs by actually editing regmap-debugfs.c. The kernel in the fpga-ofs-dev branch has this change enabled. This change is intended for development and hardware bring up only. You can enable write support for debugfs in your kernel source by including this patch.

The full functionality described above supporting 3 different regmaps in the kernel was introduced in fpga-upstream-dev-5.9-rc1 branch. Debugfs support for the Intel Max10 BMC regmap is also available in the fpga-ofs-dev-5.7.0 and fpga-ofs-dev-5.8.0 branches.