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