diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 12:20:55 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 12:20:55 -0500 |
| commit | 88cff241596f29122e9125a41b20d21dfed873cd (patch) | |
| tree | 8b9cd99d8e5e26a349a060b5856fa7c40fc06e64 /include/linux | |
| parent | 9ae46e6702d98d22037368896298d05958ad5737 (diff) | |
| parent | a2b37efc4e2aa76a5be29bbde8a2cd1c9c9066bc (diff) | |
Merge tag 'regmap-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap updates from Mark Brown:
"Several nice new features and performance improvements here,
especially the first:
- Support for using the cache infrastructure without the physical
I/O, allowing devices which don't fit the physical model regmap has
to take advantage of the cache infrastructure, contributed by
Andrey Smirnov.
- Several small improvements to the support for wake capable IRQs.
- Support for asynchronous I/O, allowing us to come much closer to
saturating fast buses like SPI.
- Support for simple array caches, giving higher performance for use
with MMIO devices.
- Restoration of the use of bulk reads for handling interrupts,
giving a performance improvement.
- Support for 24 bit register addresses.
- More performance improvements for debugfs."
* tag 'regmap-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: (24 commits)
regmap: mmio: add register clock support
regmap: debugfs: Factor out debugfs_tot_len calc into a function
regmap: debugfs: Optimize seeking within blocks of registers
regmap: debugfs: Add a `max_reg' member in struct regmap_debugfs_off_cache
regmap: debugfs: Fix reading in register field units
regmap: spi: Handle allocation failures gracefully
regmap: Export regmap_async_complete()
regmap: Export regmap_async_complete_cb
regmap: include linux/sched.h to fix build
regmap: spi: Support asynchronous I/O for SPI
regmap: Add asynchronous I/O support
regmap: Add "no-bus" option for regmap API
regmap: regmap: avoid spurious warning in regmap_read_debugfs
regmap: Add provisions to have user-defined write operation
regmap: Add provisions to have user-defined read operation
regmap: Add support for 24 bit wide register addresses
mfd: wm5110: Mark wakes as inverted
mfd: wm5102: Mark wakes as inverted
regmap: irq: Support wake IRQ mask inversion
regmap: irq: Fix sync of wake statuses to hardware
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/regmap.h | 97 |
1 files changed, 89 insertions, 8 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index b7e95bf942c9..bf77dfdabef9 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
| @@ -28,7 +28,8 @@ struct regmap_range_cfg; | |||
| 28 | enum regcache_type { | 28 | enum regcache_type { |
| 29 | REGCACHE_NONE, | 29 | REGCACHE_NONE, |
| 30 | REGCACHE_RBTREE, | 30 | REGCACHE_RBTREE, |
| 31 | REGCACHE_COMPRESSED | 31 | REGCACHE_COMPRESSED, |
| 32 | REGCACHE_FLAT, | ||
| 32 | }; | 33 | }; |
| 33 | 34 | ||
| 34 | /** | 35 | /** |
| @@ -127,7 +128,18 @@ typedef void (*regmap_unlock)(void *); | |||
| 127 | * @lock_arg: this field is passed as the only argument of lock/unlock | 128 | * @lock_arg: this field is passed as the only argument of lock/unlock |
| 128 | * functions (ignored in case regular lock/unlock functions | 129 | * functions (ignored in case regular lock/unlock functions |
| 129 | * are not overridden). | 130 | * are not overridden). |
| 130 | * | 131 | * @reg_read: Optional callback that if filled will be used to perform |
| 132 | * all the reads from the registers. Should only be provided for | ||
| 133 | * devices whos read operation cannot be represented as a simple read | ||
| 134 | * operation on a bus such as SPI, I2C, etc. Most of the devices do | ||
| 135 | * not need this. | ||
| 136 | * @reg_write: Same as above for writing. | ||
| 137 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex | ||
| 138 | * to perform locking. This field is ignored if custom lock/unlock | ||
| 139 | * functions are used (see fields lock/unlock of struct regmap_config). | ||
| 140 | * This field is a duplicate of a similar file in | ||
| 141 | * 'struct regmap_bus' and serves exact same purpose. | ||
| 142 | * Use it only for "no-bus" cases. | ||
| 131 | * @max_register: Optional, specifies the maximum valid register index. | 143 | * @max_register: Optional, specifies the maximum valid register index. |
| 132 | * @wr_table: Optional, points to a struct regmap_access_table specifying | 144 | * @wr_table: Optional, points to a struct regmap_access_table specifying |
| 133 | * valid ranges for write access. | 145 | * valid ranges for write access. |
| @@ -177,6 +189,11 @@ struct regmap_config { | |||
| 177 | regmap_unlock unlock; | 189 | regmap_unlock unlock; |
| 178 | void *lock_arg; | 190 | void *lock_arg; |
| 179 | 191 | ||
| 192 | int (*reg_read)(void *context, unsigned int reg, unsigned int *val); | ||
| 193 | int (*reg_write)(void *context, unsigned int reg, unsigned int val); | ||
| 194 | |||
| 195 | bool fast_io; | ||
| 196 | |||
| 180 | unsigned int max_register; | 197 | unsigned int max_register; |
| 181 | const struct regmap_access_table *wr_table; | 198 | const struct regmap_access_table *wr_table; |
| 182 | const struct regmap_access_table *rd_table; | 199 | const struct regmap_access_table *rd_table; |
| @@ -235,14 +252,21 @@ struct regmap_range_cfg { | |||
| 235 | unsigned int window_len; | 252 | unsigned int window_len; |
| 236 | }; | 253 | }; |
| 237 | 254 | ||
| 255 | struct regmap_async; | ||
| 256 | |||
| 238 | typedef int (*regmap_hw_write)(void *context, const void *data, | 257 | typedef int (*regmap_hw_write)(void *context, const void *data, |
| 239 | size_t count); | 258 | size_t count); |
| 240 | typedef int (*regmap_hw_gather_write)(void *context, | 259 | typedef int (*regmap_hw_gather_write)(void *context, |
| 241 | const void *reg, size_t reg_len, | 260 | const void *reg, size_t reg_len, |
| 242 | const void *val, size_t val_len); | 261 | const void *val, size_t val_len); |
| 262 | typedef int (*regmap_hw_async_write)(void *context, | ||
| 263 | const void *reg, size_t reg_len, | ||
| 264 | const void *val, size_t val_len, | ||
| 265 | struct regmap_async *async); | ||
| 243 | typedef int (*regmap_hw_read)(void *context, | 266 | typedef int (*regmap_hw_read)(void *context, |
| 244 | const void *reg_buf, size_t reg_size, | 267 | const void *reg_buf, size_t reg_size, |
| 245 | void *val_buf, size_t val_size); | 268 | void *val_buf, size_t val_size); |
| 269 | typedef struct regmap_async *(*regmap_hw_async_alloc)(void); | ||
| 246 | typedef void (*regmap_hw_free_context)(void *context); | 270 | typedef void (*regmap_hw_free_context)(void *context); |
| 247 | 271 | ||
| 248 | /** | 272 | /** |
| @@ -255,8 +279,11 @@ typedef void (*regmap_hw_free_context)(void *context); | |||
| 255 | * @write: Write operation. | 279 | * @write: Write operation. |
| 256 | * @gather_write: Write operation with split register/value, return -ENOTSUPP | 280 | * @gather_write: Write operation with split register/value, return -ENOTSUPP |
| 257 | * if not implemented on a given device. | 281 | * if not implemented on a given device. |
| 282 | * @async_write: Write operation which completes asynchronously, optional and | ||
| 283 | * must serialise with respect to non-async I/O. | ||
| 258 | * @read: Read operation. Data is returned in the buffer used to transmit | 284 | * @read: Read operation. Data is returned in the buffer used to transmit |
| 259 | * data. | 285 | * data. |
| 286 | * @async_alloc: Allocate a regmap_async() structure. | ||
| 260 | * @read_flag_mask: Mask to be set in the top byte of the register when doing | 287 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 261 | * a read. | 288 | * a read. |
| 262 | * @reg_format_endian_default: Default endianness for formatted register | 289 | * @reg_format_endian_default: Default endianness for formatted register |
| @@ -265,13 +292,16 @@ typedef void (*regmap_hw_free_context)(void *context); | |||
| 265 | * @val_format_endian_default: Default endianness for formatted register | 292 | * @val_format_endian_default: Default endianness for formatted register |
| 266 | * values. Used when the regmap_config specifies DEFAULT. If this is | 293 | * values. Used when the regmap_config specifies DEFAULT. If this is |
| 267 | * DEFAULT, BIG is assumed. | 294 | * DEFAULT, BIG is assumed. |
| 295 | * @async_size: Size of struct used for async work. | ||
| 268 | */ | 296 | */ |
| 269 | struct regmap_bus { | 297 | struct regmap_bus { |
| 270 | bool fast_io; | 298 | bool fast_io; |
| 271 | regmap_hw_write write; | 299 | regmap_hw_write write; |
| 272 | regmap_hw_gather_write gather_write; | 300 | regmap_hw_gather_write gather_write; |
| 301 | regmap_hw_async_write async_write; | ||
| 273 | regmap_hw_read read; | 302 | regmap_hw_read read; |
| 274 | regmap_hw_free_context free_context; | 303 | regmap_hw_free_context free_context; |
| 304 | regmap_hw_async_alloc async_alloc; | ||
| 275 | u8 read_flag_mask; | 305 | u8 read_flag_mask; |
| 276 | enum regmap_endian reg_format_endian_default; | 306 | enum regmap_endian reg_format_endian_default; |
| 277 | enum regmap_endian val_format_endian_default; | 307 | enum regmap_endian val_format_endian_default; |
| @@ -285,9 +315,9 @@ struct regmap *regmap_init_i2c(struct i2c_client *i2c, | |||
| 285 | const struct regmap_config *config); | 315 | const struct regmap_config *config); |
| 286 | struct regmap *regmap_init_spi(struct spi_device *dev, | 316 | struct regmap *regmap_init_spi(struct spi_device *dev, |
| 287 | const struct regmap_config *config); | 317 | const struct regmap_config *config); |
| 288 | struct regmap *regmap_init_mmio(struct device *dev, | 318 | struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
| 289 | void __iomem *regs, | 319 | void __iomem *regs, |
| 290 | const struct regmap_config *config); | 320 | const struct regmap_config *config); |
| 291 | 321 | ||
| 292 | struct regmap *devm_regmap_init(struct device *dev, | 322 | struct regmap *devm_regmap_init(struct device *dev, |
| 293 | const struct regmap_bus *bus, | 323 | const struct regmap_bus *bus, |
| @@ -297,9 +327,44 @@ struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, | |||
| 297 | const struct regmap_config *config); | 327 | const struct regmap_config *config); |
| 298 | struct regmap *devm_regmap_init_spi(struct spi_device *dev, | 328 | struct regmap *devm_regmap_init_spi(struct spi_device *dev, |
| 299 | const struct regmap_config *config); | 329 | const struct regmap_config *config); |
| 300 | struct regmap *devm_regmap_init_mmio(struct device *dev, | 330 | struct regmap *devm_regmap_init_mmio_clk(struct device *dev, const char *clk_id, |
| 301 | void __iomem *regs, | 331 | void __iomem *regs, |
| 302 | const struct regmap_config *config); | 332 | const struct regmap_config *config); |
| 333 | |||
| 334 | /** | ||
| 335 | * regmap_init_mmio(): Initialise register map | ||
| 336 | * | ||
| 337 | * @dev: Device that will be interacted with | ||
| 338 | * @regs: Pointer to memory-mapped IO region | ||
| 339 | * @config: Configuration for register map | ||
| 340 | * | ||
| 341 | * The return value will be an ERR_PTR() on error or a valid pointer to | ||
| 342 | * a struct regmap. | ||
| 343 | */ | ||
| 344 | static inline struct regmap *regmap_init_mmio(struct device *dev, | ||
| 345 | void __iomem *regs, | ||
| 346 | const struct regmap_config *config) | ||
| 347 | { | ||
| 348 | return regmap_init_mmio_clk(dev, NULL, regs, config); | ||
| 349 | } | ||
| 350 | |||
| 351 | /** | ||
| 352 | * devm_regmap_init_mmio(): Initialise managed register map | ||
| 353 | * | ||
| 354 | * @dev: Device that will be interacted with | ||
| 355 | * @regs: Pointer to memory-mapped IO region | ||
| 356 | * @config: Configuration for register map | ||
| 357 | * | ||
| 358 | * The return value will be an ERR_PTR() on error or a valid pointer | ||
| 359 | * to a struct regmap. The regmap will be automatically freed by the | ||
| 360 | * device management code. | ||
| 361 | */ | ||
| 362 | static inline struct regmap *devm_regmap_init_mmio(struct device *dev, | ||
| 363 | void __iomem *regs, | ||
| 364 | const struct regmap_config *config) | ||
| 365 | { | ||
| 366 | return devm_regmap_init_mmio_clk(dev, NULL, regs, config); | ||
| 367 | } | ||
| 303 | 368 | ||
| 304 | void regmap_exit(struct regmap *map); | 369 | void regmap_exit(struct regmap *map); |
| 305 | int regmap_reinit_cache(struct regmap *map, | 370 | int regmap_reinit_cache(struct regmap *map, |
| @@ -310,6 +375,8 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 310 | const void *val, size_t val_len); | 375 | const void *val, size_t val_len); |
| 311 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | 376 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
| 312 | size_t val_count); | 377 | size_t val_count); |
| 378 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, | ||
| 379 | const void *val, size_t val_len); | ||
| 313 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); | 380 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |
| 314 | int regmap_raw_read(struct regmap *map, unsigned int reg, | 381 | int regmap_raw_read(struct regmap *map, unsigned int reg, |
| 315 | void *val, size_t val_len); | 382 | void *val, size_t val_len); |
| @@ -321,6 +388,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg, | |||
| 321 | unsigned int mask, unsigned int val, | 388 | unsigned int mask, unsigned int val, |
| 322 | bool *change); | 389 | bool *change); |
| 323 | int regmap_get_val_bytes(struct regmap *map); | 390 | int regmap_get_val_bytes(struct regmap *map); |
| 391 | int regmap_async_complete(struct regmap *map); | ||
| 324 | 392 | ||
| 325 | int regcache_sync(struct regmap *map); | 393 | int regcache_sync(struct regmap *map); |
| 326 | int regcache_sync_region(struct regmap *map, unsigned int min, | 394 | int regcache_sync_region(struct regmap *map, unsigned int min, |
| @@ -381,6 +449,7 @@ struct regmap_irq_chip { | |||
| 381 | unsigned int wake_base; | 449 | unsigned int wake_base; |
| 382 | unsigned int irq_reg_stride; | 450 | unsigned int irq_reg_stride; |
| 383 | unsigned int mask_invert; | 451 | unsigned int mask_invert; |
| 452 | unsigned int wake_invert; | ||
| 384 | bool runtime_pm; | 453 | bool runtime_pm; |
| 385 | 454 | ||
| 386 | int num_regs; | 455 | int num_regs; |
| @@ -422,6 +491,13 @@ static inline int regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 422 | return -EINVAL; | 491 | return -EINVAL; |
| 423 | } | 492 | } |
| 424 | 493 | ||
| 494 | static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg, | ||
| 495 | const void *val, size_t val_len) | ||
| 496 | { | ||
| 497 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 498 | return -EINVAL; | ||
| 499 | } | ||
| 500 | |||
| 425 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, | 501 | static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, |
| 426 | const void *val, size_t val_count) | 502 | const void *val, size_t val_count) |
| 427 | { | 503 | { |
| @@ -500,6 +576,11 @@ static inline void regcache_mark_dirty(struct regmap *map) | |||
| 500 | WARN_ONCE(1, "regmap API is disabled"); | 576 | WARN_ONCE(1, "regmap API is disabled"); |
| 501 | } | 577 | } |
| 502 | 578 | ||
| 579 | static inline void regmap_async_complete(struct regmap *map) | ||
| 580 | { | ||
| 581 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 582 | } | ||
| 583 | |||
| 503 | static inline int regmap_register_patch(struct regmap *map, | 584 | static inline int regmap_register_patch(struct regmap *map, |
| 504 | const struct reg_default *regs, | 585 | const struct reg_default *regs, |
| 505 | int num_regs) | 586 | int num_regs) |
