diff options
Diffstat (limited to 'include/linux/regmap.h')
| -rw-r--r-- | include/linux/regmap.h | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 56af22ec9aba..7f7e00df3adf 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
| @@ -14,12 +14,14 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include <linux/list.h> | 16 | #include <linux/list.h> |
| 17 | #include <linux/rbtree.h> | ||
| 17 | 18 | ||
| 18 | struct module; | 19 | struct module; |
| 19 | struct device; | 20 | struct device; |
| 20 | struct i2c_client; | 21 | struct i2c_client; |
| 21 | struct spi_device; | 22 | struct spi_device; |
| 22 | struct regmap; | 23 | struct regmap; |
| 24 | struct regmap_range_cfg; | ||
| 23 | 25 | ||
| 24 | /* An enum of all the supported cache types */ | 26 | /* An enum of all the supported cache types */ |
| 25 | enum regcache_type { | 27 | enum regcache_type { |
| @@ -43,6 +45,14 @@ struct reg_default { | |||
| 43 | 45 | ||
| 44 | #ifdef CONFIG_REGMAP | 46 | #ifdef CONFIG_REGMAP |
| 45 | 47 | ||
| 48 | enum regmap_endian { | ||
| 49 | /* Unspecified -> 0 -> Backwards compatible default */ | ||
| 50 | REGMAP_ENDIAN_DEFAULT = 0, | ||
| 51 | REGMAP_ENDIAN_BIG, | ||
| 52 | REGMAP_ENDIAN_LITTLE, | ||
| 53 | REGMAP_ENDIAN_NATIVE, | ||
| 54 | }; | ||
| 55 | |||
| 46 | /** | 56 | /** |
| 47 | * Configuration for the register map of a device. | 57 | * Configuration for the register map of a device. |
| 48 | * | 58 | * |
| @@ -84,6 +94,15 @@ struct reg_default { | |||
| 84 | * @reg_defaults_raw: Power on reset values for registers (for use with | 94 | * @reg_defaults_raw: Power on reset values for registers (for use with |
| 85 | * register cache support). | 95 | * register cache support). |
| 86 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. | 96 | * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. |
| 97 | * @reg_format_endian: Endianness for formatted register addresses. If this is | ||
| 98 | * DEFAULT, the @reg_format_endian_default value from the | ||
| 99 | * regmap bus is used. | ||
| 100 | * @val_format_endian: Endianness for formatted register values. If this is | ||
| 101 | * DEFAULT, the @reg_format_endian_default value from the | ||
| 102 | * regmap bus is used. | ||
| 103 | * | ||
| 104 | * @ranges: Array of configuration entries for virtual address ranges. | ||
| 105 | * @num_ranges: Number of range configuration entries. | ||
| 87 | */ | 106 | */ |
| 88 | struct regmap_config { | 107 | struct regmap_config { |
| 89 | const char *name; | 108 | const char *name; |
| @@ -109,6 +128,43 @@ struct regmap_config { | |||
| 109 | u8 write_flag_mask; | 128 | u8 write_flag_mask; |
| 110 | 129 | ||
| 111 | bool use_single_rw; | 130 | bool use_single_rw; |
| 131 | |||
| 132 | enum regmap_endian reg_format_endian; | ||
| 133 | enum regmap_endian val_format_endian; | ||
| 134 | |||
| 135 | const struct regmap_range_cfg *ranges; | ||
| 136 | unsigned int n_ranges; | ||
| 137 | }; | ||
| 138 | |||
| 139 | /** | ||
| 140 | * Configuration for indirectly accessed or paged registers. | ||
| 141 | * Registers, mapped to this virtual range, are accessed in two steps: | ||
| 142 | * 1. page selector register update; | ||
| 143 | * 2. access through data window registers. | ||
| 144 | * | ||
| 145 | * @range_min: Address of the lowest register address in virtual range. | ||
| 146 | * @range_max: Address of the highest register in virtual range. | ||
| 147 | * | ||
| 148 | * @page_sel_reg: Register with selector field. | ||
| 149 | * @page_sel_mask: Bit shift for selector value. | ||
| 150 | * @page_sel_shift: Bit mask for selector value. | ||
| 151 | * | ||
| 152 | * @window_start: Address of first (lowest) register in data window. | ||
| 153 | * @window_len: Number of registers in data window. | ||
| 154 | */ | ||
| 155 | struct regmap_range_cfg { | ||
| 156 | /* Registers of virtual address range */ | ||
| 157 | unsigned int range_min; | ||
| 158 | unsigned int range_max; | ||
| 159 | |||
| 160 | /* Page selector for indirect addressing */ | ||
| 161 | unsigned int selector_reg; | ||
| 162 | unsigned int selector_mask; | ||
| 163 | int selector_shift; | ||
| 164 | |||
| 165 | /* Data window (per each page) */ | ||
| 166 | unsigned int window_start; | ||
| 167 | unsigned int window_len; | ||
| 112 | }; | 168 | }; |
| 113 | 169 | ||
| 114 | typedef int (*regmap_hw_write)(void *context, const void *data, | 170 | typedef int (*regmap_hw_write)(void *context, const void *data, |
| @@ -133,6 +189,12 @@ typedef void (*regmap_hw_free_context)(void *context); | |||
| 133 | * data. | 189 | * data. |
| 134 | * @read_flag_mask: Mask to be set in the top byte of the register when doing | 190 | * @read_flag_mask: Mask to be set in the top byte of the register when doing |
| 135 | * a read. | 191 | * a read. |
| 192 | * @reg_format_endian_default: Default endianness for formatted register | ||
| 193 | * addresses. Used when the regmap_config specifies DEFAULT. If this is | ||
| 194 | * DEFAULT, BIG is assumed. | ||
| 195 | * @val_format_endian_default: Default endianness for formatted register | ||
| 196 | * values. Used when the regmap_config specifies DEFAULT. If this is | ||
| 197 | * DEFAULT, BIG is assumed. | ||
| 136 | */ | 198 | */ |
| 137 | struct regmap_bus { | 199 | struct regmap_bus { |
| 138 | bool fast_io; | 200 | bool fast_io; |
| @@ -141,6 +203,8 @@ struct regmap_bus { | |||
| 141 | regmap_hw_read read; | 203 | regmap_hw_read read; |
| 142 | regmap_hw_free_context free_context; | 204 | regmap_hw_free_context free_context; |
| 143 | u8 read_flag_mask; | 205 | u8 read_flag_mask; |
| 206 | enum regmap_endian reg_format_endian_default; | ||
| 207 | enum regmap_endian val_format_endian_default; | ||
| 144 | }; | 208 | }; |
| 145 | 209 | ||
| 146 | struct regmap *regmap_init(struct device *dev, | 210 | struct regmap *regmap_init(struct device *dev, |
| @@ -219,6 +283,7 @@ struct regmap_irq { | |||
| 219 | * @status_base: Base status register address. | 283 | * @status_base: Base status register address. |
| 220 | * @mask_base: Base mask register address. | 284 | * @mask_base: Base mask register address. |
| 221 | * @ack_base: Base ack address. If zero then the chip is clear on read. | 285 | * @ack_base: Base ack address. If zero then the chip is clear on read. |
| 286 | * @wake_base: Base address for wake enables. If zero unsupported. | ||
| 222 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous. | 287 | * @irq_reg_stride: Stride to use for chips where registers are not contiguous. |
| 223 | * | 288 | * |
| 224 | * @num_regs: Number of registers in each control bank. | 289 | * @num_regs: Number of registers in each control bank. |
| @@ -232,6 +297,7 @@ struct regmap_irq_chip { | |||
| 232 | unsigned int status_base; | 297 | unsigned int status_base; |
| 233 | unsigned int mask_base; | 298 | unsigned int mask_base; |
| 234 | unsigned int ack_base; | 299 | unsigned int ack_base; |
| 300 | unsigned int wake_base; | ||
| 235 | unsigned int irq_reg_stride; | 301 | unsigned int irq_reg_stride; |
| 236 | 302 | ||
| 237 | int num_regs; | 303 | int num_regs; |
| @@ -243,7 +309,7 @@ struct regmap_irq_chip { | |||
| 243 | struct regmap_irq_chip_data; | 309 | struct regmap_irq_chip_data; |
| 244 | 310 | ||
| 245 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | 311 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, |
| 246 | int irq_base, struct regmap_irq_chip *chip, | 312 | int irq_base, const struct regmap_irq_chip *chip, |
| 247 | struct regmap_irq_chip_data **data); | 313 | struct regmap_irq_chip_data **data); |
| 248 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); | 314 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); |
| 249 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); | 315 | int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data); |
| @@ -361,7 +427,6 @@ static inline int regmap_register_patch(struct regmap *map, | |||
| 361 | static inline struct regmap *dev_get_regmap(struct device *dev, | 427 | static inline struct regmap *dev_get_regmap(struct device *dev, |
| 362 | const char *name) | 428 | const char *name) |
| 363 | { | 429 | { |
| 364 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 365 | return NULL; | 430 | return NULL; |
| 366 | } | 431 | } |
| 367 | 432 | ||
