summaryrefslogtreecommitdiffstats
path: root/sys/dev/sdhci/sdhci.c
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2013-02-28 19:43:14 +0000
committergonzo <gonzo@FreeBSD.org>2013-02-28 19:43:14 +0000
commit9b1d7b3ae47bf2aa81c07ad2179ef27132327f2a (patch)
treeb98301b12ea265208895740e1307ae28cc25913d /sys/dev/sdhci/sdhci.c
parent9ccbe7b6a4a12fa62e63d80ada8c85930e0c3cba (diff)
downloadFreeBSD-src-9b1d7b3ae47bf2aa81c07ad2179ef27132327f2a.zip
FreeBSD-src-9b1d7b3ae47bf2aa81c07ad2179ef27132327f2a.tar.gz
Add hooks for plugging platform-provided transfer backend.
In order to use platorm backend hardware driver should impement three methods: - platform_start_transfer and platform_finish_transfer to start and finish transfer - platform_will_handle - check whether transaction is suitable for backend. If not - driver will fall back to PIO mode. Submitted by: Daisuke Aoyama <aoyama at peach.ne.jp> Approved by: ian@
Diffstat (limited to 'sys/dev/sdhci/sdhci.c')
-rw-r--r--sys/dev/sdhci/sdhci.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c
index 1044bb6..15199f0 100644
--- a/sys/dev/sdhci/sdhci.c
+++ b/sys/dev/sdhci/sdhci.c
@@ -573,6 +573,13 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot, int num)
if (slot->quirks & SDHCI_QUIRK_FORCE_DMA)
slot->opt |= SDHCI_HAVE_DMA;
+ /*
+ * Use platform-provided transfer backend
+ * with PIO as a fallback mechanism
+ */
+ if (slot->opt & SDHCI_PLATFORM_TRANSFER)
+ slot->opt &= ~SDHCI_HAVE_DMA;
+
if (bootverbose || sdhci_debug) {
slot_printf(slot, "%uMHz%s 4bits%s%s%s %s\n",
slot->max_clk / 1000000,
@@ -909,7 +916,7 @@ sdhci_start_data(struct sdhci_slot *slot, struct mmc_data *data)
WR2(slot, SDHCI_BLOCK_COUNT, (data->len + 511) / 512);
}
-static void
+void
sdhci_finish_data(struct sdhci_slot *slot)
{
struct mmc_data *data = slot->curcmd->data;
@@ -1102,13 +1109,23 @@ sdhci_data_irq(struct sdhci_slot *slot, uint32_t intmask)
}
if (slot->curcmd->error) {
/* No need to continue after any error. */
- sdhci_finish_data(slot);
+ if (slot->flags & PLATFORM_DATA_STARTED) {
+ slot->flags &= ~PLATFORM_DATA_STARTED;
+ SDHCI_PLATFORM_FINISH_TRANSFER(slot->bus, slot);
+ } else
+ sdhci_finish_data(slot);
return;
}
/* Handle PIO interrupt. */
- if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL))
- sdhci_transfer_pio(slot);
+ if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL)) {
+ if ((slot->opt & SDHCI_PLATFORM_TRANSFER) &&
+ SDHCI_PLATFORM_WILL_HANDLE(slot->bus, slot)) {
+ SDHCI_PLATFORM_START_TRANSFER(slot->bus, slot, &intmask);
+ slot->flags |= PLATFORM_DATA_STARTED;
+ } else
+ sdhci_transfer_pio(slot);
+ }
/* Handle DMA border. */
if (intmask & SDHCI_INT_DMA_END) {
struct mmc_data *data = slot->curcmd->data;
@@ -1147,8 +1164,13 @@ sdhci_data_irq(struct sdhci_slot *slot, uint32_t intmask)
WR4(slot, SDHCI_DMA_ADDRESS, slot->paddr);
}
/* We have got all data. */
- if (intmask & SDHCI_INT_DATA_END)
- sdhci_finish_data(slot);
+ if (intmask & SDHCI_INT_DATA_END) {
+ if (slot->flags & PLATFORM_DATA_STARTED) {
+ slot->flags &= ~PLATFORM_DATA_STARTED;
+ SDHCI_PLATFORM_FINISH_TRANSFER(slot->bus, slot);
+ } else
+ sdhci_finish_data(slot);
+ }
}
static void
OpenPOWER on IntegriCloud