Sun Feb 6 15:40:55 2022 UTC ()
sdhc: tegra: Set SDHC_FLAG_BROKEN_ADMA2_ZEROLEN quirk flag.

The Tegra SDHCI implementation apparently treats ADMA2 descriptors with
length of 0 incorrectly.


(jmcneill)
diff -r1.30 -r1.31 src/sys/arch/arm/nvidia/tegra_sdhc.c

cvs diff -r1.30 -r1.31 src/sys/arch/arm/nvidia/tegra_sdhc.c (expand / switch to unified diff)

--- src/sys/arch/arm/nvidia/tegra_sdhc.c 2022/01/22 15:10:30 1.30
+++ src/sys/arch/arm/nvidia/tegra_sdhc.c 2022/02/06 15:40:55 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tegra_sdhc.c,v 1.30 2022/01/22 15:10:30 skrll Exp $ */ 1/* $NetBSD: tegra_sdhc.c,v 1.31 2022/02/06 15:40:55 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#define TEGRA_SDHC_NO_SDR104 29#define TEGRA_SDHC_NO_SDR104
30 30
31#include "locators.h" 31#include "locators.h"
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.30 2022/01/22 15:10:30 skrll Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.31 2022/02/06 15:40:55 jmcneill Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/bus.h> 37#include <sys/bus.h>
38#include <sys/device.h> 38#include <sys/device.h>
39#include <sys/intr.h> 39#include <sys/intr.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/kernel.h> 41#include <sys/kernel.h>
42 42
43#include <dev/sdmmc/sdhcreg.h> 43#include <dev/sdmmc/sdhcreg.h>
44#include <dev/sdmmc/sdhcvar.h> 44#include <dev/sdmmc/sdhcvar.h>
45#include <dev/sdmmc/sdmmcvar.h> 45#include <dev/sdmmc/sdmmcvar.h>
46 46
47#include <arm/nvidia/tegra_reg.h> 47#include <arm/nvidia/tegra_reg.h>
@@ -120,27 +120,28 @@ tegra_sdhc_attach(device_t parent, devic @@ -120,27 +120,28 @@ tegra_sdhc_attach(device_t parent, devic
120 if (error != 0) { 120 if (error != 0) {
121 aprint_error(": couldn't create DMA tag: %d\n", error); 121 aprint_error(": couldn't create DMA tag: %d\n", error);
122 return; 122 return;
123 } 123 }
124#endif 124#endif
125 125
126 sc->sc.sc_flags = SDHC_FLAG_32BIT_ACCESS | 126 sc->sc.sc_flags = SDHC_FLAG_32BIT_ACCESS |
127 SDHC_FLAG_NO_PWR0 | 127 SDHC_FLAG_NO_PWR0 |
128 SDHC_FLAG_NO_CLKBASE | 128 SDHC_FLAG_NO_CLKBASE |
129 SDHC_FLAG_NO_TIMEOUT | 129 SDHC_FLAG_NO_TIMEOUT |
130 SDHC_FLAG_SINGLE_POWER_WRITE | 130 SDHC_FLAG_SINGLE_POWER_WRITE |
131 SDHC_FLAG_NO_HS_BIT | 131 SDHC_FLAG_NO_HS_BIT |
132 SDHC_FLAG_USE_DMA | 132 SDHC_FLAG_USE_DMA |
133 SDHC_FLAG_USE_ADMA2; 133 SDHC_FLAG_USE_ADMA2 |
 134 SDHC_FLAG_BROKEN_ADMA2_ZEROLEN;
134 if (bus_width == 8) { 135 if (bus_width == 8) {
135 sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE; 136 sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE;
136 } 137 }
137 sc->sc.sc_host = &sc->sc_host; 138 sc->sc.sc_host = &sc->sc_host;
138 139
139 sc->sc_bst = faa->faa_bst; 140 sc->sc_bst = faa->faa_bst;
140 error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); 141 error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh);
141 if (error) { 142 if (error) {
142 aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", addr, error); 143 aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", addr, error);
143 return; 144 return;
144 } 145 }
145 sc->sc_bsz = size; 146 sc->sc_bsz = size;
146 147