Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define XXX_REG_STATUS 0x06
- #define XXX_REG_CTRL0 0x07
- #define XXX_REG_CTRL1 0x08
- static bool xxx_is_writeable_reg(struct device *dev, unsigned int reg)
- {
- switch (reg) {
- case XXX_REG_CTRL0:
- case XXX_REG_CTRL1:
- return true;
- default:
- return false;
- }
- }
- static bool xxx_is_readable_reg(struct device *dev, unsigned int reg)
- {
- switch (reg) {
- case XXX_REG_XOUT_L:
- case XXX_REG_XOUT_H:
- case XXX_REG_YOUT_L:
- case XXX_REG_YOUT_H:
- case XXX_REG_ZOUT_L:
- case XXX_REG_ZOUT_H:
- case XXX_REG_STATUS:
- case XXX_REG_ID:
- return true;
- default:
- return false;
- }
- }
- static bool xxx_is_volatile_reg(struct device *dev, unsigned int reg)
- {
- switch (reg) {
- case XXX_REG_CTRL0:
- case XXX_REG_CTRL1:
- case XXX_REG_STATUS:
- return false;
- default:
- return true;
- }
- }
- static struct reg_default xxx_reg_defaults[] = {
- { XXX_REG_CTRL0, 0x00 },
- { XXX_REG_CTRL1, 0x00 },
- { XXX_REG_STATUS, 0x00 },
- };
- static const struct regmap_config xxx_regmap_config = {
- .name = XXX_REGMAP_NAME,
- .reg_bits = 8,
- .val_bits = 8,
- .max_register = XXX_REG_ID,
- .cache_type = REGCACHE_RBTREE,
- .writeable_reg = xxx_is_writeable_reg,
- .readable_reg = xxx_is_readable_reg,
- .volatile_reg = xxx_is_volatile_reg,
- .reg_defaults = xxx_reg_defaults,
- .num_reg_defaults = ARRAY_SIZE(xxx_reg_defaults),
- };
Advertisement
Add Comment
Please, Sign In to add comment