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

Commit 81c4256b authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "scsi: ufs: Fix phy init sequence"

parents c5d20367 9d4ff08f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -1562,10 +1562,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
		return 0;

	if (on && (status == POST_CHANGE)) {
		if (!host->is_phy_pwr_on) {
			phy_power_on(host->generic_phy);
			host->is_phy_pwr_on = true;
		}
		/* enable the device ref clock for HS mode*/
		if (ufshcd_is_hs_mode(&hba->pwr_info))
			ufs_qcom_dev_ref_clk_ctrl(host, true);
@@ -1580,10 +1576,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
			/* disable device ref_clk */
			ufs_qcom_dev_ref_clk_ctrl(host, false);
			/* powering off PHY during aggressive clk gating */
			if (host->is_phy_pwr_on) {
				phy_power_off(host->generic_phy);
				host->is_phy_pwr_on = false;
			}
		}


+0 −1
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
		return -ENOMEM;

	vreg->name = kstrdup(name, GFP_KERNEL);

	snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
	if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
		dev_info(dev, "%s: unable to find %s\n", __func__, prop_name);
+4 −112
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2019, Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2020, Linux Foundation. All rights reserved.
 */

#include <linux/async.h>
@@ -463,63 +463,6 @@ void ufshcd_scsi_block_requests(struct ufs_hba *hba)
}
EXPORT_SYMBOL(ufshcd_scsi_block_requests);

static int ufshcd_device_reset_ctrl(struct ufs_hba *hba, bool ctrl)
{
	int ret = 0;

	if (!hba->pctrl)
		return 0;

	/* Assert reset if ctrl == true */
	if (ctrl)
		ret = pinctrl_select_state(hba->pctrl,
			pinctrl_lookup_state(hba->pctrl, "dev-reset-assert"));
	else
		ret = pinctrl_select_state(hba->pctrl,
			pinctrl_lookup_state(hba->pctrl, "dev-reset-deassert"));

	if (ret < 0)
		dev_err(hba->dev, "%s: %s failed with err %d\n",
			__func__, ctrl ? "Assert" : "Deassert", ret);

	return ret;
}

static inline int ufshcd_assert_device_reset(struct ufs_hba *hba)
{
	return ufshcd_device_reset_ctrl(hba, true);
}

static inline int ufshcd_deassert_device_reset(struct ufs_hba *hba)
{
	return ufshcd_device_reset_ctrl(hba, false);
}

static int ufshcd_reset_device(struct ufs_hba *hba)
{
	int ret;

	/* reset the connected UFS device */
	ret = ufshcd_assert_device_reset(hba);
	if (ret)
		goto out;
	/*
	 * The reset signal is active low.
	 * The UFS device shall detect more than or equal to 1us of positive
	 * or negative RST_n pulse width.
	 * To be on safe side, keep the reset low for atleast 10us.
	 */
	usleep_range(10, 15);

	ret = ufshcd_deassert_device_reset(hba);
	if (ret)
		goto out;
	/* same as assert, wait for atleast 10us after deassert */
	usleep_range(10, 15);
out:
	return ret;
}

static void ufshcd_add_cmd_upiu_trace(struct ufs_hba *hba, unsigned int tag,
		const char *str)
{
@@ -7466,12 +7409,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)

static int ufshcd_detect_device(struct ufs_hba *hba)
{
	int err = 0;

	err = ufshcd_reset_device(hba);
	if (err)
		dev_warn(hba->dev, "%s: device reset failed. err %d\n",
			 __func__, err);
	ufshcd_vops_device_reset(hba);

	return ufshcd_host_reset_and_restore(hba);
}
@@ -8246,25 +8184,6 @@ static int ufs_read_device_desc_data(struct ufs_hba *hba)
	return err;
}

static inline bool ufshcd_needs_reinit(struct ufs_hba *hba)
{
	bool reinit = false;

	if (hba->dev_info.w_spec_version < 0x300 && hba->phy_init_g4) {
		dev_warn(hba->dev, "%s: Using force-g4 setting for a non-g4 device, re-init\n",
				  __func__);
		hba->phy_init_g4 = false;
		reinit = true;
	} else if (hba->dev_info.w_spec_version >= 0x300 && !hba->phy_init_g4) {
		dev_warn(hba->dev, "%s: Re-init UFS host to use proper PHY settings for the UFS device. This can be avoided by setting the force-g4 in DT\n",
				  __func__);
		hba->phy_init_g4 = true;
		reinit = true;
	}

	return reinit;
}

/**
 * ufshcd_probe_hba - probe hba to detect device and initialize
 * @hba: per-adapter instance
@@ -8278,7 +8197,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
	ktime_t start = ktime_get();

	dev_err(hba->dev, "*** This is %s ***\n", __FILE__);
reinit:

	ret = ufshcd_link_startup(hba);
	if (ret)
		goto out;
@@ -8318,27 +8237,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
		goto out;
	}

	if (ufshcd_needs_reinit(hba)) {
		unsigned long flags;
		int err;

		err = ufshcd_reset_device(hba);
		if (err)
			dev_warn(hba->dev, "%s: device reset failed. err %d\n",
				 __func__, err);

		/* Reset the host controller */
		spin_lock_irqsave(hba->host->host_lock, flags);
		ufshcd_hba_stop(hba, false);
		spin_unlock_irqrestore(hba->host->host_lock, flags);

		err = ufshcd_hba_enable(hba);
		if (err)
			goto out;

		goto reinit;
	}

	ufs_fixup_device_setup(hba, &card);
	ufshcd_tune_unipro_params(hba);

@@ -10027,13 +9925,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
	}

	/* reset connected UFS device */
	err = ufshcd_reset_device(hba);
	if (err)
		dev_warn(hba->dev, "%s: device reset failed. err %d\n",
			 __func__, err);

	if (hba->force_g4)
		hba->phy_init_g4 = true;
	ufshcd_vops_device_reset(hba);

	/* Init crypto */
	err = ufshcd_hba_init_crypto(hba);
+1 −4
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 *
 * This code is based on drivers/scsi/ufs/ufshcd.h
 * Copyright (C) 2011-2013 Samsung India Software Operations
 * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
 *
 * Authors:
 *	Santosh Yaraganavi <santosh.sy@samsung.com>
@@ -918,9 +918,7 @@ struct ufs_hba {
#define UFSHCD_CAP_POWER_COLLAPSE_DURING_HIBERN8 (1 << 7)
	/* Allow standalone Hibern8 enter on idle */
#define UFSHCD_CAP_HIBERN8_ENTER_ON_IDLE (1 << 5)
	bool phy_init_g4;
	struct rw_semaphore lock;
	struct pinctrl *pctrl;
	/* Bitmask for enabling debug prints */
	u32 ufshcd_dbg_print;
	/* If set, don't gate device ref_clk during clock gating */
@@ -939,7 +937,6 @@ struct ufs_hba {
	bool auto_h8_err;
	struct work_struct rls_work;
	u32 dev_ref_clk_gating_wait;
	bool force_g4;
#endif
	struct devfreq *devfreq;
	struct ufs_clk_scaling clk_scaling;