blob: 3476f1159feadc70ca214bb72af914143ef15153 [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>
Simon Glassb0e6ef42014-12-10 08:55:57 -07009#include <dm.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +000010#include <asm/io.h>
Tom Warren150c2492012-09-19 15:50:56 -070011#include <asm/arch/tegra.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +000012#include <asm/arch/clock.h>
13#include <asm/arch/funcmux.h>
14#include <asm/arch/pinmux.h>
Stephen Warrend5ebc932012-05-15 06:45:28 +000015#include <asm/gpio.h>
Tom Warren150c2492012-09-19 15:50:56 -070016#include <i2c.h>
Tom Warrenc9aa8312013-02-21 12:31:30 +000017
Tom Warren3f82d892012-05-22 11:44:48 +000018#ifdef CONFIG_TEGRA_MMC
Stephen Warrend5ebc932012-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 Warrenc9aa8312013-02-21 12:31:30 +000023void pin_mux_mmc(void)
Stephen Warrend5ebc932012-05-15 06:45:28 +000024{
Simon Glassb0e6ef42014-12-10 08:55:57 -070025 struct udevice *dev;
Stephen Warrend5ebc932012-05-15 06:45:28 +000026 uchar val;
27 int ret;
28
Stephen Warrend5ebc932012-05-15 06:45:28 +000029 /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
Simon Glass25ab4b02015-01-25 08:26:55 -070030 ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev);
Simon Glassb0e6ef42014-12-10 08:55:57 -070031 if (ret) {
32 printf("%s: Cannot find MAX8907B I2C chip\n", __func__);
33 return;
34 }
Stephen Warrend5ebc932012-05-15 06:45:28 +000035 val = 0x29;
Simon Glassf9a4c2d2015-01-12 18:02:07 -070036 ret = dm_i2c_write(dev, 0x46, &val, 1);
Stephen Warrend5ebc932012-05-15 06:45:28 +000037 if (ret)
38 printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
39 val = 0x00;
Simon Glassf9a4c2d2015-01-12 18:02:07 -070040 ret = dm_i2c_write(dev, 0x45, &val, 1);
Stephen Warrend5ebc932012-05-15 06:45:28 +000041 if (ret)
42 printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
43 val = 0x1f;
Simon Glassf9a4c2d2015-01-12 18:02:07 -070044 ret = dm_i2c_write(dev, 0x44, &val, 1);
Stephen Warrend5ebc932012-05-15 06:45:28 +000045 if (ret)
46 printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
47
Tom Warrenc9aa8312013-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 Warrend5ebc932012-05-15 06:45:28 +000050}
Tom Warrenc9aa8312013-02-21 12:31:30 +000051#endif
Stephen Warrend5ebc932012-05-15 06:45:28 +000052
53/* this is a weak define that we are overriding */
54void pin_mux_usb(void)
55{
Simon Glassb0e6ef42014-12-10 08:55:57 -070056 struct udevice *dev;
Stephen Warrend5ebc932012-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 Glass25ab4b02015-01-25 08:26:55 -070067 ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev);
Simon Glassb0e6ef42014-12-10 08:55:57 -070068 if (ret) {
69 printf("%s: Cannot find TAC6416 I2C chip\n", __func__);
70 return;
71 }
Stephen Warrend5ebc932012-05-15 06:45:28 +000072 val = 0x03;
Simon Glassf9a4c2d2015-01-12 18:02:07 -070073 ret = dm_i2c_write(dev, 2, &val, 1);
Stephen Warrend5ebc932012-05-15 06:45:28 +000074 if (ret)
75 printf("i2c_write 0 0x20 2 failed: %d\n", ret);
76 val = 0xfc;
Simon Glassf9a4c2d2015-01-12 18:02:07 -070077 ret = dm_i2c_write(dev, 6, &val, 1);
Stephen Warrend5ebc932012-05-15 06:45:28 +000078 if (ret)
79 printf("i2c_write 0 0x20 6 failed: %d\n", ret);
80}