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