blob: c412c077da02f26022d2b4381e3b306b3e5e1bfe [file] [log] [blame]
Tom Warrenf4ef6662011-04-14 12:09:41 +00001/*
2 * (C) Copyright 2010,2011
3 * NVIDIA Corporation <www.nvidia.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <asm/io.h>
Tom Warren150c2492012-09-19 15:50:56 -070026#include <asm/arch/tegra.h>
Simon Glassca280902012-01-11 12:42:28 +000027#include <asm/arch/clock.h>
28#include <asm/arch/funcmux.h>
Stephen Warrena2ab6b72012-10-22 06:19:36 +000029#include <asm/arch/gpio.h>
Stephen Warrenae036612011-10-31 06:51:35 +000030#include <asm/arch/pinmux.h>
Tom Warren150c2492012-09-19 15:50:56 -070031#include <asm/arch-tegra/mmc.h>
Tom Warrenccf79882011-09-21 12:40:07 +000032#include <asm/gpio.h>
Tom Warren3f82d892012-05-22 11:44:48 +000033#ifdef CONFIG_TEGRA_MMC
Tom Warrenccf79882011-09-21 12:40:07 +000034#include <mmc.h>
35#endif
Tom Warrenf4ef6662011-04-14 12:09:41 +000036
Simon Glassa04eba92011-11-05 04:46:51 +000037/* TODO: Remove this code when the SPI switch is working */
Stephen Warrenda1f7352012-10-22 06:19:35 +000038#if !defined(CONFIG_SPI_UART_SWITCH) && (CONFIG_MACH_TYPE != MACH_TYPE_VENTANA)
Lucas Stach0cd10c72012-09-25 20:21:14 +000039void gpio_early_init_uart(void)
Stephen Warrend5ef19b2011-10-31 06:51:37 +000040{
Stephen Warrena2ab6b72012-10-22 06:19:36 +000041 /* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */
42#ifndef CONFIG_SPL_BUILD
43 gpio_request(GPIO_PI3, NULL);
44#endif
45 gpio_direction_output(GPIO_PI3, 0);
Stephen Warrend5ef19b2011-10-31 06:51:37 +000046}
Simon Glassa04eba92011-11-05 04:46:51 +000047#endif
Stephen Warrend5ef19b2011-10-31 06:51:37 +000048
Tom Warren3f82d892012-05-22 11:44:48 +000049#ifdef CONFIG_TEGRA_MMC
Tom Warrenccf79882011-09-21 12:40:07 +000050/*
Stephen Warrenae036612011-10-31 06:51:35 +000051 * Routine: pin_mux_mmc
52 * Description: setup the pin muxes/tristate values for the SDMMC(s)
53 */
54static void pin_mux_mmc(void)
55{
Simon Glassca280902012-01-11 12:42:28 +000056 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT);
57 funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_4BIT);
Stephen Warrenae036612011-10-31 06:51:35 +000058
59 /* For power GPIO PI6 */
60 pinmux_tristate_disable(PINGRP_ATA);
61 /* For CD GPIO PI5 */
62 pinmux_tristate_disable(PINGRP_ATC);
63}
64
Tom Warrenccf79882011-09-21 12:40:07 +000065/* this is a weak define that we are overriding */
Stephen Warrenae036612011-10-31 06:51:35 +000066int board_mmc_init(bd_t *bd)
67{
68 debug("board_mmc_init called\n");
69
70 /* Enable muxes, etc. for SDMMC controllers */
71 pin_mux_mmc();
Stephen Warrenae036612011-10-31 06:51:35 +000072
73 debug("board_mmc_init: init eMMC\n");
74 /* init dev 0, eMMC chip, with 4-bit bus */
75 /* The board has an 8-bit bus, but 8-bit doesn't work yet */
Tom Warren29f3e3f2012-09-04 17:00:24 -070076 tegra_mmc_init(0, 4, -1, -1);
Stephen Warrenae036612011-10-31 06:51:35 +000077
78 debug("board_mmc_init: init SD slot\n");
79 /* init dev 1, SD slot, with 4-bit bus */
Tom Warren29f3e3f2012-09-04 17:00:24 -070080 tegra_mmc_init(1, 4, GPIO_PI6, GPIO_PI5);
Tom Warrenccf79882011-09-21 12:40:07 +000081
82 return 0;
83}
84#endif
Simon Glassf10393e2012-02-27 10:52:50 +000085
86void pin_mux_usb(void)
87{
88 /* For USB's GPIO PD0. For now, since we have no pinmux in fdt */
89 pinmux_tristate_disable(PINGRP_SLXK);
90}