Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 |
| 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> |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 17 | |
| 18 | #include "pinmux-config-apalis_t30.h" |
| 19 | |
| 20 | #define PMU_I2C_ADDRESS 0x2D |
| 21 | #define MAX_I2C_RETRY 3 |
| 22 | |
Marcel Ziswiler | dd899d0 | 2015-08-06 00:47:00 +0200 | [diff] [blame] | 23 | int arch_misc_init(void) |
| 24 | { |
| 25 | if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) == |
| 26 | NVBOOTTYPE_RECOVERY) |
| 27 | printf("USB recovery mode\n"); |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 32 | /* |
| 33 | * Routine: pinmux_init |
| 34 | * Description: Do individual peripheral pinmux configs |
| 35 | */ |
| 36 | void pinmux_init(void) |
| 37 | { |
| 38 | pinmux_config_pingrp_table(tegra3_pinmux_common, |
| 39 | ARRAY_SIZE(tegra3_pinmux_common)); |
| 40 | |
| 41 | pinmux_config_pingrp_table(unused_pins_lowpower, |
| 42 | ARRAY_SIZE(unused_pins_lowpower)); |
| 43 | |
| 44 | /* Initialize any non-default pad configs (APB_MISC_GP regs) */ |
| 45 | pinmux_config_drvgrp_table(apalis_t30_padctrl, |
| 46 | ARRAY_SIZE(apalis_t30_padctrl)); |
| 47 | } |
| 48 | |
| 49 | #ifdef CONFIG_PCI_TEGRA |
| 50 | int tegra_pcie_board_init(void) |
| 51 | { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 52 | struct udevice *dev; |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 53 | u8 addr, data[1]; |
| 54 | int err; |
| 55 | |
Simon Glass | a2723ae | 2015-01-25 08:26:55 -0700 | [diff] [blame] | 56 | err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 57 | if (err) { |
Simon Glass | 667aee9 | 2014-12-10 08:55:57 -0700 | [diff] [blame] | 58 | debug("%s: Cannot find PMIC I2C chip\n", __func__); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 59 | return err; |
| 60 | } |
Marcel Ziswiler | 764d412 | 2015-08-06 00:47:10 +0200 | [diff] [blame] | 61 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 62 | /* TPS659110: VDD2_OP_REG = 1.05V */ |
| 63 | data[0] = 0x27; |
| 64 | addr = 0x25; |
| 65 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 66 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 67 | if (err) { |
| 68 | debug("failed to set VDD supply\n"); |
| 69 | return err; |
| 70 | } |
| 71 | |
| 72 | /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */ |
| 73 | data[0] = 0x0D; |
| 74 | addr = 0x24; |
| 75 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 76 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 77 | if (err) { |
| 78 | debug("failed to enable VDD supply\n"); |
| 79 | return err; |
| 80 | } |
| 81 | |
| 82 | /* TPS659110: LDO6_REG = 1.1V, ACTIVE */ |
| 83 | data[0] = 0x0D; |
| 84 | addr = 0x35; |
| 85 | |
Simon Glass | 7d72276 | 2015-01-12 18:02:07 -0700 | [diff] [blame] | 86 | err = dm_i2c_write(dev, addr, data, 1); |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 87 | if (err) { |
| 88 | debug("failed to set AVDD supply\n"); |
| 89 | return err; |
| 90 | } |
| 91 | |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 92 | return 0; |
| 93 | } |
Marcel Ziswiler | 11e2a53 | 2014-09-05 10:18:38 +0200 | [diff] [blame] | 94 | #endif /* CONFIG_PCI_TEGRA */ |