blob: 026f45c6c686da054603d908989604f2fd78301b [file] [log] [blame]
Tom Warren23d7fe92012-12-11 13:34:18 +00001/*
Tom Warren7110b952013-03-06 16:16:22 -07002 * (C) Copyright 2010-2013
Tom Warren23d7fe92012-12-11 13:34:18 +00003 * NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Tom Warren23d7fe92012-12-11 13:34:18 +00006 */
7
8#include <common.h>
Simon Glass667aee92014-12-10 08:55:57 -07009#include <dm.h>
Tom Warren23d7fe92012-12-11 13:34:18 +000010#include <asm/arch/pinmux.h>
Tom Warren7110b952013-03-06 16:16:22 -070011#include <asm/arch/gp_padctrl.h>
Tom Warren23d7fe92012-12-11 13:34:18 +000012#include "pinmux-config-cardhu.h"
Tom Warrenf5d874d2013-02-26 12:26:55 -070013#include <i2c.h>
14
15#define PMU_I2C_ADDRESS 0x2D
16#define MAX_I2C_RETRY 3
Tom Warren23d7fe92012-12-11 13:34:18 +000017
18/*
19 * Routine: pinmux_init
20 * Description: Do individual peripheral pinmux configs
21 */
22void pinmux_init(void)
23{
Stephen Warrenf4df6052014-03-21 12:28:56 -060024 pinmux_config_pingrp_table(tegra3_pinmux_common,
Tom Warren23d7fe92012-12-11 13:34:18 +000025 ARRAY_SIZE(tegra3_pinmux_common));
26
Stephen Warrenf4df6052014-03-21 12:28:56 -060027 pinmux_config_pingrp_table(unused_pins_lowpower,
Tom Warren23d7fe92012-12-11 13:34:18 +000028 ARRAY_SIZE(unused_pins_lowpower));
Tom Warren7110b952013-03-06 16:16:22 -070029
30 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
Stephen Warrenf4df6052014-03-21 12:28:56 -060031 pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl));
Tom Warren23d7fe92012-12-11 13:34:18 +000032}
Tom Warrenf5d874d2013-02-26 12:26:55 -070033
34#if defined(CONFIG_TEGRA_MMC)
35/*
36 * Do I2C/PMU writes to bring up SD card bus power
37 *
38 */
39void board_sdmmc_voltage_init(void)
40{
Simon Glass667aee92014-12-10 08:55:57 -070041 struct udevice *dev;
Tom Warrenf5d874d2013-02-26 12:26:55 -070042 uchar reg, data_buffer[1];
Simon Glass667aee92014-12-10 08:55:57 -070043 int ret;
Tom Warrenf5d874d2013-02-26 12:26:55 -070044 int i;
45
Simon Glass667aee92014-12-10 08:55:57 -070046 ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
47 if (ret) {
48 debug("%s: Cannot find PMIC I2C chip\n", __func__);
49 return;
50 }
Tom Warrenf5d874d2013-02-26 12:26:55 -070051
52 /* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */
53 data_buffer[0] = 0x65;
54 reg = 0x32;
55
56 for (i = 0; i < MAX_I2C_RETRY; ++i) {
Simon Glass667aee92014-12-10 08:55:57 -070057 if (i2c_write(dev, reg, data_buffer, 1))
Tom Warrenf5d874d2013-02-26 12:26:55 -070058 udelay(100);
59 }
60
61 /* TPS659110: GPIO7_REG = PDEN, output a 1 to EN_3V3_SYS */
62 data_buffer[0] = 0x09;
63 reg = 0x67;
64
65 for (i = 0; i < MAX_I2C_RETRY; ++i) {
Simon Glass667aee92014-12-10 08:55:57 -070066 if (i2c_write(dev, reg, data_buffer, 1))
Tom Warrenf5d874d2013-02-26 12:26:55 -070067 udelay(100);
68 }
69}
70
71/*
72 * Routine: pin_mux_mmc
73 * Description: setup the MMC muxes, power rails, etc.
74 */
75void pin_mux_mmc(void)
76{
77 /*
78 * NOTE: We don't do mmc-specific pin muxes here.
79 * They were done globally in pinmux_init().
80 */
81
82 /* Bring up the SDIO1 power rail */
83 board_sdmmc_voltage_init();
84}
85#endif /* MMC */