blob: 2a737468ddc4fce7411f2f9d183596c9edadf6c6 [file] [log] [blame]
Tom Warren07067142013-01-28 13:32:13 +00001/*
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>
Simon Glassb0e6ef42014-12-10 08:55:57 -070018#include <dm.h>
Tom Warren07067142013-01-28 13:32:13 +000019#include <asm/arch/pinmux.h>
Tom Warren2a04a312013-03-18 14:47:55 -070020#include <asm/arch/gp_padctrl.h>
Tom Warren07067142013-01-28 13:32:13 +000021#include "pinmux-config-dalmore.h"
Tom Warren6d9ea152013-03-18 14:51:20 -070022#include <i2c.h>
23
24#define BAT_I2C_ADDRESS 0x48 /* TPS65090 charger */
25#define PMU_I2C_ADDRESS 0x58 /* TPS65913 PMU */
Tom Warren07067142013-01-28 13:32:13 +000026
27/*
28 * Routine: pinmux_init
29 * Description: Do individual peripheral pinmux configs
30 */
31void pinmux_init(void)
32{
Stephen Warrendfb42fc2014-03-21 12:28:56 -060033 pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate,
Tom Warren8b7776b2013-03-01 14:38:20 -070034 ARRAY_SIZE(tegra114_pinmux_set_nontristate));
35
Stephen Warrendfb42fc2014-03-21 12:28:56 -060036 pinmux_config_pingrp_table(tegra114_pinmux_common,
Tom Warren07067142013-01-28 13:32:13 +000037 ARRAY_SIZE(tegra114_pinmux_common));
38
Stephen Warrendfb42fc2014-03-21 12:28:56 -060039 pinmux_config_pingrp_table(unused_pins_lowpower,
Tom Warren07067142013-01-28 13:32:13 +000040 ARRAY_SIZE(unused_pins_lowpower));
Tom Warren2a04a312013-03-18 14:47:55 -070041
42 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
Stephen Warrendfb42fc2014-03-21 12:28:56 -060043 pinmux_config_drvgrp_table(dalmore_padctrl,
44 ARRAY_SIZE(dalmore_padctrl));
Tom Warren07067142013-01-28 13:32:13 +000045}
Tom Warren6d9ea152013-03-18 14:51:20 -070046
47#if defined(CONFIG_TEGRA_MMC)
48/*
49 * Do I2C/PMU writes to bring up SD card bus power
50 *
51 */
52void board_sdmmc_voltage_init(void)
53{
Simon Glassb0e6ef42014-12-10 08:55:57 -070054 struct udevice *dev;
Tom Warren6d9ea152013-03-18 14:51:20 -070055 uchar reg, data_buffer[1];
56 int ret;
57
Simon Glassb0e6ef42014-12-10 08:55:57 -070058 ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
59 if (ret) {
60 debug("%s: Cannot find PMIC I2C chip\n", __func__);
61 return;
62 }
Tom Warren6d9ea152013-03-18 14:51:20 -070063
64 /* TPS65913: LDO9_VOLTAGE = 3.3V */
65 data_buffer[0] = 0x31;
66 reg = 0x61;
67
Simon Glassb0e6ef42014-12-10 08:55:57 -070068 ret = i2c_write(dev, reg, data_buffer, 1);
Tom Warren6d9ea152013-03-18 14:51:20 -070069 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
Simon Glassb0e6ef42014-12-10 08:55:57 -070077 ret = i2c_write(dev, reg, data_buffer, 1);
Tom Warren6d9ea152013-03-18 14:51:20 -070078 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
Simon Glassb0e6ef42014-12-10 08:55:57 -070086 ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, &dev);
87 if (ret) {
88 debug("%s: Cannot find charger I2C chip\n", __func__);
89 return;
90 }
91 ret = i2c_write(dev, reg, data_buffer, 1);
Tom Warren6d9ea152013-03-18 14:51:20 -070092 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 */
101void 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 */