regmap.h 25 KB

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