From d55865b97a963cb7b2ffa80fb3ba1333478b434f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 11 Jun 2014 14:55:51 -0600 Subject: [PATCH] SAMA5D4: Add support for HSMCI1 power control pin --- configs/sama5d4-ek/src/sam_hsmci.c | 20 +++++++++++++------- configs/sama5d4-ek/src/sama5d4-ek.h | 6 +++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/configs/sama5d4-ek/src/sam_hsmci.c b/configs/sama5d4-ek/src/sam_hsmci.c index 4cd4db9d08..b4501eeddd 100644 --- a/configs/sama5d4-ek/src/sam_hsmci.c +++ b/configs/sama5d4-ek/src/sam_hsmci.c @@ -109,7 +109,8 @@ struct sam_hsmci_state_s { struct sdio_dev_s *hsmci; /* R/W device handle */ - pio_pinset_t pincfg; /* Card detect PIO pin configuration */ + pio_pinset_t cdcfg; /* Card detect PIO pin configuration */ + pio_pinset_t pwrcfg; /* Power PIO pin configuration */ uint8_t irq; /* Interrupt number (same as pid) */ uint8_t slotno; /* Slot number */ bool cd; /* TRUE: card is inserted */ @@ -127,7 +128,7 @@ static int sam_hsmci0_cardetect(int irq, void *regs); static struct sam_hsmci_state_s g_hsmci0 = { - .pincfg = PIO_MCI0_CD, + .cdcfg = PIO_MCI0_CD, .irq = IRQ_MCI0_CD, .slotno = 0, .handler = sam_hsmci0_cardetect, @@ -139,7 +140,8 @@ static int sam_hsmci1_cardetect(int irq, void *regs); static struct sam_hsmci_state_s g_hsmci1 = { - .pincfg = PIO_MCI1_CD, + .cdcfg = PIO_MCI1_CD, + .pwrcfg = IRQ_MCI1_PWR, .irq = IRQ_MCI1_CD, .slotno = 1, .handler = sam_hsmci1_cardetect, @@ -164,7 +166,7 @@ bool sam_cardinserted_internal(struct sam_hsmci_state_s *state) /* Get the state of the PIO pin */ - inserted = sam_pioread(state->pincfg); + inserted = sam_pioread(state->cdcfg); fllvdbg("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES"); return !inserted; } @@ -272,9 +274,13 @@ int sam_hsmci_initialize(int slotno, int minor) return -EINVAL; } - /* Initialize card-detect and write-protect PIOs */ + /* Initialize card-detect, write-protect, and power enable PIOs */ - sam_configpio(state->pincfg); + sam_configpio(state->cdcfg); + if (state->pwrcfg != 0) + { + sam_configpio(state->pwrcfg); + } /* Mount the SDIO-based MMC/SD block driver */ /* First, get an instance of the SDIO interface */ @@ -297,7 +303,7 @@ int sam_hsmci_initialize(int slotno, int minor) /* Configure card detect interrupts */ - sam_pioirq(state->pincfg); + sam_pioirq(state->cdcfg); (void)irq_attach(state->irq, state->handler); /* Then inform the HSMCI driver if there is or is not a card in the slot. */ diff --git a/configs/sama5d4-ek/src/sama5d4-ek.h b/configs/sama5d4-ek/src/sama5d4-ek.h index ca2a045faf..414f7a078c 100644 --- a/configs/sama5d4-ek/src/sama5d4-ek.h +++ b/configs/sama5d4-ek/src/sama5d4-ek.h @@ -333,7 +333,8 @@ #define IRQ_MCI0_CD SAM_IRQ_PE5 /* The microSD connects vi HSMCI1. The card detect discrete is available on - * PE14 (pulled high): + * PE14 (pulled high) NOTE that PE15 must be controlled to provide power + * to the HSMCI1 slot (the HSMCI0 slot is always powered). * * ------------------------------ ------------------- ------------------------- * SAMA5D4 PIO SIGNAL USAGE @@ -354,6 +355,9 @@ PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN14) #define IRQ_MCI1_CD SAM_IRQ_PE14 +#define IRQ_MCI1_PWR (PIO_OUTPUT | PIO_CFG_DEFAULT | PIO_OUTPUT_SET | \ + PIO_PORT_PIOE | PIO_PIN15) + /* USB Ports ************************************************************************/ /* The SAMA5D4 series-MB features three USB communication ports: *