regmap.h 25 KB

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