Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010-2012 |
| 3 | * NVIDIA Corporation <www.nvidia.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | b0e6ef4 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 9 | #include <dm.h> |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 10 | #include <asm/io.h> |
Tom Warren | 150c249 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 11 | #include <asm/arch/tegra.h> |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/funcmux.h> |
| 14 | #include <asm/arch/pinmux.h> |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 15 | #include <asm/gpio.h> |
Tom Warren | 150c249 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 16 | #include <i2c.h> |
Tom Warren | c9aa831 | 2013-02-21 12:31:30 +0000 | [diff] [blame] | 17 | |
Tom Warren | 3f82d89 | 2012-05-22 11:44:48 +0000 | [diff] [blame] | 18 | #ifdef CONFIG_TEGRA_MMC |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 19 | /* |
| 20 | * Routine: pin_mux_mmc |
| 21 | * Description: setup the pin muxes/tristate values for the SDMMC(s) |
| 22 | */ |
Tom Warren | c9aa831 | 2013-02-21 12:31:30 +0000 | [diff] [blame] | 23 | void pin_mux_mmc(void) |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 24 | { |
Simon Glass | b0e6ef4 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 25 | struct udevice *dev; |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 26 | uchar val; |
| 27 | int ret; |
| 28 | |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 29 | /* Turn on MAX8907B LDO12 to 2.8V for J40 power */ |
Simon Glass | 25ab4b0 | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 30 | ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev); |
Simon Glass | b0e6ef4 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 31 | if (ret) { |
| 32 | printf("%s: Cannot find MAX8907B I2C chip\n", __func__); |
| 33 | return; |
| 34 | } |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 35 | val = 0x29; |
Simon Glass | f9a4c2d | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 36 | ret = dm_i2c_write(dev, 0x46, &val, 1); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 37 | if (ret) |
| 38 | printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret); |
| 39 | val = 0x00; |
Simon Glass | f9a4c2d | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 40 | ret = dm_i2c_write(dev, 0x45, &val, 1); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 41 | if (ret) |
| 42 | printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret); |
| 43 | val = 0x1f; |
Simon Glass | f9a4c2d | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 44 | ret = dm_i2c_write(dev, 0x44, &val, 1); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 45 | if (ret) |
| 46 | printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret); |
| 47 | |
Tom Warren | c9aa831 | 2013-02-21 12:31:30 +0000 | [diff] [blame] | 48 | funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT); |
| 49 | funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 50 | } |
Tom Warren | c9aa831 | 2013-02-21 12:31:30 +0000 | [diff] [blame] | 51 | #endif |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 52 | |
| 53 | /* this is a weak define that we are overriding */ |
| 54 | void pin_mux_usb(void) |
| 55 | { |
Simon Glass | b0e6ef4 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 56 | struct udevice *dev; |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 57 | 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 Glass | 25ab4b0 | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 67 | ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev); |
Simon Glass | b0e6ef4 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 68 | if (ret) { |
| 69 | printf("%s: Cannot find TAC6416 I2C chip\n", __func__); |
| 70 | return; |
| 71 | } |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 72 | val = 0x03; |
Simon Glass | f9a4c2d | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 73 | ret = dm_i2c_write(dev, 2, &val, 1); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 74 | if (ret) |
| 75 | printf("i2c_write 0 0x20 2 failed: %d\n", ret); |
| 76 | val = 0xfc; |
Simon Glass | f9a4c2d | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 77 | ret = dm_i2c_write(dev, 6, &val, 1); |
Stephen Warren | d5ebc93 | 2012-05-15 06:45:28 +0000 | [diff] [blame] | 78 | if (ret) |
| 79 | printf("i2c_write 0 0x20 6 failed: %d\n", ret); |
| 80 | } |