blob: 827eefd4630f8b1f215c2d3d7c4fc1cfdead994d [file] [log] [blame]
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02001/*
Marcel Ziswilerd92dee52016-11-16 17:49:23 +01002 * (C) Copyright 2014-2016
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02003 * Marcel Ziswiler <marcel@ziswiler.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02009#include <asm/arch/gp_padctrl.h>
10#include <asm/arch/pinmux.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020011#include <asm/arch-tegra/ap.h>
12#include <asm/arch-tegra/tegra.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020013#include <asm/gpio.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020014#include <asm/io.h>
Marcel Ziswiler764d4122015-08-06 00:47:10 +020015#include <dm.h>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020016#include <i2c.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080017#include "../common/tdx-common.h"
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020018
19#include "pinmux-config-apalis_t30.h"
20
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010021DECLARE_GLOBAL_DATA_PTR;
22
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020023#define PMU_I2C_ADDRESS 0x2D
24#define MAX_I2C_RETRY 3
25
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020026int arch_misc_init(void)
27{
28 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
29 NVBOOTTYPE_RECOVERY)
30 printf("USB recovery mode\n");
31
32 return 0;
33}
34
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010035int checkboard(void)
36{
37 printf("Model: Toradex Apalis T30 %dGB\n",
38 (gd->ram_size == 0x40000000) ? 1 : 2);
39
40 return 0;
41}
42
Stefan Agner98ffd0f2016-11-30 13:41:53 -080043#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
44int ft_board_setup(void *blob, bd_t *bd)
45{
46 return ft_common_board_setup(blob, bd);
47}
48#endif
49
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020050/*
51 * Routine: pinmux_init
52 * Description: Do individual peripheral pinmux configs
53 */
54void pinmux_init(void)
55{
56 pinmux_config_pingrp_table(tegra3_pinmux_common,
57 ARRAY_SIZE(tegra3_pinmux_common));
58
59 pinmux_config_pingrp_table(unused_pins_lowpower,
60 ARRAY_SIZE(unused_pins_lowpower));
61
62 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
63 pinmux_config_drvgrp_table(apalis_t30_padctrl,
64 ARRAY_SIZE(apalis_t30_padctrl));
65}
66
67#ifdef CONFIG_PCI_TEGRA
68int tegra_pcie_board_init(void)
69{
Simon Glass667aee92014-12-10 08:55:57 -070070 struct udevice *dev;
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020071 u8 addr, data[1];
72 int err;
73
Simon Glassa2723ae2015-01-25 08:26:55 -070074 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020075 if (err) {
Simon Glass667aee92014-12-10 08:55:57 -070076 debug("%s: Cannot find PMIC I2C chip\n", __func__);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020077 return err;
78 }
Marcel Ziswiler764d4122015-08-06 00:47:10 +020079
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020080 /* TPS659110: VDD2_OP_REG = 1.05V */
81 data[0] = 0x27;
82 addr = 0x25;
83
Simon Glass7d722762015-01-12 18:02:07 -070084 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020085 if (err) {
86 debug("failed to set VDD supply\n");
87 return err;
88 }
89
90 /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
91 data[0] = 0x0D;
92 addr = 0x24;
93
Simon Glass7d722762015-01-12 18:02:07 -070094 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020095 if (err) {
96 debug("failed to enable VDD supply\n");
97 return err;
98 }
99
100 /* TPS659110: LDO6_REG = 1.1V, ACTIVE */
101 data[0] = 0x0D;
102 addr = 0x35;
103
Simon Glass7d722762015-01-12 18:02:07 -0700104 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200105 if (err) {
106 debug("failed to set AVDD supply\n");
107 return err;
108 }
109
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200110 return 0;
111}
Marcel Ziswiler11e2a532014-09-05 10:18:38 +0200112#endif /* CONFIG_PCI_TEGRA */