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

Commit a764c6b3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: Add nvmem property in sdhc1 on SDM670"

parents c1e76e90 3d37f97d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -121,6 +121,10 @@ In the following, <supply> can be vdd (flash core voltage) or vdd-io (I/O voltag

	- qcom,wakeup-on-idle: if configured, the mmcqd thread will call
	  set_wake_up_idle(), thereby voting for it to be called on idle CPUs.
	- nvmem-cells: specifies the handle to represent the SoC revision.
	  usually it is defined by qfprom device node.
	- nvmem-cell-names: specifies the given nvmem cell name as defined in
	  qfprom node.

Example:

+2 −0
Original line number Diff line number Diff line
@@ -2365,6 +2365,8 @@
		qcom,ddr-config = <0xC3040873>;

		qcom,nonremovable;
		nvmem-cells = <&minor_rev>;
		nvmem-cell-names = "minor_rev";

		status = "disabled";
	};
+74 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * drivers/mmc/host/sdhci-msm.c - Qualcomm Technologies, Inc. MSM SDHCI Platform
 * driver source file
 *
 * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -39,6 +39,7 @@
#include <linux/iopoll.h>
#include <linux/msm-bus.h>
#include <linux/pm_runtime.h>
#include <linux/nvmem-consumer.h>
#include <trace/events/mmc.h>

#include "sdhci-msm.h"
@@ -1885,6 +1886,65 @@ static void sdhci_msm_pm_qos_parse(struct device *dev,
	}
}

#ifdef CONFIG_NVMEM
/* Parse qfprom data for deciding on errata work-arounds */
static long qfprom_read(struct device *dev, const char *name)
{
	struct nvmem_cell *cell;
	ssize_t len = 0;
	u32 *buf, val = 0;
	long err = 0;

	cell = nvmem_cell_get(dev, name);
	if (IS_ERR(cell)) {
		err = PTR_ERR(cell);
		dev_err(dev, "failed opening nvmem cell err : %ld\n", err);
		/* If entry does not exist, then that is not an error */
		if (err == -ENOENT)
			err = 0;
		return err;
	}

	buf = (u32 *)nvmem_cell_read(cell, &len);
	if (IS_ERR(buf) || !len) {
		dev_err(dev, "Failed reading nvmem cell, err: %u, bytes fetched: %zd\n",
				*buf, len);
		if (!IS_ERR(buf)) {
			kfree(buf);
			err = -EINVAL;
		} else {
			err = PTR_ERR(buf);
		}
	} else {
		val = *buf;
		kfree(buf);
	}

	nvmem_cell_put(cell);
	return err ? err : (long) val;
}

/* Reads the SoC version */
static int sdhci_msm_get_socrev(struct device *dev,
				struct sdhci_msm_host *msm_host)
{

	msm_host->soc_min_rev  = qfprom_read(dev, "minor_rev");

	if (msm_host->soc_min_rev < 0)
		dev_err(dev, "failed getting soc_min_rev, err : %d\n",
				msm_host->soc_min_rev);
	return msm_host->soc_min_rev;
}
#else
/* Reads the SoC version */
static int sdhci_msm_get_socrev(struct device *dev,
				struct sdhci_msm_host *msm_host)
{
	return 0;
}
#endif

/* Parse platform data */
static
struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev,
@@ -2062,6 +2122,13 @@ struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev,
	if (!of_property_read_u32(np, "qcom,ddr-config", &pdata->ddr_config))
		pdata->rclk_wa = true;

	/*
	 * rclk_wa is not required if soc version is mentioned and
	 * is not base version.
	 */
	if (msm_host->soc_min_rev != 0)
		pdata->rclk_wa = false;

	return pdata;
out:
	return NULL;
@@ -4530,6 +4597,12 @@ static int sdhci_msm_probe(struct platform_device *pdev)
	msm_host->mmc = host->mmc;
	msm_host->pdev = pdev;

	ret = sdhci_msm_get_socrev(&pdev->dev, msm_host);
	if (ret == -EPROBE_DEFER) {
		dev_err(&pdev->dev, "SoC version rd: fail: defer for now\n");
		goto pltfm_free;
	}

	/* get the ice device vops if present */
	ret = sdhci_msm_ice_get_dev(host);
	if (ret == -EPROBE_DEFER) {
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -255,6 +255,7 @@ struct sdhci_msm_host {
	bool core_3_0v_support;
	bool pltfm_init_done;
	struct sdhci_msm_regs_restore regs_restore;
	int soc_min_rev;
};

extern char *saved_command_line;