regcache.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. #include <linux/bsearch.h>
  13. #include <linux/device.h>
  14. #include <linux/export.h>
  15. #include <linux/slab.h>
  16. #include <linux/sort.h>
  17. #include "trace.h"
  18. #include "internal.h"
  19. static const struct regcache_ops *cache_types[] = {
  20. &regcache_rbtree_ops,
  21. #if IS_ENABLED(CONFIG_REGCACHE_COMPRESSED)
  22. &regcache_lzo_ops,
  23. #endif
  24. &regcache_flat_ops,
  25. };
  26. static int regcache_hw_init(struct regmap *map)
  27. {
  28. int i, j;
  29. int ret;
  30. int count;
  31. unsigned int reg, val;
  32. void *tmp_buf;
  33. if (!map->num_reg_defaults_raw)
  34. return -EINVAL;
  35. /* calculate the size of reg_defaults */
  36. for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++)
  37. if (regmap_readable(map, i * map->reg_stride) &&
  38. !regmap_volatile(map, i * map->reg_stride))
  39. count++;
  40. /* all registers are unreadable or volatile, so just bypass */
  41. if (!count) {
  42. map->cache_bypass = true;
  43. return 0;
  44. }
  45. map->num_reg_defaults = count;
  46. map->reg_defaults = kmalloc_array(count, sizeof(struct reg_default),
  47. GFP_KERNEL);
  48. if (!map->reg_defaults)
  49. return -ENOMEM;
  50. if (!map->reg_defaults_raw) {
  51. bool cache_bypass = map->cache_bypass;
  52. dev_warn(map->dev, "No cache defaults, reading back from HW\n");
  53. /* Bypass the cache access till data read from HW */
  54. map->cache_bypass = true;
  55. tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL);
  56. if (!tmp_buf) {
  57. ret = -ENOMEM;
  58. goto err_free;
  59. }
  60. ret = regmap_raw_read(map, 0, tmp_buf,
  61. map->cache_size_raw);
  62. map->cache_bypass = cache_bypass;
  63. if (ret == 0) {
  64. map->reg_defaults_raw = tmp_buf;
  65. map->cache_free = 1;
  66. } else {
  67. kfree(tmp_buf);
  68. }
  69. }
  70. /* fill the reg_defaults */
  71. for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
  72. reg = i * map->reg_stride;
  73. if (!regmap_readable(map, reg))
  74. continue;
  75. if (regmap_volatile(map, reg))
  76. continue;
  77. if (map->reg_defaults_raw) {
  78. val = regcache_get_val(map, map->reg_defaults_raw, i);
  79. } else {
  80. bool cache_bypass = map->cache_bypass;
  81. map->cache_bypass = true;
  82. ret = regmap_read(map, reg, &val);
  83. map->cache_bypass = cache_bypass;
  84. if (ret != 0) {
  85. dev_err(map->dev, "Failed to read %d: %d\n",
  86. reg, ret);
  87. goto err_free;
  88. }
  89. }
  90. map->reg_defaults[j].reg = reg;
  91. map->reg_defaults[j].def = val;
  92. j++;
  93. }
  94. return 0;
  95. err_free:
  96. kfree(map->reg_defaults);
  97. return ret;
  98. }
  99. int regcache_init(struct regmap *map, const struct regmap_config *config)
  100. {
  101. int ret;
  102. int i;
  103. void *tmp_buf;
  104. if (map->cache_type == REGCACHE_NONE) {
  105. if (config->reg_defaults || config->num_reg_defaults_raw)
  106. dev_warn(map->dev,
  107. "No cache used with register defaults set!\n");
  108. map->cache_bypass = true;
  109. return 0;
  110. }
  111. if (config->reg_defaults && !config->num_reg_defaults) {
  112. dev_err(map->dev,
  113. "Register defaults are set without the number!\n");
  114. return -EINVAL;
  115. }
  116. for (i = 0; i < config->num_reg_defaults; i++)
  117. if (config->reg_defaults[i].reg % map->reg_stride)
  118. return -EINVAL;
  119. for (i = 0; i < ARRAY_SIZE(cache_types); i++)
  120. if (cache_types[i]->type == map->cache_type)
  121. break;
  122. if (i == ARRAY_SIZE(cache_types)) {
  123. dev_err(map->dev, "Could not match compress type: %d\n",
  124. map->cache_type);
  125. return -EINVAL;
  126. }
  127. map->num_reg_defaults = config->num_reg_defaults;
  128. map->num_reg_defaults_raw = config->num_reg_defaults_raw;
  129. map->reg_defaults_raw = config->reg_defaults_raw;
  130. map->cache_word_size = DIV_ROUND_UP(config->val_bits, 8);
  131. map->cache_size_raw = map->cache_word_size * config->num_reg_defaults_raw;
  132. map->cache = NULL;
  133. map->cache_ops = cache_types[i];
  134. if (!map->cache_ops->read ||
  135. !map->cache_ops->write ||
  136. !map->cache_ops->name)
  137. return -EINVAL;
  138. /* We still need to ensure that the reg_defaults
  139. * won't vanish from under us. We'll need to make
  140. * a copy of it.
  141. */
  142. if (config->reg_defaults) {
  143. tmp_buf = kmemdup(config->reg_defaults, map->num_reg_defaults *
  144. sizeof(struct reg_default), GFP_KERNEL);
  145. if (!tmp_buf)
  146. return -ENOMEM;
  147. map->reg_defaults = tmp_buf;
  148. } else if (map->num_reg_defaults_raw) {
  149. /* Some devices such as PMICs don't have cache defaults,
  150. * we cope with this by reading back the HW registers and
  151. * crafting the cache defaults by hand.
  152. */
  153. ret = regcache_hw_init(map);
  154. if (ret < 0)
  155. return ret;
  156. if (map->cache_bypass)
  157. return 0;
  158. }
  159. if (!map->max_register)
  160. map->max_register = map->num_reg_defaults_raw;
  161. if (map->cache_ops->init) {
  162. dev_dbg(map->dev, "Initializing %s cache\n",
  163. map->cache_ops->name);
  164. ret = map->cache_ops->init(map);
  165. if (ret)
  166. goto err_free;
  167. }
  168. return 0;
  169. err_free:
  170. kfree(map->reg_defaults);
  171. if (map->cache_free)
  172. kfree(map->reg_defaults_raw);
  173. return ret;
  174. }
  175. void regcache_exit(struct regmap *map)
  176. {
  177. if (map->cache_type == REGCACHE_NONE)
  178. return;
  179. BUG_ON(!map->cache_ops);
  180. kfree(map->reg_defaults);
  181. if (map->cache_free)
  182. kfree(map->reg_defaults_raw);
  183. if (map->cache_ops->exit) {
  184. dev_dbg(map->dev, "Destroying %s cache\n",
  185. map->cache_ops->name);
  186. map->cache_ops->exit(map);
  187. }
  188. }
  189. /**
  190. * regcache_read - Fetch the value of a given register from the cache.
  191. *
  192. * @map: map to configure.
  193. * @reg: The register index.
  194. * @value: The value to be returned.
  195. *
  196. * Return a negative value on failure, 0 on success.
  197. */
  198. int regcache_read(struct regmap *map,
  199. unsigned int reg, unsigned int *value)
  200. {
  201. int ret;
  202. if (map->cache_type == REGCACHE_NONE)
  203. return -ENOSYS;
  204. BUG_ON(!map->cache_ops);
  205. if (!regmap_volatile(map, reg)) {
  206. ret = map->cache_ops->read(map, reg, value);
  207. if (ret == 0)
  208. trace_regmap_reg_read_cache(map, reg, *value);
  209. return ret;
  210. }
  211. return -EINVAL;
  212. }
  213. /**
  214. * regcache_write - Set the value of a given register in the cache.
  215. *
  216. * @map: map to configure.
  217. * @reg: The register index.
  218. * @value: The new register value.
  219. *
  220. * Return a negative value on failure, 0 on success.
  221. */
  222. int regcache_write(struct regmap *map,
  223. unsigned int reg, unsigned int value)
  224. {
  225. if (map->cache_type == REGCACHE_NONE)
  226. return 0;
  227. BUG_ON(!map->cache_ops);
  228. if (!regmap_volatile(map, reg))
  229. return map->cache_ops->write(map, reg, value);
  230. return 0;
  231. }
  232. static bool regcache_reg_needs_sync(struct regmap *map, unsigned int reg,
  233. unsigned int val)
  234. {
  235. int ret;
  236. /* If we don't know the chip just got reset, then sync everything. */
  237. if (!map->no_sync_defaults)
  238. return true;
  239. /* Is this the hardware default? If so skip. */
  240. ret = regcache_lookup_reg(map, reg);
  241. if (ret >= 0 && val == map->reg_defaults[ret].def)
  242. return false;
  243. return true;
  244. }
  245. static int regcache_default_sync(struct regmap *map, unsigned int min,
  246. unsigned int max)
  247. {
  248. unsigned int reg;
  249. for (reg = min; reg <= max; reg += map->reg_stride) {
  250. unsigned int val;
  251. int ret;
  252. if (regmap_volatile(map, reg) ||
  253. !regmap_writeable(map, reg))
  254. continue;
  255. ret = regcache_read(map, reg, &val);
  256. if (ret)
  257. return ret;
  258. if (!regcache_reg_needs_sync(map, reg, val))
  259. continue;
  260. map->cache_bypass = true;
  261. ret = _regmap_write(map, reg, val);
  262. map->cache_bypass = false;
  263. if (ret) {
  264. dev_err(map->dev, "Unable to sync register %#x. %d\n",
  265. reg, ret);
  266. return ret;
  267. }
  268. dev_dbg(map->dev, "Synced register %#x, value %#x\n", reg, val);
  269. }
  270. return 0;
  271. }
  272. /**
  273. * regcache_sync - Sync the register cache with the hardware.
  274. *
  275. * @map: map to configure.
  276. *
  277. * Any registers that should not be synced should be marked as
  278. * volatile. In general drivers can choose not to use the provided
  279. * syncing functionality if they so require.
  280. *
  281. * Return a negative value on failure, 0 on success.
  282. */
  283. int regcache_sync(struct regmap *map)
  284. {
  285. int ret = 0;
  286. unsigned int i;
  287. const char *name;
  288. bool bypass;
  289. BUG_ON(!map->cache_ops);
  290. map->lock(map->lock_arg);
  291. /* Remember the initial bypass state */
  292. bypass = map->cache_bypass;
  293. dev_dbg(map->dev, "Syncing %s cache\n",
  294. map->cache_ops->name);
  295. name = map->cache_ops->name;
  296. trace_regcache_sync(map, name, "start");
  297. if (!map->cache_dirty)
  298. goto out;
  299. map->async = true;
  300. /* Apply any patch first */
  301. map->cache_bypass = true;
  302. for (i = 0; i < map->patch_regs; i++) {
  303. ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
  304. if (ret != 0) {
  305. dev_err(map->dev, "Failed to write %x = %x: %d\n",
  306. map->patch[i].reg, map->patch[i].def, ret);
  307. goto out;
  308. }
  309. }
  310. map->cache_bypass = false;
  311. if (map->cache_ops->sync)
  312. ret = map->cache_ops->sync(map, 0, map->max_register);
  313. else
  314. ret = regcache_default_sync(map, 0, map->max_register);
  315. if (ret == 0)
  316. map->cache_dirty = false;
  317. out:
  318. /* Restore the bypass state */
  319. map->async = false;
  320. map->cache_bypass = bypass;
  321. map->no_sync_defaults = false;
  322. map->unlock(map->lock_arg);
  323. regmap_async_complete(map);
  324. trace_regcache_sync(map, name, "stop");
  325. return ret;
  326. }
  327. EXPORT_SYMBOL_GPL(regcache_sync);
  328. /**
  329. * regcache_sync_region - Sync part of the register cache with the hardware.
  330. *
  331. * @map: map to sync.
  332. * @min: first register to sync
  333. * @max: last register to sync
  334. *
  335. * Write all non-default register values in the specified region to
  336. * the hardware.
  337. *
  338. * Return a negative value on failure, 0 on success.
  339. */
  340. int regcache_sync_region(struct regmap *map, unsigned int min,
  341. unsigned int max)
  342. {
  343. int ret = 0;
  344. const char *name;
  345. bool bypass;
  346. BUG_ON(!map->cache_ops);
  347. map->lock(map->lock_arg);
  348. /* Remember the initial bypass state */
  349. bypass = map->cache_bypass;
  350. name = map->cache_ops->name;
  351. dev_dbg(map->dev, "Syncing %s cache from %d-%d\n", name, min, max);
  352. trace_regcache_sync(map, name, "start region");
  353. if (!map->cache_dirty)
  354. goto out;
  355. map->async = true;
  356. if (map->cache_ops->sync)
  357. ret = map->cache_ops->sync(map, min, max);
  358. else
  359. ret = regcache_default_sync(map, min, max);
  360. out:
  361. /* Restore the bypass state */
  362. map->cache_bypass = bypass;
  363. map->async = false;
  364. map->no_sync_defaults = false;
  365. map->unlock(map->lock_arg);
  366. regmap_async_complete(map);
  367. trace_regcache_sync(map, name, "stop region");
  368. return ret;
  369. }
  370. EXPORT_SYMBOL_GPL(regcache_sync_region);
  371. /**
  372. * regcache_drop_region - Discard part of the register cache
  373. *
  374. * @map: map to operate on
  375. * @min: first register to discard
  376. * @max: last register to discard
  377. *
  378. * Discard part of the register cache.
  379. *
  380. * Return a negative value on failure, 0 on success.
  381. */
  382. int regcache_drop_region(struct regmap *map, unsigned int min,
  383. unsigned int max)
  384. {
  385. int ret = 0;
  386. if (!map->cache_ops || !map->cache_ops->drop)
  387. return -EINVAL;
  388. map->lock(map->lock_arg);
  389. trace_regcache_drop_region(map, min, max);
  390. ret = map->cache_ops->drop(map, min, max);
  391. map->unlock(map->lock_arg);
  392. return ret;
  393. }
  394. EXPORT_SYMBOL_GPL(regcache_drop_region);
  395. /**
  396. * regcache_cache_only - Put a register map into cache only mode
  397. *
  398. * @map: map to configure
  399. * @enable: flag if changes should be written to the hardware
  400. *
  401. * When a register map is marked as cache only writes to the register
  402. * map API will only update the register cache, they will not cause
  403. * any hardware changes. This is useful for allowing portions of
  404. * drivers to act as though the device were functioning as normal when
  405. * it is disabled for power saving reasons.
  406. */
  407. void regcache_cache_only(struct regmap *map, bool enable)
  408. {
  409. map->lock(map->lock_arg);
  410. WARN_ON(map->cache_bypass && enable);
  411. map->cache_only = enable;
  412. trace_regmap_cache_only(map, enable);
  413. map->unlock(map->lock_arg);
  414. }
  415. EXPORT_SYMBOL_GPL(regcache_cache_only);
  416. /**
  417. * regcache_mark_dirty - Indicate that HW registers were reset to default values
  418. *
  419. * @map: map to mark
  420. *
  421. * Inform regcache that the device has been powered down or reset, so that
  422. * on resume, regcache_sync() knows to write out all non-default values
  423. * stored in the cache.
  424. *
  425. * If this function is not called, regcache_sync() will assume that
  426. * the hardware state still matches the cache state, modulo any writes that
  427. * happened when cache_only was true.
  428. */
  429. void regcache_mark_dirty(struct regmap *map)
  430. {
  431. map->lock(map->lock_arg);
  432. map->cache_dirty = true;
  433. map->no_sync_defaults = true;
  434. map->unlock(map->lock_arg);
  435. }
  436. EXPORT_SYMBOL_GPL(regcache_mark_dirty);
  437. /**
  438. * regcache_cache_bypass - Put a register map into cache bypass mode
  439. *
  440. * @map: map to configure
  441. * @enable: flag if changes should not be written to the cache
  442. *
  443. * When a register map is marked with the cache bypass option, writes
  444. * to the register map API will only update the hardware and not the
  445. * the cache directly. This is useful when syncing the cache back to
  446. * the hardware.
  447. */
  448. void regcache_cache_bypass(struct regmap *map, bool enable)
  449. {
  450. map->lock(map->lock_arg);
  451. WARN_ON(map->cache_only && enable);
  452. map->cache_bypass = enable;
  453. trace_regmap_cache_bypass(map, enable);
  454. map->unlock(map->lock_arg);
  455. }
  456. EXPORT_SYMBOL_GPL(regcache_cache_bypass);
  457. bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
  458. unsigned int val)
  459. {
  460. if (regcache_get_val(map, base, idx) == val)
  461. return true;
  462. /* Use device native format if possible */
  463. if (map->format.format_val) {
  464. map->format.format_val(base + (map->cache_word_size * idx),
  465. val, 0);
  466. return false;
  467. }
  468. switch (map->cache_word_size) {
  469. case 1: {
  470. u8 *cache = base;
  471. cache[idx] = val;
  472. break;
  473. }
  474. case 2: {
  475. u16 *cache = base;
  476. cache[idx] = val;
  477. break;
  478. }
  479. case 4: {
  480. u32 *cache = base;
  481. cache[idx] = val;
  482. break;
  483. }
  484. #ifdef CONFIG_64BIT
  485. case 8: {
  486. u64 *cache = base;
  487. cache[idx] = val;
  488. break;
  489. }
  490. #endif
  491. default:
  492. BUG();
  493. }
  494. return false;
  495. }
  496. unsigned int regcache_get_val(struct regmap *map, const void *base,
  497. unsigned int idx)
  498. {
  499. if (!base)
  500. return -EINVAL;
  501. /* Use device native format if possible */
  502. if (map->format.parse_val)
  503. return map->format.parse_val(regcache_get_val_addr(map, base,
  504. idx));
  505. switch (map->cache_word_size) {
  506. case 1: {
  507. const u8 *cache = base;
  508. return cache[idx];
  509. }
  510. case 2: {
  511. const u16 *cache = base;
  512. return cache[idx];
  513. }
  514. case 4: {
  515. const u32 *cache = base;
  516. return cache[idx];
  517. }
  518. #ifdef CONFIG_64BIT
  519. case 8: {
  520. const u64 *cache = base;
  521. return cache[idx];
  522. }
  523. #endif
  524. default:
  525. BUG();
  526. }
  527. /* unreachable */
  528. return -1;
  529. }
  530. static int regcache_default_cmp(const void *a, const void *b)
  531. {
  532. const struct reg_default *_a = a;
  533. const struct reg_default *_b = b;
  534. return _a->reg - _b->reg;
  535. }
  536. int regcache_lookup_reg(struct regmap *map, unsigned int reg)
  537. {
  538. struct reg_default key;
  539. struct reg_default *r;
  540. key.reg = reg;
  541. key.def = 0;
  542. r = bsearch(&key, map->reg_defaults, map->num_reg_defaults,
  543. sizeof(struct reg_default), regcache_default_cmp);
  544. if (r)
  545. return r - map->reg_defaults;
  546. else
  547. return -ENOENT;
  548. }
  549. static bool regcache_reg_present(unsigned long *cache_present, unsigned int idx)
  550. {
  551. if (!cache_present)
  552. return true;
  553. return test_bit(idx, cache_present);
  554. }
  555. static int regcache_sync_block_single(struct regmap *map, void *block,
  556. unsigned long *cache_present,
  557. unsigned int block_base,
  558. unsigned int start, unsigned int end)
  559. {
  560. unsigned int i, regtmp, val;
  561. int ret;
  562. for (i = start; i < end; i++) {
  563. regtmp = block_base + (i * map->reg_stride);
  564. if (!regcache_reg_present(cache_present, i) ||
  565. !regmap_writeable(map, regtmp))
  566. continue;
  567. val = regcache_get_val(map, block, i);
  568. if (!regcache_reg_needs_sync(map, regtmp, val))
  569. continue;
  570. map->cache_bypass = true;
  571. ret = _regmap_write(map, regtmp, val);
  572. map->cache_bypass = false;
  573. if (ret != 0) {
  574. dev_err(map->dev, "Unable to sync register %#x. %d\n",
  575. regtmp, ret);
  576. return ret;
  577. }
  578. dev_dbg(map->dev, "Synced register %#x, value %#x\n",
  579. regtmp, val);
  580. }
  581. return 0;
  582. }
  583. static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
  584. unsigned int base, unsigned int cur)
  585. {
  586. size_t val_bytes = map->format.val_bytes;
  587. int ret, count;
  588. if (*data == NULL)
  589. return 0;
  590. count = (cur - base) / map->reg_stride;
  591. dev_dbg(map->dev, "Writing %zu bytes for %d registers from 0x%x-0x%x\n",
  592. count * val_bytes, count, base, cur - map->reg_stride);
  593. map->cache_bypass = true;
  594. ret = _regmap_raw_write(map, base, *data, count * val_bytes);
  595. if (ret)
  596. dev_err(map->dev, "Unable to sync registers %#x-%#x. %d\n",
  597. base, cur - map->reg_stride, ret);
  598. map->cache_bypass = false;
  599. *data = NULL;
  600. return ret;
  601. }
  602. static int regcache_sync_block_raw(struct regmap *map, void *block,
  603. unsigned long *cache_present,
  604. unsigned int block_base, unsigned int start,
  605. unsigned int end)
  606. {
  607. unsigned int i, val;
  608. unsigned int regtmp = 0;
  609. unsigned int base = 0;
  610. const void *data = NULL;
  611. int ret;
  612. for (i = start; i < end; i++) {
  613. regtmp = block_base + (i * map->reg_stride);
  614. if (!regcache_reg_present(cache_present, i) ||
  615. !regmap_writeable(map, regtmp)) {
  616. ret = regcache_sync_block_raw_flush(map, &data,
  617. base, regtmp);
  618. if (ret != 0)
  619. return ret;
  620. continue;
  621. }
  622. val = regcache_get_val(map, block, i);
  623. if (!regcache_reg_needs_sync(map, regtmp, val)) {
  624. ret = regcache_sync_block_raw_flush(map, &data,
  625. base, regtmp);
  626. if (ret != 0)
  627. return ret;
  628. continue;
  629. }
  630. if (!data) {
  631. data = regcache_get_val_addr(map, block, i);
  632. base = regtmp;
  633. }
  634. }
  635. return regcache_sync_block_raw_flush(map, &data, base, regtmp +
  636. map->reg_stride);
  637. }
  638. int regcache_sync_block(struct regmap *map, void *block,
  639. unsigned long *cache_present,
  640. unsigned int block_base, unsigned int start,
  641. unsigned int end)
  642. {
  643. if (regmap_can_raw_write(map) && !map->use_single_write)
  644. return regcache_sync_block_raw(map, block, cache_present,
  645. block_base, start, end);
  646. else
  647. return regcache_sync_block_single(map, block, cache_present,
  648. block_base, start, end);
  649. }