regmap.h 26 KB

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