Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 2 | /* |
Tom Warren | 7110b95 | 2013-03-06 16:16:22 -0700 | [diff] [blame] | 3 | * (C) Copyright 2010-2013 |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 4 | * NVIDIA Corporation <www.nvidia.com> |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 8 | #include <dm.h> |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 9 | #include <asm/arch/pinmux.h> |
Tom Warren | 7110b95 | 2013-03-06 16:16:22 -0700 | [diff] [blame] | 10 | #include <asm/arch/gp_padctrl.h> |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 11 | #include <asm/arch/gpio.h> |
| 12 | #include <asm/gpio.h> |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 13 | #include "pinmux-config-cardhu.h" |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 14 | #include <i2c.h> |
| 15 | |
| 16 | #define PMU_I2C_ADDRESS 0x2D |
| 17 | #define MAX_I2C_RETRY 3 |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * Routine: pinmux_init |
| 21 | * Description: Do individual peripheral pinmux configs |
| 22 | */ |
| 23 | void pinmux_init(void) |
| 24 | { |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 25 | pinmux_config_pingrp_table(tegra3_pinmux_common, |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 26 | ARRAY_SIZE(tegra3_pinmux_common)); |
| 27 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 28 | pinmux_config_pingrp_table(unused_pins_lowpower, |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 29 | ARRAY_SIZE(unused_pins_lowpower)); |
Tom Warren | 7110b95 | 2013-03-06 16:16:22 -0700 | [diff] [blame] | 30 | |
| 31 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 32 | pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl)); |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 33 | } |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 34 | |
Masahiro Yamada | b2c8868 | 2017-01-10 13:32:07 +0900 | [diff] [blame] | 35 | #if defined(CONFIG_MMC_SDHCI_TEGRA) |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 36 | /* |
| 37 | * Do I2C/PMU writes to bring up SD card bus power |
| 38 | * |
| 39 | */ |
| 40 | void board_sdmmc_voltage_init(void) |
| 41 | { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 42 | struct udevice *dev; |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 43 | uchar reg, data_buffer[1]; |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 44 | int ret; |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 45 | int i; |
| 46 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 47 | ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 48 | if (ret) { |
| 49 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
| 50 | return; |
| 51 | } |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 52 | |
| 53 | /* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */ |
| 54 | data_buffer[0] = 0x65; |
| 55 | reg = 0x32; |
| 56 | |
| 57 | for (i = 0; i < MAX_I2C_RETRY; ++i) { |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 58 | if (dm_i2c_write(dev, reg, data_buffer, 1)) |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 59 | udelay(100); |
| 60 | } |
| 61 | |
| 62 | /* TPS659110: GPIO7_REG = PDEN, output a 1 to EN_3V3_SYS */ |
| 63 | data_buffer[0] = 0x09; |
| 64 | reg = 0x67; |
| 65 | |
| 66 | for (i = 0; i < MAX_I2C_RETRY; ++i) { |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 67 | if (dm_i2c_write(dev, reg, data_buffer, 1)) |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 68 | udelay(100); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * Routine: pin_mux_mmc |
| 74 | * Description: setup the MMC muxes, power rails, etc. |
| 75 | */ |
| 76 | void pin_mux_mmc(void) |
| 77 | { |
| 78 | /* |
| 79 | * NOTE: We don't do mmc-specific pin muxes here. |
| 80 | * They were done globally in pinmux_init(). |
| 81 | */ |
| 82 | |
| 83 | /* Bring up the SDIO1 power rail */ |
| 84 | board_sdmmc_voltage_init(); |
| 85 | } |
| 86 | #endif /* MMC */ |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef CONFIG_PCI_TEGRA |
| 89 | int tegra_pcie_board_init(void) |
| 90 | { |
| 91 | struct udevice *dev; |
| 92 | u8 addr, data[1]; |
| 93 | int err; |
| 94 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 95 | err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 96 | if (err) { |
| 97 | debug("failed to find PMU bus\n"); |
| 98 | return err; |
| 99 | } |
| 100 | |
| 101 | /* TPS659110: LDO1_REG = 1.05V, ACTIVE */ |
| 102 | data[0] = 0x15; |
| 103 | addr = 0x30; |
| 104 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 105 | err = dm_i2c_write(dev, addr, data, 1); |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 106 | if (err) { |
| 107 | debug("failed to set VDD supply\n"); |
| 108 | return err; |
| 109 | } |
| 110 | |
| 111 | /* GPIO: PEX = 3.3V */ |
Stephen Warren | 7f20bb2 | 2016-05-12 12:07:39 -0600 | [diff] [blame] | 112 | err = gpio_request(TEGRA_GPIO(L, 7), "PEX"); |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 113 | if (err < 0) |
| 114 | return err; |
| 115 | |
Stephen Warren | 7f20bb2 | 2016-05-12 12:07:39 -0600 | [diff] [blame] | 116 | gpio_direction_output(TEGRA_GPIO(L, 7), 1); |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 117 | |
| 118 | /* TPS659110: LDO2_REG = 1.05V, ACTIVE */ |
| 119 | data[0] = 0x15; |
| 120 | addr = 0x31; |
| 121 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 122 | err = dm_i2c_write(dev, addr, data, 1); |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 123 | if (err) { |
| 124 | debug("failed to set AVDD supply\n"); |
| 125 | return err; |
| 126 | } |
| 127 | |
| 128 | return 0; |
| 129 | } |
Thierry Reding | 0a5ffb0 | 2014-12-09 22:25:17 -0700 | [diff] [blame] | 130 | #endif /* PCI */ |