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

Commit 134636a4 authored by Asutosh Das's avatar Asutosh Das Committed by Sayali Lokhande
Browse files

scsi: ufs-qcom: Add check for ufs bootdevice



On qcom platforms, bootdevice is the primary storage
device. The regulators to this device are left ON by
the bootloaders. Detecting further in the init sequence
that UFS is not the bootdevice entails turning-off of
these regulators without sending PON. This is bad for
the underlying storage device.

Change-Id: I7e9231f0bcf90d8f329146ae2d831bbb5ef8190e
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
parent 4e64e456
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ Optional properties:
			  3: 52 MHz
			  Defaults to 26 MHz if not specified.
- extcon:       phandle to external connector (Refer Documentation/devicetree/bindings/extcon/extcon-gpio.txt for more details).
- non-removable		: defines if the connected ufs device is not removable


Note: If above properties are not defined it can be assumed that the supply
regulators or clocks are always on.
+30 −0
Original line number Diff line number Diff line
@@ -1987,6 +1987,18 @@ static void ufs_qcom_pm_qos_remove(struct ufs_qcom_host *host)
}
#endif /* CONFIG_SMP */

#define	ANDROID_BOOT_DEV_MAX	30
static char android_boot_dev[ANDROID_BOOT_DEV_MAX];

#ifndef MODULE
static int __init get_android_boot_dev(char *str)
{
	strlcpy(android_boot_dev, str, ANDROID_BOOT_DEV_MAX);
	return 1;
}
__setup("androidboot.bootdevice=", get_android_boot_dev);
#endif

/*
 * ufs_qcom_parse_lpm - read from DTS whether LPM modes should be disabled.
 */
@@ -2676,6 +2688,24 @@ static int ufs_qcom_probe(struct platform_device *pdev)
{
	int err;
	struct device *dev = &pdev->dev;
	struct device_node *np = dev->of_node;

	/*
	 * On qcom platforms, bootdevice is the primary storage
	 * device. This device can either be eMMC or UFS.
	 * The type of device connected is detected at runtime.
	 * So, if an eMMC device is connected, and this function
	 * is invoked, it would turn-off the regulator if it detects
	 * that the storage device is not ufs.
	 * These regulators are turned ON by the bootloaders & turning
	 * them off without sending PON may damage the connected device.
	 * Hence, check for the connected device early-on & don't turn-off
	 * the regulators.
	 */
	if (of_property_read_bool(np, "non-removable") &&
	    strlen(android_boot_dev) &&
	    strcmp(android_boot_dev, dev_name(dev)))
		return -ENODEV;

	/* Perform generic probe */
	err = ufshcd_pltfrm_init(pdev, &ufs_hba_qcom_variant);