Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 |
| 4 | * NVIDIA Corporation <www.nvidia.com> |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 8 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 10 | #include <linux/printk.h> |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 11 | #include <power/as3722.h> |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 12 | #include <power/pmic.h> |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 13 | |
Stephen Warren | fa2a123 | 2014-04-22 14:37:55 -0600 | [diff] [blame] | 14 | #include <asm/arch/gpio.h> |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 15 | #include <asm/arch/pinmux.h> |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 16 | |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 17 | #include "pinmux-config-jetson-tk1.h" |
| 18 | |
| 19 | /* |
| 20 | * Routine: pinmux_init |
| 21 | * Description: Do individual peripheral pinmux configs |
| 22 | */ |
| 23 | void pinmux_init(void) |
| 24 | { |
Stephen Warren | 2516bef | 2015-02-18 13:27:04 -0700 | [diff] [blame] | 25 | pinmux_clear_tristate_input_clamping(); |
Stephen Warren | f16f64f | 2014-04-22 14:37:56 -0600 | [diff] [blame] | 26 | |
Stephen Warren | fa2a123 | 2014-04-22 14:37:55 -0600 | [diff] [blame] | 27 | gpio_config_table(jetson_tk1_gpio_inits, |
| 28 | ARRAY_SIZE(jetson_tk1_gpio_inits)); |
| 29 | |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 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)); |
Stephen Warren | 8e7c1be | 2016-04-21 16:03:37 -0600 | [diff] [blame] | 35 | |
| 36 | pinmux_config_mipipadctrlgrp_table(jetson_tk1_mipipadctrlgrps, |
| 37 | ARRAY_SIZE(jetson_tk1_mipipadctrlgrps)); |
Stephen Warren | a844b01 | 2014-03-25 11:39:33 -0600 | [diff] [blame] | 38 | } |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 39 | |
| 40 | #ifdef CONFIG_PCI_TEGRA |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 41 | /* TODO: Convert to driver model */ |
| 42 | static int as3722_sd_enable(struct udevice *pmic, unsigned int sd) |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 43 | { |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 44 | int err; |
| 45 | |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 46 | if (sd > 6) |
| 47 | return -EINVAL; |
| 48 | |
| 49 | err = pmic_clrsetbits(pmic, AS3722_SD_CONTROL, 0, 1 << sd); |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 50 | if (err) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 51 | pr_err("failed to update SD control register: %d", err); |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 52 | return err; |
| 53 | } |
| 54 | |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | int tegra_pcie_board_init(void) |
| 59 | { |
| 60 | struct udevice *dev; |
| 61 | int ret; |
| 62 | |
| 63 | ret = uclass_get_device_by_driver(UCLASS_PMIC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 64 | DM_DRIVER_GET(pmic_as3722), &dev); |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 65 | if (ret) { |
| 66 | debug("%s: Failed to find PMIC\n", __func__); |
| 67 | return ret; |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 70 | ret = as3722_sd_enable(dev, 4); |
| 71 | if (ret < 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 72 | pr_err("failed to enable SD4: %d\n", ret); |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 73 | return ret; |
| 74 | } |
| 75 | |
| 76 | ret = as3722_sd_set_voltage(dev, 4, 0x24); |
| 77 | if (ret < 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 78 | pr_err("failed to set SD4 voltage: %d\n", ret); |
Simon Glass | b3d2ed3 | 2017-07-25 08:30:12 -0600 | [diff] [blame] | 79 | return ret; |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 82 | return 0; |
| 83 | } |
Thierry Reding | 0f4c83b | 2014-12-09 22:25:21 -0700 | [diff] [blame] | 84 | #endif /* PCI */ |