Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 2 | /* |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 3 | * (C) Copyright 2014-2016 |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 4 | * Marcel Ziswiler <marcel@ziswiler.com> |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 8 | #include <asm/arch/gp_padctrl.h> |
| 9 | #include <asm/arch/pinmux.h> |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 10 | #include <asm/arch-tegra/ap.h> |
| 11 | #include <asm/arch-tegra/tegra.h> |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 12 | #include <asm/gpio.h> |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 13 | #include <asm/io.h> |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 14 | #include <dm.h> |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 15 | #include <i2c.h> |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 16 | #include "../common/tdx-common.h" |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 17 | |
| 18 | #include "pinmux-config-apalis_t30.h" |
| 19 | |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 22 | #define PMU_I2C_ADDRESS 0x2D |
| 23 | #define MAX_I2C_RETRY 3 |
| 24 | |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 25 | int arch_misc_init(void) |
| 26 | { |
| 27 | if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) == |
| 28 | NVBOOTTYPE_RECOVERY) |
| 29 | printf("USB recovery mode\n"); |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 34 | int checkboard(void) |
| 35 | { |
| 36 | printf("Model: Toradex Apalis T30 %dGB\n", |
| 37 | (gd->ram_size == 0x40000000) ? 1 : 2); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 42 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 43 | int ft_board_setup(void *blob, bd_t *bd) |
| 44 | { |
| 45 | return ft_common_board_setup(blob, bd); |
| 46 | } |
| 47 | #endif |
| 48 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 49 | /* |
| 50 | * Routine: pinmux_init |
| 51 | * Description: Do individual peripheral pinmux configs |
| 52 | */ |
| 53 | void pinmux_init(void) |
| 54 | { |
| 55 | pinmux_config_pingrp_table(tegra3_pinmux_common, |
| 56 | ARRAY_SIZE(tegra3_pinmux_common)); |
| 57 | |
| 58 | pinmux_config_pingrp_table(unused_pins_lowpower, |
| 59 | ARRAY_SIZE(unused_pins_lowpower)); |
| 60 | |
| 61 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
| 62 | pinmux_config_drvgrp_table(apalis_t30_padctrl, |
| 63 | ARRAY_SIZE(apalis_t30_padctrl)); |
| 64 | } |
| 65 | |
| 66 | #ifdef CONFIG_PCI_TEGRA |
| 67 | int tegra_pcie_board_init(void) |
| 68 | { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 69 | struct udevice *dev; |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 70 | u8 addr, data[1]; |
| 71 | int err; |
| 72 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 73 | err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 74 | if (err) { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 75 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 76 | return err; |
| 77 | } |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 78 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 79 | /* TPS659110: VDD2_OP_REG = 1.05V */ |
| 80 | data[0] = 0x27; |
| 81 | addr = 0x25; |
| 82 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 83 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 84 | if (err) { |
| 85 | debug("failed to set VDD supply\n"); |
| 86 | return err; |
| 87 | } |
| 88 | |
| 89 | /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */ |
| 90 | data[0] = 0x0D; |
| 91 | addr = 0x24; |
| 92 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 93 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 94 | if (err) { |
| 95 | debug("failed to enable VDD supply\n"); |
| 96 | return err; |
| 97 | } |
| 98 | |
| 99 | /* TPS659110: LDO6_REG = 1.1V, ACTIVE */ |
| 100 | data[0] = 0x0D; |
| 101 | addr = 0x35; |
| 102 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 103 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 104 | if (err) { |
| 105 | debug("failed to set AVDD supply\n"); |
| 106 | return err; |
| 107 | } |
| 108 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 109 | return 0; |
| 110 | } |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 111 | #endif /* CONFIG_PCI_TEGRA */ |