Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved. |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 7 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 9 | #include <asm/arch/pinmux.h> |
Tom Warren | 3086f6a | 2013-03-18 14:47:55 -0700 | [diff] [blame] | 10 | #include <asm/arch/gp_padctrl.h> |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 11 | #include "pinmux-config-dalmore.h" |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 12 | #include <i2c.h> |
| 13 | |
| 14 | #define BAT_I2C_ADDRESS 0x48 /* TPS65090 charger */ |
| 15 | #define PMU_I2C_ADDRESS 0x58 /* TPS65913 PMU */ |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Routine: pinmux_init |
| 19 | * Description: Do individual peripheral pinmux configs |
| 20 | */ |
| 21 | void pinmux_init(void) |
| 22 | { |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 23 | pinmux_config_pingrp_table(tegra114_pinmux_set_nontristate, |
Tom Warren | 8495b22 | 2013-03-01 14:38:20 -0700 | [diff] [blame] | 24 | ARRAY_SIZE(tegra114_pinmux_set_nontristate)); |
| 25 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 26 | pinmux_config_pingrp_table(tegra114_pinmux_common, |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 27 | ARRAY_SIZE(tegra114_pinmux_common)); |
| 28 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 29 | pinmux_config_pingrp_table(unused_pins_lowpower, |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 30 | ARRAY_SIZE(unused_pins_lowpower)); |
Tom Warren | 3086f6a | 2013-03-18 14:47:55 -0700 | [diff] [blame] | 31 | |
| 32 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 33 | pinmux_config_drvgrp_table(dalmore_padctrl, |
| 34 | ARRAY_SIZE(dalmore_padctrl)); |
Tom Warren | 7a3fa01 | 2013-01-28 13:32:13 +0000 | [diff] [blame] | 35 | } |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 36 | |
Masahiro Yamada | b2c8868 | 2017-01-10 13:32:07 +0900 | [diff] [blame] | 37 | #if defined(CONFIG_MMC_SDHCI_TEGRA) |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 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 | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 45 | uchar reg, data_buffer[1]; |
| 46 | int ret; |
| 47 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 48 | ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 49 | if (ret) { |
| 50 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
| 51 | return; |
| 52 | } |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 53 | |
| 54 | /* TPS65913: LDO9_VOLTAGE = 3.3V */ |
| 55 | data_buffer[0] = 0x31; |
| 56 | reg = 0x61; |
| 57 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 58 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 59 | if (ret) |
| 60 | printf("%s: PMU i2c_write %02X<-%02X returned %d\n", |
| 61 | __func__, reg, data_buffer[0], ret); |
| 62 | |
| 63 | /* TPS65913: LDO9_CTRL = Active */ |
| 64 | data_buffer[0] = 0x01; |
| 65 | reg = 0x60; |
| 66 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 67 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 68 | if (ret) |
| 69 | printf("%s: PMU i2c_write %02X<-%02X returned %d\n", |
| 70 | __func__, reg, data_buffer[0], ret); |
| 71 | |
| 72 | /* TPS65090: FET6_CTRL = enable output auto discharge, enable FET6 */ |
| 73 | data_buffer[0] = 0x03; |
| 74 | reg = 0x14; |
| 75 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 76 | ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev); |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 77 | if (ret) { |
| 78 | debug("%s: Cannot find charger I2C chip\n", __func__); |
| 79 | return; |
| 80 | } |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 81 | ret = dm_i2c_write(dev, reg, data_buffer, 1); |
Tom Warren | 35a1d09 | 2013-03-18 14:51:20 -0700 | [diff] [blame] | 82 | if (ret) |
| 83 | printf("%s: BAT i2c_write %02X<-%02X returned %d\n", |
| 84 | __func__, reg, data_buffer[0], ret); |
| 85 | } |
| 86 | |
| 87 | /* |
| 88 | * Routine: pin_mux_mmc |
| 89 | * Description: setup the MMC muxes, power rails, etc. |
| 90 | */ |
| 91 | void pin_mux_mmc(void) |
| 92 | { |
| 93 | /* |
| 94 | * NOTE: We don't do mmc-specific pin muxes here. |
| 95 | * They were done globally in pinmux_init(). |
| 96 | */ |
| 97 | |
| 98 | /* Bring up the SDIO3 power rail */ |
| 99 | board_sdmmc_voltage_init(); |
| 100 | } |
| 101 | #endif /* MMC */ |