Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41029bb5 authored by Asutosh Das's avatar Asutosh Das
Browse files

scsi: ufs-qti: port UFS driver changes for QTI configuration



This is a snapshot of UFS driver taken as of msm-4.19 commit
<06d5054c2859> ("scsi: ufs: Remove UFS card support").
This change adapts to several upstream functions.
Some obsolete downstream changes are dropped.

Change-Id: Ib34f0d90ff683b1e7246cc9ec70375e994685e0c
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
parent 273a2b07
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
obj-$(CONFIG_MEGARAID_SAS)	+= megaraid/
obj-$(CONFIG_SCSI_MPT3SAS)	+= mpt3sas/
obj-$(CONFIG_SCSI_UFSHCD)	+= ufs/
obj-$(CONFIG_SCSI_UFSHCD_QTI)	+= ufs/
obj-$(CONFIG_SCSI_ACARD)	+= atp870u.o
obj-$(CONFIG_SCSI_SUNESP)	+= esp_scsi.o	sun_esp.o
obj-$(CONFIG_SCSI_GDTH)		+= gdth.o
+3 −0
Original line number Diff line number Diff line
@@ -11,4 +11,7 @@ obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o
obj-$(CONFIG_SCSI_UFSHCD_QTI) += ufshcd-qti-core.o
ufshcd-qti-core-y		+= ufshcd-qti.o ufs-sysfs.o
ufshcd-qti-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO) += ufshcd-crypto.o
+36 −0
Original line number Diff line number Diff line
@@ -40,6 +40,11 @@
#include <linux/types.h>
#include <uapi/scsi/scsi_bsg_ufs.h>

#ifdef CONFIG_SCSI_UFSHCD_QTI
#define MAX_QUERY_IDN		0x12
#define MAX_CDB_SIZE		16
#endif

#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))
#define QUERY_DESC_MAX_SIZE       255
#define QUERY_DESC_MIN_SIZE       2
@@ -168,6 +173,7 @@ enum attr_idn {
	QUERY_ATTR_IDN_FFU_STATUS		= 0x14,
	QUERY_ATTR_IDN_PSA_STATE		= 0x15,
	QUERY_ATTR_IDN_PSA_DATA_SIZE		= 0x16,
	QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME = 0x17,
};

/* Descriptor idn for Query requests */
@@ -376,6 +382,9 @@ enum query_opcode {
	UPIU_QUERY_OPCODE_SET_FLAG	= 0x6,
	UPIU_QUERY_OPCODE_CLEAR_FLAG	= 0x7,
	UPIU_QUERY_OPCODE_TOGGLE_FLAG	= 0x8,
#ifdef CONFIG_SCSI_UFSHCD_QTI
	UPIU_QUERY_OPCODE_MAX,
#endif
};

/* bRefClkFreq attribute values */
@@ -517,6 +526,13 @@ struct ufs_vreg {
	int min_uV;
	int max_uV;
	int max_uA;
#ifdef CONFIG_SCSI_UFSHCD_QTI
	bool low_voltage_sup;
	bool low_voltage_active;
	bool sys_suspend_pwr_off;
	int min_uA;
	bool unused;
#endif
};

struct ufs_vreg_info {
@@ -526,10 +542,27 @@ struct ufs_vreg_info {
	struct ufs_vreg *vdd_hba;
};

#ifdef CONFIG_SCSI_UFSHCD_QTI
enum {
	UFS_DEV_EMBEDDED_BOOTABLE = 0x00,
	UFS_DEV_EMBEDDED_NON_BOOTABLE = 0x01,
	UFS_DEV_REMOVABLE_BOOTABLE = 0x02,
	UFS_DEV_REMOVABLE_NON_BOOTABLE = 0x03,
};
#endif

struct ufs_dev_info {
	bool f_power_on_wp_en;
	/* Keeps information if any of the LU is power on write protected */
	bool is_lu_power_on_wp;
#ifdef CONFIG_SCSI_UFSHCD_QTI
	u8 b_device_sub_class;
	u16 w_spec_version;
	u16 w_manufacturer_id;
	u8 i_product_name;
	/* is Unit Attention Condition cleared on UFS Device LUN? */
	unsigned is_ufs_dev_wlun_ua_cleared:1;
#endif
};

#define MAX_MODEL_LEN 16
@@ -542,6 +575,9 @@ struct ufs_dev_info {
struct ufs_dev_desc {
	u16 wmanufacturerid;
	u8 *model;
#ifdef CONFIG_SCSI_UFSHCD_QTI
	u16 wspecversion;
#endif
};

/**
+55 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
 */

#ifndef _UFS_QUIRKS_H_
@@ -15,6 +15,9 @@
#define UFS_VENDOR_TOSHIBA     0x198
#define UFS_VENDOR_SAMSUNG     0x1CE
#define UFS_VENDOR_SKHYNIX     0x1AD
#ifdef CONFIG_SCSI_UFSHCD_QTI
#define UFS_VENDOR_WDC         0x145
#endif

/**
 * ufs_dev_fix - ufs device quirk info
@@ -35,6 +38,23 @@ struct ufs_dev_fix {
	.quirk = (_quirk),		   \
}

#ifdef CONFIG_SCSI_UFSHCD_QTI
/*
 * If UFS device is having issue in processing LCC (Line Control
 * Command) coming from UFS host controller then enable this quirk.
 * When this quirk is enabled, host controller driver should disable
 * the LCC transmission on UFS host controller (by clearing
 * TX_LCC_ENABLE attribute of host to 0).
 */
#define UFS_DEVICE_QUIRK_BROKEN_LCC (1 << 0)

/*
 * Some UFS devices don't need VCCQ rail for device operations. Enabling this
 * quirk for such devices will make sure that VCCQ rail is not voted.
 */
#define UFS_DEVICE_NO_VCCQ (1 << 1)
#endif

/*
 * Some vendor's UFS device sends back to back NACs for the DL data frames
 * causing the host controller to raise the DFES error status. Sometimes
@@ -69,6 +89,15 @@ struct ufs_dev_fix {
 */
#define UFS_DEVICE_QUIRK_PA_TACTIVATE	(1 << 4)

#ifdef CONFIG_SCSI_UFSHCD_QTI
/*
 * Some UFS memory devices may have really low read/write throughput in
 * FAST AUTO mode, enable this quirk to make sure that FAST AUTO mode is
 * never enabled for such devices.
 */
#define UFS_DEVICE_NO_FASTAUTO		(1 << 5)
#endif

/*
 * It seems some UFS devices may keep drawing more than sleep current
 * (atleast for 500us) from UFS rails (especially from VCCQ rail).
@@ -99,4 +128,29 @@ struct ufs_dev_fix {
 */
#define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME	(1 << 9)

#ifdef CONFIG_SCSI_UFSHCD_QTI
/*
 * Some UFS devices may stop responding after switching from HS-G1 to HS-G3.
 * Also, it is found that these devices work fine if we do 2 steps switch:
 * HS-G1 to HS-G2 followed by HS-G2 to HS-G3. Enabling this quirk for such
 * device would apply this 2 steps gear switch workaround.
 */
#define UFS_DEVICE_QUIRK_HS_G1_TO_HS_G3_SWITCH		(1 << 10)

/*
 * Some UFS devices need more delay after device reference clk is turned on
 * but before initiation of the state transition to STALL from a LS-MODE or
 * from the HIBERN8 state. Enable this quirk to give UFS devices 50us delay
 * instead of the default delay.
 */
#define UFS_DEVICE_QUIRK_WAIT_AFTER_REF_CLK_UNGATE	(1 << 11)

/*
 * Some UFS devices may not work properly after resume if the link was kept
 * in off state during suspend. Enabling this quirk will not allow the
 * link to be kept in off state during suspend.
 */
#define UFS_DEVICE_QUIRK_NO_LINK_OFF	(1 << 13)

#endif
#endif /* UFS_QUIRKS_H_ */
+10096 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading