blob: 3e9d3d9f10ae8edcca42708abc975ba8a978f2c5 [file] [log] [blame]
Stephen Warrend5ebc932012-05-15 06:45:28 +00001/*
2 * (C) Copyright 2010-2012
3 * NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stephen Warrend5ebc932012-05-15 06:45:28 +00006 */
7
8#include <common.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +00009#include <asm/io.h>
Tom Warren150c2492012-09-19 15:50:56 -070010#include <asm/arch/tegra.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +000011#include <asm/arch/clock.h>
12#include <asm/arch/funcmux.h>
13#include <asm/arch/pinmux.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +000014#include <asm/gpio.h>
Tom Warren150c2492012-09-19 15:50:56 -070015#include <i2c.h>
Tom Warrenc9aa8312013-02-21 12:31:30 +000016
Tom Warren3f82d892012-05-22 11:44:48 +000017#ifdef CONFIG_TEGRA_MMC
Stephen Warrend5ebc932012-05-15 06:45:28 +000018/*
19 * Routine: pin_mux_mmc
20 * Description: setup the pin muxes/tristate values for the SDMMC(s)
21 */
Tom Warrenc9aa8312013-02-21 12:31:30 +000022void pin_mux_mmc(void)
Stephen Warrend5ebc932012-05-15 06:45:28 +000023{
24 uchar val;
25 int ret;
26
Stephen Warrend5ebc932012-05-15 06:45:28 +000027 /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
28 ret = i2c_set_bus_num(0);
29 if (ret)
30 printf("i2c_set_bus_num failed: %d\n", ret);
31 val = 0x29;
32 ret = i2c_write(0x3c, 0x46, 1, &val, 1);
33 if (ret)
34 printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
35 val = 0x00;
36 ret = i2c_write(0x3c, 0x45, 1, &val, 1);
37 if (ret)
38 printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
39 val = 0x1f;
40 ret = i2c_write(0x3c, 0x44, 1, &val, 1);
41 if (ret)
42 printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
43
Tom Warrenc9aa8312013-02-21 12:31:30 +000044 funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
45 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
Stephen Warrend5ebc932012-05-15 06:45:28 +000046}
Tom Warrenc9aa8312013-02-21 12:31:30 +000047#endif
Stephen Warrend5ebc932012-05-15 06:45:28 +000048
49/* this is a weak define that we are overriding */
50void pin_mux_usb(void)
51{
52 uchar val;
53 int ret;
54
55 /*
56 * This is a hack. This should be represented in DT using the
57 * vbus-gpio property. However, U-Boot's DT support doesn't
58 * support any GPIO controller other than the Tegra's yet.
59 */
60
61 /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
62 ret = i2c_set_bus_num(0);
63 if (ret)
64 printf("i2c_set_bus_num failed: %d\n", ret);
65 val = 0x03;
66 ret = i2c_write(0x20, 2, 1, &val, 1);
67 if (ret)
68 printf("i2c_write 0 0x20 2 failed: %d\n", ret);
69 val = 0xfc;
70 ret = i2c_write(0x20, 6, 1, &val, 1);
71 if (ret)
72 printf("i2c_write 0 0x20 6 failed: %d\n", ret);
73}