regmap.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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. * @reg_write: Write a single register value to the given register address. This
  272. * write operation has to complete when returning from the function.
  273. * @read: Read operation. Data is returned in the buffer used to transmit
  274. * data.
  275. * @reg_read: Read a single register value from a given register address.
  276. * @free_context: Free context.
  277. * @async_alloc: Allocate a regmap_async() structure.
  278. * @read_flag_mask: Mask to be set in the top byte of the register when doing
  279. * a read.
  280. * @reg_format_endian_default: Default endianness for formatted register
  281. * addresses. Used when the regmap_config specifies DEFAULT. If this is
  282. * DEFAULT, BIG is assumed.
  283. * @val_format_endian_default: Default endianness for formatted register
  284. * values. Used when the regmap_config specifies DEFAULT. If this is
  285. * DEFAULT, BIG is assumed.
  286. */
  287. struct regmap_bus {
  288. bool fast_io;
  289. regmap_hw_write write;
  290. regmap_hw_gather_write gather_write;
  291. regmap_hw_async_write async_write;
  292. regmap_hw_reg_write reg_write;
  293. regmap_hw_read read;
  294. regmap_hw_reg_read reg_read;
  295. regmap_hw_free_context free_context;
  296. regmap_hw_async_alloc async_alloc;
  297. u8 read_flag_mask;
  298. enum regmap_endian reg_format_endian_default;
  299. enum regmap_endian val_format_endian_default;
  300. };
  301. struct regmap *regmap_init(struct device *dev,
  302. const struct regmap_bus *bus,
  303. void *bus_context,
  304. const struct regmap_config *config);
  305. int regmap_attach_dev(struct device *dev, struct regmap *map,
  306. const struct regmap_config *config);
  307. struct regmap *regmap_init_i2c(struct i2c_client *i2c,
  308. const struct regmap_config *config);
  309. struct regmap *regmap_init_spi(struct spi_device *dev,
  310. const struct regmap_config *config);
  311. struct regmap *regmap_init_spmi_base(struct spmi_device *dev,
  312. const struct regmap_config *config);
  313. struct regmap *regmap_init_spmi_ext(struct spmi_device *dev,
  314. const struct regmap_config *config);
  315. struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  316. void __iomem *regs,
  317. const struct regmap_config *config);
  318. struct regmap *regmap_init_ac97(struct snd_ac97 *ac97,
  319. const struct regmap_config *config);
  320. struct regmap *devm_regmap_init(struct device *dev,
  321. const struct regmap_bus *bus,
  322. void *bus_context,
  323. const struct regmap_config *config);
  324. struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
  325. const struct regmap_config *config);
  326. struct regmap *devm_regmap_init_spi(struct spi_device *dev,
  327. const struct regmap_config *config);
  328. struct regmap *devm_regmap_init_spmi_base(struct spmi_device *dev,
  329. const struct regmap_config *config);
  330. struct regmap *devm_regmap_init_spmi_ext(struct spmi_device *dev,
  331. const struct regmap_config *config);
  332. struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  333. void __iomem *regs,
  334. const struct regmap_config *config);
  335. struct regmap *devm_regmap_init_ac97(struct snd_ac97 *ac97,
  336. const struct regmap_config *config);
  337. bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
  338. /**
  339. * regmap_init_mmio(): Initialise register map
  340. *
  341. * @dev: Device that will be interacted with
  342. * @regs: Pointer to memory-mapped IO region
  343. * @config: Configuration for register map
  344. *
  345. * The return value will be an ERR_PTR() on error or a valid pointer to
  346. * a struct regmap.
  347. */
  348. static inline struct regmap *regmap_init_mmio(struct device *dev,
  349. void __iomem *regs,
  350. const struct regmap_config *config)
  351. {
  352. return regmap_init_mmio_clk(dev, NULL, regs, config);
  353. }
  354. /**
  355. * devm_regmap_init_mmio(): Initialise managed register map
  356. *
  357. * @dev: Device that will be interacted with
  358. * @regs: Pointer to memory-mapped IO region
  359. * @config: Configuration for register map
  360. *
  361. * The return value will be an ERR_PTR() on error or a valid pointer
  362. * to a struct regmap. The regmap will be automatically freed by the
  363. * device management code.
  364. */
  365. static inline struct regmap *devm_regmap_init_mmio(struct device *dev,
  366. void __iomem *regs,
  367. const struct regmap_config *config)
  368. {
  369. return devm_regmap_init_mmio_clk(dev, NULL, regs, config);
  370. }
  371. void regmap_exit(struct regmap *map);
  372. int regmap_reinit_cache(struct regmap *map,
  373. const struct regmap_config *config);
  374. struct regmap *dev_get_regmap(struct device *dev, const char *name);
  375. struct device *regmap_get_device(struct regmap *map);
  376. int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
  377. int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
  378. int regmap_raw_write(struct regmap *map, unsigned int reg,
  379. const void *val, size_t val_len);
  380. int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
  381. size_t val_count);
  382. int regmap_multi_reg_write(struct regmap *map, const struct reg_default *regs,
  383. int num_regs);
  384. int regmap_multi_reg_write_bypassed(struct regmap *map,
  385. const struct reg_default *regs,
  386. int num_regs);
  387. int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  388. const void *val, size_t val_len);
  389. int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
  390. int regmap_raw_read(struct regmap *map, unsigned int reg,
  391. void *val, size_t val_len);
  392. int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
  393. size_t val_count);
  394. int regmap_update_bits(struct regmap *map, unsigned int reg,
  395. unsigned int mask, unsigned int val);
  396. int regmap_update_bits_async(struct regmap *map, unsigned int reg,
  397. unsigned int mask, unsigned int val);
  398. int regmap_update_bits_check(struct regmap *map, unsigned int reg,
  399. unsigned int mask, unsigned int val,
  400. bool *change);
  401. int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
  402. unsigned int mask, unsigned int val,
  403. bool *change);
  404. int regmap_get_val_bytes(struct regmap *map);
  405. int regmap_get_max_register(struct regmap *map);
  406. int regmap_get_reg_stride(struct regmap *map);
  407. int regmap_async_complete(struct regmap *map);
  408. bool regmap_can_raw_write(struct regmap *map);
  409. int regcache_sync(struct regmap *map);
  410. int regcache_sync_region(struct regmap *map, unsigned int min,
  411. unsigned int max);
  412. int regcache_drop_region(struct regmap *map, unsigned int min,
  413. unsigned int max);
  414. void regcache_cache_only(struct regmap *map, bool enable);
  415. void regcache_cache_bypass(struct regmap *map, bool enable);
  416. void regcache_mark_dirty(struct regmap *map);
  417. bool regmap_check_range_table(struct regmap *map, unsigned int reg,
  418. const struct regmap_access_table *table);
  419. int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
  420. int num_regs);
  421. int regmap_parse_val(struct regmap *map, const void *buf,
  422. unsigned int *val);
  423. static inline bool regmap_reg_in_range(unsigned int reg,
  424. const struct regmap_range *range)
  425. {
  426. return reg >= range->range_min && reg <= range->range_max;
  427. }
  428. bool regmap_reg_in_ranges(unsigned int reg,
  429. const struct regmap_range *ranges,
  430. unsigned int nranges);
  431. /**
  432. * Description of an register field
  433. *
  434. * @reg: Offset of the register within the regmap bank
  435. * @lsb: lsb of the register field.
  436. * @msb: msb of the register field.
  437. * @id_size: port size if it has some ports
  438. * @id_offset: address offset for each ports
  439. */
  440. struct reg_field {
  441. unsigned int reg;
  442. unsigned int lsb;
  443. unsigned int msb;
  444. unsigned int id_size;
  445. unsigned int id_offset;
  446. };
  447. #define REG_FIELD(_reg, _lsb, _msb) { \
  448. .reg = _reg, \
  449. .lsb = _lsb, \
  450. .msb = _msb, \
  451. }
  452. struct regmap_field *regmap_field_alloc(struct regmap *regmap,
  453. struct reg_field reg_field);
  454. void regmap_field_free(struct regmap_field *field);
  455. struct regmap_field *devm_regmap_field_alloc(struct device *dev,
  456. struct regmap *regmap, struct reg_field reg_field);
  457. void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
  458. int regmap_field_read(struct regmap_field *field, unsigned int *val);
  459. int regmap_field_write(struct regmap_field *field, unsigned int val);
  460. int regmap_field_update_bits(struct regmap_field *field,
  461. unsigned int mask, unsigned int val);
  462. int regmap_fields_write(struct regmap_field *field, unsigned int id,
  463. unsigned int val);
  464. int regmap_fields_read(struct regmap_field *field, unsigned int id,
  465. unsigned int *val);
  466. int regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
  467. unsigned int mask, unsigned int val);
  468. /**
  469. * Description of an IRQ for the generic regmap irq_chip.
  470. *
  471. * @reg_offset: Offset of the status/mask register within the bank
  472. * @mask: Mask used to flag/control the register.
  473. */
  474. struct regmap_irq {
  475. unsigned int reg_offset;
  476. unsigned int mask;
  477. };
  478. /**
  479. * Description of a generic regmap irq_chip. This is not intended to
  480. * handle every possible interrupt controller, but it should handle a
  481. * substantial proportion of those that are found in the wild.
  482. *
  483. * @name: Descriptive name for IRQ controller.
  484. *
  485. * @status_base: Base status register address.
  486. * @mask_base: Base mask register address.
  487. * @ack_base: Base ack address. If zero then the chip is clear on read.
  488. * Using zero value is possible with @use_ack bit.
  489. * @wake_base: Base address for wake enables. If zero unsupported.
  490. * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
  491. * @init_ack_masked: Ack all masked interrupts once during initalization.
  492. * @mask_invert: Inverted mask register: cleared bits are masked out.
  493. * @use_ack: Use @ack register even if it is zero.
  494. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  495. * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
  496. *
  497. * @num_regs: Number of registers in each control bank.
  498. * @irqs: Descriptors for individual IRQs. Interrupt numbers are
  499. * assigned based on the index in the array of the interrupt.
  500. * @num_irqs: Number of descriptors.
  501. */
  502. struct regmap_irq_chip {
  503. const char *name;
  504. unsigned int status_base;
  505. unsigned int mask_base;
  506. unsigned int ack_base;
  507. unsigned int wake_base;
  508. unsigned int irq_reg_stride;
  509. bool init_ack_masked:1;
  510. bool mask_invert:1;
  511. bool use_ack:1;
  512. bool wake_invert:1;
  513. bool runtime_pm:1;
  514. int num_regs;
  515. const struct regmap_irq *irqs;
  516. int num_irqs;
  517. };
  518. struct regmap_irq_chip_data;
  519. int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
  520. int irq_base, const struct regmap_irq_chip *chip,
  521. struct regmap_irq_chip_data **data);
  522. void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
  523. int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  524. int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
  525. struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
  526. #else
  527. /*
  528. * These stubs should only ever be called by generic code which has
  529. * regmap based facilities, if they ever get called at runtime
  530. * something is going wrong and something probably needs to select
  531. * REGMAP.
  532. */
  533. static inline int regmap_write(struct regmap *map, unsigned int reg,
  534. unsigned int val)
  535. {
  536. WARN_ONCE(1, "regmap API is disabled");
  537. return -EINVAL;
  538. }
  539. static inline int regmap_write_async(struct regmap *map, unsigned int reg,
  540. unsigned int val)
  541. {
  542. WARN_ONCE(1, "regmap API is disabled");
  543. return -EINVAL;
  544. }
  545. static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
  546. const void *val, size_t val_len)
  547. {
  548. WARN_ONCE(1, "regmap API is disabled");
  549. return -EINVAL;
  550. }
  551. static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  552. const void *val, size_t val_len)
  553. {
  554. WARN_ONCE(1, "regmap API is disabled");
  555. return -EINVAL;
  556. }
  557. static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  558. const void *val, size_t val_count)
  559. {
  560. WARN_ONCE(1, "regmap API is disabled");
  561. return -EINVAL;
  562. }
  563. static inline int regmap_read(struct regmap *map, unsigned int reg,
  564. unsigned int *val)
  565. {
  566. WARN_ONCE(1, "regmap API is disabled");
  567. return -EINVAL;
  568. }
  569. static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  570. void *val, size_t val_len)
  571. {
  572. WARN_ONCE(1, "regmap API is disabled");
  573. return -EINVAL;
  574. }
  575. static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  576. void *val, size_t val_count)
  577. {
  578. WARN_ONCE(1, "regmap API is disabled");
  579. return -EINVAL;
  580. }
  581. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  582. unsigned int mask, unsigned int val)
  583. {
  584. WARN_ONCE(1, "regmap API is disabled");
  585. return -EINVAL;
  586. }
  587. static inline int regmap_update_bits_async(struct regmap *map,
  588. unsigned int reg,
  589. unsigned int mask, unsigned int val)
  590. {
  591. WARN_ONCE(1, "regmap API is disabled");
  592. return -EINVAL;
  593. }
  594. static inline int regmap_update_bits_check(struct regmap *map,
  595. unsigned int reg,
  596. unsigned int mask, unsigned int val,
  597. bool *change)
  598. {
  599. WARN_ONCE(1, "regmap API is disabled");
  600. return -EINVAL;
  601. }
  602. static inline int regmap_update_bits_check_async(struct regmap *map,
  603. unsigned int reg,
  604. unsigned int mask,
  605. unsigned int val,
  606. bool *change)
  607. {
  608. WARN_ONCE(1, "regmap API is disabled");
  609. return -EINVAL;
  610. }
  611. static inline int regmap_get_val_bytes(struct regmap *map)
  612. {
  613. WARN_ONCE(1, "regmap API is disabled");
  614. return -EINVAL;
  615. }
  616. static inline int regmap_get_max_register(struct regmap *map)
  617. {
  618. WARN_ONCE(1, "regmap API is disabled");
  619. return -EINVAL;
  620. }
  621. static inline int regmap_get_reg_stride(struct regmap *map)
  622. {
  623. WARN_ONCE(1, "regmap API is disabled");
  624. return -EINVAL;
  625. }
  626. static inline int regcache_sync(struct regmap *map)
  627. {
  628. WARN_ONCE(1, "regmap API is disabled");
  629. return -EINVAL;
  630. }
  631. static inline int regcache_sync_region(struct regmap *map, unsigned int min,
  632. unsigned int max)
  633. {
  634. WARN_ONCE(1, "regmap API is disabled");
  635. return -EINVAL;
  636. }
  637. static inline int regcache_drop_region(struct regmap *map, unsigned int min,
  638. unsigned int max)
  639. {
  640. WARN_ONCE(1, "regmap API is disabled");
  641. return -EINVAL;
  642. }
  643. static inline void regcache_cache_only(struct regmap *map, bool enable)
  644. {
  645. WARN_ONCE(1, "regmap API is disabled");
  646. }
  647. static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  648. {
  649. WARN_ONCE(1, "regmap API is disabled");
  650. }
  651. static inline void regcache_mark_dirty(struct regmap *map)
  652. {
  653. WARN_ONCE(1, "regmap API is disabled");
  654. }
  655. static inline void regmap_async_complete(struct regmap *map)
  656. {
  657. WARN_ONCE(1, "regmap API is disabled");
  658. }
  659. static inline int regmap_register_patch(struct regmap *map,
  660. const struct reg_default *regs,
  661. int num_regs)
  662. {
  663. WARN_ONCE(1, "regmap API is disabled");
  664. return -EINVAL;
  665. }
  666. static inline int regmap_parse_val(struct regmap *map, const void *buf,
  667. unsigned int *val)
  668. {
  669. WARN_ONCE(1, "regmap API is disabled");
  670. return -EINVAL;
  671. }
  672. static inline struct regmap *dev_get_regmap(struct device *dev,
  673. const char *name)
  674. {
  675. return NULL;
  676. }
  677. static inline struct device *regmap_get_device(struct regmap *map)
  678. {
  679. WARN_ONCE(1, "regmap API is disabled");
  680. return NULL;
  681. }
  682. #endif
  683. #endif