1 /* 2 * (C) Copyright 2014-2016 3 * Marcel Ziswiler <marcel@ziswiler.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <common.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 <dm.h> 16 #include <i2c.h> 17 18 #include "pinmux-config-apalis_t30.h" 19 20 DECLARE_GLOBAL_DATA_PTR; 21 22 #define PMU_I2C_ADDRESS 0x2D 23 #define MAX_I2C_RETRY 3 24 25 int arch_misc_init(void) 26 { 27 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) == 28 NVBOOTTYPE_RECOVERY) 29 printf("USB recovery mode\n"); 30 31 return 0; 32 } 33 34 int checkboard(void) 35 { 36 printf("Model: Toradex Apalis T30 %dGB\n", 37 (gd->ram_size == 0x40000000) ? 1 : 2); 38 39 return 0; 40 } 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(apalis_t30_padctrl, 56 ARRAY_SIZE(apalis_t30_padctrl)); 57 } 58 59 #ifdef CONFIG_PCI_TEGRA 60 int tegra_pcie_board_init(void) 61 { 62 struct udevice *dev; 63 u8 addr, data[1]; 64 int err; 65 66 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); 67 if (err) { 68 debug("%s: Cannot find PMIC I2C chip\n", __func__); 69 return err; 70 } 71 72 /* TPS659110: VDD2_OP_REG = 1.05V */ 73 data[0] = 0x27; 74 addr = 0x25; 75 76 err = dm_i2c_write(dev, addr, data, 1); 77 if (err) { 78 debug("failed to set VDD supply\n"); 79 return err; 80 } 81 82 /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */ 83 data[0] = 0x0D; 84 addr = 0x24; 85 86 err = dm_i2c_write(dev, addr, data, 1); 87 if (err) { 88 debug("failed to enable VDD supply\n"); 89 return err; 90 } 91 92 /* TPS659110: LDO6_REG = 1.1V, ACTIVE */ 93 data[0] = 0x0D; 94 addr = 0x35; 95 96 err = dm_i2c_write(dev, addr, data, 1); 97 if (err) { 98 debug("failed to set AVDD supply\n"); 99 return err; 100 } 101 102 return 0; 103 } 104 #endif /* CONFIG_PCI_TEGRA */ 105