Changeset 625 for GPL/branches/uniaud32-next/include/linux/regmap.h
- Timestamp:
- Jan 3, 2021, 7:20:20 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/include/linux/regmap.h
r615 r625 13 13 * published by the Free Software Foundation. 14 14 */ 15 /* from 4.1 4.202*/15 /* from 4.19.163 */ 16 16 17 17 #include <linux/list.h> 18 18 #include <linux/rbtree.h> 19 #include <linux/ktime.h> 19 20 #include <linux/delay.h> 20 21 #include <linux/err.h> … … 22 23 #include <linux/lockdep.h> 23 24 24 #define CONFIG_REGMAP25 26 25 struct module; 26 struct clk; 27 27 struct device; 28 28 struct i2c_client; 29 29 struct irq_domain; 30 struct slim_device; 30 31 struct spi_device; 31 32 struct spmi_device; … … 34 35 struct regmap_field; 35 36 struct snd_ac97; 37 struct sdw_slave; 36 38 37 39 /* An enum of all the supported cache types */ … … 124 126 #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ 125 127 ({ \ 126 ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ 128 u64 __timeout_us = (timeout_us); \ 129 unsigned long __sleep_us = (sleep_us); \ 130 ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ 131 int __ret; \ 132 might_sleep_if(__sleep_us); \ 133 for (;;) { \ 134 __ret = regmap_read((map), (addr), &(val)); \ 135 if (__ret) \ 136 break; \ 137 if (cond) \ 138 break; \ 139 if ((__timeout_us) && \ 140 ktime_compare(ktime_get(), __timeout) > 0) { \ 141 __ret = regmap_read((map), (addr), &(val)); \ 142 break; \ 143 } \ 144 if (__sleep_us) \ 145 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ 146 } \ 147 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ 148 }) 149 150 /** 151 * regmap_field_read_poll_timeout - Poll until a condition is met or timeout 152 * 153 * @field: Regmap field to read from 154 * @val: Unsigned integer variable to read the value into 155 * @cond: Break condition (usually involving @val) 156 * @sleep_us: Maximum time to sleep between reads in us (0 157 * tight-loops). Should be less than ~20ms since usleep_range 158 * is used (see Documentation/timers/timers-howto.txt). 159 * @timeout_us: Timeout in us, 0 means never timeout 160 * 161 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read 162 * error return value in case of a error read. In the two former cases, 163 * the last read value at @addr is stored in @val. Must not be called 164 * from atomic context if sleep_us or timeout_us are used. 165 * 166 * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. 167 */ 168 #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ 169 ({ \ 170 u64 __timeout_us = (timeout_us); \ 171 unsigned long __sleep_us = (sleep_us); \ 172 ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \ 127 173 int pollret; \ 128 might_sleep_if( sleep_us); \174 might_sleep_if(__sleep_us); \ 129 175 for (;;) { \ 130 pollret = regmap_ read((map), (addr), &(val)); \176 pollret = regmap_field_read((field), &(val)); \ 131 177 if (pollret) \ 132 178 break; \ 133 179 if (cond) \ 134 180 break; \ 135 if ( timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \136 pollret = regmap_ read((map), (addr), &(val)); \181 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ 182 pollret = regmap_field_read((field), &(val)); \ 137 183 break; \ 138 184 } \ 139 if ( sleep_us) \140 usleep_range(( sleep_us >> 2) + 1,sleep_us); \185 if (__sleep_us) \ 186 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ 141 187 } \ 142 188 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ 143 189 }) 144 190 191 #define CONFIG_REGMAP 145 192 #ifdef CONFIG_REGMAP 146 193 … … 224 271 * check is performed on such table (a register is precious if 225 272 * it belongs to one of the ranges specified by precious_table). 273 * @readable_noinc_reg: Optional callback returning true if the register 274 * supports multiple read operations without incrementing 275 * the register number. If this field is NULL but 276 * rd_noinc_table (see below) is not, the check is 277 * performed on such table (a register is no increment 278 * readable if it belongs to one of the ranges specified 279 * by rd_noinc_table). 280 * @disable_locking: This regmap is either protected by external means or 281 * is guaranteed not be be accessed from multiple threads. 282 * Don't use any locking mechanisms. 226 283 * @lock: Optional lock callback (overrides regmap's default lock 227 284 * function, based on spinlock or mutex). … … 248 305 * @volatile_table: As above, for volatile registers. 249 306 * @precious_table: As above, for precious registers. 307 * @rd_noinc_table: As above, for no increment readable registers. 250 308 * @reg_defaults: Power on reset values for registers (for use with 251 309 * register cache support). … … 256 314 * @write_flag_mask: Mask to be set in the top bytes of the register when doing 257 315 * a write. If both read_flag_mask and write_flag_mask are 258 * empty the regmap_bus default masks are used. 316 * empty and zero_flag_mask is not set the regmap_bus default 317 * masks are used. 318 * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even 319 * if they are both empty. 259 320 * @use_single_rw: If set, converts the bulk read and write operations into 260 321 * a series of single read and write operations. This is useful … … 277 338 * @ranges: Array of configuration entries for virtual address ranges. 278 339 * @num_ranges: Number of range configuration entries. 340 * @use_hwlock: Indicate if a hardware spinlock should be used. 341 * @hwlock_id: Specify the hardware spinlock id. 342 * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE, 343 * HWLOCK_IRQ or 0. 279 344 */ 280 345 struct regmap_config { … … 290 355 bool (*volatile_reg)(struct device *dev, unsigned int reg); 291 356 bool (*precious_reg)(struct device *dev, unsigned int reg); 357 bool (*readable_noinc_reg)(struct device *dev, unsigned int reg); 358 359 bool disable_locking; 292 360 regmap_lock lock; 293 361 regmap_unlock unlock; … … 304 372 const struct regmap_access_table *volatile_table; 305 373 const struct regmap_access_table *precious_table; 374 const struct regmap_access_table *rd_noinc_table; 306 375 const struct reg_default *reg_defaults; 307 376 unsigned int num_reg_defaults; … … 312 381 unsigned long read_flag_mask; 313 382 unsigned long write_flag_mask; 383 bool zero_flag_mask; 314 384 315 385 bool use_single_read; … … 322 392 const struct regmap_range_cfg *ranges; 323 393 unsigned int num_ranges; 394 395 bool use_hwlock; 396 unsigned int hwlock_id; 397 unsigned int hwlock_mode; 324 398 }; 325 399 … … 454 528 struct lock_class_key *lock_key, 455 529 const char *lock_name); 530 struct regmap *__regmap_init_sccb(struct i2c_client *i2c, 531 const struct regmap_config *config, 532 struct lock_class_key *lock_key, 533 const char *lock_name); 534 struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, 535 const struct regmap_config *config, 536 struct lock_class_key *lock_key, 537 const char *lock_name); 456 538 struct regmap *__regmap_init_spi(struct spi_device *dev, 457 539 const struct regmap_config *config, … … 479 561 struct lock_class_key *lock_key, 480 562 const char *lock_name); 563 struct regmap *__regmap_init_sdw(struct sdw_slave *sdw, 564 const struct regmap_config *config, 565 struct lock_class_key *lock_key, 566 const char *lock_name); 481 567 482 568 struct regmap *__devm_regmap_init(struct device *dev, … … 490 576 struct lock_class_key *lock_key, 491 577 const char *lock_name); 578 struct regmap *__devm_regmap_init_sccb(struct i2c_client *i2c, 579 const struct regmap_config *config, 580 struct lock_class_key *lock_key, 581 const char *lock_name); 492 582 struct regmap *__devm_regmap_init_spi(struct spi_device *dev, 493 583 const struct regmap_config *config, … … 516 606 struct lock_class_key *lock_key, 517 607 const char *lock_name); 518 608 struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw, 609 const struct regmap_config *config, 610 struct lock_class_key *lock_key, 611 const char *lock_name); 612 struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, 613 const struct regmap_config *config, 614 struct lock_class_key *lock_key, 615 const char *lock_name); 519 616 /* 520 617 * Wrapper for regmap_init macros to include a unique lockdep key and name … … 571 668 572 669 /** 670 * regmap_init_sccb() - Initialise register map 671 * 672 * @i2c: Device that will be interacted with 673 * @config: Configuration for register map 674 * 675 * The return value will be an ERR_PTR() on error or a valid pointer to 676 * a struct regmap. 677 */ 678 #define regmap_init_sccb(i2c, config) \ 679 __regmap_lockdep_wrapper(__regmap_init_sccb, #config, \ 680 i2c, config) 681 682 /** 683 * regmap_init_slimbus() - Initialise register map 684 * 685 * @slimbus: Device that will be interacted with 686 * @config: Configuration for register map 687 * 688 * The return value will be an ERR_PTR() on error or a valid pointer to 689 * a struct regmap. 690 */ 691 #define regmap_init_slimbus(slimbus, config) \ 692 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \ 693 slimbus, config) 694 695 /** 573 696 * regmap_init_spi() - Initialise register map 574 697 * … … 665 788 666 789 /** 790 * regmap_init_sdw() - Initialise register map 791 * 792 * @sdw: Device that will be interacted with 793 * @config: Configuration for register map 794 * 795 * The return value will be an ERR_PTR() on error or a valid pointer to 796 * a struct regmap. 797 */ 798 #define regmap_init_sdw(sdw, config) \ 799 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ 800 sdw, config) 801 802 803 /** 667 804 * devm_regmap_init() - Initialise managed register map 668 805 * … … 696 833 697 834 /** 835 * devm_regmap_init_sccb() - Initialise managed register map 836 * 837 * @i2c: Device that will be interacted with 838 * @config: Configuration for register map 839 * 840 * The return value will be an ERR_PTR() on error or a valid pointer 841 * to a struct regmap. The regmap will be automatically freed by the 842 * device management code. 843 */ 844 #define devm_regmap_init_sccb(i2c, config) \ 845 __regmap_lockdep_wrapper(__devm_regmap_init_sccb, #config, \ 846 i2c, config) 847 848 /** 698 849 * devm_regmap_init_spi() - Initialise register map 699 850 * … … 794 945 ac97, config) 795 946 947 /** 948 * devm_regmap_init_sdw() - Initialise managed register map 949 * 950 * @sdw: 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_sdw(sdw, config) \ 958 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ 959 sdw, config) 960 961 /** 962 * devm_regmap_init_slimbus() - Initialise managed register map 963 * 964 * @slimbus: 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 regmap will be automatically freed by the 969 * device management code. 970 */ 971 #define devm_regmap_init_slimbus(slimbus, config) \ 972 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ 973 slimbus, config) 974 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); 975 void regmap_mmio_detach_clk(struct regmap *map); 796 976 void regmap_exit(struct regmap *map); 797 977 int regmap_reinit_cache(struct regmap *map, … … 815 995 int regmap_raw_read(struct regmap *map, unsigned int reg, 816 996 void *val, size_t val_len); 997 int regmap_noinc_read(struct regmap *map, unsigned int reg, 998 void *val, size_t val_len); 817 999 int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, 818 1000 size_t val_count); … … 1019 1201 unsigned int val) 1020 1202 { 1021 WARN_ONCE(1, "regmap API is disabled");1203 // WARN_ONCE(1, "regmap API is disabled"); 1022 1204 return -EINVAL; 1023 1205 } … … 1060 1242 static inline int regmap_raw_read(struct regmap *map, unsigned int reg, 1061 1243 void *val, size_t val_len) 1244 { 1245 WARN_ONCE(1, "regmap API is disabled"); 1246 return -EINVAL; 1247 } 1248 1249 static inline int regmap_noinc_read(struct regmap *map, unsigned int reg, 1250 void *val, size_t val_len) 1062 1251 { 1063 1252 WARN_ONCE(1, "regmap API is disabled");
Note:
See TracChangeset
for help on using the changeset viewer.