Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 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> |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 9 | #include <dm.h> |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 10 | #include <power/as3722.h> |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 11 | #include <power/pmic.h> |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 12 | |
Stephen Warren | 9348532 | 2014-04-22 14:37:55 -0600 | [diff] [blame] | 13 | #include <asm/arch/gpio.h> |
Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 14 | #include <asm/arch/pinmux.h> |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 15 | |
Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 16 | #include "pinmux-config-jetson-tk1.h" |
| 17 | |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 20 | /* |
| 21 | * Routine: pinmux_init |
| 22 | * Description: Do individual peripheral pinmux configs |
| 23 | */ |
| 24 | void pinmux_init(void) |
| 25 | { |
Stephen Warren | c1fe92f | 2015-02-18 13:27:04 -0700 | [diff] [blame] | 26 | pinmux_clear_tristate_input_clamping(); |
Stephen Warren | 4ff213b | 2014-04-22 14:37:56 -0600 | [diff] [blame] | 27 | |
Stephen Warren | 9348532 | 2014-04-22 14:37:55 -0600 | [diff] [blame] | 28 | gpio_config_table(jetson_tk1_gpio_inits, |
| 29 | ARRAY_SIZE(jetson_tk1_gpio_inits)); |
| 30 | |
Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 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)); |
Stephen Warren | bbca710 | 2016-04-21 16:03:37 -0600 | [diff] [blame] | 36 | |
| 37 | pinmux_config_mipipadctrlgrp_table(jetson_tk1_mipipadctrlgrps, |
| 38 | ARRAY_SIZE(jetson_tk1_mipipadctrlgrps)); |
Stephen Warren | e04bfda | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 39 | } |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 40 | |
| 41 | #ifdef CONFIG_PCI_TEGRA |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 42 | /* TODO: Convert to driver model */ |
| 43 | static int as3722_sd_enable(struct udevice *pmic, unsigned int sd) |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 44 | { |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 45 | int err; |
| 46 | |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 47 | if (sd > 6) |
| 48 | return -EINVAL; |
| 49 | |
| 50 | err = pmic_clrsetbits(pmic, AS3722_SD_CONTROL, 0, 1 << sd); |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 51 | if (err) { |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 52 | error("failed to update SD control register: %d", err); |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 53 | return err; |
| 54 | } |
| 55 | |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | int 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; |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Simon Glass | e3f44f5 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 71 | ret = as3722_sd_enable(dev, 4); |
| 72 | if (ret < 0) { |
| 73 | error("failed to enable SD4: %d\n", ret); |
| 74 | return ret; |
| 75 | } |
| 76 | |
| 77 | ret = as3722_sd_set_voltage(dev, 4, 0x24); |
| 78 | if (ret < 0) { |
| 79 | error("failed to set SD4 voltage: %d\n", ret); |
| 80 | return ret; |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 83 | return 0; |
| 84 | } |
Thierry Reding | 6e2fca9 | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 85 | #endif /* PCI */ |