1 /*
2  *  (C) Copyright 2014
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 #include <netdev.h>
18 
19 #include "pinmux-config-apalis_t30.h"
20 
21 #define PMU_I2C_ADDRESS		0x2D
22 #define MAX_I2C_RETRY		3
23 
24 int arch_misc_init(void)
25 {
26 	if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
27 	    NVBOOTTYPE_RECOVERY)
28 		printf("USB recovery mode\n");
29 
30 	return 0;
31 }
32 
33 /*
34  * Routine: pinmux_init
35  * Description: Do individual peripheral pinmux configs
36  */
37 void pinmux_init(void)
38 {
39 	pinmux_config_pingrp_table(tegra3_pinmux_common,
40 				   ARRAY_SIZE(tegra3_pinmux_common));
41 
42 	pinmux_config_pingrp_table(unused_pins_lowpower,
43 				   ARRAY_SIZE(unused_pins_lowpower));
44 
45 	/* Initialize any non-default pad configs (APB_MISC_GP regs) */
46 	pinmux_config_drvgrp_table(apalis_t30_padctrl,
47 				   ARRAY_SIZE(apalis_t30_padctrl));
48 }
49 
50 #ifdef CONFIG_PCI_TEGRA
51 int tegra_pcie_board_init(void)
52 {
53 	struct udevice *dev;
54 	u8 addr, data[1];
55 	int err;
56 
57 	err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
58 	if (err) {
59 		debug("%s: Cannot find PMIC I2C chip\n", __func__);
60 		return err;
61 	}
62 
63 	/* TPS659110: VDD2_OP_REG = 1.05V */
64 	data[0] = 0x27;
65 	addr = 0x25;
66 
67 	err = dm_i2c_write(dev, addr, data, 1);
68 	if (err) {
69 		debug("failed to set VDD supply\n");
70 		return err;
71 	}
72 
73 	/* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
74 	data[0] = 0x0D;
75 	addr = 0x24;
76 
77 	err = dm_i2c_write(dev, addr, data, 1);
78 	if (err) {
79 		debug("failed to enable VDD supply\n");
80 		return err;
81 	}
82 
83 	/* TPS659110: LDO6_REG = 1.1V, ACTIVE */
84 	data[0] = 0x0D;
85 	addr = 0x35;
86 
87 	err = dm_i2c_write(dev, addr, data, 1);
88 	if (err) {
89 		debug("failed to set AVDD supply\n");
90 		return err;
91 	}
92 
93 	return 0;
94 }
95 
96 int board_eth_init(bd_t *bis)
97 {
98 	return pci_eth_init(bis);
99 }
100 #endif /* CONFIG_PCI_TEGRA */
101