commonlib/storage: Add attach callback to sdhci_ctrlr
Adding a attach callback function pointer in case a platform needs to execute anything before the standard initialization of the sdhci mem controller. BUG=b:254092907 BRANCH=None TEST=emerge-herobrine coreboot Change-Id: I0f37ec09d083922cad5ecd3c47b184cf3311fe2d Signed-off-by: Shelley Chen <shchen@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72633 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
This commit is contained in:
parent
3ecf377e30
commit
8c692d7dfa
|
@ -46,6 +46,12 @@ struct sdhci_ctrlr {
|
||||||
|
|
||||||
/* Number of ADMA descriptors currently in the array. */
|
/* Number of ADMA descriptors currently in the array. */
|
||||||
int adma_desc_count;
|
int adma_desc_count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Point to function to run before running initialization.
|
||||||
|
* This would include anything non-standard.
|
||||||
|
*/
|
||||||
|
int (*attach)(struct sdhci_ctrlr *ctrlr);
|
||||||
};
|
};
|
||||||
|
|
||||||
int add_sdhci(struct sdhci_ctrlr *sdhci_ctrlr);
|
int add_sdhci(struct sdhci_ctrlr *sdhci_ctrlr);
|
||||||
|
@ -57,6 +63,7 @@ void sdhci_display_setup(struct sdhci_ctrlr *sdhci_ctrlr);
|
||||||
struct sd_mmc_ctrlr *new_pci_sdhci_controller(uint32_t dev);
|
struct sd_mmc_ctrlr *new_pci_sdhci_controller(uint32_t dev);
|
||||||
|
|
||||||
/* Add SDHCI controller with memory address */
|
/* Add SDHCI controller with memory address */
|
||||||
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));
|
||||||
|
|
||||||
#endif /* __COMMONLIB_SDHCI_H__ */
|
#endif /* __COMMONLIB_SDHCI_H__ */
|
||||||
|
|
|
@ -12,21 +12,23 @@
|
||||||
/* Initialize an SDHCI port */
|
/* Initialize an SDHCI port */
|
||||||
int sdhci_controller_init(struct sdhci_ctrlr *sdhci_ctrlr, void *ioaddr)
|
int sdhci_controller_init(struct sdhci_ctrlr *sdhci_ctrlr, void *ioaddr)
|
||||||
{
|
{
|
||||||
memset(sdhci_ctrlr, 0, sizeof(*sdhci_ctrlr));
|
|
||||||
sdhci_ctrlr->ioaddr = ioaddr;
|
sdhci_ctrlr->ioaddr = ioaddr;
|
||||||
return add_sdhci(sdhci_ctrlr);
|
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 bool sdhci_init_done;
|
||||||
static struct sdhci_ctrlr sdhci_ctrlr;
|
static struct sdhci_ctrlr sdhci_ctrlr = {0};
|
||||||
|
|
||||||
if (sdhci_init_done == true) {
|
if (sdhci_init_done == true) {
|
||||||
sdhc_error("Error: SDHCI is already initialized.\n");
|
sdhc_error("Error: SDHCI is already initialized.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdhci_ctrlr.attach = pre_init_func;
|
||||||
|
|
||||||
if (sdhci_controller_init(&sdhci_ctrlr, ioaddr)) {
|
if (sdhci_controller_init(&sdhci_ctrlr, ioaddr)) {
|
||||||
sdhc_error("Error: SDHCI initialization failed.\n");
|
sdhc_error("Error: SDHCI initialization failed.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -48,5 +50,5 @@ struct sd_mmc_ctrlr *new_pci_sdhci_controller(pci_devfn_t dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr &= ~0xf;
|
addr &= ~0xf;
|
||||||
return new_mem_sdhci_controller((void *)addr);
|
return new_mem_sdhci_controller((void *)addr, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,6 +585,16 @@ static int sdhci_pre_init(struct sdhci_ctrlr *sdhci_ctrlr)
|
||||||
struct sd_mmc_ctrlr *ctrlr = &sdhci_ctrlr->sd_mmc_ctrlr;
|
struct sd_mmc_ctrlr *ctrlr = &sdhci_ctrlr->sd_mmc_ctrlr;
|
||||||
unsigned int caps, caps_1;
|
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 */
|
/* Get controller version and capabilities */
|
||||||
ctrlr->version = sdhci_readw(sdhci_ctrlr, SDHCI_HOST_VERSION) & 0xff;
|
ctrlr->version = sdhci_readw(sdhci_ctrlr, SDHCI_HOST_VERSION) & 0xff;
|
||||||
caps = sdhci_readl(sdhci_ctrlr, SDHCI_CAPABILITIES);
|
caps = sdhci_readl(sdhci_ctrlr, SDHCI_CAPABILITIES);
|
||||||
|
|
Loading…
Reference in New Issue