ufshcd.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  2. * Universal Flash Storage Host controller driver
  3. *
  4. * This code is based on drivers/scsi/ufs/ufshcd.h
  5. * Copyright (C) 2011-2013 Samsung India Software Operations
  6. *
  7. * Authors:
  8. * Santosh Yaraganavi <santosh.sy@samsung.com>
  9. * Vinayak Holikatti <h.vinayak@samsung.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version 2
  14. * of the License, or (at your option) any later version.
  15. * See the COPYING file in the top-level directory or visit
  16. * <http://www.gnu.org/licenses/gpl-2.0.html>
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * This program is provided "AS IS" and "WITH ALL FAULTS" and
  24. * without warranty of any kind. You are solely responsible for
  25. * determining the appropriateness of using and distributing
  26. * the program and assume all risks associated with your exercise
  27. * of rights with respect to the program, including but not limited
  28. * to infringement of third party rights, the risks and costs of
  29. * program errors, damage to or loss of data, programs or equipment,
  30. * and unavailability or interruption of operations. Under no
  31. * circumstances will the contributor of this Program be liable for
  32. * any damages of any kind arising from your use or distribution of
  33. * this program.
  34. */
  35. #ifndef _UFSHCD_H
  36. #define _UFSHCD_H
  37. #include <linux/module.h>
  38. #include <linux/kernel.h>
  39. #include <linux/init.h>
  40. #include <linux/interrupt.h>
  41. #include <linux/io.h>
  42. #include <linux/delay.h>
  43. #include <linux/slab.h>
  44. #include <linux/spinlock.h>
  45. #include <linux/workqueue.h>
  46. #include <linux/errno.h>
  47. #include <linux/types.h>
  48. #include <linux/wait.h>
  49. #include <linux/bitops.h>
  50. #include <linux/pm_runtime.h>
  51. #include <linux/clk.h>
  52. #include <linux/completion.h>
  53. #include <linux/regulator/consumer.h>
  54. #include <asm/irq.h>
  55. #include <asm/byteorder.h>
  56. #include <scsi/scsi.h>
  57. #include <scsi/scsi_cmnd.h>
  58. #include <scsi/scsi_host.h>
  59. #include <scsi/scsi_tcq.h>
  60. #include <scsi/scsi_dbg.h>
  61. #include <scsi/scsi_eh.h>
  62. #include "ufs.h"
  63. #include "ufshci.h"
  64. #define UFSHCD "ufshcd"
  65. #define UFSHCD_DRIVER_VERSION "0.2"
  66. struct ufs_hba;
  67. enum dev_cmd_type {
  68. DEV_CMD_TYPE_NOP = 0x0,
  69. DEV_CMD_TYPE_QUERY = 0x1,
  70. };
  71. /**
  72. * struct uic_command - UIC command structure
  73. * @command: UIC command
  74. * @argument1: UIC command argument 1
  75. * @argument2: UIC command argument 2
  76. * @argument3: UIC command argument 3
  77. * @cmd_active: Indicate if UIC command is outstanding
  78. * @result: UIC command result
  79. * @done: UIC command completion
  80. */
  81. struct uic_command {
  82. u32 command;
  83. u32 argument1;
  84. u32 argument2;
  85. u32 argument3;
  86. int cmd_active;
  87. int result;
  88. struct completion done;
  89. };
  90. /* Used to differentiate the power management options */
  91. enum ufs_pm_op {
  92. UFS_RUNTIME_PM,
  93. UFS_SYSTEM_PM,
  94. UFS_SHUTDOWN_PM,
  95. };
  96. #define ufshcd_is_runtime_pm(op) ((op) == UFS_RUNTIME_PM)
  97. #define ufshcd_is_system_pm(op) ((op) == UFS_SYSTEM_PM)
  98. #define ufshcd_is_shutdown_pm(op) ((op) == UFS_SHUTDOWN_PM)
  99. /* Host <-> Device UniPro Link state */
  100. enum uic_link_state {
  101. UIC_LINK_OFF_STATE = 0, /* Link powered down or disabled */
  102. UIC_LINK_ACTIVE_STATE = 1, /* Link is in Fast/Slow/Sleep state */
  103. UIC_LINK_HIBERN8_STATE = 2, /* Link is in Hibernate state */
  104. };
  105. #define ufshcd_is_link_off(hba) ((hba)->uic_link_state == UIC_LINK_OFF_STATE)
  106. #define ufshcd_is_link_active(hba) ((hba)->uic_link_state == \
  107. UIC_LINK_ACTIVE_STATE)
  108. #define ufshcd_is_link_hibern8(hba) ((hba)->uic_link_state == \
  109. UIC_LINK_HIBERN8_STATE)
  110. #define ufshcd_set_link_off(hba) ((hba)->uic_link_state = UIC_LINK_OFF_STATE)
  111. #define ufshcd_set_link_active(hba) ((hba)->uic_link_state = \
  112. UIC_LINK_ACTIVE_STATE)
  113. #define ufshcd_set_link_hibern8(hba) ((hba)->uic_link_state = \
  114. UIC_LINK_HIBERN8_STATE)
  115. /*
  116. * UFS Power management levels.
  117. * Each level is in increasing order of power savings.
  118. */
  119. enum ufs_pm_level {
  120. UFS_PM_LVL_0, /* UFS_ACTIVE_PWR_MODE, UIC_LINK_ACTIVE_STATE */
  121. UFS_PM_LVL_1, /* UFS_ACTIVE_PWR_MODE, UIC_LINK_HIBERN8_STATE */
  122. UFS_PM_LVL_2, /* UFS_SLEEP_PWR_MODE, UIC_LINK_ACTIVE_STATE */
  123. UFS_PM_LVL_3, /* UFS_SLEEP_PWR_MODE, UIC_LINK_HIBERN8_STATE */
  124. UFS_PM_LVL_4, /* UFS_POWERDOWN_PWR_MODE, UIC_LINK_HIBERN8_STATE */
  125. UFS_PM_LVL_5, /* UFS_POWERDOWN_PWR_MODE, UIC_LINK_OFF_STATE */
  126. UFS_PM_LVL_MAX
  127. };
  128. struct ufs_pm_lvl_states {
  129. enum ufs_dev_pwr_mode dev_state;
  130. enum uic_link_state link_state;
  131. };
  132. /**
  133. * struct ufshcd_lrb - local reference block
  134. * @utr_descriptor_ptr: UTRD address of the command
  135. * @ucd_req_ptr: UCD address of the command
  136. * @ucd_rsp_ptr: Response UPIU address for this command
  137. * @ucd_prdt_ptr: PRDT address of the command
  138. * @cmd: pointer to SCSI command
  139. * @sense_buffer: pointer to sense buffer address of the SCSI command
  140. * @sense_bufflen: Length of the sense buffer
  141. * @scsi_status: SCSI status of the command
  142. * @command_type: SCSI, UFS, Query.
  143. * @task_tag: Task tag of the command
  144. * @lun: LUN of the command
  145. * @intr_cmd: Interrupt command (doesn't participate in interrupt aggregation)
  146. */
  147. struct ufshcd_lrb {
  148. struct utp_transfer_req_desc *utr_descriptor_ptr;
  149. struct utp_upiu_req *ucd_req_ptr;
  150. struct utp_upiu_rsp *ucd_rsp_ptr;
  151. struct ufshcd_sg_entry *ucd_prdt_ptr;
  152. struct scsi_cmnd *cmd;
  153. u8 *sense_buffer;
  154. unsigned int sense_bufflen;
  155. int scsi_status;
  156. int command_type;
  157. int task_tag;
  158. u8 lun; /* UPIU LUN id field is only 8-bit wide */
  159. bool intr_cmd;
  160. };
  161. /**
  162. * struct ufs_query - holds relevent data structures for query request
  163. * @request: request upiu and function
  164. * @descriptor: buffer for sending/receiving descriptor
  165. * @response: response upiu and response
  166. */
  167. struct ufs_query {
  168. struct ufs_query_req request;
  169. u8 *descriptor;
  170. struct ufs_query_res response;
  171. };
  172. /**
  173. * struct ufs_dev_cmd - all assosiated fields with device management commands
  174. * @type: device management command type - Query, NOP OUT
  175. * @lock: lock to allow one command at a time
  176. * @complete: internal commands completion
  177. * @tag_wq: wait queue until free command slot is available
  178. */
  179. struct ufs_dev_cmd {
  180. enum dev_cmd_type type;
  181. struct mutex lock;
  182. struct completion *complete;
  183. wait_queue_head_t tag_wq;
  184. struct ufs_query query;
  185. };
  186. /**
  187. * struct ufs_clk_info - UFS clock related info
  188. * @list: list headed by hba->clk_list_head
  189. * @clk: clock node
  190. * @name: clock name
  191. * @max_freq: maximum frequency supported by the clock
  192. * @min_freq: min frequency that can be used for clock scaling
  193. * @curr_freq: indicates the current frequency that it is set to
  194. * @enabled: variable to check against multiple enable/disable
  195. */
  196. struct ufs_clk_info {
  197. struct list_head list;
  198. struct clk *clk;
  199. const char *name;
  200. u32 max_freq;
  201. u32 min_freq;
  202. u32 curr_freq;
  203. bool enabled;
  204. };
  205. #define PRE_CHANGE 0
  206. #define POST_CHANGE 1
  207. struct ufs_pa_layer_attr {
  208. u32 gear_rx;
  209. u32 gear_tx;
  210. u32 lane_rx;
  211. u32 lane_tx;
  212. u32 pwr_rx;
  213. u32 pwr_tx;
  214. u32 hs_rate;
  215. };
  216. struct ufs_pwr_mode_info {
  217. bool is_valid;
  218. struct ufs_pa_layer_attr info;
  219. };
  220. /**
  221. * struct ufs_hba_variant_ops - variant specific callbacks
  222. * @name: variant name
  223. * @init: called when the driver is initialized
  224. * @exit: called to cleanup everything done in init
  225. * @clk_scale_notify: notifies that clks are scaled up/down
  226. * @setup_clocks: called before touching any of the controller registers
  227. * @setup_regulators: called before accessing the host controller
  228. * @hce_enable_notify: called before and after HCE enable bit is set to allow
  229. * variant specific Uni-Pro initialization.
  230. * @link_startup_notify: called before and after Link startup is carried out
  231. * to allow variant specific Uni-Pro initialization.
  232. * @pwr_change_notify: called before and after a power mode change
  233. * is carried out to allow vendor spesific capabilities
  234. * to be set.
  235. * @suspend: called during host controller PM callback
  236. * @resume: called during host controller PM callback
  237. */
  238. struct ufs_hba_variant_ops {
  239. const char *name;
  240. int (*init)(struct ufs_hba *);
  241. void (*exit)(struct ufs_hba *);
  242. void (*clk_scale_notify)(struct ufs_hba *);
  243. int (*setup_clocks)(struct ufs_hba *, bool);
  244. int (*setup_regulators)(struct ufs_hba *, bool);
  245. int (*hce_enable_notify)(struct ufs_hba *, bool);
  246. int (*link_startup_notify)(struct ufs_hba *, bool);
  247. int (*pwr_change_notify)(struct ufs_hba *,
  248. bool, struct ufs_pa_layer_attr *,
  249. struct ufs_pa_layer_attr *);
  250. int (*suspend)(struct ufs_hba *, enum ufs_pm_op);
  251. int (*resume)(struct ufs_hba *, enum ufs_pm_op);
  252. };
  253. /* clock gating state */
  254. enum clk_gating_state {
  255. CLKS_OFF,
  256. CLKS_ON,
  257. REQ_CLKS_OFF,
  258. REQ_CLKS_ON,
  259. };
  260. /**
  261. * struct ufs_clk_gating - UFS clock gating related info
  262. * @gate_work: worker to turn off clocks after some delay as specified in
  263. * delay_ms
  264. * @ungate_work: worker to turn on clocks that will be used in case of
  265. * interrupt context
  266. * @state: the current clocks state
  267. * @delay_ms: gating delay in ms
  268. * @is_suspended: clk gating is suspended when set to 1 which can be used
  269. * during suspend/resume
  270. * @delay_attr: sysfs attribute to control delay_attr
  271. * @active_reqs: number of requests that are pending and should be waited for
  272. * completion before gating clocks.
  273. */
  274. struct ufs_clk_gating {
  275. struct delayed_work gate_work;
  276. struct work_struct ungate_work;
  277. enum clk_gating_state state;
  278. unsigned long delay_ms;
  279. bool is_suspended;
  280. struct device_attribute delay_attr;
  281. int active_reqs;
  282. };
  283. struct ufs_clk_scaling {
  284. ktime_t busy_start_t;
  285. bool is_busy_started;
  286. unsigned long tot_busy_t;
  287. unsigned long window_start_t;
  288. };
  289. /**
  290. * struct ufs_init_prefetch - contains data that is pre-fetched once during
  291. * initialization
  292. * @icc_level: icc level which was read during initialization
  293. */
  294. struct ufs_init_prefetch {
  295. u32 icc_level;
  296. };
  297. /**
  298. * struct ufs_hba - per adapter private structure
  299. * @mmio_base: UFSHCI base register address
  300. * @ucdl_base_addr: UFS Command Descriptor base address
  301. * @utrdl_base_addr: UTP Transfer Request Descriptor base address
  302. * @utmrdl_base_addr: UTP Task Management Descriptor base address
  303. * @ucdl_dma_addr: UFS Command Descriptor DMA address
  304. * @utrdl_dma_addr: UTRDL DMA address
  305. * @utmrdl_dma_addr: UTMRDL DMA address
  306. * @host: Scsi_Host instance of the driver
  307. * @dev: device handle
  308. * @lrb: local reference block
  309. * @lrb_in_use: lrb in use
  310. * @outstanding_tasks: Bits representing outstanding task requests
  311. * @outstanding_reqs: Bits representing outstanding transfer requests
  312. * @capabilities: UFS Controller Capabilities
  313. * @nutrs: Transfer Request Queue depth supported by controller
  314. * @nutmrs: Task Management Queue depth supported by controller
  315. * @ufs_version: UFS Version to which controller complies
  316. * @vops: pointer to variant specific operations
  317. * @priv: pointer to variant specific private data
  318. * @irq: Irq number of the controller
  319. * @active_uic_cmd: handle of active UIC command
  320. * @uic_cmd_mutex: mutex for uic command
  321. * @tm_wq: wait queue for task management
  322. * @tm_tag_wq: wait queue for free task management slots
  323. * @tm_slots_in_use: bit map of task management request slots in use
  324. * @pwr_done: completion for power mode change
  325. * @tm_condition: condition variable for task management
  326. * @ufshcd_state: UFSHCD states
  327. * @eh_flags: Error handling flags
  328. * @intr_mask: Interrupt Mask Bits
  329. * @ee_ctrl_mask: Exception event control mask
  330. * @is_powered: flag to check if HBA is powered
  331. * @is_init_prefetch: flag to check if data was pre-fetched in initialization
  332. * @init_prefetch_data: data pre-fetched during initialization
  333. * @eh_work: Worker to handle UFS errors that require s/w attention
  334. * @eeh_work: Worker to handle exception events
  335. * @errors: HBA errors
  336. * @uic_error: UFS interconnect layer error status
  337. * @saved_err: sticky error mask
  338. * @saved_uic_err: sticky UIC error mask
  339. * @dev_cmd: ufs device management command information
  340. * @auto_bkops_enabled: to track whether bkops is enabled in device
  341. * @vreg_info: UFS device voltage regulator information
  342. * @clk_list_head: UFS host controller clocks list node head
  343. * @pwr_info: holds current power mode
  344. * @max_pwr_info: keeps the device max valid pwm
  345. */
  346. struct ufs_hba {
  347. void __iomem *mmio_base;
  348. /* Virtual memory reference */
  349. struct utp_transfer_cmd_desc *ucdl_base_addr;
  350. struct utp_transfer_req_desc *utrdl_base_addr;
  351. struct utp_task_req_desc *utmrdl_base_addr;
  352. /* DMA memory reference */
  353. dma_addr_t ucdl_dma_addr;
  354. dma_addr_t utrdl_dma_addr;
  355. dma_addr_t utmrdl_dma_addr;
  356. struct Scsi_Host *host;
  357. struct device *dev;
  358. /*
  359. * This field is to keep a reference to "scsi_device" corresponding to
  360. * "UFS device" W-LU.
  361. */
  362. struct scsi_device *sdev_ufs_device;
  363. enum ufs_dev_pwr_mode curr_dev_pwr_mode;
  364. enum uic_link_state uic_link_state;
  365. /* Desired UFS power management level during runtime PM */
  366. enum ufs_pm_level rpm_lvl;
  367. /* Desired UFS power management level during system PM */
  368. enum ufs_pm_level spm_lvl;
  369. int pm_op_in_progress;
  370. struct ufshcd_lrb *lrb;
  371. unsigned long lrb_in_use;
  372. unsigned long outstanding_tasks;
  373. unsigned long outstanding_reqs;
  374. u32 capabilities;
  375. int nutrs;
  376. int nutmrs;
  377. u32 ufs_version;
  378. struct ufs_hba_variant_ops *vops;
  379. void *priv;
  380. unsigned int irq;
  381. bool is_irq_enabled;
  382. wait_queue_head_t tm_wq;
  383. wait_queue_head_t tm_tag_wq;
  384. unsigned long tm_condition;
  385. unsigned long tm_slots_in_use;
  386. struct uic_command *active_uic_cmd;
  387. struct mutex uic_cmd_mutex;
  388. struct completion *uic_async_done;
  389. u32 ufshcd_state;
  390. u32 eh_flags;
  391. u32 intr_mask;
  392. u16 ee_ctrl_mask;
  393. bool is_powered;
  394. bool is_init_prefetch;
  395. struct ufs_init_prefetch init_prefetch_data;
  396. /* Work Queues */
  397. struct work_struct eh_work;
  398. struct work_struct eeh_work;
  399. /* HBA Errors */
  400. u32 errors;
  401. u32 uic_error;
  402. u32 saved_err;
  403. u32 saved_uic_err;
  404. /* Device management request data */
  405. struct ufs_dev_cmd dev_cmd;
  406. /* Keeps information of the UFS device connected to this host */
  407. struct ufs_dev_info dev_info;
  408. bool auto_bkops_enabled;
  409. struct ufs_vreg_info vreg_info;
  410. struct list_head clk_list_head;
  411. bool wlun_dev_clr_ua;
  412. struct ufs_pa_layer_attr pwr_info;
  413. struct ufs_pwr_mode_info max_pwr_info;
  414. struct ufs_clk_gating clk_gating;
  415. /* Control to enable/disable host capabilities */
  416. u32 caps;
  417. /* Allow dynamic clk gating */
  418. #define UFSHCD_CAP_CLK_GATING (1 << 0)
  419. /* Allow hiberb8 with clk gating */
  420. #define UFSHCD_CAP_HIBERN8_WITH_CLK_GATING (1 << 1)
  421. /* Allow dynamic clk scaling */
  422. #define UFSHCD_CAP_CLK_SCALING (1 << 2)
  423. /* Allow auto bkops to enabled during runtime suspend */
  424. #define UFSHCD_CAP_AUTO_BKOPS_SUSPEND (1 << 3)
  425. struct devfreq *devfreq;
  426. struct ufs_clk_scaling clk_scaling;
  427. bool is_sys_suspended;
  428. };
  429. /* Returns true if clocks can be gated. Otherwise false */
  430. static inline bool ufshcd_is_clkgating_allowed(struct ufs_hba *hba)
  431. {
  432. return hba->caps & UFSHCD_CAP_CLK_GATING;
  433. }
  434. static inline bool ufshcd_can_hibern8_during_gating(struct ufs_hba *hba)
  435. {
  436. return hba->caps & UFSHCD_CAP_HIBERN8_WITH_CLK_GATING;
  437. }
  438. static inline int ufshcd_is_clkscaling_enabled(struct ufs_hba *hba)
  439. {
  440. return hba->caps & UFSHCD_CAP_CLK_SCALING;
  441. }
  442. static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba)
  443. {
  444. return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND;
  445. }
  446. #define ufshcd_writel(hba, val, reg) \
  447. writel((val), (hba)->mmio_base + (reg))
  448. #define ufshcd_readl(hba, reg) \
  449. readl((hba)->mmio_base + (reg))
  450. /**
  451. * ufshcd_rmwl - read modify write into a register
  452. * @hba - per adapter instance
  453. * @mask - mask to apply on read value
  454. * @val - actual value to write
  455. * @reg - register address
  456. */
  457. static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
  458. {
  459. u32 tmp;
  460. tmp = ufshcd_readl(hba, reg);
  461. tmp &= ~mask;
  462. tmp |= (val & mask);
  463. ufshcd_writel(hba, tmp, reg);
  464. }
  465. int ufshcd_alloc_host(struct device *, struct ufs_hba **);
  466. int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int);
  467. void ufshcd_remove(struct ufs_hba *);
  468. /**
  469. * ufshcd_hba_stop - Send controller to reset state
  470. * @hba: per adapter instance
  471. */
  472. static inline void ufshcd_hba_stop(struct ufs_hba *hba)
  473. {
  474. ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE);
  475. }
  476. static inline void check_upiu_size(void)
  477. {
  478. BUILD_BUG_ON(ALIGNED_UPIU_SIZE <
  479. GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE);
  480. }
  481. extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
  482. extern int ufshcd_runtime_resume(struct ufs_hba *hba);
  483. extern int ufshcd_runtime_idle(struct ufs_hba *hba);
  484. extern int ufshcd_system_suspend(struct ufs_hba *hba);
  485. extern int ufshcd_system_resume(struct ufs_hba *hba);
  486. extern int ufshcd_shutdown(struct ufs_hba *hba);
  487. extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
  488. u8 attr_set, u32 mib_val, u8 peer);
  489. extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
  490. u32 *mib_val, u8 peer);
  491. /* UIC command interfaces for DME primitives */
  492. #define DME_LOCAL 0
  493. #define DME_PEER 1
  494. #define ATTR_SET_NOR 0 /* NORMAL */
  495. #define ATTR_SET_ST 1 /* STATIC */
  496. static inline int ufshcd_dme_set(struct ufs_hba *hba, u32 attr_sel,
  497. u32 mib_val)
  498. {
  499. return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR,
  500. mib_val, DME_LOCAL);
  501. }
  502. static inline int ufshcd_dme_st_set(struct ufs_hba *hba, u32 attr_sel,
  503. u32 mib_val)
  504. {
  505. return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST,
  506. mib_val, DME_LOCAL);
  507. }
  508. static inline int ufshcd_dme_peer_set(struct ufs_hba *hba, u32 attr_sel,
  509. u32 mib_val)
  510. {
  511. return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR,
  512. mib_val, DME_PEER);
  513. }
  514. static inline int ufshcd_dme_peer_st_set(struct ufs_hba *hba, u32 attr_sel,
  515. u32 mib_val)
  516. {
  517. return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST,
  518. mib_val, DME_PEER);
  519. }
  520. static inline int ufshcd_dme_get(struct ufs_hba *hba,
  521. u32 attr_sel, u32 *mib_val)
  522. {
  523. return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL);
  524. }
  525. static inline int ufshcd_dme_peer_get(struct ufs_hba *hba,
  526. u32 attr_sel, u32 *mib_val)
  527. {
  528. return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_PEER);
  529. }
  530. int ufshcd_hold(struct ufs_hba *hba, bool async);
  531. void ufshcd_release(struct ufs_hba *hba);
  532. #endif /* End of Header */