blob: 3476f1159feadc70ca214bb72af914143ef15153 [file] [log] [blame]
Stephen Warren2791a0c2012-05-15 06:45:28 +00001/*
2 * (C) Copyright 2010-2012
3 * NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stephen Warren2791a0c2012-05-15 06:45:28 +00006 */
7
8#include <common.h>
Simon Glass667aee92014-12-10 08:55:57 -07009#include <dm.h>
Stephen Warren2791a0c2012-05-15 06:45:28 +000010#include <asm/io.h>
Tom Warrenab371962012-09-19 15:50:56 -070011#include <asm/arch/tegra.h>
Stephen Warren2791a0c2012-05-15 06:45:28 +000012#include <asm/arch/clock.h>
13#include <asm/arch/funcmux.h>
14#include <asm/arch/pinmux.h>
Stephen Warren2791a0c2012-05-15 06:45:28 +000015#include <asm/gpio.h>
Tom Warrenab371962012-09-19 15:50:56 -070016#include <i2c.h>
Stephen Warren2791a0c2012-05-15 06:45:28 +000017
Tom Warren9745cf82013-02-21 12:31:30 +000018#ifdef CONFIG_TEGRA_MMC
Stephen Warren2791a0c2012-05-15 06:45:28 +000019/*
20 * Routine: pin_mux_mmc
21 * Description: setup the pin muxes/tristate values for the SDMMC(s)
22 */
Tom Warren9745cf82013-02-21 12:31:30 +000023void pin_mux_mmc(void)
Stephen Warren2791a0c2012-05-15 06:45:28 +000024{
Simon Glass667aee92014-12-10 08:55:57 -070025 struct udevice *dev;
Stephen Warren2791a0c2012-05-15 06:45:28 +000026 uchar val;
27 int ret;
28
Stephen Warren2791a0c2012-05-15 06:45:28 +000029 /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
Simon Glassa2723ae2015-01-25 08:26:55 -070030 ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070031 if (ret) {
32 printf("%s: Cannot find MAX8907B I2C chip\n", __func__);
33 return;
34 }
Stephen Warren2791a0c2012-05-15 06:45:28 +000035 val = 0x29;
Simon Glass7d722762015-01-12 18:02:07 -070036 ret = dm_i2c_write(dev, 0x46, &val, 1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000037 if (ret)
38 printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
39 val = 0x00;
Simon Glass7d722762015-01-12 18:02:07 -070040 ret = dm_i2c_write(dev, 0x45, &val, 1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000041 if (ret)
42 printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
43 val = 0x1f;
Simon Glass7d722762015-01-12 18:02:07 -070044 ret = dm_i2c_write(dev, 0x44, &val, 1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000045 if (ret)
46 printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
47
Tom Warren9745cf82013-02-21 12:31:30 +000048 funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
49 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
Stephen Warren2791a0c2012-05-15 06:45:28 +000050}
Tom Warren9745cf82013-02-21 12:31:30 +000051#endif
Stephen Warren2791a0c2012-05-15 06:45:28 +000052
53/* this is a weak define that we are overriding */
54void pin_mux_usb(void)
55{
Simon Glass667aee92014-12-10 08:55:57 -070056 struct udevice *dev;
Stephen Warren2791a0c2012-05-15 06:45:28 +000057 uchar val;
58 int ret;
59
60 /*
61 * This is a hack. This should be represented in DT using the
62 * vbus-gpio property. However, U-Boot's DT support doesn't
63 * support any GPIO controller other than the Tegra's yet.
64 */
65
66 /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
Simon Glassa2723ae2015-01-25 08:26:55 -070067 ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev);
Simon Glass667aee92014-12-10 08:55:57 -070068 if (ret) {
69 printf("%s: Cannot find TAC6416 I2C chip\n", __func__);
70 return;
71 }
Stephen Warren2791a0c2012-05-15 06:45:28 +000072 val = 0x03;
Simon Glass7d722762015-01-12 18:02:07 -070073 ret = dm_i2c_write(dev, 2, &val, 1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000074 if (ret)
75 printf("i2c_write 0 0x20 2 failed: %d\n", ret);
76 val = 0xfc;
Simon Glass7d722762015-01-12 18:02:07 -070077 ret = dm_i2c_write(dev, 6, &val, 1);
Stephen Warren2791a0c2012-05-15 06:45:28 +000078 if (ret)
79 printf("i2c_write 0 0x20 6 failed: %d\n", ret);
80}