blob: fcee21713fa4bfa470b359864de666d1761b98fb [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>
Tom Warren7a3fa012013-01-28 13:32:13 +00008#include <asm/arch/pinmux.h>
Tom Warren3086f6a2013-03-18 14:47:55 -07009#include <asm/arch/gp_padctrl.h>
Tom Warren7a3fa012013-01-28 13:32:13 +000010#include "pinmux-config-dalmore.h"
Tom Warren35a1d092013-03-18 14:51:20 -070011#include <i2c.h>
12
13#define BAT_I2C_ADDRESS 0x48 /* TPS65090 charger */
14#define PMU_I2C_ADDRESS 0x58 /* TPS65913 PMU */
Tom Warren7a3fa012013-01-28 13:32:13 +000015
16/*
17 * Routine: pinmux_init
18 * Description: Do individual peripheral pinmux configs
19 */
20void pinmux_init(void)
21{
Stephen Warrenf4df6052014-03-21 12:28:56 -060022 pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate,
Tom Warren8495b222013-03-01 14:38:20 -070023 ARRAY_SIZE(tegra114_pinmux_set_nontristate));
24
Stephen Warrenf4df6052014-03-21 12:28:56 -060025 pinmux_config_pingrp_table(tegra114_pinmux_common,
Tom Warren7a3fa012013-01-28 13:32:13 +000026 ARRAY_SIZE(tegra114_pinmux_common));
27
Stephen Warrenf4df6052014-03-21 12:28:56 -060028 pinmux_config_pingrp_table(unused_pins_lowpower,
Tom Warren7a3fa012013-01-28 13:32:13 +000029 ARRAY_SIZE(unused_pins_lowpower));
Tom Warren3086f6a2013-03-18 14:47:55 -070030
31 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
Stephen Warrenf4df6052014-03-21 12:28:56 -060032 pinmux_config_drvgrp_table(dalmore_padctrl,
33 ARRAY_SIZE(dalmore_padctrl));
Tom Warren7a3fa012013-01-28 13:32:13 +000034}
Tom Warren35a1d092013-03-18 14:51:20 -070035
Masahiro Yamadab2c88682017-01-10 13:32:07 +090036#if defined(CONFIG_MMC_SDHCI_TEGRA)
Tom Warren35a1d092013-03-18 14:51:20 -070037/*
38 * Do I2C/PMU writes to bring up SD card bus power
39 *
40 */
41void board_sdmmc_voltage_init(void)
42{
Simon Glass667aee92014-12-10 08:55:57 -070043 struct udevice *dev;
Tom Warren35a1d092013-03-18 14:51:20 -070044 uchar reg, data_buffer[1];
45 int ret;
46
Simon Glassa2723ae2015-01-25 08:26:55 -070047 ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070048 if (ret) {
49 debug("%s: Cannot find PMIC I2C chip\n", __func__);
50 return;
51 }
Tom Warren35a1d092013-03-18 14:51:20 -070052
53 /* TPS65913: LDO9_VOLTAGE = 3.3V */
54 data_buffer[0] = 0x31;
55 reg = 0x61;
56
Simon Glass7d722762015-01-12 18:02:07 -070057 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070058 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
Simon Glass7d722762015-01-12 18:02:07 -070066 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070067 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
Simon Glassa2723ae2015-01-25 08:26:55 -070075 ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070076 if (ret) {
77 debug("%s: Cannot find charger I2C chip\n", __func__);
78 return;
79 }
Simon Glass7d722762015-01-12 18:02:07 -070080 ret = dm_i2c_write(dev, reg, data_buffer, 1);
Tom Warren35a1d092013-03-18 14:51:20 -070081 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 */
90void 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 */