blob: 28830b63458f9441064b68f6ed78f5cc69718643 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02002/*
Marcel Ziswilerd92dee52016-11-16 17:49:23 +01003 * (C) Copyright 2014-2016
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02004 * Marcel Ziswiler <marcel@ziswiler.com>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02005 */
6
7#include <common.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02008#include <asm/arch/gp_padctrl.h>
9#include <asm/arch/pinmux.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020010#include <asm/arch-tegra/ap.h>
11#include <asm/arch-tegra/tegra.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020012#include <asm/gpio.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020013#include <asm/io.h>
Marcel Ziswiler764d4122015-08-06 00:47:10 +020014#include <dm.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020015#include <i2c.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080016#include "../common/tdx-common.h"
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020017
18#include "pinmux-config-apalis_t30.h"
19
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010020DECLARE_GLOBAL_DATA_PTR;
21
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020022#define PMU_I2C_ADDRESS 0x2D
23#define MAX_I2C_RETRY 3
24
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020025int 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
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010034int checkboard(void)
35{
36 printf("Model: Toradex Apalis T30 %dGB\n",
37 (gd->ram_size == 0x40000000) ? 1 : 2);
38
39 return 0;
40}
41
Stefan Agner98ffd0f2016-11-30 13:41:53 -080042#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
43int ft_board_setup(void *blob, bd_t *bd)
44{
45 return ft_common_board_setup(blob, bd);
46}
47#endif
48
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020049/*
50 * Routine: pinmux_init
51 * Description: Do individual peripheral pinmux configs
52 */
53void pinmux_init(void)
54{
55 pinmux_config_pingrp_table(tegra3_pinmux_common,
56 ARRAY_SIZE(tegra3_pinmux_common));
57
58 pinmux_config_pingrp_table(unused_pins_lowpower,
59 ARRAY_SIZE(unused_pins_lowpower));
60
61 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
62 pinmux_config_drvgrp_table(apalis_t30_padctrl,
63 ARRAY_SIZE(apalis_t30_padctrl));
64}
65
66#ifdef CONFIG_PCI_TEGRA
67int tegra_pcie_board_init(void)
68{
Simon Glass667aee92014-12-10 08:55:57 -070069 struct udevice *dev;
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020070 u8 addr, data[1];
71 int err;
72
Simon Glassa2723ae2015-01-25 08:26:55 -070073 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020074 if (err) {
Simon Glass667aee92014-12-10 08:55:57 -070075 debug("%s: Cannot find PMIC I2C chip\n", __func__);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020076 return err;
77 }
Marcel Ziswiler764d4122015-08-06 00:47:10 +020078
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020079 /* TPS659110: VDD2_OP_REG = 1.05V */
80 data[0] = 0x27;
81 addr = 0x25;
82
Simon Glass7d722762015-01-12 18:02:07 -070083 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020084 if (err) {
85 debug("failed to set VDD supply\n");
86 return err;
87 }
88
89 /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
90 data[0] = 0x0D;
91 addr = 0x24;
92
Simon Glass7d722762015-01-12 18:02:07 -070093 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020094 if (err) {
95 debug("failed to enable VDD supply\n");
96 return err;
97 }
98
99 /* TPS659110: LDO6_REG = 1.1V, ACTIVE */
100 data[0] = 0x0D;
101 addr = 0x35;
102
Simon Glass7d722762015-01-12 18:02:07 -0700103 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200104 if (err) {
105 debug("failed to set AVDD supply\n");
106 return err;
107 }
108
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200109 return 0;
110}
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200111#endif /* CONFIG_PCI_TEGRA */