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