// SPDX-License-Identifier: GPL-2.0-or-later /* * Universal Flash Storage Host controller driver Core * Copyright (C) 2011-2013 Samsung India Software Operations * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * * Authors: * Santosh Yaraganavi <[email protected]> * Vinayak Holikatti <[email protected]> */ #include <linux/async.h> #include <linux/devfreq.h> #include <linux/nls.h> #include <linux/of.h> #include <linux/bitfield.h> #include <linux/blk-pm.h> #include <linux/blkdev.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/pm_opp.h> #include <linux/regulator/consumer.h> #include <linux/sched/clock.h> #include <linux/iopoll.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_dbg.h> #include <scsi/scsi_driver.h> #include <scsi/scsi_eh.h> #include "ufshcd-priv.h" #include <ufs/ufs_quirks.h> #include <ufs/unipro.h> #include "ufs-sysfs.h" #include "ufs-debugfs.h" #include "ufs-fault-injection.h" #include "ufs_bsg.h" #include "ufshcd-crypto.h" #include <linux/unaligned.h> #define CREATE_TRACE_POINTS #include "ufs_trace.h" #define UFSHCD_ENABLE_INTRS … #define UFSHCD_ENABLE_MCQ_INTRS … /* UIC command timeout, unit: ms */ enum { … }; /* NOP OUT retries waiting for NOP IN response */ #define NOP_OUT_RETRIES … /* Timeout after 50 msecs if NOP OUT hangs without response */ #define NOP_OUT_TIMEOUT … /* Query request retries */ #define QUERY_REQ_RETRIES … /* Query request timeout */ #define QUERY_REQ_TIMEOUT … /* Advanced RPMB request timeout */ #define ADVANCED_RPMB_REQ_TIMEOUT … /* Task management command timeout */ #define TM_CMD_TIMEOUT … /* maximum number of retries for a general UIC command */ #define UFS_UIC_COMMAND_RETRIES … /* maximum number of link-startup retries */ #define DME_LINKSTARTUP_RETRIES … /* maximum number of reset retries before giving up */ #define MAX_HOST_RESET_RETRIES … /* Maximum number of error handler retries before giving up */ #define MAX_ERR_HANDLER_RETRIES … /* Expose the flag value from utp_upiu_query.value */ #define MASK_QUERY_UPIU_FLAG_LOC … /* Interrupt aggregation default timeout, unit: 40us */ #define INT_AGGR_DEF_TO … /* default delay of autosuspend: 2000 ms */ #define RPM_AUTOSUSPEND_DELAY_MS … /* Default delay of RPM device flush delayed work */ #define RPM_DEV_FLUSH_RECHECK_WORK_DELAY_MS … /* Default value of wait time before gating device ref clock */ #define UFSHCD_REF_CLK_GATING_WAIT_US … /* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT … /* Default RTC update every 10 seconds */ #define UFS_RTC_UPDATE_INTERVAL_MS … /* bMaxNumOfRTT is equal to two after device manufacturing */ #define DEFAULT_MAX_NUM_RTT … /* UFSHC 4.0 compliant HC support this mode. */ static bool use_mcq_mode = …; static bool is_mcq_supported(struct ufs_hba *hba) { … } module_param(use_mcq_mode, bool, 0644); MODULE_PARM_DESC(…) …; static unsigned int uic_cmd_timeout = …; static int uic_cmd_timeout_set(const char *val, const struct kernel_param *kp) { … } static const struct kernel_param_ops uic_cmd_timeout_ops = …; module_param_cb(…); MODULE_PARM_DESC(…) …; #define ufshcd_toggle_vreg(_dev, _vreg, _on) … #define ufshcd_hex_dump(prefix_str, buf, len) … int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, const char *prefix) { … } EXPORT_SYMBOL_GPL(…); enum { … }; static const char *const ufshcd_state_name[] = …; /* UFSHCD error handling flags */ enum { … }; /* UFSHCD UIC layer error flags */ enum { … }; #define ufshcd_set_eh_in_progress(h) … #define ufshcd_eh_in_progress(h) … #define ufshcd_clear_eh_in_progress(h) … const struct ufs_pm_lvl_states ufs_pm_lvl_states[] = …; static inline enum ufs_dev_pwr_mode ufs_get_pm_lvl_to_dev_pwr_mode(enum ufs_pm_level lvl) { … } static inline enum uic_link_state ufs_get_pm_lvl_to_link_pwr_state(enum ufs_pm_level lvl) { … } static inline enum ufs_pm_level ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, enum uic_link_state link_state) { … } static bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba) { … } static const struct ufs_dev_quirk ufs_fixups[] = …; static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba); static void ufshcd_async_scan(void *data, async_cookie_t cookie); static int ufshcd_reset_and_restore(struct ufs_hba *hba); static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params); static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba); static int ufshcd_host_reset_and_restore(struct ufs_hba *hba); static void ufshcd_resume_clkscaling(struct ufs_hba *hba); static void ufshcd_suspend_clkscaling(struct ufs_hba *hba); static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq, bool scale_up); static irqreturn_t ufshcd_intr(int irq, void *__hba); static int ufshcd_change_power_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *pwr_mode); static int ufshcd_setup_hba_vreg(struct ufs_hba *hba, bool on); static int ufshcd_setup_vreg(struct ufs_hba *hba, bool on); static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, struct ufs_vreg *vreg); static void ufshcd_wb_toggle_buf_flush_during_h8(struct ufs_hba *hba, bool enable); static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba); static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba); void ufshcd_enable_irq(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); void ufshcd_disable_irq(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); static void ufshcd_configure_wb(struct ufs_hba *hba) { … } static void ufshcd_scsi_unblock_requests(struct ufs_hba *hba) { … } static void ufshcd_scsi_block_requests(struct ufs_hba *hba) { … } static void ufshcd_add_cmd_upiu_trace(struct ufs_hba *hba, unsigned int tag, enum ufs_trace_str_t str_t) { … } static void ufshcd_add_query_upiu_trace(struct ufs_hba *hba, enum ufs_trace_str_t str_t, struct utp_upiu_req *rq_rsp) { … } static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, enum ufs_trace_str_t str_t) { … } static void ufshcd_add_uic_command_trace(struct ufs_hba *hba, const struct uic_command *ucmd, enum ufs_trace_str_t str_t) { … } static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, enum ufs_trace_str_t str_t) { … } static void ufshcd_print_clk_freqs(struct ufs_hba *hba) { … } static void ufshcd_print_evt(struct ufs_hba *hba, u32 id, const char *err_name) { … } static void ufshcd_print_evt_hist(struct ufs_hba *hba) { … } static void ufshcd_print_tr(struct ufs_hba *hba, int tag, bool pr_prdt) { … } static bool ufshcd_print_tr_iter(struct request *req, void *priv) { … } /** * ufshcd_print_trs_all - print trs for all started requests. * @hba: per-adapter instance. * @pr_prdt: need to print prdt or not. */ static void ufshcd_print_trs_all(struct ufs_hba *hba, bool pr_prdt) { … } static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap) { … } static void ufshcd_print_host_state(struct ufs_hba *hba) { … } /** * ufshcd_print_pwr_info - print power params as saved in hba * power info * @hba: per-adapter instance */ static void ufshcd_print_pwr_info(struct ufs_hba *hba) { … } static void ufshcd_device_reset(struct ufs_hba *hba) { … } void ufshcd_delay_us(unsigned long us, unsigned long tolerance) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_wait_for_register - wait for register value to change * @hba: per-adapter interface * @reg: mmio register offset * @mask: mask to apply to the read register value * @val: value to wait for * @interval_us: polling interval in microseconds * @timeout_ms: timeout in milliseconds * * Return: -ETIMEDOUT on error, zero on success. */ static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, u32 val, unsigned long interval_us, unsigned long timeout_ms) { … } /** * ufshcd_get_intr_mask - Get the interrupt bit mask * @hba: Pointer to adapter instance * * Return: interrupt bit mask per version */ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba) { … } /** * ufshcd_get_ufs_version - Get the UFS version supported by the HBA * @hba: Pointer to adapter instance * * Return: UFSHCI version supported by the controller */ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba) { … } /** * ufshcd_is_device_present - Check if any device connected to * the host controller * @hba: pointer to adapter instance * * Return: true if device present, false if no device detected */ static inline bool ufshcd_is_device_present(struct ufs_hba *hba) { … } /** * ufshcd_get_tr_ocs - Get the UTRD Overall Command Status * @lrbp: pointer to local command reference block * @cqe: pointer to the completion queue entry * * This function is used to get the OCS field from UTRD * * Return: the OCS field in the UTRD. */ static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp, struct cq_entry *cqe) { … } /** * ufshcd_utrl_clear() - Clear requests from the controller request list. * @hba: per adapter instance * @mask: mask with one bit set for each request to be cleared */ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 mask) { … } /** * ufshcd_utmrl_clear - Clear a bit in UTMRLCLR register * @hba: per adapter instance * @pos: position of the bit to be cleared */ static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) { … } /** * ufshcd_get_lists_status - Check UCRDY, UTRLRDY and UTMRLRDY * @reg: Register value of host controller status * * Return: 0 on success; a positive value if failed. */ static inline int ufshcd_get_lists_status(u32 reg) { … } /** * ufshcd_get_uic_cmd_result - Get the UIC command result * @hba: Pointer to adapter instance * * This function gets the result of UIC command completion * * Return: 0 on success; non-zero value on error. */ static inline int ufshcd_get_uic_cmd_result(struct ufs_hba *hba) { … } /** * ufshcd_get_dme_attr_val - Get the value of attribute returned by UIC command * @hba: Pointer to adapter instance * * This function gets UIC command argument3 * * Return: 0 on success; non-zero value on error. */ static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba) { … } /** * ufshcd_get_req_rsp - returns the TR response transaction type * @ucd_rsp_ptr: pointer to response UPIU * * Return: UPIU type. */ static inline enum upiu_response_transaction ufshcd_get_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr) { … } /** * ufshcd_is_exception_event - Check if the device raised an exception event * @ucd_rsp_ptr: pointer to response UPIU * * The function checks if the device raised an exception event indicated in * the Device Information field of response UPIU. * * Return: true if exception is raised, false otherwise. */ static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr) { … } /** * ufshcd_reset_intr_aggr - Reset interrupt aggregation values. * @hba: per adapter instance */ static inline void ufshcd_reset_intr_aggr(struct ufs_hba *hba) { … } /** * ufshcd_config_intr_aggr - Configure interrupt aggregation values. * @hba: per adapter instance * @cnt: Interrupt aggregation counter threshold * @tmout: Interrupt aggregation timeout value */ static inline void ufshcd_config_intr_aggr(struct ufs_hba *hba, u8 cnt, u8 tmout) { … } /** * ufshcd_disable_intr_aggr - Disables interrupt aggregation. * @hba: per adapter instance */ static inline void ufshcd_disable_intr_aggr(struct ufs_hba *hba) { … } /** * ufshcd_enable_run_stop_reg - Enable run-stop registers, * When run-stop registers are set to 1, it indicates the * host controller that it can process the requests * @hba: per adapter instance */ static void ufshcd_enable_run_stop_reg(struct ufs_hba *hba) { … } /** * ufshcd_hba_start - Start controller initialization sequence * @hba: per adapter instance */ static inline void ufshcd_hba_start(struct ufs_hba *hba) { … } /** * ufshcd_is_hba_active - Get controller state * @hba: per adapter instance * * Return: true if and only if the controller is active. */ bool ufshcd_is_hba_active(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_pm_qos_init - initialize PM QoS request * @hba: per adapter instance */ void ufshcd_pm_qos_init(struct ufs_hba *hba) { … } /** * ufshcd_pm_qos_exit - remove request from PM QoS * @hba: per adapter instance */ void ufshcd_pm_qos_exit(struct ufs_hba *hba) { … } /** * ufshcd_pm_qos_update - update PM QoS request * @hba: per adapter instance * @on: If True, vote for perf PM QoS mode otherwise power save mode */ static void ufshcd_pm_qos_update(struct ufs_hba *hba, bool on) { … } /** * ufshcd_set_clk_freq - set UFS controller clock frequencies * @hba: per adapter instance * @scale_up: If True, set max possible frequency othewise set low frequency * * Return: 0 if successful; < 0 upon failure. */ static int ufshcd_set_clk_freq(struct ufs_hba *hba, bool scale_up) { … } int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, bool scaling_down) { … } EXPORT_SYMBOL_GPL(…); static int ufshcd_opp_set_rate(struct ufs_hba *hba, unsigned long freq) { … } /** * ufshcd_scale_clks - scale up or scale down UFS controller clocks * @hba: per adapter instance * @freq: frequency to scale * @scale_up: True if scaling up and false if scaling down * * Return: 0 if successful; < 0 upon failure. */ static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq, bool scale_up) { … } /** * ufshcd_is_devfreq_scaling_required - check if scaling is required or not * @hba: per adapter instance * @freq: frequency to scale * @scale_up: True if scaling up and false if scaling down * * Return: true if scaling is required, false otherwise. */ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba, unsigned long freq, bool scale_up) { … } /* * Determine the number of pending commands by counting the bits in the SCSI * device budget maps. This approach has been selected because a bit is set in * the budget map before scsi_host_queue_ready() checks the host_self_blocked * flag. The host_self_blocked flag can be modified by calling * scsi_block_requests() or scsi_unblock_requests(). */ static u32 ufshcd_pending_cmds(struct ufs_hba *hba) { … } /* * Wait until all pending SCSI commands and TMFs have finished or the timeout * has expired. * * Return: 0 upon success; -EBUSY upon timeout. */ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us) { … } /** * ufshcd_scale_gear - scale up/down UFS gear * @hba: per adapter instance * @scale_up: True for scaling up gear and false for scaling down * * Return: 0 for success; -EBUSY if scaling can't happen at this time; * non-zero for any other errors. */ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) { … } /* * Wait until all pending SCSI commands and TMFs have finished or the timeout * has expired. * * Return: 0 upon success; -EBUSY upon timeout. */ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us) { … } static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err, bool scale_up) { … } /** * ufshcd_devfreq_scale - scale up/down UFS clocks and gear * @hba: per adapter instance * @freq: frequency to scale * @scale_up: True for scaling up and false for scalin down * * Return: 0 for success; -EBUSY if scaling can't happen at this time; non-zero * for any other errors. */ static int ufshcd_devfreq_scale(struct ufs_hba *hba, unsigned long freq, bool scale_up) { … } static void ufshcd_clk_scaling_suspend_work(struct work_struct *work) { … } static void ufshcd_clk_scaling_resume_work(struct work_struct *work) { … } static int ufshcd_devfreq_target(struct device *dev, unsigned long *freq, u32 flags) { … } static int ufshcd_devfreq_get_dev_status(struct device *dev, struct devfreq_dev_status *stat) { … } static int ufshcd_devfreq_init(struct ufs_hba *hba) { … } static void ufshcd_devfreq_remove(struct ufs_hba *hba) { … } static void ufshcd_suspend_clkscaling(struct ufs_hba *hba) { … } static void ufshcd_resume_clkscaling(struct ufs_hba *hba) { … } static ssize_t ufshcd_clkscale_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static ssize_t ufshcd_clkscale_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { … } static void ufshcd_init_clk_scaling_sysfs(struct ufs_hba *hba) { … } static void ufshcd_remove_clk_scaling_sysfs(struct ufs_hba *hba) { … } static void ufshcd_init_clk_scaling(struct ufs_hba *hba) { … } static void ufshcd_exit_clk_scaling(struct ufs_hba *hba) { … } static void ufshcd_ungate_work(struct work_struct *work) { … } /** * ufshcd_hold - Enable clocks that were gated earlier due to ufshcd_release. * Also, exit from hibern8 mode and set the link as active. * @hba: per adapter instance */ void ufshcd_hold(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); static void ufshcd_gate_work(struct work_struct *work) { … } /* host lock must be held before calling this variant */ static void __ufshcd_release(struct ufs_hba *hba) { … } void ufshcd_release(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); static ssize_t ufshcd_clkgate_delay_show(struct device *dev, struct device_attribute *attr, char *buf) { … } void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value) { … } EXPORT_SYMBOL_GPL(…); static ssize_t ufshcd_clkgate_delay_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { … } static ssize_t ufshcd_clkgate_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static ssize_t ufshcd_clkgate_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { … } static void ufshcd_init_clk_gating_sysfs(struct ufs_hba *hba) { … } static void ufshcd_remove_clk_gating_sysfs(struct ufs_hba *hba) { … } static void ufshcd_init_clk_gating(struct ufs_hba *hba) { … } static void ufshcd_exit_clk_gating(struct ufs_hba *hba) { … } static void ufshcd_clk_scaling_start_busy(struct ufs_hba *hba) { … } static void ufshcd_clk_scaling_update_busy(struct ufs_hba *hba) { … } static inline int ufshcd_monitor_opcode2dir(u8 opcode) { … } static inline bool ufshcd_should_inform_monitor(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } static void ufshcd_start_monitor(struct ufs_hba *hba, const struct ufshcd_lrb *lrbp) { … } static void ufshcd_update_monitor(struct ufs_hba *hba, const struct ufshcd_lrb *lrbp) { … } /** * ufshcd_send_command - Send SCSI or device management commands * @hba: per adapter instance * @task_tag: Task tag of the command * @hwq: pointer to hardware queue instance */ static inline void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, struct ufs_hw_queue *hwq) { … } /** * ufshcd_copy_sense_data - Copy sense data in case of check condition * @lrbp: pointer to local reference block */ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) { … } /** * ufshcd_copy_query_response() - Copy the Query Response and the data * descriptor * @hba: per adapter instance * @lrbp: pointer to local reference block * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } /** * ufshcd_hba_capabilities - Read controller capabilities * @hba: per adapter instance * * Return: 0 on success, negative on error. */ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) { … } /** * ufshcd_ready_for_uic_cmd - Check if controller is ready * to accept UIC commands * @hba: per adapter instance * * Return: true on success, else false. */ static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba) { … } /** * ufshcd_get_upmcrs - Get the power mode change request status * @hba: Pointer to adapter instance * * This function gets the UPMCRS field of HCS register * * Return: value of UPMCRS field. */ static inline u8 ufshcd_get_upmcrs(struct ufs_hba *hba) { … } /** * ufshcd_dispatch_uic_cmd - Dispatch an UIC command to the Unipro layer * @hba: per adapter instance * @uic_cmd: UIC command */ static inline void ufshcd_dispatch_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { … } /** * ufshcd_wait_for_uic_cmd - Wait for completion of an UIC command * @hba: per adapter instance * @uic_cmd: UIC command * * Return: 0 only if success. */ static int ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { … } /** * __ufshcd_send_uic_cmd - Send UIC commands and retrieve the result * @hba: per adapter instance * @uic_cmd: UIC command * @completion: initialize the completion only if this is set to true * * Return: 0 only if success. */ static int __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, bool completion) { … } /** * ufshcd_send_uic_cmd - Send UIC commands and retrieve the result * @hba: per adapter instance * @uic_cmd: UIC command * * Return: 0 only if success. */ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { … } /** * ufshcd_sgl_to_prdt - SG list to PRTD (Physical Region Description Table, 4DW format) * @hba: per-adapter instance * @lrbp: pointer to local reference block * @sg_entries: The number of sg lists actually used * @sg_list: Pointer to SG list */ static void ufshcd_sgl_to_prdt(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, int sg_entries, struct scatterlist *sg_list) { … } /** * ufshcd_map_sg - Map scatter-gather list to prdt * @hba: per adapter instance * @lrbp: pointer to local reference block * * Return: 0 in case of success, non-zero value in case of failure. */ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } /** * ufshcd_enable_intr - enable interrupts * @hba: per adapter instance * @intrs: interrupt bits */ static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs) { … } /** * ufshcd_disable_intr - disable interrupts * @hba: per adapter instance * @intrs: interrupt bits */ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs) { … } /** * ufshcd_prepare_req_desc_hdr - Fill UTP Transfer request descriptor header according to request * descriptor according to request * @hba: per adapter instance * @lrbp: pointer to local reference block * @upiu_flags: flags required in the header * @cmd_dir: requests data direction * @ehs_length: Total EHS Length (in 32‐bytes units of all Extra Header Segments) */ static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, u8 *upiu_flags, enum dma_data_direction cmd_dir, int ehs_length) { … } /** * ufshcd_prepare_utp_scsi_cmd_upiu() - fills the utp_transfer_req_desc, * for scsi commands * @lrbp: local reference block pointer * @upiu_flags: flags */ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u8 upiu_flags) { … } /** * ufshcd_prepare_utp_query_req_upiu() - fill the utp_transfer_req_desc for query request * @hba: UFS hba * @lrbp: local reference block pointer * @upiu_flags: flags */ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, u8 upiu_flags) { … } static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp) { … } /** * ufshcd_compose_devman_upiu - UFS Protocol Information Unit(UPIU) * for Device Management Purposes * @hba: per adapter instance * @lrbp: pointer to local reference block * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } /** * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU) * for SCSI Purposes * @hba: per adapter instance * @lrbp: pointer to local reference block */ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } /** * ufshcd_upiu_wlun_to_scsi_wlun - maps UPIU W-LUN id to SCSI W-LUN ID * @upiu_wlun_id: UPIU W-LUN id * * Return: SCSI W-LUN id. */ static inline u16 ufshcd_upiu_wlun_to_scsi_wlun(u8 upiu_wlun_id) { … } static inline bool is_device_wlun(struct scsi_device *sdev) { … } /* * Associate the UFS controller queue with the default and poll HCTX types. * Initialize the mq_map[] arrays. */ static void ufshcd_map_queues(struct Scsi_Host *shost) { … } static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i) { … } /** * ufshcd_queuecommand - main entry point for SCSI requests * @host: SCSI host pointer * @cmd: command from SCSI Midlayer * * Return: 0 for success, non-zero in case of failure. */ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) { … } static void ufshcd_setup_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, u8 lun, int tag) { … } static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) { … } /* * Check with the block layer if the command is inflight * @cmd: command to check. * * Return: true if command is inflight; false if not. */ bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd) { … } /* * Clear the pending command in the controller and wait until * the controller confirms that the command has been cleared. * @hba: per adapter instance * @task_tag: The tag number of the command to be cleared. */ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) { … } /** * ufshcd_dev_cmd_completion() - handles device management command responses * @hba: per adapter instance * @lrbp: pointer to local reference block * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, int max_timeout) { … } static void ufshcd_dev_man_lock(struct ufs_hba *hba) { … } static void ufshcd_dev_man_unlock(struct ufs_hba *hba) { … } static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, const u32 tag, int timeout) { … } /** * ufshcd_exec_dev_cmd - API for sending device management requests * @hba: UFS hba * @cmd_type: specifies the type (NOP, Query...) * @timeout: timeout in milliseconds * * Return: 0 upon success; < 0 upon failure. * * NOTE: Since there is only one available tag for device management commands, * it is expected you hold the hba->dev_cmd.lock mutex. */ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, enum dev_cmd_type cmd_type, int timeout) { … } /** * ufshcd_init_query() - init the query response and request parameters * @hba: per-adapter instance * @request: address of the request pointer to be initialized * @response: address of the response pointer to be initialized * @opcode: operation to perform * @idn: flag idn to access * @index: LU number to access * @selector: query/flag/descriptor further identification */ static inline void ufshcd_init_query(struct ufs_hba *hba, struct ufs_query_req **request, struct ufs_query_res **response, enum query_opcode opcode, u8 idn, u8 index, u8 selector) { … } static int ufshcd_query_flag_retry(struct ufs_hba *hba, enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) { … } /** * ufshcd_query_flag() - API function for sending flag query requests * @hba: per-adapter instance * @opcode: flag query to perform * @idn: flag idn to access * @index: flag index to access * @flag_res: the flag value after the query request completes * * Return: 0 for success, non-zero in case of failure. */ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) { … } /** * ufshcd_query_attr - API function for sending attribute requests * @hba: per-adapter instance * @opcode: attribute opcode * @idn: attribute idn to access * @index: index field * @selector: selector field * @attr_val: the attribute value after the query request completes * * Return: 0 for success, non-zero in case of failure. */ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, u32 *attr_val) { … } /** * ufshcd_query_attr_retry() - API function for sending query * attribute with retries * @hba: per-adapter instance * @opcode: attribute opcode * @idn: attribute idn to access * @index: index field * @selector: selector field * @attr_val: the attribute value after the query request * completes * * Return: 0 for success, non-zero in case of failure. */ int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, u32 *attr_val) { … } static int __ufshcd_query_descriptor(struct ufs_hba *hba, enum query_opcode opcode, enum desc_idn idn, u8 index, u8 selector, u8 *desc_buf, int *buf_len) { … } /** * ufshcd_query_descriptor_retry - API function for sending descriptor requests * @hba: per-adapter instance * @opcode: attribute opcode * @idn: attribute idn to access * @index: index field * @selector: selector field * @desc_buf: the buffer that contains the descriptor * @buf_len: length parameter passed to the device * * The buf_len parameter will contain, on return, the length parameter * received on the response. * * Return: 0 for success, non-zero in case of failure. */ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, enum query_opcode opcode, enum desc_idn idn, u8 index, u8 selector, u8 *desc_buf, int *buf_len) { … } /** * ufshcd_read_desc_param - read the specified descriptor parameter * @hba: Pointer to adapter instance * @desc_id: descriptor idn value * @desc_index: descriptor index * @param_offset: offset of the parameter to read * @param_read_buf: pointer to buffer where parameter would be read * @param_size: sizeof(param_read_buf) * * Return: 0 in case of success, non-zero otherwise. */ int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id, int desc_index, u8 param_offset, u8 *param_read_buf, u8 param_size) { … } /** * struct uc_string_id - unicode string * * @len: size of this descriptor inclusive * @type: descriptor type * @uc: unicode string character */ struct uc_string_id { … } __packed; /* replace non-printable or non-ASCII characters with spaces */ static inline char ufshcd_remove_non_printable(u8 ch) { … } /** * ufshcd_read_string_desc - read string descriptor * @hba: pointer to adapter instance * @desc_index: descriptor index * @buf: pointer to buffer where descriptor would be read, * the caller should free the memory. * @ascii: if true convert from unicode to ascii characters * null terminated string. * * Return: * * string size on success. * * -ENOMEM: on allocation failure * * -EINVAL: on a wrong parameter */ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, bool ascii) { … } /** * ufshcd_read_unit_desc_param - read the specified unit descriptor parameter * @hba: Pointer to adapter instance * @lun: lun id * @param_offset: offset of the parameter to read * @param_read_buf: pointer to buffer where parameter would be read * @param_size: sizeof(param_read_buf) * * Return: 0 in case of success, non-zero otherwise. */ static inline int ufshcd_read_unit_desc_param(struct ufs_hba *hba, int lun, enum unit_desc_param param_offset, u8 *param_read_buf, u32 param_size) { … } static int ufshcd_get_ref_clk_gating_wait(struct ufs_hba *hba) { … } /** * ufshcd_memory_alloc - allocate memory for host memory space data structures * @hba: per adapter instance * * 1. Allocate DMA memory for Command Descriptor array * Each command descriptor consist of Command UPIU, Response UPIU and PRDT * 2. Allocate DMA memory for UTP Transfer Request Descriptor List (UTRDL). * 3. Allocate DMA memory for UTP Task Management Request Descriptor List * (UTMRDL) * 4. Allocate memory for local reference block(lrb). * * Return: 0 for success, non-zero in case of failure. */ static int ufshcd_memory_alloc(struct ufs_hba *hba) { … } /** * ufshcd_host_memory_configure - configure local reference block with * memory offsets * @hba: per adapter instance * * Configure Host memory space * 1. Update Corresponding UTRD.UCDBA and UTRD.UCDBAU with UCD DMA * address. * 2. Update each UTRD with Response UPIU offset, Response UPIU length * and PRDT offset. * 3. Save the corresponding addresses of UTRD, UCD.CMD, UCD.RSP and UCD.PRDT * into local reference block. */ static void ufshcd_host_memory_configure(struct ufs_hba *hba) { … } /** * ufshcd_dme_link_startup - Notify Unipro to perform link startup * @hba: per adapter instance * * UIC_CMD_DME_LINK_STARTUP command must be issued to Unipro layer, * in order to initialize the Unipro link startup procedure. * Once the Unipro links are up, the device connected to the controller * is detected. * * Return: 0 on success, non-zero value on failure. */ static int ufshcd_dme_link_startup(struct ufs_hba *hba) { … } /** * ufshcd_dme_reset - UIC command for DME_RESET * @hba: per adapter instance * * DME_RESET command is issued in order to reset UniPro stack. * This function now deals with cold reset. * * Return: 0 on success, non-zero value on failure. */ static int ufshcd_dme_reset(struct ufs_hba *hba) { … } int ufshcd_dme_configure_adapt(struct ufs_hba *hba, int agreed_gear, int adapt_val) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_dme_enable - UIC command for DME_ENABLE * @hba: per adapter instance * * DME_ENABLE command is issued in order to enable UniPro stack. * * Return: 0 on success, non-zero value on failure. */ static int ufshcd_dme_enable(struct ufs_hba *hba) { … } static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba) { … } /** * ufshcd_dme_set_attr - UIC command for DME_SET, DME_PEER_SET * @hba: per adapter instance * @attr_sel: uic command argument1 * @attr_set: attribute set type as uic command argument2 * @mib_val: setting value as uic command argument3 * @peer: indicate whether peer or local * * Return: 0 on success, non-zero value on failure. */ int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel, u8 attr_set, u32 mib_val, u8 peer) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_dme_get_attr - UIC command for DME_GET, DME_PEER_GET * @hba: per adapter instance * @attr_sel: uic command argument1 * @mib_val: the value of the attribute as returned by the UIC command * @peer: indicate whether peer or local * * Return: 0 on success, non-zero value on failure. */ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val, u8 peer) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power * state) and waits for it to take effect. * * @hba: per adapter instance * @cmd: UIC command to execute * * DME operations like DME_SET(PA_PWRMODE), DME_HIBERNATE_ENTER & * DME_HIBERNATE_EXIT commands take some time to take its effect on both host * and device UniPro link and hence it's final completion would be indicated by * dedicated status bits in Interrupt Status register (UPMS, UHES, UHXS) in * addition to normal UIC command completion Status (UCCS). This function only * returns after the relevant status bits indicate the completion. * * Return: 0 on success, non-zero value on failure. */ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) { … } /** * ufshcd_uic_change_pwr_mode - Perform the UIC power mode chage * using DME_SET primitives. * @hba: per adapter instance * @mode: powr mode value * * Return: 0 on success, non-zero value on failure. */ int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_link_recovery(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_uic_hibern8_enter(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_uic_hibern8_exit(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); static void ufshcd_configure_auto_hibern8(struct ufs_hba *hba) { … } void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_init_pwr_info - setting the POR (power on reset) * values in hba power info * @hba: per-adapter instance */ static void ufshcd_init_pwr_info(struct ufs_hba *hba) { … } /** * ufshcd_get_max_pwr_mode - reads the max power mode negotiated with device * @hba: per-adapter instance * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_get_max_pwr_mode(struct ufs_hba *hba) { … } static int ufshcd_change_power_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *pwr_mode) { … } /** * ufshcd_config_pwr_mode - configure a new power mode * @hba: per-adapter instance * @desired_pwr_mode: desired power configuration * * Return: 0 upon success; < 0 upon failure. */ int ufshcd_config_pwr_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *desired_pwr_mode) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_complete_dev_init() - checks device readiness * @hba: per-adapter instance * * Set fDeviceInit flag and poll until device toggles it. * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_complete_dev_init(struct ufs_hba *hba) { … } /** * ufshcd_make_hba_operational - Make UFS controller operational * @hba: per adapter instance * * To bring UFS host controller to operational state, * 1. Enable required interrupts * 2. Configure interrupt aggregation * 3. Program UTRL and UTMRL base address * 4. Configure run-stop-registers * * Return: 0 on success, non-zero value on failure. */ int ufshcd_make_hba_operational(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_hba_stop - Send controller to reset state * @hba: per adapter instance */ void ufshcd_hba_stop(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_hba_execute_hce - initialize the controller * @hba: per adapter instance * * The controller resets itself and controller firmware initialization * sequence kicks off. When controller is ready it will set * the Host Controller Enable bit to 1. * * Return: 0 on success, non-zero value on failure. */ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) { … } int ufshcd_hba_enable(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) { … } static inline int ufshcd_disable_device_tx_lcc(struct ufs_hba *hba) { … } void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_link_startup - Initialize unipro link startup * @hba: per adapter instance * * Return: 0 for success, non-zero in case of failure. */ static int ufshcd_link_startup(struct ufs_hba *hba) { … } /** * ufshcd_verify_dev_init() - Verify device initialization * @hba: per-adapter instance * * Send NOP OUT UPIU and wait for NOP IN response to check whether the * device Transport Protocol (UTP) layer is ready after a reset. * If the UTP layer at the device side is not initialized, it may * not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT * and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations. * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_verify_dev_init(struct ufs_hba *hba) { … } /** * ufshcd_setup_links - associate link b/w device wlun and other luns * @sdev: pointer to SCSI device * @hba: pointer to ufs hba */ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev) { … } /** * ufshcd_lu_init - Initialize the relevant parameters of the LU * @hba: per-adapter instance * @sdev: pointer to SCSI device */ static void ufshcd_lu_init(struct ufs_hba *hba, struct scsi_device *sdev) { … } /** * ufshcd_slave_alloc - handle initial SCSI device configurations * @sdev: pointer to SCSI device * * Return: success. */ static int ufshcd_slave_alloc(struct scsi_device *sdev) { … } /** * ufshcd_change_queue_depth - change queue depth * @sdev: pointer to SCSI device * @depth: required depth to set * * Change queue depth and make sure the max. limits are not crossed. * * Return: new queue depth. */ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) { … } /** * ufshcd_device_configure - adjust SCSI device configurations * @sdev: pointer to SCSI device * @lim: queue limits * * Return: 0 (success). */ static int ufshcd_device_configure(struct scsi_device *sdev, struct queue_limits *lim) { … } /** * ufshcd_slave_destroy - remove SCSI device configurations * @sdev: pointer to SCSI device */ static void ufshcd_slave_destroy(struct scsi_device *sdev) { … } /** * ufshcd_scsi_cmd_status - Update SCSI command result based on SCSI status * @lrbp: pointer to local reference block of completed command * @scsi_status: SCSI command status * * Return: value base on SCSI command status. */ static inline int ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status) { … } /** * ufshcd_transfer_rsp_status - Get overall status of the response * @hba: per adapter instance * @lrbp: pointer to local reference block of completed command * @cqe: pointer to the completion queue entry * * Return: result of the command to notify SCSI midlayer. */ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, struct cq_entry *cqe) { … } static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba, u32 intr_mask) { … } /** * ufshcd_uic_cmd_compl - handle completion of uic command * @hba: per adapter instance * @intr_status: interrupt status generated by the controller * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) { … } /* Release the resources allocated for processing a SCSI command. */ void ufshcd_release_scsi_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { … } /** * ufshcd_compl_one_cqe - handle a completion queue entry * @hba: per adapter instance * @task_tag: the task tag of the request to be completed * @cqe: pointer to the completion queue entry */ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, struct cq_entry *cqe) { … } /** * __ufshcd_transfer_req_compl - handle SCSI and query command completion * @hba: per adapter instance * @completed_reqs: bitmask that indicates which requests to complete */ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, unsigned long completed_reqs) { … } /* Any value that is not an existing queue number is fine for this constant. */ enum { … }; static void ufshcd_clear_polled(struct ufs_hba *hba, unsigned long *completed_reqs) { … } /* * Return: > 0 if one or more commands have been completed or 0 if no * requests have been completed. */ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num) { … } /** * ufshcd_mcq_compl_pending_transfer - MCQ mode function. It is * invoked from the error handler context or ufshcd_host_reset_and_restore() * to complete the pending transfers and free the resources associated with * the scsi command. * * @hba: per adapter instance * @force_compl: This flag is set to true when invoked * from ufshcd_host_reset_and_restore() in which case it requires special * handling because the host controller has been reset by ufshcd_hba_stop(). */ static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba, bool force_compl) { … } /** * ufshcd_transfer_req_compl - handle SCSI and query command completion * @hba: per adapter instance * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) { … } int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask) { … } int ufshcd_write_ee_control(struct ufs_hba *hba) { … } int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, const u16 *other_mask, u16 set, u16 clr) { … } /** * ufshcd_disable_ee - disable exception event * @hba: per-adapter instance * @mask: exception event to disable * * Disables exception event in the device so that the EVENT_ALERT * bit is not set. * * Return: zero on success, non-zero error value on failure. */ static inline int ufshcd_disable_ee(struct ufs_hba *hba, u16 mask) { … } /** * ufshcd_enable_ee - enable exception event * @hba: per-adapter instance * @mask: exception event to enable * * Enable corresponding exception event in the device to allow * device to alert host in critical scenarios. * * Return: zero on success, non-zero error value on failure. */ static inline int ufshcd_enable_ee(struct ufs_hba *hba, u16 mask) { … } /** * ufshcd_enable_auto_bkops - Allow device managed BKOPS * @hba: per-adapter instance * * Allow device to manage background operations on its own. Enabling * this might lead to inconsistent latencies during normal data transfers * as the device is allowed to manage its own way of handling background * operations. * * Return: zero on success, non-zero on failure. */ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba) { … } /** * ufshcd_disable_auto_bkops - block device in doing background operations * @hba: per-adapter instance * * Disabling background operations improves command response latency but * has drawback of device moving into critical state where the device is * not-operable. Make sure to call ufshcd_enable_auto_bkops() whenever the * host is idle so that BKOPS are managed effectively without any negative * impacts. * * Return: zero on success, non-zero on failure. */ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) { … } /** * ufshcd_force_reset_auto_bkops - force reset auto bkops state * @hba: per adapter instance * * After a device reset the device may toggle the BKOPS_EN flag * to default value. The s/w tracking variables should be updated * as well. This function would change the auto-bkops state based on * UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND. */ static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba) { … } static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status) { … } /** * ufshcd_bkops_ctrl - control the auto bkops based on current bkops status * @hba: per-adapter instance * * Read the bkops_status from the UFS device and Enable fBackgroundOpsEn * flag in the device to permit background operations if the device * bkops_status is greater than or equal to the "hba->urgent_bkops_lvl", * disable otherwise. * * Return: 0 for success, non-zero in case of failure. * * NOTE: Caller of this function can check the "hba->auto_bkops_enabled" flag * to know whether auto bkops is enabled or disabled after this function * returns control to it. */ static int ufshcd_bkops_ctrl(struct ufs_hba *hba) { … } static inline int ufshcd_get_ee_status(struct ufs_hba *hba, u32 *status) { … } static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) { … } static void ufshcd_temp_exception_event_handler(struct ufs_hba *hba, u16 status) { … } static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn) { … } int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable) { … } static void ufshcd_wb_toggle_buf_flush_during_h8(struct ufs_hba *hba, bool enable) { … } int ufshcd_wb_toggle_buf_flush(struct ufs_hba *hba, bool enable) { … } static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, u32 avail_buf) { … } static void ufshcd_wb_force_disable(struct ufs_hba *hba) { … } static bool ufshcd_is_wb_buf_lifetime_available(struct ufs_hba *hba) { … } static bool ufshcd_wb_need_flush(struct ufs_hba *hba) { … } static void ufshcd_rpm_dev_flush_recheck_work(struct work_struct *work) { … } /** * ufshcd_exception_event_handler - handle exceptions raised by device * @work: pointer to work data * * Read bExceptionEventStatus attribute from the device and handle the * exception event accordingly. */ static void ufshcd_exception_event_handler(struct work_struct *work) { … } /* Complete requests that have door-bell cleared */ static void ufshcd_complete_requests(struct ufs_hba *hba, bool force_compl) { … } /** * ufshcd_quirk_dl_nac_errors - This function checks if error handling is * to recover from the DL NAC errors or not. * @hba: per-adapter instance * * Return: true if error handling is required, false otherwise. */ static bool ufshcd_quirk_dl_nac_errors(struct ufs_hba *hba) { … } /* host lock must be held before calling this func */ static inline bool ufshcd_is_saved_err_fatal(struct ufs_hba *hba) { … } void ufshcd_schedule_eh_work(struct ufs_hba *hba) { … } static void ufshcd_force_error_recovery(struct ufs_hba *hba) { … } static void ufshcd_clk_scaling_allow(struct ufs_hba *hba, bool allow) { … } static void ufshcd_clk_scaling_suspend(struct ufs_hba *hba, bool suspend) { … } static void ufshcd_err_handling_prepare(struct ufs_hba *hba) { … } static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) { … } static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba) { … } #ifdef CONFIG_PM static void ufshcd_recover_pm_error(struct ufs_hba *hba) { … } #else static inline void ufshcd_recover_pm_error(struct ufs_hba *hba) { } #endif static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) { … } static bool ufshcd_abort_one(struct request *rq, void *priv) { … } /** * ufshcd_abort_all - Abort all pending commands. * @hba: Host bus adapter pointer. * * Return: true if and only if the host controller needs to be reset. */ static bool ufshcd_abort_all(struct ufs_hba *hba) { … } /** * ufshcd_err_handler - handle UFS errors that require s/w attention * @work: pointer to work structure */ static void ufshcd_err_handler(struct work_struct *work) { … } /** * ufshcd_update_uic_error - check and set fatal UIC error flags. * @hba: per-adapter instance * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) { … } /** * ufshcd_check_errors - Check for errors that need s/w attention * @hba: per-adapter instance * @intr_status: interrupt status generated by the controller * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status) { … } /** * ufshcd_tmc_handler - handle task management function completion * @hba: per adapter instance * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba) { … } /** * ufshcd_handle_mcq_cq_events - handle MCQ completion queue events * @hba: per adapter instance * * Return: IRQ_HANDLED if interrupt is handled. */ static irqreturn_t ufshcd_handle_mcq_cq_events(struct ufs_hba *hba) { … } /** * ufshcd_sl_intr - Interrupt service routine * @hba: per adapter instance * @intr_status: contains interrupts generated by the controller * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_sl_intr(struct ufs_hba *hba, u32 intr_status) { … } /** * ufshcd_intr - Main interrupt service routine * @irq: irq number * @__hba: pointer to adapter instance * * Return: * IRQ_HANDLED - If interrupt is valid * IRQ_NONE - If invalid interrupt */ static irqreturn_t ufshcd_intr(int irq, void *__hba) { … } static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) { … } static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, struct utp_task_req_desc *treq, u8 tm_function) { … } /** * ufshcd_issue_tm_cmd - issues task management commands to controller * @hba: per adapter instance * @lun_id: LUN ID to which TM command is sent * @task_id: task ID to which the TM command is applicable * @tm_function: task management function opcode * @tm_response: task management service response return value * * Return: non-zero value on error, zero on success. */ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, u8 tm_function, u8 *tm_response) { … } /** * ufshcd_issue_devman_upiu_cmd - API for sending "utrd" type requests * @hba: per-adapter instance * @req_upiu: upiu request * @rsp_upiu: upiu reply * @desc_buff: pointer to descriptor buffer, NULL if NA * @buff_len: descriptor size, 0 if NA * @cmd_type: specifies the type (NOP, Query...) * @desc_op: descriptor operation * * Those type of requests uses UTP Transfer Request Descriptor - utrd. * Therefore, it "rides" the device management infrastructure: uses its tag and * tasks work queues. * * Since there is only one available tag for device management commands, * the caller is expected to hold the hba->dev_cmd.lock mutex. * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, struct utp_upiu_req *rsp_upiu, u8 *desc_buff, int *buff_len, enum dev_cmd_type cmd_type, enum query_opcode desc_op) { … } /** * ufshcd_exec_raw_upiu_cmd - API function for sending raw upiu commands * @hba: per-adapter instance * @req_upiu: upiu request * @rsp_upiu: upiu reply - only 8 DW as we do not support scsi commands * @msgcode: message code, one of UPIU Transaction Codes Initiator to Target * @desc_buff: pointer to descriptor buffer, NULL if NA * @buff_len: descriptor size, 0 if NA * @desc_op: descriptor operation * * Supports UTP Transfer requests (nop and query), and UTP Task * Management requests. * It is up to the caller to fill the upiu conent properly, as it will * be copied without any further input validations. * * Return: 0 upon success; < 0 upon failure. */ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, struct utp_upiu_req *rsp_upiu, enum upiu_request_transaction msgcode, u8 *desc_buff, int *buff_len, enum query_opcode desc_op) { … } /** * ufshcd_advanced_rpmb_req_handler - handle advanced RPMB request * @hba: per adapter instance * @req_upiu: upiu request * @rsp_upiu: upiu reply * @req_ehs: EHS field which contains Advanced RPMB Request Message * @rsp_ehs: EHS field which returns Advanced RPMB Response Message * @sg_cnt: The number of sg lists actually used * @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation * @dir: DMA direction * * Return: zero on success, non-zero on failure. */ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, struct utp_upiu_req *rsp_upiu, struct ufs_ehs *req_ehs, struct ufs_ehs *rsp_ehs, int sg_cnt, struct scatterlist *sg_list, enum dma_data_direction dir) { … } /** * ufshcd_eh_device_reset_handler() - Reset a single logical unit. * @cmd: SCSI command pointer * * Return: SUCCESS or FAILED. */ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) { … } static void ufshcd_set_req_abort_skip(struct ufs_hba *hba, unsigned long bitmap) { … } /** * ufshcd_try_to_abort_task - abort a specific task * @hba: Pointer to adapter instance * @tag: Task tag/index to be aborted * * Abort the pending command in device by sending UFS_ABORT_TASK task management * command, and in host controller by clearing the door-bell register. There can * be race between controller sending the command to the device while abort is * issued. To avoid that, first issue UFS_QUERY_TASK to check if the command is * really issued and then try to abort it. * * Return: zero on success, non-zero on failure. */ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag) { … } /** * ufshcd_abort - scsi host template eh_abort_handler callback * @cmd: SCSI command pointer * * Return: SUCCESS or FAILED. */ static int ufshcd_abort(struct scsi_cmnd *cmd) { … } /** * ufshcd_host_reset_and_restore - reset and restore host controller * @hba: per-adapter instance * * Note that host controller reset may issue DME_RESET to * local and remote (device) Uni-Pro stack and the attributes * are reset to default state. * * Return: zero on success, non-zero on failure. */ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) { … } /** * ufshcd_reset_and_restore - reset and re-initialize host/device * @hba: per-adapter instance * * Reset and recover device, host and re-establish link. This * is helpful to recover the communication in fatal error conditions. * * Return: zero on success, non-zero on failure. */ static int ufshcd_reset_and_restore(struct ufs_hba *hba) { … } /** * ufshcd_eh_host_reset_handler - host reset handler registered to scsi layer * @cmd: SCSI command pointer * * Return: SUCCESS or FAILED. */ static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd) { … } /** * ufshcd_get_max_icc_level - calculate the ICC level * @sup_curr_uA: max. current supported by the regulator * @start_scan: row at the desc table to start scan from * @buff: power descriptor buffer * * Return: calculated max ICC level for specific regulator. */ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, const char *buff) { … } /** * ufshcd_find_max_sup_active_icc_level - calculate the max ICC level * In case regulators are not initialized we'll return 0 * @hba: per-adapter instance * @desc_buf: power descriptor buffer to extract ICC levels from. * * Return: calculated ICC level. */ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, const u8 *desc_buf) { … } static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba) { … } static inline void ufshcd_blk_pm_runtime_init(struct scsi_device *sdev) { … } /** * ufshcd_scsi_add_wlus - Adds required W-LUs * @hba: per-adapter instance * * UFS device specification requires the UFS devices to support 4 well known * logical units: * "REPORT_LUNS" (address: 01h) * "UFS Device" (address: 50h) * "RPMB" (address: 44h) * "BOOT" (address: 30h) * UFS device's power management needs to be controlled by "POWER CONDITION" * field of SSU (START STOP UNIT) command. But this "power condition" field * will take effect only when its sent to "UFS device" well known logical unit * hence we require the scsi_device instance to represent this logical unit in * order for the UFS host driver to send the SSU command for power management. * * We also require the scsi_device instance for "RPMB" (Replay Protected Memory * Block) LU so user space process can control this LU. User space may also * want to have access to BOOT LU. * * This function adds scsi device instances for each of all well known LUs * (except "REPORT LUNS" LU). * * Return: zero on success (all required W-LUs are added successfully), * non-zero error value on failure (if failed to add any of the required W-LU). */ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) { … } static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf) { … } static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf) { … } static void ufshcd_ext_iid_probe(struct ufs_hba *hba, u8 *desc_buf) { … } static void ufshcd_set_rtt(struct ufs_hba *hba) { … } void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, const struct ufs_dev_quirk *fixups) { … } EXPORT_SYMBOL_GPL(…); static void ufs_fixup_device_setup(struct ufs_hba *hba) { … } static void ufshcd_update_rtc(struct ufs_hba *hba) { … } static void ufshcd_rtc_work(struct work_struct *work) { … } static void ufs_init_rtc(struct ufs_hba *hba, u8 *desc_buf) { … } static int ufs_get_device_desc(struct ufs_hba *hba) { … } static void ufs_put_device_desc(struct ufs_hba *hba) { … } /** * ufshcd_quirk_tune_host_pa_tactivate - Ensures that host PA_TACTIVATE is * less than device PA_TACTIVATE time. * @hba: per-adapter instance * * Some UFS devices require host PA_TACTIVATE to be lower than device * PA_TACTIVATE, we need to enable UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE quirk * for such devices. * * Return: zero on success, non-zero error value on failure. */ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba) { … } static void ufshcd_tune_unipro_params(struct ufs_hba *hba) { … } static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba) { … } static int ufshcd_device_geo_params_init(struct ufs_hba *hba) { … } struct ufs_ref_clk { … }; static const struct ufs_ref_clk ufs_ref_clk_freqs[] = …; static enum ufs_ref_clk_freq ufs_get_bref_clk_from_hz(unsigned long freq) { … } void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk) { … } static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba) { … } static int ufshcd_device_params_init(struct ufs_hba *hba) { … } static void ufshcd_set_timestamp_attr(struct ufs_hba *hba) { … } /** * ufshcd_add_lus - probe and add UFS logical units * @hba: per-adapter instance * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_add_lus(struct ufs_hba *hba) { … } /* SDB - Single Doorbell */ static void ufshcd_release_sdb_queue(struct ufs_hba *hba, int nutrs) { … } static int ufshcd_alloc_mcq(struct ufs_hba *hba) { … } static void ufshcd_config_mcq(struct ufs_hba *hba) { … } static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) { … } /** * ufshcd_probe_hba - probe hba to detect device and initialize it * @hba: per-adapter instance * @init_dev_params: whether or not to call ufshcd_device_params_init(). * * Execute link-startup and verify device initialization * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) { … } /** * ufshcd_async_scan - asynchronous execution for probing hba * @data: data pointer to pass to this function * @cookie: cookie data */ static void ufshcd_async_scan(void *data, async_cookie_t cookie) { … } static enum scsi_timeout_action ufshcd_eh_timed_out(struct scsi_cmnd *scmd) { … } static const struct attribute_group *ufshcd_driver_groups[] = …; static struct ufs_hba_variant_params ufs_hba_vps = …; static const struct scsi_host_template ufshcd_driver_template = …; static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, int ua) { … } static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, struct ufs_vreg *vreg) { … } static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, struct ufs_vreg *vreg) { … } static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { … } static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg) { … } static int ufshcd_disable_vreg(struct device *dev, struct ufs_vreg *vreg) { … } static int ufshcd_setup_vreg(struct ufs_hba *hba, bool on) { … } static int ufshcd_setup_hba_vreg(struct ufs_hba *hba, bool on) { … } int ufshcd_get_vreg(struct device *dev, struct ufs_vreg *vreg) { … } EXPORT_SYMBOL_GPL(…); static int ufshcd_init_vreg(struct ufs_hba *hba) { … } static int ufshcd_init_hba_vreg(struct ufs_hba *hba) { … } static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on) { … } static enum ufs_ref_clk_freq ufshcd_parse_ref_clk_property(struct ufs_hba *hba) { … } static int ufshcd_init_clocks(struct ufs_hba *hba) { … } static int ufshcd_variant_hba_init(struct ufs_hba *hba) { … } static void ufshcd_variant_hba_exit(struct ufs_hba *hba) { … } static int ufshcd_hba_init(struct ufs_hba *hba) { … } static void ufshcd_hba_exit(struct ufs_hba *hba) { … } static int ufshcd_execute_start_stop(struct scsi_device *sdev, enum ufs_dev_pwr_mode pwr_mode, struct scsi_sense_hdr *sshdr) { … } /** * ufshcd_set_dev_pwr_mode - sends START STOP UNIT command to set device * power mode * @hba: per adapter instance * @pwr_mode: device power mode to set * * Return: 0 if requested power mode is set successfully; * < 0 if failed to set the requested power mode. */ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, enum ufs_dev_pwr_mode pwr_mode) { … } static int ufshcd_link_state_transition(struct ufs_hba *hba, enum uic_link_state req_link_state, bool check_for_bkops) { … } static void ufshcd_vreg_set_lpm(struct ufs_hba *hba) { … } #ifdef CONFIG_PM static int ufshcd_vreg_set_hpm(struct ufs_hba *hba) { … } #endif /* CONFIG_PM */ static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba) { … } static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba) { … } static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) { … } #ifdef CONFIG_PM static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) { … } static int ufshcd_wl_runtime_suspend(struct device *dev) { … } static int ufshcd_wl_runtime_resume(struct device *dev) { … } #endif #ifdef CONFIG_PM_SLEEP static int ufshcd_wl_suspend(struct device *dev) { … } static int ufshcd_wl_resume(struct device *dev) { … } #endif /** * ufshcd_suspend - helper function for suspend operations * @hba: per adapter instance * * This function will put disable irqs, turn off clocks * and set vreg and hba-vreg in lpm mode. * * Return: 0 upon success; < 0 upon failure. */ static int ufshcd_suspend(struct ufs_hba *hba) { … } #ifdef CONFIG_PM /** * ufshcd_resume - helper function for resume operations * @hba: per adapter instance * * This function basically turns on the regulators, clocks and * irqs of the hba. * * Return: 0 for success and non-zero for failure. */ static int ufshcd_resume(struct ufs_hba *hba) { … } #endif /* CONFIG_PM */ #ifdef CONFIG_PM_SLEEP /** * ufshcd_system_suspend - system suspend callback * @dev: Device associated with the UFS controller. * * Executed before putting the system into a sleep state in which the contents * of main memory are preserved. * * Return: 0 for success and non-zero for failure. */ int ufshcd_system_suspend(struct device *dev) { … } EXPORT_SYMBOL(…); /** * ufshcd_system_resume - system resume callback * @dev: Device associated with the UFS controller. * * Executed after waking the system up from a sleep state in which the contents * of main memory were preserved. * * Return: 0 for success and non-zero for failure. */ int ufshcd_system_resume(struct device *dev) { … } EXPORT_SYMBOL(…); #endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_PM /** * ufshcd_runtime_suspend - runtime suspend callback * @dev: Device associated with the UFS controller. * * Check the description of ufshcd_suspend() function for more details. * * Return: 0 for success and non-zero for failure. */ int ufshcd_runtime_suspend(struct device *dev) { … } EXPORT_SYMBOL(…); /** * ufshcd_runtime_resume - runtime resume routine * @dev: Device associated with the UFS controller. * * This function basically brings controller * to active state. Following operations are done in this function: * * 1. Turn on all the controller related clocks * 2. Turn ON VCC rail * * Return: 0 upon success; < 0 upon failure. */ int ufshcd_runtime_resume(struct device *dev) { … } EXPORT_SYMBOL(…); #endif /* CONFIG_PM */ static void ufshcd_wl_shutdown(struct device *dev) { … } /** * ufshcd_remove - de-allocate SCSI host and host memory space * data structure memory * @hba: per adapter instance */ void ufshcd_remove(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_PM_SLEEP int ufshcd_system_freeze(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_system_restore(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_system_thaw(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); #endif /* CONFIG_PM_SLEEP */ /** * ufshcd_dealloc_host - deallocate Host Bus Adapter (HBA) * @hba: pointer to Host Bus Adapter (HBA) */ void ufshcd_dealloc_host(struct ufs_hba *hba) { … } EXPORT_SYMBOL_GPL(…); /** * ufshcd_set_dma_mask - Set dma mask based on the controller * addressing capability * @hba: per adapter instance * * Return: 0 for success, non-zero for failure. */ static int ufshcd_set_dma_mask(struct ufs_hba *hba) { … } /** * ufshcd_alloc_host - allocate Host Bus Adapter (HBA) * @dev: pointer to device handle * @hba_handle: driver private handle * * Return: 0 on success, non-zero value on failure. */ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle) { … } EXPORT_SYMBOL(…); /* This function exists because blk_mq_alloc_tag_set() requires this. */ static blk_status_t ufshcd_queue_tmf(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *qd) { … } static const struct blk_mq_ops ufshcd_tmf_ops = …; /** * ufshcd_init - Driver initialization routine * @hba: per-adapter instance * @mmio_base: base register address * @irq: Interrupt line of device * * Return: 0 on success, non-zero value on failure. */ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) { … } EXPORT_SYMBOL_GPL(…); void ufshcd_resume_complete(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba) { … } int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm) { … } EXPORT_SYMBOL_GPL(…); int ufshcd_suspend_prepare(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_PM_SLEEP static int ufshcd_wl_poweroff(struct device *dev) { … } #endif static int ufshcd_wl_probe(struct device *dev) { … } static int ufshcd_wl_remove(struct device *dev) { … } static const struct dev_pm_ops ufshcd_wl_pm_ops = …; static void ufshcd_check_header_layout(void) { … } /* * ufs_dev_wlun_template - describes ufs device wlun * ufs-device wlun - used to send pm commands * All luns are consumers of ufs-device wlun. * * Currently, no sd driver is present for wluns. * Hence the no specific pm operations are performed. * With ufs design, SSU should be sent to ufs-device wlun. * Hence register a scsi driver for ufs wluns only. */ static struct scsi_driver ufs_dev_wlun_template = …; static int __init ufshcd_core_init(void) { … } static void __exit ufshcd_core_exit(void) { … } module_init(…) …; module_exit(ufshcd_core_exit); MODULE_AUTHOR(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_SOFTDEP(…) …; MODULE_LICENSE(…) …;