SAMA5D4: Add support for HSMCI1 power control pin

This commit is contained in:
Gregory Nutt
2014-06-11 14:55:51 -06:00
parent 2cf637692a
commit d55865b97a
2 changed files with 18 additions and 8 deletions
+13 -7
View File
@@ -109,7 +109,8 @@
struct sam_hsmci_state_s struct sam_hsmci_state_s
{ {
struct sdio_dev_s *hsmci; /* R/W device handle */ 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 irq; /* Interrupt number (same as pid) */
uint8_t slotno; /* Slot number */ uint8_t slotno; /* Slot number */
bool cd; /* TRUE: card is inserted */ 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 = static struct sam_hsmci_state_s g_hsmci0 =
{ {
.pincfg = PIO_MCI0_CD, .cdcfg = PIO_MCI0_CD,
.irq = IRQ_MCI0_CD, .irq = IRQ_MCI0_CD,
.slotno = 0, .slotno = 0,
.handler = sam_hsmci0_cardetect, .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 = static struct sam_hsmci_state_s g_hsmci1 =
{ {
.pincfg = PIO_MCI1_CD, .cdcfg = PIO_MCI1_CD,
.pwrcfg = IRQ_MCI1_PWR,
.irq = IRQ_MCI1_CD, .irq = IRQ_MCI1_CD,
.slotno = 1, .slotno = 1,
.handler = sam_hsmci1_cardetect, .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 */ /* 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"); fllvdbg("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES");
return !inserted; return !inserted;
} }
@@ -272,9 +274,13 @@ int sam_hsmci_initialize(int slotno, int minor)
return -EINVAL; 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 */ /* Mount the SDIO-based MMC/SD block driver */
/* First, get an instance of the SDIO interface */ /* First, get an instance of the SDIO interface */
@@ -297,7 +303,7 @@ int sam_hsmci_initialize(int slotno, int minor)
/* Configure card detect interrupts */ /* Configure card detect interrupts */
sam_pioirq(state->pincfg); sam_pioirq(state->cdcfg);
(void)irq_attach(state->irq, state->handler); (void)irq_attach(state->irq, state->handler);
/* Then inform the HSMCI driver if there is or is not a card in the slot. */ /* Then inform the HSMCI driver if there is or is not a card in the slot. */
+5 -1
View File
@@ -333,7 +333,8 @@
#define IRQ_MCI0_CD SAM_IRQ_PE5 #define IRQ_MCI0_CD SAM_IRQ_PE5
/* The microSD connects vi HSMCI1. The card detect discrete is available on /* 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 * SAMA5D4 PIO SIGNAL USAGE
@@ -354,6 +355,9 @@
PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN14) PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN14)
#define IRQ_MCI1_CD SAM_IRQ_PE14 #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 ************************************************************************/ /* USB Ports ************************************************************************/
/* The SAMA5D4 series-MB features three USB communication ports: /* The SAMA5D4 series-MB features three USB communication ports:
* *