regmap.h 23 KB

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