1 // SPDX-License-Identifier: GPL-2.0-only
3 * sdhci-brcmstb.c Support for SDHCI on Broadcom BRCMSTB SoC's
5 * Copyright (C) 2015 Broadcom Corporation
9 #include <linux/mmc/host.h>
10 #include <linux/module.h>
13 #include "sdhci-pltfm.h"
15 static const struct sdhci_ops sdhci_brcmstb_ops
= {
16 .set_clock
= sdhci_set_clock
,
17 .set_bus_width
= sdhci_set_bus_width
,
19 .set_uhs_signaling
= sdhci_set_uhs_signaling
,
22 static const struct sdhci_pltfm_data sdhci_brcmstb_pdata
= {
23 .ops
= &sdhci_brcmstb_ops
,
26 static int sdhci_brcmstb_probe(struct platform_device
*pdev
)
28 struct sdhci_host
*host
;
29 struct sdhci_pltfm_host
*pltfm_host
;
33 clk
= devm_clk_get(&pdev
->dev
, NULL
);
35 dev_err(&pdev
->dev
, "Clock not found in Device Tree\n");
38 res
= clk_prepare_enable(clk
);
42 host
= sdhci_pltfm_init(pdev
, &sdhci_brcmstb_pdata
, 0);
48 sdhci_get_of_property(pdev
);
49 res
= mmc_of_parse(host
->mmc
);
54 * Supply the existing CAPS, but clear the UHS modes. This
55 * will allow these modes to be specified by device tree
56 * properties through mmc_of_parse().
58 host
->caps
= sdhci_readl(host
, SDHCI_CAPABILITIES
);
59 if (of_device_is_compatible(pdev
->dev
.of_node
, "brcm,bcm7425-sdhci"))
60 host
->caps
&= ~SDHCI_CAN_64BIT
;
61 host
->caps1
= sdhci_readl(host
, SDHCI_CAPABILITIES_1
);
62 host
->caps1
&= ~(SDHCI_SUPPORT_SDR50
| SDHCI_SUPPORT_SDR104
|
64 host
->quirks
|= SDHCI_QUIRK_MISSING_CAPS
|
65 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
;
67 res
= sdhci_add_host(host
);
71 pltfm_host
= sdhci_priv(host
);
72 pltfm_host
->clk
= clk
;
76 sdhci_pltfm_free(pdev
);
78 clk_disable_unprepare(clk
);
82 static const struct of_device_id sdhci_brcm_of_match
[] = {
83 { .compatible
= "brcm,bcm7425-sdhci" },
84 { .compatible
= "brcm,bcm7445-sdhci" },
87 MODULE_DEVICE_TABLE(of
, sdhci_brcm_of_match
);
89 static struct platform_driver sdhci_brcmstb_driver
= {
91 .name
= "sdhci-brcmstb",
92 .pm
= &sdhci_pltfm_pmops
,
93 .of_match_table
= of_match_ptr(sdhci_brcm_of_match
),
95 .probe
= sdhci_brcmstb_probe
,
96 .remove
= sdhci_pltfm_unregister
,
99 module_platform_driver(sdhci_brcmstb_driver
);
101 MODULE_DESCRIPTION("SDHCI driver for Broadcom BRCMSTB SoCs");
102 MODULE_AUTHOR("Broadcom");
103 MODULE_LICENSE("GPL v2");