diff options
Diffstat (limited to 'include/linux/regmap.h')
| -rw-r--r-- | include/linux/regmap.h | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index a90abb6bfa64..9dbc9a1bec43 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
| @@ -46,7 +46,13 @@ struct reg_default { | |||
| 46 | /** | 46 | /** |
| 47 | * Configuration for the register map of a device. | 47 | * Configuration for the register map of a device. |
| 48 | * | 48 | * |
| 49 | * @name: Optional name of the regmap. Useful when a device has multiple | ||
| 50 | * register regions. | ||
| 51 | * | ||
| 49 | * @reg_bits: Number of bits in a register address, mandatory. | 52 | * @reg_bits: Number of bits in a register address, mandatory. |
| 53 | * @reg_stride: The register address stride. Valid register addresses are a | ||
| 54 | * multiple of this value. If set to 0, a value of 1 will be | ||
| 55 | * used. | ||
| 50 | * @pad_bits: Number of bits of padding between register and value. | 56 | * @pad_bits: Number of bits of padding between register and value. |
| 51 | * @val_bits: Number of bits in a register value, mandatory. | 57 | * @val_bits: Number of bits in a register value, mandatory. |
| 52 | * | 58 | * |
| @@ -70,6 +76,9 @@ struct reg_default { | |||
| 70 | * @write_flag_mask: Mask to be set in the top byte of the register when doing | 76 | * @write_flag_mask: Mask to be set in the top byte of the register when doing |
| 71 | * a write. If both read_flag_mask and write_flag_mask are | 77 | * a write. If both read_flag_mask and write_flag_mask are |
| 72 | * empty the regmap_bus default masks are used. | 78 | * empty the regmap_bus default masks are used. |
| 79 | * @use_single_rw: If set, converts the bulk read and write operations into | ||
| 80 | * a series of single read and write operations. This is useful | ||
| 81 | * for device that does not support bulk read and write. | ||
| 73 | * | 82 | * |
| 74 | * @cache_type: The actual cache type. | 83 | * @cache_type: The actual cache type. |
| 75 | * @reg_defaults_raw: Power on reset values for registers (for use with | 84 | * @reg_defaults_raw: Power on reset values for registers (for use with |
| @@ -77,7 +86,10 @@ struct reg_default { | |||
| 77 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. | 86 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. |
| 78 | */ | 87 | */ |
| 79 | struct regmap_config { | 88 | struct regmap_config { |
| 89 | const char *name; | ||
| 90 | |||
| 80 | int reg_bits; | 91 | int reg_bits; |
| 92 | int reg_stride; | ||
| 81 | int pad_bits; | 93 | int pad_bits; |
| 82 | int val_bits; | 94 | int val_bits; |
| 83 | 95 | ||
| @@ -95,20 +107,25 @@ struct regmap_config { | |||
| 95 | 107 | ||
| 96 | u8 read_flag_mask; | 108 | u8 read_flag_mask; |
| 97 | u8 write_flag_mask; | 109 | u8 write_flag_mask; |
| 110 | |||
| 111 | bool use_single_rw; | ||
| 98 | }; | 112 | }; |
| 99 | 113 | ||
| 100 | typedef int (*regmap_hw_write)(struct device *dev, const void *data, | 114 | typedef int (*regmap_hw_write)(void *context, const void *data, |
| 101 | size_t count); | 115 | size_t count); |
| 102 | typedef int (*regmap_hw_gather_write)(struct device *dev, | 116 | typedef int (*regmap_hw_gather_write)(void *context, |
| 103 | const void *reg, size_t reg_len, | 117 | const void *reg, size_t reg_len, |
| 104 | const void *val, size_t val_len); | 118 | const void *val, size_t val_len); |
| 105 | typedef int (*regmap_hw_read)(struct device *dev, | 119 | typedef int (*regmap_hw_read)(void *context, |
| 106 | const void *reg_buf, size_t reg_size, | 120 | const void *reg_buf, size_t reg_size, |
| 107 | void *val_buf, size_t val_size); | 121 | void *val_buf, size_t val_size); |
| 122 | typedef void (*regmap_hw_free_context)(void *context); | ||
| 108 | 123 | ||
| 109 | /** | 124 | /** |
| 110 | * Description of a hardware bus for the register map infrastructure. | 125 | * Description of a hardware bus for the register map infrastructure. |
| 111 | * | 126 | * |
| 127 | * @fast_io: Register IO is fast. Use a spinlock instead of a mutex | ||
| 128 | * to perform locking. | ||
| 112 | * @write: Write operation. | 129 | * @write: Write operation. |
| 113 | * @gather_write: Write operation with split register/value, return -ENOTSUPP | 130 | * @gather_write: Write operation with split register/value, return -ENOTSUPP |
| 114 | * if not implemented on a given device. | 131 | * if not implemented on a given device. |
| @@ -118,31 +135,42 @@ typedef int (*regmap_hw_read)(struct device *dev, | |||
| 118 | * a read. | 135 | * a read. |
| 119 | */ | 136 | */ |
| 120 | struct regmap_bus { | 137 | struct regmap_bus { |
| 138 | bool fast_io; | ||
| 121 | regmap_hw_write write; | 139 | regmap_hw_write write; |
| 122 | regmap_hw_gather_write gather_write; | 140 | regmap_hw_gather_write gather_write; |
| 123 | regmap_hw_read read; | 141 | regmap_hw_read read; |
| 142 | regmap_hw_free_context free_context; | ||
| 124 | u8 read_flag_mask; | 143 | u8 read_flag_mask; |
| 125 | }; | 144 | }; |
| 126 | 145 | ||
| 127 | struct regmap *regmap_init(struct device *dev, | 146 | struct regmap *regmap_init(struct device *dev, |
| 128 | const struct regmap_bus *bus, | 147 | const struct regmap_bus *bus, |
| 148 | void *bus_context, | ||
| 129 | const struct regmap_config *config); | 149 | const struct regmap_config *config); |
| 130 | struct regmap *regmap_init_i2c(struct i2c_client *i2c, | 150 | struct regmap *regmap_init_i2c(struct i2c_client *i2c, |
| 131 | const struct regmap_config *config); | 151 | const struct regmap_config *config); |
| 132 | struct regmap *regmap_init_spi(struct spi_device *dev, | 152 | struct regmap *regmap_init_spi(struct spi_device *dev, |
| 133 | const struct regmap_config *config); | 153 | const struct regmap_config *config); |
| 154 | struct regmap *regmap_init_mmio(struct device *dev, | ||
| 155 | void __iomem *regs, | ||
| 156 | const struct regmap_config *config); | ||
| 134 | 157 | ||
| 135 | struct regmap *devm_regmap_init(struct device *dev, | 158 | struct regmap *devm_regmap_init(struct device *dev, |
| 136 | const struct regmap_bus *bus, | 159 | const struct regmap_bus *bus, |
| 160 | void *bus_context, | ||
| 137 | const struct regmap_config *config); | 161 | const struct regmap_config *config); |
| 138 | struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, | 162 | struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, |
| 139 | const struct regmap_config *config); | 163 | const struct regmap_config *config); |
| 140 | struct regmap *devm_regmap_init_spi(struct spi_device *dev, | 164 | struct regmap *devm_regmap_init_spi(struct spi_device *dev, |
| 141 | const struct regmap_config *config); | 165 | const struct regmap_config *config); |
| 166 | struct regmap *devm_regmap_init_mmio(struct device *dev, | ||
| 167 | void __iomem *regs, | ||
| 168 | const struct regmap_config *config); | ||
| 142 | 169 | ||
| 143 | void regmap_exit(struct regmap *map); | 170 | void regmap_exit(struct regmap *map); |
| 144 | int regmap_reinit_cache(struct regmap *map, | 171 | int regmap_reinit_cache(struct regmap *map, |
| 145 | const struct regmap_config *config); | 172 | const struct regmap_config *config); |
| 173 | struct regmap *dev_get_regmap(struct device *dev, const char *name); | ||
| 146 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); | 174 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
| 147 | int regmap_raw_write(struct regmap *map, unsigned int reg, | 175 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 148 | const void *val, size_t val_len); | 176 | const void *val, size_t val_len); |
| @@ -327,6 +355,13 @@ static inline int regmap_register_patch(struct regmap *map, | |||
| 327 | return -EINVAL; | 355 | return -EINVAL; |
| 328 | } | 356 | } |
| 329 | 357 | ||
| 358 | static inline struct regmap *dev_get_regmap(struct device *dev, | ||
| 359 | const char *name) | ||
| 360 | { | ||
| 361 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 362 | return NULL; | ||
| 363 | } | ||
| 364 | |||
| 330 | #endif | 365 | #endif |
| 331 | 366 | ||
| 332 | #endif | 367 | #endif |
