regmap.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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. * @can_multi_write: If set, the device supports the multi write mode of bulk
  156. * write operations, if clear multi write requests will be
  157. * split into individual write operations
  158. *
  159. * @cache_type: The actual cache type.
  160. * @reg_defaults_raw: Power on reset values for registers (for use with
  161. * register cache support).
  162. * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
  163. * @reg_format_endian: Endianness for formatted register addresses. If this is
  164. * DEFAULT, the @reg_format_endian_default value from the
  165. * regmap bus is used.
  166. * @val_format_endian: Endianness for formatted register values. If this is
  167. * DEFAULT, the @reg_format_endian_default value from the
  168. * regmap bus is used.
  169. *
  170. * @ranges: Array of configuration entries for virtual address ranges.
  171. * @num_ranges: Number of range configuration entries.
  172. */
  173. struct regmap_config {
  174. const char *name;
  175. int reg_bits;
  176. int reg_stride;
  177. int pad_bits;
  178. int val_bits;
  179. bool (*writeable_reg)(struct device *dev, unsigned int reg);
  180. bool (*readable_reg)(struct device *dev, unsigned int reg);
  181. bool (*volatile_reg)(struct device *dev, unsigned int reg);
  182. bool (*precious_reg)(struct device *dev, unsigned int reg);
  183. regmap_lock lock;
  184. regmap_unlock unlock;
  185. void *lock_arg;
  186. int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
  187. int (*reg_write)(void *context, unsigned int reg, unsigned int val);
  188. bool fast_io;
  189. unsigned int max_register;
  190. const struct regmap_access_table *wr_table;
  191. const struct regmap_access_table *rd_table;
  192. const struct regmap_access_table *volatile_table;
  193. const struct regmap_access_table *precious_table;
  194. const struct reg_default *reg_defaults;
  195. unsigned int num_reg_defaults;
  196. enum regcache_type cache_type;
  197. const void *reg_defaults_raw;
  198. unsigned int num_reg_defaults_raw;
  199. u8 read_flag_mask;
  200. u8 write_flag_mask;
  201. bool use_single_rw;
  202. bool can_multi_write;
  203. enum regmap_endian reg_format_endian;
  204. enum regmap_endian val_format_endian;
  205. const struct regmap_range_cfg *ranges;
  206. unsigned int num_ranges;
  207. };
  208. /**
  209. * Configuration for indirectly accessed or paged registers.
  210. * Registers, mapped to this virtual range, are accessed in two steps:
  211. * 1. page selector register update;
  212. * 2. access through data window registers.
  213. *
  214. * @name: Descriptive name for diagnostics
  215. *
  216. * @range_min: Address of the lowest register address in virtual range.
  217. * @range_max: Address of the highest register in virtual range.
  218. *
  219. * @page_sel_reg: Register with selector field.
  220. * @page_sel_mask: Bit shift for selector value.
  221. * @page_sel_shift: Bit mask for selector value.
  222. *
  223. * @window_start: Address of first (lowest) register in data window.
  224. * @window_len: Number of registers in data window.
  225. */
  226. struct regmap_range_cfg {
  227. const char *name;
  228. /* Registers of virtual address range */
  229. unsigned int range_min;
  230. unsigned int range_max;
  231. /* Page selector for indirect addressing */
  232. unsigned int selector_reg;
  233. unsigned int selector_mask;
  234. int selector_shift;
  235. /* Data window (per each page) */
  236. unsigned int window_start;
  237. unsigned int window_len;
  238. };
  239. struct regmap_async;
  240. typedef int (*regmap_hw_write)(void *context, const void *data,
  241. size_t count);
  242. typedef int (*regmap_hw_gather_write)(void *context,
  243. const void *reg, size_t reg_len,
  244. const void *val, size_t val_len);
  245. typedef int (*regmap_hw_async_write)(void *context,
  246. const void *reg, size_t reg_len,
  247. const void *val, size_t val_len,
  248. struct regmap_async *async);
  249. typedef int (*regmap_hw_read)(void *context,
  250. const void *reg_buf, size_t reg_size,
  251. void *val_buf, size_t val_size);
  252. typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
  253. unsigned int *val);
  254. typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
  255. unsigned int val);
  256. typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
  257. typedef void (*regmap_hw_free_context)(void *context);
  258. /**
  259. * Description of a hardware bus for the register map infrastructure.
  260. *
  261. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
  262. * to perform locking. This field is ignored if custom lock/unlock
  263. * functions are used (see fields lock/unlock of
  264. * struct regmap_config).
  265. * @write: Write operation.
  266. * @gather_write: Write operation with split register/value, return -ENOTSUPP
  267. * if not implemented on a given device.
  268. * @async_write: Write operation which completes asynchronously, optional and
  269. * must serialise with respect to non-async I/O.
  270. * @read: Read operation. Data is returned in the buffer used to transmit
  271. * data.
  272. * @async_alloc: Allocate a regmap_async() structure.
  273. * @read_flag_mask: Mask to be set in the top byte of the register when doing
  274. * a read.
  275. * @reg_format_endian_default: Default endianness for formatted register
  276. * addresses. Used when the regmap_config specifies DEFAULT. If this is
  277. * DEFAULT, BIG is assumed.
  278. * @val_format_endian_default: Default endianness for formatted register
  279. * values. Used when the regmap_config specifies DEFAULT. If this is
  280. * DEFAULT, BIG is assumed.
  281. * @async_size: Size of struct used for async work.
  282. */
  283. struct regmap_bus {
  284. bool fast_io;
  285. regmap_hw_write write;
  286. regmap_hw_gather_write gather_write;
  287. regmap_hw_async_write async_write;
  288. regmap_hw_reg_write reg_write;
  289. regmap_hw_read read;
  290. regmap_hw_reg_read reg_read;
  291. regmap_hw_free_context free_context;
  292. regmap_hw_async_alloc async_alloc;
  293. u8 read_flag_mask;
  294. enum regmap_endian reg_format_endian_default;
  295. enum regmap_endian val_format_endian_default;
  296. };
  297. struct regmap *regmap_init(struct device *dev,
  298. const struct regmap_bus *bus,
  299. void *bus_context,
  300. const struct regmap_config *config);
  301. int regmap_attach_dev(struct device *dev, struct regmap *map,
  302. const struct regmap_config *config);
  303. struct regmap *regmap_init_i2c(struct i2c_client *i2c,
  304. const struct regmap_config *config);
  305. struct regmap *regmap_init_spi(struct spi_device *dev,
  306. const struct regmap_config *config);
  307. struct regmap *regmap_init_spmi_base(struct spmi_device *dev,
  308. const struct regmap_config *config);
  309. struct regmap *regmap_init_spmi_ext(struct spmi_device *dev,
  310. const struct regmap_config *config);
  311. struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  312. void __iomem *regs,
  313. const struct regmap_config *config);
  314. struct regmap *devm_regmap_init(struct device *dev,
  315. const struct regmap_bus *bus,
  316. void *bus_context,
  317. const struct regmap_config *config);
  318. struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
  319. const struct regmap_config *config);
  320. struct regmap *devm_regmap_init_spi(struct spi_device *dev,
  321. const struct regmap_config *config);
  322. struct regmap *devm_regmap_init_spmi_base(struct spmi_device *dev,
  323. const struct regmap_config *config);
  324. struct regmap *devm_regmap_init_spmi_ext(struct spmi_device *dev,
  325. const struct regmap_config *config);
  326. struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  327. void __iomem *regs,
  328. const struct regmap_config *config);
  329. /**
  330. * regmap_init_mmio(): Initialise 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 to
  337. * a struct regmap.
  338. */
  339. static inline struct regmap *regmap_init_mmio(struct device *dev,
  340. void __iomem *regs,
  341. const struct regmap_config *config)
  342. {
  343. return regmap_init_mmio_clk(dev, NULL, regs, config);
  344. }
  345. /**
  346. * devm_regmap_init_mmio(): Initialise managed register map
  347. *
  348. * @dev: Device that will be interacted with
  349. * @regs: Pointer to memory-mapped IO region
  350. * @config: Configuration for register map
  351. *
  352. * The return value will be an ERR_PTR() on error or a valid pointer
  353. * to a struct regmap. The regmap will be automatically freed by the
  354. * device management code.
  355. */
  356. static inline struct regmap *devm_regmap_init_mmio(struct device *dev,
  357. void __iomem *regs,
  358. const struct regmap_config *config)
  359. {
  360. return devm_regmap_init_mmio_clk(dev, NULL, regs, config);
  361. }
  362. void regmap_exit(struct regmap *map);
  363. int regmap_reinit_cache(struct regmap *map,
  364. const struct regmap_config *config);
  365. struct regmap *dev_get_regmap(struct device *dev, const char *name);
  366. int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
  367. int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
  368. int regmap_raw_write(struct regmap *map, unsigned int reg,
  369. const void *val, size_t val_len);
  370. int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
  371. size_t val_count);
  372. int regmap_multi_reg_write(struct regmap *map, const struct reg_default *regs,
  373. int num_regs);
  374. int regmap_multi_reg_write_bypassed(struct regmap *map,
  375. const struct reg_default *regs,
  376. int num_regs);
  377. int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  378. const void *val, size_t val_len);
  379. int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
  380. int regmap_raw_read(struct regmap *map, unsigned int reg,
  381. void *val, size_t val_len);
  382. int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
  383. size_t val_count);
  384. int regmap_update_bits(struct regmap *map, unsigned int reg,
  385. unsigned int mask, unsigned int val);
  386. int regmap_update_bits_async(struct regmap *map, unsigned int reg,
  387. unsigned int mask, unsigned int val);
  388. int regmap_update_bits_check(struct regmap *map, unsigned int reg,
  389. unsigned int mask, unsigned int val,
  390. bool *change);
  391. int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
  392. unsigned int mask, unsigned int val,
  393. bool *change);
  394. int regmap_get_val_bytes(struct regmap *map);
  395. int regmap_async_complete(struct regmap *map);
  396. bool regmap_can_raw_write(struct regmap *map);
  397. int regcache_sync(struct regmap *map);
  398. int regcache_sync_region(struct regmap *map, unsigned int min,
  399. unsigned int max);
  400. int regcache_drop_region(struct regmap *map, unsigned int min,
  401. unsigned int max);
  402. void regcache_cache_only(struct regmap *map, bool enable);
  403. void regcache_cache_bypass(struct regmap *map, bool enable);
  404. void regcache_mark_dirty(struct regmap *map);
  405. bool regmap_check_range_table(struct regmap *map, unsigned int reg,
  406. const struct regmap_access_table *table);
  407. int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
  408. int num_regs);
  409. int regmap_parse_val(struct regmap *map, const void *buf,
  410. unsigned int *val);
  411. static inline bool regmap_reg_in_range(unsigned int reg,
  412. const struct regmap_range *range)
  413. {
  414. return reg >= range->range_min && reg <= range->range_max;
  415. }
  416. bool regmap_reg_in_ranges(unsigned int reg,
  417. const struct regmap_range *ranges,
  418. unsigned int nranges);
  419. /**
  420. * Description of an register field
  421. *
  422. * @reg: Offset of the register within the regmap bank
  423. * @lsb: lsb of the register field.
  424. * @reg: msb of the register field.
  425. * @id_size: port size if it has some ports
  426. * @id_offset: address offset for each ports
  427. */
  428. struct reg_field {
  429. unsigned int reg;
  430. unsigned int lsb;
  431. unsigned int msb;
  432. unsigned int id_size;
  433. unsigned int id_offset;
  434. };
  435. #define REG_FIELD(_reg, _lsb, _msb) { \
  436. .reg = _reg, \
  437. .lsb = _lsb, \
  438. .msb = _msb, \
  439. }
  440. struct regmap_field *regmap_field_alloc(struct regmap *regmap,
  441. struct reg_field reg_field);
  442. void regmap_field_free(struct regmap_field *field);
  443. struct regmap_field *devm_regmap_field_alloc(struct device *dev,
  444. struct regmap *regmap, struct reg_field reg_field);
  445. void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
  446. int regmap_field_read(struct regmap_field *field, unsigned int *val);
  447. int regmap_field_write(struct regmap_field *field, unsigned int val);
  448. int regmap_field_update_bits(struct regmap_field *field,
  449. unsigned int mask, unsigned int val);
  450. int regmap_fields_write(struct regmap_field *field, unsigned int id,
  451. unsigned int val);
  452. int regmap_fields_read(struct regmap_field *field, unsigned int id,
  453. unsigned int *val);
  454. int regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
  455. unsigned int mask, unsigned int val);
  456. /**
  457. * Description of an IRQ for the generic regmap irq_chip.
  458. *
  459. * @reg_offset: Offset of the status/mask register within the bank
  460. * @mask: Mask used to flag/control the register.
  461. */
  462. struct regmap_irq {
  463. unsigned int reg_offset;
  464. unsigned int mask;
  465. };
  466. /**
  467. * Description of a generic regmap irq_chip. This is not intended to
  468. * handle every possible interrupt controller, but it should handle a
  469. * substantial proportion of those that are found in the wild.
  470. *
  471. * @name: Descriptive name for IRQ controller.
  472. *
  473. * @status_base: Base status register address.
  474. * @mask_base: Base mask register address.
  475. * @ack_base: Base ack address. If zero then the chip is clear on read.
  476. * Using zero value is possible with @use_ack bit.
  477. * @wake_base: Base address for wake enables. If zero unsupported.
  478. * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
  479. * @init_ack_masked: Ack all masked interrupts once during initalization.
  480. * @mask_invert: Inverted mask register: cleared bits are masked out.
  481. * @use_ack: Use @ack register even if it is zero.
  482. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  483. * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
  484. *
  485. * @num_regs: Number of registers in each control bank.
  486. * @irqs: Descriptors for individual IRQs. Interrupt numbers are
  487. * assigned based on the index in the array of the interrupt.
  488. * @num_irqs: Number of descriptors.
  489. */
  490. struct regmap_irq_chip {
  491. const char *name;
  492. unsigned int status_base;
  493. unsigned int mask_base;
  494. unsigned int ack_base;
  495. unsigned int wake_base;
  496. unsigned int irq_reg_stride;
  497. bool init_ack_masked:1;
  498. bool mask_invert:1;
  499. bool use_ack:1;
  500. bool wake_invert:1;
  501. bool runtime_pm:1;
  502. int num_regs;
  503. const struct regmap_irq *irqs;
  504. int num_irqs;
  505. };
  506. struct regmap_irq_chip_data;
  507. int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
  508. int irq_base, const struct regmap_irq_chip *chip,
  509. struct regmap_irq_chip_data **data);
  510. void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
  511. int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  512. int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
  513. struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
  514. #else
  515. /*
  516. * These stubs should only ever be called by generic code which has
  517. * regmap based facilities, if they ever get called at runtime
  518. * something is going wrong and something probably needs to select
  519. * REGMAP.
  520. */
  521. static inline int regmap_write(struct regmap *map, unsigned int reg,
  522. unsigned int val)
  523. {
  524. WARN_ONCE(1, "regmap API is disabled");
  525. return -EINVAL;
  526. }
  527. static inline int regmap_write_async(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_write(struct regmap *map, unsigned int reg,
  534. const void *val, size_t val_len)
  535. {
  536. WARN_ONCE(1, "regmap API is disabled");
  537. return -EINVAL;
  538. }
  539. static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  540. const void *val, size_t val_len)
  541. {
  542. WARN_ONCE(1, "regmap API is disabled");
  543. return -EINVAL;
  544. }
  545. static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  546. const void *val, size_t val_count)
  547. {
  548. WARN_ONCE(1, "regmap API is disabled");
  549. return -EINVAL;
  550. }
  551. static inline int regmap_read(struct regmap *map, unsigned int reg,
  552. unsigned int *val)
  553. {
  554. WARN_ONCE(1, "regmap API is disabled");
  555. return -EINVAL;
  556. }
  557. static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  558. void *val, size_t val_len)
  559. {
  560. WARN_ONCE(1, "regmap API is disabled");
  561. return -EINVAL;
  562. }
  563. static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  564. void *val, size_t val_count)
  565. {
  566. WARN_ONCE(1, "regmap API is disabled");
  567. return -EINVAL;
  568. }
  569. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  570. unsigned int mask, unsigned int val)
  571. {
  572. WARN_ONCE(1, "regmap API is disabled");
  573. return -EINVAL;
  574. }
  575. static inline int regmap_update_bits_async(struct regmap *map,
  576. unsigned int reg,
  577. unsigned int mask, unsigned int val)
  578. {
  579. WARN_ONCE(1, "regmap API is disabled");
  580. return -EINVAL;
  581. }
  582. static inline int regmap_update_bits_check(struct regmap *map,
  583. unsigned int reg,
  584. unsigned int mask, unsigned int val,
  585. bool *change)
  586. {
  587. WARN_ONCE(1, "regmap API is disabled");
  588. return -EINVAL;
  589. }
  590. static inline int regmap_update_bits_check_async(struct regmap *map,
  591. unsigned int reg,
  592. unsigned int mask,
  593. unsigned int val,
  594. bool *change)
  595. {
  596. WARN_ONCE(1, "regmap API is disabled");
  597. return -EINVAL;
  598. }
  599. static inline int regmap_get_val_bytes(struct regmap *map)
  600. {
  601. WARN_ONCE(1, "regmap API is disabled");
  602. return -EINVAL;
  603. }
  604. static inline int regcache_sync(struct regmap *map)
  605. {
  606. WARN_ONCE(1, "regmap API is disabled");
  607. return -EINVAL;
  608. }
  609. static inline int regcache_sync_region(struct regmap *map, unsigned int min,
  610. unsigned int max)
  611. {
  612. WARN_ONCE(1, "regmap API is disabled");
  613. return -EINVAL;
  614. }
  615. static inline int regcache_drop_region(struct regmap *map, unsigned int min,
  616. unsigned int max)
  617. {
  618. WARN_ONCE(1, "regmap API is disabled");
  619. return -EINVAL;
  620. }
  621. static inline void regcache_cache_only(struct regmap *map, bool enable)
  622. {
  623. WARN_ONCE(1, "regmap API is disabled");
  624. }
  625. static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  626. {
  627. WARN_ONCE(1, "regmap API is disabled");
  628. }
  629. static inline void regcache_mark_dirty(struct regmap *map)
  630. {
  631. WARN_ONCE(1, "regmap API is disabled");
  632. }
  633. static inline void regmap_async_complete(struct regmap *map)
  634. {
  635. WARN_ONCE(1, "regmap API is disabled");
  636. }
  637. static inline int regmap_register_patch(struct regmap *map,
  638. const struct reg_default *regs,
  639. int num_regs)
  640. {
  641. WARN_ONCE(1, "regmap API is disabled");
  642. return -EINVAL;
  643. }
  644. static inline int regmap_parse_val(struct regmap *map, const void *buf,
  645. unsigned int *val)
  646. {
  647. WARN_ONCE(1, "regmap API is disabled");
  648. return -EINVAL;
  649. }
  650. static inline struct regmap *dev_get_regmap(struct device *dev,
  651. const char *name)
  652. {
  653. return NULL;
  654. }
  655. #endif
  656. #endif