blob: fb1a224daa72e7b4d79caa48c747bbd4bd8a8f46 [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
8#include <common.h>
9#include <fdtdec.h>
10#include <i2c.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060011#include <linux/bitops.h>
Tom Warren872111a2020-02-28 16:17:07 -070012#include <linux/libfdt.h>
13#include <pca953x.h>
Tom Warren872111a2020-02-28 16:17:07 -070014#include <asm/arch/gpio.h>
15#include <asm/arch/pinmux.h>
Thierry Reding1398da62021-09-03 15:16:24 +020016#include <asm/arch-tegra/board.h>
Tom Warren872111a2020-02-28 16:17:07 -070017#include "../p2571/max77620_init.h"
18
19void pin_mux_mmc(void)
20{
21 struct udevice *dev;
22 uchar val;
23 int ret;
24
25 /* Turn on MAX77620 LDO2 to 3.3V for SD card power */
26 debug("%s: Set LDO2 for VDDIO_SDMMC_AP power to 3.3V\n", __func__);
27 ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
28 if (ret) {
29 printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
30 return;
31 }
32 /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
33 val = 0xF2;
34 ret = dm_i2c_write(dev, MAX77620_CNFG1_L2_REG, &val, 1);
35 if (ret)
36 printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret);
37
38 /* Disable LDO4 discharge */
39 ret = dm_i2c_read(dev, MAX77620_CNFG2_L4_REG, &val, 1);
40 if (ret) {
41 printf("i2c_read 0 0x3c 0x2c failed: %d\n", ret);
42 } else {
43 val &= ~BIT(1); /* ADE */
44 ret = dm_i2c_write(dev, MAX77620_CNFG2_L4_REG, &val, 1);
45 if (ret)
46 printf("i2c_write 0 0x3c 0x2c failed: %d\n", ret);
47 }
48
49 /* Set MBLPD */
50 ret = dm_i2c_read(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
51 if (ret) {
52 printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
53 } else {
54 val |= BIT(6); /* MBLPD */
55 ret = dm_i2c_write(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
56 if (ret)
57 printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
58 }
59}
60
61#ifdef CONFIG_PCI_TEGRA
62int tegra_pcie_board_init(void)
63{
64 struct udevice *dev;
65 uchar val;
66 int ret;
67
68 /* Turn on MAX77620 LDO1 to 1.05V for PEX power */
69 debug("%s: Set LDO1 for PEX power to 1.05V\n", __func__);
70 ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
71 if (ret) {
72 printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
73 return -1;
74 }
75 /* 0xCA for 1.05v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
76 val = 0xCA;
77 ret = dm_i2c_write(dev, MAX77620_CNFG1_L1_REG, &val, 1);
78 if (ret)
79 printf("i2c_write 0 0x3c 0x25 failed: %d\n", ret);
80
81 return 0;
82}
83#endif /* PCI */
84
Thierry Reding1398da62021-09-03 15:16:24 +020085static const char * const nodes[] = {
86 "/host1x@50000000/dc@54200000",
87 "/host1x@50000000/dc@54240000",
88 "/external-memory-controller@7001b000",
89};
Tom Warren872111a2020-02-28 16:17:07 -070090
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090091int ft_board_setup(void *fdt, struct bd_info *bd)
Tom Warren872111a2020-02-28 16:17:07 -070092{
93 ft_mac_address_setup(fdt);
Thierry Reding1398da62021-09-03 15:16:24 +020094 ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
Tom Warren872111a2020-02-28 16:17:07 -070095
96 return 0;
97}