From c5fb414e0a125faa2c7c44d033b6fdc2779efcd6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 21 Jan 2009 17:39:11 +0000 Subject: [PATCH] o The f_max is really at91_master_clock / 2, not 30MHz, so compute it as such. o Only set 4-bit caps on those boards that have 4-bit caps (this means that because we don't set wire4 yet, this forces us to always use 1-bit bus). o Don't test wire4 when setting up the bus width, since bad things will happen if we do. # This likely won't fix the busted at91 sd card support, but these are # needful changes for correctness. --- sys/arm/at91/at91_mci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/arm/at91/at91_mci.c b/sys/arm/at91/at91_mci.c index f55e3718317..067abc2ee16 100644 --- a/sys/arm/at91/at91_mci.c +++ b/sys/arm/at91/at91_mci.c @@ -199,9 +199,12 @@ at91_mci_attach(device_t dev) goto out; } sc->host.f_min = 375000; - sc->host.f_max = 30000000; + sc->host.f_max = at91_master_clock / 2; /* Typically 30MHz */ sc->host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; - sc->host.caps = MMC_CAP_4_BIT_DATA; + if (sc->wire4) + sc->host.caps = MMC_CAP_4_BIT_DATA; + else + sc->host.caps = 0; child = device_add_child(dev, "mmc", 0); device_set_ivars(dev, &sc->host); err = bus_generic_attach(dev); @@ -294,7 +297,7 @@ at91_mci_update_ios(device_t brdev, device_t reqdev) else clkdiv = (at91_master_clock / ios->clock) / 2; } - if (ios->bus_width == bus_width_4 && sc->wire4) + if (ios->bus_width == bus_width_4) WR4(sc, MCI_SDCR, RD4(sc, MCI_SDCR) | MCI_SDCR_SDCBUS); else WR4(sc, MCI_SDCR, RD4(sc, MCI_SDCR) & ~MCI_SDCR_SDCBUS);