Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 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 | |
| 36 | #ifndef _UFSHCD_H |
| 37 | #define _UFSHCD_H |
| 38 | |
| 39 | #include <linux/module.h> |
| 40 | #include <linux/kernel.h> |
| 41 | #include <linux/init.h> |
| 42 | #include <linux/interrupt.h> |
| 43 | #include <linux/io.h> |
| 44 | #include <linux/delay.h> |
| 45 | #include <linux/slab.h> |
| 46 | #include <linux/spinlock.h> |
| 47 | #include <linux/workqueue.h> |
| 48 | #include <linux/errno.h> |
| 49 | #include <linux/types.h> |
| 50 | #include <linux/wait.h> |
| 51 | #include <linux/bitops.h> |
| 52 | #include <linux/pm_runtime.h> |
| 53 | #include <linux/clk.h> |
Seungwon Jeon | 6ccf44fe | 2013-06-26 22:39:29 +0530 | [diff] [blame] | 54 | #include <linux/completion.h> |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 55 | |
| 56 | #include <asm/irq.h> |
| 57 | #include <asm/byteorder.h> |
| 58 | #include <scsi/scsi.h> |
| 59 | #include <scsi/scsi_cmnd.h> |
| 60 | #include <scsi/scsi_host.h> |
| 61 | #include <scsi/scsi_tcq.h> |
| 62 | #include <scsi/scsi_dbg.h> |
| 63 | #include <scsi/scsi_eh.h> |
| 64 | |
| 65 | #include "ufs.h" |
| 66 | #include "ufshci.h" |
| 67 | |
| 68 | #define UFSHCD "ufshcd" |
| 69 | #define UFSHCD_DRIVER_VERSION "0.2" |
| 70 | |
Sujit Reddy Thumma | 5c0c28a | 2014-09-25 15:32:21 +0300 | [diff] [blame^] | 71 | struct ufs_hba; |
| 72 | |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 73 | enum dev_cmd_type { |
| 74 | DEV_CMD_TYPE_NOP = 0x0, |
Dolev Raviv | 68078d5 | 2013-07-30 00:35:58 +0530 | [diff] [blame] | 75 | DEV_CMD_TYPE_QUERY = 0x1, |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 76 | }; |
| 77 | |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 78 | /** |
| 79 | * struct uic_command - UIC command structure |
| 80 | * @command: UIC command |
| 81 | * @argument1: UIC command argument 1 |
| 82 | * @argument2: UIC command argument 2 |
| 83 | * @argument3: UIC command argument 3 |
| 84 | * @cmd_active: Indicate if UIC command is outstanding |
| 85 | * @result: UIC command result |
Seungwon Jeon | 6ccf44fe | 2013-06-26 22:39:29 +0530 | [diff] [blame] | 86 | * @done: UIC command completion |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 87 | */ |
| 88 | struct uic_command { |
| 89 | u32 command; |
| 90 | u32 argument1; |
| 91 | u32 argument2; |
| 92 | u32 argument3; |
| 93 | int cmd_active; |
| 94 | int result; |
Seungwon Jeon | 6ccf44fe | 2013-06-26 22:39:29 +0530 | [diff] [blame] | 95 | struct completion done; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * struct ufshcd_lrb - local reference block |
| 100 | * @utr_descriptor_ptr: UTRD address of the command |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 101 | * @ucd_req_ptr: UCD address of the command |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 102 | * @ucd_rsp_ptr: Response UPIU address for this command |
| 103 | * @ucd_prdt_ptr: PRDT address of the command |
| 104 | * @cmd: pointer to SCSI command |
| 105 | * @sense_buffer: pointer to sense buffer address of the SCSI command |
| 106 | * @sense_bufflen: Length of the sense buffer |
| 107 | * @scsi_status: SCSI status of the command |
| 108 | * @command_type: SCSI, UFS, Query. |
| 109 | * @task_tag: Task tag of the command |
| 110 | * @lun: LUN of the command |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 111 | * @intr_cmd: Interrupt command (doesn't participate in interrupt aggregation) |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 112 | */ |
| 113 | struct ufshcd_lrb { |
| 114 | struct utp_transfer_req_desc *utr_descriptor_ptr; |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 115 | struct utp_upiu_req *ucd_req_ptr; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 116 | struct utp_upiu_rsp *ucd_rsp_ptr; |
| 117 | struct ufshcd_sg_entry *ucd_prdt_ptr; |
| 118 | |
| 119 | struct scsi_cmnd *cmd; |
| 120 | u8 *sense_buffer; |
| 121 | unsigned int sense_bufflen; |
| 122 | int scsi_status; |
| 123 | |
| 124 | int command_type; |
| 125 | int task_tag; |
| 126 | unsigned int lun; |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 127 | bool intr_cmd; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 128 | }; |
| 129 | |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 130 | /** |
Dolev Raviv | 68078d5 | 2013-07-30 00:35:58 +0530 | [diff] [blame] | 131 | * struct ufs_query - holds relevent data structures for query request |
| 132 | * @request: request upiu and function |
| 133 | * @descriptor: buffer for sending/receiving descriptor |
| 134 | * @response: response upiu and response |
| 135 | */ |
| 136 | struct ufs_query { |
| 137 | struct ufs_query_req request; |
| 138 | u8 *descriptor; |
| 139 | struct ufs_query_res response; |
| 140 | }; |
| 141 | |
| 142 | /** |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 143 | * struct ufs_dev_cmd - all assosiated fields with device management commands |
| 144 | * @type: device management command type - Query, NOP OUT |
| 145 | * @lock: lock to allow one command at a time |
| 146 | * @complete: internal commands completion |
| 147 | * @tag_wq: wait queue until free command slot is available |
| 148 | */ |
| 149 | struct ufs_dev_cmd { |
| 150 | enum dev_cmd_type type; |
| 151 | struct mutex lock; |
| 152 | struct completion *complete; |
| 153 | wait_queue_head_t tag_wq; |
Dolev Raviv | 68078d5 | 2013-07-30 00:35:58 +0530 | [diff] [blame] | 154 | struct ufs_query query; |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 155 | }; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 156 | |
Sujit Reddy Thumma | 5c0c28a | 2014-09-25 15:32:21 +0300 | [diff] [blame^] | 157 | #define PRE_CHANGE 0 |
| 158 | #define POST_CHANGE 1 |
| 159 | /** |
| 160 | * struct ufs_hba_variant_ops - variant specific callbacks |
| 161 | * @name: variant name |
| 162 | * @init: called when the driver is initialized |
| 163 | * @exit: called to cleanup everything done in init |
| 164 | * @setup_clocks: called before touching any of the controller registers |
| 165 | * @setup_regulators: called before accessing the host controller |
| 166 | * @hce_enable_notify: called before and after HCE enable bit is set to allow |
| 167 | * variant specific Uni-Pro initialization. |
| 168 | * @link_startup_notify: called before and after Link startup is carried out |
| 169 | * to allow variant specific Uni-Pro initialization. |
| 170 | */ |
| 171 | struct ufs_hba_variant_ops { |
| 172 | const char *name; |
| 173 | int (*init)(struct ufs_hba *); |
| 174 | void (*exit)(struct ufs_hba *); |
| 175 | int (*setup_clocks)(struct ufs_hba *, bool); |
| 176 | int (*setup_regulators)(struct ufs_hba *, bool); |
| 177 | int (*hce_enable_notify)(struct ufs_hba *, bool); |
| 178 | int (*link_startup_notify)(struct ufs_hba *, bool); |
| 179 | }; |
| 180 | |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 181 | /** |
| 182 | * struct ufs_hba - per adapter private structure |
| 183 | * @mmio_base: UFSHCI base register address |
| 184 | * @ucdl_base_addr: UFS Command Descriptor base address |
| 185 | * @utrdl_base_addr: UTP Transfer Request Descriptor base address |
| 186 | * @utmrdl_base_addr: UTP Task Management Descriptor base address |
| 187 | * @ucdl_dma_addr: UFS Command Descriptor DMA address |
| 188 | * @utrdl_dma_addr: UTRDL DMA address |
| 189 | * @utmrdl_dma_addr: UTMRDL DMA address |
| 190 | * @host: Scsi_Host instance of the driver |
| 191 | * @dev: device handle |
| 192 | * @lrb: local reference block |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 193 | * @lrb_in_use: lrb in use |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 194 | * @outstanding_tasks: Bits representing outstanding task requests |
| 195 | * @outstanding_reqs: Bits representing outstanding transfer requests |
| 196 | * @capabilities: UFS Controller Capabilities |
| 197 | * @nutrs: Transfer Request Queue depth supported by controller |
| 198 | * @nutmrs: Task Management Queue depth supported by controller |
| 199 | * @ufs_version: UFS Version to which controller complies |
Sujit Reddy Thumma | 5c0c28a | 2014-09-25 15:32:21 +0300 | [diff] [blame^] | 200 | * @vops: pointer to variant specific operations |
| 201 | * @priv: pointer to variant specific private data |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 202 | * @irq: Irq number of the controller |
| 203 | * @active_uic_cmd: handle of active UIC command |
Seungwon Jeon | 6ccf44fe | 2013-06-26 22:39:29 +0530 | [diff] [blame] | 204 | * @uic_cmd_mutex: mutex for uic command |
Sujit Reddy Thumma | e293313 | 2014-05-26 10:59:12 +0530 | [diff] [blame] | 205 | * @tm_wq: wait queue for task management |
| 206 | * @tm_tag_wq: wait queue for free task management slots |
| 207 | * @tm_slots_in_use: bit map of task management request slots in use |
Seungwon Jeon | 53b3d9c | 2013-08-31 21:40:22 +0530 | [diff] [blame] | 208 | * @pwr_done: completion for power mode change |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 209 | * @tm_condition: condition variable for task management |
| 210 | * @ufshcd_state: UFSHCD states |
Sujit Reddy Thumma | 3441da7 | 2014-05-26 10:59:14 +0530 | [diff] [blame] | 211 | * @eh_flags: Error handling flags |
Seungwon Jeon | 2fbd009 | 2013-06-26 22:39:27 +0530 | [diff] [blame] | 212 | * @intr_mask: Interrupt Mask Bits |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 213 | * @ee_ctrl_mask: Exception event control mask |
Sujit Reddy Thumma | e8e7f27 | 2014-05-26 10:59:15 +0530 | [diff] [blame] | 214 | * @eh_work: Worker to handle UFS errors that require s/w attention |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 215 | * @eeh_work: Worker to handle exception events |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 216 | * @errors: HBA errors |
Sujit Reddy Thumma | e8e7f27 | 2014-05-26 10:59:15 +0530 | [diff] [blame] | 217 | * @uic_error: UFS interconnect layer error status |
| 218 | * @saved_err: sticky error mask |
| 219 | * @saved_uic_err: sticky UIC error mask |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 220 | * @dev_cmd: ufs device management command information |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 221 | * @auto_bkops_enabled: to track whether bkops is enabled in device |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 222 | */ |
| 223 | struct ufs_hba { |
| 224 | void __iomem *mmio_base; |
| 225 | |
| 226 | /* Virtual memory reference */ |
| 227 | struct utp_transfer_cmd_desc *ucdl_base_addr; |
| 228 | struct utp_transfer_req_desc *utrdl_base_addr; |
| 229 | struct utp_task_req_desc *utmrdl_base_addr; |
| 230 | |
| 231 | /* DMA memory reference */ |
| 232 | dma_addr_t ucdl_dma_addr; |
| 233 | dma_addr_t utrdl_dma_addr; |
| 234 | dma_addr_t utmrdl_dma_addr; |
| 235 | |
| 236 | struct Scsi_Host *host; |
| 237 | struct device *dev; |
| 238 | |
| 239 | struct ufshcd_lrb *lrb; |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 240 | unsigned long lrb_in_use; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 241 | |
| 242 | unsigned long outstanding_tasks; |
| 243 | unsigned long outstanding_reqs; |
| 244 | |
| 245 | u32 capabilities; |
| 246 | int nutrs; |
| 247 | int nutmrs; |
| 248 | u32 ufs_version; |
Sujit Reddy Thumma | 5c0c28a | 2014-09-25 15:32:21 +0300 | [diff] [blame^] | 249 | struct ufs_hba_variant_ops *vops; |
| 250 | void *priv; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 251 | unsigned int irq; |
| 252 | |
Seungwon Jeon | 6ccf44fe | 2013-06-26 22:39:29 +0530 | [diff] [blame] | 253 | struct uic_command *active_uic_cmd; |
| 254 | struct mutex uic_cmd_mutex; |
| 255 | |
Sujit Reddy Thumma | e293313 | 2014-05-26 10:59:12 +0530 | [diff] [blame] | 256 | wait_queue_head_t tm_wq; |
| 257 | wait_queue_head_t tm_tag_wq; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 258 | unsigned long tm_condition; |
Sujit Reddy Thumma | e293313 | 2014-05-26 10:59:12 +0530 | [diff] [blame] | 259 | unsigned long tm_slots_in_use; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 260 | |
Seungwon Jeon | 53b3d9c | 2013-08-31 21:40:22 +0530 | [diff] [blame] | 261 | struct completion *pwr_done; |
| 262 | |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 263 | u32 ufshcd_state; |
Sujit Reddy Thumma | 3441da7 | 2014-05-26 10:59:14 +0530 | [diff] [blame] | 264 | u32 eh_flags; |
Seungwon Jeon | 2fbd009 | 2013-06-26 22:39:27 +0530 | [diff] [blame] | 265 | u32 intr_mask; |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 266 | u16 ee_ctrl_mask; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 267 | |
| 268 | /* Work Queues */ |
Sujit Reddy Thumma | e8e7f27 | 2014-05-26 10:59:15 +0530 | [diff] [blame] | 269 | struct work_struct eh_work; |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 270 | struct work_struct eeh_work; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 271 | |
| 272 | /* HBA Errors */ |
| 273 | u32 errors; |
Sujit Reddy Thumma | e8e7f27 | 2014-05-26 10:59:15 +0530 | [diff] [blame] | 274 | u32 uic_error; |
| 275 | u32 saved_err; |
| 276 | u32 saved_uic_err; |
Sujit Reddy Thumma | 5a0b0cb | 2013-07-30 00:35:57 +0530 | [diff] [blame] | 277 | |
| 278 | /* Device management request data */ |
| 279 | struct ufs_dev_cmd dev_cmd; |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 280 | |
| 281 | bool auto_bkops_enabled; |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 282 | }; |
| 283 | |
Seungwon Jeon | b873a275 | 2013-06-26 22:39:26 +0530 | [diff] [blame] | 284 | #define ufshcd_writel(hba, val, reg) \ |
| 285 | writel((val), (hba)->mmio_base + (reg)) |
| 286 | #define ufshcd_readl(hba, reg) \ |
| 287 | readl((hba)->mmio_base + (reg)) |
| 288 | |
Sujit Reddy Thumma | 5c0c28a | 2014-09-25 15:32:21 +0300 | [diff] [blame^] | 289 | int ufshcd_alloc_host(struct device *, struct ufs_hba **); |
| 290 | int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int); |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 291 | void ufshcd_remove(struct ufs_hba *); |
| 292 | |
| 293 | /** |
| 294 | * ufshcd_hba_stop - Send controller to reset state |
| 295 | * @hba: per adapter instance |
| 296 | */ |
| 297 | static inline void ufshcd_hba_stop(struct ufs_hba *hba) |
| 298 | { |
Seungwon Jeon | b873a275 | 2013-06-26 22:39:26 +0530 | [diff] [blame] | 299 | ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE); |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 300 | } |
| 301 | |
Dolev Raviv | 68078d5 | 2013-07-30 00:35:58 +0530 | [diff] [blame] | 302 | static inline void check_upiu_size(void) |
| 303 | { |
| 304 | BUILD_BUG_ON(ALIGNED_UPIU_SIZE < |
| 305 | GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE); |
| 306 | } |
| 307 | |
Sujit Reddy Thumma | bdbe5d2 | 2014-05-26 10:59:11 +0530 | [diff] [blame] | 308 | extern int ufshcd_suspend(struct ufs_hba *hba, pm_message_t state); |
| 309 | extern int ufshcd_resume(struct ufs_hba *hba); |
Sujit Reddy Thumma | 66ec6d5 | 2013-07-30 00:35:59 +0530 | [diff] [blame] | 310 | extern int ufshcd_runtime_suspend(struct ufs_hba *hba); |
| 311 | extern int ufshcd_runtime_resume(struct ufs_hba *hba); |
| 312 | extern int ufshcd_runtime_idle(struct ufs_hba *hba); |
Seungwon Jeon | 12b4fdb | 2013-08-31 21:40:21 +0530 | [diff] [blame] | 313 | extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel, |
| 314 | u8 attr_set, u32 mib_val, u8 peer); |
| 315 | extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, |
| 316 | u32 *mib_val, u8 peer); |
| 317 | |
| 318 | /* UIC command interfaces for DME primitives */ |
| 319 | #define DME_LOCAL 0 |
| 320 | #define DME_PEER 1 |
| 321 | #define ATTR_SET_NOR 0 /* NORMAL */ |
| 322 | #define ATTR_SET_ST 1 /* STATIC */ |
| 323 | |
| 324 | static inline int ufshcd_dme_set(struct ufs_hba *hba, u32 attr_sel, |
| 325 | u32 mib_val) |
| 326 | { |
| 327 | return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, |
| 328 | mib_val, DME_LOCAL); |
| 329 | } |
| 330 | |
| 331 | static inline int ufshcd_dme_st_set(struct ufs_hba *hba, u32 attr_sel, |
| 332 | u32 mib_val) |
| 333 | { |
| 334 | return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, |
| 335 | mib_val, DME_LOCAL); |
| 336 | } |
| 337 | |
| 338 | static inline int ufshcd_dme_peer_set(struct ufs_hba *hba, u32 attr_sel, |
| 339 | u32 mib_val) |
| 340 | { |
| 341 | return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, |
| 342 | mib_val, DME_PEER); |
| 343 | } |
| 344 | |
| 345 | static inline int ufshcd_dme_peer_st_set(struct ufs_hba *hba, u32 attr_sel, |
| 346 | u32 mib_val) |
| 347 | { |
| 348 | return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, |
| 349 | mib_val, DME_PEER); |
| 350 | } |
| 351 | |
| 352 | static inline int ufshcd_dme_get(struct ufs_hba *hba, |
| 353 | u32 attr_sel, u32 *mib_val) |
| 354 | { |
| 355 | return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL); |
| 356 | } |
| 357 | |
| 358 | static inline int ufshcd_dme_peer_get(struct ufs_hba *hba, |
| 359 | u32 attr_sel, u32 *mib_val) |
| 360 | { |
| 361 | return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_PEER); |
| 362 | } |
| 363 | |
Vinayak Holikatti | e0eca63 | 2013-02-25 21:44:33 +0530 | [diff] [blame] | 364 | #endif /* End of Header */ |