From owner-svn-src-stable-10@FreeBSD.ORG Sat Feb 14 19:28:27 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3863189B; Sat, 14 Feb 2015 19:28:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18D29B39; Sat, 14 Feb 2015 19:28:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1EJSQfr030633; Sat, 14 Feb 2015 19:28:26 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1EJSQS7030632; Sat, 14 Feb 2015 19:28:26 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201502141928.t1EJSQS7030632@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Sat, 14 Feb 2015 19:28:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r278778 - stable/10/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2015 19:28:27 -0000 Author: loos Date: Sat Feb 14 19:28:26 2015 New Revision: 278778 URL: https://svnweb.freebsd.org/changeset/base/278778 Log: MFC: r273264, r274409, r278212, r278213: Add a workaround needed to fix a bug of Arasan Host Controller where it may lose the contents of consecutive writes (that happens within two SD card clock cycles). This fixes the causes of instability during the SD card detection and identification on Raspberry Pi (which happens at 400 kHz and so was much more vulnerable to this issue). Remove the previous workaround which clearly can't provide the same effect. Remove stale comments about the issues with HS mode. Remove a previous workaround to limit the minimum sdhci frequency that isn't needed anymore. Remove some duplicate calls to bus_release_resource() and destroy the mutex on error cases. While here remove unnecessary includes. Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sat Feb 14 19:24:38 2015 (r278777) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sat Feb 14 19:28:26 2015 (r278778) @@ -29,32 +29,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include -#include -#include #include -#include #include #include #include #include -#include -#include #include #include #include -#include -#include -#include - -#include #include -#include -#include -#include -#include #include #include @@ -82,16 +67,9 @@ __FBSDID("$FreeBSD$"); #define dprintf(fmt, args...) #endif -/* - * Arasan HC seems to have problem with Data CRC on lower frequencies. - * Use this tunable to cap initialization sequence frequency at higher - * value. Default is standard 400kHz - */ -static int bcm2835_sdhci_min_freq = 400000; static int bcm2835_sdhci_hs = 1; static int bcm2835_sdhci_pio_mode = 0; -TUNABLE_INT("hw.bcm2835.sdhci.min_freq", &bcm2835_sdhci_min_freq); TUNABLE_INT("hw.bcm2835.sdhci.hs", &bcm2835_sdhci_hs); TUNABLE_INT("hw.bcm2835.sdhci.pio_mode", &bcm2835_sdhci_pio_mode); @@ -208,16 +186,12 @@ bcm_sdhci_attach(device_t dev) RF_ACTIVE); if (!sc->sc_irq_res) { device_printf(dev, "cannot allocate interrupt\n"); - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); err = ENXIO; goto fail; } if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, bcm_sdhci_intr, sc, &sc->sc_intrhand)) - { - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); - bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res); + NULL, bcm_sdhci_intr, sc, &sc->sc_intrhand)) { device_printf(dev, "cannot setup interrupt handler\n"); err = ENXIO; goto fail; @@ -283,6 +257,7 @@ fail: bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res); if (sc->sc_mem_res) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); + mtx_destroy(&sc->sc_mtx); return (err); } @@ -319,21 +294,15 @@ RD4(struct bcm_sdhci_softc *sc, bus_size static inline void WR4(struct bcm_sdhci_softc *sc, bus_size_t off, uint32_t val) { - bus_space_write_4(sc->sc_bst, sc->sc_bsh, off, val); - if ((off != SDHCI_BUFFER && off != SDHCI_INT_STATUS && off != SDHCI_CLOCK_CONTROL)) - { - int timeout = 100000; - while (val != bus_space_read_4(sc->sc_bst, sc->sc_bsh, off) - && --timeout > 0) - continue; - - if (timeout <= 0) - printf("sdhci_brcm: writing 0x%X to reg 0x%X " - "always gives 0x%X\n", - val, (uint32_t)off, - bus_space_read_4(sc->sc_bst, sc->sc_bsh, off)); - } + bus_space_write_4(sc->sc_bst, sc->sc_bsh, off, val); + /* + * The Arasan HC has a bug where it may lose the content of + * consecutive writes to registers that are within two SD-card + * clock cycles of each other (a clock domain crossing problem). + */ + if (sc->sc_slot.clock > 0) + DELAY(((2 * 1000000) / sc->sc_slot.clock) + 1); } static uint8_t @@ -425,13 +394,6 @@ bcm_sdhci_write_multi_4(device_t dev, st bus_space_write_multi_4(sc->sc_bst, sc->sc_bsh, off, data, count); } -static uint32_t -bcm_sdhci_min_freq(device_t dev, struct sdhci_slot *slot) -{ - - return bcm2835_sdhci_min_freq; -} - static void bcm_sdhci_start_dma_seg(struct bcm_sdhci_softc *sc) { @@ -684,7 +646,6 @@ static device_method_t bcm_sdhci_methods DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), - DEVMETHOD(sdhci_min_freq, bcm_sdhci_min_freq), /* Platform transfer methods */ DEVMETHOD(sdhci_platform_will_handle, bcm_sdhci_will_handle_transfer), DEVMETHOD(sdhci_platform_start_transfer, bcm_sdhci_start_transfer),