cam_soc_util.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_SOC_UTIL_H_
  6. #define _CAM_SOC_UTIL_H_
  7. #include <linux/slab.h>
  8. #include <linux/clk.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/io.h>
  11. #include <linux/delay.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/i2c.h>
  14. #include <linux/regulator/consumer.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/of_fdt.h>
  17. #include "cam_io_util.h"
  18. #define NO_SET_RATE -1
  19. #define INIT_RATE -2
  20. /* maximum number of device block */
  21. #define CAM_SOC_MAX_BLOCK 7
  22. /* maximum number of device base */
  23. #define CAM_SOC_MAX_BASE CAM_SOC_MAX_BLOCK
  24. /* maximum number of device regulator */
  25. #define CAM_SOC_MAX_REGULATOR 5
  26. /* maximum number of device clock */
  27. #define CAM_SOC_MAX_CLK 32
  28. /* DDR device types */
  29. #define DDR_TYPE_LPDDR4 6
  30. #define DDR_TYPE_LPDDR4X 7
  31. #define DDR_TYPE_LPDDR5 8
  32. #define DDR_TYPE_LPDDR5X 9
  33. /**
  34. * enum cam_vote_level - Enum for voting level
  35. *
  36. * @CAM_SUSPEND_VOTE : Suspend vote
  37. * @CAM_MINSVS_VOTE : Min SVS vote
  38. * @CAM_LOWSVS_VOTE : Low SVS vote
  39. * @CAM_SVS_VOTE : SVS vote
  40. * @CAM_SVSL1_VOTE : SVS Plus vote
  41. * @CAM_NOMINAL_VOTE : Nominal vote
  42. * @CAM_NOMINALL1_VOTE: Nominal plus vote
  43. * @CAM_TURBO_VOTE : Turbo vote
  44. * @CAM_MAX_VOTE : Max voting level, This is invalid level.
  45. */
  46. enum cam_vote_level {
  47. CAM_SUSPEND_VOTE,
  48. CAM_MINSVS_VOTE,
  49. CAM_LOWSVS_VOTE,
  50. CAM_SVS_VOTE,
  51. CAM_SVSL1_VOTE,
  52. CAM_NOMINAL_VOTE,
  53. CAM_NOMINALL1_VOTE,
  54. CAM_TURBO_VOTE,
  55. CAM_MAX_VOTE,
  56. };
  57. /* pinctrl states */
  58. #define CAM_SOC_PINCTRL_STATE_SLEEP "cam_suspend"
  59. #define CAM_SOC_PINCTRL_STATE_DEFAULT "cam_default"
  60. /**
  61. * struct cam_soc_reg_map: Information about the mapped register space
  62. *
  63. * @mem_base: Starting location of MAPPED register space
  64. * @mem_cam_base: Starting offset of this register space compared
  65. * to ENTIRE Camera register space
  66. * @size: Size of register space
  67. **/
  68. struct cam_soc_reg_map {
  69. void __iomem *mem_base;
  70. uint32_t mem_cam_base;
  71. resource_size_t size;
  72. };
  73. /**
  74. * struct cam_soc_pinctrl_info: Information about pinctrl data
  75. *
  76. * @pinctrl: pintrl object
  77. * @gpio_state_active: default pinctrl state
  78. * @gpio_state_suspend suspend state of pinctrl
  79. **/
  80. struct cam_soc_pinctrl_info {
  81. struct pinctrl *pinctrl;
  82. struct pinctrl_state *gpio_state_active;
  83. struct pinctrl_state *gpio_state_suspend;
  84. };
  85. /**
  86. * struct cam_soc_gpio_data: Information about the gpio pins
  87. *
  88. * @cam_gpio_common_tbl: It is list of al the gpios present in gpios node
  89. * @cam_gpio_common_tbl_size: It is equal to number of gpios prsent in
  90. * gpios node in DTSI
  91. * @cam_gpio_req_tbl It is list of al the requesetd gpios
  92. * @cam_gpio_req_tbl_size: It is size of requested gpios
  93. **/
  94. struct cam_soc_gpio_data {
  95. struct gpio *cam_gpio_common_tbl;
  96. uint8_t cam_gpio_common_tbl_size;
  97. struct gpio *cam_gpio_req_tbl;
  98. uint8_t cam_gpio_req_tbl_size;
  99. };
  100. /**
  101. * struct cam_hw_soc_info: Soc information pertaining to specific instance of
  102. * Camera hardware driver module
  103. *
  104. * @pdev: Platform device pointer
  105. * @device: Device pointer
  106. * @hw_version: Camera device version
  107. * @index: Instance id for the camera device
  108. * @dev_name: Device Name
  109. * @irq_name: Name of the irq associated with the device
  110. * @irq_line: Irq resource
  111. * @irq_data: Private data that is passed when IRQ is requested
  112. * @compatible: Compatible string associated with the device
  113. * @num_mem_block: Number of entry in the "reg-names"
  114. * @mem_block_name: Array of the reg block name
  115. * @mem_block_cam_base: Array of offset of this register space compared
  116. * to ENTIRE Camera register space
  117. * @mem_block: Associated resource structs
  118. * @reg_map: Array of Mapped register info for the "reg-names"
  119. * @num_reg_map: Number of mapped register space associated
  120. * with mem_block. num_reg_map = num_mem_block in
  121. * most cases
  122. * @reserve_mem: Whether to reserve memory for Mem blocks
  123. * @num_rgltr: Number of regulators
  124. * @rgltr_name: Array of regulator names
  125. * @rgltr_ctrl_support: Whether regulator control is supported
  126. * @rgltr_min_volt: Array of minimum regulator voltage
  127. * @rgltr_max_volt: Array of maximum regulator voltage
  128. * @rgltr_op_mode: Array of regulator operation mode
  129. * @rgltr_type: Array of regulator names
  130. * @rgltr: Array of associated regulator resources
  131. * @rgltr_delay: Array of regulator delay values
  132. * @num_clk: Number of clocks
  133. * @clk_name: Array of clock names
  134. * @clk: Array of associated clock resources
  135. * @clk_rate: 2D array of clock rates representing clock rate
  136. * values at different vote levels
  137. * @prev_clk_level Last vote level
  138. * @src_clk_idx: Source clock index that is rate-controllable
  139. * @clk_level_valid: Indicates whether corresponding level is valid
  140. * @scl_clk_count: Number of scalable clocks present
  141. * @scl_clk_idx: Index of scalable clocks
  142. * @gpio_data: Pointer to gpio info
  143. * @pinctrl_info: Pointer to pinctrl info
  144. * @dentry: Debugfs entry
  145. * @clk_level_override: Clk level set from debugfs
  146. * @clk_control: Enable/disable clk rate control through debugfs
  147. * @cam_cx_ipeak_enable cx-ipeak enable/disable flag
  148. * @cam_cx_ipeak_bit cx-ipeak mask for driver
  149. * @soc_private: Soc private data
  150. */
  151. struct cam_hw_soc_info {
  152. struct platform_device *pdev;
  153. struct device *dev;
  154. uint32_t hw_version;
  155. uint32_t index;
  156. const char *dev_name;
  157. const char *irq_name;
  158. struct resource *irq_line;
  159. void *irq_data;
  160. const char *compatible;
  161. uint32_t num_mem_block;
  162. const char *mem_block_name[CAM_SOC_MAX_BLOCK];
  163. uint32_t mem_block_cam_base[CAM_SOC_MAX_BLOCK];
  164. struct resource *mem_block[CAM_SOC_MAX_BLOCK];
  165. struct cam_soc_reg_map reg_map[CAM_SOC_MAX_BASE];
  166. uint32_t num_reg_map;
  167. uint32_t reserve_mem;
  168. uint32_t num_rgltr;
  169. const char *rgltr_name[CAM_SOC_MAX_REGULATOR];
  170. uint32_t rgltr_ctrl_support;
  171. uint32_t rgltr_min_volt[CAM_SOC_MAX_REGULATOR];
  172. uint32_t rgltr_max_volt[CAM_SOC_MAX_REGULATOR];
  173. uint32_t rgltr_op_mode[CAM_SOC_MAX_REGULATOR];
  174. uint32_t rgltr_type[CAM_SOC_MAX_REGULATOR];
  175. struct regulator *rgltr[CAM_SOC_MAX_REGULATOR];
  176. uint32_t rgltr_delay[CAM_SOC_MAX_REGULATOR];
  177. uint32_t use_shared_clk;
  178. uint32_t num_clk;
  179. const char *clk_name[CAM_SOC_MAX_CLK];
  180. struct clk *clk[CAM_SOC_MAX_CLK];
  181. int32_t clk_rate[CAM_MAX_VOTE][CAM_SOC_MAX_CLK];
  182. int32_t prev_clk_level;
  183. int32_t src_clk_idx;
  184. bool clk_level_valid[CAM_MAX_VOTE];
  185. int32_t scl_clk_count;
  186. int32_t scl_clk_idx[CAM_SOC_MAX_CLK];
  187. struct cam_soc_gpio_data *gpio_data;
  188. struct cam_soc_pinctrl_info pinctrl_info;
  189. struct dentry *dentry;
  190. uint32_t clk_level_override;
  191. bool clk_control_enable;
  192. bool cam_cx_ipeak_enable;
  193. int32_t cam_cx_ipeak_bit;
  194. void *soc_private;
  195. };
  196. /*
  197. * CAM_SOC_GET_REG_MAP_START
  198. *
  199. * @brief: This MACRO will get the mapped starting address
  200. * where the register space can be accessed
  201. *
  202. * @__soc_info: Device soc information
  203. * @__base_index: Index of register space in the HW block
  204. *
  205. * @return: Returns a pointer to the mapped register memory
  206. */
  207. #define CAM_SOC_GET_REG_MAP_START(__soc_info, __base_index) \
  208. ((!__soc_info || __base_index >= __soc_info->num_reg_map) ? \
  209. NULL : __soc_info->reg_map[__base_index].mem_base)
  210. /*
  211. * CAM_SOC_GET_REG_MAP_CAM_BASE
  212. *
  213. * @brief: This MACRO will get the cam_base of the
  214. * register space
  215. *
  216. * @__soc_info: Device soc information
  217. * @__base_index: Index of register space in the HW block
  218. *
  219. * @return: Returns an int32_t value.
  220. * Failure: -1
  221. * Success: Starting offset of register space compared
  222. * to entire Camera Register Map
  223. */
  224. #define CAM_SOC_GET_REG_MAP_CAM_BASE(__soc_info, __base_index) \
  225. ((!__soc_info || __base_index >= __soc_info->num_reg_map) ? \
  226. -1 : __soc_info->reg_map[__base_index].mem_cam_base)
  227. /*
  228. * CAM_SOC_GET_REG_MAP_SIZE
  229. *
  230. * @brief: This MACRO will get the size of the mapped
  231. * register space
  232. *
  233. * @__soc_info: Device soc information
  234. * @__base_index: Index of register space in the HW block
  235. *
  236. * @return: Returns a uint32_t value.
  237. * Failure: 0
  238. * Success: Non-zero size of mapped register space
  239. */
  240. #define CAM_SOC_GET_REG_MAP_SIZE(__soc_info, __base_index) \
  241. ((!__soc_info || __base_index >= __soc_info->num_reg_map) ? \
  242. 0 : __soc_info->reg_map[__base_index].size)
  243. /**
  244. * cam_soc_util_get_level_from_string()
  245. *
  246. * @brief: Get the associated vote level for the input string
  247. *
  248. * @string: Input string to compare with.
  249. * @level: Vote level corresponds to input string.
  250. *
  251. * @return: Success or failure
  252. */
  253. int cam_soc_util_get_level_from_string(const char *string,
  254. enum cam_vote_level *level);
  255. /**
  256. * cam_soc_util_get_dt_properties()
  257. *
  258. * @brief: Parse the DT and populate the common properties that
  259. * are part of the soc_info structure - register map,
  260. * clocks, regulators, irq, etc.
  261. *
  262. * @soc_info: Device soc struct to be populated
  263. *
  264. * @return: Success or failure
  265. */
  266. int cam_soc_util_get_dt_properties(struct cam_hw_soc_info *soc_info);
  267. /**
  268. * cam_soc_util_request_platform_resource()
  269. *
  270. * @brief: Request regulator, irq, and clock resources
  271. *
  272. * @soc_info: Device soc information
  273. * @handler: Irq handler function pointer
  274. * @irq_data: Irq handler function CB data
  275. *
  276. * @return: Success or failure
  277. */
  278. int cam_soc_util_request_platform_resource(struct cam_hw_soc_info *soc_info,
  279. irq_handler_t handler, void *irq_data);
  280. /**
  281. * cam_soc_util_release_platform_resource()
  282. *
  283. * @brief: Release regulator, irq, and clock resources
  284. *
  285. * @soc_info: Device soc information
  286. *
  287. * @return: Success or failure
  288. */
  289. int cam_soc_util_release_platform_resource(struct cam_hw_soc_info *soc_info);
  290. /**
  291. * cam_soc_util_enable_platform_resource()
  292. *
  293. * @brief: Enable regulator, irq resources
  294. *
  295. * @soc_info: Device soc information
  296. * @enable_clocks: Boolean flag:
  297. * TRUE: Enable all clocks in soc_info Now.
  298. * False: Don't enable clocks Now. Driver will
  299. * enable independently.
  300. * @clk_level: Clock level to be applied.
  301. * Applicable only if enable_clocks is true
  302. * Valid range : 0 to (CAM_MAX_VOTE - 1)
  303. * @enable_irq: Boolean flag:
  304. * TRUE: Enable IRQ in soc_info Now.
  305. * False: Don't enable IRQ Now. Driver will
  306. * enable independently.
  307. *
  308. * @return: Success or failure
  309. */
  310. int cam_soc_util_enable_platform_resource(struct cam_hw_soc_info *soc_info,
  311. bool enable_clocks, enum cam_vote_level clk_level, bool enable_irq);
  312. /**
  313. * cam_soc_util_disable_platform_resource()
  314. *
  315. * @brief: Disable regulator, irq resources
  316. *
  317. * @soc_info: Device soc information
  318. * @disable_irq: Boolean flag:
  319. * TRUE: Disable IRQ in soc_info Now.
  320. * False: Don't disable IRQ Now. Driver will
  321. * disable independently.
  322. *
  323. * @return: Success or failure
  324. */
  325. int cam_soc_util_disable_platform_resource(struct cam_hw_soc_info *soc_info,
  326. bool disable_clocks, bool disable_irq);
  327. /**
  328. * cam_soc_util_get_clk_round_rate()
  329. *
  330. * @brief: Get the rounded clock rate for the given clock's
  331. * clock rate value
  332. *
  333. * @soc_info: Device soc information
  334. * @clk_index: Clock index in soc_info for which round rate is needed
  335. * @clk_rate: Input clock rate for which rounded rate is needed
  336. *
  337. * @return: Rounded clock rate
  338. */
  339. long cam_soc_util_get_clk_round_rate(struct cam_hw_soc_info *soc_info,
  340. uint32_t clk_index, unsigned long clk_rate);
  341. /**
  342. * cam_soc_util_set_clk_flags()
  343. *
  344. * @brief: Camera SOC util to set the flags for a specified clock
  345. *
  346. * @soc_info: Device soc information
  347. * @clk_index: Clock index in soc_info for which flags are to be set
  348. * @flags: Flags to set
  349. *
  350. * @return: Success or Failure
  351. */
  352. int cam_soc_util_set_clk_flags(struct cam_hw_soc_info *soc_info,
  353. uint32_t clk_index, unsigned long flags);
  354. /**
  355. * cam_soc_util_set_src_clk_rate()
  356. *
  357. * @brief: Set the rate on the source clock.
  358. *
  359. * @soc_info: Device soc information
  360. * @clk_rate: Clock rate associated with the src clk
  361. *
  362. * @return: success or failure
  363. */
  364. int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
  365. int32_t clk_rate);
  366. /**
  367. * cam_soc_util_get_option_clk_by_name()
  368. *
  369. * @brief: Get reference to optional clk using name
  370. *
  371. * @soc_info: Device soc information
  372. * @clk_name: Name of clock to find reference for
  373. * @clk: Clock reference pointer to be filled if Success
  374. * @clk_index: Clk index in the option clk array to be returned
  375. * @clk_rate: Clk rate in the option clk array
  376. *
  377. * @return: 0: Success
  378. * Negative: Failure
  379. */
  380. int cam_soc_util_get_option_clk_by_name(struct cam_hw_soc_info *soc_info,
  381. const char *clk_name, struct clk **clk, int32_t *clk_index,
  382. int32_t *clk_rate);
  383. /**
  384. * cam_soc_util_clk_put()
  385. *
  386. * @brief: Put clock specified in params
  387. *
  388. * @clk: Reference to the Clock that needs to be put
  389. *
  390. * @return: Success or failure
  391. */
  392. int cam_soc_util_clk_put(struct clk **clk);
  393. /**
  394. * cam_soc_util_clk_enable()
  395. *
  396. * @brief: Enable clock specified in params
  397. *
  398. * @clk: Clock that needs to be turned ON
  399. * @clk_name: Clocks name associated with clk
  400. * @clk_rate: Clocks rate associated with clk
  401. *
  402. * @return: Success or failure
  403. */
  404. int cam_soc_util_clk_enable(struct clk *clk, const char *clk_name,
  405. int32_t clk_rate);
  406. /**
  407. * cam_soc_util_set_clk_rate_level()
  408. *
  409. * @brief: Apply clock rates for the requested level.
  410. * This applies the new requested level for all
  411. * the clocks listed in DT based on their values.
  412. *
  413. * @soc_info: Device soc information
  414. * @clk_level: Clock level number to set
  415. *
  416. * @return: Success or failure
  417. */
  418. int cam_soc_util_set_clk_rate_level(struct cam_hw_soc_info *soc_info,
  419. enum cam_vote_level clk_level);
  420. /**
  421. * cam_soc_util_clk_disable()
  422. *
  423. * @brief: Disable clock specified in params
  424. *
  425. * @clk: Clock that needs to be turned OFF
  426. * @clk_name: Clocks name associated with clk
  427. *
  428. * @return: Success or failure
  429. */
  430. int cam_soc_util_clk_disable(struct clk *clk, const char *clk_name);
  431. /**
  432. * cam_soc_util_irq_enable()
  433. *
  434. * @brief: Enable IRQ in SOC
  435. *
  436. * @soc_info: Device soc information
  437. *
  438. * @return: Success or failure
  439. */
  440. int cam_soc_util_irq_enable(struct cam_hw_soc_info *soc_info);
  441. /**
  442. * cam_soc_util_irq_disable()
  443. *
  444. * @brief: Disable IRQ in SOC
  445. *
  446. * @soc_info: Device soc information
  447. *
  448. * @return: Success or failure
  449. */
  450. int cam_soc_util_irq_disable(struct cam_hw_soc_info *soc_info);
  451. /**
  452. * cam_soc_util_regulator_enable()
  453. *
  454. * @brief: Enable single regulator
  455. *
  456. * @rgltr Regulator that needs to be turned ON
  457. * @rgltr_name Associated Regulator name
  458. * @rgltr_min_volt: Requested minimum volatage
  459. * @rgltr_max_volt: Requested maximum volatage
  460. * @rgltr_op_mode: Requested Load
  461. * @rgltr_delay: Requested delay needed aaftre enabling regulator
  462. *
  463. * @return: Success or failure
  464. */
  465. int cam_soc_util_regulator_enable(struct regulator *rgltr,
  466. const char *rgltr_name,
  467. uint32_t rgltr_min_volt, uint32_t rgltr_max_volt,
  468. uint32_t rgltr_op_mode, uint32_t rgltr_delay);
  469. /**
  470. * cam_soc_util_regulator_enable()
  471. *
  472. * @brief: Disable single regulator
  473. *
  474. * @rgltr Regulator that needs to be turned ON
  475. * @rgltr_name Associated Regulator name
  476. * @rgltr_min_volt: Requested minimum volatage
  477. * @rgltr_max_volt: Requested maximum volatage
  478. * @rgltr_op_mode: Requested Load
  479. * @rgltr_delay: Requested delay needed aaftre enabling regulator
  480. *
  481. * @return: Success or failure
  482. */
  483. int cam_soc_util_regulator_disable(struct regulator *rgltr,
  484. const char *rgltr_name,
  485. uint32_t rgltr_min_volt, uint32_t rgltr_max_volt,
  486. uint32_t rgltr_op_mode, uint32_t rgltr_delay);
  487. /**
  488. * cam_soc_util_w()
  489. *
  490. * @brief: Camera SOC util for register write
  491. *
  492. * @soc_info: Device soc information
  493. * @base_index: Index of register space in the HW block
  494. * @offset: Offset of register to be read
  495. * @data: Value to be written
  496. *
  497. * @return: Success or Failure
  498. */
  499. static inline int cam_soc_util_w(struct cam_hw_soc_info *soc_info,
  500. uint32_t base_index, uint32_t offset, uint32_t data)
  501. {
  502. if (!CAM_SOC_GET_REG_MAP_START(soc_info, base_index))
  503. return -EINVAL;
  504. return cam_io_w(data,
  505. CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
  506. }
  507. /**
  508. * cam_soc_util_w_mb()
  509. *
  510. * @brief: Camera SOC util for register write with memory barrier.
  511. * Memory Barrier is only before the write to ensure the
  512. * order. If need to ensure this write is also flushed
  513. * call wmb() independently in the caller.
  514. *
  515. * @soc_info: Device soc information
  516. * @base_index: Index of register space in the HW block
  517. * @offset: Offset of register to be read
  518. * @data: Value to be written
  519. *
  520. * @return: Success or Failure
  521. */
  522. static inline int cam_soc_util_w_mb(struct cam_hw_soc_info *soc_info,
  523. uint32_t base_index, uint32_t offset, uint32_t data)
  524. {
  525. if (!CAM_SOC_GET_REG_MAP_START(soc_info, base_index))
  526. return -EINVAL;
  527. return cam_io_w_mb(data,
  528. CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
  529. }
  530. /**
  531. * cam_soc_util_r()
  532. *
  533. * @brief: Camera SOC util for register read
  534. *
  535. * @soc_info: Device soc information
  536. * @base_index: Index of register space in the HW block
  537. * @offset: Offset of register to be read
  538. *
  539. * @return: Value read from the register address
  540. */
  541. static inline uint32_t cam_soc_util_r(struct cam_hw_soc_info *soc_info,
  542. uint32_t base_index, uint32_t offset)
  543. {
  544. if (!CAM_SOC_GET_REG_MAP_START(soc_info, base_index))
  545. return 0;
  546. return cam_io_r(
  547. CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
  548. }
  549. /**
  550. * cam_soc_util_r_mb()
  551. *
  552. * @brief: Camera SOC util for register read with memory barrier.
  553. * Memory Barrier is only before the write to ensure the
  554. * order. If need to ensure this write is also flushed
  555. * call rmb() independently in the caller.
  556. *
  557. * @soc_info: Device soc information
  558. * @base_index: Index of register space in the HW block
  559. * @offset: Offset of register to be read
  560. *
  561. * @return: Value read from the register address
  562. */
  563. static inline uint32_t cam_soc_util_r_mb(struct cam_hw_soc_info *soc_info,
  564. uint32_t base_index, uint32_t offset)
  565. {
  566. if (!CAM_SOC_GET_REG_MAP_START(soc_info, base_index))
  567. return 0;
  568. return cam_io_r_mb(
  569. CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
  570. }
  571. /**
  572. * cam_soc_util_reg_dump()
  573. *
  574. * @brief: Camera SOC util for dumping a range of register
  575. *
  576. * @soc_info: Device soc information
  577. * @base_index: Index of register space in the HW block
  578. * @offset: Start register offset for the dump
  579. * @size: Size specifying the range for dump
  580. *
  581. * @return: Success or Failure
  582. */
  583. int cam_soc_util_reg_dump(struct cam_hw_soc_info *soc_info,
  584. uint32_t base_index, uint32_t offset, int size);
  585. void cam_soc_util_clk_disable_default(struct cam_hw_soc_info *soc_info);
  586. int cam_soc_util_clk_enable_default(struct cam_hw_soc_info *soc_info,
  587. enum cam_vote_level clk_level);
  588. int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info,
  589. int32_t clk_rate, int clk_idx, int32_t *clk_lvl);
  590. #endif /* _CAM_SOC_UTIL_H_ */