blob: 530c438a2e3081b8b2b5fd1a806523ef077ff610 [file] [log] [blame]
Tom Warren872111a2020-02-28 16:17:07 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2018-2019
4 * NVIDIA Corporation <www.nvidia.com>
5 *
6 */
7
Tom Warren872111a2020-02-28 16:17:07 -07008#include <fdtdec.h>
9#include <i2c.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060010#include <linux/bitops.h>
Tom Warren872111a2020-02-28 16:17:07 -070011#include <linux/libfdt.h>
12#include <pca953x.h>
Tom Warren872111a2020-02-28 16:17:07 -070013#include <asm/arch/gpio.h>
14#include <asm/arch/pinmux.h>
Thierry Reding1398da62021-09-03 15:16:24 +020015#include <asm/arch-tegra/board.h>
Tom Warren872111a2020-02-28 16:17:07 -070016#include "../p2571/max77620_init.h"
17
18void pin_mux_mmc(void)
19{
20 struct udevice *dev;
21 uchar val;
22 int ret;
23
24 /* Turn on MAX77620 LDO2 to 3.3V for SD card power */
25 debug("%s: Set LDO2 for VDDIO_SDMMC_AP power to 3.3V\n", __func__);
26 ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
27 if (ret) {
28 printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
29 return;
30 }
31 /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
32 val = 0xF2;
33 ret = dm_i2c_write(dev, MAX77620_CNFG1_L2_REG, &val, 1);
34 if (ret)
35 printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret);
36
37 /* Disable LDO4 discharge */
38 ret = dm_i2c_read(dev, MAX77620_CNFG2_L4_REG, &val, 1);
39 if (ret) {
40 printf("i2c_read 0 0x3c 0x2c failed: %d\n", ret);
41 } else {
42 val &= ~BIT(1); /* ADE */
43 ret = dm_i2c_write(dev, MAX77620_CNFG2_L4_REG, &val, 1);
44 if (ret)
45 printf("i2c_write 0 0x3c 0x2c failed: %d\n", ret);
46 }
47
48 /* Set MBLPD */
49 ret = dm_i2c_read(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
50 if (ret) {
51 printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
52 } else {
53 val |= BIT(6); /* MBLPD */
54 ret = dm_i2c_write(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
55 if (ret)
56 printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
57 }
58}
59
60#ifdef CONFIG_PCI_TEGRA
61int tegra_pcie_board_init(void)
62{
63 struct udevice *dev;
64 uchar val;
65 int ret;
66
67 /* Turn on MAX77620 LDO1 to 1.05V for PEX power */
68 debug("%s: Set LDO1 for PEX power to 1.05V\n", __func__);
69 ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
70 if (ret) {
71 printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
72 return -1;
73 }
74 /* 0xCA for 1.05v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
75 val = 0xCA;
76 ret = dm_i2c_write(dev, MAX77620_CNFG1_L1_REG, &val, 1);
77 if (ret)
78 printf("i2c_write 0 0x3c 0x25 failed: %d\n", ret);
79
80 return 0;
81}
82#endif /* PCI */
83
Thierry Reding1398da62021-09-03 15:16:24 +020084static const char * const nodes[] = {
85 "/host1x@50000000/dc@54200000",
86 "/host1x@50000000/dc@54240000",
87 "/external-memory-controller@7001b000",
88};
Tom Warren872111a2020-02-28 16:17:07 -070089
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090090int ft_board_setup(void *fdt, struct bd_info *bd)
Tom Warren872111a2020-02-28 16:17:07 -070091{
92 ft_mac_address_setup(fdt);
Thierry Reding1398da62021-09-03 15:16:24 +020093 ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
Tom Warren872111a2020-02-28 16:17:07 -070094
95 return 0;
96}