regmap.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __LINUX_REGMAP_H
  3. #define __LINUX_REGMAP_H
  4. /*
  5. * Register map access API
  6. *
  7. * Copyright 2011 Wolfson Microelectronics plc
  8. *
  9. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  10. */
  11. #include <linux/list.h>
  12. #include <linux/rbtree.h>
  13. #include <linux/ktime.h>
  14. #include <linux/delay.h>
  15. #include <linux/err.h>
  16. #include <linux/bug.h>
  17. #include <linux/lockdep.h>
  18. #include <linux/iopoll.h>
  19. #include <linux/fwnode.h>
  20. #include <linux/android_kabi.h>
  21. struct module;
  22. struct clk;
  23. struct device;
  24. struct device_node;
  25. struct i2c_client;
  26. struct i3c_device;
  27. struct irq_domain;
  28. struct slim_device;
  29. struct spi_device;
  30. struct spmi_device;
  31. struct regmap;
  32. struct regmap_range_cfg;
  33. struct regmap_field;
  34. struct snd_ac97;
  35. struct sdw_slave;
  36. /* An enum of all the supported cache types */
  37. enum regcache_type {
  38. REGCACHE_NONE,
  39. REGCACHE_RBTREE,
  40. REGCACHE_COMPRESSED,
  41. REGCACHE_FLAT,
  42. };
  43. /**
  44. * struct reg_default - Default value for a register.
  45. *
  46. * @reg: Register address.
  47. * @def: Register default value.
  48. *
  49. * We use an array of structs rather than a simple array as many modern devices
  50. * have very sparse register maps.
  51. */
  52. struct reg_default {
  53. unsigned int reg;
  54. unsigned int def;
  55. };
  56. /**
  57. * struct reg_sequence - An individual write from a sequence of writes.
  58. *
  59. * @reg: Register address.
  60. * @def: Register value.
  61. * @delay_us: Delay to be applied after the register write in microseconds
  62. *
  63. * Register/value pairs for sequences of writes with an optional delay in
  64. * microseconds to be applied after each write.
  65. */
  66. struct reg_sequence {
  67. unsigned int reg;
  68. unsigned int def;
  69. unsigned int delay_us;
  70. };
  71. #define REG_SEQ(_reg, _def, _delay_us) { \
  72. .reg = _reg, \
  73. .def = _def, \
  74. .delay_us = _delay_us, \
  75. }
  76. #define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0)
  77. /**
  78. * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs
  79. *
  80. * @map: Regmap to read from
  81. * @addr: Address to poll
  82. * @val: Unsigned integer variable to read the value into
  83. * @cond: Break condition (usually involving @val)
  84. * @sleep_us: Maximum time to sleep between reads in us (0
  85. * tight-loops). Should be less than ~20ms since usleep_range
  86. * is used (see Documentation/timers/timers-howto.rst).
  87. * @timeout_us: Timeout in us, 0 means never timeout
  88. *
  89. * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
  90. * error return value in case of a error read. In the two former cases,
  91. * the last read value at @addr is stored in @val. Must not be called
  92. * from atomic context if sleep_us or timeout_us are used.
  93. *
  94. * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  95. */
  96. #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
  97. ({ \
  98. int __ret, __tmp; \
  99. __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \
  100. sleep_us, timeout_us, false, (map), (addr), &(val)); \
  101. __ret ?: __tmp; \
  102. })
  103. /**
  104. * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs
  105. *
  106. * @map: Regmap to read from
  107. * @addr: Address to poll
  108. * @val: Unsigned integer variable to read the value into
  109. * @cond: Break condition (usually involving @val)
  110. * @delay_us: Time to udelay between reads in us (0 tight-loops).
  111. * Should be less than ~10us since udelay is used
  112. * (see Documentation/timers/timers-howto.rst).
  113. * @timeout_us: Timeout in us, 0 means never timeout
  114. *
  115. * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
  116. * error return value in case of a error read. In the two former cases,
  117. * the last read value at @addr is stored in @val.
  118. *
  119. * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
  120. *
  121. * Note: In general regmap cannot be used in atomic context. If you want to use
  122. * this macro then first setup your regmap for atomic use (flat or no cache
  123. * and MMIO regmap).
  124. */
  125. #define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
  126. ({ \
  127. u64 __timeout_us = (timeout_us); \
  128. unsigned long __delay_us = (delay_us); \
  129. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  130. int __ret; \
  131. for (;;) { \
  132. __ret = regmap_read((map), (addr), &(val)); \
  133. if (__ret) \
  134. break; \
  135. if (cond) \
  136. break; \
  137. if ((__timeout_us) && \
  138. ktime_compare(ktime_get(), __timeout) > 0) { \
  139. __ret = regmap_read((map), (addr), &(val)); \
  140. break; \
  141. } \
  142. if (__delay_us) \
  143. udelay(__delay_us); \
  144. } \
  145. __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
  146. })
  147. /**
  148. * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
  149. *
  150. * @field: Regmap field to read from
  151. * @val: Unsigned integer variable to read the value into
  152. * @cond: Break condition (usually involving @val)
  153. * @sleep_us: Maximum time to sleep between reads in us (0
  154. * tight-loops). Should be less than ~20ms since usleep_range
  155. * is used (see Documentation/timers/timers-howto.rst).
  156. * @timeout_us: Timeout in us, 0 means never timeout
  157. *
  158. * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read
  159. * error return value in case of a error read. In the two former cases,
  160. * the last read value at @addr is stored in @val. Must not be called
  161. * from atomic context if sleep_us or timeout_us are used.
  162. *
  163. * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  164. */
  165. #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
  166. ({ \
  167. int __ret, __tmp; \
  168. __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \
  169. sleep_us, timeout_us, false, (field), &(val)); \
  170. __ret ?: __tmp; \
  171. })
  172. #ifdef CONFIG_REGMAP
  173. enum regmap_endian {
  174. /* Unspecified -> 0 -> Backwards compatible default */
  175. REGMAP_ENDIAN_DEFAULT = 0,
  176. REGMAP_ENDIAN_BIG,
  177. REGMAP_ENDIAN_LITTLE,
  178. REGMAP_ENDIAN_NATIVE,
  179. };
  180. /**
  181. * struct regmap_range - A register range, used for access related checks
  182. * (readable/writeable/volatile/precious checks)
  183. *
  184. * @range_min: address of first register
  185. * @range_max: address of last register
  186. */
  187. struct regmap_range {
  188. unsigned int range_min;
  189. unsigned int range_max;
  190. };
  191. #define regmap_reg_range(low, high) { .range_min = low, .range_max = high, }
  192. /**
  193. * struct regmap_access_table - A table of register ranges for access checks
  194. *
  195. * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges"
  196. * @n_yes_ranges: size of the above array
  197. * @no_ranges: pointer to an array of regmap ranges used as "no ranges"
  198. * @n_no_ranges: size of the above array
  199. *
  200. * A table of ranges including some yes ranges and some no ranges.
  201. * If a register belongs to a no_range, the corresponding check function
  202. * will return false. If a register belongs to a yes range, the corresponding
  203. * check function will return true. "no_ranges" are searched first.
  204. */
  205. struct regmap_access_table {
  206. const struct regmap_range *yes_ranges;
  207. unsigned int n_yes_ranges;
  208. const struct regmap_range *no_ranges;
  209. unsigned int n_no_ranges;
  210. };
  211. typedef void (*regmap_lock)(void *);
  212. typedef void (*regmap_unlock)(void *);
  213. /**
  214. * struct regmap_config - Configuration for the register map of a device.
  215. *
  216. * @name: Optional name of the regmap. Useful when a device has multiple
  217. * register regions.
  218. *
  219. * @reg_bits: Number of bits in a register address, mandatory.
  220. * @reg_stride: The register address stride. Valid register addresses are a
  221. * multiple of this value. If set to 0, a value of 1 will be
  222. * used.
  223. * @pad_bits: Number of bits of padding between register and value.
  224. * @val_bits: Number of bits in a register value, mandatory.
  225. *
  226. * @writeable_reg: Optional callback returning true if the register
  227. * can be written to. If this field is NULL but wr_table
  228. * (see below) is not, the check is performed on such table
  229. * (a register is writeable if it belongs to one of the ranges
  230. * specified by wr_table).
  231. * @readable_reg: Optional callback returning true if the register
  232. * can be read from. If this field is NULL but rd_table
  233. * (see below) is not, the check is performed on such table
  234. * (a register is readable if it belongs to one of the ranges
  235. * specified by rd_table).
  236. * @volatile_reg: Optional callback returning true if the register
  237. * value can't be cached. If this field is NULL but
  238. * volatile_table (see below) is not, the check is performed on
  239. * such table (a register is volatile if it belongs to one of
  240. * the ranges specified by volatile_table).
  241. * @precious_reg: Optional callback returning true if the register
  242. * should not be read outside of a call from the driver
  243. * (e.g., a clear on read interrupt status register). If this
  244. * field is NULL but precious_table (see below) is not, the
  245. * check is performed on such table (a register is precious if
  246. * it belongs to one of the ranges specified by precious_table).
  247. * @writeable_noinc_reg: Optional callback returning true if the register
  248. * supports multiple write operations without incrementing
  249. * the register number. If this field is NULL but
  250. * wr_noinc_table (see below) is not, the check is
  251. * performed on such table (a register is no increment
  252. * writeable if it belongs to one of the ranges specified
  253. * by wr_noinc_table).
  254. * @readable_noinc_reg: Optional callback returning true if the register
  255. * supports multiple read operations without incrementing
  256. * the register number. If this field is NULL but
  257. * rd_noinc_table (see below) is not, the check is
  258. * performed on such table (a register is no increment
  259. * readable if it belongs to one of the ranges specified
  260. * by rd_noinc_table).
  261. * @disable_locking: This regmap is either protected by external means or
  262. * is guaranteed not to be accessed from multiple threads.
  263. * Don't use any locking mechanisms.
  264. * @lock: Optional lock callback (overrides regmap's default lock
  265. * function, based on spinlock or mutex).
  266. * @unlock: As above for unlocking.
  267. * @lock_arg: this field is passed as the only argument of lock/unlock
  268. * functions (ignored in case regular lock/unlock functions
  269. * are not overridden).
  270. * @reg_read: Optional callback that if filled will be used to perform
  271. * all the reads from the registers. Should only be provided for
  272. * devices whose read operation cannot be represented as a simple
  273. * read operation on a bus such as SPI, I2C, etc. Most of the
  274. * devices do not need this.
  275. * @reg_write: Same as above for writing.
  276. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
  277. * to perform locking. This field is ignored if custom lock/unlock
  278. * functions are used (see fields lock/unlock of struct regmap_config).
  279. * This field is a duplicate of a similar file in
  280. * 'struct regmap_bus' and serves exact same purpose.
  281. * Use it only for "no-bus" cases.
  282. * @max_register: Optional, specifies the maximum valid register address.
  283. * @wr_table: Optional, points to a struct regmap_access_table specifying
  284. * valid ranges for write access.
  285. * @rd_table: As above, for read access.
  286. * @volatile_table: As above, for volatile registers.
  287. * @precious_table: As above, for precious registers.
  288. * @wr_noinc_table: As above, for no increment writeable registers.
  289. * @rd_noinc_table: As above, for no increment readable registers.
  290. * @reg_defaults: Power on reset values for registers (for use with
  291. * register cache support).
  292. * @num_reg_defaults: Number of elements in reg_defaults.
  293. *
  294. * @read_flag_mask: Mask to be set in the top bytes of the register when doing
  295. * a read.
  296. * @write_flag_mask: Mask to be set in the top bytes of the register when doing
  297. * a write. If both read_flag_mask and write_flag_mask are
  298. * empty and zero_flag_mask is not set the regmap_bus default
  299. * masks are used.
  300. * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even
  301. * if they are both empty.
  302. * @use_single_read: If set, converts the bulk read operation into a series of
  303. * single read operations. This is useful for a device that
  304. * does not support bulk read.
  305. * @use_single_write: If set, converts the bulk write operation into a series of
  306. * single write operations. This is useful for a device that
  307. * does not support bulk write.
  308. * @can_multi_write: If set, the device supports the multi write mode of bulk
  309. * write operations, if clear multi write requests will be
  310. * split into individual write operations
  311. *
  312. * @cache_type: The actual cache type.
  313. * @reg_defaults_raw: Power on reset values for registers (for use with
  314. * register cache support).
  315. * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
  316. * @reg_format_endian: Endianness for formatted register addresses. If this is
  317. * DEFAULT, the @reg_format_endian_default value from the
  318. * regmap bus is used.
  319. * @val_format_endian: Endianness for formatted register values. If this is
  320. * DEFAULT, the @reg_format_endian_default value from the
  321. * regmap bus is used.
  322. *
  323. * @ranges: Array of configuration entries for virtual address ranges.
  324. * @num_ranges: Number of range configuration entries.
  325. * @use_hwlock: Indicate if a hardware spinlock should be used.
  326. * @hwlock_id: Specify the hardware spinlock id.
  327. * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE,
  328. * HWLOCK_IRQ or 0.
  329. * @can_sleep: Optional, specifies whether regmap operations can sleep.
  330. */
  331. struct regmap_config {
  332. const char *name;
  333. int reg_bits;
  334. int reg_stride;
  335. int pad_bits;
  336. int val_bits;
  337. bool (*writeable_reg)(struct device *dev, unsigned int reg);
  338. bool (*readable_reg)(struct device *dev, unsigned int reg);
  339. bool (*volatile_reg)(struct device *dev, unsigned int reg);
  340. bool (*precious_reg)(struct device *dev, unsigned int reg);
  341. bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
  342. bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
  343. bool disable_locking;
  344. regmap_lock lock;
  345. regmap_unlock unlock;
  346. void *lock_arg;
  347. int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
  348. int (*reg_write)(void *context, unsigned int reg, unsigned int val);
  349. bool fast_io;
  350. unsigned int max_register;
  351. const struct regmap_access_table *wr_table;
  352. const struct regmap_access_table *rd_table;
  353. const struct regmap_access_table *volatile_table;
  354. const struct regmap_access_table *precious_table;
  355. const struct regmap_access_table *wr_noinc_table;
  356. const struct regmap_access_table *rd_noinc_table;
  357. const struct reg_default *reg_defaults;
  358. unsigned int num_reg_defaults;
  359. enum regcache_type cache_type;
  360. const void *reg_defaults_raw;
  361. unsigned int num_reg_defaults_raw;
  362. unsigned long read_flag_mask;
  363. unsigned long write_flag_mask;
  364. bool zero_flag_mask;
  365. bool use_single_read;
  366. bool use_single_write;
  367. bool can_multi_write;
  368. enum regmap_endian reg_format_endian;
  369. enum regmap_endian val_format_endian;
  370. const struct regmap_range_cfg *ranges;
  371. unsigned int num_ranges;
  372. bool use_hwlock;
  373. unsigned int hwlock_id;
  374. unsigned int hwlock_mode;
  375. bool can_sleep;
  376. ANDROID_KABI_RESERVE(1);
  377. };
  378. /**
  379. * struct regmap_range_cfg - Configuration for indirectly accessed or paged
  380. * registers.
  381. *
  382. * @name: Descriptive name for diagnostics
  383. *
  384. * @range_min: Address of the lowest register address in virtual range.
  385. * @range_max: Address of the highest register in virtual range.
  386. *
  387. * @selector_reg: Register with selector field.
  388. * @selector_mask: Bit mask for selector value.
  389. * @selector_shift: Bit shift for selector value.
  390. *
  391. * @window_start: Address of first (lowest) register in data window.
  392. * @window_len: Number of registers in data window.
  393. *
  394. * Registers, mapped to this virtual range, are accessed in two steps:
  395. * 1. page selector register update;
  396. * 2. access through data window registers.
  397. */
  398. struct regmap_range_cfg {
  399. const char *name;
  400. /* Registers of virtual address range */
  401. unsigned int range_min;
  402. unsigned int range_max;
  403. /* Page selector for indirect addressing */
  404. unsigned int selector_reg;
  405. unsigned int selector_mask;
  406. int selector_shift;
  407. /* Data window (per each page) */
  408. unsigned int window_start;
  409. unsigned int window_len;
  410. ANDROID_KABI_RESERVE(1);
  411. };
  412. struct regmap_async;
  413. typedef int (*regmap_hw_write)(void *context, const void *data,
  414. size_t count);
  415. typedef int (*regmap_hw_gather_write)(void *context,
  416. const void *reg, size_t reg_len,
  417. const void *val, size_t val_len);
  418. typedef int (*regmap_hw_async_write)(void *context,
  419. const void *reg, size_t reg_len,
  420. const void *val, size_t val_len,
  421. struct regmap_async *async);
  422. typedef int (*regmap_hw_read)(void *context,
  423. const void *reg_buf, size_t reg_size,
  424. void *val_buf, size_t val_size);
  425. typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
  426. unsigned int *val);
  427. typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
  428. unsigned int val);
  429. typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg,
  430. unsigned int mask, unsigned int val);
  431. typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
  432. typedef void (*regmap_hw_free_context)(void *context);
  433. /**
  434. * struct regmap_bus - Description of a hardware bus for the register map
  435. * infrastructure.
  436. *
  437. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
  438. * to perform locking. This field is ignored if custom lock/unlock
  439. * functions are used (see fields lock/unlock of
  440. * struct regmap_config).
  441. * @write: Write operation.
  442. * @gather_write: Write operation with split register/value, return -ENOTSUPP
  443. * if not implemented on a given device.
  444. * @async_write: Write operation which completes asynchronously, optional and
  445. * must serialise with respect to non-async I/O.
  446. * @reg_write: Write a single register value to the given register address. This
  447. * write operation has to complete when returning from the function.
  448. * @reg_update_bits: Update bits operation to be used against volatile
  449. * registers, intended for devices supporting some mechanism
  450. * for setting clearing bits without having to
  451. * read/modify/write.
  452. * @read: Read operation. Data is returned in the buffer used to transmit
  453. * data.
  454. * @reg_read: Read a single register value from a given register address.
  455. * @free_context: Free context.
  456. * @async_alloc: Allocate a regmap_async() structure.
  457. * @read_flag_mask: Mask to be set in the top byte of the register when doing
  458. * a read.
  459. * @reg_format_endian_default: Default endianness for formatted register
  460. * addresses. Used when the regmap_config specifies DEFAULT. If this is
  461. * DEFAULT, BIG is assumed.
  462. * @val_format_endian_default: Default endianness for formatted register
  463. * values. Used when the regmap_config specifies DEFAULT. If this is
  464. * DEFAULT, BIG is assumed.
  465. * @max_raw_read: Max raw read size that can be used on the bus.
  466. * @max_raw_write: Max raw write size that can be used on the bus.
  467. */
  468. struct regmap_bus {
  469. bool fast_io;
  470. regmap_hw_write write;
  471. regmap_hw_gather_write gather_write;
  472. regmap_hw_async_write async_write;
  473. regmap_hw_reg_write reg_write;
  474. regmap_hw_reg_update_bits reg_update_bits;
  475. regmap_hw_read read;
  476. regmap_hw_reg_read reg_read;
  477. regmap_hw_free_context free_context;
  478. regmap_hw_async_alloc async_alloc;
  479. u8 read_flag_mask;
  480. enum regmap_endian reg_format_endian_default;
  481. enum regmap_endian val_format_endian_default;
  482. size_t max_raw_read;
  483. size_t max_raw_write;
  484. ANDROID_KABI_RESERVE(1);
  485. };
  486. /*
  487. * __regmap_init functions.
  488. *
  489. * These functions take a lock key and name parameter, and should not be called
  490. * directly. Instead, use the regmap_init macros that generate a key and name
  491. * for each call.
  492. */
  493. struct regmap *__regmap_init(struct device *dev,
  494. const struct regmap_bus *bus,
  495. void *bus_context,
  496. const struct regmap_config *config,
  497. struct lock_class_key *lock_key,
  498. const char *lock_name);
  499. struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
  500. const struct regmap_config *config,
  501. struct lock_class_key *lock_key,
  502. const char *lock_name);
  503. struct regmap *__regmap_init_sccb(struct i2c_client *i2c,
  504. const struct regmap_config *config,
  505. struct lock_class_key *lock_key,
  506. const char *lock_name);
  507. struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
  508. const struct regmap_config *config,
  509. struct lock_class_key *lock_key,
  510. const char *lock_name);
  511. struct regmap *__regmap_init_spi(struct spi_device *dev,
  512. const struct regmap_config *config,
  513. struct lock_class_key *lock_key,
  514. const char *lock_name);
  515. struct regmap *__regmap_init_spmi_base(struct spmi_device *dev,
  516. const struct regmap_config *config,
  517. struct lock_class_key *lock_key,
  518. const char *lock_name);
  519. struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev,
  520. const struct regmap_config *config,
  521. struct lock_class_key *lock_key,
  522. const char *lock_name);
  523. struct regmap *__regmap_init_w1(struct device *w1_dev,
  524. const struct regmap_config *config,
  525. struct lock_class_key *lock_key,
  526. const char *lock_name);
  527. struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id,
  528. void __iomem *regs,
  529. const struct regmap_config *config,
  530. struct lock_class_key *lock_key,
  531. const char *lock_name);
  532. struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
  533. const struct regmap_config *config,
  534. struct lock_class_key *lock_key,
  535. const char *lock_name);
  536. struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
  537. const struct regmap_config *config,
  538. struct lock_class_key *lock_key,
  539. const char *lock_name);
  540. struct regmap *__regmap_init_spi_avmm(struct spi_device *spi,
  541. const struct regmap_config *config,
  542. struct lock_class_key *lock_key,
  543. const char *lock_name);
  544. struct regmap *__devm_regmap_init(struct device *dev,
  545. const struct regmap_bus *bus,
  546. void *bus_context,
  547. const struct regmap_config *config,
  548. struct lock_class_key *lock_key,
  549. const char *lock_name);
  550. struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c,
  551. const struct regmap_config *config,
  552. struct lock_class_key *lock_key,
  553. const char *lock_name);
  554. struct regmap *__devm_regmap_init_sccb(struct i2c_client *i2c,
  555. const struct regmap_config *config,
  556. struct lock_class_key *lock_key,
  557. const char *lock_name);
  558. struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
  559. const struct regmap_config *config,
  560. struct lock_class_key *lock_key,
  561. const char *lock_name);
  562. struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev,
  563. const struct regmap_config *config,
  564. struct lock_class_key *lock_key,
  565. const char *lock_name);
  566. struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev,
  567. const struct regmap_config *config,
  568. struct lock_class_key *lock_key,
  569. const char *lock_name);
  570. struct regmap *__devm_regmap_init_w1(struct device *w1_dev,
  571. const struct regmap_config *config,
  572. struct lock_class_key *lock_key,
  573. const char *lock_name);
  574. struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
  575. const char *clk_id,
  576. void __iomem *regs,
  577. const struct regmap_config *config,
  578. struct lock_class_key *lock_key,
  579. const char *lock_name);
  580. struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
  581. const struct regmap_config *config,
  582. struct lock_class_key *lock_key,
  583. const char *lock_name);
  584. struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
  585. const struct regmap_config *config,
  586. struct lock_class_key *lock_key,
  587. const char *lock_name);
  588. struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus,
  589. const struct regmap_config *config,
  590. struct lock_class_key *lock_key,
  591. const char *lock_name);
  592. struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c,
  593. const struct regmap_config *config,
  594. struct lock_class_key *lock_key,
  595. const char *lock_name);
  596. struct regmap *__devm_regmap_init_spi_avmm(struct spi_device *spi,
  597. const struct regmap_config *config,
  598. struct lock_class_key *lock_key,
  599. const char *lock_name);
  600. /*
  601. * Wrapper for regmap_init macros to include a unique lockdep key and name
  602. * for each call. No-op if CONFIG_LOCKDEP is not set.
  603. *
  604. * @fn: Real function to call (in the form __[*_]regmap_init[_*])
  605. * @name: Config variable name (#config in the calling macro)
  606. **/
  607. #ifdef CONFIG_LOCKDEP
  608. #define __regmap_lockdep_wrapper(fn, name, ...) \
  609. ( \
  610. ({ \
  611. static struct lock_class_key _key; \
  612. fn(__VA_ARGS__, &_key, \
  613. KBUILD_BASENAME ":" \
  614. __stringify(__LINE__) ":" \
  615. "(" name ")->lock"); \
  616. }) \
  617. )
  618. #else
  619. #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL)
  620. #endif
  621. /**
  622. * regmap_init() - Initialise register map
  623. *
  624. * @dev: Device that will be interacted with
  625. * @bus: Bus-specific callbacks to use with device
  626. * @bus_context: Data passed to bus-specific callbacks
  627. * @config: Configuration for register map
  628. *
  629. * The return value will be an ERR_PTR() on error or a valid pointer to
  630. * a struct regmap. This function should generally not be called
  631. * directly, it should be called by bus-specific init functions.
  632. */
  633. #define regmap_init(dev, bus, bus_context, config) \
  634. __regmap_lockdep_wrapper(__regmap_init, #config, \
  635. dev, bus, bus_context, config)
  636. int regmap_attach_dev(struct device *dev, struct regmap *map,
  637. const struct regmap_config *config);
  638. /**
  639. * regmap_init_i2c() - Initialise register map
  640. *
  641. * @i2c: Device that will be interacted with
  642. * @config: Configuration for register map
  643. *
  644. * The return value will be an ERR_PTR() on error or a valid pointer to
  645. * a struct regmap.
  646. */
  647. #define regmap_init_i2c(i2c, config) \
  648. __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \
  649. i2c, config)
  650. /**
  651. * regmap_init_sccb() - Initialise register map
  652. *
  653. * @i2c: Device that will be interacted with
  654. * @config: Configuration for register map
  655. *
  656. * The return value will be an ERR_PTR() on error or a valid pointer to
  657. * a struct regmap.
  658. */
  659. #define regmap_init_sccb(i2c, config) \
  660. __regmap_lockdep_wrapper(__regmap_init_sccb, #config, \
  661. i2c, config)
  662. /**
  663. * regmap_init_slimbus() - Initialise register map
  664. *
  665. * @slimbus: Device that will be interacted with
  666. * @config: Configuration for register map
  667. *
  668. * The return value will be an ERR_PTR() on error or a valid pointer to
  669. * a struct regmap.
  670. */
  671. #define regmap_init_slimbus(slimbus, config) \
  672. __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \
  673. slimbus, config)
  674. /**
  675. * regmap_init_spi() - Initialise register map
  676. *
  677. * @dev: Device that will be interacted with
  678. * @config: Configuration for register map
  679. *
  680. * The return value will be an ERR_PTR() on error or a valid pointer to
  681. * a struct regmap.
  682. */
  683. #define regmap_init_spi(dev, config) \
  684. __regmap_lockdep_wrapper(__regmap_init_spi, #config, \
  685. dev, config)
  686. /**
  687. * regmap_init_spmi_base() - Create regmap for the Base register space
  688. *
  689. * @dev: SPMI device that will be interacted with
  690. * @config: Configuration for register map
  691. *
  692. * The return value will be an ERR_PTR() on error or a valid pointer to
  693. * a struct regmap.
  694. */
  695. #define regmap_init_spmi_base(dev, config) \
  696. __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \
  697. dev, config)
  698. /**
  699. * regmap_init_spmi_ext() - Create regmap for Ext register space
  700. *
  701. * @dev: Device that will be interacted with
  702. * @config: Configuration for register map
  703. *
  704. * The return value will be an ERR_PTR() on error or a valid pointer to
  705. * a struct regmap.
  706. */
  707. #define regmap_init_spmi_ext(dev, config) \
  708. __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \
  709. dev, config)
  710. /**
  711. * regmap_init_w1() - Initialise register map
  712. *
  713. * @w1_dev: Device that will be interacted with
  714. * @config: Configuration for register map
  715. *
  716. * The return value will be an ERR_PTR() on error or a valid pointer to
  717. * a struct regmap.
  718. */
  719. #define regmap_init_w1(w1_dev, config) \
  720. __regmap_lockdep_wrapper(__regmap_init_w1, #config, \
  721. w1_dev, config)
  722. /**
  723. * regmap_init_mmio_clk() - Initialise register map with register clock
  724. *
  725. * @dev: Device that will be interacted with
  726. * @clk_id: register clock consumer ID
  727. * @regs: Pointer to memory-mapped IO region
  728. * @config: Configuration for register map
  729. *
  730. * The return value will be an ERR_PTR() on error or a valid pointer to
  731. * a struct regmap.
  732. */
  733. #define regmap_init_mmio_clk(dev, clk_id, regs, config) \
  734. __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \
  735. dev, clk_id, regs, config)
  736. /**
  737. * regmap_init_mmio() - Initialise register map
  738. *
  739. * @dev: Device that will be interacted with
  740. * @regs: Pointer to memory-mapped IO region
  741. * @config: Configuration for register map
  742. *
  743. * The return value will be an ERR_PTR() on error or a valid pointer to
  744. * a struct regmap.
  745. */
  746. #define regmap_init_mmio(dev, regs, config) \
  747. regmap_init_mmio_clk(dev, NULL, regs, config)
  748. /**
  749. * regmap_init_ac97() - Initialise AC'97 register map
  750. *
  751. * @ac97: Device that will be interacted with
  752. * @config: Configuration for register map
  753. *
  754. * The return value will be an ERR_PTR() on error or a valid pointer to
  755. * a struct regmap.
  756. */
  757. #define regmap_init_ac97(ac97, config) \
  758. __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \
  759. ac97, config)
  760. bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
  761. /**
  762. * regmap_init_sdw() - Initialise register map
  763. *
  764. * @sdw: Device that will be interacted with
  765. * @config: Configuration for register map
  766. *
  767. * The return value will be an ERR_PTR() on error or a valid pointer to
  768. * a struct regmap.
  769. */
  770. #define regmap_init_sdw(sdw, config) \
  771. __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \
  772. sdw, config)
  773. /**
  774. * regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave
  775. * to AVMM Bus Bridge
  776. *
  777. * @spi: Device that will be interacted with
  778. * @config: Configuration for register map
  779. *
  780. * The return value will be an ERR_PTR() on error or a valid pointer
  781. * to a struct regmap.
  782. */
  783. #define regmap_init_spi_avmm(spi, config) \
  784. __regmap_lockdep_wrapper(__regmap_init_spi_avmm, #config, \
  785. spi, config)
  786. /**
  787. * devm_regmap_init() - Initialise managed register map
  788. *
  789. * @dev: Device that will be interacted with
  790. * @bus: Bus-specific callbacks to use with device
  791. * @bus_context: Data passed to bus-specific callbacks
  792. * @config: Configuration for register map
  793. *
  794. * The return value will be an ERR_PTR() on error or a valid pointer
  795. * to a struct regmap. This function should generally not be called
  796. * directly, it should be called by bus-specific init functions. The
  797. * map will be automatically freed by the device management code.
  798. */
  799. #define devm_regmap_init(dev, bus, bus_context, config) \
  800. __regmap_lockdep_wrapper(__devm_regmap_init, #config, \
  801. dev, bus, bus_context, config)
  802. /**
  803. * devm_regmap_init_i2c() - Initialise managed register map
  804. *
  805. * @i2c: Device that will be interacted with
  806. * @config: Configuration for register map
  807. *
  808. * The return value will be an ERR_PTR() on error or a valid pointer
  809. * to a struct regmap. The regmap will be automatically freed by the
  810. * device management code.
  811. */
  812. #define devm_regmap_init_i2c(i2c, config) \
  813. __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \
  814. i2c, config)
  815. /**
  816. * devm_regmap_init_sccb() - Initialise managed register map
  817. *
  818. * @i2c: Device that will be interacted with
  819. * @config: Configuration for register map
  820. *
  821. * The return value will be an ERR_PTR() on error or a valid pointer
  822. * to a struct regmap. The regmap will be automatically freed by the
  823. * device management code.
  824. */
  825. #define devm_regmap_init_sccb(i2c, config) \
  826. __regmap_lockdep_wrapper(__devm_regmap_init_sccb, #config, \
  827. i2c, config)
  828. /**
  829. * devm_regmap_init_spi() - Initialise register map
  830. *
  831. * @dev: Device that will be interacted with
  832. * @config: Configuration for register map
  833. *
  834. * The return value will be an ERR_PTR() on error or a valid pointer
  835. * to a struct regmap. The map will be automatically freed by the
  836. * device management code.
  837. */
  838. #define devm_regmap_init_spi(dev, config) \
  839. __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
  840. dev, config)
  841. /**
  842. * devm_regmap_init_spmi_base() - Create managed regmap for Base register space
  843. *
  844. * @dev: SPMI device that will be interacted with
  845. * @config: Configuration for register map
  846. *
  847. * The return value will be an ERR_PTR() on error or a valid pointer
  848. * to a struct regmap. The regmap will be automatically freed by the
  849. * device management code.
  850. */
  851. #define devm_regmap_init_spmi_base(dev, config) \
  852. __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \
  853. dev, config)
  854. /**
  855. * devm_regmap_init_spmi_ext() - Create managed regmap for Ext register space
  856. *
  857. * @dev: SPMI device that will be interacted with
  858. * @config: Configuration for register map
  859. *
  860. * The return value will be an ERR_PTR() on error or a valid pointer
  861. * to a struct regmap. The regmap will be automatically freed by the
  862. * device management code.
  863. */
  864. #define devm_regmap_init_spmi_ext(dev, config) \
  865. __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \
  866. dev, config)
  867. /**
  868. * devm_regmap_init_w1() - Initialise managed register map
  869. *
  870. * @w1_dev: Device that will be interacted with
  871. * @config: Configuration for register map
  872. *
  873. * The return value will be an ERR_PTR() on error or a valid pointer
  874. * to a struct regmap. The regmap will be automatically freed by the
  875. * device management code.
  876. */
  877. #define devm_regmap_init_w1(w1_dev, config) \
  878. __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \
  879. w1_dev, config)
  880. /**
  881. * devm_regmap_init_mmio_clk() - Initialise managed register map with clock
  882. *
  883. * @dev: Device that will be interacted with
  884. * @clk_id: register clock consumer ID
  885. * @regs: Pointer to memory-mapped IO region
  886. * @config: Configuration for register map
  887. *
  888. * The return value will be an ERR_PTR() on error or a valid pointer
  889. * to a struct regmap. The regmap will be automatically freed by the
  890. * device management code.
  891. */
  892. #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \
  893. __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \
  894. dev, clk_id, regs, config)
  895. /**
  896. * devm_regmap_init_mmio() - Initialise managed register map
  897. *
  898. * @dev: Device that will be interacted with
  899. * @regs: Pointer to memory-mapped IO region
  900. * @config: Configuration for register map
  901. *
  902. * The return value will be an ERR_PTR() on error or a valid pointer
  903. * to a struct regmap. The regmap will be automatically freed by the
  904. * device management code.
  905. */
  906. #define devm_regmap_init_mmio(dev, regs, config) \
  907. devm_regmap_init_mmio_clk(dev, NULL, regs, config)
  908. /**
  909. * devm_regmap_init_ac97() - Initialise AC'97 register map
  910. *
  911. * @ac97: Device that will be interacted with
  912. * @config: Configuration for register map
  913. *
  914. * The return value will be an ERR_PTR() on error or a valid pointer
  915. * to a struct regmap. The regmap will be automatically freed by the
  916. * device management code.
  917. */
  918. #define devm_regmap_init_ac97(ac97, config) \
  919. __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \
  920. ac97, config)
  921. /**
  922. * devm_regmap_init_sdw() - Initialise managed register map
  923. *
  924. * @sdw: Device that will be interacted with
  925. * @config: Configuration for register map
  926. *
  927. * The return value will be an ERR_PTR() on error or a valid pointer
  928. * to a struct regmap. The regmap will be automatically freed by the
  929. * device management code.
  930. */
  931. #define devm_regmap_init_sdw(sdw, config) \
  932. __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \
  933. sdw, config)
  934. /**
  935. * devm_regmap_init_slimbus() - Initialise managed register map
  936. *
  937. * @slimbus: Device that will be interacted with
  938. * @config: Configuration for register map
  939. *
  940. * The return value will be an ERR_PTR() on error or a valid pointer
  941. * to a struct regmap. The regmap will be automatically freed by the
  942. * device management code.
  943. */
  944. #define devm_regmap_init_slimbus(slimbus, config) \
  945. __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \
  946. slimbus, config)
  947. /**
  948. * devm_regmap_init_i3c() - Initialise managed register map
  949. *
  950. * @i3c: Device that will be interacted with
  951. * @config: Configuration for register map
  952. *
  953. * The return value will be an ERR_PTR() on error or a valid pointer
  954. * to a struct regmap. The regmap will be automatically freed by the
  955. * device management code.
  956. */
  957. #define devm_regmap_init_i3c(i3c, config) \
  958. __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \
  959. i3c, config)
  960. /**
  961. * devm_regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave
  962. * to AVMM Bus Bridge
  963. *
  964. * @spi: Device that will be interacted with
  965. * @config: Configuration for register map
  966. *
  967. * The return value will be an ERR_PTR() on error or a valid pointer
  968. * to a struct regmap. The map will be automatically freed by the
  969. * device management code.
  970. */
  971. #define devm_regmap_init_spi_avmm(spi, config) \
  972. __regmap_lockdep_wrapper(__devm_regmap_init_spi_avmm, #config, \
  973. spi, config)
  974. int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk);
  975. void regmap_mmio_detach_clk(struct regmap *map);
  976. void regmap_exit(struct regmap *map);
  977. int regmap_reinit_cache(struct regmap *map,
  978. const struct regmap_config *config);
  979. struct regmap *dev_get_regmap(struct device *dev, const char *name);
  980. struct device *regmap_get_device(struct regmap *map);
  981. int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
  982. int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
  983. int regmap_raw_write(struct regmap *map, unsigned int reg,
  984. const void *val, size_t val_len);
  985. int regmap_noinc_write(struct regmap *map, unsigned int reg,
  986. const void *val, size_t val_len);
  987. int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
  988. size_t val_count);
  989. int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
  990. int num_regs);
  991. int regmap_multi_reg_write_bypassed(struct regmap *map,
  992. const struct reg_sequence *regs,
  993. int num_regs);
  994. int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  995. const void *val, size_t val_len);
  996. int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
  997. int regmap_raw_read(struct regmap *map, unsigned int reg,
  998. void *val, size_t val_len);
  999. int regmap_noinc_read(struct regmap *map, unsigned int reg,
  1000. void *val, size_t val_len);
  1001. int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
  1002. size_t val_count);
  1003. int regmap_update_bits_base(struct regmap *map, unsigned int reg,
  1004. unsigned int mask, unsigned int val,
  1005. bool *change, bool async, bool force);
  1006. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  1007. unsigned int mask, unsigned int val)
  1008. {
  1009. return regmap_update_bits_base(map, reg, mask, val, NULL, false, false);
  1010. }
  1011. static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
  1012. unsigned int mask, unsigned int val)
  1013. {
  1014. return regmap_update_bits_base(map, reg, mask, val, NULL, true, false);
  1015. }
  1016. static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
  1017. unsigned int mask, unsigned int val,
  1018. bool *change)
  1019. {
  1020. return regmap_update_bits_base(map, reg, mask, val,
  1021. change, false, false);
  1022. }
  1023. static inline int
  1024. regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
  1025. unsigned int mask, unsigned int val,
  1026. bool *change)
  1027. {
  1028. return regmap_update_bits_base(map, reg, mask, val,
  1029. change, true, false);
  1030. }
  1031. static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
  1032. unsigned int mask, unsigned int val)
  1033. {
  1034. return regmap_update_bits_base(map, reg, mask, val, NULL, false, true);
  1035. }
  1036. int regmap_get_val_bytes(struct regmap *map);
  1037. int regmap_get_max_register(struct regmap *map);
  1038. int regmap_get_reg_stride(struct regmap *map);
  1039. int regmap_async_complete(struct regmap *map);
  1040. bool regmap_can_raw_write(struct regmap *map);
  1041. size_t regmap_get_raw_read_max(struct regmap *map);
  1042. size_t regmap_get_raw_write_max(struct regmap *map);
  1043. int regcache_sync(struct regmap *map);
  1044. int regcache_sync_region(struct regmap *map, unsigned int min,
  1045. unsigned int max);
  1046. int regcache_drop_region(struct regmap *map, unsigned int min,
  1047. unsigned int max);
  1048. void regcache_cache_only(struct regmap *map, bool enable);
  1049. void regcache_cache_bypass(struct regmap *map, bool enable);
  1050. void regcache_mark_dirty(struct regmap *map);
  1051. bool regmap_check_range_table(struct regmap *map, unsigned int reg,
  1052. const struct regmap_access_table *table);
  1053. int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
  1054. int num_regs);
  1055. int regmap_parse_val(struct regmap *map, const void *buf,
  1056. unsigned int *val);
  1057. static inline bool regmap_reg_in_range(unsigned int reg,
  1058. const struct regmap_range *range)
  1059. {
  1060. return reg >= range->range_min && reg <= range->range_max;
  1061. }
  1062. bool regmap_reg_in_ranges(unsigned int reg,
  1063. const struct regmap_range *ranges,
  1064. unsigned int nranges);
  1065. static inline int regmap_set_bits(struct regmap *map,
  1066. unsigned int reg, unsigned int bits)
  1067. {
  1068. return regmap_update_bits_base(map, reg, bits, bits,
  1069. NULL, false, false);
  1070. }
  1071. static inline int regmap_clear_bits(struct regmap *map,
  1072. unsigned int reg, unsigned int bits)
  1073. {
  1074. return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false);
  1075. }
  1076. int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
  1077. /**
  1078. * struct reg_field - Description of an register field
  1079. *
  1080. * @reg: Offset of the register within the regmap bank
  1081. * @lsb: lsb of the register field.
  1082. * @msb: msb of the register field.
  1083. * @id_size: port size if it has some ports
  1084. * @id_offset: address offset for each ports
  1085. */
  1086. struct reg_field {
  1087. unsigned int reg;
  1088. unsigned int lsb;
  1089. unsigned int msb;
  1090. unsigned int id_size;
  1091. unsigned int id_offset;
  1092. };
  1093. #define REG_FIELD(_reg, _lsb, _msb) { \
  1094. .reg = _reg, \
  1095. .lsb = _lsb, \
  1096. .msb = _msb, \
  1097. }
  1098. #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \
  1099. .reg = _reg, \
  1100. .lsb = _lsb, \
  1101. .msb = _msb, \
  1102. .id_size = _size, \
  1103. .id_offset = _offset, \
  1104. }
  1105. struct regmap_field *regmap_field_alloc(struct regmap *regmap,
  1106. struct reg_field reg_field);
  1107. void regmap_field_free(struct regmap_field *field);
  1108. struct regmap_field *devm_regmap_field_alloc(struct device *dev,
  1109. struct regmap *regmap, struct reg_field reg_field);
  1110. void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
  1111. int regmap_field_bulk_alloc(struct regmap *regmap,
  1112. struct regmap_field **rm_field,
  1113. struct reg_field *reg_field,
  1114. int num_fields);
  1115. void regmap_field_bulk_free(struct regmap_field *field);
  1116. int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap,
  1117. struct regmap_field **field,
  1118. struct reg_field *reg_field, int num_fields);
  1119. void devm_regmap_field_bulk_free(struct device *dev,
  1120. struct regmap_field *field);
  1121. int regmap_field_read(struct regmap_field *field, unsigned int *val);
  1122. int regmap_field_update_bits_base(struct regmap_field *field,
  1123. unsigned int mask, unsigned int val,
  1124. bool *change, bool async, bool force);
  1125. int regmap_fields_read(struct regmap_field *field, unsigned int id,
  1126. unsigned int *val);
  1127. int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
  1128. unsigned int mask, unsigned int val,
  1129. bool *change, bool async, bool force);
  1130. static inline int regmap_field_write(struct regmap_field *field,
  1131. unsigned int val)
  1132. {
  1133. return regmap_field_update_bits_base(field, ~0, val,
  1134. NULL, false, false);
  1135. }
  1136. static inline int regmap_field_force_write(struct regmap_field *field,
  1137. unsigned int val)
  1138. {
  1139. return regmap_field_update_bits_base(field, ~0, val, NULL, false, true);
  1140. }
  1141. static inline int regmap_field_update_bits(struct regmap_field *field,
  1142. unsigned int mask, unsigned int val)
  1143. {
  1144. return regmap_field_update_bits_base(field, mask, val,
  1145. NULL, false, false);
  1146. }
  1147. static inline int
  1148. regmap_field_force_update_bits(struct regmap_field *field,
  1149. unsigned int mask, unsigned int val)
  1150. {
  1151. return regmap_field_update_bits_base(field, mask, val,
  1152. NULL, false, true);
  1153. }
  1154. static inline int regmap_fields_write(struct regmap_field *field,
  1155. unsigned int id, unsigned int val)
  1156. {
  1157. return regmap_fields_update_bits_base(field, id, ~0, val,
  1158. NULL, false, false);
  1159. }
  1160. static inline int regmap_fields_force_write(struct regmap_field *field,
  1161. unsigned int id, unsigned int val)
  1162. {
  1163. return regmap_fields_update_bits_base(field, id, ~0, val,
  1164. NULL, false, true);
  1165. }
  1166. static inline int
  1167. regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
  1168. unsigned int mask, unsigned int val)
  1169. {
  1170. return regmap_fields_update_bits_base(field, id, mask, val,
  1171. NULL, false, false);
  1172. }
  1173. static inline int
  1174. regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
  1175. unsigned int mask, unsigned int val)
  1176. {
  1177. return regmap_fields_update_bits_base(field, id, mask, val,
  1178. NULL, false, true);
  1179. }
  1180. /**
  1181. * struct regmap_irq_type - IRQ type definitions.
  1182. *
  1183. * @type_reg_offset: Offset register for the irq type setting.
  1184. * @type_rising_val: Register value to configure RISING type irq.
  1185. * @type_falling_val: Register value to configure FALLING type irq.
  1186. * @type_level_low_val: Register value to configure LEVEL_LOW type irq.
  1187. * @type_level_high_val: Register value to configure LEVEL_HIGH type irq.
  1188. * @types_supported: logical OR of IRQ_TYPE_* flags indicating supported types.
  1189. */
  1190. struct regmap_irq_type {
  1191. unsigned int type_reg_offset;
  1192. unsigned int type_reg_mask;
  1193. unsigned int type_rising_val;
  1194. unsigned int type_falling_val;
  1195. unsigned int type_level_low_val;
  1196. unsigned int type_level_high_val;
  1197. unsigned int types_supported;
  1198. };
  1199. /**
  1200. * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip.
  1201. *
  1202. * @reg_offset: Offset of the status/mask register within the bank
  1203. * @mask: Mask used to flag/control the register.
  1204. * @type: IRQ trigger type setting details if supported.
  1205. */
  1206. struct regmap_irq {
  1207. unsigned int reg_offset;
  1208. unsigned int mask;
  1209. struct regmap_irq_type type;
  1210. };
  1211. #define REGMAP_IRQ_REG(_irq, _off, _mask) \
  1212. [_irq] = { .reg_offset = (_off), .mask = (_mask) }
  1213. #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \
  1214. [_id] = { \
  1215. .mask = BIT((_id) % (_reg_bits)), \
  1216. .reg_offset = (_id) / (_reg_bits), \
  1217. }
  1218. #define REGMAP_IRQ_MAIN_REG_OFFSET(arr) \
  1219. { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] }
  1220. struct regmap_irq_sub_irq_map {
  1221. unsigned int num_regs;
  1222. unsigned int *offset;
  1223. };
  1224. /**
  1225. * struct regmap_irq_chip - Description of a generic regmap irq_chip.
  1226. *
  1227. * @name: Descriptive name for IRQ controller.
  1228. *
  1229. * @main_status: Base main status register address. For chips which have
  1230. * interrupts arranged in separate sub-irq blocks with own IRQ
  1231. * registers and which have a main IRQ registers indicating
  1232. * sub-irq blocks with unhandled interrupts. For such chips fill
  1233. * sub-irq register information in status_base, mask_base and
  1234. * ack_base.
  1235. * @num_main_status_bits: Should be given to chips where number of meaningfull
  1236. * main status bits differs from num_regs.
  1237. * @sub_reg_offsets: arrays of mappings from main register bits to sub irq
  1238. * registers. First item in array describes the registers
  1239. * for first main status bit. Second array for second bit etc.
  1240. * Offset is given as sub register status offset to
  1241. * status_base. Should contain num_regs arrays.
  1242. * Can be provided for chips with more complex mapping than
  1243. * 1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ...
  1244. * @num_main_regs: Number of 'main status' irq registers for chips which have
  1245. * main_status set.
  1246. *
  1247. * @status_base: Base status register address.
  1248. * @mask_base: Base mask register address.
  1249. * @mask_writeonly: Base mask register is write only.
  1250. * @unmask_base: Base unmask register address. for chips who have
  1251. * separate mask and unmask registers
  1252. * @ack_base: Base ack address. If zero then the chip is clear on read.
  1253. * Using zero value is possible with @use_ack bit.
  1254. * @wake_base: Base address for wake enables. If zero unsupported.
  1255. * @type_base: Base address for irq type. If zero unsupported.
  1256. * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
  1257. * @init_ack_masked: Ack all masked interrupts once during initalization.
  1258. * @mask_invert: Inverted mask register: cleared bits are masked out.
  1259. * @use_ack: Use @ack register even if it is zero.
  1260. * @ack_invert: Inverted ack register: cleared bits for ack.
  1261. * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts.
  1262. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  1263. * @type_invert: Invert the type flags.
  1264. * @type_in_mask: Use the mask registers for controlling irq type. For
  1265. * interrupts defining type_rising/falling_mask use mask_base
  1266. * for edge configuration and never update bits in type_base.
  1267. * @clear_on_unmask: For chips with interrupts cleared on read: read the status
  1268. * registers before unmasking interrupts to clear any bits
  1269. * set when they were masked.
  1270. * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
  1271. *
  1272. * @num_regs: Number of registers in each control bank.
  1273. * @irqs: Descriptors for individual IRQs. Interrupt numbers are
  1274. * assigned based on the index in the array of the interrupt.
  1275. * @num_irqs: Number of descriptors.
  1276. * @num_type_reg: Number of type registers.
  1277. * @type_reg_stride: Stride to use for chips where type registers are not
  1278. * contiguous.
  1279. * @handle_pre_irq: Driver specific callback to handle interrupt from device
  1280. * before regmap_irq_handler process the interrupts.
  1281. * @handle_post_irq: Driver specific callback to handle interrupt from device
  1282. * after handling the interrupts in regmap_irq_handler().
  1283. * @irq_drv_data: Driver specific IRQ data which is passed as parameter when
  1284. * driver specific pre/post interrupt handler is called.
  1285. *
  1286. * This is not intended to handle every possible interrupt controller, but
  1287. * it should handle a substantial proportion of those that are found in the
  1288. * wild.
  1289. */
  1290. struct regmap_irq_chip {
  1291. const char *name;
  1292. unsigned int main_status;
  1293. unsigned int num_main_status_bits;
  1294. struct regmap_irq_sub_irq_map *sub_reg_offsets;
  1295. int num_main_regs;
  1296. unsigned int status_base;
  1297. unsigned int mask_base;
  1298. unsigned int unmask_base;
  1299. unsigned int ack_base;
  1300. unsigned int wake_base;
  1301. unsigned int type_base;
  1302. unsigned int irq_reg_stride;
  1303. bool mask_writeonly:1;
  1304. bool init_ack_masked:1;
  1305. bool mask_invert:1;
  1306. bool use_ack:1;
  1307. bool ack_invert:1;
  1308. bool clear_ack:1;
  1309. bool wake_invert:1;
  1310. bool runtime_pm:1;
  1311. bool type_invert:1;
  1312. bool type_in_mask:1;
  1313. bool clear_on_unmask:1;
  1314. int num_regs;
  1315. const struct regmap_irq *irqs;
  1316. int num_irqs;
  1317. int num_type_reg;
  1318. unsigned int type_reg_stride;
  1319. int (*handle_pre_irq)(void *irq_drv_data);
  1320. int (*handle_post_irq)(void *irq_drv_data);
  1321. void *irq_drv_data;
  1322. };
  1323. struct regmap_irq_chip_data;
  1324. int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
  1325. int irq_base, const struct regmap_irq_chip *chip,
  1326. struct regmap_irq_chip_data **data);
  1327. int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
  1328. struct regmap *map, int irq,
  1329. int irq_flags, int irq_base,
  1330. const struct regmap_irq_chip *chip,
  1331. struct regmap_irq_chip_data **data);
  1332. void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
  1333. int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
  1334. int irq_flags, int irq_base,
  1335. const struct regmap_irq_chip *chip,
  1336. struct regmap_irq_chip_data **data);
  1337. int devm_regmap_add_irq_chip_fwnode(struct device *dev,
  1338. struct fwnode_handle *fwnode,
  1339. struct regmap *map, int irq,
  1340. int irq_flags, int irq_base,
  1341. const struct regmap_irq_chip *chip,
  1342. struct regmap_irq_chip_data **data);
  1343. void devm_regmap_del_irq_chip(struct device *dev, int irq,
  1344. struct regmap_irq_chip_data *data);
  1345. int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  1346. int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
  1347. struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
  1348. #else
  1349. /*
  1350. * These stubs should only ever be called by generic code which has
  1351. * regmap based facilities, if they ever get called at runtime
  1352. * something is going wrong and something probably needs to select
  1353. * REGMAP.
  1354. */
  1355. static inline int regmap_write(struct regmap *map, unsigned int reg,
  1356. unsigned int val)
  1357. {
  1358. WARN_ONCE(1, "regmap API is disabled");
  1359. return -EINVAL;
  1360. }
  1361. static inline int regmap_write_async(struct regmap *map, unsigned int reg,
  1362. unsigned int val)
  1363. {
  1364. WARN_ONCE(1, "regmap API is disabled");
  1365. return -EINVAL;
  1366. }
  1367. static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
  1368. const void *val, size_t val_len)
  1369. {
  1370. WARN_ONCE(1, "regmap API is disabled");
  1371. return -EINVAL;
  1372. }
  1373. static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
  1374. const void *val, size_t val_len)
  1375. {
  1376. WARN_ONCE(1, "regmap API is disabled");
  1377. return -EINVAL;
  1378. }
  1379. static inline int regmap_noinc_write(struct regmap *map, unsigned int reg,
  1380. const void *val, size_t val_len)
  1381. {
  1382. WARN_ONCE(1, "regmap API is disabled");
  1383. return -EINVAL;
  1384. }
  1385. static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  1386. const void *val, size_t val_count)
  1387. {
  1388. WARN_ONCE(1, "regmap API is disabled");
  1389. return -EINVAL;
  1390. }
  1391. static inline int regmap_read(struct regmap *map, unsigned int reg,
  1392. unsigned int *val)
  1393. {
  1394. WARN_ONCE(1, "regmap API is disabled");
  1395. return -EINVAL;
  1396. }
  1397. static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  1398. void *val, size_t val_len)
  1399. {
  1400. WARN_ONCE(1, "regmap API is disabled");
  1401. return -EINVAL;
  1402. }
  1403. static inline int regmap_noinc_read(struct regmap *map, unsigned int reg,
  1404. void *val, size_t val_len)
  1405. {
  1406. WARN_ONCE(1, "regmap API is disabled");
  1407. return -EINVAL;
  1408. }
  1409. static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  1410. void *val, size_t val_count)
  1411. {
  1412. WARN_ONCE(1, "regmap API is disabled");
  1413. return -EINVAL;
  1414. }
  1415. static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
  1416. unsigned int mask, unsigned int val,
  1417. bool *change, bool async, bool force)
  1418. {
  1419. WARN_ONCE(1, "regmap API is disabled");
  1420. return -EINVAL;
  1421. }
  1422. static inline int regmap_set_bits(struct regmap *map,
  1423. unsigned int reg, unsigned int bits)
  1424. {
  1425. WARN_ONCE(1, "regmap API is disabled");
  1426. return -EINVAL;
  1427. }
  1428. static inline int regmap_clear_bits(struct regmap *map,
  1429. unsigned int reg, unsigned int bits)
  1430. {
  1431. WARN_ONCE(1, "regmap API is disabled");
  1432. return -EINVAL;
  1433. }
  1434. static inline int regmap_test_bits(struct regmap *map,
  1435. unsigned int reg, unsigned int bits)
  1436. {
  1437. WARN_ONCE(1, "regmap API is disabled");
  1438. return -EINVAL;
  1439. }
  1440. static inline int regmap_field_update_bits_base(struct regmap_field *field,
  1441. unsigned int mask, unsigned int val,
  1442. bool *change, bool async, bool force)
  1443. {
  1444. WARN_ONCE(1, "regmap API is disabled");
  1445. return -EINVAL;
  1446. }
  1447. static inline int regmap_fields_update_bits_base(struct regmap_field *field,
  1448. unsigned int id,
  1449. unsigned int mask, unsigned int val,
  1450. bool *change, bool async, bool force)
  1451. {
  1452. WARN_ONCE(1, "regmap API is disabled");
  1453. return -EINVAL;
  1454. }
  1455. static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  1456. unsigned int mask, unsigned int val)
  1457. {
  1458. WARN_ONCE(1, "regmap API is disabled");
  1459. return -EINVAL;
  1460. }
  1461. static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
  1462. unsigned int mask, unsigned int val)
  1463. {
  1464. WARN_ONCE(1, "regmap API is disabled");
  1465. return -EINVAL;
  1466. }
  1467. static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
  1468. unsigned int mask, unsigned int val,
  1469. bool *change)
  1470. {
  1471. WARN_ONCE(1, "regmap API is disabled");
  1472. return -EINVAL;
  1473. }
  1474. static inline int
  1475. regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
  1476. unsigned int mask, unsigned int val,
  1477. bool *change)
  1478. {
  1479. WARN_ONCE(1, "regmap API is disabled");
  1480. return -EINVAL;
  1481. }
  1482. static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
  1483. unsigned int mask, unsigned int val)
  1484. {
  1485. WARN_ONCE(1, "regmap API is disabled");
  1486. return -EINVAL;
  1487. }
  1488. static inline int regmap_field_write(struct regmap_field *field,
  1489. unsigned int val)
  1490. {
  1491. WARN_ONCE(1, "regmap API is disabled");
  1492. return -EINVAL;
  1493. }
  1494. static inline int regmap_field_force_write(struct regmap_field *field,
  1495. unsigned int val)
  1496. {
  1497. WARN_ONCE(1, "regmap API is disabled");
  1498. return -EINVAL;
  1499. }
  1500. static inline int regmap_field_update_bits(struct regmap_field *field,
  1501. unsigned int mask, unsigned int val)
  1502. {
  1503. WARN_ONCE(1, "regmap API is disabled");
  1504. return -EINVAL;
  1505. }
  1506. static inline int
  1507. regmap_field_force_update_bits(struct regmap_field *field,
  1508. unsigned int mask, unsigned int val)
  1509. {
  1510. WARN_ONCE(1, "regmap API is disabled");
  1511. return -EINVAL;
  1512. }
  1513. static inline int regmap_fields_write(struct regmap_field *field,
  1514. unsigned int id, unsigned int val)
  1515. {
  1516. WARN_ONCE(1, "regmap API is disabled");
  1517. return -EINVAL;
  1518. }
  1519. static inline int regmap_fields_force_write(struct regmap_field *field,
  1520. unsigned int id, unsigned int val)
  1521. {
  1522. WARN_ONCE(1, "regmap API is disabled");
  1523. return -EINVAL;
  1524. }
  1525. static inline int
  1526. regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
  1527. unsigned int mask, unsigned int val)
  1528. {
  1529. WARN_ONCE(1, "regmap API is disabled");
  1530. return -EINVAL;
  1531. }
  1532. static inline int
  1533. regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
  1534. unsigned int mask, unsigned int val)
  1535. {
  1536. WARN_ONCE(1, "regmap API is disabled");
  1537. return -EINVAL;
  1538. }
  1539. static inline int regmap_get_val_bytes(struct regmap *map)
  1540. {
  1541. WARN_ONCE(1, "regmap API is disabled");
  1542. return -EINVAL;
  1543. }
  1544. static inline int regmap_get_max_register(struct regmap *map)
  1545. {
  1546. WARN_ONCE(1, "regmap API is disabled");
  1547. return -EINVAL;
  1548. }
  1549. static inline int regmap_get_reg_stride(struct regmap *map)
  1550. {
  1551. WARN_ONCE(1, "regmap API is disabled");
  1552. return -EINVAL;
  1553. }
  1554. static inline int regcache_sync(struct regmap *map)
  1555. {
  1556. WARN_ONCE(1, "regmap API is disabled");
  1557. return -EINVAL;
  1558. }
  1559. static inline int regcache_sync_region(struct regmap *map, unsigned int min,
  1560. unsigned int max)
  1561. {
  1562. WARN_ONCE(1, "regmap API is disabled");
  1563. return -EINVAL;
  1564. }
  1565. static inline int regcache_drop_region(struct regmap *map, unsigned int min,
  1566. unsigned int max)
  1567. {
  1568. WARN_ONCE(1, "regmap API is disabled");
  1569. return -EINVAL;
  1570. }
  1571. static inline void regcache_cache_only(struct regmap *map, bool enable)
  1572. {
  1573. WARN_ONCE(1, "regmap API is disabled");
  1574. }
  1575. static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  1576. {
  1577. WARN_ONCE(1, "regmap API is disabled");
  1578. }
  1579. static inline void regcache_mark_dirty(struct regmap *map)
  1580. {
  1581. WARN_ONCE(1, "regmap API is disabled");
  1582. }
  1583. static inline void regmap_async_complete(struct regmap *map)
  1584. {
  1585. WARN_ONCE(1, "regmap API is disabled");
  1586. }
  1587. static inline int regmap_register_patch(struct regmap *map,
  1588. const struct reg_sequence *regs,
  1589. int num_regs)
  1590. {
  1591. WARN_ONCE(1, "regmap API is disabled");
  1592. return -EINVAL;
  1593. }
  1594. static inline int regmap_parse_val(struct regmap *map, const void *buf,
  1595. unsigned int *val)
  1596. {
  1597. WARN_ONCE(1, "regmap API is disabled");
  1598. return -EINVAL;
  1599. }
  1600. static inline struct regmap *dev_get_regmap(struct device *dev,
  1601. const char *name)
  1602. {
  1603. return NULL;
  1604. }
  1605. static inline struct device *regmap_get_device(struct regmap *map)
  1606. {
  1607. WARN_ONCE(1, "regmap API is disabled");
  1608. return NULL;
  1609. }
  1610. #endif
  1611. #endif