Svyatoslav Ryhel | 8178e89 | 2023-06-29 10:10:26 +0300 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2010-2013 |
| 4 | * NVIDIA Corporation <www.nvidia.com> |
| 5 | * |
| 6 | * (C) Copyright 2023 |
| 7 | * Svyatoslav Ryhel <clamor95@gmail.com> |
| 8 | */ |
| 9 | |
| 10 | #include <dm.h> |
| 11 | #include <fdt_support.h> |
| 12 | #include <i2c.h> |
| 13 | #include <log.h> |
| 14 | |
| 15 | #ifdef CONFIG_MMC_SDHCI_TEGRA |
| 16 | |
| 17 | #define TPS65913_I2C_ADDRESS 0x58 |
| 18 | #define TPS65913_PRIMARY_SECONDARY_PAD2 0xfb |
| 19 | #define GPIO_4 BIT(0) |
| 20 | #define TPS65913_PRIMARY_SECONDARY_PAD3 0xfe |
| 21 | #define DVFS2 BIT(1) |
| 22 | #define DVFS1 BIT(0) |
| 23 | |
| 24 | /* We are using this function only till palmas pinctrl driver is available */ |
| 25 | void pin_mux_mmc(void) |
| 26 | { |
| 27 | struct udevice *dev; |
| 28 | int ret; |
| 29 | |
| 30 | ret = i2c_get_chip_for_busnum(0, TPS65913_I2C_ADDRESS, 1, &dev); |
| 31 | if (ret) { |
| 32 | log_debug("%s: cannot find PMIC I2C chip\n", __func__); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | /* GPIO4 function has to be GPIO */ |
| 37 | dm_i2c_reg_clrset(dev, TPS65913_PRIMARY_SECONDARY_PAD2, |
| 38 | GPIO_4, 0); |
| 39 | |
| 40 | /* DVFS1 is enabled, DVFS2 is disabled */ |
| 41 | dm_i2c_reg_clrset(dev, TPS65913_PRIMARY_SECONDARY_PAD3, |
| 42 | DVFS2 | DVFS1, DVFS1); |
| 43 | } |
| 44 | #endif |
| 45 | |
| 46 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 47 | int ft_board_setup(void *blob, struct bd_info *bd) |
| 48 | { |
| 49 | /* Remove TrustZone nodes and memory reserves */ |
| 50 | fdt_del_node_and_alias(blob, "/firmware"); |
| 51 | fdt_del_node_and_alias(blob, "/reserved-memory/trustzone@bfe00000"); |
| 52 | fdt_del_node_and_alias(blob, "/reserved-memory/bootloader-firmware@b7e00000"); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | #endif |