xref: /openbmc/u-boot/board/nvidia/cardhu/cardhu.c (revision bcc05c7a)
1 /*
2  *  (C) Copyright 2010-2013
3  *  NVIDIA Corporation <www.nvidia.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <asm/arch/pinmux.h>
10 #include <asm/arch/gp_padctrl.h>
11 #include "pinmux-config-cardhu.h"
12 #include <i2c.h>
13 
14 #define PMU_I2C_ADDRESS		0x2D
15 #define MAX_I2C_RETRY		3
16 
17 /*
18  * Routine: pinmux_init
19  * Description: Do individual peripheral pinmux configs
20  */
21 void pinmux_init(void)
22 {
23 	pinmux_config_table(tegra3_pinmux_common,
24 		ARRAY_SIZE(tegra3_pinmux_common));
25 
26 	pinmux_config_table(unused_pins_lowpower,
27 		ARRAY_SIZE(unused_pins_lowpower));
28 
29 	/* Initialize any non-default pad configs (APB_MISC_GP regs) */
30 	padgrp_config_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl));
31 }
32 
33 #if defined(CONFIG_TEGRA_MMC)
34 /*
35  * Do I2C/PMU writes to bring up SD card bus power
36  *
37  */
38 void 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  */
68 void 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 */
79