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