Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 2 | /* |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 3 | * (C) Copyright 2014-2016 |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 4 | * Stefan Agner <stefan@agner.ch> |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Marcel Ziswiler | 61c99fe | 2022-05-21 12:42:46 +0200 | [diff] [blame] | 8 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 10 | #include <asm/arch/gp_padctrl.h> |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 11 | #include <asm/arch/pinmux.h> |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 12 | #include <asm/arch-tegra/ap.h> |
| 13 | #include <asm/arch-tegra/tegra.h> |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 14 | #include <asm/gpio.h> |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 15 | #include <asm/io.h> |
Marcel Ziswiler | 61c99fe | 2022-05-21 12:42:46 +0200 | [diff] [blame] | 16 | #include <fdt_support.h> |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 17 | #include <i2c.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 18 | #include <linux/delay.h> |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 19 | #include "pinmux-config-colibri_t30.h" |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 20 | #include "../common/tdx-common.h" |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 21 | |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 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 | |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 31 | int checkboard(void) |
| 32 | { |
| 33 | puts("Model: Toradex Colibri T30 1GB\n"); |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 38 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 39 | int ft_board_setup(void *blob, struct bd_info *bd) |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 40 | { |
Marcel Ziswiler | 61c99fe | 2022-05-21 12:42:46 +0200 | [diff] [blame] | 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 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 59 | return ft_common_board_setup(blob, bd); |
| 60 | } |
| 61 | #endif |
| 62 | |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 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 | /* |
Marcel Ziswiler | 7d44295 | 2019-09-12 11:12:56 +0200 | [diff] [blame] | 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 | /* |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 92 | * Enable AX88772B USB to LAN controller |
| 93 | */ |
| 94 | void pin_mux_usb(void) |
| 95 | { |
| 96 | /* Reset ASIX using LAN_RESET */ |
Stephen Warren | 7f20bb2 | 2016-05-12 12:07:39 -0600 | [diff] [blame] | 97 | gpio_request(TEGRA_GPIO(DD, 0), "LAN_RESET"); |
| 98 | gpio_direction_output(TEGRA_GPIO(DD, 0), 0); |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 99 | udelay(5); |
Stephen Warren | 7f20bb2 | 2016-05-12 12:07:39 -0600 | [diff] [blame] | 100 | gpio_set_value(TEGRA_GPIO(DD, 0), 1); |
Stefan Agner | 60bae8c | 2014-08-05 23:27:30 +0200 | [diff] [blame] | 101 | } |
Gerard Salvatella | 108d739 | 2018-11-19 15:54:10 +0100 | [diff] [blame] | 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 | } |