From owner-svn-src-all@FreeBSD.ORG Sat Oct 18 19:01:07 2014 Return-Path: Delivered-To: svn-src-all@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 E639047A; Sat, 18 Oct 2014 19:01:07 +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 B8656F10; Sat, 18 Oct 2014 19:01:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9IJ17pb003708; Sat, 18 Oct 2014 19:01:07 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9IJ17LF003707; Sat, 18 Oct 2014 19:01:07 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201410181901.s9IJ17LF003707@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, 18 Oct 2014 19:01:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273264 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Oct 2014 19:01:08 -0000 Author: loos Date: Sat Oct 18 19:01:07 2014 New Revision: 273264 URL: https://svnweb.freebsd.org/changeset/base/273264 Log: 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. MFC after: 1 week Relnotes: yes Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sat Oct 18 18:27:24 2014 (r273263) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sat Oct 18 19:01:07 2014 (r273264) @@ -312,21 +312,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