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

Commit 581df134 authored by Sahitya Tummala's avatar Sahitya Tummala Committed by Xiaonian Wang
Browse files

mmc: sdhci-msm: Add support for hardware based card detection



Add support for hardware based card detection for external
SD card slot.

Change-Id: I3e081f2eff54d6932a89f826cc85c201c52ca840
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
Signed-off-by: default avatarVenkat Gopalakrishnan <venkatg@codeaurora.org>
[xiaonian@codeaurora.org: fix trivial merge conflict]
Signed-off-by: default avatarXiaonian Wang <xiaonian@codeaurora.org>
parent 8a3e818f
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/slot-gpio.h>
#include <linux/msm-bus.h>

#include "sdhci-pltfm.h"
@@ -170,6 +171,7 @@ struct sdhci_msm_pltfm_data {
	bool nonremovable;
	struct sdhci_msm_pin_data *pin_data;
	u32 cpu_dma_latency_us;
	int status_gpio; /* card detection GPIO that is configured as IRQ */
	struct sdhci_msm_bus_voting_data *voting_data;
};

@@ -835,6 +837,8 @@ static struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev)
		goto out;
	}

	pdata->status_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, 0);

	of_property_read_u32(np, "qcom,bus-width", &bus_width);
	if (bus_width == 8)
		pdata->mmc_bus_width = MMC_CAP_8_BIT_DATA;
@@ -1779,10 +1783,20 @@ static int sdhci_msm_probe(struct platform_device *pdev)
		INIT_DELAYED_WORK(&msm_host->msm_bus_vote.vote_work,
				  sdhci_msm_bus_work);

	if (gpio_is_valid(msm_host->pdata->status_gpio)) {
		ret = mmc_gpio_request_cd(msm_host->mmc,
				msm_host->pdata->status_gpio, 0);
		if (ret) {
			dev_err(&pdev->dev, "%s: Failed to request card detection IRQ %d\n",
					__func__, ret);
			goto bus_unregister;
		}
	}

	ret = sdhci_add_host(host);
	if (ret) {
		dev_err(&pdev->dev, "Add host failed (%d)\n", ret);
		goto bus_unregister;
		goto vreg_deinit;
	}

	 /* Set core clk rate, optionally override from dts */
@@ -1843,6 +1857,7 @@ static int sdhci_msm_remove(struct platform_device *pdev)
	device_remove_file(&pdev->dev, &msm_host->msm_bus_vote.max_bus_bw);
	sdhci_remove_host(host, dead);
	sdhci_pltfm_free(pdev);

	sdhci_msm_vreg_init(&pdev->dev, msm_host->pdata, false);

	if (pdata->pin_data)