regmap.h 21 KB

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