blob: 816c7bec6ae4eafe09e63df68fdc99412a8b4989 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stephen Warren25734282015-08-13 22:34:22 -06002/*
Tom Warren48ba1962020-03-26 16:10:11 -07003 * (C) Copyright 2013-2019
Stephen Warren25734282015-08-13 22:34:22 -06004 * NVIDIA Corporation <www.nvidia.com>
Stephen Warren25734282015-08-13 22:34:22 -06005 */
6
7#include <common.h>
Simon Glass7b51b572019-08-01 09:46:52 -06008#include <env.h>
Thierry Reding595ea732019-04-15 11:32:35 +02009#include <fdtdec.h>
Stephen Warren25734282015-08-13 22:34:22 -060010#include <i2c.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060011#include <log.h>
Simon Glass90526e92020-05-10 11:39:56 -060012#include <net.h>
Thierry Redingdb8a0302021-09-03 15:16:22 +020013#include <stdlib.h>
Simon Glasscd93d622020-05-10 11:40:13 -060014#include <linux/bitops.h>
Thierry Redinga930a722019-04-15 11:32:33 +020015#include <linux/libfdt.h>
Stephen Warren25734282015-08-13 22:34:22 -060016#include <asm/arch/gpio.h>
17#include <asm/arch/pinmux.h>
Thierry Reding77409c72021-09-03 15:16:24 +020018#include <asm/arch-tegra/board.h>
Stephen Warren25734282015-08-13 22:34:22 -060019#include "../p2571/max77620_init.h"
Stephen Warren25734282015-08-13 22:34:22 -060020
21void 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 Warrenefbb3d42016-07-18 13:02:11 -060039
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 Warren25734282015-08-13 22:34:22 -060061}
62
Stephen Warren019bc622015-10-05 17:02:40 -060063#ifdef CONFIG_PCI_TEGRA
64int 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 Warren019bc622015-10-05 17:02:40 -060085#endif /* PCI */
Thierry Redinga930a722019-04-15 11:32:33 +020086
Thierry Reding77409c72021-09-03 15:16:24 +020087static const char * const nodes[] = {
88 "/host1x@50000000/dc@54200000",
89 "/host1x@50000000/dc@54240000",
90 "/external-memory-controller@7001b000",
91};
Thierry Reding595ea732019-04-15 11:32:35 +020092
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +090093int ft_board_setup(void *fdt, struct bd_info *bd)
Thierry Redinga930a722019-04-15 11:32:33 +020094{
95 ft_mac_address_setup(fdt);
Thierry Reding77409c72021-09-03 15:16:24 +020096 ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
Thierry Redinga930a722019-04-15 11:32:33 +020097
98 return 0;
99}