regmap.h 25 KB

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