1873e3ef9STom Warren /*
2873e3ef9STom Warren * (C) Copyright 2013-2015
3873e3ef9STom Warren * NVIDIA Corporation <www.nvidia.com>
4873e3ef9STom Warren *
5873e3ef9STom Warren * SPDX-License-Identifier: GPL-2.0+
6873e3ef9STom Warren */
7873e3ef9STom Warren
8873e3ef9STom Warren #include <common.h>
94132bc90STom Warren #include <i2c.h>
10873e3ef9STom Warren #include <asm/arch/gpio.h>
11873e3ef9STom Warren #include <asm/arch/pinmux.h>
1266999892STom Warren #include <asm/gpio.h>
134132bc90STom Warren #include "max77620_init.h"
14873e3ef9STom Warren #include "pinmux-config-p2571.h"
15873e3ef9STom Warren
pin_mux_mmc(void)164132bc90STom Warren void pin_mux_mmc(void)
174132bc90STom Warren {
184132bc90STom Warren struct udevice *dev;
194132bc90STom Warren uchar val;
204132bc90STom Warren int ret;
214132bc90STom Warren
224132bc90STom Warren /* Turn on MAX77620 LDO2 to 3.3V for SD card power */
234132bc90STom Warren debug("%s: Set LDO2 for VDDIO_SDMMC_AP power to 3.3V\n", __func__);
244132bc90STom Warren ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
254132bc90STom Warren if (ret) {
264132bc90STom Warren printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
274132bc90STom Warren return;
284132bc90STom Warren }
294132bc90STom Warren /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
304132bc90STom Warren val = 0xF2;
314132bc90STom Warren ret = dm_i2c_write(dev, MAX77620_CNFG1_L2_REG, &val, 1);
324132bc90STom Warren if (ret)
334132bc90STom Warren printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret);
344132bc90STom Warren }
354132bc90STom Warren
36873e3ef9STom Warren /*
37873e3ef9STom Warren * Routine: pinmux_init
38873e3ef9STom Warren * Description: Do individual peripheral pinmux configs
39873e3ef9STom Warren */
pinmux_init(void)40873e3ef9STom Warren void pinmux_init(void)
41873e3ef9STom Warren {
42873e3ef9STom Warren pinmux_clear_tristate_input_clamping();
43873e3ef9STom Warren
44873e3ef9STom Warren gpio_config_table(p2571_gpio_inits,
45873e3ef9STom Warren ARRAY_SIZE(p2571_gpio_inits));
46873e3ef9STom Warren
47873e3ef9STom Warren pinmux_config_pingrp_table(p2571_pingrps,
48873e3ef9STom Warren ARRAY_SIZE(p2571_pingrps));
49873e3ef9STom Warren
50873e3ef9STom Warren pinmux_config_drvgrp_table(p2571_drvgrps,
51873e3ef9STom Warren ARRAY_SIZE(p2571_drvgrps));
52873e3ef9STom Warren }
5366999892STom Warren
5466999892STom Warren /*
5566999892STom Warren * Routine: start_cpu_fan
5666999892STom Warren * Description: Enable/start PWM CPU fan on P2571
5766999892STom Warren */
start_cpu_fan(void)5866999892STom Warren void start_cpu_fan(void)
5966999892STom Warren {
6066999892STom Warren /* GPIO_PE4 is PS_VDD_FAN_ENABLE */
61*01a97a11SStephen Warren gpio_request(TEGRA_GPIO(E, 4), "FAN_VDD");
62*01a97a11SStephen Warren gpio_direction_output(TEGRA_GPIO(E, 4), 1);
6366999892STom Warren }
64