Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 2 | /* |
Tom Warren | 547bd33 | 2020-03-26 16:10:11 -0700 | [diff] [blame] | 3 | * (C) Copyright 2013-2019 |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 4 | * NVIDIA Corporation <www.nvidia.com> |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 8 | #include <env.h> |
Thierry Reding | 8f88e02 | 2019-04-15 11:32:35 +0200 | [diff] [blame] | 9 | #include <fdtdec.h> |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 10 | #include <i2c.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
Thierry Reding | 4a024c2 | 2021-09-03 15:16:22 +0200 | [diff] [blame] | 13 | #include <stdlib.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 14 | #include <linux/bitops.h> |
Thierry Reding | 14f9d16 | 2019-04-15 11:32:33 +0200 | [diff] [blame] | 15 | #include <linux/libfdt.h> |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 16 | #include <asm/arch/gpio.h> |
| 17 | #include <asm/arch/pinmux.h> |
Thierry Reding | 1398da6 | 2021-09-03 15:16:24 +0200 | [diff] [blame] | 18 | #include <asm/arch-tegra/board.h> |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 19 | #include "../p2571/max77620_init.h" |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 20 | |
| 21 | void pin_mux_mmc(void) |
| 22 | { |
| 23 | struct udevice *dev; |
| 24 | uchar val; |
| 25 | int ret; |
| 26 | |
| 27 | /* Turn on MAX77620 LDO2 to 3.3V for SD card power */ |
| 28 | debug("%s: Set LDO2 for VDDIO_SDMMC_AP power to 3.3V\n", __func__); |
| 29 | ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev); |
| 30 | if (ret) { |
| 31 | printf("%s: Cannot find MAX77620 I2C chip\n", __func__); |
| 32 | return; |
| 33 | } |
| 34 | /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */ |
| 35 | val = 0xF2; |
| 36 | ret = dm_i2c_write(dev, MAX77620_CNFG1_L2_REG, &val, 1); |
| 37 | if (ret) |
| 38 | printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret); |
Stephen Warren | b0cd500 | 2016-07-18 13:02:11 -0600 | [diff] [blame] | 39 | |
| 40 | /* Disable LDO4 discharge */ |
| 41 | ret = dm_i2c_read(dev, MAX77620_CNFG2_L4_REG, &val, 1); |
| 42 | if (ret) { |
| 43 | printf("i2c_read 0 0x3c 0x2c failed: %d\n", ret); |
| 44 | } else { |
| 45 | val &= ~BIT(1); /* ADE */ |
| 46 | ret = dm_i2c_write(dev, MAX77620_CNFG2_L4_REG, &val, 1); |
| 47 | if (ret) |
| 48 | printf("i2c_write 0 0x3c 0x2c failed: %d\n", ret); |
| 49 | } |
| 50 | |
| 51 | /* Set MBLPD */ |
| 52 | ret = dm_i2c_read(dev, MAX77620_CNFGGLBL1_REG, &val, 1); |
| 53 | if (ret) { |
| 54 | printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret); |
| 55 | } else { |
| 56 | val |= BIT(6); /* MBLPD */ |
| 57 | ret = dm_i2c_write(dev, MAX77620_CNFGGLBL1_REG, &val, 1); |
| 58 | if (ret) |
| 59 | printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret); |
| 60 | } |
Stephen Warren | 8681561 | 2015-08-13 22:34:22 -0600 | [diff] [blame] | 61 | } |
| 62 | |
Stephen Warren | 16572fd | 2015-10-05 17:02:40 -0600 | [diff] [blame] | 63 | #ifdef CONFIG_PCI_TEGRA |
| 64 | int tegra_pcie_board_init(void) |
| 65 | { |
| 66 | struct udevice *dev; |
| 67 | uchar val; |
| 68 | int ret; |
| 69 | |
| 70 | /* Turn on MAX77620 LDO1 to 1.05V for PEX power */ |
| 71 | debug("%s: Set LDO1 for PEX power to 1.05V\n", __func__); |
| 72 | ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev); |
| 73 | if (ret) { |
| 74 | printf("%s: Cannot find MAX77620 I2C chip\n", __func__); |
| 75 | return -1; |
| 76 | } |
| 77 | /* 0xCA for 1.05v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */ |
| 78 | val = 0xCA; |
| 79 | ret = dm_i2c_write(dev, MAX77620_CNFG1_L1_REG, &val, 1); |
| 80 | if (ret) |
| 81 | printf("i2c_write 0 0x3c 0x25 failed: %d\n", ret); |
| 82 | |
| 83 | return 0; |
| 84 | } |
Stephen Warren | 16572fd | 2015-10-05 17:02:40 -0600 | [diff] [blame] | 85 | #endif /* PCI */ |
Thierry Reding | 14f9d16 | 2019-04-15 11:32:33 +0200 | [diff] [blame] | 86 | |
Thierry Reding | 1398da6 | 2021-09-03 15:16:24 +0200 | [diff] [blame] | 87 | static const char * const nodes[] = { |
| 88 | "/host1x@50000000/dc@54200000", |
| 89 | "/host1x@50000000/dc@54240000", |
| 90 | "/external-memory-controller@7001b000", |
| 91 | }; |
Thierry Reding | 8f88e02 | 2019-04-15 11:32:35 +0200 | [diff] [blame] | 92 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 93 | int ft_board_setup(void *fdt, struct bd_info *bd) |
Thierry Reding | 14f9d16 | 2019-04-15 11:32:33 +0200 | [diff] [blame] | 94 | { |
| 95 | ft_mac_address_setup(fdt); |
Thierry Reding | 1398da6 | 2021-09-03 15:16:24 +0200 | [diff] [blame] | 96 | ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes)); |
Thierry Reding | 14f9d16 | 2019-04-15 11:32:33 +0200 | [diff] [blame] | 97 | |
| 98 | return 0; |
| 99 | } |