summaryrefslogtreecommitdiff
path: root/src/commonlib/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/commonlib/storage')
-rw-r--r--src/commonlib/storage/pci_sdhci.c10
-rw-r--r--src/commonlib/storage/sdhci.c10
2 files changed, 16 insertions, 4 deletions
diff --git a/src/commonlib/storage/pci_sdhci.c b/src/commonlib/storage/pci_sdhci.c
index 2f9b648130..de9dd1b55c 100644
--- a/src/commonlib/storage/pci_sdhci.c
+++ b/src/commonlib/storage/pci_sdhci.c
@@ -12,21 +12,23 @@
/* Initialize an SDHCI port */
int sdhci_controller_init(struct sdhci_ctrlr *sdhci_ctrlr, void *ioaddr)
{
- memset(sdhci_ctrlr, 0, sizeof(*sdhci_ctrlr));
sdhci_ctrlr->ioaddr = ioaddr;
return add_sdhci(sdhci_ctrlr);
}
-struct sd_mmc_ctrlr *new_mem_sdhci_controller(void *ioaddr)
+struct sd_mmc_ctrlr *new_mem_sdhci_controller(void *ioaddr,
+ int (*pre_init_func)(struct sdhci_ctrlr *host))
{
static bool sdhci_init_done;
- static struct sdhci_ctrlr sdhci_ctrlr;
+ static struct sdhci_ctrlr sdhci_ctrlr = {0};
if (sdhci_init_done == true) {
sdhc_error("Error: SDHCI is already initialized.\n");
return NULL;
}
+ sdhci_ctrlr.attach = pre_init_func;
+
if (sdhci_controller_init(&sdhci_ctrlr, ioaddr)) {
sdhc_error("Error: SDHCI initialization failed.\n");
return NULL;
@@ -48,5 +50,5 @@ struct sd_mmc_ctrlr *new_pci_sdhci_controller(pci_devfn_t dev)
}
addr &= ~0xf;
- return new_mem_sdhci_controller((void *)addr);
+ return new_mem_sdhci_controller((void *)addr, NULL);
}
diff --git a/src/commonlib/storage/sdhci.c b/src/commonlib/storage/sdhci.c
index 3a01f62af1..882920d6a4 100644
--- a/src/commonlib/storage/sdhci.c
+++ b/src/commonlib/storage/sdhci.c
@@ -585,6 +585,16 @@ static int sdhci_pre_init(struct sdhci_ctrlr *sdhci_ctrlr)
struct sd_mmc_ctrlr *ctrlr = &sdhci_ctrlr->sd_mmc_ctrlr;
unsigned int caps, caps_1;
+ /*
+ * If the device needs to do anything non-standard before
+ * sdhci initialization, run it here.
+ */
+ if (sdhci_ctrlr->attach) {
+ int rv = sdhci_ctrlr->attach(sdhci_ctrlr);
+ if (rv)
+ return rv;
+ }
+
/* Get controller version and capabilities */
ctrlr->version = sdhci_readw(sdhci_ctrlr, SDHCI_HOST_VERSION) & 0xff;
caps = sdhci_readl(sdhci_ctrlr, SDHCI_CAPABILITIES);