xref: /openbmc/u-boot/board/nvidia/dalmore/dalmore.c (revision 657fd2d0)
1 /*
2  * Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #include <common.h>
18 #include <dm.h>
19 #include <asm/arch/pinmux.h>
20 #include <asm/arch/gp_padctrl.h>
21 #include "pinmux-config-dalmore.h"
22 #include <i2c.h>
23 
24 #define BAT_I2C_ADDRESS		0x48	/* TPS65090 charger */
25 #define PMU_I2C_ADDRESS		0x58	/* TPS65913 PMU */
26 
27 /*
28  * Routine: pinmux_init
29  * Description: Do individual peripheral pinmux configs
30  */
31 void pinmux_init(void)
32 {
33 	pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate,
34 		ARRAY_SIZE(tegra114_pinmux_set_nontristate));
35 
36 	pinmux_config_pingrp_table(tegra114_pinmux_common,
37 		ARRAY_SIZE(tegra114_pinmux_common));
38 
39 	pinmux_config_pingrp_table(unused_pins_lowpower,
40 		ARRAY_SIZE(unused_pins_lowpower));
41 
42 	/* Initialize any non-default pad configs (APB_MISC_GP regs) */
43 	pinmux_config_drvgrp_table(dalmore_padctrl,
44 		ARRAY_SIZE(dalmore_padctrl));
45 }
46 
47 #if defined(CONFIG_TEGRA_MMC)
48 /*
49  * Do I2C/PMU writes to bring up SD card bus power
50  *
51  */
52 void board_sdmmc_voltage_init(void)
53 {
54 	struct udevice *dev;
55 	uchar reg, data_buffer[1];
56 	int ret;
57 
58 	ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
59 	if (ret) {
60 		debug("%s: Cannot find PMIC I2C chip\n", __func__);
61 		return;
62 	}
63 
64 	/* TPS65913: LDO9_VOLTAGE = 3.3V */
65 	data_buffer[0] = 0x31;
66 	reg = 0x61;
67 
68 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
69 	if (ret)
70 		printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
71 			__func__, reg, data_buffer[0], ret);
72 
73 	/* TPS65913: LDO9_CTRL = Active */
74 	data_buffer[0] = 0x01;
75 	reg = 0x60;
76 
77 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
78 	if (ret)
79 		printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
80 			__func__, reg, data_buffer[0], ret);
81 
82 	/* TPS65090: FET6_CTRL = enable output auto discharge, enable FET6 */
83 	data_buffer[0] = 0x03;
84 	reg = 0x14;
85 
86 	ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev);
87 	if (ret) {
88 		debug("%s: Cannot find charger I2C chip\n", __func__);
89 		return;
90 	}
91 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
92 	if (ret)
93 		printf("%s: BAT i2c_write %02X<-%02X returned %d\n",
94 			__func__, reg, data_buffer[0], ret);
95 }
96 
97 /*
98  * Routine: pin_mux_mmc
99  * Description: setup the MMC muxes, power rails, etc.
100  */
101 void pin_mux_mmc(void)
102 {
103 	/*
104 	 * NOTE: We don't do mmc-specific pin muxes here.
105 	 * They were done globally in pinmux_init().
106 	 */
107 
108 	/* Bring up the SDIO3 power rail */
109 	board_sdmmc_voltage_init();
110 }
111 #endif /* MMC */
112