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> |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 12 | #include "pinmux-config-cardhu.h" |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 13 | #include <i2c.h> |
| 14 | |
| 15 | #define PMU_I2C_ADDRESS 0x2D |
| 16 | #define MAX_I2C_RETRY 3 |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * Routine: pinmux_init |
| 20 | * Description: Do individual peripheral pinmux configs |
| 21 | */ |
| 22 | void pinmux_init(void) |
| 23 | { |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 24 | pinmux_config_pingrp_table(tegra3_pinmux_common, |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 25 | ARRAY_SIZE(tegra3_pinmux_common)); |
| 26 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 27 | pinmux_config_pingrp_table(unused_pins_lowpower, |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 28 | ARRAY_SIZE(unused_pins_lowpower)); |
Tom Warren | 7110b95 | 2013-03-06 16:16:22 -0700 | [diff] [blame] | 29 | |
| 30 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 31 | pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl)); |
Tom Warren | 23d7fe9 | 2012-12-11 13:34:18 +0000 | [diff] [blame] | 32 | } |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 33 | |
| 34 | #if defined(CONFIG_TEGRA_MMC) |
| 35 | /* |
| 36 | * Do I2C/PMU writes to bring up SD card bus power |
| 37 | * |
| 38 | */ |
| 39 | void board_sdmmc_voltage_init(void) |
| 40 | { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 41 | struct udevice *dev; |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 42 | uchar reg, data_buffer[1]; |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 43 | int ret; |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 44 | int i; |
| 45 | |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 46 | ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev); |
| 47 | if (ret) { |
| 48 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
| 49 | return; |
| 50 | } |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 51 | |
| 52 | /* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */ |
| 53 | data_buffer[0] = 0x65; |
| 54 | reg = 0x32; |
| 55 | |
| 56 | for (i = 0; i < MAX_I2C_RETRY; ++i) { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 57 | if (i2c_write(dev, reg, data_buffer, 1)) |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 58 | udelay(100); |
| 59 | } |
| 60 | |
| 61 | /* TPS659110: GPIO7_REG = PDEN, output a 1 to EN_3V3_SYS */ |
| 62 | data_buffer[0] = 0x09; |
| 63 | reg = 0x67; |
| 64 | |
| 65 | for (i = 0; i < MAX_I2C_RETRY; ++i) { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 66 | if (i2c_write(dev, reg, data_buffer, 1)) |
Tom Warren | f5d874d | 2013-02-26 12:26:55 -0700 | [diff] [blame] | 67 | udelay(100); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * Routine: pin_mux_mmc |
| 73 | * Description: setup the MMC muxes, power rails, etc. |
| 74 | */ |
| 75 | void pin_mux_mmc(void) |
| 76 | { |
| 77 | /* |
| 78 | * NOTE: We don't do mmc-specific pin muxes here. |
| 79 | * They were done globally in pinmux_init(). |
| 80 | */ |
| 81 | |
| 82 | /* Bring up the SDIO1 power rail */ |
| 83 | board_sdmmc_voltage_init(); |
| 84 | } |
| 85 | #endif /* MMC */ |