Skip to content

Commit

Permalink
drivers: sdhc: brcm_bcm2712: enable irq support
Browse files Browse the repository at this point in the history
Add IRQ support for RPI5 bcm2712 SDHC driver. The IRQs are enabled by
default and can be disabled with CONFIG_BRCM_BCM2712_SDHC_USE_IRQ Kconfig
option.

Signed-off-by: Grygorii Strashko <[email protected]>
Acked-by: Mykola Kvach <[email protected]>
Acked-by: Oleksii Moisieiev <[email protected]>
Acked-by: Dmytro Firsov <[email protected]>
  • Loading branch information
Grygorii Strashko committed Aug 7, 2024
1 parent 23d527c commit bcfc843
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/sdhc/Kconfig.brcm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config BRCM_BCM2712_SDHCI
select CACHE_MANAGEMENT
select SDHC_SUPPORTS_UHS if SDMMC_STACK
help
BCM2712 SDHC v3.0 cpapable.
BCM2712 SDHC v3.0 capable with SD interface support.

if BRCM_BCM2712_SDHCI

Expand Down Expand Up @@ -39,4 +39,11 @@ config BRCM_BCM2712_ADMA2_DESCS_NUM
default 16 if BRCM_BCM2712_XFER_ADMA2
default 0

config BRCM_BCM2712_SDHC_USE_IRQ
bool "BCM2712 SDHC enable IRQ support"
select EVENTS
default y
help
BCM2712 SDHC enable IRQ support for cmd/data transfers.

endif # BRCM_BCM2712_SDHCI
34 changes: 34 additions & 0 deletions drivers/sdhc/brcm_bcm2712_sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct bcm2712_sdhci_config {
const struct device *regulator_vqmmc;
const struct device *regulator_vmmc;
uint32_t clk_freq;
void (*irq_config)(const struct device *dev);

struct sdhc_adma_desc *adma_descs;

Expand Down Expand Up @@ -348,6 +349,10 @@ static int bcm2712_sdhci_init_host_props(const struct device *dev)
LOG_DEV_ERR(dev, "enable sdma");
}

if (IS_ENABLED(CONFIG_BRCM_BCM2712_SDHC_USE_IRQ)) {
sdhc_enable_irq(sdhci_ctx, true);
}

return ret;
}

Expand Down Expand Up @@ -450,9 +455,36 @@ static int bcm2712_sdhci_init(const struct device *dev)
}
}

if (IS_ENABLED(CONFIG_BRCM_BCM2712_SDHC_USE_IRQ)) {
cfg->irq_config(dev);
}

return 0;
}

#if defined(CONFIG_BRCM_BCM2712_SDHC_USE_IRQ)
static void bcm2712_irq_handler(const void *arg)
{
const struct device *dev = arg;
struct bcm2712_sdhci_data *data = dev->data;

sdhc_irq_cb(&data->sdhci_ctx);
}

#define BCM2712_SDHC_IRQ_CFG(inst) \
static void irq_config_##inst(const struct device *dev) \
{ \
IRQ_CONNECT(DT_INST_IRQN(inst), DT_INST_IRQ(inst, priority), bcm2712_irq_handler, \
DEVICE_DT_INST_GET(inst), DT_INST_IRQ(inst, flags)); \
irq_enable(DT_INST_IRQN(inst)); \
}

#define BCM2712_SDHC_IRQ_INIT(inst) .irq_config = irq_config_##inst,
#else
#define BCM2712_SDHC_IRQ_CFG(inst)
#define BCM2712_SDHC_IRQ_INIT(inst)
#endif /* CONFIG_BRCM_BCM2712_SDHC_USE_IRQ */

#if defined(CONFIG_BRCM_BCM2712_XFER_ADMA2)
#define BRCM_BCM2712_ADMA2_DESCS(inst) \
static struct sdhc_adma_desc \
Expand All @@ -465,6 +497,7 @@ static int bcm2712_sdhci_init(const struct device *dev)

#define BCM2712_SDHCI_INIT(inst) \
BRCM_BCM2712_ADMA2_DESCS(inst) \
BCM2712_SDHC_IRQ_CFG(inst) \
static const struct bcm2712_sdhci_config bcm2712_sdhci_config_##inst = { \
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(host, DT_DRV_INST(inst)), \
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(cfg, DT_DRV_INST(inst)), \
Expand All @@ -483,6 +516,7 @@ static int bcm2712_sdhci_init(const struct device *dev)
.power_delay_ms = DT_INST_PROP_OR(inst, power_delay_ms, 500), \
.non_removable = DT_INST_PROP_OR(inst, non_removable, 0), \
BRCM_BCM2712_ADMA2_DESCS_INIT(inst) \
BCM2712_SDHC_IRQ_INIT(inst) \
}; \
static struct bcm2712_sdhci_data bcm2712_sdhci_data_##inst = {}; \
DEVICE_DT_INST_DEFINE(inst, &bcm2712_sdhci_init, NULL, &bcm2712_sdhci_data_##inst, \
Expand Down

0 comments on commit bcfc843

Please sign in to comment.