2019-03-16 08:04:47 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 MediaTek Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UFS_MEDIATEK_H
|
|
|
|
#define _UFS_MEDIATEK_H
|
|
|
|
|
2019-12-30 08:32:26 +03:00
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/soc/mediatek/mtk_sip_svc.h>
|
|
|
|
|
2019-12-30 08:32:27 +03:00
|
|
|
/*
|
|
|
|
* Vendor specific UFSHCI Registers
|
|
|
|
*/
|
|
|
|
#define REG_UFS_REFCLK_CTRL 0x144
|
2020-01-17 06:51:06 +03:00
|
|
|
#define REG_UFS_EXTREG 0x2100
|
|
|
|
#define REG_UFS_MPHYCTRL 0x2200
|
|
|
|
#define REG_UFS_REJECT_MON 0x22AC
|
|
|
|
#define REG_UFS_DEBUG_SEL 0x22C0
|
|
|
|
#define REG_UFS_PROBE 0x22C8
|
2019-12-30 08:32:27 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ref-clk control
|
|
|
|
*
|
|
|
|
* Values for register REG_UFS_REFCLK_CTRL
|
|
|
|
*/
|
|
|
|
#define REFCLK_RELEASE 0x0
|
|
|
|
#define REFCLK_REQUEST BIT(0)
|
|
|
|
#define REFCLK_ACK BIT(1)
|
|
|
|
|
2020-06-01 13:46:42 +03:00
|
|
|
#define REFCLK_REQ_TIMEOUT_US 3000
|
2019-12-30 08:32:27 +03:00
|
|
|
|
2019-03-16 08:04:47 +03:00
|
|
|
/*
|
|
|
|
* Vendor specific pre-defined parameters
|
|
|
|
*/
|
2020-08-19 11:43:40 +03:00
|
|
|
#define UFS_MTK_LIMIT_NUM_LANES_RX 2
|
|
|
|
#define UFS_MTK_LIMIT_NUM_LANES_TX 2
|
2019-03-16 08:04:47 +03:00
|
|
|
#define UFS_MTK_LIMIT_HSGEAR_RX UFS_HS_G3
|
|
|
|
#define UFS_MTK_LIMIT_HSGEAR_TX UFS_HS_G3
|
|
|
|
#define UFS_MTK_LIMIT_PWMGEAR_RX UFS_PWM_G4
|
|
|
|
#define UFS_MTK_LIMIT_PWMGEAR_TX UFS_PWM_G4
|
|
|
|
#define UFS_MTK_LIMIT_RX_PWR_PWM SLOW_MODE
|
|
|
|
#define UFS_MTK_LIMIT_TX_PWR_PWM SLOW_MODE
|
|
|
|
#define UFS_MTK_LIMIT_RX_PWR_HS FAST_MODE
|
|
|
|
#define UFS_MTK_LIMIT_TX_PWR_HS FAST_MODE
|
|
|
|
#define UFS_MTK_LIMIT_HS_RATE PA_HS_MODE_B
|
|
|
|
#define UFS_MTK_LIMIT_DESIRED_MODE UFS_HS_MODE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Other attributes
|
|
|
|
*/
|
|
|
|
#define VS_DEBUGCLOCKENABLE 0xD0A1
|
|
|
|
#define VS_SAVEPOWERCONTROL 0xD0A6
|
|
|
|
#define VS_UNIPROPOWERDOWNCONTROL 0xD0A8
|
|
|
|
|
2020-01-29 13:52:51 +03:00
|
|
|
/*
|
|
|
|
* Vendor specific link state
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
VS_LINK_DISABLED = 0,
|
|
|
|
VS_LINK_DOWN = 1,
|
|
|
|
VS_LINK_UP = 2,
|
|
|
|
VS_LINK_HIBERN8 = 3,
|
|
|
|
VS_LINK_LOST = 4,
|
|
|
|
VS_LINK_CFG = 5,
|
|
|
|
};
|
|
|
|
|
2019-12-30 08:32:26 +03:00
|
|
|
/*
|
|
|
|
* SiP commands
|
|
|
|
*/
|
2019-12-30 08:32:27 +03:00
|
|
|
#define MTK_SIP_UFS_CONTROL MTK_SIP_SMC_CMD(0x276)
|
|
|
|
#define UFS_MTK_SIP_DEVICE_RESET BIT(1)
|
2020-07-12 03:32:26 +03:00
|
|
|
#define UFS_MTK_SIP_CRYPTO_CTRL BIT(2)
|
2019-12-30 08:32:27 +03:00
|
|
|
#define UFS_MTK_SIP_REF_CLK_NOTIFICATION BIT(3)
|
2019-12-30 08:32:26 +03:00
|
|
|
|
2019-03-16 08:04:47 +03:00
|
|
|
/*
|
|
|
|
* VS_DEBUGCLOCKENABLE
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
TX_SYMBOL_CLK_REQ_FORCE = 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VS_SAVEPOWERCONTROL
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
RX_SYMBOL_CLK_GATE_EN = 0,
|
|
|
|
SYS_CLK_GATE_EN = 2,
|
|
|
|
TX_CLK_GATE_EN = 3,
|
|
|
|
};
|
|
|
|
|
2020-09-14 08:00:51 +03:00
|
|
|
/*
|
|
|
|
* Host capability
|
|
|
|
*/
|
|
|
|
enum ufs_mtk_host_caps {
|
|
|
|
UFS_MTK_CAP_BOOST_CRYPT_ENGINE = 1 << 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_mtk_crypt_cfg {
|
|
|
|
struct regulator *reg_vcore;
|
|
|
|
struct clk *clk_crypt_perf;
|
|
|
|
struct clk *clk_crypt_mux;
|
|
|
|
struct clk *clk_crypt_lp;
|
|
|
|
int vcore_volt;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_mtk_host_cfg {
|
|
|
|
enum ufs_mtk_host_caps caps;
|
|
|
|
};
|
|
|
|
|
2019-03-16 08:04:47 +03:00
|
|
|
struct ufs_mtk_host {
|
|
|
|
struct ufs_hba *hba;
|
|
|
|
struct phy *mphy;
|
2020-09-14 08:00:51 +03:00
|
|
|
struct ufs_mtk_host_cfg *cfg;
|
|
|
|
struct ufs_mtk_crypt_cfg *crypt;
|
|
|
|
enum ufs_mtk_host_caps caps;
|
2020-09-08 09:45:07 +03:00
|
|
|
struct reset_control *hci_reset;
|
|
|
|
struct reset_control *unipro_reset;
|
|
|
|
struct reset_control *crypto_reset;
|
2020-06-01 13:46:45 +03:00
|
|
|
bool mphy_powered_on;
|
2020-03-18 13:40:16 +03:00
|
|
|
bool unipro_lpm;
|
2019-12-30 08:32:27 +03:00
|
|
|
bool ref_clk_enabled;
|
2020-02-20 16:48:48 +03:00
|
|
|
u16 ref_clk_ungating_wait_us;
|
|
|
|
u16 ref_clk_gating_wait_us;
|
2019-03-16 08:04:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !_UFS_MEDIATEK_H */
|