1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * (C) Copyright 2010-2013 4 * NVIDIA Corporation <www.nvidia.com> 5 */ 6 7 #include <common.h> 8 #include <dm.h> 9 #include <asm/arch/pinmux.h> 10 #include <asm/arch/gp_padctrl.h> 11 #include <asm/arch/gpio.h> 12 #include <asm/gpio.h> 13 #include "pinmux-config-cardhu.h" 14 #include <i2c.h> 15 16 #define PMU_I2C_ADDRESS 0x2D 17 #define MAX_I2C_RETRY 3 18 19 /* 20 * Routine: pinmux_init 21 * Description: Do individual peripheral pinmux configs 22 */ 23 void pinmux_init(void) 24 { 25 pinmux_config_pingrp_table(tegra3_pinmux_common, 26 ARRAY_SIZE(tegra3_pinmux_common)); 27 28 pinmux_config_pingrp_table(unused_pins_lowpower, 29 ARRAY_SIZE(unused_pins_lowpower)); 30 31 /* Initialize any non-default pad configs (APB_MISC_GP regs) */ 32 pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl)); 33 } 34 35 #if defined(CONFIG_MMC_SDHCI_TEGRA) 36 /* 37 * Do I2C/PMU writes to bring up SD card bus power 38 * 39 */ 40 void board_sdmmc_voltage_init(void) 41 { 42 struct udevice *dev; 43 uchar reg, data_buffer[1]; 44 int ret; 45 int i; 46 47 ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); 48 if (ret) { 49 debug("%s: Cannot find PMIC I2C chip\n", __func__); 50 return; 51 } 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) { 58 if (dm_i2c_write(dev, reg, data_buffer, 1)) 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) { 67 if (dm_i2c_write(dev, reg, data_buffer, 1)) 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 */ 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 95 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); 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 105 err = dm_i2c_write(dev, addr, data, 1); 106 if (err) { 107 debug("failed to set VDD supply\n"); 108 return err; 109 } 110 111 /* GPIO: PEX = 3.3V */ 112 err = gpio_request(TEGRA_GPIO(L, 7), "PEX"); 113 if (err < 0) 114 return err; 115 116 gpio_direction_output(TEGRA_GPIO(L, 7), 1); 117 118 /* TPS659110: LDO2_REG = 1.05V, ACTIVE */ 119 data[0] = 0x15; 120 addr = 0x31; 121 122 err = dm_i2c_write(dev, addr, data, 1); 123 if (err) { 124 debug("failed to set AVDD supply\n"); 125 return err; 126 } 127 128 return 0; 129 } 130 #endif /* PCI */ 131