uboot/board/nvidia/p2371-2180/p2371-2180.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * (C) Copyright 2013-2019
   4 * NVIDIA Corporation <www.nvidia.com>
   5 */
   6
   7#include <common.h>
   8#include <env.h>
   9#include <fdtdec.h>
  10#include <i2c.h>
  11#include <log.h>
  12#include <net.h>
  13#include <stdlib.h>
  14#include <linux/bitops.h>
  15#include <linux/libfdt.h>
  16#include <asm/arch/gpio.h>
  17#include <asm/arch/pinmux.h>
  18#include <asm/arch-tegra/board.h>
  19#include "../p2571/max77620_init.h"
  20
  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);
  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        }
  61}
  62
  63#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}
  85#endif /* PCI */
  86
  87static const char * const nodes[] = {
  88        "/host1x@50000000/dc@54200000",
  89        "/host1x@50000000/dc@54240000",
  90        "/external-memory-controller@7001b000",
  91};
  92
  93int ft_board_setup(void *fdt, struct bd_info *bd)
  94{
  95        ft_mac_address_setup(fdt);
  96        ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
  97
  98        return 0;
  99}
 100