blob: 72511e401e3cea6e0c48cf6f079907cc2ba9ce80 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Tom Warren7a3fa012013-01-28 13:32:13 +00002/*
3 * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved.
Tom Warren7a3fa012013-01-28 13:32:13 +00004 */
5
6#include <common.h>
Simon Glass667aee92014-12-10 08:55:57 -07007#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Tom Warren7a3fa012013-01-28 13:32:13 +00009#include <asm/arch/pinmux.h>
Tom Warren3086f6a2013-03-18 14:47:55 -070010#include <asm/arch/gp_padctrl.h>
Tom Warren7a3fa012013-01-28 13:32:13 +000011#include "pinmux-config-dalmore.h"
Tom Warren35a1d092013-03-18 14:51:20 -070012#include <i2c.h>
13
14#define BAT_I2C_ADDRESS 0x48 /* TPS65090 charger */
15#define PMU_I2C_ADDRESS 0x58 /* TPS65913 PMU */
Tom Warren7a3fa012013-01-28 13:32:13 +000016
17/*
18 * Routine: pinmux_init
19 * Description: Do individual peripheral pinmux configs
20 */
21void pinmux_init(void)
22{
Stephen Warrenf4df6052014-03-21 12:28:56 -060023 pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate,
Tom Warren8495b222013-03-01 14:38:20 -070024 ARRAY_SIZE(tegra114_pinmux_set_nontristate));
25
Stephen Warrenf4df6052014-03-21 12:28:56 -060026 pinmux_config_pingrp_table(tegra114_pinmux_common,
Tom Warren7a3fa012013-01-28 13:32:13 +000027 ARRAY_SIZE(tegra114_pinmux_common));
28
Stephen Warrenf4df6052014-03-21 12:28:56 -060029 pinmux_config_pingrp_table(unused_pins_lowpower,
Tom Warren7a3fa012013-01-28 13:32:13 +000030 ARRAY_SIZE(unused_pins_lowpower));
Tom Warren3086f6a2013-03-18 14:47:55 -070031
32 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
Stephen Warrenf4df6052014-03-21 12:28:56 -060033 pinmux_config_drvgrp_table(dalmore_padctrl,
34 ARRAY_SIZE(dalmore_padctrl));
Tom Warren7a3fa012013-01-28 13:32:13 +000035}
Tom Warren35a1d092013-03-18 14:51:20 -070036
Masahiro Yamadab2c88682017-01-10 13:32:07 +090037#if defined(CONFIG_MMC_SDHCI_TEGRA)
Tom Warren35a1d092013-03-18 14:51:20 -070038/*
39 * Do I2C/PMU writes to bring up SD card bus power
40 *
41 */
42void board_sdmmc_voltage_init(void)
43{
Simon Glass667aee92014-12-10 08:55:57 -070044 struct udevice *dev;
Tom Warren35a1d092013-03-18 14:51:20 -070045 uchar reg, data_buffer[1];
46 int ret;
47
Simon Glassa2723ae2015-01-25 08:26:55 -070048 ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070049 if (ret) {
50 debug("%s: Cannot find PMIC I2C chip\n", __func__);
51 return;
52 }
Tom Warren35a1d092013-03-18 14:51:20 -070053
54 /* TPS65913: LDO9_VOLTAGE = 3.3V */
55 data_buffer[0] = 0x31;
56 reg = 0x61;
57
Simon Glass7d722762015-01-12 18:02:07 -070058 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070059 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
Simon Glass7d722762015-01-12 18:02:07 -070067 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070068 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
Simon Glassa2723ae2015-01-25 08:26:55 -070076 ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070077 if (ret) {
78 debug("%s: Cannot find charger I2C chip\n", __func__);
79 return;
80 }
Simon Glass7d722762015-01-12 18:02:07 -070081 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070082 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 */
91void 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 */