blob: 0da247de98f91e0b338120e872a714c33ce0beb1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Agner60bae8c2014-08-05 23:27:30 +02002/*
Marcel Ziswilerd92dee52016-11-16 17:49:23 +01003 * (C) Copyright 2014-2016
Stefan Agner60bae8c2014-08-05 23:27:30 +02004 * Stefan Agner <stefan@agner.ch>
Stefan Agner60bae8c2014-08-05 23:27:30 +02005 */
6
Tom Riniabb9a042024-05-18 20:20:43 -06007#include <common.h>
Marcel Ziswiler61c99fe2022-05-21 12:42:46 +02008#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Stefan Agner60bae8c2014-08-05 23:27:30 +020010#include <asm/arch/gp_padctrl.h>
Marcel Ziswiler764d4122015-08-06 00:47:10 +020011#include <asm/arch/pinmux.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020012#include <asm/arch-tegra/ap.h>
13#include <asm/arch-tegra/tegra.h>
Marcel Ziswiler764d4122015-08-06 00:47:10 +020014#include <asm/gpio.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020015#include <asm/io.h>
Marcel Ziswiler61c99fe2022-05-21 12:42:46 +020016#include <fdt_support.h>
Stefan Agner60bae8c2014-08-05 23:27:30 +020017#include <i2c.h>
Simon Glassdbd79542020-05-10 11:40:11 -060018#include <linux/delay.h>
Marcel Ziswiler764d4122015-08-06 00:47:10 +020019#include "pinmux-config-colibri_t30.h"
Stefan Agner98ffd0f2016-11-30 13:41:53 -080020#include "../common/tdx-common.h"
Stefan Agner60bae8c2014-08-05 23:27:30 +020021
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020022int arch_misc_init(void)
23{
24 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
25 NVBOOTTYPE_RECOVERY)
26 printf("USB recovery mode\n");
27
28 return 0;
29}
30
Stefan Agner98ffd0f2016-11-30 13:41:53 -080031#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090032int ft_board_setup(void *blob, struct bd_info *bd)
Stefan Agner98ffd0f2016-11-30 13:41:53 -080033{
Marcel Ziswiler61c99fe2022-05-21 12:42:46 +020034 u8 enetaddr[6];
35
36 /* MAC addr */
37 if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
38 int err = fdt_find_and_setprop(blob,
39 "/usb@7d004000/ethernet@1",
40 "local-mac-address", enetaddr, 6, 0);
41
42 /* Older device trees might have used a different node name */
43 if (err < 0)
44 err = fdt_find_and_setprop(blob,
45 "/usb@7d004000/asix@1",
46 "local-mac-address", enetaddr, 6, 0);
47
48 if (err >= 0)
49 puts(" MAC address updated...\n");
50 }
51
Stefan Agner98ffd0f2016-11-30 13:41:53 -080052 return ft_common_board_setup(blob, bd);
53}
54#endif
55
Stefan Agner60bae8c2014-08-05 23:27:30 +020056/*
57 * Routine: pinmux_init
58 * Description: Do individual peripheral pinmux configs
59 */
60void pinmux_init(void)
61{
62 pinmux_config_pingrp_table(tegra3_pinmux_common,
63 ARRAY_SIZE(tegra3_pinmux_common));
64
65 pinmux_config_pingrp_table(unused_pins_lowpower,
66 ARRAY_SIZE(unused_pins_lowpower));
67
68 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
69 pinmux_config_drvgrp_table(colibri_t30_padctrl,
70 ARRAY_SIZE(colibri_t30_padctrl));
71}
72
73/*
Marcel Ziswiler7d442952019-09-12 11:12:56 +020074 * Disable RS232 serial transceiver ForceOFF# pins on Iris
75 */
76void gpio_early_init_uart(void)
77{
78 gpio_request(TEGRA_GPIO(X, 6), "Force OFF# X13");
79 gpio_direction_output(TEGRA_GPIO(X, 6), 1);
80 gpio_request(TEGRA_GPIO(X, 7), "Force OFF# X14");
81 gpio_direction_output(TEGRA_GPIO(X, 7), 1);
82}
83
84/*
Stefan Agner60bae8c2014-08-05 23:27:30 +020085 * Enable AX88772B USB to LAN controller
86 */
87void pin_mux_usb(void)
88{
89 /* Reset ASIX using LAN_RESET */
Stephen Warren7f20bb22016-05-12 12:07:39 -060090 gpio_request(TEGRA_GPIO(DD, 0), "LAN_RESET");
91 gpio_direction_output(TEGRA_GPIO(DD, 0), 0);
Stefan Agner60bae8c2014-08-05 23:27:30 +020092 udelay(5);
Stephen Warren7f20bb22016-05-12 12:07:39 -060093 gpio_set_value(TEGRA_GPIO(DD, 0), 1);
Stefan Agner60bae8c2014-08-05 23:27:30 +020094}
Gerard Salvatella108d7392018-11-19 15:54:10 +010095
96/*
97 * Backlight off before OS handover
98 */
99void board_preboot_os(void)
100{
101 gpio_request(TEGRA_GPIO(V, 2), "BL_ON");
102 gpio_direction_output(TEGRA_GPIO(V, 2), 0);
103}