Thu Oct 19 16:01:58 2017 UTC ()
Don't call tegra_pcie_reset_port for now - it makes tk1 re @ pci not work


(skrll)
diff -r1.22 -r1.23 src/sys/arch/arm/nvidia/tegra_pcie.c

cvs diff -r1.22 -r1.23 src/sys/arch/arm/nvidia/tegra_pcie.c (expand / switch to unified diff)

--- src/sys/arch/arm/nvidia/tegra_pcie.c 2017/09/27 10:19:13 1.22
+++ src/sys/arch/arm/nvidia/tegra_pcie.c 2017/10/19 16:01:58 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tegra_pcie.c,v 1.22 2017/09/27 10:19:13 jmcneill Exp $ */ 1/* $NetBSD: tegra_pcie.c,v 1.23 2017/10/19 16:01:58 skrll 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.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
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 <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: tegra_pcie.c,v 1.22 2017/09/27 10:19:13 jmcneill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: tegra_pcie.c,v 1.23 2017/10/19 16:01:58 skrll Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/bus.h> 33#include <sys/bus.h>
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/intr.h> 35#include <sys/intr.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/extent.h> 38#include <sys/extent.h>
39#include <sys/queue.h> 39#include <sys/queue.h>
40#include <sys/mutex.h> 40#include <sys/mutex.h>
41#include <sys/kmem.h> 41#include <sys/kmem.h>
42 42
43#include <arm/cpufunc.h> 43#include <arm/cpufunc.h>
@@ -345,41 +345,43 @@ tegra_pcie_enable_clocks(struct tegra_pc @@ -345,41 +345,43 @@ tegra_pcie_enable_clocks(struct tegra_pc
345 if (clk == NULL || clk_enable(clk) != 0) 345 if (clk == NULL || clk_enable(clk) != 0)
346 aprint_error_dev(sc->sc_dev, "couldn't enable clock %s\n", 346 aprint_error_dev(sc->sc_dev, "couldn't enable clock %s\n",
347 clock_names[n]); 347 clock_names[n]);
348 } 348 }
349 349
350 for (n = 0; n < __arraycount(reset_names); n++) { 350 for (n = 0; n < __arraycount(reset_names); n++) {
351 rst = fdtbus_reset_get(sc->sc_phandle, reset_names[n]); 351 rst = fdtbus_reset_get(sc->sc_phandle, reset_names[n]);
352 if (rst == NULL || fdtbus_reset_deassert(rst) != 0) 352 if (rst == NULL || fdtbus_reset_deassert(rst) != 0)
353 aprint_error_dev(sc->sc_dev, "couldn't de-assert reset %s\n", 353 aprint_error_dev(sc->sc_dev, "couldn't de-assert reset %s\n",
354 reset_names[n]); 354 reset_names[n]);
355 } 355 }
356} 356}
357 357
 358#if 0
358static void 359static void
359tegra_pcie_reset_port(struct tegra_pcie_softc * const sc, int index) 360tegra_pcie_reset_port(struct tegra_pcie_softc * const sc, int index)
360{ 361{
361 uint32_t val; 362 uint32_t val;
362 363
363 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index)); 364 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index));
364 val &= ~AFI_PEXn_CTRL_RST_L; 365 val &= ~AFI_PEXn_CTRL_RST_L;
365 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val); 366 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val);
366 367
367 delay(2000); 368 delay(2000);
368 369
369 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index)); 370 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index));
370 val |= AFI_PEXn_CTRL_RST_L; 371 val |= AFI_PEXn_CTRL_RST_L;
371 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val); 372 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val);
372} 373}
 374#endif
373 375
374static void 376static void
375tegra_pcie_enable_ports(struct tegra_pcie_softc * const sc) 377tegra_pcie_enable_ports(struct tegra_pcie_softc * const sc)
376{ 378{
377 struct fdtbus_phy *phy; 379 struct fdtbus_phy *phy;
378 const u_int *data; 380 const u_int *data;
379 int child, len, n; 381 int child, len, n;
380 uint32_t val; 382 uint32_t val;
381 383
382 for (child = OF_child(sc->sc_phandle); child; child = OF_peer(child)) { 384 for (child = OF_child(sc->sc_phandle); child; child = OF_peer(child)) {
383 if (!fdtbus_status_okay(child)) 385 if (!fdtbus_status_okay(child))
384 continue; 386 continue;
385 387
@@ -390,27 +392,29 @@ tegra_pcie_enable_ports(struct tegra_pci @@ -390,27 +392,29 @@ tegra_pcie_enable_ports(struct tegra_pci
390 fdtbus_get_string(child, "name"), n); 392 fdtbus_get_string(child, "name"), n);
391 393
392 data = fdtbus_get_prop(child, "reg", &len); 394 data = fdtbus_get_prop(child, "reg", &len);
393 if (data == NULL || len < 4) 395 if (data == NULL || len < 4)
394 continue; 396 continue;
395 const u_int index = ((be32toh(data[0]) >> 11) & 0x1f) - 1; 397 const u_int index = ((be32toh(data[0]) >> 11) & 0x1f) - 1;
396 398
397 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index)); 399 val = bus_space_read_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index));
398 val |= AFI_PEXn_CTRL_CLKREQ_EN; 400 val |= AFI_PEXn_CTRL_CLKREQ_EN;
399 val |= AFI_PEXn_CTRL_REFCLK_EN; 401 val |= AFI_PEXn_CTRL_REFCLK_EN;
400 val |= AFI_PEXn_CTRL_REFCLK_OVERRIDE_EN; 402 val |= AFI_PEXn_CTRL_REFCLK_OVERRIDE_EN;
401 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val); 403 bus_space_write_4(sc->sc_bst, sc->sc_bsh_afi, AFI_PEXn_CTRL_REG(index), val);
402 404
 405#if 0
403 tegra_pcie_reset_port(sc, index); 406 tegra_pcie_reset_port(sc, index);
 407#endif
404 408
405 } 409 }
406} 410}
407 411
408static void 412static void
409tegra_pcie_setup(struct tegra_pcie_softc * const sc) 413tegra_pcie_setup(struct tegra_pcie_softc * const sc)
410{ 414{
411 uint32_t val, cfg, lanes; 415 uint32_t val, cfg, lanes;
412 int child, len; 416 int child, len;
413 const u_int *data; 417 const u_int *data;
414 size_t i; 418 size_t i;
415 419
416 /* Enable PLLE control */ 420 /* Enable PLLE control */