2019-03-16 13:04:47 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 MediaTek Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UFS_MEDIATEK_H
|
|
|
|
#define _UFS_MEDIATEK_H
|
|
|
|
|
2019-12-30 13:32:26 +08:00
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/soc/mediatek/mtk_sip_svc.h>
|
|
|
|
|
2019-12-30 13:32:27 +08:00
|
|
|
/*
|
|
|
|
* Vendor specific UFSHCI Registers
|
|
|
|
*/
|
|
|
|
#define REG_UFS_REFCLK_CTRL 0x144
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ref-clk control
|
|
|
|
*
|
|
|
|
* Values for register REG_UFS_REFCLK_CTRL
|
|
|
|
*/
|
|
|
|
#define REFCLK_RELEASE 0x0
|
|
|
|
#define REFCLK_REQUEST BIT(0)
|
|
|
|
#define REFCLK_ACK BIT(1)
|
|
|
|
|
|
|
|
#define REFCLK_REQ_TIMEOUT_MS 3
|
|
|
|
|
2019-03-16 13:04:47 +08:00
|
|
|
/*
|
|
|
|
* Vendor specific pre-defined parameters
|
|
|
|
*/
|
|
|
|
#define UFS_MTK_LIMIT_NUM_LANES_RX 1
|
|
|
|
#define UFS_MTK_LIMIT_NUM_LANES_TX 1
|
|
|
|
#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
|
|
|
|
|
2019-12-30 13:32:26 +08:00
|
|
|
/*
|
|
|
|
* SiP commands
|
|
|
|
*/
|
2019-12-30 13:32:27 +08:00
|
|
|
#define MTK_SIP_UFS_CONTROL MTK_SIP_SMC_CMD(0x276)
|
|
|
|
#define UFS_MTK_SIP_DEVICE_RESET BIT(1)
|
|
|
|
#define UFS_MTK_SIP_REF_CLK_NOTIFICATION BIT(3)
|
2019-12-30 13:32:26 +08:00
|
|
|
|
2019-03-16 13:04:47 +08: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,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_mtk_host {
|
|
|
|
struct ufs_hba *hba;
|
|
|
|
struct phy *mphy;
|
2019-12-30 13:32:27 +08:00
|
|
|
bool ref_clk_enabled;
|
2019-03-16 13:04:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !_UFS_MEDIATEK_H */
|