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