blob: 01b55be763da4167c2986f88b30e6d69279cb549 [file] [log] [blame]
Lucas Stach85990a92012-10-07 11:36:06 +00001/*
2 * Copyright (C) 2012 Lucas Stach
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Lucas Stach85990a92012-10-07 11:36:06 +00005 */
6
7#include <common.h>
Lucas Stach85990a92012-10-07 11:36:06 +00008#include <asm/arch/clock.h>
9#include <asm/arch/funcmux.h>
10#include <asm/arch/pinmux.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020011#include <asm/arch-tegra/ap.h>
Lucas Stach85990a92012-10-07 11:36:06 +000012#include <asm/arch-tegra/board.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020013#include <asm/arch-tegra/tegra.h>
Marcel Ziswileraf722622015-03-26 01:31:53 +010014#include <asm/gpio.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020015#include <asm/io.h>
Marcel Ziswilerf0c3fb72015-08-06 00:47:04 +020016#include <i2c.h>
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010017#include <nand.h>
18
19DECLARE_GLOBAL_DATA_PTR;
Marcel Ziswilerf0c3fb72015-08-06 00:47:04 +020020
21#define PMU_I2C_ADDRESS 0x34
22#define MAX_I2C_RETRY 3
23#define PMU_SUPPLYENE 0x14
24#define PMU_SUPPLYENE_SYSINEN (1<<5)
25#define PMU_SUPPLYENE_EXITSLREQ (1<<1)
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020026
27int arch_misc_init(void)
28{
Marcel Ziswilerf0c3fb72015-08-06 00:47:04 +020029 /* Disable PMIC sleep mode on low supply voltage */
30 struct udevice *dev;
31 u8 addr, data[1];
32 int err;
33
34 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
35 if (err) {
36 debug("%s: Cannot find PMIC I2C chip\n", __func__);
37 return err;
38 }
39
40 addr = PMU_SUPPLYENE;
41
42 err = dm_i2c_read(dev, addr, data, 1);
43 if (err) {
44 debug("failed to get PMU_SUPPLYENE\n");
45 return err;
46 }
47
48 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
49 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
50
51 err = dm_i2c_write(dev, addr, data, 1);
52 if (err) {
53 debug("failed to set PMU_SUPPLYENE\n");
54 return err;
55 }
56
Marcel Ziswiler653bc792015-08-06 00:47:11 +020057 /* make sure SODIMM pin 87 nRESET_OUT is released properly */
58 pinmux_set_func(PMUX_PINGRP_ATA, PMUX_FUNC_GMI);
59
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020060 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
61 NVBOOTTYPE_RECOVERY)
62 printf("USB recovery mode\n");
63
64 return 0;
65}
Lucas Stach85990a92012-10-07 11:36:06 +000066
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010067int checkboard(void)
68{
69 printf("Model: Toradex Colibri T20 %dMB V%s\n",
70 (gd->ram_size == 0x10000000) ? 256 : 512,
71 (nand_info[0]->erasesize >> 10 == 512) ?
72 ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
73
74 return 0;
75}
76
Lucas Stach85990a92012-10-07 11:36:06 +000077#ifdef CONFIG_TEGRA_MMC
Tom Warren9745cf82013-02-21 12:31:30 +000078/*
79 * Routine: pin_mux_mmc
80 * Description: setup the pin muxes/tristate values for the SDMMC(s)
81 */
82void pin_mux_mmc(void)
Lucas Stach85990a92012-10-07 11:36:06 +000083{
84 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
Stephen Warrenf27f4e82014-03-21 12:28:58 -060085 pinmux_tristate_disable(PMUX_PINGRP_GMB);
Lucas Stach85990a92012-10-07 11:36:06 +000086}
87#endif
Marcel Ziswileraf722622015-03-26 01:31:53 +010088
89#ifdef CONFIG_TEGRA_NAND
90void pin_mux_nand(void)
91{
92 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
Marcel Ziswilerbdddbab2015-03-27 01:31:45 +010093
94 /*
95 * configure pingroup ATC to something unrelated to
96 * avoid ATC overriding KBC
97 */
98 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
Marcel Ziswileraf722622015-03-26 01:31:53 +010099}
100#endif
101
102#ifdef CONFIG_USB_EHCI_TEGRA
103void pin_mux_usb(void)
104{
105 /* module internal USB bus to connect ethernet chipset */
106 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
107
108 /* ULPI reference clock output */
109 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
110 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
111
112 /* PHY reset GPIO */
113 pinmux_tristate_disable(PMUX_PINGRP_UAC);
114
115 /* VBus GPIO */
116 pinmux_tristate_disable(PMUX_PINGRP_DTE);
117
Marcel Ziswilerc33dd262015-03-26 02:17:07 +0100118 /* Reset ASIX using LAN_RESET */
Stephen Warren7f20bb22016-05-12 12:07:39 -0600119 gpio_request(TEGRA_GPIO(V, 4), "LAN_RESET");
120 gpio_direction_output(TEGRA_GPIO(V, 4), 0);
Marcel Ziswilerc33dd262015-03-26 02:17:07 +0100121 pinmux_tristate_disable(PMUX_PINGRP_GPV);
122 udelay(5);
Stephen Warren7f20bb22016-05-12 12:07:39 -0600123 gpio_set_value(TEGRA_GPIO(V, 4), 1);
Marcel Ziswilerc33dd262015-03-26 02:17:07 +0100124
125 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
Marcel Ziswileraf722622015-03-26 01:31:53 +0100126 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
127}
128#endif
Marcel Ziswilercbd2b512015-08-06 00:47:02 +0200129
Simon Glass89c03462016-01-30 16:37:51 -0700130#ifdef CONFIG_VIDEO_TEGRA20
Marcel Ziswilercbd2b512015-08-06 00:47:02 +0200131/*
132 * Routine: pin_mux_display
133 * Description: setup the pin muxes/tristate values for the LCD interface)
134 */
135void pin_mux_display(void)
136{
137 /*
138 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
139 * device-tree
140 */
141 pinmux_tristate_disable(PMUX_PINGRP_DTA);
142
143 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
144 pinmux_tristate_disable(PMUX_PINGRP_SDC);
145}
146#endif