regcache.c 17 KB

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