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