Showing the changes to include/linux (1 of 4 files). Show all
Unified · Split
| @@ -17,10 +17,12 @@ · 16 unmodified lines | |||
| 17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 18 | #include <linux/bug.h> | 18 | #include <linux/bug.h> |
| 19 | #include <linux/lockdep.h> | 19 | #include <linux/lockdep.h> |
| 20 | #include <linux/iopoll.h> | ||
| 20 | 21 | ||
| 21 | struct module; | 22 | struct module; |
| 22 | struct clk; | 23 | struct clk; |
| 23 | struct device; | 24 | struct device; |
| 25 | struct device_node; | ||
| 24 | struct i2c_client; | 26 | struct i2c_client; |
| 25 | struct i3c_device; | 27 | struct i3c_device; |
| 26 | struct irq_domain; | 28 | struct irq_domain; |
| @@ -71,6 +73,13 @@ struct reg_sequence { · 44 unmodified lines | |||
| 71 | unsigned int delay_us; | 73 | unsigned int delay_us; |
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| 76 | #define REG_SEQ(_reg, _def, _delay_us) { \ | ||
| 77 | .reg = _reg, \ | ||
| 78 | .def = _def, \ | ||
| 79 | .delay_us = _delay_us, \ | ||
| 80 | } | ||
| 81 | #define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0) | ||
| 82 | |||
| 74 | #define regmap_update_bits(map, reg, mask, val) \ | 83 | #define regmap_update_bits(map, reg, mask, val) \ |
| 75 | regmap_update_bits_base(map, reg, mask, val, NULL, false, false) | 84 | regmap_update_bits_base(map, reg, mask, val, NULL, false, false) |
| 76 | #define regmap_update_bits_async(map, reg, mask, val)\ | 85 | #define regmap_update_bits_async(map, reg, mask, val)\ |
| @@ -122,26 +131,10 @@ struct reg_sequence { · 45 unmodified lines | |||
| 122 | */ | 131 | */ |
| 123 | #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ | 132 | #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \ |
| 124 | ({ \ | 133 | ({ \ |
| 125 | u64 __timeout_us = (timeout_us); \ | 134 | int __ret, __tmp; \ |
| 126 | unsigned long __sleep_us = (sleep_us); \ | 135 | __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ |
| 127 | ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ | 136 | sleep_us, timeout_us, false, (map), (addr), &(val)); \ |
| 128 | int __ret; \ | 137 | __ret ?: __tmp; \ |
| 129 | might_sleep_if(__sleep_us); \ | ||
| 130 | for (;;) { \ | ||
| 131 | __ret = regmap_read((map), (addr), &(val)); \ | ||
| 132 | if (__ret) \ | ||
| 133 | break; \ | ||
| 134 | if (cond) \ | ||
| 135 | break; \ | ||
| 136 | if ((__timeout_us) && \ | ||
| 137 | ktime_compare(ktime_get(), __timeout) > 0) { \ | ||
| 138 | __ret = regmap_read((map), (addr), &(val)); \ | ||
| 139 | break; \ | ||
| 140 | } \ | ||
| 141 | if (__sleep_us) \ | ||
| 142 | usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ | ||
| 143 | } \ | ||
| 144 | __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ | ||
| 145 | }) | 138 | }) |
| 146 | 139 | ||
| 147 | /** | 140 | /** |
| @@ -209,25 +202,10 @@ struct reg_sequence { · 61 unmodified lines | |||
| 209 | */ | 202 | */ |
| 210 | #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ | 203 | #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ |
| 211 | ({ \ | 204 | ({ \ |
| 212 | u64 __timeout_us = (timeout_us); \ | 205 | int __ret, __tmp; \ |
| 213 | unsigned long __sleep_us = (sleep_us); \ | 206 | __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \ |
| 214 | ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \ | 207 | sleep_us, timeout_us, false, (field), &(val)); \ |
| 215 | int pollret; \ | 208 | __ret ?: __tmp; \ |
| 216 | might_sleep_if(__sleep_us); \ | ||
| 217 | for (;;) { \ | ||
| 218 | pollret = regmap_field_read((field), &(val)); \ | ||
| 219 | if (pollret) \ | ||
| 220 | break; \ | ||
| 221 | if (cond) \ | ||
| 222 | break; \ | ||
| 223 | if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ | ||
| 224 | pollret = regmap_field_read((field), &(val)); \ | ||
| 225 | break; \ | ||
| 226 | } \ | ||
| 227 | if (__sleep_us) \ | ||
| 228 | usleep_range((__sleep_us >> 2) + 1, __sleep_us); \ | ||
| 229 | } \ | ||
| 230 | pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ | ||
| 231 | }) | 209 | }) |
| 232 | 210 | ||
| 233 | #ifdef CONFIG_REGMAP | 211 | #ifdef CONFIG_REGMAP |
| @@ -1111,6 +1089,21 @@ bool regmap_reg_in_ranges(unsigned int reg, · 877 unmodified lines | |||
| 1111 | const struct regmap_range *ranges, | 1089 | const struct regmap_range *ranges, |
| 1112 | unsigned int nranges); | 1090 | unsigned int nranges); |
| 1113 | 1091 | ||
| 1092 | static inline int regmap_set_bits(struct regmap *map, | ||
| 1093 | unsigned int reg, unsigned int bits) | ||
| 1094 | { | ||
| 1095 | return regmap_update_bits_base(map, reg, bits, bits, | ||
| 1096 | NULL, false, false); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | static inline int regmap_clear_bits(struct regmap *map, | ||
| 1100 | unsigned int reg, unsigned int bits) | ||
| 1101 | { | ||
| 1102 | return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false); | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits); | ||
| 1106 | |||
| 1114 | /** | 1107 | /** |
| 1115 | * struct reg_field - Description of an register field | 1108 | * struct reg_field - Description of an register field |
| 1116 | * | 1109 | * |
| @@ -1134,6 +1127,14 @@ struct reg_field { · 17 unmodified lines | |||
| 1134 | .msb = _msb, \ | 1127 | .msb = _msb, \ |
| 1135 | } | 1128 | } |
| 1136 | 1129 | ||
| 1130 | #define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \ | ||
| 1131 | .reg = _reg, \ | ||
| 1132 | .lsb = _lsb, \ | ||
| 1133 | .msb = _msb, \ | ||
| 1134 | .id_size = _size, \ | ||
| 1135 | .id_offset = _offset, \ | ||
| 1136 | } | ||
| 1137 | |||
| 1137 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, | 1138 | struct regmap_field *regmap_field_alloc(struct regmap *regmap, |
| 1138 | struct reg_field reg_field); | 1139 | struct reg_field reg_field); |
| 1139 | void regmap_field_free(struct regmap_field *field); | 1140 | void regmap_field_free(struct regmap_field *field); |
| @@ -1310,12 +1311,21 @@ struct regmap_irq_chip_data; · 170 unmodified lines | |||
| 1310 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | 1311 | int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, |
| 1311 | int irq_base, const struct regmap_irq_chip *chip, | 1312 | int irq_base, const struct regmap_irq_chip *chip, |
| 1312 | struct regmap_irq_chip_data **data); | 1313 | struct regmap_irq_chip_data **data); |
| 1314 | int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq, | ||
| 1315 | int irq_flags, int irq_base, | ||
| 1316 | const struct regmap_irq_chip *chip, | ||
| 1317 | struct regmap_irq_chip_data **data); | ||
| 1313 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); | 1318 | void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); |
| 1314 | 1319 | ||
| 1315 | int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, | 1320 | int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, |
| 1316 | int irq_flags, int irq_base, | 1321 | int irq_flags, int irq_base, |
| 1317 | const struct regmap_irq_chip *chip, | 1322 | const struct regmap_irq_chip *chip, |
| 1318 | struct regmap_irq_chip_data **data); | 1323 | struct regmap_irq_chip_data **data); |
| 1324 | int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np, | ||
| 1325 | struct regmap *map, int irq, int irq_flags, | ||
| 1326 | int irq_base, | ||
| 1327 | const struct regmap_irq_chip *chip, | ||
| 1328 | struct regmap_irq_chip_data **data); | ||
| 1319 | void devm_regmap_del_irq_chip(struct device *dev, int irq, | 1329 | void devm_regmap_del_irq_chip(struct device *dev, int irq, |
| 1320 | struct regmap_irq_chip_data *data); | 1330 | struct regmap_irq_chip_data *data); |
| 1321 | 1331 | ||
| @@ -1410,6 +1420,27 @@ static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg, · 88 unmodified lines | |||
| 1410 | return -EINVAL; | 1420 | return -EINVAL; |
| 1411 | } | 1421 | } |
| 1412 | 1422 | ||
| 1423 | static inline int regmap_set_bits(struct regmap *map, | ||
| 1424 | unsigned int reg, unsigned int bits) | ||
| 1425 | { | ||
| 1426 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 1427 | return -EINVAL; | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | static inline int regmap_clear_bits(struct regmap *map, | ||
| 1431 | unsigned int reg, unsigned int bits) | ||
| 1432 | { | ||
| 1433 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 1434 | return -EINVAL; | ||
| 1435 | } | ||
| 1436 | |||
| 1437 | static inline int regmap_test_bits(struct regmap *map, | ||
| 1438 | unsigned int reg, unsigned int bits) | ||
| 1439 | { | ||
| 1440 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 1441 | return -EINVAL; | ||
| 1442 | } | ||
| 1443 | |||
| 1413 | static inline int regmap_field_update_bits_base(struct regmap_field *field, | 1444 | static inline int regmap_field_update_bits_base(struct regmap_field *field, |
| 1414 | unsigned int mask, unsigned int val, | 1445 | unsigned int mask, unsigned int val, |
| 1415 | bool *change, bool async, bool force) | 1446 | bool *change, bool async, bool force) |