1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * (C) Copyright 2014 4 * NVIDIA Corporation <www.nvidia.com> 5 */ 6 7#include <common.h> 8#include <dm.h> 9#include <log.h> 10#include <linux/printk.h> 11#include <power/as3722.h> 12#include <power/pmic.h> 13 14#include <asm/arch/gpio.h> 15#include <asm/arch/pinmux.h> 16 17#include "pinmux-config-jetson-tk1.h" 18 19/* 20 * Routine: pinmux_init 21 * Description: Do individual peripheral pinmux configs 22 */ 23void pinmux_init(void) 24{ 25 pinmux_clear_tristate_input_clamping(); 26 27 gpio_config_table(jetson_tk1_gpio_inits, 28 ARRAY_SIZE(jetson_tk1_gpio_inits)); 29 30 pinmux_config_pingrp_table(jetson_tk1_pingrps, 31 ARRAY_SIZE(jetson_tk1_pingrps)); 32 33 pinmux_config_drvgrp_table(jetson_tk1_drvgrps, 34 ARRAY_SIZE(jetson_tk1_drvgrps)); 35 36 pinmux_config_mipipadctrlgrp_table(jetson_tk1_mipipadctrlgrps, 37 ARRAY_SIZE(jetson_tk1_mipipadctrlgrps)); 38} 39 40#ifdef CONFIG_PCI_TEGRA 41/* TODO: Convert to driver model */ 42static int as3722_sd_enable(struct udevice *pmic, unsigned int sd) 43{ 44 int err; 45 46 if (sd > 6) 47 return -EINVAL; 48 49 err = pmic_clrsetbits(pmic, AS3722_SD_CONTROL, 0, 1 << sd); 50 if (err) { 51 pr_err("failed to update SD control register: %d", err); 52 return err; 53 } 54 55 return 0; 56} 57 58int tegra_pcie_board_init(void) 59{ 60 struct udevice *dev; 61 int ret; 62 63 ret = uclass_get_device_by_driver(UCLASS_PMIC, 64 DM_DRIVER_GET(pmic_as3722), &dev); 65 if (ret) { 66 debug("%s: Failed to find PMIC\n", __func__); 67 return ret; 68 } 69 70 ret = as3722_sd_enable(dev, 4); 71 if (ret < 0) { 72 pr_err("failed to enable SD4: %d\n", ret); 73 return ret; 74 } 75 76 ret = as3722_sd_set_voltage(dev, 4, 0x24); 77 if (ret < 0) { 78 pr_err("failed to set SD4 voltage: %d\n", ret); 79 return ret; 80 } 81 82 return 0; 83} 84#endif /* PCI */ 85