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