Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 1ce3d54 | 2016-05-12 13:32:56 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION |
Stephen Warren | 1ce3d54 | 2016-05-12 13:32:56 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Stephen Warren | 7f253c8 | 2016-07-29 13:15:05 -0600 | [diff] [blame] | 7 | #include <i2c.h> |
| 8 | #include "../p2571/max77620_init.h" |
| 9 | |
| 10 | int tegra_board_init(void) |
| 11 | { |
| 12 | struct udevice *dev; |
| 13 | uchar val; |
| 14 | int ret; |
| 15 | |
| 16 | /* Turn on MAX77620 LDO3 to 3.3V for SD card power */ |
| 17 | debug("%s: Set LDO3 for VDDIO_SDMMC_AP power to 3.3V\n", __func__); |
| 18 | ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev); |
| 19 | if (ret) { |
| 20 | printf("%s: Cannot find MAX77620 I2C chip\n", __func__); |
| 21 | return ret; |
| 22 | } |
| 23 | /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */ |
| 24 | val = 0xF2; |
| 25 | ret = dm_i2c_write(dev, MAX77620_CNFG1_L3_REG, &val, 1); |
| 26 | if (ret) { |
| 27 | printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret); |
| 28 | return ret; |
| 29 | } |
| 30 | |
| 31 | return 0; |
| 32 | } |
Stephen Warren | 2f54650 | 2016-07-29 13:15:06 -0600 | [diff] [blame] | 33 | |
| 34 | int tegra_pcie_board_init(void) |
| 35 | { |
| 36 | struct udevice *dev; |
| 37 | uchar val; |
| 38 | int ret; |
| 39 | |
| 40 | /* Turn on MAX77620 LDO7 to 1.05V for PEX power */ |
| 41 | debug("%s: Set LDO7 for PEX power to 1.05V\n", __func__); |
| 42 | ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev); |
| 43 | if (ret) { |
| 44 | printf("%s: Cannot find MAX77620 I2C chip\n", __func__); |
| 45 | return -1; |
| 46 | } |
| 47 | /* 0xC5 for 1.05v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */ |
| 48 | val = 0xC5; |
| 49 | ret = dm_i2c_write(dev, MAX77620_CNFG1_L7_REG, &val, 1); |
| 50 | if (ret) |
| 51 | printf("i2c_write 0 0x3c 0x31 failed: %d\n", ret); |
| 52 | |
| 53 | return 0; |
| 54 | } |