regmap.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. #ifndef __LINUX_REGMAP_H
  2. #define __LINUX_REGMAP_H
  3. /*
  4. * Register map access API
  5. *
  6. * Copyright 2011 Wolfson Microelectronics plc
  7. *
  8. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/list.h>
  15. #include <linux/rbtree.h>
  16. #include <linux/err.h>
  17. #include <linux/bug.h>
  18. struct module;
  19. struct device;
  20. struct i2c_client;
  21. struct irq_domain;
  22. struct spi_device;
  23. struct spmi_device;
  24. struct regmap;
  25. struct regmap_range_cfg;
  26. struct regmap_field;
  27. /* An enum of all the supported cache types */
  28. enum regcache_type {
  29. REGCACHE_NONE,
  30. REGCACHE_RBTREE,
  31. REGCACHE_COMPRESSED,
  32. REGCACHE_FLAT,
  33. };
  34. /**
  35. * Default value for a register. We use an array of structs rather
  36. * than a simple array as many modern devices have very sparse
  37. * register maps.
  38. *
  39. * @reg: Register address.
  40. * @def: Register default value.
  41. */
  42. struct reg_default {
  43. unsigned int reg;
  44. unsigned int def;
  45. };
  46. #ifdef CONFIG_REGMAP
  47. enum regmap_endian {
  48. /* Unspecified -> 0 -> Backwards compatible default */
  49. REGMAP_ENDIAN_DEFAULT = 0,
  50. REGMAP_ENDIAN_BIG,
  51. REGMAP_ENDIAN_LITTLE,
  52. REGMAP_ENDIAN_NATIVE,
  53. };
  54. /**
  55. * A register range, used for access related checks
  56. * (readable/writeable/volatile/precious checks)
  57. *
  58. * @range_min: address of first register
  59. * @range_max: address of last register
  60. */
  61. struct regmap_range {
  62. unsigned int range_min;
  63. unsigned int range_max;
  64. };
  65. /*
  66. * A table of ranges including some yes ranges and some no ranges.
  67. * If a register belongs to a no_range, the corresponding check function
  68. * will return false. If a register belongs to a yes range, the corresponding
  69. * check function will return true. "no_ranges" are searched first.
  70. *
  71. * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges"
  72. * @n_yes_ranges: size of the above array
  73. * @no_ranges: pointer to an array of regmap ranges used as "no ranges"
  74. * @n_no_ranges: size of the above array
  75. */
  76. struct regmap_access_table {
  77. const struct regmap_range *yes_ranges;
  78. unsigned int n_yes_ranges;
  79. const struct regmap_range *no_ranges;
  80. unsigned int n_no_ranges;
  81. };
  82. typedef void (*regmap_lock)(void *);
  83. typedef void (*regmap_unlock)(void *);
  84. /**
  85. * Configuration for the register map of a device.
  86. *
  87. * @name: Optional name of the regmap. Useful when a device has multiple
  88. * register regions.
  89. *
  90. * @reg_bits: Number of bits in a register address, mandatory.
  91. * @reg_stride: The register address stride. Valid register addresses are a
  92. * multiple of this value. If set to 0, a value of 1 will be
  93. * used.
  94. * @pad_bits: Number of bits of padding between register and value.
  95. * @val_bits: Number of bits in a register value, mandatory.
  96. *
  97. * @writeable_reg: Optional callback returning true if the register
  98. * can be written to. If this field is NULL but wr_table
  99. * (see below) is not, the check is performed on such table
  100. * (a register is writeable if it belongs to one of the ranges
  101. * specified by wr_table).
  102. * @readable_reg: Optional callback returning true if the register
  103. * can be read from. If this field is NULL but rd_table
  104. * (see below) is not, the check is performed on such table
  105. * (a register is readable if it belongs to one of the ranges
  106. * specified by rd_table).
  107. * @volatile_reg: Optional callback returning true if the register
  108. * value can't be cached. If this field is NULL but
  109. * volatile_table (see below) is not, the check is performed on
  110. * such table (a register is volatile if it belongs to one of
  111. * the ranges specified by volatile_table).
  112. * @precious_reg: Optional callback returning true if the rgister
  113. * should not be read outside of a call from the driver
  114. * (eg, a clear on read interrupt status register). If this
  115. * field is NULL but precious_table (see below) is not, the
  116. * check is performed on such table (a register is precious if
  117. * it belongs to one of the ranges specified by precious_table).
  118. * @lock: Optional lock callback (overrides regmap's default lock
  119. * function, based on spinlock or mutex).
  120. * @unlock: As above for unlocking.
  121. * @lock_arg: this field is passed as the only argument of lock/unlock
  122. * functions (ignored in case regular lock/unlock functions
  123. * are not overridden).
  124. * @reg_read: Optional callback that if filled will be used to perform
  125. * all the reads from the registers. Should only be provided for
  126. * devices whos read operation cannot be represented as a simple read
  127. * operation on a bus such as SPI, I2C, etc. Most of the devices do
  128. * not need this.
  129. * @reg_write: Same as above for writing.
  130. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
  131. * to perform locking. This field is ignored if custom lock/unlock
  132. * functions are used (see fields lock/unlock of struct regmap_config).
  133. * This field is a duplicate of a similar file in
  134. * 'struct regmap_bus' and serves exact same purpose.
  135. * Use it only for "no-bus" cases.
  136. * @max_register: Optional, specifies the maximum valid register index.
  137. * @wr_table: Optional, points to a struct regmap_access_table specifying
  138. * valid ranges for write access.
  139. * @rd_table: As above, for read access.
  140. * @volatile_table: As above, for volatile registers.
  141. * @precious_table: As above, for precious registers.
  142. * @reg_defaults: Power on reset values for registers (for use with
  143. * register cache support).
  144. * @num_reg_defaults: Number of elements in reg_defaults.
  145. *
  146. * @read_flag_mask: Mask to be set in the top byte of the register when doing
  147. * a read.
  148. * @write_flag_mask: Mask to be set in the top byte of the register when doing
  149. * a write. If both read_flag_mask and write_flag_mask are
  150. * empty the regmap_bus default masks are used.
  151. * @use_single_rw: If set, converts the bulk read and write operations into
  152. * a series of single read and write operations. This is useful
  153. * for device that does not support bulk read and write.
  154. *
  155. * @cache_type: The actual cache type.
  156. * @reg_defaults_raw: Power on reset values for registers (for use with
  157. * register cache support).
  158. * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
  159. * @reg_format_endian: Endianness for formatted register addresses. If this is
  160. * DEFAULT, the @reg_format_endian_default value from the
  161. * regmap bus is used.
  162. * @val_format_endian: Endianness for formatted register values. If this is
  163. * DEFAULT, the @reg_format_endian_default value from the
  164. * regmap bus is used.
  165. *
  166. * @ranges: Array of configuration entries for virtual address ranges.
  167. * @num_ranges: Number of range configuration entries.
  168. */
  169. struct regmap_config {
  170. const char *name;
  171. int reg_bits;
  172. int reg_stride;
  173. int pad_bits;
  174. int val_bits;
  175. bool (*writeable_reg)(struct device *dev, unsigned int reg);
  176. bool (*readable_reg)(struct device *dev, unsigned int reg);
  177. bool (*volatile_reg)(struct device *dev, unsigned int reg);
  178. bool (*precious_reg)(struct device *dev, unsigned int reg);
  179. regmap_lock lock;
  180. regmap_unlock unlock;
  181. void *lock_arg;
  182. int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
  183. int (*reg_write)(void *context, unsigned int reg, unsigned int val);
  184. bool fast_io;
  185. unsigned int max_register;
  186. const struct regmap_access_table *wr_table;
  187. const struct regmap_access_table *rd_table;
  188. const struct regmap_access_table *volatile_table;
  189. const struct regmap_access_table *precious_table;
  190. const struct reg_default *reg_defaults;
  191. unsigned int num_reg_defaults;
  192. enum regcache_type cache_type;
  193. const void *reg_defaults_raw;
  194. unsigned int num_reg_defaults_raw;
  195. u8 read_flag_mask;
  196. u8 write_flag_mask;
  197. bool use_single_rw;
  198. enum regmap_endian reg_format_endian;
  199. enum regmap_endian val_format_endian;
  200. const struct regmap_range_cfg *ranges;
  201. unsigned int num_ranges;
  202. };
  203. /**
  204. * Configuration for indirectly accessed or paged registers.
  205. * Registers, mapped to this virtual range, are accessed in two steps:
  206. * 1. page selector register update;
  207. * 2. access through data window registers.
  208. *
  209. * @name: Descriptive name for diagnostics
  210. *
  211. * @range_min: Address of the lowest register address in virtual range.
  212. * @range_max: Address of the highest register in virtual range.
  213. *
  214. * @page_sel_reg: Register with selector field.
  215. * @page_sel_mask: Bit shift for selector value.
  216. * @page_sel_shift: Bit mask for selector value.
  217. *
  218. * @window_start: Address of first (lowest) register in data window.
  219. * @window_len: Number of registers in data window.
  220. */
  221. struct regmap_range_cfg {
  222. const char *name;
  223. /* Registers of virtual address range */
  224. unsigned int range_min;
  225. unsigned int range_max;
  226. /* Page selector for indirect addressing */
  227. unsigned int selector_reg;
  228. unsigned int selector_mask;
  229. int selector_shift;
  230. /* Data window (per each page) */
  231. unsigned int window_start;
  232. unsigned int window_len;
  233. };
  234. struct regmap_async;
  235. typedef int (*regmap_hw_write)(void *context, const void *data,
  236. size_t count);
  237. typedef int (*regmap_hw_gather_write)(void *context,
  238. const void *reg, size_t reg_len,
  239. const void *val, size_t val_len);
  240. typedef int (*regmap_hw_async_write)(void *context,
  241. const void *reg, size_t reg_len,
  242. const void *val, size_t val_len,
  243. struct regmap_async *async);
  244. typedef int (*regmap_hw_read)(void *context,
  245. const void *reg_buf, size_t reg_size,
  246. void *val_buf, size_t val_size);
  247. typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
  248. typedef void (*regmap_hw_free_context)(void *context);
  249. /**
  250. * Description of a hardware bus for the register map infrastructure.
  251. *
  252. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
  253. * to perform locking. This field is ignored if custom lock/unlock
  254. * functions are used (see fields lock/unlock of
  255. * struct regmap_config).
  256. * @write: Write operation.
  257. * @gather_write: Write operation with split register/value, return -ENOTSUPP
  258. * if not implemented on a given device.
  259. * @async_write: Write operation which completes asynchronously, optional and
  260. * must serialise with respect to non-async I/O.
  261. * @read: Read operation. Data is returned in the buffer used to transmit
  262. * data.
  263. * @async_alloc: Allocate a regmap_async() structure.
  264. * @read_flag_mask: Mask to be set in the top byte of the register when doing
  265. * a read.
  266. * @reg_format_endian_default: Default endianness for formatted register
  267. * addresses. Used when the regmap_config specifies DEFAULT. If this is
  268. * DEFAULT, BIG is assumed.
  269. * @val_format_endian_default: Default endianness for formatted register
  270. * values. Used when the regmap_config specifies DEFAULT. If this is
  271. * DEFAULT, BIG is assumed.
  272. * @async_size: Size of struct used for async work.
  273. */
  274. struct regmap_bus {
  275. bool fast_io;
  276. regmap_hw_write write;
  277. regmap_hw_gather_write gather_write;
  278. regmap_hw_async_write async_write;
  279. regmap_hw_read read;
  280. regmap_hw_free_context free_context;
  281. regmap_hw_async_alloc async_alloc;
  282. u8 read_flag_mask;
  283. enum regmap_endian reg_format_endian_default;
  284. enum regmap_endian val_format_endian_default;
  285. };
  286. struct regmap *regmap_init(struct device *dev,
  287. const struct regmap_bus *bus,
  288. void *bus_context,
  289. const struct regmap_config *config);
  290. struct regmap *regmap_init_i2c(struct i2c_client *i2c,
  291. const struct regmap_config *config);
  292. struct regmap *regmap_init_spi(struct spi_device *dev,
  293. const struct regmap_config *config);
  294. struct regmap *regmap_init_spmi(struct spmi_device *dev,
  295. const struct regmap_config *config);
  296. struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  297. void __iomem *regs,
  298. const struct regmap_config *config);
  299. struct regmap *devm_regmap_init(struct device *dev,
  300. const struct regmap_bus *bus,
  301. void *bus_context,
  302. const struct regmap_config *config);
  303. struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
  304. const struct regmap_config *config);
  305. struct regmap *devm_regmap_init_spi(struct spi_device *dev,
  306. const struct regmap_config *config);
  307. struct regmap *devm_regmap_init_spmi(struct spmi_device *dev,
  308. const struct regmap_config *config);
  309. struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  310. void __iomem *regs,
  311. const struct regmap_config *config);
  312. /**
  313. * regmap_init_mmio(): Initialise register map
  314. *
  315. * @dev: Device that will be interacted with
  316. * @regs: Pointer to memory-mapped IO region
  317. * @config: Configuration for register map
  318. *
  319. * The return value will be an ERR_PTR() on error or a valid pointer to
  320. * a struct regmap.
  321. */
  322. static inline struct regmap *regmap_init_mmio(struct device *dev,
  323. void __iomem *regs,
  324. const struct regmap_config *config)
  325. {
  326. return regmap_init_mmio_clk(dev, NULL, regs, config);
  327. }
  328. /**
  329. * devm_regmap_init_mmio(): Initialise managed register map
  330. *
  331. * @dev: Device that will be interacted with
  332. * @regs: Pointer to memory-mapped IO region
  333. * @config: Configuration for register map
  334. *
  335. * The return value will be an ERR_PTR() on error or a valid pointer
  336. * to a struct regmap. The regmap will be automatically freed by the
  337. * device management code.
  338. */
  339. static inline struct regmap *devm_regmap_init_mmio(struct device *dev,
  340. void __iomem *regs,
  341. const struct regmap_config *config)
  342. {
  343. return devm_regmap_init_mmio_clk(dev, NULL, regs, config);
  344. }
  345. void regmap_exit(struct regmap *map);
  346. int regmap_reinit_cache(struct regmap *map,
  347. const struct regmap_config *config);
  348. struct regmap *dev_get_regmap(struct device *dev, const char *name);
  349. int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
  350. int regmap_raw_write(struct regmap *map, unsigned int reg,
  351. const void *val, size_t val_len);
  352. int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
  353. size_t val_count);
  354. int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  355. const void *val, size_t val_len);
  356. int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
  357. int regmap_raw_read(struct regmap *map, unsigned int reg,
  358. void *val, size_t val_len);
  359. int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
  360. size_t val_count);
  361. int regmap_update_bits(struct regmap *map, unsigned int reg,
  362. unsigned int mask, unsigned int val);
  363. int regmap_update_bits_check(struct regmap *map, unsigned int reg,
  364. unsigned int mask, unsigned int val,
  365. bool *change);
  366. int regmap_get_val_bytes(struct regmap *map);
  367. int regmap_async_complete(struct regmap *map);
  368. bool regmap_can_raw_write(struct regmap *map);
  369. int regcache_sync(struct regmap *map);
  370. int regcache_sync_region(struct regmap *map, unsigned int min,
  371. unsigned int max);
  372. int regcache_drop_region(struct regmap *map, unsigned int min,
  373. unsigned int max);
  374. void regcache_cache_only(struct regmap *map, bool enable);
  375. void regcache_cache_bypass(struct regmap *map, bool enable);
  376. void regcache_mark_dirty(struct regmap *map);
  377. bool regmap_check_range_table(struct regmap *map, unsigned int reg,
  378. const struct regmap_access_table *table);
  379. int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
  380. int num_regs);
  381. static inline bool regmap_reg_in_range(unsigned int reg,
  382. const struct regmap_range *range)
  383. {
  384. return reg >= range->range_min && reg <= range->range_max;
  385. }
  386. bool regmap_reg_in_ranges(unsigned int reg,
  387. const struct regmap_range *ranges,
  388. unsigned int nranges);
  389. /**
  390. * Description of an register field
  391. *
  392. * @reg: Offset of the register within the regmap bank
  393. * @lsb: lsb of the register field.
  394. * @reg: msb of the register field.
  395. */
  396. struct reg_field {
  397. unsigned int reg;
  398. unsigned int lsb;
  399. unsigned int msb;
  400. };
  401. #define REG_FIELD(_reg, _lsb, _msb) { \
  402. .reg = _reg, \
  403. .lsb = _lsb, \
  404. .msb = _msb, \
  405. }
  406. struct regmap_field *regmap_field_alloc(struct regmap *regmap,
  407. struct reg_field reg_field);
  408. void regmap_field_free(struct regmap_field *field);
  409. struct regmap_field *devm_regmap_field_alloc(struct device *dev,
  410. struct regmap *regmap, struct reg_field reg_field);
  411. void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
  412. int regmap_field_read(struct regmap_field *field, unsigned int *val);
  413. int regmap_field_write(struct regmap_field *field, unsigned int val);
  414. /**
  415. * Description of an IRQ for the generic regmap irq_chip.
  416. *
  417. * @reg_offset: Offset of the status/mask register within the bank
  418. * @mask: Mask used to flag/control the register.
  419. */
  420. struct regmap_irq {
  421. unsigned int reg_offset;
  422. unsigned int mask;
  423. };
  424. /**
  425. * Description of a generic regmap irq_chip. This is not intended to
  426. * handle every possible interrupt controller, but it should handle a
  427. * substantial proportion of those that are found in the wild.
  428. *
  429. * @name: Descriptive name for IRQ controller.
  430. *
  431. * @status_base: Base status register address.
  432. * @mask_base: Base mask register address.
  433. * @ack_base: Base ack address. If zero then the chip is clear on read.
  434. * @wake_base: Base address for wake enables. If zero unsupported.
  435. * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
  436. * @init_ack_masked: Ack all masked interrupts once during initalization.
  437. * @mask_invert: Inverted mask register: cleared bits are masked out.
  438. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  439. * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
  440. *
  441. * @num_regs: Number of registers in each control bank.
  442. * @irqs: Descriptors for individual IRQs. Interrupt numbers are
  443. * assigned based on the index in the array of the interrupt.
  444. * @num_irqs: Number of descriptors.
  445. */
  446. struct regmap_irq_chip {
  447. const char *name;
  448. unsigned int status_base;
  449. unsigned int mask_base;
  450. unsigned int ack_base;
  451. unsigned int wake_base;
  452. unsigned int irq_reg_stride;
  453. bool init_ack_masked:1;
  454. bool mask_invert:1;
  455. bool wake_invert:1;
  456. bool runtime_pm:1;
  457. int num_regs;
  458. const struct regmap_irq *irqs;
  459. int num_irqs;
  460. };
  461. struct regmap_irq_chip_data;
  462. int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
  463. int irq_base, const struct regmap_irq_chip *chip,
  464. struct regmap_irq_chip_data **data);
  465. void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
  466. int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  467. int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
  468. struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
  469. #else
  470. /*
  471. * These stubs should only ever be called by generic code which has
  472. * regmap based facilities, if they ever get called at runtime
  473. * something is going wrong and something probably needs to select
  474. * REGMAP.
  475. */
  476. static inline int regmap_write(struct regmap *map, unsigned int reg,
  477. unsigned int val)
  478. {
  479. WARN_ONCE(1, "regmap API is disabled");
  480. return -EINVAL;
  481. }
  482. static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
  483. const void *val, size_t val_len)
  484. {
  485. WARN_ONCE(1, "regmap API is disabled");
  486. return -EINVAL;
  487. }
  488. static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  489. const void *val, size_t val_len)
  490. {
  491. WARN_ONCE(1, "regmap API is disabled");
  492. return -EINVAL;
  493. }
  494. static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  495. const void *val, size_t val_count)
  496. {
  497. WARN_ONCE(1, "regmap API is disabled");
  498. return -EINVAL;
  499. }
  500. static inline int regmap_read(struct regmap *map, unsigned int reg,
  501. unsigned int *val)
  502. {
  503. WARN_ONCE(1, "regmap API is disabled");
  504. return -EINVAL;
  505. }
  506. static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  507. void *val, size_t val_len)
  508. {
  509. WARN_ONCE(1, "regmap API is disabled");
  510. return -EINVAL;
  511. }
  512. static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  513. void *val, size_t val_count)
  514. {
  515. WARN_ONCE(1, "regmap API is disabled");
  516. return -EINVAL;
  517. }
  518. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  519. unsigned int mask, unsigned int val)
  520. {
  521. WARN_ONCE(1, "regmap API is disabled");
  522. return -EINVAL;
  523. }
  524. static inline int regmap_update_bits_check(struct regmap *map,
  525. unsigned int reg,
  526. unsigned int mask, unsigned int val,
  527. bool *change)
  528. {
  529. WARN_ONCE(1, "regmap API is disabled");
  530. return -EINVAL;
  531. }
  532. static inline int regmap_get_val_bytes(struct regmap *map)
  533. {
  534. WARN_ONCE(1, "regmap API is disabled");
  535. return -EINVAL;
  536. }
  537. static inline int regcache_sync(struct regmap *map)
  538. {
  539. WARN_ONCE(1, "regmap API is disabled");
  540. return -EINVAL;
  541. }
  542. static inline int regcache_sync_region(struct regmap *map, unsigned int min,
  543. unsigned int max)
  544. {
  545. WARN_ONCE(1, "regmap API is disabled");
  546. return -EINVAL;
  547. }
  548. static inline int regcache_drop_region(struct regmap *map, unsigned int min,
  549. unsigned int max)
  550. {
  551. WARN_ONCE(1, "regmap API is disabled");
  552. return -EINVAL;
  553. }
  554. static inline void regcache_cache_only(struct regmap *map, bool enable)
  555. {
  556. WARN_ONCE(1, "regmap API is disabled");
  557. }
  558. static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  559. {
  560. WARN_ONCE(1, "regmap API is disabled");
  561. }
  562. static inline void regcache_mark_dirty(struct regmap *map)
  563. {
  564. WARN_ONCE(1, "regmap API is disabled");
  565. }
  566. static inline void regmap_async_complete(struct regmap *map)
  567. {
  568. WARN_ONCE(1, "regmap API is disabled");
  569. }
  570. static inline int regmap_register_patch(struct regmap *map,
  571. const struct reg_default *regs,
  572. int num_regs)
  573. {
  574. WARN_ONCE(1, "regmap API is disabled");
  575. return -EINVAL;
  576. }
  577. static inline struct regmap *dev_get_regmap(struct device *dev,
  578. const char *name)
  579. {
  580. return NULL;
  581. }
  582. #endif
  583. #endif