blob: cc0e5e130fda30209db2f8341a1fbcf461f2f39b [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>
9#include <asm/arch/pinmux.h>
Tom Warren7110b952013-03-06 16:16:22 -070010#include <asm/arch/gp_padctrl.h>
Tom Warren23d7fe92012-12-11 13:34:18 +000011#include "pinmux-config-cardhu.h"
Tom Warrenf5d874d2013-02-26 12:26:55 -070012#include <i2c.h>
13
14#define PMU_I2C_ADDRESS 0x2D
15#define MAX_I2C_RETRY 3
Tom Warren23d7fe92012-12-11 13:34:18 +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(tegra3_pinmux_common,
Tom Warren23d7fe92012-12-11 13:34:18 +000024 ARRAY_SIZE(tegra3_pinmux_common));
25
Stephen Warrenf4df6052014-03-21 12:28:56 -060026 pinmux_config_pingrp_table(unused_pins_lowpower,
Tom Warren23d7fe92012-12-11 13:34:18 +000027 ARRAY_SIZE(unused_pins_lowpower));
Tom Warren7110b952013-03-06 16:16:22 -070028
29 /* Initialize any non-default pad configs (APB_MISC_GP regs) */
Stephen Warrenf4df6052014-03-21 12:28:56 -060030 pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl));
Tom Warren23d7fe92012-12-11 13:34:18 +000031}
Tom Warrenf5d874d2013-02-26 12:26:55 -070032
33#if defined(CONFIG_TEGRA_MMC)
34/*
35 * Do I2C/PMU writes to bring up SD card bus power
36 *
37 */
38void board_sdmmc_voltage_init(void)
39{
40 uchar reg, data_buffer[1];
41 int i;
42
43 i2c_set_bus_num(0); /* PMU is on bus 0 */
44
45 /* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */
46 data_buffer[0] = 0x65;
47 reg = 0x32;
48
49 for (i = 0; i < MAX_I2C_RETRY; ++i) {
50 if (i2c_write(PMU_I2C_ADDRESS, reg, 1, data_buffer, 1))
51 udelay(100);
52 }
53
54 /* TPS659110: GPIO7_REG = PDEN, output a 1 to EN_3V3_SYS */
55 data_buffer[0] = 0x09;
56 reg = 0x67;
57
58 for (i = 0; i < MAX_I2C_RETRY; ++i) {
59 if (i2c_write(PMU_I2C_ADDRESS, reg, 1, data_buffer, 1))
60 udelay(100);
61 }
62}
63
64/*
65 * Routine: pin_mux_mmc
66 * Description: setup the MMC muxes, power rails, etc.
67 */
68void pin_mux_mmc(void)
69{
70 /*
71 * NOTE: We don't do mmc-specific pin muxes here.
72 * They were done globally in pinmux_init().
73 */
74
75 /* Bring up the SDIO1 power rail */
76 board_sdmmc_voltage_init();
77}
78#endif /* MMC */