Sun Apr 16 13:27:19 2017 UTC ()
Disable SDR104 until the Tegra K1 custom tuning method is implemented.
This is required to work around errata that describes periodic data CRC
errors after autotuning has completed.


(jmcneill)
diff -r1.16 -r1.17 src/sys/arch/arm/nvidia/tegra_sdhc.c

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

--- src/sys/arch/arm/nvidia/tegra_sdhc.c 2017/04/11 11:06:02 1.16
+++ src/sys/arch/arm/nvidia/tegra_sdhc.c 2017/04/16 13:27:19 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tegra_sdhc.c,v 1.16 2017/04/11 11:06:02 jmcneill Exp $ */ 1/* $NetBSD: tegra_sdhc.c,v 1.17 2017/04/16 13:27:19 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.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
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#include "locators.h" 29#include "locators.h"
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.16 2017/04/11 11:06:02 jmcneill Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.17 2017/04/16 13:27:19 jmcneill Exp $");
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/bus.h> 35#include <sys/bus.h>
36#include <sys/device.h> 36#include <sys/device.h>
37#include <sys/intr.h> 37#include <sys/intr.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40 40
41#include <dev/sdmmc/sdhcreg.h> 41#include <dev/sdmmc/sdhcreg.h>
42#include <dev/sdmmc/sdhcvar.h> 42#include <dev/sdmmc/sdhcvar.h>
43#include <dev/sdmmc/sdmmcvar.h> 43#include <dev/sdmmc/sdmmcvar.h>
44 44
45#include <arm/nvidia/tegra_reg.h> 45#include <arm/nvidia/tegra_reg.h>
@@ -114,26 +114,34 @@ tegra_sdhc_attach(device_t parent, devic @@ -114,26 +114,34 @@ tegra_sdhc_attach(device_t parent, devic
114 if (bus_width == 8) { 114 if (bus_width == 8) {
115 sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE; 115 sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE;
116 } 116 }
117 sc->sc.sc_host = &sc->sc_host; 117 sc->sc.sc_host = &sc->sc_host;
118 118
119 sc->sc_bst = faa->faa_bst; 119 sc->sc_bst = faa->faa_bst;
120 error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); 120 error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh);
121 if (error) { 121 if (error) {
122 aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error); 122 aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
123 return; 123 return;
124 } 124 }
125 sc->sc_bsz = size; 125 sc->sc_bsz = size;
126 126
 127 /* XXX SDR104 requires a custom tuning method on Tegra K1 */
 128 sc->sc.sc_flags |= SDHC_FLAG_HOSTCAPS;
 129 sc->sc.sc_caps = bus_space_read_4(sc->sc_bst, sc->sc_bsh,
 130 SDHC_CAPABILITIES);
 131 sc->sc.sc_caps2 = bus_space_read_4(sc->sc_bst, sc->sc_bsh,
 132 SDHC_CAPABILITIES2);
 133 sc->sc.sc_caps2 &= ~SDHC_SDR104_SUPP;
 134
127 sc->sc_pin_power = fdtbus_gpio_acquire(faa->faa_phandle, 135 sc->sc_pin_power = fdtbus_gpio_acquire(faa->faa_phandle,
128 "power-gpios", GPIO_PIN_OUTPUT); 136 "power-gpios", GPIO_PIN_OUTPUT);
129 if (sc->sc_pin_power) 137 if (sc->sc_pin_power)
130 fdtbus_gpio_write(sc->sc_pin_power, 1); 138 fdtbus_gpio_write(sc->sc_pin_power, 1);
131 139
132 sc->sc_pin_cd = fdtbus_gpio_acquire(faa->faa_phandle,  140 sc->sc_pin_cd = fdtbus_gpio_acquire(faa->faa_phandle,
133 "cd-gpios", GPIO_PIN_INPUT); 141 "cd-gpios", GPIO_PIN_INPUT);
134 sc->sc_pin_wp = fdtbus_gpio_acquire(faa->faa_phandle, 142 sc->sc_pin_wp = fdtbus_gpio_acquire(faa->faa_phandle,
135 "wp-gpios", GPIO_PIN_INPUT); 143 "wp-gpios", GPIO_PIN_INPUT);
136 144
137 if (sc->sc_pin_cd) { 145 if (sc->sc_pin_cd) {
138 sc->sc.sc_vendor_card_detect = tegra_sdhc_card_detect; 146 sc->sc.sc_vendor_card_detect = tegra_sdhc_card_detect;
139 sc->sc.sc_flags |= SDHC_FLAG_POLL_CARD_DET; 147 sc->sc.sc_flags |= SDHC_FLAG_POLL_CARD_DET;