Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

A regmap example

To achieve our goal, let's first describe a fake SPI device for which we can write a driver:

  • 8-bit register address
  • 8-bit register values
  • Max register: 0x80
  • The write mask is 0x80
  • Valid address range:
    • 0x20 to 0x4F
    • 0x60 to 0x7F
  • No custom read/write function needed

The following is a fake skeleton:

/* mandatory for regmap */ #include <linux/regmap.h> /* Depending on your need you should include other files */ static struct private_struct { /* Feel free to add whatever you want here */ struct regmap *map; int foo; }; static const struct regmap_range wr_rd_range[] = { { .range_min = 0x20, .range_max = 0x4F, },{ .range_min = 0x60, .range_max = 0x7F }, }; struct regmap_access_table drv_wr_table = { .yes_ranges = wr_rd_range, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content