diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c index 1aea9c2d6d..baa0dc60ad 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.c +++ b/drivers/phy/samsung/phy-samsung-ufs.c @@ -34,6 +34,12 @@ void samsung_ufs_phy_config(struct samsung_ufs_phy *phy, { enum {LANE_0, LANE_1}; /* lane index */ + if (cfg->id == PHY_DELAY_BLK) { + if (lane == LANE_0) + udelay(cfg->val); + return; + } + switch (lane) { case LANE_0: writel(cfg->val, (phy)->reg_pma + cfg->off_0); diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h index e1a41df26e..1270f5e303 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.h +++ b/drivers/phy/samsung/phy-samsung-ufs.h @@ -15,6 +15,7 @@ #define PHY_COMN_BLK 1 #define PHY_TRSV_BLK 2 +#define PHY_DELAY_BLK 3 #define END_UFS_PHY_CFG { 0 } #define PHY_TRSV_CH_OFFSET 0x30 #define PHY_APB_ADDR(off) ((off) << 2) @@ -38,6 +39,12 @@ #define PHY_TRSV_REG_CFG(o, v, d) \ PHY_TRSV_REG_CFG_OFFSET(o, v, d, PHY_TRSV_CH_OFFSET) +/* Wait @us microseconds before the next entry of a table, once for all lanes. */ +#define PHY_DELAY_US_CFG(us) { \ + .val = (us), \ + .id = PHY_DELAY_BLK, \ +} + /* UFS PHY registers */ #define PHY_PLL_LOCK_STATUS 0x1e diff --git a/drivers/phy/samsung/phy-zumapro-ufs.c b/drivers/phy/samsung/phy-zumapro-ufs.c index 899a327f5e..195342435b 100644 --- a/drivers/phy/samsung/phy-zumapro-ufs.c +++ b/drivers/phy/samsung/phy-zumapro-ufs.c @@ -56,10 +56,36 @@ static const struct samsung_ufs_phy_cfg zumapro_pre_init[] = { END_UFS_PHY_CFG, }; +/* Google's post_h8_enter: after the link has entered Hibern8. */ +static const struct samsung_ufs_phy_cfg zumapro_post_h8_enter[] = { + PHY_TRSV_REG_CFG_OFFSET(0x27d, 0x08, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x280, 0x3a, PWR_MODE_ANY, 0x200), + PHY_COMN_REG_CFG(0x000, 0x51, PWR_MODE_ANY), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x30, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x33, PWR_MODE_ANY, 0x200), + END_UFS_PHY_CFG, +}; + +/* Google's pre_h8_exit: before the link leaves Hibern8. */ +static const struct samsung_ufs_phy_cfg zumapro_pre_h8_exit[] = { + PHY_COMN_REG_CFG(0x000, 0x11, PWR_MODE_ANY), + PHY_DELAY_US_CFG(10), + PHY_TRSV_REG_CFG_OFFSET(0x27d, 0x00, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x280, 0x30, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x32, PWR_MODE_ANY, 0x200), + PHY_TRSV_REG_CFG_OFFSET(0x2d9, 0x22, PWR_MODE_ANY, 0x200), + END_UFS_PHY_CFG, +}; + static const struct samsung_ufs_phy_cfg *zumapro_cfgs[CFG_TAG_MAX] = { [CFG_PRE_INIT] = zumapro_pre_init, }; +static const struct samsung_ufs_phy_cfg *zumapro_hibern8_cfgs[] = { + [CFG_POST_HIBERN8_ENTER] = zumapro_post_h8_enter, + [CFG_PRE_HIBERN8_EXIT] = zumapro_pre_h8_exit, +}; + static const char * const zumapro_clks[] = { "ref_clk" }; static int zumapro_wait_for_cal(struct phy *phy, u8 lane) @@ -79,6 +105,7 @@ static int zumapro_wait_for_cal(struct phy *phy, u8 lane) const struct samsung_ufs_phy_drvdata tensor_zumapro_ufs_phy = { .cfgs = zumapro_cfgs, + .cfgs_hibern8 = zumapro_hibern8_cfgs, .isol = { .offset = 0x3ec0, .mask = BIT(0), diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index 61078ad79c..5a4b13db29 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -266,7 +266,7 @@ static int gs201_ufs_drv_init(struct exynos_ufs *ufs) return gs101_ufs_drv_init(ufs); } -static int zumapro_ufs_drv_init(struct exynos_ufs *ufs) +static int zuma_ufs_drv_init(struct exynos_ufs *ufs) { u32 reg; @@ -278,6 +278,18 @@ static int zumapro_ufs_drv_init(struct exynos_ufs *ufs) return exynos_ufs_shareability(ufs); } +static int zumapro_ufs_drv_init(struct exynos_ufs *ufs) +{ + /* + * Idle clock gating with the link in Hibern8, as on gs101 and gs201: + * it also drops the CPU latency request the core holds while the + * clocks are on. + */ + ufs->hba->caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING; + + return zuma_ufs_drv_init(ufs); +} + static int exynosauto_ufs_drv_init(struct exynos_ufs *ufs) { return exynos_ufs_shareability(ufs); @@ -2545,7 +2557,28 @@ static const struct exynos_ufs_drv_data gs201_ufs_drvs = { .suspend = gs101_ufs_suspend, }; -/* G4 shares the G2 descriptor format, but not its PHY/PCS calibration. */ +/* + * G3 and G4 share the G2 descriptor format, but not its PHY/PCS calibration. + * G3 (zuma) runs the G4 data, which its device tree names as a fallback. + */ +static const struct exynos_ufs_drv_data zuma_ufs_drvs = { + .uic_attr = &gs101_uic_attr, + .quirks = UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | + UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8 | + UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING, + .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR | + EXYNOS_UFS_OPT_UFSPR_SECURE | + EXYNOS_UFS_OPT_TIMER_TICK_SELECT | + EXYNOS_UFS_OPT_CLKSTOP_PRE_CHANGE | + EXYNOS_UFS_OPT_UNGATE_POST_CHANGE, + .iocc_mask = UFS_GS101_SHARABLE, + .drv_init = zuma_ufs_drv_init, + .suspend = gs101_ufs_suspend, + .pre_link = zumapro_ufs_pre_link, + .post_link = zumapro_ufs_post_link, + .pre_pwr_change = zumapro_ufs_pre_pwr_change, +}; + static const struct exynos_ufs_drv_data zumapro_ufs_drvs = { .uic_attr = &gs101_uic_attr, .quirks = UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | @@ -2584,6 +2617,8 @@ static const struct of_device_id exynos_ufs_of_match[] = { .data = &gs101_ufs_drvs }, { .compatible = "google,gs201-ufs", .data = &gs201_ufs_drvs }, + { .compatible = "google,zuma-ufs", + .data = &zuma_ufs_drvs }, { .compatible = "google,zumapro-ufs", .data = &zumapro_ufs_drvs }, { .compatible = "samsung,exynos7-ufs",