Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <common.h> |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 18 | #include <dm.h> |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 19 | #include <asm/arch/pinmux.h> |
Tom Warren | 3086f6a | 2013-03-18 14:47:55 -0700 | [diff] [blame] | 20 | #include <asm/arch/gp_padctrl.h> |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 21 | #include "pinmux-config-dalmore.h" |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 22 | #include <i2c.h> |
| 23 | |
| 24 | #define BAT_I2C_ADDRESS 0x48 /* TPS65090 charger */ |
| 25 | #define PMU_I2C_ADDRESS 0x58 /* TPS65913 PMU */ |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * Routine: pinmux_init |
| 29 | * Description: Do individual peripheral pinmux configs |
| 30 | */ |
| 31 | void pinmux_init(void) |
| 32 | { |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 33 | pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate, |
Tom Warren | 8495b22 | 2013-03-01 14:38:20 -0700 | [diff] [blame] | 34 | ARRAY_SIZE(tegra114_pinmux_set_nontristate)); |
| 35 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 36 | pinmux_config_pingrp_table(tegra114_pinmux_common, |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 37 | ARRAY_SIZE(tegra114_pinmux_common)); |
| 38 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 39 | pinmux_config_pingrp_table(unused_pins_lowpower, |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 40 | ARRAY_SIZE(unused_pins_lowpower)); |
Tom Warren | 3086f6a | 2013-03-18 14:47:55 -0700 | [diff] [blame] | 41 | |
| 42 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 43 | pinmux_config_drvgrp_table(dalmore_padctrl, |
| 44 | ARRAY_SIZE(dalmore_padctrl)); |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 45 | } |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 46 | |
| 47 | #if defined(CONFIG_TEGRA_MMC) |
| 48 | /* |
| 49 | * Do I2C/PMU writes to bring up SD card bus power |
| 50 | * |
| 51 | */ |
| 52 | void board_sdmmc_voltage_init(void) |
| 53 | { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 54 | struct udevice *dev; |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 55 | uchar reg, data_buffer[1]; |
| 56 | int ret; |
| 57 | |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 58 | ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev); |
| 59 | if (ret) { |
| 60 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
| 61 | return; |
| 62 | } |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 63 | |
| 64 | /* TPS65913: LDO9_VOLTAGE = 3.3V */ |
| 65 | data_buffer[0] = 0x31; |
| 66 | reg = 0x61; |
| 67 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame^] | 68 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 69 | if (ret) |
| 70 | printf("%s: PMU i2c_write %02X<-%02X returned %d\n", |
| 71 | __func__, reg, data_buffer[0], ret); |
| 72 | |
| 73 | /* TPS65913: LDO9_CTRL = Active */ |
| 74 | data_buffer[0] = 0x01; |
| 75 | reg = 0x60; |
| 76 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame^] | 77 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 78 | if (ret) |
| 79 | printf("%s: PMU i2c_write %02X<-%02X returned %d\n", |
| 80 | __func__, reg, data_buffer[0], ret); |
| 81 | |
| 82 | /* TPS65090: FET6_CTRL = enable output auto discharge, enable FET6 */ |
| 83 | data_buffer[0] = 0x03; |
| 84 | reg = 0x14; |
| 85 | |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 86 | ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, &dev); |
| 87 | if (ret) { |
| 88 | debug("%s: Cannot find charger I2C chip\n", __func__); |
| 89 | return; |
| 90 | } |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame^] | 91 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 92 | if (ret) |
| 93 | printf("%s: BAT i2c_write %02X<-%02X returned %d\n", |
| 94 | __func__, reg, data_buffer[0], ret); |
| 95 | } |
| 96 | |
| 97 | /* |
| 98 | * Routine: pin_mux_mmc |
| 99 | * Description: setup the MMC muxes, power rails, etc. |
| 100 | */ |
| 101 | void pin_mux_mmc(void) |
| 102 | { |
| 103 | /* |
| 104 | * NOTE: We don't do mmc-specific pin muxes here. |
| 105 | * They were done globally in pinmux_init(). |
| 106 | */ |
| 107 | |
| 108 | /* Bring up the SDIO3 power rail */ |
| 109 | board_sdmmc_voltage_init(); |
| 110 | } |
| 111 | #endif /* MMC */ |