diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/regmap/internal.h | 8 | ||||
| -rw-r--r-- | drivers/base/regmap/regcache.c | 3 | ||||
| -rw-r--r-- | drivers/base/regmap/regmap.c | 294 | ||||
| -rw-r--r-- | drivers/mfd/mc13xxx-core.c | 5 | ||||
| -rw-r--r-- | drivers/mfd/mc13xxx-spi.c | 5 |
5 files changed, 272 insertions, 43 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 57f777835d97..33414b1de201 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h | |||
| @@ -44,7 +44,6 @@ struct regmap_format { | |||
| 44 | 44 | ||
| 45 | struct regmap_async { | 45 | struct regmap_async { |
| 46 | struct list_head list; | 46 | struct list_head list; |
| 47 | struct work_struct cleanup; | ||
| 48 | struct regmap *map; | 47 | struct regmap *map; |
| 49 | void *work_buf; | 48 | void *work_buf; |
| 50 | }; | 49 | }; |
| @@ -64,9 +63,11 @@ struct regmap { | |||
| 64 | void *bus_context; | 63 | void *bus_context; |
| 65 | const char *name; | 64 | const char *name; |
| 66 | 65 | ||
| 66 | bool async; | ||
| 67 | spinlock_t async_lock; | 67 | spinlock_t async_lock; |
| 68 | wait_queue_head_t async_waitq; | 68 | wait_queue_head_t async_waitq; |
| 69 | struct list_head async_list; | 69 | struct list_head async_list; |
| 70 | struct list_head async_free; | ||
| 70 | int async_ret; | 71 | int async_ret; |
| 71 | 72 | ||
| 72 | #ifdef CONFIG_DEBUG_FS | 73 | #ifdef CONFIG_DEBUG_FS |
| @@ -179,6 +180,9 @@ struct regmap_field { | |||
| 179 | /* lsb */ | 180 | /* lsb */ |
| 180 | unsigned int shift; | 181 | unsigned int shift; |
| 181 | unsigned int reg; | 182 | unsigned int reg; |
| 183 | |||
| 184 | unsigned int id_size; | ||
| 185 | unsigned int id_offset; | ||
| 182 | }; | 186 | }; |
| 183 | 187 | ||
| 184 | #ifdef CONFIG_DEBUG_FS | 188 | #ifdef CONFIG_DEBUG_FS |
| @@ -218,7 +222,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, | |||
| 218 | int regcache_lookup_reg(struct regmap *map, unsigned int reg); | 222 | int regcache_lookup_reg(struct regmap *map, unsigned int reg); |
| 219 | 223 | ||
| 220 | int _regmap_raw_write(struct regmap *map, unsigned int reg, | 224 | int _regmap_raw_write(struct regmap *map, unsigned int reg, |
| 221 | const void *val, size_t val_len, bool async); | 225 | const void *val, size_t val_len); |
| 222 | 226 | ||
| 223 | void regmap_async_complete_cb(struct regmap_async *async, int ret); | 227 | void regmap_async_complete_cb(struct regmap_async *async, int ret); |
| 224 | 228 | ||
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d6c2d691b6e8..a36112af494c 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
| @@ -631,8 +631,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, | |||
| 631 | 631 | ||
| 632 | map->cache_bypass = 1; | 632 | map->cache_bypass = 1; |
| 633 | 633 | ||
| 634 | ret = _regmap_raw_write(map, base, *data, count * val_bytes, | 634 | ret = _regmap_raw_write(map, base, *data, count * val_bytes); |
| 635 | false); | ||
| 636 | 635 | ||
| 637 | map->cache_bypass = 0; | 636 | map->cache_bypass = 0; |
| 638 | 637 | ||
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 7d689a15c500..ccdac61ac5e2 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
| @@ -42,15 +42,6 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg, | |||
| 42 | static int _regmap_bus_raw_write(void *context, unsigned int reg, | 42 | static int _regmap_bus_raw_write(void *context, unsigned int reg, |
| 43 | unsigned int val); | 43 | unsigned int val); |
| 44 | 44 | ||
| 45 | static void async_cleanup(struct work_struct *work) | ||
| 46 | { | ||
| 47 | struct regmap_async *async = container_of(work, struct regmap_async, | ||
| 48 | cleanup); | ||
| 49 | |||
| 50 | kfree(async->work_buf); | ||
| 51 | kfree(async); | ||
| 52 | } | ||
| 53 | |||
| 54 | bool regmap_reg_in_ranges(unsigned int reg, | 45 | bool regmap_reg_in_ranges(unsigned int reg, |
| 55 | const struct regmap_range *ranges, | 46 | const struct regmap_range *ranges, |
| 56 | unsigned int nranges) | 47 | unsigned int nranges) |
| @@ -465,6 +456,7 @@ struct regmap *regmap_init(struct device *dev, | |||
| 465 | 456 | ||
| 466 | spin_lock_init(&map->async_lock); | 457 | spin_lock_init(&map->async_lock); |
| 467 | INIT_LIST_HEAD(&map->async_list); | 458 | INIT_LIST_HEAD(&map->async_list); |
| 459 | INIT_LIST_HEAD(&map->async_free); | ||
| 468 | init_waitqueue_head(&map->async_waitq); | 460 | init_waitqueue_head(&map->async_waitq); |
| 469 | 461 | ||
| 470 | if (config->read_flag_mask || config->write_flag_mask) { | 462 | if (config->read_flag_mask || config->write_flag_mask) { |
| @@ -821,6 +813,8 @@ static void regmap_field_init(struct regmap_field *rm_field, | |||
| 821 | rm_field->reg = reg_field.reg; | 813 | rm_field->reg = reg_field.reg; |
| 822 | rm_field->shift = reg_field.lsb; | 814 | rm_field->shift = reg_field.lsb; |
| 823 | rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb); | 815 | rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb); |
| 816 | rm_field->id_size = reg_field.id_size; | ||
| 817 | rm_field->id_offset = reg_field.id_offset; | ||
| 824 | } | 818 | } |
| 825 | 819 | ||
| 826 | /** | 820 | /** |
| @@ -942,12 +936,22 @@ EXPORT_SYMBOL_GPL(regmap_reinit_cache); | |||
| 942 | */ | 936 | */ |
| 943 | void regmap_exit(struct regmap *map) | 937 | void regmap_exit(struct regmap *map) |
| 944 | { | 938 | { |
| 939 | struct regmap_async *async; | ||
| 940 | |||
| 945 | regcache_exit(map); | 941 | regcache_exit(map); |
| 946 | regmap_debugfs_exit(map); | 942 | regmap_debugfs_exit(map); |
| 947 | regmap_range_exit(map); | 943 | regmap_range_exit(map); |
| 948 | if (map->bus && map->bus->free_context) | 944 | if (map->bus && map->bus->free_context) |
| 949 | map->bus->free_context(map->bus_context); | 945 | map->bus->free_context(map->bus_context); |
| 950 | kfree(map->work_buf); | 946 | kfree(map->work_buf); |
| 947 | while (!list_empty(&map->async_free)) { | ||
| 948 | async = list_first_entry_or_null(&map->async_free, | ||
| 949 | struct regmap_async, | ||
| 950 | list); | ||
| 951 | list_del(&async->list); | ||
| 952 | kfree(async->work_buf); | ||
| 953 | kfree(async); | ||
| 954 | } | ||
| 951 | kfree(map); | 955 | kfree(map); |
| 952 | } | 956 | } |
| 953 | EXPORT_SYMBOL_GPL(regmap_exit); | 957 | EXPORT_SYMBOL_GPL(regmap_exit); |
| @@ -1039,7 +1043,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, | |||
| 1039 | } | 1043 | } |
| 1040 | 1044 | ||
| 1041 | int _regmap_raw_write(struct regmap *map, unsigned int reg, | 1045 | int _regmap_raw_write(struct regmap *map, unsigned int reg, |
| 1042 | const void *val, size_t val_len, bool async) | 1046 | const void *val, size_t val_len) |
| 1043 | { | 1047 | { |
| 1044 | struct regmap_range_node *range; | 1048 | struct regmap_range_node *range; |
| 1045 | unsigned long flags; | 1049 | unsigned long flags; |
| @@ -1091,7 +1095,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1091 | dev_dbg(map->dev, "Writing window %d/%zu\n", | 1095 | dev_dbg(map->dev, "Writing window %d/%zu\n", |
| 1092 | win_residue, val_len / map->format.val_bytes); | 1096 | win_residue, val_len / map->format.val_bytes); |
| 1093 | ret = _regmap_raw_write(map, reg, val, win_residue * | 1097 | ret = _regmap_raw_write(map, reg, val, win_residue * |
| 1094 | map->format.val_bytes, async); | 1098 | map->format.val_bytes); |
| 1095 | if (ret != 0) | 1099 | if (ret != 0) |
| 1096 | return ret; | 1100 | return ret; |
| 1097 | 1101 | ||
| @@ -1114,21 +1118,42 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1114 | 1118 | ||
| 1115 | u8[0] |= map->write_flag_mask; | 1119 | u8[0] |= map->write_flag_mask; |
| 1116 | 1120 | ||
| 1117 | if (async && map->bus->async_write) { | 1121 | /* |
| 1118 | struct regmap_async *async = map->bus->async_alloc(); | 1122 | * Essentially all I/O mechanisms will be faster with a single |
| 1119 | if (!async) | 1123 | * buffer to write. Since register syncs often generate raw |
| 1120 | return -ENOMEM; | 1124 | * writes of single registers optimise that case. |
| 1125 | */ | ||
| 1126 | if (val != work_val && val_len == map->format.val_bytes) { | ||
| 1127 | memcpy(work_val, val, map->format.val_bytes); | ||
| 1128 | val = work_val; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | if (map->async && map->bus->async_write) { | ||
| 1132 | struct regmap_async *async; | ||
| 1121 | 1133 | ||
| 1122 | trace_regmap_async_write_start(map->dev, reg, val_len); | 1134 | trace_regmap_async_write_start(map->dev, reg, val_len); |
| 1123 | 1135 | ||
| 1124 | async->work_buf = kzalloc(map->format.buf_size, | 1136 | spin_lock_irqsave(&map->async_lock, flags); |
| 1125 | GFP_KERNEL | GFP_DMA); | 1137 | async = list_first_entry_or_null(&map->async_free, |
| 1126 | if (!async->work_buf) { | 1138 | struct regmap_async, |
| 1127 | kfree(async); | 1139 | list); |
| 1128 | return -ENOMEM; | 1140 | if (async) |
| 1141 | list_del(&async->list); | ||
| 1142 | spin_unlock_irqrestore(&map->async_lock, flags); | ||
| 1143 | |||
| 1144 | if (!async) { | ||
| 1145 | async = map->bus->async_alloc(); | ||
| 1146 | if (!async) | ||
| 1147 | return -ENOMEM; | ||
| 1148 | |||
| 1149 | async->work_buf = kzalloc(map->format.buf_size, | ||
| 1150 | GFP_KERNEL | GFP_DMA); | ||
| 1151 | if (!async->work_buf) { | ||
| 1152 | kfree(async); | ||
| 1153 | return -ENOMEM; | ||
| 1154 | } | ||
| 1129 | } | 1155 | } |
| 1130 | 1156 | ||
| 1131 | INIT_WORK(&async->cleanup, async_cleanup); | ||
| 1132 | async->map = map; | 1157 | async->map = map; |
| 1133 | 1158 | ||
| 1134 | /* If the caller supplied the value we can use it safely. */ | 1159 | /* If the caller supplied the value we can use it safely. */ |
| @@ -1152,11 +1177,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1152 | ret); | 1177 | ret); |
| 1153 | 1178 | ||
| 1154 | spin_lock_irqsave(&map->async_lock, flags); | 1179 | spin_lock_irqsave(&map->async_lock, flags); |
| 1155 | list_del(&async->list); | 1180 | list_move(&async->list, &map->async_free); |
| 1156 | spin_unlock_irqrestore(&map->async_lock, flags); | 1181 | spin_unlock_irqrestore(&map->async_lock, flags); |
| 1157 | |||
| 1158 | kfree(async->work_buf); | ||
| 1159 | kfree(async); | ||
| 1160 | } | 1182 | } |
| 1161 | 1183 | ||
| 1162 | return ret; | 1184 | return ret; |
| @@ -1253,7 +1275,7 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg, | |||
| 1253 | map->work_buf + | 1275 | map->work_buf + |
| 1254 | map->format.reg_bytes + | 1276 | map->format.reg_bytes + |
| 1255 | map->format.pad_bytes, | 1277 | map->format.pad_bytes, |
| 1256 | map->format.val_bytes, false); | 1278 | map->format.val_bytes); |
| 1257 | } | 1279 | } |
| 1258 | 1280 | ||
| 1259 | static inline void *_regmap_map_get_context(struct regmap *map) | 1281 | static inline void *_regmap_map_get_context(struct regmap *map) |
| @@ -1318,6 +1340,37 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val) | |||
| 1318 | EXPORT_SYMBOL_GPL(regmap_write); | 1340 | EXPORT_SYMBOL_GPL(regmap_write); |
| 1319 | 1341 | ||
| 1320 | /** | 1342 | /** |
| 1343 | * regmap_write_async(): Write a value to a single register asynchronously | ||
| 1344 | * | ||
| 1345 | * @map: Register map to write to | ||
| 1346 | * @reg: Register to write to | ||
| 1347 | * @val: Value to be written | ||
| 1348 | * | ||
| 1349 | * A value of zero will be returned on success, a negative errno will | ||
| 1350 | * be returned in error cases. | ||
| 1351 | */ | ||
| 1352 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val) | ||
| 1353 | { | ||
| 1354 | int ret; | ||
| 1355 | |||
| 1356 | if (reg % map->reg_stride) | ||
| 1357 | return -EINVAL; | ||
| 1358 | |||
| 1359 | map->lock(map->lock_arg); | ||
| 1360 | |||
| 1361 | map->async = true; | ||
| 1362 | |||
| 1363 | ret = _regmap_write(map, reg, val); | ||
| 1364 | |||
| 1365 | map->async = false; | ||
| 1366 | |||
| 1367 | map->unlock(map->lock_arg); | ||
| 1368 | |||
| 1369 | return ret; | ||
| 1370 | } | ||
| 1371 | EXPORT_SYMBOL_GPL(regmap_write_async); | ||
| 1372 | |||
| 1373 | /** | ||
| 1321 | * regmap_raw_write(): Write raw values to one or more registers | 1374 | * regmap_raw_write(): Write raw values to one or more registers |
| 1322 | * | 1375 | * |
| 1323 | * @map: Register map to write to | 1376 | * @map: Register map to write to |
| @@ -1345,7 +1398,7 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1345 | 1398 | ||
| 1346 | map->lock(map->lock_arg); | 1399 | map->lock(map->lock_arg); |
| 1347 | 1400 | ||
| 1348 | ret = _regmap_raw_write(map, reg, val, val_len, false); | 1401 | ret = _regmap_raw_write(map, reg, val, val_len); |
| 1349 | 1402 | ||
| 1350 | map->unlock(map->lock_arg); | 1403 | map->unlock(map->lock_arg); |
| 1351 | 1404 | ||
| @@ -1369,6 +1422,74 @@ int regmap_field_write(struct regmap_field *field, unsigned int val) | |||
| 1369 | } | 1422 | } |
| 1370 | EXPORT_SYMBOL_GPL(regmap_field_write); | 1423 | EXPORT_SYMBOL_GPL(regmap_field_write); |
| 1371 | 1424 | ||
| 1425 | /** | ||
| 1426 | * regmap_field_update_bits(): Perform a read/modify/write cycle | ||
| 1427 | * on the register field | ||
| 1428 | * | ||
| 1429 | * @field: Register field to write to | ||
| 1430 | * @mask: Bitmask to change | ||
| 1431 | * @val: Value to be written | ||
| 1432 | * | ||
| 1433 | * A value of zero will be returned on success, a negative errno will | ||
| 1434 | * be returned in error cases. | ||
| 1435 | */ | ||
| 1436 | int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val) | ||
| 1437 | { | ||
| 1438 | mask = (mask << field->shift) & field->mask; | ||
| 1439 | |||
| 1440 | return regmap_update_bits(field->regmap, field->reg, | ||
| 1441 | mask, val << field->shift); | ||
| 1442 | } | ||
| 1443 | EXPORT_SYMBOL_GPL(regmap_field_update_bits); | ||
| 1444 | |||
| 1445 | /** | ||
| 1446 | * regmap_fields_write(): Write a value to a single register field with port ID | ||
| 1447 | * | ||
| 1448 | * @field: Register field to write to | ||
| 1449 | * @id: port ID | ||
| 1450 | * @val: Value to be written | ||
| 1451 | * | ||
| 1452 | * A value of zero will be returned on success, a negative errno will | ||
| 1453 | * be returned in error cases. | ||
| 1454 | */ | ||
| 1455 | int regmap_fields_write(struct regmap_field *field, unsigned int id, | ||
| 1456 | unsigned int val) | ||
| 1457 | { | ||
| 1458 | if (id >= field->id_size) | ||
| 1459 | return -EINVAL; | ||
| 1460 | |||
| 1461 | return regmap_update_bits(field->regmap, | ||
| 1462 | field->reg + (field->id_offset * id), | ||
| 1463 | field->mask, val << field->shift); | ||
| 1464 | } | ||
| 1465 | EXPORT_SYMBOL_GPL(regmap_fields_write); | ||
| 1466 | |||
| 1467 | /** | ||
| 1468 | * regmap_fields_update_bits(): Perform a read/modify/write cycle | ||
| 1469 | * on the register field | ||
| 1470 | * | ||
| 1471 | * @field: Register field to write to | ||
| 1472 | * @id: port ID | ||
| 1473 | * @mask: Bitmask to change | ||
| 1474 | * @val: Value to be written | ||
| 1475 | * | ||
| 1476 | * A value of zero will be returned on success, a negative errno will | ||
| 1477 | * be returned in error cases. | ||
| 1478 | */ | ||
| 1479 | int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, | ||
| 1480 | unsigned int mask, unsigned int val) | ||
| 1481 | { | ||
| 1482 | if (id >= field->id_size) | ||
| 1483 | return -EINVAL; | ||
| 1484 | |||
| 1485 | mask = (mask << field->shift) & field->mask; | ||
| 1486 | |||
| 1487 | return regmap_update_bits(field->regmap, | ||
| 1488 | field->reg + (field->id_offset * id), | ||
| 1489 | mask, val << field->shift); | ||
| 1490 | } | ||
| 1491 | EXPORT_SYMBOL_GPL(regmap_fields_update_bits); | ||
| 1492 | |||
| 1372 | /* | 1493 | /* |
| 1373 | * regmap_bulk_write(): Write multiple registers to the device | 1494 | * regmap_bulk_write(): Write multiple registers to the device |
| 1374 | * | 1495 | * |
| @@ -1426,8 +1547,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | |||
| 1426 | return ret; | 1547 | return ret; |
| 1427 | } | 1548 | } |
| 1428 | } else { | 1549 | } else { |
| 1429 | ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count, | 1550 | ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count); |
| 1430 | false); | ||
| 1431 | } | 1551 | } |
| 1432 | 1552 | ||
| 1433 | if (val_bytes != 1) | 1553 | if (val_bytes != 1) |
| @@ -1473,7 +1593,11 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg, | |||
| 1473 | 1593 | ||
| 1474 | map->lock(map->lock_arg); | 1594 | map->lock(map->lock_arg); |
| 1475 | 1595 | ||
| 1476 | ret = _regmap_raw_write(map, reg, val, val_len, true); | 1596 | map->async = true; |
| 1597 | |||
| 1598 | ret = _regmap_raw_write(map, reg, val, val_len); | ||
| 1599 | |||
| 1600 | map->async = false; | ||
| 1477 | 1601 | ||
| 1478 | map->unlock(map->lock_arg); | 1602 | map->unlock(map->lock_arg); |
| 1479 | 1603 | ||
| @@ -1677,6 +1801,39 @@ int regmap_field_read(struct regmap_field *field, unsigned int *val) | |||
| 1677 | EXPORT_SYMBOL_GPL(regmap_field_read); | 1801 | EXPORT_SYMBOL_GPL(regmap_field_read); |
| 1678 | 1802 | ||
| 1679 | /** | 1803 | /** |
| 1804 | * regmap_fields_read(): Read a value to a single register field with port ID | ||
| 1805 | * | ||
| 1806 | * @field: Register field to read from | ||
| 1807 | * @id: port ID | ||
| 1808 | * @val: Pointer to store read value | ||
| 1809 | * | ||
| 1810 | * A value of zero will be returned on success, a negative errno will | ||
| 1811 | * be returned in error cases. | ||
| 1812 | */ | ||
| 1813 | int regmap_fields_read(struct regmap_field *field, unsigned int id, | ||
| 1814 | unsigned int *val) | ||
| 1815 | { | ||
| 1816 | int ret; | ||
| 1817 | unsigned int reg_val; | ||
| 1818 | |||
| 1819 | if (id >= field->id_size) | ||
| 1820 | return -EINVAL; | ||
| 1821 | |||
| 1822 | ret = regmap_read(field->regmap, | ||
| 1823 | field->reg + (field->id_offset * id), | ||
| 1824 | ®_val); | ||
| 1825 | if (ret != 0) | ||
| 1826 | return ret; | ||
| 1827 | |||
| 1828 | reg_val &= field->mask; | ||
| 1829 | reg_val >>= field->shift; | ||
| 1830 | *val = reg_val; | ||
| 1831 | |||
| 1832 | return ret; | ||
| 1833 | } | ||
| 1834 | EXPORT_SYMBOL_GPL(regmap_fields_read); | ||
| 1835 | |||
| 1836 | /** | ||
| 1680 | * regmap_bulk_read(): Read multiple registers from the device | 1837 | * regmap_bulk_read(): Read multiple registers from the device |
| 1681 | * | 1838 | * |
| 1682 | * @map: Register map to write to | 1839 | * @map: Register map to write to |
| @@ -1788,6 +1945,41 @@ int regmap_update_bits(struct regmap *map, unsigned int reg, | |||
| 1788 | EXPORT_SYMBOL_GPL(regmap_update_bits); | 1945 | EXPORT_SYMBOL_GPL(regmap_update_bits); |
| 1789 | 1946 | ||
| 1790 | /** | 1947 | /** |
| 1948 | * regmap_update_bits_async: Perform a read/modify/write cycle on the register | ||
| 1949 | * map asynchronously | ||
| 1950 | * | ||
| 1951 | * @map: Register map to update | ||
| 1952 | * @reg: Register to update | ||
| 1953 | * @mask: Bitmask to change | ||
| 1954 | * @val: New value for bitmask | ||
| 1955 | * | ||
| 1956 | * With most buses the read must be done synchronously so this is most | ||
| 1957 | * useful for devices with a cache which do not need to interact with | ||
| 1958 | * the hardware to determine the current register value. | ||
| 1959 | * | ||
| 1960 | * Returns zero for success, a negative number on error. | ||
| 1961 | */ | ||
| 1962 | int regmap_update_bits_async(struct regmap *map, unsigned int reg, | ||
| 1963 | unsigned int mask, unsigned int val) | ||
| 1964 | { | ||
| 1965 | bool change; | ||
| 1966 | int ret; | ||
| 1967 | |||
| 1968 | map->lock(map->lock_arg); | ||
| 1969 | |||
| 1970 | map->async = true; | ||
| 1971 | |||
| 1972 | ret = _regmap_update_bits(map, reg, mask, val, &change); | ||
| 1973 | |||
| 1974 | map->async = false; | ||
| 1975 | |||
| 1976 | map->unlock(map->lock_arg); | ||
| 1977 | |||
| 1978 | return ret; | ||
| 1979 | } | ||
| 1980 | EXPORT_SYMBOL_GPL(regmap_update_bits_async); | ||
| 1981 | |||
| 1982 | /** | ||
| 1791 | * regmap_update_bits_check: Perform a read/modify/write cycle on the | 1983 | * regmap_update_bits_check: Perform a read/modify/write cycle on the |
| 1792 | * register map and report if updated | 1984 | * register map and report if updated |
| 1793 | * | 1985 | * |
| @@ -1812,6 +2004,43 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg, | |||
| 1812 | } | 2004 | } |
| 1813 | EXPORT_SYMBOL_GPL(regmap_update_bits_check); | 2005 | EXPORT_SYMBOL_GPL(regmap_update_bits_check); |
| 1814 | 2006 | ||
| 2007 | /** | ||
| 2008 | * regmap_update_bits_check_async: Perform a read/modify/write cycle on the | ||
| 2009 | * register map asynchronously and report if | ||
| 2010 | * updated | ||
| 2011 | * | ||
| 2012 | * @map: Register map to update | ||
| 2013 | * @reg: Register to update | ||
| 2014 | * @mask: Bitmask to change | ||
| 2015 | * @val: New value for bitmask | ||
| 2016 | * @change: Boolean indicating if a write was done | ||
| 2017 | * | ||
| 2018 | * With most buses the read must be done synchronously so this is most | ||
| 2019 | * useful for devices with a cache which do not need to interact with | ||
| 2020 | * the hardware to determine the current register value. | ||
| 2021 | * | ||
| 2022 | * Returns zero for success, a negative number on error. | ||
| 2023 | */ | ||
| 2024 | int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, | ||
| 2025 | unsigned int mask, unsigned int val, | ||
| 2026 | bool *change) | ||
| 2027 | { | ||
| 2028 | int ret; | ||
| 2029 | |||
| 2030 | map->lock(map->lock_arg); | ||
| 2031 | |||
| 2032 | map->async = true; | ||
| 2033 | |||
| 2034 | ret = _regmap_update_bits(map, reg, mask, val, change); | ||
| 2035 | |||
| 2036 | map->async = false; | ||
| 2037 | |||
| 2038 | map->unlock(map->lock_arg); | ||
| 2039 | |||
| 2040 | return ret; | ||
| 2041 | } | ||
| 2042 | EXPORT_SYMBOL_GPL(regmap_update_bits_check_async); | ||
| 2043 | |||
| 1815 | void regmap_async_complete_cb(struct regmap_async *async, int ret) | 2044 | void regmap_async_complete_cb(struct regmap_async *async, int ret) |
| 1816 | { | 2045 | { |
| 1817 | struct regmap *map = async->map; | 2046 | struct regmap *map = async->map; |
| @@ -1820,8 +2049,7 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret) | |||
| 1820 | trace_regmap_async_io_complete(map->dev); | 2049 | trace_regmap_async_io_complete(map->dev); |
| 1821 | 2050 | ||
| 1822 | spin_lock(&map->async_lock); | 2051 | spin_lock(&map->async_lock); |
| 1823 | 2052 | list_move(&async->list, &map->async_free); | |
| 1824 | list_del(&async->list); | ||
| 1825 | wake = list_empty(&map->async_list); | 2053 | wake = list_empty(&map->async_list); |
| 1826 | 2054 | ||
| 1827 | if (ret != 0) | 2055 | if (ret != 0) |
| @@ -1829,8 +2057,6 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret) | |||
| 1829 | 2057 | ||
| 1830 | spin_unlock(&map->async_lock); | 2058 | spin_unlock(&map->async_lock); |
| 1831 | 2059 | ||
| 1832 | schedule_work(&async->cleanup); | ||
| 1833 | |||
| 1834 | if (wake) | 2060 | if (wake) |
| 1835 | wake_up(&map->async_waitq); | 2061 | wake_up(&map->async_waitq); |
| 1836 | } | 2062 | } |
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index 2a9b100c4825..dbbf8ee3f592 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c | |||
| @@ -158,8 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val) | |||
| 158 | { | 158 | { |
| 159 | int ret; | 159 | int ret; |
| 160 | 160 | ||
| 161 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 162 | |||
| 163 | if (offset > MC13XXX_NUMREGS) | 161 | if (offset > MC13XXX_NUMREGS) |
| 164 | return -EINVAL; | 162 | return -EINVAL; |
| 165 | 163 | ||
| @@ -172,8 +170,6 @@ EXPORT_SYMBOL(mc13xxx_reg_read); | |||
| 172 | 170 | ||
| 173 | int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) | 171 | int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) |
| 174 | { | 172 | { |
| 175 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 176 | |||
| 177 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); | 173 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); |
| 178 | 174 | ||
| 179 | if (offset > MC13XXX_NUMREGS || val > 0xffffff) | 175 | if (offset > MC13XXX_NUMREGS || val > 0xffffff) |
| @@ -186,7 +182,6 @@ EXPORT_SYMBOL(mc13xxx_reg_write); | |||
| 186 | int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, | 182 | int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, |
| 187 | u32 mask, u32 val) | 183 | u32 mask, u32 val) |
| 188 | { | 184 | { |
| 189 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 190 | BUG_ON(val & ~mask); | 185 | BUG_ON(val & ~mask); |
| 191 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", | 186 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", |
| 192 | offset, val, mask); | 187 | offset, val, mask); |
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 77189daadf1e..5f14ef6693c2 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c | |||
| @@ -94,10 +94,15 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count) | |||
| 94 | { | 94 | { |
| 95 | struct device *dev = context; | 95 | struct device *dev = context; |
| 96 | struct spi_device *spi = to_spi_device(dev); | 96 | struct spi_device *spi = to_spi_device(dev); |
| 97 | const char *reg = data; | ||
| 97 | 98 | ||
| 98 | if (count != 4) | 99 | if (count != 4) |
| 99 | return -ENOTSUPP; | 100 | return -ENOTSUPP; |
| 100 | 101 | ||
| 102 | /* include errata fix for spi audio problems */ | ||
| 103 | if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC) | ||
| 104 | spi_write(spi, data, count); | ||
| 105 | |||
| 101 | return spi_write(spi, data, count); | 106 | return spi_write(spi, data, count); |
| 102 | } | 107 | } |
| 103 | 108 | ||
