d21ff544f4bdab952263b8291108153933ef5210
[oweals/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 <init.h>
9 #include <asm/arch/gp_padctrl.h>
10 #include <asm/arch/pinmux.h>
11 #include <asm/arch-tegra/ap.h>
12 #include <asm/arch-tegra/tegra.h>
13 #include <asm/gpio.h>
14 #include <asm/io.h>
15 #include <i2c.h>
16 #include "pinmux-config-colibri_t30.h"
17 #include "../common/tdx-common.h"
18
19 int arch_misc_init(void)
20 {
21         if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
22             NVBOOTTYPE_RECOVERY)
23                 printf("USB recovery mode\n");
24
25         return 0;
26 }
27
28 int checkboard(void)
29 {
30         puts("Model: Toradex Colibri T30 1GB\n");
31
32         return 0;
33 }
34
35 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
36 int ft_board_setup(void *blob, bd_t *bd)
37 {
38         return ft_common_board_setup(blob, bd);
39 }
40 #endif
41
42 /*
43  * Routine: pinmux_init
44  * Description: Do individual peripheral pinmux configs
45  */
46 void pinmux_init(void)
47 {
48         pinmux_config_pingrp_table(tegra3_pinmux_common,
49                                    ARRAY_SIZE(tegra3_pinmux_common));
50
51         pinmux_config_pingrp_table(unused_pins_lowpower,
52                                    ARRAY_SIZE(unused_pins_lowpower));
53
54         /* Initialize any non-default pad configs (APB_MISC_GP regs) */
55         pinmux_config_drvgrp_table(colibri_t30_padctrl,
56                                    ARRAY_SIZE(colibri_t30_padctrl));
57 }
58
59 /*
60  * Enable AX88772B USB to LAN controller
61  */
62 void pin_mux_usb(void)
63 {
64         /* Reset ASIX using LAN_RESET */
65         gpio_request(TEGRA_GPIO(DD, 0), "LAN_RESET");
66         gpio_direction_output(TEGRA_GPIO(DD, 0), 0);
67         udelay(5);
68         gpio_set_value(TEGRA_GPIO(DD, 0), 1);
69 }
70
71 /*
72  * Backlight off before OS handover
73  */
74 void board_preboot_os(void)
75 {
76         gpio_request(TEGRA_GPIO(V, 2), "BL_ON");
77         gpio_direction_output(TEGRA_GPIO(V, 2), 0);
78 }