1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2014-2018
4 * Marcel Ziswiler <marcel@ziswiler.com>
11 #include <asm/arch/gp_padctrl.h>
12 #include <asm/arch/pinmux.h>
13 #include <asm/arch-tegra/ap.h>
14 #include <asm/arch-tegra/tegra.h>
15 #include <asm/global_data.h>
20 #include <fdt_support.h>
21 #include <pci_tegra.h>
22 #include <linux/delay.h>
23 #include "../common/tdx-common.h"
25 #include "pinmux-config-apalis_t30.h"
27 DECLARE_GLOBAL_DATA_PTR;
29 #define PMU_I2C_ADDRESS 0x2D
30 #define MAX_I2C_RETRY 3
32 #ifdef CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT
33 #define PEX_PERST_N TEGRA_GPIO(S, 7) /* Apalis GPIO7 */
34 #define RESET_MOCI_CTRL TEGRA_GPIO(I, 4)
36 static int pci_reset_status;
37 #endif /* CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT */
39 int arch_misc_init(void)
41 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
43 printf("USB recovery mode\n");
50 printf("Model: Toradex Apalis T30 %dGB\n",
51 (gd->ram_size == 0x40000000) ? 1 : 2);
56 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
57 int ft_board_setup(void *blob, struct bd_info *bd)
62 if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
63 int err = fdt_find_and_setprop(blob,
64 "/pcie@3000/pci@3,0/ethernet@0,0",
65 "local-mac-address", enetaddr, 6, 0);
67 /* Older device trees might have used a different node name */
69 err = fdt_find_and_setprop(blob,
70 "/pcie@3000/pci@3,0/pcie@0",
71 "local-mac-address", enetaddr, 6, 0);
74 puts(" MAC address updated...\n");
77 return ft_common_board_setup(blob, bd);
82 * Routine: pinmux_init
83 * Description: Do individual peripheral pinmux configs
85 void pinmux_init(void)
87 pinmux_config_pingrp_table(tegra3_pinmux_common,
88 ARRAY_SIZE(tegra3_pinmux_common));
90 pinmux_config_pingrp_table(unused_pins_lowpower,
91 ARRAY_SIZE(unused_pins_lowpower));
93 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
94 pinmux_config_drvgrp_table(apalis_t30_padctrl,
95 ARRAY_SIZE(apalis_t30_padctrl));
98 #ifdef CONFIG_PCI_TEGRA
99 int tegra_pcie_board_init(void)
105 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
107 debug("%s: Cannot find PMIC I2C chip\n", __func__);
111 /* TPS659110: VDD2_OP_REG = 1.05V */
115 err = dm_i2c_write(dev, addr, data, 1);
117 debug("failed to set VDD supply\n");
121 /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
125 err = dm_i2c_write(dev, addr, data, 1);
127 debug("failed to enable VDD supply\n");
131 /* TPS659110: LDO6_REG = 1.1V, ACTIVE */
135 err = dm_i2c_write(dev, addr, data, 1);
137 debug("failed to set AVDD supply\n");
141 #ifdef CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT
142 gpio_request(PEX_PERST_N, "PEX_PERST_N");
143 gpio_request(RESET_MOCI_CTRL, "RESET_MOCI_CTRL");
144 #endif /* CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT */
149 void tegra_pcie_board_port_reset(struct tegra_pcie_port *port)
151 int index = tegra_pcie_port_index_of_port(port);
153 if (index == 2) { /* I210 Gigabit Ethernet Controller (On-module) */
154 tegra_pcie_port_reset(port);
156 #ifdef CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT
158 * Apalis PCIe aka port 1 and Apalis Type Specific 4 Lane PCIe aka port
159 * 0 share the same RESET_MOCI therefore only assert it once for both
160 * ports to avoid losing the previously brought up port again.
162 else if ((index == 1) || (index == 0)) {
163 /* only do it once per init cycle */
164 if (pci_reset_status % 2 == 0) {
166 * Reset PLX PEX 8605 PCIe Switch plus PCIe devices on
167 * Apalis Evaluation Board
169 gpio_direction_output(PEX_PERST_N, 0);
170 gpio_direction_output(RESET_MOCI_CTRL, 0);
173 * Must be asserted for 100 ms after power and clocks
178 gpio_set_value(PEX_PERST_N, 1);
180 * Err_5: PEX_REFCLK_OUTpx/nx Clock Outputs is not
181 * Guaranteed Until 900 us After PEX_PERST# De-assertion
184 gpio_set_value(RESET_MOCI_CTRL, 1);
188 #endif /* CONFIG_APALIS_T30_PCIE_EVALBOARD_INIT */
190 #endif /* CONFIG_PCI_TEGRA */
193 * Backlight off before OS handover
195 void board_preboot_os(void)
197 gpio_request(TEGRA_GPIO(V, 2), "BKL1_ON");
198 gpio_direction_output(TEGRA_GPIO(V, 2), 0);