regmap.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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 register
  114. * should not be read outside of a call from the driver
  115. * (e.g., 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 whose read operation cannot be represented as a simple
  128. * read operation on a bus such as SPI, I2C, etc. Most of the
  129. * devices do 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. int regmap_parse_val(struct regmap *map, const void *buf,
  391. unsigned int *val);
  392. static inline bool regmap_reg_in_range(unsigned int reg,
  393. const struct regmap_range *range)
  394. {
  395. return reg >= range->range_min && reg <= range->range_max;
  396. }
  397. bool regmap_reg_in_ranges(unsigned int reg,
  398. const struct regmap_range *ranges,
  399. unsigned int nranges);
  400. /**
  401. * Description of an register field
  402. *
  403. * @reg: Offset of the register within the regmap bank
  404. * @lsb: lsb of the register field.
  405. * @reg: msb of the register field.
  406. * @id_size: port size if it has some ports
  407. * @id_offset: address offset for each ports
  408. */
  409. struct reg_field {
  410. unsigned int reg;
  411. unsigned int lsb;
  412. unsigned int msb;
  413. unsigned int id_size;
  414. unsigned int id_offset;
  415. };
  416. #define REG_FIELD(_reg, _lsb, _msb) { \
  417. .reg = _reg, \
  418. .lsb = _lsb, \
  419. .msb = _msb, \
  420. }
  421. struct regmap_field *regmap_field_alloc(struct regmap *regmap,
  422. struct reg_field reg_field);
  423. void regmap_field_free(struct regmap_field *field);
  424. struct regmap_field *devm_regmap_field_alloc(struct device *dev,
  425. struct regmap *regmap, struct reg_field reg_field);
  426. void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
  427. int regmap_field_read(struct regmap_field *field, unsigned int *val);
  428. int regmap_field_write(struct regmap_field *field, unsigned int val);
  429. int regmap_field_update_bits(struct regmap_field *field,
  430. unsigned int mask, unsigned int val);
  431. int regmap_fields_write(struct regmap_field *field, unsigned int id,
  432. unsigned int val);
  433. int regmap_fields_read(struct regmap_field *field, unsigned int id,
  434. unsigned int *val);
  435. int regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
  436. unsigned int mask, unsigned int val);
  437. /**
  438. * Description of an IRQ for the generic regmap irq_chip.
  439. *
  440. * @reg_offset: Offset of the status/mask register within the bank
  441. * @mask: Mask used to flag/control the register.
  442. */
  443. struct regmap_irq {
  444. unsigned int reg_offset;
  445. unsigned int mask;
  446. };
  447. /**
  448. * Description of a generic regmap irq_chip. This is not intended to
  449. * handle every possible interrupt controller, but it should handle a
  450. * substantial proportion of those that are found in the wild.
  451. *
  452. * @name: Descriptive name for IRQ controller.
  453. *
  454. * @status_base: Base status register address.
  455. * @mask_base: Base mask register address.
  456. * @ack_base: Base ack address. If zero then the chip is clear on read.
  457. * Using zero value is possible with @use_ack bit.
  458. * @wake_base: Base address for wake enables. If zero unsupported.
  459. * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
  460. * @init_ack_masked: Ack all masked interrupts once during initalization.
  461. * @mask_invert: Inverted mask register: cleared bits are masked out.
  462. * @use_ack: Use @ack register even if it is zero.
  463. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  464. * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
  465. *
  466. * @num_regs: Number of registers in each control bank.
  467. * @irqs: Descriptors for individual IRQs. Interrupt numbers are
  468. * assigned based on the index in the array of the interrupt.
  469. * @num_irqs: Number of descriptors.
  470. */
  471. struct regmap_irq_chip {
  472. const char *name;
  473. unsigned int status_base;
  474. unsigned int mask_base;
  475. unsigned int ack_base;
  476. unsigned int wake_base;
  477. unsigned int irq_reg_stride;
  478. bool init_ack_masked:1;
  479. bool mask_invert:1;
  480. bool use_ack:1;
  481. bool wake_invert:1;
  482. bool runtime_pm:1;
  483. int num_regs;
  484. const struct regmap_irq *irqs;
  485. int num_irqs;
  486. };
  487. struct regmap_irq_chip_data;
  488. int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
  489. int irq_base, const struct regmap_irq_chip *chip,
  490. struct regmap_irq_chip_data **data);
  491. void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
  492. int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  493. int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
  494. struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
  495. #else
  496. /*
  497. * These stubs should only ever be called by generic code which has
  498. * regmap based facilities, if they ever get called at runtime
  499. * something is going wrong and something probably needs to select
  500. * REGMAP.
  501. */
  502. static inline int regmap_write(struct regmap *map, unsigned int reg,
  503. unsigned int val)
  504. {
  505. WARN_ONCE(1, "regmap API is disabled");
  506. return -EINVAL;
  507. }
  508. static inline int regmap_write_async(struct regmap *map, unsigned int reg,
  509. unsigned int val)
  510. {
  511. WARN_ONCE(1, "regmap API is disabled");
  512. return -EINVAL;
  513. }
  514. static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
  515. const void *val, size_t val_len)
  516. {
  517. WARN_ONCE(1, "regmap API is disabled");
  518. return -EINVAL;
  519. }
  520. static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  521. const void *val, size_t val_len)
  522. {
  523. WARN_ONCE(1, "regmap API is disabled");
  524. return -EINVAL;
  525. }
  526. static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  527. const void *val, size_t val_count)
  528. {
  529. WARN_ONCE(1, "regmap API is disabled");
  530. return -EINVAL;
  531. }
  532. static inline int regmap_read(struct regmap *map, unsigned int reg,
  533. unsigned int *val)
  534. {
  535. WARN_ONCE(1, "regmap API is disabled");
  536. return -EINVAL;
  537. }
  538. static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  539. void *val, size_t val_len)
  540. {
  541. WARN_ONCE(1, "regmap API is disabled");
  542. return -EINVAL;
  543. }
  544. static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  545. void *val, size_t val_count)
  546. {
  547. WARN_ONCE(1, "regmap API is disabled");
  548. return -EINVAL;
  549. }
  550. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  551. unsigned int mask, unsigned int val)
  552. {
  553. WARN_ONCE(1, "regmap API is disabled");
  554. return -EINVAL;
  555. }
  556. static inline int regmap_update_bits_async(struct regmap *map,
  557. unsigned int reg,
  558. unsigned int mask, unsigned int val)
  559. {
  560. WARN_ONCE(1, "regmap API is disabled");
  561. return -EINVAL;
  562. }
  563. static inline int regmap_update_bits_check(struct regmap *map,
  564. unsigned int reg,
  565. unsigned int mask, unsigned int val,
  566. bool *change)
  567. {
  568. WARN_ONCE(1, "regmap API is disabled");
  569. return -EINVAL;
  570. }
  571. static inline int regmap_update_bits_check_async(struct regmap *map,
  572. unsigned int reg,
  573. unsigned int mask,
  574. unsigned int val,
  575. bool *change)
  576. {
  577. WARN_ONCE(1, "regmap API is disabled");
  578. return -EINVAL;
  579. }
  580. static inline int regmap_get_val_bytes(struct regmap *map)
  581. {
  582. WARN_ONCE(1, "regmap API is disabled");
  583. return -EINVAL;
  584. }
  585. static inline int regcache_sync(struct regmap *map)
  586. {
  587. WARN_ONCE(1, "regmap API is disabled");
  588. return -EINVAL;
  589. }
  590. static inline int regcache_sync_region(struct regmap *map, unsigned int min,
  591. unsigned int max)
  592. {
  593. WARN_ONCE(1, "regmap API is disabled");
  594. return -EINVAL;
  595. }
  596. static inline int regcache_drop_region(struct regmap *map, unsigned int min,
  597. unsigned int max)
  598. {
  599. WARN_ONCE(1, "regmap API is disabled");
  600. return -EINVAL;
  601. }
  602. static inline void regcache_cache_only(struct regmap *map, bool enable)
  603. {
  604. WARN_ONCE(1, "regmap API is disabled");
  605. }
  606. static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  607. {
  608. WARN_ONCE(1, "regmap API is disabled");
  609. }
  610. static inline void regcache_mark_dirty(struct regmap *map)
  611. {
  612. WARN_ONCE(1, "regmap API is disabled");
  613. }
  614. static inline void regmap_async_complete(struct regmap *map)
  615. {
  616. WARN_ONCE(1, "regmap API is disabled");
  617. }
  618. static inline int regmap_register_patch(struct regmap *map,
  619. const struct reg_default *regs,
  620. int num_regs)
  621. {
  622. WARN_ONCE(1, "regmap API is disabled");
  623. return -EINVAL;
  624. }
  625. static inline int regmap_parse_val(struct regmap *map, const void *buf,
  626. unsigned int *val)
  627. {
  628. WARN_ONCE(1, "regmap API is disabled");
  629. return -EINVAL;
  630. }
  631. static inline struct regmap *dev_get_regmap(struct device *dev,
  632. const char *name)
  633. {
  634. return NULL;
  635. }
  636. #endif
  637. #endif