Prepare v2023.10
[platform/kernel/u-boot.git] / board / toradex / colibri_t30 / colibri_t30.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *  (C) Copyright 2014-2016
4  *  Stefan Agner <stefan@agner.ch>
5  */
6
7 #include <common.h>
8 #include <env.h>
9 #include <init.h>
10 #include <asm/arch/gp_padctrl.h>
11 #include <asm/arch/pinmux.h>
12 #include <asm/arch-tegra/ap.h>
13 #include <asm/arch-tegra/tegra.h>
14 #include <asm/gpio.h>
15 #include <asm/io.h>
16 #include <fdt_support.h>
17 #include <i2c.h>
18 #include <linux/delay.h>
19 #include "pinmux-config-colibri_t30.h"
20 #include "../common/tdx-common.h"
21
22 int 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
31 int checkboard(void)
32 {
33         puts("Model: Toradex Colibri T30 1GB\n");
34
35         return 0;
36 }
37
38 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
39 int ft_board_setup(void *blob, struct bd_info *bd)
40 {
41         u8 enetaddr[6];
42
43         /* MAC addr */
44         if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
45                 int err = fdt_find_and_setprop(blob,
46                                                "/usb@7d004000/ethernet@1",
47                                                "local-mac-address", enetaddr, 6, 0);
48
49                 /* Older device trees might have used a different node name */
50                 if (err < 0)
51                         err = fdt_find_and_setprop(blob,
52                                                    "/usb@7d004000/asix@1",
53                                                    "local-mac-address", enetaddr, 6, 0);
54
55                 if (err >= 0)
56                         puts("   MAC address updated...\n");
57         }
58
59         return ft_common_board_setup(blob, bd);
60 }
61 #endif
62
63 /*
64  * Routine: pinmux_init
65  * Description: Do individual peripheral pinmux configs
66  */
67 void pinmux_init(void)
68 {
69         pinmux_config_pingrp_table(tegra3_pinmux_common,
70                                    ARRAY_SIZE(tegra3_pinmux_common));
71
72         pinmux_config_pingrp_table(unused_pins_lowpower,
73                                    ARRAY_SIZE(unused_pins_lowpower));
74
75         /* Initialize any non-default pad configs (APB_MISC_GP regs) */
76         pinmux_config_drvgrp_table(colibri_t30_padctrl,
77                                    ARRAY_SIZE(colibri_t30_padctrl));
78 }
79
80 /*
81  * Disable RS232 serial transceiver ForceOFF# pins on Iris
82  */
83 void gpio_early_init_uart(void)
84 {
85         gpio_request(TEGRA_GPIO(X, 6), "Force OFF# X13");
86         gpio_direction_output(TEGRA_GPIO(X, 6), 1);
87         gpio_request(TEGRA_GPIO(X, 7), "Force OFF# X14");
88         gpio_direction_output(TEGRA_GPIO(X, 7), 1);
89 }
90
91 /*
92  * Enable AX88772B USB to LAN controller
93  */
94 void pin_mux_usb(void)
95 {
96         /* Reset ASIX using LAN_RESET */
97         gpio_request(TEGRA_GPIO(DD, 0), "LAN_RESET");
98         gpio_direction_output(TEGRA_GPIO(DD, 0), 0);
99         udelay(5);
100         gpio_set_value(TEGRA_GPIO(DD, 0), 1);
101 }
102
103 /*
104  * Backlight off before OS handover
105  */
106 void board_preboot_os(void)
107 {
108         gpio_request(TEGRA_GPIO(V, 2), "BL_ON");
109         gpio_direction_output(TEGRA_GPIO(V, 2), 0);
110 }