]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/mmc/host/sdhci-tegra.c
mmc: sdhci: Add size for caller in init+register
[karo-tx-linux.git] / drivers / mmc / host / sdhci-tegra.c
index 08b06e9a3a21523e8c16b9d63299308885310ab7..c8b058283a06fd43f64a09da6f5b0835318db264 100644 (file)
@@ -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>
 
 #define NVQUIRK_ENABLE_SDHCI_SPEC_300  BIT(2)
 
 struct sdhci_tegra_soc_data {
-       struct sdhci_pltfm_data *pdata;
+       const struct sdhci_pltfm_data *pdata;
        u32 nvquirks;
 };
 
 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 {
@@ -164,7 +147,7 @@ static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
        return 0;
 }
 
-static struct sdhci_ops tegra_sdhci_ops = {
+static const struct sdhci_ops tegra_sdhci_ops = {
        .get_ro     = tegra_sdhci_get_ro,
        .read_l     = tegra_sdhci_readl,
        .read_w     = tegra_sdhci_readw,
@@ -173,8 +156,7 @@ static struct sdhci_ops tegra_sdhci_ops = {
        .platform_reset_exit = tegra_sdhci_reset_exit,
 };
 
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
-static struct sdhci_pltfm_data sdhci_tegra20_pdata = {
+static const struct sdhci_pltfm_data sdhci_tegra20_pdata = {
        .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
                  SDHCI_QUIRK_SINGLE_POWER_WRITE |
                  SDHCI_QUIRK_NO_HISPD_BIT |
@@ -187,10 +169,8 @@ static struct sdhci_tegra_soc_data soc_data_tegra20 = {
        .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 |
                    NVQUIRK_ENABLE_BLOCK_GAP_DET,
 };
-#endif
 
-#ifdef CONFIG_ARCH_TEGRA_3x_SOC
-static struct sdhci_pltfm_data sdhci_tegra30_pdata = {
+static const struct sdhci_pltfm_data sdhci_tegra30_pdata = {
        .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
                  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
                  SDHCI_QUIRK_SINGLE_POWER_WRITE |
@@ -203,32 +183,37 @@ static struct sdhci_tegra_soc_data soc_data_tegra30 = {
        .pdata = &sdhci_tegra30_pdata,
        .nvquirks = NVQUIRK_ENABLE_SDHCI_SPEC_300,
 };
-#endif
+
+static const struct sdhci_pltfm_data sdhci_tegra114_pdata = {
+       .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
+                 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
+                 SDHCI_QUIRK_SINGLE_POWER_WRITE |
+                 SDHCI_QUIRK_NO_HISPD_BIT |
+                 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
+       .ops  = &tegra_sdhci_ops,
+};
+
+static struct sdhci_tegra_soc_data soc_data_tegra114 = {
+       .pdata = &sdhci_tegra114_pdata,
+};
 
 static const struct of_device_id sdhci_tegra_dt_match[] = {
-#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+       { .compatible = "nvidia,tegra114-sdhci", .data = &soc_data_tegra114 },
        { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 },
-#endif
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
        { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 },
-#endif
        {}
 };
-MODULE_DEVICE_TABLE(of, sdhci_dt_ids);
+MODULE_DEVICE_TABLE(of, sdhci_tegra_dt_match);
 
-static void sdhci_tegra_parse_dt(struct device *dev,
-                                       struct sdhci_tegra *tegra_host)
+static void sdhci_tegra_parse_dt(struct device *dev)
 {
        struct device_node *np = dev->of_node;
-       u32 bus_width;
+       struct sdhci_host *host = dev_get_drvdata(dev);
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+       struct sdhci_tegra *tegra_host = pltfm_host->priv;
 
-       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;
+       mmc_of_parse(host->mmc);
 }
 
 static int sdhci_tegra_probe(struct platform_device *pdev)
@@ -246,7 +231,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
                return -EINVAL;
        soc_data = match->data;
 
-       host = sdhci_pltfm_init(pdev, soc_data->pdata);
+       host = sdhci_pltfm_init(pdev, soc_data->pdata, 0);
        if (IS_ERR(host))
                return PTR_ERR(host);
        pltfm_host = sdhci_priv(host);
@@ -260,7 +245,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
        tegra_host->soc_data = soc_data;
        pltfm_host->priv = tegra_host;
 
-       sdhci_tegra_parse_dt(&pdev->dev, tegra_host);
+       sdhci_tegra_parse_dt(&pdev->dev);
 
        if (gpio_is_valid(tegra_host->power_gpio)) {
                rc = gpio_request(tegra_host->power_gpio, "sdhci_power");
@@ -272,37 +257,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 +266,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 +276,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 +293,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);