i2c: aspeed: Fix initial values of master and slave state
[linux/fpc-iii.git] / drivers / mmc / host / sdhci-brcmstb.c
blob552bddc5096ce2e2d2638483f3baf7317115d5bf
1 /*
2 * sdhci-brcmstb.c Support for SDHCI on Broadcom BRCMSTB SoC's
4 * Copyright (C) 2015 Broadcom Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/io.h>
18 #include <linux/mmc/host.h>
19 #include <linux/module.h>
20 #include <linux/of.h>
22 #include "sdhci-pltfm.h"
24 static const struct sdhci_ops sdhci_brcmstb_ops = {
25 .set_clock = sdhci_set_clock,
26 .set_bus_width = sdhci_set_bus_width,
27 .reset = sdhci_reset,
28 .set_uhs_signaling = sdhci_set_uhs_signaling,
31 static const struct sdhci_pltfm_data sdhci_brcmstb_pdata = {
32 .ops = &sdhci_brcmstb_ops,
35 static int sdhci_brcmstb_probe(struct platform_device *pdev)
37 struct sdhci_host *host;
38 struct sdhci_pltfm_host *pltfm_host;
39 struct clk *clk;
40 int res;
42 clk = devm_clk_get(&pdev->dev, NULL);
43 if (IS_ERR(clk)) {
44 dev_err(&pdev->dev, "Clock not found in Device Tree\n");
45 clk = NULL;
47 res = clk_prepare_enable(clk);
48 if (res)
49 return res;
51 host = sdhci_pltfm_init(pdev, &sdhci_brcmstb_pdata, 0);
52 if (IS_ERR(host)) {
53 res = PTR_ERR(host);
54 goto err_clk;
57 sdhci_get_of_property(pdev);
58 mmc_of_parse(host->mmc);
61 * Supply the existing CAPS, but clear the UHS modes. This
62 * will allow these modes to be specified by device tree
63 * properties through mmc_of_parse().
65 host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
66 if (of_device_is_compatible(pdev->dev.of_node, "brcm,bcm7425-sdhci"))
67 host->caps &= ~SDHCI_CAN_64BIT;
68 host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
69 host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
70 SDHCI_SUPPORT_DDR50);
71 host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
72 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
74 res = sdhci_add_host(host);
75 if (res)
76 goto err;
78 pltfm_host = sdhci_priv(host);
79 pltfm_host->clk = clk;
80 return res;
82 err:
83 sdhci_pltfm_free(pdev);
84 err_clk:
85 clk_disable_unprepare(clk);
86 return res;
89 static const struct of_device_id sdhci_brcm_of_match[] = {
90 { .compatible = "brcm,bcm7425-sdhci" },
91 { .compatible = "brcm,bcm7445-sdhci" },
92 {},
94 MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match);
96 static struct platform_driver sdhci_brcmstb_driver = {
97 .driver = {
98 .name = "sdhci-brcmstb",
99 .pm = &sdhci_pltfm_pmops,
100 .of_match_table = of_match_ptr(sdhci_brcm_of_match),
102 .probe = sdhci_brcmstb_probe,
103 .remove = sdhci_pltfm_unregister,
106 module_platform_driver(sdhci_brcmstb_driver);
108 MODULE_DESCRIPTION("SDHCI driver for Broadcom BRCMSTB SoCs");
109 MODULE_AUTHOR("Broadcom");
110 MODULE_LICENSE("GPL v2");