1
2
3
4
5
6
7
8
9#include <common.h>
10#include <dm.h>
11#include <mach/sdhci.h>
12#include <malloc.h>
13#include <sdhci.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#define BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY 0
32
33
34
35
36
37
38
39#define BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY 400000
40
41
42
43
44
45struct sdhci_bcmstb_plat {
46 struct mmc_config cfg;
47 struct mmc mmc;
48};
49
50static int sdhci_bcmstb_bind(struct udevice *dev)
51{
52 struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev);
53
54 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
55}
56
57static int sdhci_bcmstb_probe(struct udevice *dev)
58{
59 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
60 struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev);
61 struct sdhci_host *host = dev_get_priv(dev);
62 fdt_addr_t base;
63 int ret;
64
65 base = dev_read_addr(dev);
66 if (base == FDT_ADDR_T_NONE)
67 return -EINVAL;
68
69 host->name = dev->name;
70 host->ioaddr = (void *)base;
71
72 ret = mmc_of_parse(dev, &plat->cfg);
73 if (ret)
74 return ret;
75
76 host->mmc = &plat->mmc;
77 host->mmc->dev = dev;
78 ret = sdhci_setup_cfg(&plat->cfg, host,
79 BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY,
80 BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY);
81 if (ret)
82 return ret;
83
84 upriv->mmc = &plat->mmc;
85 host->mmc->priv = host;
86
87 return sdhci_probe(dev);
88}
89
90static const struct udevice_id sdhci_bcmstb_match[] = {
91 { .compatible = "brcm,bcm7425-sdhci" },
92 { .compatible = "brcm,sdhci-brcmstb" },
93 { }
94};
95
96U_BOOT_DRIVER(sdhci_bcmstb) = {
97 .name = "sdhci-bcmstb",
98 .id = UCLASS_MMC,
99 .of_match = sdhci_bcmstb_match,
100 .ops = &sdhci_ops,
101 .bind = sdhci_bcmstb_bind,
102 .probe = sdhci_bcmstb_probe,
103 .priv_auto_alloc_size = sizeof(struct sdhci_host),
104 .platdata_auto_alloc_size = sizeof(struct sdhci_bcmstb_plat),
105};
106