From: Joseph Lo <josephl@nvidia.com>
To: Chris Ball <cjb@laptop.org>, Stephen Warren <swarren@wwwdotorg.org>
Cc: linux-tegra@vger.kernel.org, linux-mmc@vger.kernel.org,
Joseph Lo <josephl@nvidia.com>
Subject: [PATCH 2/2] mmc: tegra: use mmc_of_parse to get the support of standard MMC DT bindings
Date: Wed, 20 Feb 2013 15:05:02 +0800 [thread overview]
Message-ID: <1361343902-15223-3-git-send-email-josephl@nvidia.com> (raw)
In-Reply-To: <1361343902-15223-1-git-send-email-josephl@nvidia.com>
Updating the sdhci-tegra driver to use mmc_of_parse to support standard
MMC DT bindings. Then we can remove the redundant code that already support
in generic MMC core.
Signed-off-by: Joseph Lo <josephl@nvidia.com>
---
drivers/mmc/host/sdhci-tegra.c | 85 ++++--------------------------------------
1 file changed, 7 insertions(+), 78 deletions(-)
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 08b06e9..4f6b5c4 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -24,6 +24,7 @@
#include <linux/gpio.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
+#include <linux/mmc/slot-gpio.h>
#include <asm/gpio.h>
@@ -44,10 +45,7 @@ struct sdhci_tegra_soc_data {
struct sdhci_tegra {
const struct sdhci_tegra_soc_data *soc_data;
- int cd_gpio;
- int wp_gpio;
int power_gpio;
- int is_8bit;
};
static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg)
@@ -107,23 +105,9 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg)
static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host)
{
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_tegra *tegra_host = pltfm_host->priv;
-
- if (!gpio_is_valid(tegra_host->wp_gpio))
- return -1;
-
- return gpio_get_value(tegra_host->wp_gpio);
+ return mmc_gpio_get_ro(host->mmc);
}
-static irqreturn_t carddetect_irq(int irq, void *data)
-{
- struct sdhci_host *sdhost = (struct sdhci_host *)data;
-
- tasklet_schedule(&sdhost->card_tasklet);
- return IRQ_HANDLED;
-};
-
static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -145,12 +129,11 @@ static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
{
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_tegra *tegra_host = pltfm_host->priv;
u32 ctrl;
ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
- if (tegra_host->is_8bit && bus_width == MMC_BUS_WIDTH_8) {
+ if (host->mmc->caps == MMC_CAP_8_BIT_DATA &&
+ bus_width == MMC_BUS_WIDTH_8) {
ctrl &= ~SDHCI_CTRL_4BITBUS;
ctrl |= SDHCI_CTRL_8BITBUS;
} else {
@@ -220,15 +203,12 @@ static void sdhci_tegra_parse_dt(struct device *dev,
struct sdhci_tegra *tegra_host)
{
struct device_node *np = dev->of_node;
- u32 bus_width;
+ struct sdhci_host *host;
- tegra_host->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
- tegra_host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
tegra_host->power_gpio = of_get_named_gpio(np, "power-gpios", 0);
- if (of_property_read_u32(np, "bus-width", &bus_width) == 0 &&
- bus_width == 8)
- tegra_host->is_8bit = 1;
+ host = platform_get_drvdata(to_platform_device(dev));
+ mmc_of_parse(host->mmc);
}
static int sdhci_tegra_probe(struct platform_device *pdev)
@@ -272,37 +252,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
gpio_direction_output(tegra_host->power_gpio, 1);
}
- if (gpio_is_valid(tegra_host->cd_gpio)) {
- rc = gpio_request(tegra_host->cd_gpio, "sdhci_cd");
- if (rc) {
- dev_err(mmc_dev(host->mmc),
- "failed to allocate cd gpio\n");
- goto err_cd_req;
- }
- gpio_direction_input(tegra_host->cd_gpio);
-
- rc = request_irq(gpio_to_irq(tegra_host->cd_gpio),
- carddetect_irq,
- IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
- mmc_hostname(host->mmc), host);
-
- if (rc) {
- dev_err(mmc_dev(host->mmc), "request irq error\n");
- goto err_cd_irq_req;
- }
-
- }
-
- if (gpio_is_valid(tegra_host->wp_gpio)) {
- rc = gpio_request(tegra_host->wp_gpio, "sdhci_wp");
- if (rc) {
- dev_err(mmc_dev(host->mmc),
- "failed to allocate wp gpio\n");
- goto err_wp_req;
- }
- gpio_direction_input(tegra_host->wp_gpio);
- }
-
clk = clk_get(mmc_dev(host->mmc), NULL);
if (IS_ERR(clk)) {
dev_err(mmc_dev(host->mmc), "clk err\n");
@@ -312,9 +261,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
clk_prepare_enable(clk);
pltfm_host->clk = clk;
- if (tegra_host->is_8bit)
- host->mmc->caps |= MMC_CAP_8_BIT_DATA;
-
rc = sdhci_add_host(host);
if (rc)
goto err_add_host;
@@ -325,15 +271,6 @@ err_add_host:
clk_disable_unprepare(pltfm_host->clk);
clk_put(pltfm_host->clk);
err_clk_get:
- if (gpio_is_valid(tegra_host->wp_gpio))
- gpio_free(tegra_host->wp_gpio);
-err_wp_req:
- if (gpio_is_valid(tegra_host->cd_gpio))
- free_irq(gpio_to_irq(tegra_host->cd_gpio), host);
-err_cd_irq_req:
- if (gpio_is_valid(tegra_host->cd_gpio))
- gpio_free(tegra_host->cd_gpio);
-err_cd_req:
if (gpio_is_valid(tegra_host->power_gpio))
gpio_free(tegra_host->power_gpio);
err_power_req:
@@ -351,14 +288,6 @@ static int sdhci_tegra_remove(struct platform_device *pdev)
sdhci_remove_host(host, dead);
- if (gpio_is_valid(tegra_host->wp_gpio))
- gpio_free(tegra_host->wp_gpio);
-
- if (gpio_is_valid(tegra_host->cd_gpio)) {
- free_irq(gpio_to_irq(tegra_host->cd_gpio), host);
- gpio_free(tegra_host->cd_gpio);
- }
-
if (gpio_is_valid(tegra_host->power_gpio))
gpio_free(tegra_host->power_gpio);
--
1.8.1.1
next prev parent reply other threads:[~2013-02-20 7:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-20 7:05 [PATCH 0/2] mmc: tegra: use mmc_of_parse to get support of standard MMC DT binding Joseph Lo
2013-02-20 7:05 ` [PATCH 1/2] ARM: dts: tegra: fix the activate polarity of cd-gpio in mmc host Joseph Lo
[not found] ` <1361343902-15223-2-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 16:59 ` Stephen Warren
[not found] ` <512500EB.1070802-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-21 8:18 ` Thierry Reding
[not found] ` <20130221081809.GB7718-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2013-02-21 8:30 ` Joseph Lo
2013-02-20 7:05 ` Joseph Lo [this message]
[not found] ` <1361343902-15223-3-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 17:07 ` [PATCH 2/2] mmc: tegra: use mmc_of_parse to get the support of standard MMC DT bindings Stephen Warren
[not found] ` <512502D7.4090605-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-21 2:23 ` Joseph Lo
[not found] ` <1361413425.5678.8.camel-yx3yKKdKkHfc7b1ADBJPm0n48jw8i0AO@public.gmane.org>
2013-02-21 4:20 ` Stephen Warren
[not found] ` <5125A075.5000000-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-21 6:26 ` Joseph Lo
2013-02-21 6:34 ` Joseph Lo
2013-02-21 8:03 ` Thierry Reding
[not found] ` <20130221080306.GA7718-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2013-02-21 8:15 ` Joseph Lo
[not found] ` <1361427997.5678.59.camel-yx3yKKdKkHfc7b1ADBJPm0n48jw8i0AO@public.gmane.org>
2013-02-21 18:50 ` Stephen Warren
2013-02-21 22:44 ` Guennadi Liakhovetski
[not found] ` <Pine.LNX.4.64.1302212333330.10403-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2013-02-22 2:07 ` Joseph Lo
[not found] ` <1361343902-15223-1-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-21 8:24 ` [PATCH 0/2] mmc: tegra: use mmc_of_parse to get support of standard MMC DT binding Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361343902-15223-3-git-send-email-josephl@nvidia.com \
--to=josephl@nvidia.com \
--cc=cjb@laptop.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox