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 
10 #include <asm/arch/gp_padctrl.h>
11 #include <asm/arch/pinmux.h>
12 #include <asm/gpio.h>
13 #include <i2c.h>
14 #include <netdev.h>
15 
16 #include "pinmux-config-apalis_t30.h"
17 
18 #define PMU_I2C_ADDRESS		0x2D
19 #define MAX_I2C_RETRY		3
20 
21 /*
22  * Routine: pinmux_init
23  * Description: Do individual peripheral pinmux configs
24  */
25 void pinmux_init(void)
26 {
27 	pinmux_config_pingrp_table(tegra3_pinmux_common,
28 				   ARRAY_SIZE(tegra3_pinmux_common));
29 
30 	pinmux_config_pingrp_table(unused_pins_lowpower,
31 				   ARRAY_SIZE(unused_pins_lowpower));
32 
33 	/* Initialize any non-default pad configs (APB_MISC_GP regs) */
34 	pinmux_config_drvgrp_table(apalis_t30_padctrl,
35 				   ARRAY_SIZE(apalis_t30_padctrl));
36 }
37 
38 #ifdef CONFIG_PCI_TEGRA
39 int tegra_pcie_board_init(void)
40 {
41 	unsigned int old_bus;
42 	u8 addr, data[1];
43 	int err;
44 
45 	old_bus = i2c_get_bus_num();
46 
47 	err = i2c_set_bus_num(0);
48 	if (err) {
49 		debug("failed to set I2C bus\n");
50 		return err;
51 	}
52 
53 	/* TPS659110: VDD2_OP_REG = 1.05V */
54 	data[0] = 0x27;
55 	addr = 0x25;
56 
57 	err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
58 	if (err) {
59 		debug("failed to set VDD supply\n");
60 		return err;
61 	}
62 
63 	/* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
64 	data[0] = 0x0D;
65 	addr = 0x24;
66 
67 	err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
68 	if (err) {
69 		debug("failed to enable VDD supply\n");
70 		return err;
71 	}
72 
73 	/* TPS659110: LDO6_REG = 1.1V, ACTIVE */
74 	data[0] = 0x0D;
75 	addr = 0x35;
76 
77 	err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
78 	if (err) {
79 		debug("failed to set AVDD supply\n");
80 		return err;
81 	}
82 
83 	i2c_set_bus_num(old_bus);
84 
85 	return 0;
86 }
87 
88 int board_eth_init(bd_t *bis)
89 {
90 	return pci_eth_init(bis);
91 }
92 #endif /* CONFIG_PCI_TEGRA */
93