Changeset 652
- Timestamp:
- Jan 24, 2021, 8:40:08 AM (5 years ago)
- Location:
- GPL/branches/uniaud32-next
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/include/linux/regmap.h
r625 r652 1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 2 #ifndef __LINUX_REGMAP_H 2 3 #define __LINUX_REGMAP_H … … 8 9 * 9 10 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 */ 15 /* from 4.19.163 */ 11 */ 12 13 /* from 5.10.10 */ 16 14 17 15 #include <linux/list.h> … … 22 20 //#include <linux/bug.h> 23 21 #include <linux/lockdep.h> 22 //#include <linux/iopoll.h> 23 #include <linux/fwnode.h> 24 24 25 25 struct module; 26 26 struct clk; 27 27 struct device; 28 struct device_node; 28 29 struct i2c_client; 30 struct i3c_device; 29 31 struct irq_domain; 30 32 struct slim_device; … … 75 77 }; 76 78 77 #define regmap_update_bits(map, reg, mask, val) \ 78 regmap_update_bits_base(map, reg, mask, val, NULL, false, false) 79 #define regmap_update_bits_async(map, reg, mask, val)\ 80 regmap_update_bits_base(map, reg, mask, val, NULL, true, false) 81 #define regmap_update_bits_check(map, reg, mask, val, change)\ 82 regmap_update_bits_base(map, reg, mask, val, change, false, false) 83 #define regmap_update_bits_check_async(map, reg, mask, val, change)\ 84 regmap_update_bits_base(map, reg, mask, val, change, true, false) 85 86 #define regmap_write_bits(map, reg, mask, val) \ 87 regmap_update_bits_base(map, reg, mask, val, NULL, false, true) 88 89 #define regmap_field_write(field, val) \ 90 regmap_field_update_bits_base(field, ~0, val, NULL, false, false) 91 #define regmap_field_force_write(field, val) \ 92 regmap_field_update_bits_base(field, ~0, val, NULL, false, true) 93 #define regmap_field_update_bits(field, mask, val)\ 94 regmap_field_update_bits_base(field, mask, val, NULL, false, false) 95 #define regmap_field_force_update_bits(field, mask, val) \ 96 regmap_field_update_bits_base(field, mask, val, NULL, false, true) 97 98 #define regmap_fields_write(field, id, val) \ 99 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false) 100 #define regmap_fields_force_write(field, id, val) \ 101 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true) 102 #define regmap_fields_update_bits(field, id, mask, val)\ 103 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false) 104 #define regmap_fields_force_update_bits(field, id, mask, val) \ 105 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true) 79 #define REG_SEQ(_reg, _def, _delay_us) { \ 80 .reg = _reg, \ 81 .def = _def, \ 82 .delay_us = _delay_us, \ 83 } 84 #define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0) 106 85 107 86 /** … … 114 93 * @sleep_us: Maximum time to sleep between reads in us (0 115 94 * tight-loops). Should be less than ~20ms since usleep_range 116 * is used (see Documentation/timers/timers-howto. txt).95 * is used (see Documentation/timers/timers-howto.rst). 117 96 * @timeout_us: Timeout in us, 0 means never timeout 118 97 * … … 126 105 #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ 127 106 ({ \ 107 int __ret, __tmp; \ 108 __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ 109 sleep_us, timeout_us, false, (map), (addr), &(val)); \ 110 __ret ?: __tmp; \ 111 }) 112 113 /** 114 * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs 115 * 116 * @map: Regmap to read from 117 * @addr: Address to poll 118 * @val: Unsigned integer variable to read the value into 119 * @cond: Break condition (usually involving @val) 120 * @delay_us: Time to udelay between reads in us (0 tight-loops). 121 * Should be less than ~10us since udelay is used 122 * (see Documentation/timers/timers-howto.rst). 123 * @timeout_us: Timeout in us, 0 means never timeout 124 * 125 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read 126 * error return value in case of a error read. In the two former cases, 127 * the last read value at @addr is stored in @val. 128 * 129 * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h. 130 * 131 * Note: In general regmap cannot be used in atomic context. If you want to use 132 * this macro then first setup your regmap for atomic use (flat or no cache 133 * and MMIO regmap). 134 */ 135 #define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \ 136 ({ \ 128 137 u64 __timeout_us = (timeout_us); \ 129 unsigned long __ sleep_us = (sleep_us); \138 unsigned long __delay_us = (delay_us); \ 130 139 ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ 131 140 int __ret; \ 132 might_sleep_if(__sleep_us); \133 141 for (;;) { \ 134 142 __ret = regmap_read((map), (addr), &(val)); \ … … 142 150 break; \ 143 151 } \ 144 if (__ sleep_us) \145 u sleep_range((__sleep_us >> 2) + 1, __sleep_us); \152 if (__delay_us) \ 153 udelay(__delay_us); \ 146 154 } \ 147 155 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ … … 156 164 * @sleep_us: Maximum time to sleep between reads in us (0 157 165 * tight-loops). Should be less than ~20ms since usleep_range 158 * is used (see Documentation/timers/timers-howto. txt).166 * is used (see Documentation/timers/timers-howto.rst). 159 167 * @timeout_us: Timeout in us, 0 means never timeout 160 168 * … … 168 176 #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ 169 177 ({ \ 170 u64 __timeout_us = (timeout_us); \ 171 unsigned long __sleep_us = (sleep_us); \ 172 ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \ 173 int pollret; \ 174 might_sleep_if(__sleep_us); \ 175 for (;;) { \ 176 pollret = regmap_field_read((field), &(val)); \ 177 if (pollret) \ 178 break; \ 179 if (cond) \ 180 break; \ 181 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ 182 pollret = regmap_field_read((field), &(val)); \ 183 break; \ 184 } \ 185 if (__sleep_us) \ 186 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ 187 } \ 188 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ 178 int __ret, __tmp; \ 179 __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \ 180 sleep_us, timeout_us, false, (field), &(val)); \ 181 __ret ?: __tmp; \ 189 182 }) 190 183 … … 271 264 * check is performed on such table (a register is precious if 272 265 * it belongs to one of the ranges specified by precious_table). 266 * @writeable_noinc_reg: Optional callback returning true if the register 267 * supports multiple write operations without incrementing 268 * the register number. If this field is NULL but 269 * wr_noinc_table (see below) is not, the check is 270 * performed on such table (a register is no increment 271 * writeable if it belongs to one of the ranges specified 272 * by wr_noinc_table). 273 273 * @readable_noinc_reg: Optional callback returning true if the register 274 274 * supports multiple read operations without incrementing … … 279 279 * by rd_noinc_table). 280 280 * @disable_locking: This regmap is either protected by external means or 281 * is guaranteed not bebe accessed from multiple threads.281 * is guaranteed not to be accessed from multiple threads. 282 282 * Don't use any locking mechanisms. 283 283 * @lock: Optional lock callback (overrides regmap's default lock … … 305 305 * @volatile_table: As above, for volatile registers. 306 306 * @precious_table: As above, for precious registers. 307 * @wr_noinc_table: As above, for no increment writeable registers. 307 308 * @rd_noinc_table: As above, for no increment readable registers. 308 309 * @reg_defaults: Power on reset values for registers (for use with … … 318 319 * @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even 319 320 * if they are both empty. 320 * @use_single_rw: If set, converts the bulk read and write operations into 321 * a series of single read and write operations. This is useful 322 * for device that does not support bulk read and write. 321 * @use_single_read: If set, converts the bulk read operation into a series of 322 * single read operations. This is useful for a device that 323 * does not support bulk read. 324 * @use_single_write: If set, converts the bulk write operation into a series of 325 * single write operations. This is useful for a device that 326 * does not support bulk write. 323 327 * @can_multi_write: If set, the device supports the multi write mode of bulk 324 328 * write operations, if clear multi write requests will be … … 342 346 * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE, 343 347 * HWLOCK_IRQ or 0. 348 * @can_sleep: Optional, specifies whether regmap operations can sleep. 344 349 */ 345 350 struct regmap_config { … … 355 360 bool (*volatile_reg)(struct device *dev, unsigned int reg); 356 361 bool (*precious_reg)(struct device *dev, unsigned int reg); 362 bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg); 357 363 bool (*readable_noinc_reg)(struct device *dev, unsigned int reg); 358 364 … … 372 378 const struct regmap_access_table *volatile_table; 373 379 const struct regmap_access_table *precious_table; 380 const struct regmap_access_table *wr_noinc_table; 374 381 const struct regmap_access_table *rd_noinc_table; 375 382 const struct reg_default *reg_defaults; … … 396 403 unsigned int hwlock_id; 397 404 unsigned int hwlock_mode; 405 406 bool can_sleep; 398 407 }; 399 408 … … 408 417 * 409 418 * @selector_reg: Register with selector field. 410 * @selector_mask: Bit shiftfor selector value.411 * @selector_shift: Bit maskfor selector value.419 * @selector_mask: Bit mask for selector value. 420 * @selector_shift: Bit shift for selector value. 412 421 * 413 422 * @window_start: Address of first (lowest) register in data window. … … 565 574 struct lock_class_key *lock_key, 566 575 const char *lock_name); 576 struct regmap *__regmap_init_spi_avmm(struct spi_device *spi, 577 const struct regmap_config *config, 578 struct lock_class_key *lock_key, 579 const char *lock_name); 567 580 568 581 struct regmap *__devm_regmap_init(struct device *dev, … … 614 627 struct lock_class_key *lock_key, 615 628 const char *lock_name); 629 struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, 630 const struct regmap_config *config, 631 struct lock_class_key *lock_key, 632 const char *lock_name); 633 struct regmap *__devm_regmap_init_spi_avmm(struct spi_device *spi, 634 const struct regmap_config *config, 635 struct lock_class_key *lock_key, 636 const char *lock_name); 616 637 /* 617 638 * Wrapper for regmap_init macros to include a unique lockdep key and name … … 800 821 sdw, config) 801 822 823 /** 824 * regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave 825 * to AVMM Bus Bridge 826 * 827 * @spi: Device that will be interacted with 828 * @config: Configuration for register map 829 * 830 * The return value will be an ERR_PTR() on error or a valid pointer 831 * to a struct regmap. 832 */ 833 #define regmap_init_spi_avmm(spi, config) \ 834 __regmap_lockdep_wrapper(__regmap_init_spi_avmm, #config, \ 835 spi, config) 802 836 803 837 /** … … 972 1006 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ 973 1007 slimbus, config) 1008 1009 /** 1010 * devm_regmap_init_i3c() - Initialise managed register map 1011 * 1012 * @i3c: Device that will be interacted with 1013 * @config: Configuration for register map 1014 * 1015 * The return value will be an ERR_PTR() on error or a valid pointer 1016 * to a struct regmap. The regmap will be automatically freed by the 1017 * device management code. 1018 */ 1019 #define devm_regmap_init_i3c(i3c, config) \ 1020 __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ 1021 i3c, config) 1022 1023 /** 1024 * devm_regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave 1025 * to AVMM Bus Bridge 1026 * 1027 * @spi: Device that will be interacted with 1028 * @config: Configuration for register map 1029 * 1030 * The return value will be an ERR_PTR() on error or a valid pointer 1031 * to a struct regmap. The map will be automatically freed by the 1032 * device management code. 1033 */ 1034 #define devm_regmap_init_spi_avmm(spi, config) \ 1035 __regmap_lockdep_wrapper(__devm_regmap_init_spi_avmm, #config, \ 1036 spi, config) 1037 974 1038 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); 975 1039 void regmap_mmio_detach_clk(struct regmap *map); … … 982 1046 int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); 983 1047 int regmap_raw_write(struct regmap *map, unsigned int reg, 1048 const void *val, size_t val_len); 1049 int regmap_noinc_write(struct regmap *map, unsigned int reg, 984 1050 const void *val, size_t val_len); 985 1051 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, … … 1002 1068 unsigned int mask, unsigned int val, 1003 1069 bool *change, bool async, bool force); 1070 1071 static inline int regmap_update_bits(struct regmap *map, unsigned int reg, 1072 unsigned int mask, unsigned int val) 1073 { 1074 return regmap_update_bits_base(map, reg, mask, val, NULL, false, false); 1075 } 1076 1077 static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg, 1078 unsigned int mask, unsigned int val) 1079 { 1080 return regmap_update_bits_base(map, reg, mask, val, NULL, true, false); 1081 } 1082 1083 static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg, 1084 unsigned int mask, unsigned int val, 1085 bool *change) 1086 { 1087 return regmap_update_bits_base(map, reg, mask, val, 1088 change, false, false); 1089 } 1090 1091 static inline int 1092 regmap_update_bits_check_async(struct regmap *map, unsigned int reg, 1093 unsigned int mask, unsigned int val, 1094 bool *change) 1095 { 1096 return regmap_update_bits_base(map, reg, mask, val, 1097 change, true, false); 1098 } 1099 1100 static inline int regmap_write_bits(struct regmap *map, unsigned int reg, 1101 unsigned int mask, unsigned int val) 1102 { 1103 return regmap_update_bits_base(map, reg, mask, val, NULL, false, true); 1104 } 1105 1004 1106 int regmap_get_val_bytes(struct regmap *map); 1005 1107 int regmap_get_max_register(struct regmap *map); … … 1037 1139 unsigned int nranges); 1038 1140 1141 static inline int regmap_set_bits(struct regmap *map, 1142 unsigned int reg, unsigned int bits) 1143 { 1144 return regmap_update_bits_base(map, reg, bits, bits, 1145 NULL, false, false); 1146 } 1147 1148 static inline int regmap_clear_bits(struct regmap *map, 1149 unsigned int reg, unsigned int bits) 1150 { 1151 return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false); 1152 } 1153 1154 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits); 1155 1039 1156 /** 1040 1157 * struct reg_field - Description of an register field … … 1060 1177 } 1061 1178 1179 #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \ 1180 .reg = _reg, \ 1181 .lsb = _lsb, \ 1182 .msb = _msb, \ 1183 .id_size = _size, \ 1184 .id_offset = _offset, \ 1185 } 1186 1062 1187 struct regmap_field *regmap_field_alloc(struct regmap *regmap, 1063 1188 struct reg_field reg_field); … … 1067 1192 struct regmap *regmap, struct reg_field reg_field); 1068 1193 void devm_regmap_field_free(struct device *dev, struct regmap_field *field); 1194 1195 int regmap_field_bulk_alloc(struct regmap *regmap, 1196 struct regmap_field **rm_field, 1197 struct reg_field *reg_field, 1198 int num_fields); 1199 void regmap_field_bulk_free(struct regmap_field *field); 1200 int devm_regmap_field_bulk_alloc(struct device *dev, struct regmap *regmap, 1201 struct regmap_field **field, 1202 struct reg_field *reg_field, int num_fields); 1203 void devm_regmap_field_bulk_free(struct device *dev, 1204 struct regmap_field *field); 1069 1205 1070 1206 int regmap_field_read(struct regmap_field *field, unsigned int *val); … … 1078 1214 bool *change, bool async, bool force); 1079 1215 1216 static inline int regmap_field_write(struct regmap_field *field, 1217 unsigned int val) 1218 { 1219 return regmap_field_update_bits_base(field, ~0, val, 1220 NULL, false, false); 1221 } 1222 1223 static inline int regmap_field_force_write(struct regmap_field *field, 1224 unsigned int val) 1225 { 1226 return regmap_field_update_bits_base(field, ~0, val, NULL, false, true); 1227 } 1228 1229 static inline int regmap_field_update_bits(struct regmap_field *field, 1230 unsigned int mask, unsigned int val) 1231 { 1232 return regmap_field_update_bits_base(field, mask, val, 1233 NULL, false, false); 1234 } 1235 1236 static inline int 1237 regmap_field_force_update_bits(struct regmap_field *field, 1238 unsigned int mask, unsigned int val) 1239 { 1240 return regmap_field_update_bits_base(field, mask, val, 1241 NULL, false, true); 1242 } 1243 1244 static inline int regmap_fields_write(struct regmap_field *field, 1245 unsigned int id, unsigned int val) 1246 { 1247 return regmap_fields_update_bits_base(field, id, ~0, val, 1248 NULL, false, false); 1249 } 1250 1251 static inline int regmap_fields_force_write(struct regmap_field *field, 1252 unsigned int id, unsigned int val) 1253 { 1254 return regmap_fields_update_bits_base(field, id, ~0, val, 1255 NULL, false, true); 1256 } 1257 1258 static inline int 1259 regmap_fields_update_bits(struct regmap_field *field, unsigned int id, 1260 unsigned int mask, unsigned int val) 1261 { 1262 return regmap_fields_update_bits_base(field, id, mask, val, 1263 NULL, false, false); 1264 } 1265 1266 static inline int 1267 regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id, 1268 unsigned int mask, unsigned int val) 1269 { 1270 return regmap_fields_update_bits_base(field, id, mask, val, 1271 NULL, false, true); 1272 } 1273 1274 /** 1275 * struct regmap_irq_type - IRQ type definitions. 1276 * 1277 * @type_reg_offset: Offset register for the irq type setting. 1278 * @type_rising_val: Register value to configure RISING type irq. 1279 * @type_falling_val: Register value to configure FALLING type irq. 1280 * @type_level_low_val: Register value to configure LEVEL_LOW type irq. 1281 * @type_level_high_val: Register value to configure LEVEL_HIGH type irq. 1282 * @types_supported: logical OR of IRQ_TYPE_* flags indicating supported types. 1283 */ 1284 struct regmap_irq_type { 1285 unsigned int type_reg_offset; 1286 unsigned int type_reg_mask; 1287 unsigned int type_rising_val; 1288 unsigned int type_falling_val; 1289 unsigned int type_level_low_val; 1290 unsigned int type_level_high_val; 1291 unsigned int types_supported; 1292 }; 1293 1080 1294 /** 1081 1295 * struct regmap_irq - Description of an IRQ for the generic regmap irq_chip. … … 1083 1297 * @reg_offset: Offset of the status/mask register within the bank 1084 1298 * @mask: Mask used to flag/control the register. 1085 * @type_reg_offset: Offset register for the irq type setting. 1086 * @type_rising_mask: Mask bit to configure RISING type irq. 1087 * @type_falling_mask: Mask bit to configure FALLING type irq. 1299 * @type: IRQ trigger type setting details if supported. 1088 1300 */ 1089 1301 struct regmap_irq { 1090 1302 unsigned int reg_offset; 1091 1303 unsigned int mask; 1092 unsigned int type_reg_offset; 1093 unsigned int type_rising_mask; 1094 unsigned int type_falling_mask; 1304 struct regmap_irq_type type; 1095 1305 }; 1096 1306 … … 1098 1308 [_irq] = { .reg_offset = (_off), .mask = (_mask) } 1099 1309 1310 #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \ 1311 [_id] = { \ 1312 .mask = BIT((_id) % (_reg_bits)), \ 1313 .reg_offset = (_id) / (_reg_bits), \ 1314 } 1315 1316 #define REGMAP_IRQ_MAIN_REG_OFFSET(arr) \ 1317 { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] } 1318 1319 struct regmap_irq_sub_irq_map { 1320 unsigned int num_regs; 1321 unsigned int *offset; 1322 }; 1323 1100 1324 /** 1101 1325 * struct regmap_irq_chip - Description of a generic regmap irq_chip. 1102 1326 * 1103 1327 * @name: Descriptive name for IRQ controller. 1328 * 1329 * @main_status: Base main status register address. For chips which have 1330 * interrupts arranged in separate sub-irq blocks with own IRQ 1331 * registers and which have a main IRQ registers indicating 1332 * sub-irq blocks with unhandled interrupts. For such chips fill 1333 * sub-irq register information in status_base, mask_base and 1334 * ack_base. 1335 * @num_main_status_bits: Should be given to chips where number of meaningfull 1336 * main status bits differs from num_regs. 1337 * @sub_reg_offsets: arrays of mappings from main register bits to sub irq 1338 * registers. First item in array describes the registers 1339 * for first main status bit. Second array for second bit etc. 1340 * Offset is given as sub register status offset to 1341 * status_base. Should contain num_regs arrays. 1342 * Can be provided for chips with more complex mapping than 1343 * 1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ... 1344 * @num_main_regs: Number of 'main status' irq registers for chips which have 1345 * main_status set. 1104 1346 * 1105 1347 * @status_base: Base status register address. … … 1117 1359 * @use_ack: Use @ack register even if it is zero. 1118 1360 * @ack_invert: Inverted ack register: cleared bits for ack. 1361 * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts. 1119 1362 * @wake_invert: Inverted wake register: cleared bits are wake enabled. 1120 1363 * @type_invert: Invert the type flags. 1364 * @type_in_mask: Use the mask registers for controlling irq type. For 1365 * interrupts defining type_rising/falling_mask use mask_base 1366 * for edge configuration and never update bits in type_base. 1367 * @clear_on_unmask: For chips with interrupts cleared on read: read the status 1368 * registers before unmasking interrupts to clear any bits 1369 * set when they were masked. 1121 1370 * @runtime_pm: Hold a runtime PM lock on the device when accessing it. 1122 1371 * … … 1142 1391 const char *name; 1143 1392 1393 unsigned int main_status; 1394 unsigned int num_main_status_bits; 1395 struct regmap_irq_sub_irq_map *sub_reg_offsets; 1396 int num_main_regs; 1397 1144 1398 unsigned int status_base; 1145 1399 unsigned int mask_base; … … 1154 1408 bool use_ack:1; 1155 1409 bool ack_invert:1; 1410 bool clear_ack:1; 1156 1411 bool wake_invert:1; 1157 1412 bool runtime_pm:1; 1158 1413 bool type_invert:1; 1414 bool type_in_mask:1; 1415 bool clear_on_unmask:1; 1159 1416 1160 1417 int num_regs; … … 1176 1433 int irq_base, const struct regmap_irq_chip *chip, 1177 1434 struct regmap_irq_chip_data **data); 1435 int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, 1436 struct regmap *map, int irq, 1437 int irq_flags, int irq_base, 1438 const struct regmap_irq_chip *chip, 1439 struct regmap_irq_chip_data **data); 1178 1440 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); 1179 1441 … … 1182 1444 const struct regmap_irq_chip *chip, 1183 1445 struct regmap_irq_chip_data **data); 1446 int devm_regmap_add_irq_chip_fwnode(struct device *dev, 1447 struct fwnode_handle *fwnode, 1448 struct regmap *map, int irq, 1449 int irq_flags, int irq_base, 1450 const struct regmap_irq_chip *chip, 1451 struct regmap_irq_chip_data **data); 1184 1452 void devm_regmap_del_irq_chip(struct device *dev, int irq, 1185 1453 struct regmap_irq_chip_data *data); … … 1226 1494 } 1227 1495 1496 static inline int regmap_noinc_write(struct regmap *map, unsigned int reg, 1497 const void *val, size_t val_len) 1498 { 1499 WARN_ONCE(1, "regmap API is disabled"); 1500 return -EINVAL; 1501 } 1502 1228 1503 static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, 1229 1504 const void *val, size_t val_count) … … 1264 1539 unsigned int mask, unsigned int val, 1265 1540 bool *change, bool async, bool force) 1541 { 1542 WARN_ONCE(1, "regmap API is disabled"); 1543 return -EINVAL; 1544 } 1545 1546 static inline int regmap_set_bits(struct regmap *map, 1547 unsigned int reg, unsigned int bits) 1548 { 1549 WARN_ONCE(1, "regmap API is disabled"); 1550 return -EINVAL; 1551 } 1552 1553 static inline int regmap_clear_bits(struct regmap *map, 1554 unsigned int reg, unsigned int bits) 1555 { 1556 WARN_ONCE(1, "regmap API is disabled"); 1557 return -EINVAL; 1558 } 1559 1560 static inline int regmap_test_bits(struct regmap *map, 1561 unsigned int reg, unsigned int bits) 1266 1562 { 1267 1563 WARN_ONCE(1, "regmap API is disabled"); … … 1286 1582 } 1287 1583 1584 static inline int regmap_update_bits(struct regmap *map, unsigned int reg, 1585 unsigned int mask, unsigned int val) 1586 { 1587 WARN_ONCE(1, "regmap API is disabled"); 1588 return -EINVAL; 1589 } 1590 1591 static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg, 1592 unsigned int mask, unsigned int val) 1593 { 1594 WARN_ONCE(1, "regmap API is disabled"); 1595 return -EINVAL; 1596 } 1597 1598 static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg, 1599 unsigned int mask, unsigned int val, 1600 bool *change) 1601 { 1602 WARN_ONCE(1, "regmap API is disabled"); 1603 return -EINVAL; 1604 } 1605 1606 static inline int 1607 regmap_update_bits_check_async(struct regmap *map, unsigned int reg, 1608 unsigned int mask, unsigned int val, 1609 bool *change) 1610 { 1611 WARN_ONCE(1, "regmap API is disabled"); 1612 return -EINVAL; 1613 } 1614 1615 static inline int regmap_write_bits(struct regmap *map, unsigned int reg, 1616 unsigned int mask, unsigned int val) 1617 { 1618 WARN_ONCE(1, "regmap API is disabled"); 1619 return -EINVAL; 1620 } 1621 1622 static inline int regmap_field_write(struct regmap_field *field, 1623 unsigned int val) 1624 { 1625 WARN_ONCE(1, "regmap API is disabled"); 1626 return -EINVAL; 1627 } 1628 1629 static inline int regmap_field_force_write(struct regmap_field *field, 1630 unsigned int val) 1631 { 1632 WARN_ONCE(1, "regmap API is disabled"); 1633 return -EINVAL; 1634 } 1635 1636 static inline int regmap_field_update_bits(struct regmap_field *field, 1637 unsigned int mask, unsigned int val) 1638 { 1639 WARN_ONCE(1, "regmap API is disabled"); 1640 return -EINVAL; 1641 } 1642 1643 static inline int 1644 regmap_field_force_update_bits(struct regmap_field *field, 1645 unsigned int mask, unsigned int val) 1646 { 1647 WARN_ONCE(1, "regmap API is disabled"); 1648 return -EINVAL; 1649 } 1650 1651 static inline int regmap_fields_write(struct regmap_field *field, 1652 unsigned int id, unsigned int val) 1653 { 1654 WARN_ONCE(1, "regmap API is disabled"); 1655 return -EINVAL; 1656 } 1657 1658 static inline int regmap_fields_force_write(struct regmap_field *field, 1659 unsigned int id, unsigned int val) 1660 { 1661 WARN_ONCE(1, "regmap API is disabled"); 1662 return -EINVAL; 1663 } 1664 1665 static inline int 1666 regmap_fields_update_bits(struct regmap_field *field, unsigned int id, 1667 unsigned int mask, unsigned int val) 1668 { 1669 WARN_ONCE(1, "regmap API is disabled"); 1670 return -EINVAL; 1671 } 1672 1673 static inline int 1674 regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id, 1675 unsigned int mask, unsigned int val) 1676 { 1677 WARN_ONCE(1, "regmap API is disabled"); 1678 return -EINVAL; 1679 } 1680 1288 1681 static inline int regmap_get_val_bytes(struct regmap *map) 1289 1682 { -
GPL/branches/uniaud32-next/lib32/internal.h
r625 r652 1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Register map access API internal header … … 5 6 * 6 7 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 *8 * This program is free software; you can redistribute it and/or modify9 * it under the terms of the GNU General Public License version 2 as10 * published by the Free Software Foundation.11 8 */ 12 /* from 4.19.163 */ 9 10 /* from 5.10.10 */ 13 11 14 12 #ifndef _REGMAP_INTERNAL_H … … 20 18 #include <linux/list.h> 21 19 #include <linux/wait.h> 22 #include <linux/timer.h>23 #include <linux/bitops.h>24 #include <linux/bitmap.h>25 20 26 21 struct regmap; … … 99 94 bool (*volatile_reg)(struct device *dev, unsigned int reg); 100 95 bool (*precious_reg)(struct device *dev, unsigned int reg); 96 bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg); 101 97 bool (*readable_noinc_reg)(struct device *dev, unsigned int reg); 102 98 const struct regmap_access_table *wr_table; … … 104 100 const struct regmap_access_table *volatile_table; 105 101 const struct regmap_access_table *precious_table; 102 const struct regmap_access_table *wr_noinc_table; 106 103 const struct regmap_access_table *rd_noinc_table; 107 104 … … 154 151 /* if set, converts bulk read to single read */ 155 152 bool use_single_read; 156 /* if set, converts bulk read to single read*/153 /* if set, converts bulk write to single write */ 157 154 bool use_single_write; 158 155 /* if set, the device supports multi write mode */ … … 167 164 168 165 struct hwspinlock *hwlock; 166 167 /* if set, the regmap core can sleep */ 168 bool can_sleep; 169 169 }; 170 170 … … 188 188 bool regmap_volatile(struct regmap *map, unsigned int reg); 189 189 bool regmap_precious(struct regmap *map, unsigned int reg); 190 bool regmap_writeable_noinc(struct regmap *map, unsigned int reg); 190 191 bool regmap_readable_noinc(struct regmap *map, unsigned int reg); 191 192 … … 222 223 #ifdef CONFIG_DEBUG_FS 223 224 extern void regmap_debugfs_initcall(void); 224 extern void regmap_debugfs_init(struct regmap *map , const char *name);225 extern void regmap_debugfs_init(struct regmap *map); 225 226 extern void regmap_debugfs_exit(struct regmap *map); 226 227 … … 232 233 #else 233 234 static inline void regmap_debugfs_initcall(void) { } 234 static inline void regmap_debugfs_init(struct regmap *map , const char *name) { }235 static inline void regmap_debugfs_init(struct regmap *map) { } 235 236 static inline void regmap_debugfs_exit(struct regmap *map) { } 236 237 static inline void regmap_debugfs_disable(struct regmap *map) { } … … 264 265 265 266 int _regmap_raw_write(struct regmap *map, unsigned int reg, 266 const void *val, size_t val_len );267 const void *val, size_t val_len, bool noinc); 267 268 268 269 void regmap_async_complete_cb(struct regmap_async *async, int ret); -
GPL/branches/uniaud32-next/lib32/regcache-flat.c
r625 r652 1 /* 2 * Register cache access API - flat caching support 3 * 4 * Copyright 2012 Wolfson Microelectronics plc 5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.19.163 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register cache access API - flat caching support 4 // 5 // Copyright 2012 Wolfson Microelectronics plc 6 // 7 // Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 #include <linux/device.h> -
GPL/branches/uniaud32-next/lib32/regcache-lzo.c
r615 r652 1 /* 2 * Register cache access API - LZO caching support 3 * 4 * Copyright 2011 Wolfson Microelectronics plc 5 * 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.14.202 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register cache access API - LZO caching support 4 // 5 // Copyright 2011 Wolfson Microelectronics plc 6 // 7 // Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 #include <linux/device.h> 15 12 #include <linux/lzo.h> 16 13 #include <linux/slab.h> 17 #include <linux/module.h>18 #include <linux/workqueue.h>19 #include <linux/byteorder/little_endian.h>20 #include <linux/printk.h>21 14 22 15 #include "internal.h" … … 158 151 */ 159 152 bmp_size = map->num_reg_defaults_raw; 160 sync_bmp = kmalloc_array(BITS_TO_LONGS(bmp_size), sizeof(long), 161 GFP_KERNEL); 153 sync_bmp = bitmap_zalloc(bmp_size, GFP_KERNEL); 162 154 if (!sync_bmp) { 163 155 ret = -ENOMEM; 164 156 goto err; 165 157 } 166 bitmap_zero(sync_bmp, bmp_size);167 158 168 159 /* allocate the lzo blocks and initialize them */ … … 171 162 GFP_KERNEL); 172 163 if (!lzo_blocks[i]) { 173 kfree(sync_bmp);164 bitmap_free(sync_bmp); 174 165 ret = -ENOMEM; 175 166 goto err; … … 223 214 */ 224 215 if (lzo_blocks[0]) 225 kfree(lzo_blocks[0]->sync_bmp);216 bitmap_free(lzo_blocks[0]->sync_bmp); 226 217 for (i = 0; i < blkcount; i++) { 227 218 if (lzo_blocks[i]) { -
GPL/branches/uniaud32-next/lib32/regcache-rbtree.c
r647 r652 1 /* 2 * Register cache access API - rbtree caching support 3 * 4 * Copyright 2011 Wolfson Microelectronics plc 5 * 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.19.163 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register cache access API - rbtree caching support 4 // 5 // Copyright 2011 Wolfson Microelectronics plc 6 // 7 // Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 //#include <linux/debugfs.h> … … 17 14 #include <linux/seq_file.h> 18 15 #include <linux/slab.h> 19 #include <linux/module.h> 20 #include <linux/workqueue.h> 21 #include <linux/byteorder/little_endian.h> 22 #include <linux/printk.h> 23 16 #ifdef TARGET_OS2 17 #include <linux/bitmap.h> 18 #endif 24 19 #include "internal.h" 25 20 26 /*static inline*/int regcache_rbtree_write(struct regmap *map, unsigned int reg,21 static int regcache_rbtree_write(struct regmap *map, unsigned int reg, 27 22 unsigned int value); 28 /*static inline*/int regcache_rbtree_exit(struct regmap *map);23 static int regcache_rbtree_exit(struct regmap *map); 29 24 30 25 struct regcache_rbtree_node { … … 39 34 /* the actual rbtree node holding this block */ 40 35 struct rb_node node; 41 } /*__attribute__ ((packed))*/;36 }; 42 37 43 38 struct regcache_rbtree_ctx { … … 46 41 }; 47 42 48 /*static inline*/inline void regcache_rbtree_get_base_top_reg(43 static inline void regcache_rbtree_get_base_top_reg( 49 44 struct regmap *map, 50 45 struct regcache_rbtree_node *rbnode, … … 55 50 } 56 51 57 /*static inline*/unsigned int regcache_rbtree_get_register(struct regmap *map,52 static unsigned int regcache_rbtree_get_register(struct regmap *map, 58 53 struct regcache_rbtree_node *rbnode, unsigned int idx) 59 54 { … … 61 56 } 62 57 63 /*static inline*/void regcache_rbtree_set_register(struct regmap *map,58 static void regcache_rbtree_set_register(struct regmap *map, 64 59 struct regcache_rbtree_node *rbnode, 65 60 unsigned int idx, unsigned int val) … … 69 64 } 70 65 71 /*static inline*/struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map,66 static struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map, 72 67 unsigned int reg) 73 68 { … … 103 98 } 104 99 105 /*static inline*/int regcache_rbtree_insert(struct regmap *map, struct rb_root *root,100 static int regcache_rbtree_insert(struct regmap *map, struct rb_root *root, 106 101 struct regcache_rbtree_node *rbnode) 107 102 { … … 139 134 140 135 #ifdef CONFIG_DEBUG_FS 141 /*static inline*/int rbtree_show(struct seq_file *s, void *ignored)136 static int rbtree_show(struct seq_file *s, void *ignored) 142 137 { 143 138 struct regmap *map = s->private; … … 183 178 } 184 179 185 /*static inline*/ int rbtree_open(struct inode *inode, struct file *file) 186 { 187 return single_open(file, rbtree_show, inode->i_private); 188 } 189 190 /*static inline*/ const struct file_operations rbtree_fops = { 191 .open = rbtree_open, 192 .read = seq_read, 193 .llseek = seq_lseek, 194 .release = single_release, 195 }; 196 197 /*static inline*/ void rbtree_debugfs_init(struct regmap *map) 180 DEFINE_SHOW_ATTRIBUTE(rbtree); 181 182 static void rbtree_debugfs_init(struct regmap *map) 198 183 { 199 184 debugfs_create_file("rbtree", 0400, map->debugfs, map, &rbtree_fops); … … 201 186 #endif 202 187 203 /*static inline*/int regcache_rbtree_init(struct regmap *map)188 static int regcache_rbtree_init(struct regmap *map) 204 189 { 205 190 struct regcache_rbtree_ctx *rbtree_ctx; 206 191 int i; 207 192 int ret; 193 208 194 #ifdef TARGET_OS2 209 195 // 2020-11-17 SHL FIXME patched struct rb_root … … 240 226 } 241 227 242 /*static inline*/int regcache_rbtree_exit(struct regmap *map)228 static int regcache_rbtree_exit(struct regmap *map) 243 229 { 244 230 struct rb_node *next; … … 269 255 } 270 256 271 /*static inline*/int regcache_rbtree_read(struct regmap *map,257 static int regcache_rbtree_read(struct regmap *map, 272 258 unsigned int reg, unsigned int *value) 273 259 { … … 289 275 290 276 291 /*static inline*/int regcache_rbtree_insert_to_block(struct regmap *map,277 static int regcache_rbtree_insert_to_block(struct regmap *map, 292 278 struct regcache_rbtree_node *rbnode, 293 279 unsigned int base_reg, … … 324 310 * sizeof(*present)); 325 311 } else { 326 present = (unsigned long *)rbnode->cache_present;312 present = rbnode->cache_present; 327 313 } 328 314 … … 338 324 rbnode->blklen = blklen; 339 325 rbnode->base_reg = base_reg; 340 rbnode->cache_present = (long*)present;326 rbnode->cache_present = present; 341 327 342 328 regcache_rbtree_set_register(map, rbnode, pos, value); … … 344 330 } 345 331 346 /*static inline*/struct regcache_rbtree_node *332 static struct regcache_rbtree_node * 347 333 regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) 348 334 { … … 396 382 } 397 383 398 /*static inline*/int regcache_rbtree_write(struct regmap *map, unsigned int reg,384 static int regcache_rbtree_write(struct regmap *map, unsigned int reg, 399 385 unsigned int value) 400 386 { … … 492 478 } 493 479 494 /*static inline*/int regcache_rbtree_sync(struct regmap *map, unsigned int min,480 static int regcache_rbtree_sync(struct regmap *map, unsigned int min, 495 481 unsigned int max) 496 482 { … … 524 510 525 511 ret = regcache_sync_block(map, rbnode->block, 526 (unsigned long *)rbnode->cache_present,512 rbnode->cache_present, 527 513 rbnode->base_reg, start, end); 528 514 if (ret != 0) … … 533 519 } 534 520 535 /*static inline*/int regcache_rbtree_drop(struct regmap *map, unsigned int min,521 static int regcache_rbtree_drop(struct regmap *map, unsigned int min, 536 522 unsigned int max) 537 523 { … … 563 549 end = rbnode->blklen; 564 550 565 bitmap_clear( (unsigned long *)rbnode->cache_present, start, end - start);551 bitmap_clear(rbnode->cache_present, start, end - start); 566 552 } 567 553 -
GPL/branches/uniaud32-next/lib32/regcache.c
r625 r652 1 /* 2 * Register cache access API 3 * 4 * Copyright 2011 Wolfson Microelectronics plc 5 * 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.19.163 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register cache access API 4 // 5 // Copyright 2011 Wolfson Microelectronics plc 6 // 7 // Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 //#include <linux/bsearch.h> … … 253 250 ret = map->cache_ops->read(map, reg, value); 254 251 252 #ifndef TARGET_OS2 253 if (ret == 0) 254 trace_regmap_reg_read_cache(map, reg, *value); 255 #endif 255 256 return ret; 256 257 } … … 358 359 map->cache_ops->name); 359 360 name = map->cache_ops->name; 360 361 #ifndef TARGET_OS2 362 trace_regcache_sync(map, name, "start"); 363 #endif 361 364 if (!map->cache_dirty) 362 365 goto out; … … 393 396 regmap_async_complete(map); 394 397 398 #ifndef TARGET_OS2 399 trace_regcache_sync(map, name, "stop"); 400 #endif 395 401 return ret; 396 402 } … … 426 432 dev_dbg(map->dev, "Syncing %s cache from %d-%d\n", name, min, max); 427 433 434 #ifndef TARGET_OS2 435 trace_regcache_sync(map, name, "start region"); 436 #endif 428 437 if (!map->cache_dirty) 429 438 goto out; … … 445 454 regmap_async_complete(map); 446 455 456 #ifndef TARGET_OS2 457 trace_regcache_sync(map, name, "stop region"); 458 #endif 447 459 return ret; 448 460 } … … 470 482 map->lock(map->lock_arg); 471 483 484 #ifndef TARGET_OS2 485 trace_regcache_drop_region(map, min, max); 486 #endif 472 487 ret = map->cache_ops->drop(map, min, max); 473 488 … … 495 510 WARN_ON(map->cache_bypass && enable); 496 511 map->cache_only = enable; 512 #ifndef TARGET_OS2 513 trace_regmap_cache_only(map, enable); 514 #endif 497 515 map->unlock(map->lock_arg); 498 516 } … … 537 555 WARN_ON(map->cache_only && enable); 538 556 map->cache_bypass = enable; 557 #ifndef TARGET_OS2 558 trace_regmap_cache_bypass(map, enable); 559 #endif 539 560 map->unlock(map->lock_arg); 540 561 } … … 713 734 map->cache_bypass = true; 714 735 715 ret = _regmap_raw_write(map, base, *data, count * val_bytes );736 ret = _regmap_raw_write(map, base, *data, count * val_bytes, false); 716 737 if (ret) 717 738 dev_err(map->dev, "Unable to sync registers %#x-%#x. %d\n", -
GPL/branches/uniaud32-next/lib32/regmap.c
r638 r652 1 /* 2 * Register map access API 3 * 4 * Copyright 2011 Wolfson Microelectronics plc 5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 /* from 4.19.163 */ 1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Register map access API 4 // 5 // Copyright 2011 Wolfson Microelectronics plc 6 // 7 // Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 8 9 /* from 5.10.10 */ 13 10 14 11 #include <linux/device.h> … … 17 14 #include <linux/mutex.h> 18 15 #include <linux/err.h> 19 #include <linux/of.h>16 //#include <linux/property.h> 20 17 #include <linux/rbtree.h> 21 18 #include <linux/sched.h> … … 47 44 #undef LOG_DEVICE 48 45 49 /*static inline*/ int _regmap_update_bits(struct regmap *map, unsigned int reg, 46 #ifdef LOG_DEVICE 47 static inline bool regmap_should_log(struct regmap *map) 48 { 49 return (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0); 50 } 51 #else 52 static inline bool regmap_should_log(struct regmap *map) { return false; } 53 #endif 54 55 56 static int _regmap_update_bits(struct regmap *map, unsigned int reg, 50 57 unsigned int mask, unsigned int val, 51 58 bool *change, bool force_write); 52 59 53 /*static inline*/int _regmap_bus_reg_read(void *context, unsigned int reg,60 static int _regmap_bus_reg_read(void *context, unsigned int reg, 54 61 unsigned int *val); 55 /*static inline*/int _regmap_bus_read(void *context, unsigned int reg,62 static int _regmap_bus_read(void *context, unsigned int reg, 56 63 unsigned int *val); 57 /*static inline*/int _regmap_bus_formatted_write(void *context, unsigned int reg,64 static int _regmap_bus_formatted_write(void *context, unsigned int reg, 58 65 unsigned int val); 59 /*static inline*/int _regmap_bus_reg_write(void *context, unsigned int reg,66 static int _regmap_bus_reg_write(void *context, unsigned int reg, 60 67 unsigned int val); 61 /*static inline*/int _regmap_bus_raw_write(void *context, unsigned int reg,68 static int _regmap_bus_raw_write(void *context, unsigned int reg, 62 69 unsigned int val); 63 70 … … 180 187 } 181 188 189 bool regmap_writeable_noinc(struct regmap *map, unsigned int reg) 190 { 191 if (map->writeable_noinc_reg) 192 return map->writeable_noinc_reg(map->dev, reg); 193 194 if (map->wr_noinc_table) 195 return regmap_check_range_table(map, reg, map->wr_noinc_table); 196 197 return true; 198 } 199 182 200 bool regmap_readable_noinc(struct regmap *map, unsigned int reg) 183 201 { … … 191 209 } 192 210 193 /*static inline*/bool regmap_volatile_range(struct regmap *map, unsigned int reg,211 static bool regmap_volatile_range(struct regmap *map, unsigned int reg, 194 212 size_t num) 195 213 { … … 203 221 } 204 222 205 /*static inline*/ void regmap_format_2_6_write(struct regmap *map,223 static void regmap_format_12_20_write(struct regmap *map, 206 224 unsigned int reg, unsigned int val) 207 225 { 208 226 u8 *out = map->work_buf; 209 227 228 out[0] = reg >> 4; 229 out[1] = (reg << 4) | (val >> 16); 230 out[2] = val >> 8; 231 out[3] = val; 232 } 233 234 235 static void regmap_format_2_6_write(struct regmap *map, 236 unsigned int reg, unsigned int val) 237 { 238 u8 *out = map->work_buf; 239 210 240 *out = (reg << 6) | val; 211 241 } 212 242 213 /*static inline*/void regmap_format_4_12_write(struct regmap *map,243 static void regmap_format_4_12_write(struct regmap *map, 214 244 unsigned int reg, unsigned int val) 215 245 { … … 218 248 } 219 249 220 /*static inline*/void regmap_format_7_9_write(struct regmap *map,250 static void regmap_format_7_9_write(struct regmap *map, 221 251 unsigned int reg, unsigned int val) 222 252 { … … 225 255 } 226 256 227 /*static inline*/void regmap_format_10_14_write(struct regmap *map,257 static void regmap_format_10_14_write(struct regmap *map, 228 258 unsigned int reg, unsigned int val) 229 259 { … … 235 265 } 236 266 237 /*static inline*/void regmap_format_8(void *buf, unsigned int val, unsigned int shift)267 static void regmap_format_8(void *buf, unsigned int val, unsigned int shift) 238 268 { 239 269 u8 *b = buf; … … 242 272 } 243 273 244 /*static inline*/void regmap_format_16_be(void *buf, unsigned int val, unsigned int shift)274 static void regmap_format_16_be(void *buf, unsigned int val, unsigned int shift) 245 275 { 246 276 put_unaligned_be16(val << shift, buf); 247 277 } 248 278 249 /*static inline*/void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift)279 static void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift) 250 280 { 251 281 put_unaligned_le16(val << shift, buf); 252 282 } 253 283 254 /*static inline*/void regmap_format_16_native(void *buf, unsigned int val,284 static void regmap_format_16_native(void *buf, unsigned int val, 255 285 unsigned int shift) 256 286 { … … 260 290 } 261 291 262 /*static inline*/void regmap_format_24(void *buf, unsigned int val, unsigned int shift)292 static void regmap_format_24(void *buf, unsigned int val, unsigned int shift) 263 293 { 264 294 u8 *b = buf; … … 271 301 } 272 302 273 /*static inline*/void regmap_format_32_be(void *buf, unsigned int val, unsigned int shift)303 static void regmap_format_32_be(void *buf, unsigned int val, unsigned int shift) 274 304 { 275 305 put_unaligned_be32(val << shift, buf); 276 306 } 277 307 278 /*static inline*/void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift)308 static void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift) 279 309 { 280 310 put_unaligned_le32(val << shift, buf); 281 311 } 282 312 283 /*static inline*/void regmap_format_32_native(void *buf, unsigned int val,313 static void regmap_format_32_native(void *buf, unsigned int val, 284 314 unsigned int shift) 285 315 { … … 290 320 291 321 #ifdef CONFIG_64BIT 292 /*static inline*/void regmap_format_64_be(void *buf, unsigned int val, unsigned int shift)322 static void regmap_format_64_be(void *buf, unsigned int val, unsigned int shift) 293 323 { 294 324 put_unaligned_be64((u64) val << shift, buf); 295 325 } 296 326 297 /*static inline*/void regmap_format_64_le(void *buf, unsigned int val, unsigned int shift)327 static void regmap_format_64_le(void *buf, unsigned int val, unsigned int shift) 298 328 { 299 329 put_unaligned_le64((u64) val << shift, buf); 300 330 } 301 331 302 /*static inline*/void regmap_format_64_native(void *buf, unsigned int val,332 static void regmap_format_64_native(void *buf, unsigned int val, 303 333 unsigned int shift) 304 334 { … … 309 339 #endif 310 340 311 /*static inline*/void regmap_parse_inplace_noop(void *buf)312 { 313 } 314 315 /*static inline*/unsigned int regmap_parse_8(const void *buf)341 static void regmap_parse_inplace_noop(void *buf) 342 { 343 } 344 345 static unsigned int regmap_parse_8(const void *buf) 316 346 { 317 347 const u8 *b = buf; … … 320 350 } 321 351 322 /*static inline*/unsigned int regmap_parse_16_be(const void *buf)352 static unsigned int regmap_parse_16_be(const void *buf) 323 353 { 324 354 return get_unaligned_be16(buf); 325 355 } 326 356 327 /*static inline*/unsigned int regmap_parse_16_le(const void *buf)357 static unsigned int regmap_parse_16_le(const void *buf) 328 358 { 329 359 return get_unaligned_le16(buf); 330 360 } 331 361 332 /*static inline*/void regmap_parse_16_be_inplace(void *buf)362 static void regmap_parse_16_be_inplace(void *buf) 333 363 { 334 364 u16 v = get_unaligned_be16(buf); … … 337 367 } 338 368 339 /*static inline*/void regmap_parse_16_le_inplace(void *buf)369 static void regmap_parse_16_le_inplace(void *buf) 340 370 { 341 371 u16 v = get_unaligned_le16(buf); … … 344 374 } 345 375 346 /*static inline*/unsigned int regmap_parse_16_native(const void *buf)376 static unsigned int regmap_parse_16_native(const void *buf) 347 377 { 348 378 u16 v; … … 352 382 } 353 383 354 /*static inline*/unsigned int regmap_parse_24(const void *buf)384 static unsigned int regmap_parse_24(const void *buf) 355 385 { 356 386 const u8 *b = buf; … … 362 392 } 363 393 364 /*static inline*/unsigned int regmap_parse_32_be(const void *buf)394 static unsigned int regmap_parse_32_be(const void *buf) 365 395 { 366 396 return get_unaligned_be32(buf); 367 397 } 368 398 369 /*static inline*/unsigned int regmap_parse_32_le(const void *buf)399 static unsigned int regmap_parse_32_le(const void *buf) 370 400 { 371 401 return get_unaligned_le32(buf); 372 402 } 373 403 374 /*static inline*/void regmap_parse_32_be_inplace(void *buf)404 static void regmap_parse_32_be_inplace(void *buf) 375 405 { 376 406 u32 v = get_unaligned_be32(buf); … … 379 409 } 380 410 381 /*static inline*/void regmap_parse_32_le_inplace(void *buf)411 static void regmap_parse_32_le_inplace(void *buf) 382 412 { 383 413 u32 v = get_unaligned_le32(buf); … … 386 416 } 387 417 388 /*static inline*/unsigned int regmap_parse_32_native(const void *buf)418 static unsigned int regmap_parse_32_native(const void *buf) 389 419 { 390 420 u32 v; … … 395 425 396 426 #ifdef CONFIG_64BIT 397 /*static inline*/unsigned int regmap_parse_64_be(const void *buf)427 static unsigned int regmap_parse_64_be(const void *buf) 398 428 { 399 429 return get_unaligned_be64(buf); 400 430 } 401 431 402 /*static inline*/unsigned int regmap_parse_64_le(const void *buf)432 static unsigned int regmap_parse_64_le(const void *buf) 403 433 { 404 434 return get_unaligned_le64(buf); 405 435 } 406 436 407 /*static inline*/void regmap_parse_64_be_inplace(void *buf)437 static void regmap_parse_64_be_inplace(void *buf) 408 438 { 409 439 u64 v = get_unaligned_be64(buf); … … 412 442 } 413 443 414 /*static inline*/void regmap_parse_64_le_inplace(void *buf)444 static void regmap_parse_64_le_inplace(void *buf) 415 445 { 416 446 u64 v = get_unaligned_le64(buf); … … 419 449 } 420 450 421 /*static inline*/unsigned int regmap_parse_64_native(const void *buf)451 static unsigned int regmap_parse_64_native(const void *buf) 422 452 { 423 453 u64 v; … … 428 458 #endif 429 459 430 /*static inline*/void regmap_lock_hwlock(void *__map)431 { 432 //NOT_USEDstruct regmap *map = __map;460 static void regmap_lock_hwlock(void *__map) 461 { 462 struct regmap *map = __map; 433 463 434 464 // hwspin_lock_timeout(map->hwlock, UINT_MAX); 435 465 } 436 466 437 /*static inline*/void regmap_lock_hwlock_irq(void *__map)438 { 439 //NOT_USEDstruct regmap *map = __map;467 static void regmap_lock_hwlock_irq(void *__map) 468 { 469 struct regmap *map = __map; 440 470 441 471 // hwspin_lock_timeout_irq(map->hwlock, UINT_MAX); 442 472 } 443 473 444 /*static inline*/void regmap_lock_hwlock_irqsave(void *__map)445 { 446 //NOT_USEDstruct regmap *map = __map;474 static void regmap_lock_hwlock_irqsave(void *__map) 475 { 476 struct regmap *map = __map; 447 477 448 478 // hwspin_lock_timeout_irqsave(map->hwlock, UINT_MAX, … … 450 480 } 451 481 452 /*static inline*/void regmap_unlock_hwlock(void *__map)453 { 454 //NOT_USEDstruct regmap *map = __map;482 static void regmap_unlock_hwlock(void *__map) 483 { 484 struct regmap *map = __map; 455 485 456 486 // hwspin_unlock(map->hwlock); 457 487 } 458 488 459 /*static inline*/void regmap_unlock_hwlock_irq(void *__map)460 { 461 //NOT_USEDstruct regmap *map = __map;489 static void regmap_unlock_hwlock_irq(void *__map) 490 { 491 struct regmap *map = __map; 462 492 463 493 // hwspin_unlock_irq(map->hwlock); 464 494 } 465 495 466 /*static inline*/void regmap_unlock_hwlock_irqrestore(void *__map)467 { 468 //NOT_USEDstruct regmap *map = __map;496 static void regmap_unlock_hwlock_irqrestore(void *__map) 497 { 498 struct regmap *map = __map; 469 499 470 500 // hwspin_unlock_irqrestore(map->hwlock, &map->spinlock_flags); 471 501 } 472 502 473 /*static inline*/void regmap_lock_unlock_none(void *__map)474 { 475 476 } 477 478 /*static inline*/void regmap_lock_mutex(void *__map)503 static void regmap_lock_unlock_none(void *__map) 504 { 505 506 } 507 508 static void regmap_lock_mutex(void *__map) 479 509 { 480 510 struct regmap *map = __map; … … 482 512 } 483 513 484 /*static inline*/void regmap_unlock_mutex(void *__map)514 static void regmap_unlock_mutex(void *__map) 485 515 { 486 516 struct regmap *map = __map; … … 488 518 } 489 519 490 /*static inline*/void regmap_lock_spinlock(void *__map)520 static void regmap_lock_spinlock(void *__map) 491 521 __acquires(&map->spinlock) 492 522 { … … 498 528 } 499 529 500 /*static inline*/void regmap_unlock_spinlock(void *__map)530 static void regmap_unlock_spinlock(void *__map) 501 531 __releases(&map->spinlock) 502 532 { … … 505 535 } 506 536 507 /*static inline*/void dev_get_regmap_release(struct device *dev, void *res)537 static void dev_get_regmap_release(struct device *dev, void *res) 508 538 { 509 539 /* … … 514 544 } 515 545 516 /*static inline*/bool _regmap_range_add(struct regmap *map,546 static bool _regmap_range_add(struct regmap *map, 517 547 struct regmap_range_node *data) 518 548 { … … 539 569 } 540 570 541 /*static inline*/struct regmap_range_node *_regmap_range_lookup(struct regmap *map,571 static struct regmap_range_node *_regmap_range_lookup(struct regmap *map, 542 572 unsigned int reg) 543 573 { … … 559 589 } 560 590 561 /*static inline*/void regmap_range_exit(struct regmap *map)591 static void regmap_range_exit(struct regmap *map) 562 592 { 563 593 struct rb_node *next; … … 575 605 } 576 606 607 static int regmap_set_name(struct regmap *map, const struct regmap_config *config) 608 { 609 if (config->name) { 610 #ifndef TARGET_OS2 611 const char *name = kstrdup_const(config->name, GFP_KERNEL); 612 #else 613 const char *name = config->name; 614 #endif 615 616 if (!name) 617 return -ENOMEM; 618 619 #ifndef TARGET_OS2 620 kfree_const(map->name); 621 #else 622 kfree(map->name); 623 #endif 624 map->name = name; 625 } 626 627 return 0; 628 } 629 577 630 int regmap_attach_dev(struct device *dev, struct regmap *map, 578 631 const struct regmap_config *config) 579 632 { 580 633 struct regmap **m; 634 int ret; 581 635 582 636 map->dev = dev; 583 637 584 regmap_debugfs_init(map, config->name); 638 ret = regmap_set_name(map, config); 639 if (ret) 640 return ret; 641 642 regmap_debugfs_init(map); 585 643 586 644 /* Add a devres resource for dev_get_regmap() */ … … 597 655 EXPORT_SYMBOL_GPL(regmap_attach_dev); 598 656 599 /*static inline*/enum regmap_endian regmap_get_reg_endian(const struct regmap_bus *bus,657 static enum regmap_endian regmap_get_reg_endian(const struct regmap_bus *bus, 600 658 const struct regmap_config *config) 601 659 { … … 625 683 const struct regmap_config *config) 626 684 { 627 struct device_node *np; 685 #ifndef TARGET_OS2 686 struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL; 687 #else 688 struct fwnode_handle *fwnode = NULL; 689 #endif 628 690 enum regmap_endian endian; 629 691 … … 635 697 return endian; 636 698 637 /* If the dev and dev->of_node exist try to get endianness from DT */ 638 if (dev && dev->of_node) { 639 np = dev->of_node; 640 641 /* Parse the device's DT node for an endianness specification */ 642 if (of_property_read_bool(np, "big-endian")) 643 endian = REGMAP_ENDIAN_BIG; 644 else if (of_property_read_bool(np, "little-endian")) 645 endian = REGMAP_ENDIAN_LITTLE; 646 else if (of_property_read_bool(np, "native-endian")) 647 endian = REGMAP_ENDIAN_NATIVE; 648 649 /* If the endianness was specified in DT, use that */ 650 if (endian != REGMAP_ENDIAN_DEFAULT) 651 return endian; 652 } 699 #ifndef TARGET_OS2 700 /* If the firmware node exist try to get endianness from it */ 701 if (fwnode_property_read_bool(fwnode, "big-endian")) 702 endian = REGMAP_ENDIAN_BIG; 703 else if (fwnode_property_read_bool(fwnode, "little-endian")) 704 endian = REGMAP_ENDIAN_LITTLE; 705 else if (fwnode_property_read_bool(fwnode, "native-endian")) 706 endian = REGMAP_ENDIAN_NATIVE; 707 #endif 708 /* If the endianness was specified in fwnode, use that */ 709 if (endian != REGMAP_ENDIAN_DEFAULT) 710 return endian; 653 711 654 712 /* Retrieve the endianness specification from the bus config */ … … 690 748 } 691 749 692 if (config->name) { 693 #ifndef TARGET_OS2 694 map->name = kstrdup_const(config->name, GFP_KERNEL); 695 #else 696 map->name = config->name; 697 #endif 698 if (!map->name) { 699 ret = -ENOMEM; 700 goto err_map; 701 } 702 } 750 ret = regmap_set_name(map, config); 751 if (ret) 752 goto err_map; 753 754 ret = -EINVAL; /* Later error paths rely on this */ 703 755 704 756 if (config->disable_locking) { 705 757 map->lock = map->unlock = regmap_lock_unlock_none; 758 map->can_sleep = config->can_sleep; 706 759 regmap_debugfs_disable(map); 707 760 } else if (config->lock && config->unlock) { … … 709 762 map->unlock = config->unlock; 710 763 map->lock_arg = config->lock_arg; 764 map->can_sleep = config->can_sleep; 711 765 } else if (config->use_hwlock) { 712 // map->hwlock = hwspin_lock_request_specific(config->hwlock_id); 713 // if (!map->hwlock) { 714 // ret = -ENXIO; 715 // goto err_name; 716 // } 717 766 #ifndef TARGET_OS2 767 map->hwlock = hwspin_lock_request_specific(config->hwlock_id); 768 if (!map->hwlock) { 769 ret = -ENXIO; 770 goto err_name; 771 } 772 #endif 718 773 switch (config->hwlock_mode) { 719 774 case HWLOCK_IRQSTATE: … … 744 799 map->lock = regmap_lock_mutex; 745 800 map->unlock = regmap_unlock_mutex; 801 map->can_sleep = true; 746 802 lockdep_set_class_and_name(&map->mutex, 747 803 lock_key, lock_name); … … 774 830 map->reg_stride_order = -1; 775 831 map->use_single_read = config->use_single_read || !bus || !bus->read; 776 map->use_single_write = config->use_single_ read|| !bus || !bus->write;832 map->use_single_write = config->use_single_write || !bus || !bus->write; 777 833 map->can_multi_write = config->can_multi_write && bus && bus->write; 778 834 if (bus) { … … 788 844 map->volatile_table = config->volatile_table; 789 845 map->precious_table = config->precious_table; 846 map->wr_noinc_table = config->wr_noinc_table; 790 847 map->rd_noinc_table = config->rd_noinc_table; 791 848 map->writeable_reg = config->writeable_reg; … … 793 850 map->volatile_reg = config->volatile_reg; 794 851 map->precious_reg = config->precious_reg; 852 map->writeable_noinc_reg = config->writeable_noinc_reg; 795 853 map->readable_noinc_reg = config->readable_noinc_reg; 796 854 map->cache_type = config->cache_type; … … 819 877 map->reg_read = _regmap_bus_reg_read; 820 878 map->reg_write = _regmap_bus_reg_write; 879 map->reg_update_bits = bus->reg_update_bits; 821 880 822 881 map->defer_caching = false; … … 865 924 case 14: 866 925 map->format.format_write = regmap_format_10_14_write; 926 break; 927 default: 928 goto err_hwlock; 929 } 930 break; 931 932 case 12: 933 switch (config->val_bits) { 934 case 20: 935 map->format.format_write = regmap_format_12_20_write; 867 936 break; 868 937 default: … … 1048 1117 memset(&map->range_tree, 0, sizeof(struct rb_root)); 1049 1118 #endif 1050 1051 1119 for (i = 0; i < config->num_ranges; i++) { 1052 1120 const struct regmap_range_cfg *range_cfg = &config->ranges[i]; … … 1148 1216 goto err_regcache; 1149 1217 } else { 1150 regmap_debugfs_init(map , config->name);1218 regmap_debugfs_init(map); 1151 1219 } 1152 1220 … … 1159 1227 kfree(map->work_buf); 1160 1228 err_hwlock: 1161 // if (map->hwlock) 1162 // hwspin_lock_free(map->hwlock); 1163 //err_name: 1164 // kfree_const(map->name); 1229 #ifndef TARGET_OS2 1230 if (map->hwlock) 1231 hwspin_lock_free(map->hwlock); 1232 #endif 1233 err_name: 1234 #ifndef TARGET_OS2 1235 kfree_const(map->name); 1236 #else 1237 kfree(map->name); 1238 #endif 1165 1239 err_map: 1166 1240 kfree(map); … … 1171 1245 1172 1246 #ifndef TARGET_OS2 1173 /*static inline*/void devm_regmap_release(struct device *dev, void *res)1247 static void devm_regmap_release(struct device *dev, void *res) 1174 1248 { 1175 1249 regmap_exit(*(struct regmap **)res); … … 1203 1277 #endif 1204 1278 1205 /*static inline*/void regmap_field_init(struct regmap_field *rm_field,1279 static void regmap_field_init(struct regmap_field *rm_field, 1206 1280 struct regmap *regmap, struct reg_field reg_field) 1207 1281 { … … 1240 1314 } 1241 1315 EXPORT_SYMBOL_GPL(devm_regmap_field_alloc); 1316 #endif 1317 1318 /** 1319 * regmap_field_bulk_alloc() - Allocate and initialise a bulk register field. 1320 * 1321 * @regmap: regmap bank in which this register field is located. 1322 * @rm_field: regmap register fields within the bank. 1323 * @reg_field: Register fields within the bank. 1324 * @num_fields: Number of register fields. 1325 * 1326 * The return value will be an -ENOMEM on error or zero for success. 1327 * Newly allocated regmap_fields should be freed by calling 1328 * regmap_field_bulk_free() 1329 */ 1330 int regmap_field_bulk_alloc(struct regmap *regmap, 1331 struct regmap_field **rm_field, 1332 struct reg_field *reg_field, 1333 int num_fields) 1334 { 1335 struct regmap_field *rf; 1336 int i; 1337 1338 rf = kcalloc(num_fields, sizeof(*rf), GFP_KERNEL); 1339 if (!rf) 1340 return -ENOMEM; 1341 1342 for (i = 0; i < num_fields; i++) { 1343 regmap_field_init(&rf[i], regmap, reg_field[i]); 1344 rm_field[i] = &rf[i]; 1345 } 1346 1347 return 0; 1348 } 1349 EXPORT_SYMBOL_GPL(regmap_field_bulk_alloc); 1350 1351 #ifndef TARGET_OS2 1352 /** 1353 * devm_regmap_field_bulk_alloc() - Allocate and initialise a bulk register 1354 * fields. 1355 * 1356 * @dev: Device that will be interacted with 1357 * @regmap: regmap bank in which this register field is located. 1358 * @rm_field: regmap register fields within the bank. 1359 * @reg_field: Register fields within the bank. 1360 * @num_fields: Number of register fields. 1361 * 1362 * The return value will be an -ENOMEM on error or zero for success. 1363 * Newly allocated regmap_fields will be automatically freed by the 1364 * device management code. 1365 */ 1366 int devm_regmap_field_bulk_alloc(struct device *dev, 1367 struct regmap *regmap, 1368 struct regmap_field **rm_field, 1369 struct reg_field *reg_field, 1370 int num_fields) 1371 { 1372 struct regmap_field *rf; 1373 int i; 1374 1375 rf = devm_kcalloc(dev, num_fields, sizeof(*rf), GFP_KERNEL); 1376 if (!rf) 1377 return -ENOMEM; 1378 1379 for (i = 0; i < num_fields; i++) { 1380 regmap_field_init(&rf[i], regmap, reg_field[i]); 1381 rm_field[i] = &rf[i]; 1382 } 1383 1384 return 0; 1385 } 1386 EXPORT_SYMBOL_GPL(devm_regmap_field_bulk_alloc); 1387 #endif 1388 1389 /** 1390 * regmap_field_bulk_free() - Free register field allocated using 1391 * regmap_field_bulk_alloc. 1392 * 1393 * @field: regmap fields which should be freed. 1394 */ 1395 void regmap_field_bulk_free(struct regmap_field *field) 1396 { 1397 kfree(field); 1398 } 1399 EXPORT_SYMBOL_GPL(regmap_field_bulk_free); 1400 1401 #ifndef TARGET_OS2 1402 /** 1403 * devm_regmap_field_bulk_free() - Free a bulk register field allocated using 1404 * devm_regmap_field_bulk_alloc. 1405 * 1406 * @dev: Device that will be interacted with 1407 * @field: regmap field which should be freed. 1408 * 1409 * Free register field allocated using devm_regmap_field_bulk_alloc(). Usually 1410 * drivers need not call this function, as the memory allocated via devm 1411 * will be freed as per device-driver life-cycle. 1412 */ 1413 void devm_regmap_field_bulk_free(struct device *dev, 1414 struct regmap_field *field) 1415 { 1416 devm_kfree(dev, field); 1417 } 1418 EXPORT_SYMBOL_GPL(devm_regmap_field_bulk_free); 1242 1419 1243 1420 /** … … 1312 1489 int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) 1313 1490 { 1491 int ret; 1492 1314 1493 regcache_exit(map); 1315 1494 regmap_debugfs_exit(map); … … 1320 1499 map->volatile_reg = config->volatile_reg; 1321 1500 map->precious_reg = config->precious_reg; 1501 map->writeable_noinc_reg = config->writeable_noinc_reg; 1322 1502 map->readable_noinc_reg = config->readable_noinc_reg; 1323 1503 map->cache_type = config->cache_type; 1324 1504 1325 regmap_debugfs_init(map, config->name); 1505 ret = regmap_set_name(map, config); 1506 if (ret) 1507 return ret; 1508 1509 regmap_debugfs_init(map); 1326 1510 1327 1511 map->cache_bypass = false; … … 1355 1539 kfree(async); 1356 1540 } 1357 // if (map->hwlock) 1358 // hwspin_lock_free(map->hwlock); 1359 // kfree_const(map->name); 1541 #ifndef TARGET_OS2 1542 if (map->hwlock) 1543 hwspin_lock_free(map->hwlock); 1544 #endif 1545 if (map->lock == regmap_lock_mutex) 1546 mutex_destroy(&map->mutex); 1547 #ifndef TARGET_OS2 1548 kfree_const(map->name); 1549 #else 1550 kfree(map->name); 1551 #endif 1360 1552 kfree(map->patch); 1361 1553 kfree(map); … … 1363 1555 EXPORT_SYMBOL_GPL(regmap_exit); 1364 1556 1365 /*static inline*/int dev_get_regmap_match(struct device *dev, void *res, void *data)1557 static int dev_get_regmap_match(struct device *dev, void *res, void *data) 1366 1558 { 1367 1559 struct regmap **r = res; … … 1414 1606 EXPORT_SYMBOL_GPL(regmap_get_device); 1415 1607 1416 /*static inline*/int _regmap_select_page(struct regmap *map, unsigned int *reg,1608 static int _regmap_select_page(struct regmap *map, unsigned int *reg, 1417 1609 struct regmap_range_node *range, 1418 1610 unsigned int val_num) … … 1462 1654 } 1463 1655 1464 /*static inline*/void regmap_set_work_buf_flag_mask(struct regmap *map, int max_bytes,1656 static void regmap_set_work_buf_flag_mask(struct regmap *map, int max_bytes, 1465 1657 unsigned long mask) 1466 1658 { … … 1477 1669 } 1478 1670 1479 /*static inline*/int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,1480 const void *val, size_t val_len )1671 static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, 1672 const void *val, size_t val_len, bool noinc) 1481 1673 { 1482 1674 struct regmap_range_node *range; … … 1491 1683 WARN_ON(!map->bus); 1492 1684 1493 /* Check for unwritable registers before we start */ 1494 if (map->writeable_reg) 1495 for (i = 0; i < val_len / map->format.val_bytes; i++) 1496 if (!map->writeable_reg(map->dev, 1497 reg + regmap_get_offset(map, i))) 1685 /* Check for unwritable or noinc registers in range 1686 * before we start 1687 */ 1688 if (!regmap_writeable_noinc(map, reg)) { 1689 for (i = 0; i < val_len / map->format.val_bytes; i++) { 1690 unsigned int element = 1691 reg + regmap_get_offset(map, i); 1692 if (!regmap_writeable(map, element) || 1693 regmap_writeable_noinc(map, element)) 1498 1694 return -EINVAL; 1695 } 1696 } 1499 1697 1500 1698 if (!map->cache_bypass && map->format.parse_val) { … … 1531 1729 ret = _regmap_raw_write_impl(map, reg, val, 1532 1730 win_residue * 1533 map->format.val_bytes );1731 map->format.val_bytes, noinc); 1534 1732 if (ret != 0) 1535 1733 return ret; … … 1545 1743 } 1546 1744 1547 ret = _regmap_select_page(map, ®, range, val_num);1745 ret = _regmap_select_page(map, ®, range, noinc ? 1 : val_num); 1548 1746 if (ret != 0) 1549 1747 return ret; … … 1698 1896 EXPORT_SYMBOL_GPL(regmap_get_raw_write_max); 1699 1897 1700 /*static inline*/int _regmap_bus_formatted_write(void *context, unsigned int reg,1898 static int _regmap_bus_formatted_write(void *context, unsigned int reg, 1701 1899 unsigned int val) 1702 1900 { … … 1722 1920 } 1723 1921 1724 /*static inline*/int _regmap_bus_reg_write(void *context, unsigned int reg,1922 static int _regmap_bus_reg_write(void *context, unsigned int reg, 1725 1923 unsigned int val) 1726 1924 { … … 1730 1928 } 1731 1929 1732 /*static inline*/int _regmap_bus_raw_write(void *context, unsigned int reg,1930 static int _regmap_bus_raw_write(void *context, unsigned int reg, 1733 1931 unsigned int val) 1734 1932 { … … 1743 1941 map->format.reg_bytes + 1744 1942 map->format.pad_bytes, 1745 map->format.val_bytes); 1746 } 1747 1748 /*static inline*/ inline void *_regmap_map_get_context(struct regmap *map) 1943 map->format.val_bytes, 1944 false); 1945 } 1946 1947 static inline void *_regmap_map_get_context(struct regmap *map) 1749 1948 { 1750 1949 return (map->bus) ? map : map->bus_context; … … 1770 1969 } 1771 1970 1772 #ifdef LOG_DEVICE 1773 if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0) 1971 if (regmap_should_log(map)) 1774 1972 dev_info(map->dev, "%x <= %x\n", reg, val); 1973 1974 return map->reg_write(context, reg, val); 1975 } 1976 1977 #ifdef TARGET_OS2 1978 #define IS_ALIGNED(x, a) (((x) & ((unsigned int)(a) - 1)) == 0) 1775 1979 #endif 1776 1777 return map->reg_write(context, reg, val);1778 }1779 1780 #define IS_ALIGNED(x, a) (((x) & ((unsigned int)(a) - 1)) == 0)1781 1980 1782 1981 /** … … 1839 2038 1840 2039 int _regmap_raw_write(struct regmap *map, unsigned int reg, 1841 const void *val, size_t val_len )2040 const void *val, size_t val_len, bool noinc) 1842 2041 { 1843 2042 size_t val_bytes = map->format.val_bytes; … … 1860 2059 /* Write as many bytes as possible with chunk_size */ 1861 2060 for (i = 0; i < chunk_count; i++) { 1862 ret = _regmap_raw_write_impl(map, reg, val, chunk_bytes );2061 ret = _regmap_raw_write_impl(map, reg, val, chunk_bytes, noinc); 1863 2062 if (ret) 1864 2063 return ret; … … 1871 2070 /* Write remaining bytes */ 1872 2071 if (val_len) 1873 ret = _regmap_raw_write_impl(map, reg, val, val_len );2072 ret = _regmap_raw_write_impl(map, reg, val, val_len, noinc); 1874 2073 1875 2074 return ret; … … 1904 2103 map->lock(map->lock_arg); 1905 2104 1906 ret = _regmap_raw_write(map, reg, val, val_len );2105 ret = _regmap_raw_write(map, reg, val, val_len, false); 1907 2106 1908 2107 map->unlock(map->lock_arg); … … 1911 2110 } 1912 2111 EXPORT_SYMBOL_GPL(regmap_raw_write); 2112 2113 /** 2114 * regmap_noinc_write(): Write data from a register without incrementing the 2115 * register number 2116 * 2117 * @map: Register map to write to 2118 * @reg: Register to write to 2119 * @val: Pointer to data buffer 2120 * @val_len: Length of output buffer in bytes. 2121 * 2122 * The regmap API usually assumes that bulk bus write operations will write a 2123 * range of registers. Some devices have certain registers for which a write 2124 * operation can write to an internal FIFO. 2125 * 2126 * The target register must be volatile but registers after it can be 2127 * completely unrelated cacheable registers. 2128 * 2129 * This will attempt multiple writes as required to write val_len bytes. 2130 * 2131 * A value of zero will be returned on success, a negative errno will be 2132 * returned in error cases. 2133 */ 2134 int regmap_noinc_write(struct regmap *map, unsigned int reg, 2135 const void *val, size_t val_len) 2136 { 2137 size_t write_len; 2138 int ret; 2139 2140 if (!map->bus) 2141 return -EINVAL; 2142 if (!map->bus->write) 2143 return -ENOTSUPP; 2144 if (val_len % map->format.val_bytes) 2145 return -EINVAL; 2146 if (!IS_ALIGNED(reg, map->reg_stride)) 2147 return -EINVAL; 2148 if (val_len == 0) 2149 return -EINVAL; 2150 2151 map->lock(map->lock_arg); 2152 2153 if (!regmap_volatile(map, reg) || !regmap_writeable_noinc(map, reg)) { 2154 ret = -EINVAL; 2155 goto out_unlock; 2156 } 2157 2158 while (val_len) { 2159 if (map->max_raw_write && map->max_raw_write < val_len) 2160 write_len = map->max_raw_write; 2161 else 2162 write_len = val_len; 2163 ret = _regmap_raw_write(map, reg, val, write_len, true); 2164 if (ret) 2165 goto out_unlock; 2166 val = ((u8 *)val) + write_len; 2167 val_len -= write_len; 2168 } 2169 2170 out_unlock: 2171 map->unlock(map->lock_arg); 2172 return ret; 2173 } 2174 EXPORT_SYMBOL_GPL(regmap_noinc_write); 1913 2175 1914 2176 /** … … 1956 2218 * be returned in error cases. 1957 2219 */ 1958 int regmap_fields_update_bits_base(struct regmap_field *field, 2220 int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, 1959 2221 unsigned int mask, unsigned int val, 1960 2222 bool *change, bool async, bool force) … … 2057 2319 * relative. The page register has been written if that was necessary. 2058 2320 */ 2059 /*static inline*/int _regmap_raw_multi_reg_write(struct regmap *map,2321 static int _regmap_raw_multi_reg_write(struct regmap *map, 2060 2322 const struct reg_sequence *regs, 2061 2323 size_t num_regs) … … 2098 2360 2099 2361 for (i = 0; i < num_regs; i++) { 2100 int reg; 2101 reg = regs[i].reg; 2362 int reg = regs[i].reg; 2102 2363 } 2103 2364 return ret; 2104 2365 } 2105 2366 2106 /*static inline*/unsigned int _regmap_register_page(struct regmap *map,2367 static unsigned int _regmap_register_page(struct regmap *map, 2107 2368 unsigned int reg, 2108 2369 struct regmap_range_node *range) … … 2113 2374 } 2114 2375 2115 /*static inline*/int _regmap_range_multi_paged_reg_write(struct regmap *map,2376 static int _regmap_range_multi_paged_reg_write(struct regmap *map, 2116 2377 struct reg_sequence *regs, 2117 2378 size_t num_regs) … … 2166 2427 return ret; 2167 2428 2168 if (regs[i].delay_us) 2169 udelay(regs[i].delay_us); 2429 if (regs[i].delay_us) { 2430 #ifndef TARGET_OS2 2431 if (map->can_sleep) 2432 fsleep(regs[i].delay_us); 2433 else 2434 #endif 2435 udelay(regs[i].delay_us); 2436 } 2170 2437 2171 2438 base += n; … … 2190 2457 } 2191 2458 2192 /*static inline*/int _regmap_multi_reg_write(struct regmap *map,2459 static int _regmap_multi_reg_write(struct regmap *map, 2193 2460 const struct reg_sequence *regs, 2194 2461 size_t num_regs) … … 2203 2470 return ret; 2204 2471 2205 if (regs[i].delay_us) 2206 udelay(regs[i].delay_us); 2472 if (regs[i].delay_us) { 2473 #ifndef TARGET_OS2 2474 if (map->can_sleep) 2475 fsleep(regs[i].delay_us); 2476 else 2477 #endif 2478 udelay(regs[i].delay_us); 2479 } 2207 2480 } 2208 2481 return 0; … … 2375 2648 map->async = true; 2376 2649 2377 ret = _regmap_raw_write(map, reg, val, val_len );2650 ret = _regmap_raw_write(map, reg, val, val_len, false); 2378 2651 2379 2652 map->async = false; … … 2385 2658 EXPORT_SYMBOL_GPL(regmap_raw_write_async); 2386 2659 2387 /*static inline*/int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,2660 static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val, 2388 2661 unsigned int val_len, bool noinc) 2389 2662 { … … 2415 2688 } 2416 2689 2417 /*static inline*/int _regmap_bus_reg_read(void *context, unsigned int reg,2690 static int _regmap_bus_reg_read(void *context, unsigned int reg, 2418 2691 unsigned int *val) 2419 2692 { … … 2423 2696 } 2424 2697 2425 /*static inline*/int _regmap_bus_read(void *context, unsigned int reg,2698 static int _regmap_bus_read(void *context, unsigned int reg, 2426 2699 unsigned int *val) 2427 2700 { … … 2441 2714 } 2442 2715 2443 /*static inline*/int _regmap_read(struct regmap *map, unsigned int reg,2716 static int _regmap_read(struct regmap *map, unsigned int reg, 2444 2717 unsigned int *val) 2445 2718 { … … 2461 2734 ret = map->reg_read(context, reg, val); 2462 2735 if (ret == 0) { 2463 #ifdef LOG_DEVICE 2464 if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0) 2736 if (regmap_should_log(map)) 2465 2737 dev_info(map->dev, "%x => %x\n", reg, *val); 2466 #endif2467 2738 2468 2739 if (!map->cache_bypass) … … 2784 3055 EXPORT_SYMBOL_GPL(regmap_bulk_read); 2785 3056 2786 /*static inline*/int _regmap_update_bits(struct regmap *map, unsigned int reg,3057 static int _regmap_update_bits(struct regmap *map, unsigned int reg, 2787 3058 unsigned int mask, unsigned int val, 2788 3059 bool *change, bool force_write) … … 2858 3129 EXPORT_SYMBOL_GPL(regmap_update_bits_base); 2859 3130 3131 /** 3132 * regmap_test_bits() - Check if all specified bits are set in a register. 3133 * 3134 * @map: Register map to operate on 3135 * @reg: Register to read from 3136 * @bits: Bits to test 3137 * 3138 * Returns 0 if at least one of the tested bits is not set, 1 if all tested 3139 * bits are set and a negative error number if the underlying regmap_read() 3140 * fails. 3141 */ 3142 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits) 3143 { 3144 unsigned int val, ret; 3145 3146 ret = regmap_read(map, reg, &val); 3147 if (ret) 3148 return ret; 3149 3150 return (val & bits) == bits; 3151 } 3152 EXPORT_SYMBOL_GPL(regmap_test_bits); 3153 2860 3154 void regmap_async_complete_cb(struct regmap_async *async, int ret) 2861 3155 { … … 2877 3171 EXPORT_SYMBOL_GPL(regmap_async_complete_cb); 2878 3172 2879 /*static inline*/int regmap_async_is_done(struct regmap *map)3173 static int regmap_async_is_done(struct regmap *map) 2880 3174 { 2881 3175 unsigned long flags; … … 2906 3200 return 0; 2907 3201 2908 // wait_event(map->async_waitq, regmap_async_is_done(map)); 2909 3202 #ifndef TARGET_OS2 3203 wait_event(map->async_waitq, regmap_async_is_done(map)); 3204 #endif 2910 3205 spin_lock_irqsave(&map->async_lock, flags); 2911 3206 ret = map->async_ret; … … 2941 3236 bool bypass; 2942 3237 2943 #if 03238 #ifndef TARGET_OS2 2944 3239 if (WARN_ONCE(num_regs <= 0, "invalid registers number (%d)\n", 2945 3240 num_regs)) 2946 3241 return 0; 3242 #else 3243 if (num_regs <= 0) { 3244 pr_warn("invalid registers number (%d)", num_regs); 3245 return 0; 3246 } 2947 3247 #endif 2948 3248 p = krealloc(map->patch, … … 3034 3334 EXPORT_SYMBOL_GPL(regmap_parse_val); 3035 3335 3036 /*static inline*/int __init regmap_initcall(void)3336 static int __init regmap_initcall(void) 3037 3337 { 3038 3338 regmap_debugfs_initcall();
Note:
See TracChangeset
for help on using the changeset viewer.