blob: 598b2e5ce2518e646236b840629cb2d847df8720 [file] [log] [blame]
Stephen Warren2791a0c2012-05-15 06:45:28 +00001/*
2 * (C) Copyright 2010-2012
3 * NVIDIA Corporation <www.nvidia.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <i2c.h>
26#include <asm/io.h>
Allen Martin55d98a12012-08-31 08:30:00 +000027#include <asm/arch/tegra20.h>
Stephen Warren2791a0c2012-05-15 06:45:28 +000028#include <asm/arch/clock.h>
29#include <asm/arch/funcmux.h>
30#include <asm/arch/pinmux.h>
31#include <asm/arch/mmc.h>
32#include <asm/gpio.h>
Tom Warren8c57e962012-05-22 11:44:48 +000033#ifdef CONFIG_TEGRA_MMC
Stephen Warren2791a0c2012-05-15 06:45:28 +000034#include <mmc.h>
35#endif
36
37/*
38 * Routine: gpio_config_uart
39 * Description: Does nothing on Whistler - no UART-related GPIOs.
40 */
41void gpio_config_uart(void)
42{
43}
44
45/*
46 * Routine: pin_mux_mmc
47 * Description: setup the pin muxes/tristate values for the SDMMC(s)
48 */
49static void pin_mux_mmc(void)
50{
51 funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
52 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
53}
54
55/* this is a weak define that we are overriding */
56int board_mmc_init(bd_t *bd)
57{
58 uchar val;
59 int ret;
60
61 debug("board_mmc_init called\n");
62
63 /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
64 ret = i2c_set_bus_num(0);
65 if (ret)
66 printf("i2c_set_bus_num failed: %d\n", ret);
67 val = 0x29;
68 ret = i2c_write(0x3c, 0x46, 1, &val, 1);
69 if (ret)
70 printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
71 val = 0x00;
72 ret = i2c_write(0x3c, 0x45, 1, &val, 1);
73 if (ret)
74 printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
75 val = 0x1f;
76 ret = i2c_write(0x3c, 0x44, 1, &val, 1);
77 if (ret)
78 printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
79
80 /* Enable muxes, etc. for SDMMC controllers */
81 pin_mux_mmc();
82
83 /* init dev 0 (SDMMC4), (J29 "HSMMC") with 8-bit bus */
Tom Warren22562a42012-09-04 17:00:24 -070084 tegra_mmc_init(0, 8, -1, -1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000085
86 /* init dev 1 (SDMMC3), (J40 "SDIO3") with 8-bit bus */
Tom Warren22562a42012-09-04 17:00:24 -070087 tegra_mmc_init(1, 8, -1, -1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000088
89 return 0;
90}
91
92/* this is a weak define that we are overriding */
93void pin_mux_usb(void)
94{
95 uchar val;
96 int ret;
97
98 /*
99 * This is a hack. This should be represented in DT using the
100 * vbus-gpio property. However, U-Boot's DT support doesn't
101 * support any GPIO controller other than the Tegra's yet.
102 */
103
104 /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
105 ret = i2c_set_bus_num(0);
106 if (ret)
107 printf("i2c_set_bus_num failed: %d\n", ret);
108 val = 0x03;
109 ret = i2c_write(0x20, 2, 1, &val, 1);
110 if (ret)
111 printf("i2c_write 0 0x20 2 failed: %d\n", ret);
112 val = 0xfc;
113 ret = i2c_write(0x20, 6, 1, &val, 1);
114 if (ret)
115 printf("i2c_write 0 0x20 6 failed: %d\n", ret);
116}