internal.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Register map access API internal header
  3. *
  4. * Copyright 2011 Wolfson Microelectronics plc
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef _REGMAP_INTERNAL_H
  13. #define _REGMAP_INTERNAL_H
  14. #include <linux/regmap.h>
  15. #include <linux/fs.h>
  16. struct regmap;
  17. struct regmap_format {
  18. size_t buf_size;
  19. size_t reg_bytes;
  20. size_t val_bytes;
  21. void (*format_write)(struct regmap *map,
  22. unsigned int reg, unsigned int val);
  23. void (*format_reg)(void *buf, unsigned int reg);
  24. void (*format_val)(void *buf, unsigned int val);
  25. unsigned int (*parse_val)(void *buf);
  26. };
  27. struct regmap {
  28. struct mutex lock;
  29. struct device *dev; /* Device we do I/O on */
  30. void *work_buf; /* Scratch buffer used to format I/O */
  31. struct regmap_format format; /* Buffer format */
  32. const struct regmap_bus *bus;
  33. #ifdef CONFIG_DEBUG_FS
  34. struct dentry *debugfs;
  35. #endif
  36. unsigned int max_register;
  37. bool (*writeable_reg)(struct device *dev, unsigned int reg);
  38. bool (*readable_reg)(struct device *dev, unsigned int reg);
  39. bool (*volatile_reg)(struct device *dev, unsigned int reg);
  40. bool (*precious_reg)(struct device *dev, unsigned int reg);
  41. };
  42. bool regmap_writeable(struct regmap *map, unsigned int reg);
  43. bool regmap_readable(struct regmap *map, unsigned int reg);
  44. bool regmap_volatile(struct regmap *map, unsigned int reg);
  45. bool regmap_precious(struct regmap *map, unsigned int reg);
  46. #ifdef CONFIG_DEBUG_FS
  47. extern void regmap_debugfs_initcall(void);
  48. extern void regmap_debugfs_init(struct regmap *map);
  49. extern void regmap_debugfs_exit(struct regmap *map);
  50. #else
  51. void regmap_debugfs_initcall(void) { }
  52. void regmap_debugfs_init(struct regmap *map) { }
  53. void regmap_debugfs_exit(struct regmap *map) { }
  54. #endif
  55. #endif