apalis-tk1: support v1.2 hardware revision
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>
Fri, 9 Aug 2019 10:21:46 +0000 (13:21 +0300)
committerTom Warren <twarren@nvidia.com>
Fri, 9 Aug 2019 17:01:35 +0000 (10:01 -0700)
Support the V1.2 hardware revision with the following pin muxing
changes:

Ddc_scl_pv4 and ddc_sda_pv5 previously used as Apalis GPIO3 and GPIO4
are now used as DDC pins.

Gen2_i2c_scl_pt5 and gen2_i2c_sda_pt6 previously used as DDC pins are
now used as USB power enable signals.

Usb_vbus_en0_pn4 and usb_vbus_en1_pn5 previously used as USB power
enable signals are now used as GPIO3 and GPIO4.

Additionally a new device tree file tegra124-apalis-v1.2-eval.dtb is
loaded on V1.2 and later modules and resp. USB power enable signals
activated.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
arch/arm/dts/tegra124-apalis.dts
board/toradex/apalis-tk1/apalis-tk1.c
board/toradex/apalis-tk1/pinmux-config-apalis-tk1.h
configs/apalis-tk1_defconfig
include/configs/apalis-tk1.h

index a962c0a2f0ae10a34840a9dd2c5087da4ef463e0..08184ab3ac29d0d7901027a6ac5d1cbe93611646 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Toradex AG
+ * Copyright 2016-2019 Toradex AG
  *
  * This file is dual-licensed: you can use it either under the terms
  * of the GPL or the X11 license, at your option. Note that this dual
                        };
 
                        /* Apalis GPIO */
-                       ddc_scl_pv4 {
-                               nvidia,pins = "ddc_scl_pv4";
+                       usb_vbus_en0_pn4 {
+                               nvidia,pins = "usb_vbus_en0_pn4";
                                nvidia,function = "rsvd2";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
+                               nvidia,open-drain = <TEGRA_PIN_DISABLE>;
                        };
-                       ddc_sda_pv5 {
-                               nvidia,pins = "ddc_sda_pv5";
+                       usb_vbus_en1_pn5 {
+                               nvidia,pins = "usb_vbus_en1_pn5";
                                nvidia,function = "rsvd2";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
+                               nvidia,open-drain = <TEGRA_PIN_DISABLE>;
                        };
                        pex_l0_rst_n_pdd1 {
                                nvidia,pins = "pex_l0_rst_n_pdd1";
                                nvidia,open-drain = <TEGRA_PIN_ENABLE>;
                        };
 
-                       /* Apalis I2C2 (DDC) */
-                       gen2_i2c_scl_pt5 {
-                               nvidia,pins = "gen2_i2c_scl_pt5";
-                               nvidia,function = "i2c2";
+                       /* Apalis I2C3 (CAM) */
+                       cam_i2c_scl_pbb1 {
+                               nvidia,pins = "cam_i2c_scl_pbb1";
+                               nvidia,function = "i2c3";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                nvidia,open-drain = <TEGRA_PIN_ENABLE>;
                        };
-                       gen2_i2c_sda_pt6 {
-                               nvidia,pins = "gen2_i2c_sda_pt6";
-                               nvidia,function = "i2c2";
+                       cam_i2c_sda_pbb2 {
+                               nvidia,pins = "cam_i2c_sda_pbb2";
+                               nvidia,function = "i2c3";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                nvidia,open-drain = <TEGRA_PIN_ENABLE>;
                        };
 
-                       /* Apalis I2C3 (CAM) */
-                       cam_i2c_scl_pbb1 {
-                               nvidia,pins = "cam_i2c_scl_pbb1";
-                               nvidia,function = "i2c3";
+                       /* Apalis I2C4 (DDC) */
+                       ddc_scl_pv4 {
+                               nvidia,pins = "ddc_scl_pv4";
+                               nvidia,function = "i2c4";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-                               nvidia,open-drain = <TEGRA_PIN_ENABLE>;
+                               nvidia,rcv-sel = <TEGRA_PIN_DISABLE>;
                        };
-                       cam_i2c_sda_pbb2 {
-                               nvidia,pins = "cam_i2c_sda_pbb2";
-                               nvidia,function = "i2c3";
+                       ddc_sda_pv5 {
+                               nvidia,pins = "ddc_sda_pv5";
+                               nvidia,function = "i2c4";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-                               nvidia,open-drain = <TEGRA_PIN_ENABLE>;
+                               nvidia,rcv-sel = <TEGRA_PIN_DISABLE>;
                        };
 
                        /* Apalis MMC1 */
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                        };
-                       /* PWM3 active on pu6 being Apalis BKL1_PWM */
+                       /* PWM3 active on pu6 being Apalis BKL1_PWM as well */
                        ph3 {
                                nvidia,pins = "ph3";
-                               nvidia,function = "gmi";
-                               nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-                               nvidia,tristate = <TEGRA_PIN_ENABLE>;
+                               nvidia,function = "pwm3";
+                               nvidia,pull = <TEGRA_PIN_PULL_NONE>;
+                               nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                        };
 
                        };
 
                        /* Apalis USBH_EN */
-                       usb_vbus_en1_pn5 {
-                               nvidia,pins = "usb_vbus_en1_pn5";
+                       gen2_i2c_sda_pt6 {
+                               nvidia,pins = "gen2_i2c_sda_pt6";
                                nvidia,function = "rsvd2";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                        };
 
                        /* Apalis USBO1_EN */
-                       usb_vbus_en0_pn4 {
-                               nvidia,pins = "usb_vbus_en0_pn4";
+                       gen2_i2c_scl_pt5 {
+                               nvidia,pins = "gen2_i2c_scl_pt5";
                                nvidia,function = "rsvd2";
                                nvidia,pull = <TEGRA_PIN_PULL_NONE>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,tristate = <TEGRA_PIN_ENABLE>;
                                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                        };
-                       pv0 { /* NC */
+                       /*
+                        * PCB Version Indication: V1.2 and later have GPIO_PV0
+                        * wired to GND, was NC before
+                        */
+                       pv0 {
                                nvidia,pins = "pv0";
                                nvidia,function = "rsvd1";
-                               nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+                               nvidia,pull = <TEGRA_PIN_PULL_UP>;
                                nvidia,tristate = <TEGRA_PIN_ENABLE>;
                                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                        };
                };
        };
 
-       /*
-        * GEN2_I2C: I2C2_SDA/SCL (DDC) on MXM3 pin 205/207 (e.g. display EDID)
-        */
-       hdmi_ddc: i2c@7000c400 {
-               status = "okay";
-               clock-frequency = <10000>;
-       };
+       /* GEN2_I2C: unused */
 
        /*
         * CAM_I2C: I2C3_SDA/SCL (CAM) on MXM3 pin 201/203 (e.g. camera sensor
                clock-frequency = <400000>;
        };
 
-       /* I2C4 (DDC): unused */
+       /*
+        * I2C4 (DDC): I2C4_SDA/SCL (DDC) on MXM3 pin 205/207
+        * (e.g. display EDID)
+        */
+       hdmi_ddc: i2c@7000c700 {
+               status = "okay";
+               clock-frequency = <10000>;
+       };
 
        /* PWR_I2C: power I2C to audio codec, PMIC and temperature sensor */
        i2c@7000d000 {
                regulator-name = "VCC_USBO1";
                regulator-min-microvolt = <5000000>;
                regulator-max-microvolt = <5000000>;
-               gpio = <&gpio TEGRA_GPIO(N, 4) GPIO_ACTIVE_HIGH>;
+               gpio = <&gpio TEGRA_GPIO(T, 5) GPIO_ACTIVE_HIGH>;
                enable-active-high;
                vin-supply = <&reg_5v0>;
        };
                regulator-name = "VCC_USBH(2A|2C|2D|3|4)";
                regulator-min-microvolt = <5000000>;
                regulator-max-microvolt = <5000000>;
-               gpio = <&gpio TEGRA_GPIO(N, 5) GPIO_ACTIVE_HIGH>;
+               gpio = <&gpio TEGRA_GPIO(T, 6) GPIO_ACTIVE_HIGH>;
                enable-active-high;
                vin-supply = <&reg_5v0>;
        };
index d57c5042dddb98a5a724755c7017d6736970dbd6..beb7e10dfedfa64b19d0a12fcc24d34b7570d7f4 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
+#include <environment.h>
 #include <pci_tegra.h>
 #include <power/as3722.h>
 #include <power/pmic.h>
 #define PEX_PERST_N    TEGRA_GPIO(DD, 1) /* Apalis GPIO7 */
 #define RESET_MOCI_CTRL        TEGRA_GPIO(U, 4)
 #endif /* CONFIG_APALIS_TK1_PCIE_EVALBOARD_INIT */
+#define VCC_USBH       TEGRA_GPIO(T, 6)
+#define VCC_USBH_V1_0  TEGRA_GPIO(N, 5)
+#define VCC_USBO1      TEGRA_GPIO(T, 5)
+#define VCC_USBO1_V1_0 TEGRA_GPIO(N, 4)
 
 int arch_misc_init(void)
 {
@@ -32,6 +37,38 @@ int arch_misc_init(void)
            NVBOOTTYPE_RECOVERY)
                printf("USB recovery mode\n");
 
+       /* PCB Version Indication: V1.2 and later have GPIO_PV0 wired to GND */
+       gpio_request(TEGRA_GPIO(V, 0), "PCB Version Indication");
+       gpio_direction_input(TEGRA_GPIO(V, 0));
+       if (gpio_get_value(TEGRA_GPIO(V, 0))) {
+               /*
+                * if using the default device tree for new V1.2 and later HW,
+                * use version for older V1.0 and V1.1 HW
+                */
+               char *fdt_env = env_get("fdt_module");
+
+               if (fdt_env && !strcmp(FDT_MODULE, fdt_env)) {
+                       env_set("fdt_module", FDT_MODULE_V1_0);
+                       printf("patching fdt_module to " FDT_MODULE_V1_0
+                              " for older V1.0 and V1.1 HW\n");
+#ifndef CONFIG_ENV_IS_NOWHERE
+                       env_save();
+#endif
+               }
+
+               /* activate USB power enable GPIOs */
+               gpio_request(VCC_USBH_V1_0, "VCC_USBH");
+               gpio_direction_output(VCC_USBH_V1_0, 1);
+               gpio_request(VCC_USBO1_V1_0, "VCC_USBO1");
+               gpio_direction_output(VCC_USBO1_V1_0, 1);
+       } else {
+               /* activate USB power enable GPIOs */
+               gpio_request(VCC_USBH, "VCC_USBH");
+               gpio_direction_output(VCC_USBH, 1);
+               gpio_request(VCC_USBO1, "VCC_USBO1");
+               gpio_direction_output(VCC_USBO1, 1);
+       }
+
        return 0;
 }
 
index d2d24c4391698adb01b4a938d5d24c09781a7b42..6778a41e07db39ad95171c9cc62fbf712b0e8031 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (c) 2016, Toradex, Inc.
+ * Copyright (c) 2016-2019, Toradex, Inc.
  */
 
 #ifndef _PINMUX_CONFIG_APALIS_TK1_H_
@@ -24,8 +24,6 @@ static const struct tegra_gpio_config apalis_tk1_gpio_inits[] = {
        GPIO_INIT(K,    2,   IN),
        GPIO_INIT(K,    7,   IN),
        GPIO_INIT(N,    2,   OUT1),
-       GPIO_INIT(N,    4,   OUT1),
-       GPIO_INIT(N,    5,   OUT1),
        GPIO_INIT(N,    7,   IN),
        GPIO_INIT(O,    5,   IN),
        GPIO_INIT(Q,    0,   OUT0), /* Shift_CTRL_OE[0] */
@@ -40,6 +38,7 @@ static const struct tegra_gpio_config apalis_tk1_gpio_inits[] = {
        GPIO_INIT(R,    2,   OUT0), /* Shift_CTRL_OE[3] */
        GPIO_INIT(S,    3,   OUT0), /* Shift_CTRL_Dir_In[2] */
        GPIO_INIT(U,    4,   OUT0), /* RESET_MOCI_CTRL */
+       GPIO_INIT(V,    0,   IN),
        GPIO_INIT(W,    3,   IN),
        GPIO_INIT(W,    5,   IN),
        GPIO_INIT(BB,   0,  IN),
@@ -130,8 +129,8 @@ static const struct pmux_pingrp_config apalis_tk1_pingrps[] = {
        PINCFG(DAP1_DIN_PN1,           RSVD4,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(DAP1_DOUT_PN2,          SATA,         NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(DAP1_SCLK_PN3,          RSVD4,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
-       PINCFG(USB_VBUS_EN0_PN4,       RSVD2,        NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
-       PINCFG(USB_VBUS_EN1_PN5,       RSVD2,        NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
+       PINCFG(USB_VBUS_EN0_PN4,       RSVD2,        NORMAL, NORMAL,   INPUT,   DISABLE, DEFAULT),
+       PINCFG(USB_VBUS_EN1_PN5,       RSVD2,        NORMAL, NORMAL,   INPUT,   DISABLE, DEFAULT),
        PINCFG(HDMI_INT_PN7,           RSVD1,        DOWN,   TRISTATE, INPUT,   DEFAULT, NORMAL),
        PINCFG(ULPI_DATA7_PO0,         ULPI,         DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(ULPI_DATA0_PO1,         ULPI,         DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
@@ -175,8 +174,8 @@ static const struct pmux_pingrp_config apalis_tk1_pingrps[] = {
        PINCFG(KB_ROW15_PS7,           RSVD2,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(KB_ROW16_PT0,           RSVD2,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(KB_ROW17_PT1,           RSVD2,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
-       PINCFG(GEN2_I2C_SCL_PT5,       I2C2,         NORMAL, NORMAL,   INPUT,   ENABLE,  DEFAULT),
-       PINCFG(GEN2_I2C_SDA_PT6,       I2C2,         NORMAL, NORMAL,   INPUT,   ENABLE,  DEFAULT),
+       PINCFG(GEN2_I2C_SCL_PT5,       RSVD2,        NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
+       PINCFG(GEN2_I2C_SDA_PT6,       RSVD2,        NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
        PINCFG(SDMMC4_CMD_PT7,         SDMMC4,       UP,     NORMAL,   INPUT,   DEFAULT, DEFAULT),
        PINCFG(PU0,                    UARTA,        NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(PU1,                    UARTA,        NORMAL, TRISTATE, INPUT,   DEFAULT, DEFAULT),
@@ -185,12 +184,12 @@ static const struct pmux_pingrp_config apalis_tk1_pingrps[] = {
        PINCFG(PU4,                    GMI,          NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(PU5,                    GMI,          DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(PU6,                    PWM3,         NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
-       PINCFG(PV0,                    RSVD1,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
+       PINCFG(PV0,                    RSVD1,        UP,     NORMAL,   INPUT,   DEFAULT, DEFAULT),
        PINCFG(PV1,                    RSVD1,        DOWN,   TRISTATE, OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(SDMMC3_CD_N_PV2,        RSVD3,        UP,     TRISTATE, INPUT,   DEFAULT, DEFAULT),
        PINCFG(SDMMC1_WP_N_PV3,        SDMMC1,       UP,     TRISTATE, INPUT,   DEFAULT, DEFAULT),
-       PINCFG(DDC_SCL_PV4,            RSVD2,        NORMAL, NORMAL,   INPUT,   DEFAULT, DEFAULT),
-       PINCFG(DDC_SDA_PV5,            RSVD2,        NORMAL, NORMAL,   INPUT,   DEFAULT, DEFAULT),
+       PINCFG(DDC_SCL_PV4,            I2C4,         NORMAL, NORMAL,   INPUT,   DEFAULT, NORMAL),
+       PINCFG(DDC_SDA_PV5,            I2C4,         NORMAL, NORMAL,   INPUT,   DEFAULT, NORMAL),
        PINCFG(GPIO_W2_AUD_PW2,        SPI2,         NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(GPIO_W3_AUD_PW3,        SPI6,         NORMAL, TRISTATE, INPUT,   DEFAULT, DEFAULT),
        PINCFG(DAP_MCLK1_PW4,          EXTPERIPH1,   NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
index 67f7731a42dc52f0970004ba671f283de209a3c9..be0554b15048df1751bb385cb1e98909445fae89 100644 (file)
@@ -8,7 +8,7 @@ CONFIG_TARGET_APALIS_TK1=y
 CONFIG_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=1
-CONFIG_BOOTCOMMAND="run emmcboot; setenv fdtfile ${soc}-apalis-${fdt_board}.dtb && run distro_bootcmd"
+CONFIG_BOOTCOMMAND="run emmcboot; setenv fdtfile ${soc}-${fdt-module}-${fdt_board}.dtb && run distro_bootcmd"
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_VERSION_VARIABLE=y
index 843e64e3cc8b0cd1e5ffde08547a07cffd7ca124..a21975050a5f58385da2dd141680fbb8a9d71146 100644 (file)
@@ -18,6 +18,9 @@
 #define CONFIG_TEGRA_ENABLE_UARTA
 #define CONFIG_SYS_NS16550_COM1                NV_PA_APB_UARTA_BASE
 
+#define FDT_MODULE                     "apalis-v1.2"
+#define FDT_MODULE_V1_0                        "apalis"
+
 /* Environment in eMMC, before config block at the end of 1st "boot sector" */
 #define CONFIG_ENV_OFFSET              (-CONFIG_ENV_SIZE + \
                                         CONFIG_TDX_CFG_BLOCK_OFFSET)
@@ -58,7 +61,7 @@
        "emmcbootpart=1\0" \
        "emmcdev=0\0" \
        "emmcdtbload=setenv dtbparam; load mmc ${emmcdev}:${emmcbootpart} " \
-               "${fdt_addr_r} ${soc}-apalis-${fdt_board}.dtb && " \
+               "${fdt_addr_r} ${soc}-${fdt_module}-${fdt_board}.dtb && " \
                "setenv dtbparam ${fdt_addr_r}\0" \
        "emmcfinduuid=part uuid mmc ${mmcdev}:${emmcrootpart} uuid\0" \
        "emmcrootpart=2\0"
@@ -70,7 +73,7 @@
                "run nfsdtbload; dhcp ${kernel_addr_r} " \
                "&& run fdt_fixup && bootz ${kernel_addr_r} - ${dtbparam}\0" \
        "nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r} " \
-               "${soc}-apalis-${fdt_board}.dtb " \
+               "${soc}-${fdt_module}-${fdt_board}.dtb " \
                "&& setenv dtbparam ${fdt_addr_r}\0"
 
 #define SD_BOOTCMD \
@@ -85,7 +88,7 @@
        "sdbootpart=1\0" \
        "sddev=1\0" \
        "sddtbload=setenv dtbparam; load mmc ${sddev}:${sdbootpart} " \
-               "${fdt_addr_r} ${soc}-apalis-${fdt_board}.dtb " \
+               "${fdt_addr_r} ${soc}-${fdt_module}-${fdt_board}.dtb " \
                "&& setenv dtbparam ${fdt_addr_r}\0" \
        "sdfinduuid=part uuid mmc ${sddev}:${sdrootpart} uuid\0" \
        "sdrootpart=2\0"
        "usbbootpart=1\0" \
        "usbdev=0\0" \
        "usbdtbload=setenv dtbparam; load usb ${usbdev}:${usbbootpart} " \
-               "${fdt_addr_r} ${soc}-apalis-${fdt_board}.dtb " \
+               "${fdt_addr_r} ${soc}-${fdt_module}-${fdt_board}.dtb " \
                "&& setenv dtbparam ${fdt_addr_r}\0" \
        "usbfinduuid=part uuid usb ${usbdev}:${usbrootpart} uuid\0" \
        "usbrootpart=2\0"
        EMMC_BOOTCMD \
        "fdt_board=eval\0" \
        "fdt_fixup=;\0" \
+       "fdt_module=" FDT_MODULE "\0" \
        NFS_BOOTCMD \
        SD_BOOTCMD \
        USB_BOOTCMD \