xref: /openbmc/u-boot/board/nvidia/dalmore/dalmore.c (revision 57efeb04)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <asm/arch/pinmux.h>
9 #include <asm/arch/gp_padctrl.h>
10 #include "pinmux-config-dalmore.h"
11 #include <i2c.h>
12 
13 #define BAT_I2C_ADDRESS		0x48	/* TPS65090 charger */
14 #define PMU_I2C_ADDRESS		0x58	/* TPS65913 PMU */
15 
16 /*
17  * Routine: pinmux_init
18  * Description: Do individual peripheral pinmux configs
19  */
20 void pinmux_init(void)
21 {
22 	pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate,
23 		ARRAY_SIZE(tegra114_pinmux_set_nontristate));
24 
25 	pinmux_config_pingrp_table(tegra114_pinmux_common,
26 		ARRAY_SIZE(tegra114_pinmux_common));
27 
28 	pinmux_config_pingrp_table(unused_pins_lowpower,
29 		ARRAY_SIZE(unused_pins_lowpower));
30 
31 	/* Initialize any non-default pad configs (APB_MISC_GP regs) */
32 	pinmux_config_drvgrp_table(dalmore_padctrl,
33 		ARRAY_SIZE(dalmore_padctrl));
34 }
35 
36 #if defined(CONFIG_MMC_SDHCI_TEGRA)
37 /*
38  * Do I2C/PMU writes to bring up SD card bus power
39  *
40  */
41 void board_sdmmc_voltage_init(void)
42 {
43 	struct udevice *dev;
44 	uchar reg, data_buffer[1];
45 	int ret;
46 
47 	ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
48 	if (ret) {
49 		debug("%s: Cannot find PMIC I2C chip\n", __func__);
50 		return;
51 	}
52 
53 	/* TPS65913: LDO9_VOLTAGE = 3.3V */
54 	data_buffer[0] = 0x31;
55 	reg = 0x61;
56 
57 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
58 	if (ret)
59 		printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
60 			__func__, reg, data_buffer[0], ret);
61 
62 	/* TPS65913: LDO9_CTRL = Active */
63 	data_buffer[0] = 0x01;
64 	reg = 0x60;
65 
66 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
67 	if (ret)
68 		printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
69 			__func__, reg, data_buffer[0], ret);
70 
71 	/* TPS65090: FET6_CTRL = enable output auto discharge, enable FET6 */
72 	data_buffer[0] = 0x03;
73 	reg = 0x14;
74 
75 	ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev);
76 	if (ret) {
77 		debug("%s: Cannot find charger I2C chip\n", __func__);
78 		return;
79 	}
80 	ret = dm_i2c_write(dev, reg, data_buffer, 1);
81 	if (ret)
82 		printf("%s: BAT i2c_write %02X<-%02X returned %d\n",
83 			__func__, reg, data_buffer[0], ret);
84 }
85 
86 /*
87  * Routine: pin_mux_mmc
88  * Description: setup the MMC muxes, power rails, etc.
89  */
90 void pin_mux_mmc(void)
91 {
92 	/*
93 	 * NOTE: We don't do mmc-specific pin muxes here.
94 	 * They were done globally in pinmux_init().
95 	 */
96 
97 	/* Bring up the SDIO3 power rail */
98 	board_sdmmc_voltage_init();
99 }
100 #endif /* MMC */
101