blob: 3f56971a13b15416549bdfbdd8d380f61d77476d [file] [log] [blame]
Marcel Ziswiler11e2a532014-09-05 10:18:38 +02001/*
2 * (C) Copyright 2014
3 * 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>
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020017
18#include "pinmux-config-apalis_t30.h"
19
20#define PMU_I2C_ADDRESS 0x2D
21#define MAX_I2C_RETRY 3
22
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020023int arch_misc_init(void)
24{
25 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
26 NVBOOTTYPE_RECOVERY)
27 printf("USB recovery mode\n");
28
29 return 0;
30}
31
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020032/*
33 * Routine: pinmux_init
34 * Description: Do individual peripheral pinmux configs
35 */
36void pinmux_init(void)
37{
38 pinmux_config_pingrp_table(tegra3_pinmux_common,
39 ARRAY_SIZE(tegra3_pinmux_common));
40
41 pinmux_config_pingrp_table(unused_pins_lowpower,
42 ARRAY_SIZE(unused_pins_lowpower));
43
44 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
45 pinmux_config_drvgrp_table(apalis_t30_padctrl,
46 ARRAY_SIZE(apalis_t30_padctrl));
47}
48
49#ifdef CONFIG_PCI_TEGRA
50int tegra_pcie_board_init(void)
51{
Simon Glass667aee92014-12-10 08:55:57 -070052 struct udevice *dev;
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020053 u8 addr, data[1];
54 int err;
55
Simon Glassa2723ae2015-01-25 08:26:55 -070056 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020057 if (err) {
Simon Glass667aee92014-12-10 08:55:57 -070058 debug("%s: Cannot find PMIC I2C chip\n", __func__);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020059 return err;
60 }
Marcel Ziswiler764d4122015-08-06 00:47:10 +020061
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020062 /* TPS659110: VDD2_OP_REG = 1.05V */
63 data[0] = 0x27;
64 addr = 0x25;
65
Simon Glass7d722762015-01-12 18:02:07 -070066 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020067 if (err) {
68 debug("failed to set VDD supply\n");
69 return err;
70 }
71
72 /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
73 data[0] = 0x0D;
74 addr = 0x24;
75
Simon Glass7d722762015-01-12 18:02:07 -070076 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020077 if (err) {
78 debug("failed to enable VDD supply\n");
79 return err;
80 }
81
82 /* TPS659110: LDO6_REG = 1.1V, ACTIVE */
83 data[0] = 0x0D;
84 addr = 0x35;
85
Simon Glass7d722762015-01-12 18:02:07 -070086 err = dm_i2c_write(dev, addr, data, 1);
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020087 if (err) {
88 debug("failed to set AVDD supply\n");
89 return err;
90 }
91
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020092 return 0;
93}
Marcel Ziswiler11e2a532014-09-05 10:18:38 +020094#endif /* CONFIG_PCI_TEGRA */