From ae03661fda98465420016b410a27e6bf2a3c03f4 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 31 Oct 2011 06:51:35 +0000 Subject: tegra2: Move board_mmc_init into board files For Seaboard, this is mostly a cut/paste of board_mmc_init() and pin_mux_mmc() into seaboard.c; pin_mux_mmc() was modified to add some missing pinmux_tristate_disable calls for the GPIOs. For Harmony, those functions were modified to configure SDMMC2 (index 2) instead of SDMMC3 (index 1), since that's what is present on the board. However, harmony.c is still missing the required GPIO setup, so neither port is likely to function correctly yet. This will be fixed in the next change. v4: Include board.h to prototype tegra2_mmc_init(). Signed-off-by: Stephen Warren Tested-by: Simon Glass Acked-by: Simon Glass Signed-off-by: Tom Warren --- board/nvidia/common/board.c | 52 ------------------------------------- board/nvidia/harmony/harmony.c | 56 ++++++++++++++++++++++++++++++++++++++++ board/nvidia/seaboard/seaboard.c | 53 +++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 52 deletions(-) (limited to 'board/nvidia') diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 370a25906d..0f12de2097 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -33,10 +33,6 @@ #include #include "board.h" -#ifdef CONFIG_TEGRA2_MMC -#include -#endif - DECLARE_GLOBAL_DATA_PTR; const struct tegra2_sysinfo sysinfo = { @@ -100,33 +96,6 @@ static void pin_mux_uart(void) #endif /* CONFIG_TEGRA2_ENABLE_UARTD */ } -#ifdef CONFIG_TEGRA2_MMC -/* - * Routine: pin_mux_mmc - * Description: setup the pin muxes/tristate values for the SDMMC(s) - */ -static void pin_mux_mmc(void) -{ - /* SDMMC4: config 3, x8 on 2nd set of pins */ - pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4); - pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4); - pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4); - - pinmux_tristate_disable(PINGRP_ATB); - pinmux_tristate_disable(PINGRP_GMA); - pinmux_tristate_disable(PINGRP_GME); - - /* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */ - pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3); - pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3); - pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3); - - pinmux_tristate_disable(PINGRP_SDC); - pinmux_tristate_disable(PINGRP_SDD); - pinmux_tristate_disable(PINGRP_SDB); -} -#endif - /* * Routine: board_init * Description: Early hardware init. @@ -142,27 +111,6 @@ int board_init(void) return 0; } -#ifdef CONFIG_TEGRA2_MMC -/* this is a weak define that we are overriding */ -int board_mmc_init(bd_t *bd) -{ - debug("board_mmc_init called\n"); - /* Enable muxes, etc. for SDMMC controllers */ - pin_mux_mmc(); - gpio_config_mmc(); - - debug("board_mmc_init: init eMMC\n"); - /* init dev 0, eMMC chip, with 4-bit bus */ - tegra2_mmc_init(0, 4); - - debug("board_mmc_init: init SD slot\n"); - /* init dev 1, SD slot, with 4-bit bus */ - tegra2_mmc_init(1, 4); - - return 0; -} -#endif - #ifdef CONFIG_BOARD_EARLY_INIT_F int board_early_init_f(void) { diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c index cbb30d6301..f2c3867251 100644 --- a/board/nvidia/harmony/harmony.c +++ b/board/nvidia/harmony/harmony.c @@ -24,9 +24,11 @@ #include #include #include +#include #ifdef CONFIG_TEGRA2_MMC #include #endif +#include "../common/board.h" /* * Routine: gpio_config_uart @@ -37,6 +39,39 @@ void gpio_config_uart(void) } #ifdef CONFIG_TEGRA2_MMC +/* + * Routine: pin_mux_mmc + * Description: setup the pin muxes/tristate values for the SDMMC(s) + */ +static void pin_mux_mmc(void) +{ + /* SDMMC4: config 3, x8 on 2nd set of pins */ + pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4); + pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4); + pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4); + + pinmux_tristate_disable(PINGRP_ATB); + pinmux_tristate_disable(PINGRP_GMA); + pinmux_tristate_disable(PINGRP_GME); + + /* For power GPIO PI6 */ + pinmux_tristate_disable(PINGRP_ATA); + /* For CD GPIO PH2 */ + pinmux_tristate_disable(PINGRP_ATD); + + /* SDMMC2: SDIO2_CLK, SDIO2_CMD, SDIO2_DAT[7:0] */ + pinmux_set_func(PINGRP_DTA, PMUX_FUNC_SDIO2); + pinmux_set_func(PINGRP_DTD, PMUX_FUNC_SDIO2); + + pinmux_tristate_disable(PINGRP_DTA); + pinmux_tristate_disable(PINGRP_DTD); + + /* For power GPIO PT3 */ + pinmux_tristate_disable(PINGRP_DTB); + /* For CD GPIO PI5 */ + pinmux_tristate_disable(PINGRP_ATC); +} + /* * Routine: gpio_config_mmc * Description: Set GPIOs for SD card @@ -46,6 +81,27 @@ void gpio_config_mmc(void) /* Not implemented for now */ } +/* this is a weak define that we are overriding */ +int board_mmc_init(bd_t *bd) +{ + debug("board_mmc_init called\n"); + + /* Enable muxes, etc. for SDMMC controllers */ + pin_mux_mmc(); + gpio_config_mmc(); + + debug("board_mmc_init: init SD slot J26\n"); + /* init dev 0, SD slot J26, with 4-bit bus */ + /* The board has an 8-bit bus, but 8-bit doesn't work yet */ + tegra2_mmc_init(0, 4); + + debug("board_mmc_init: init SD slot J5\n"); + /* init dev 2, SD slot J5, with 4-bit bus */ + tegra2_mmc_init(2, 4); + + return 0; +} + /* this is a weak define that we are overriding */ int board_mmc_getcd(u8 *cd, struct mmc *mmc) { diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c index bc67d0f94c..22a0e69f06 100644 --- a/board/nvidia/seaboard/seaboard.c +++ b/board/nvidia/seaboard/seaboard.c @@ -24,10 +24,12 @@ #include #include #include +#include #include #ifdef CONFIG_TEGRA2_MMC #include #endif +#include "../common/board.h" /* * Routine: gpio_config_uart @@ -55,6 +57,36 @@ void gpio_config_uart(void) } #ifdef CONFIG_TEGRA2_MMC +/* + * Routine: pin_mux_mmc + * Description: setup the pin muxes/tristate values for the SDMMC(s) + */ +static void pin_mux_mmc(void) +{ + /* SDMMC4: config 3, x8 on 2nd set of pins */ + pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4); + pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4); + pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4); + + pinmux_tristate_disable(PINGRP_ATB); + pinmux_tristate_disable(PINGRP_GMA); + pinmux_tristate_disable(PINGRP_GME); + + /* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */ + pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3); + pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3); + pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3); + + pinmux_tristate_disable(PINGRP_SDC); + pinmux_tristate_disable(PINGRP_SDD); + pinmux_tristate_disable(PINGRP_SDB); + + /* For power GPIO PI6 */ + pinmux_tristate_disable(PINGRP_ATA); + /* For CD GPIO PI5 */ + pinmux_tristate_disable(PINGRP_ATC); +} + /* * Routine: gpio_config_mmc * Description: Set GPIOs for SDMMC3 SDIO slot. @@ -68,6 +100,27 @@ void gpio_config_mmc(void) gpio_direction_input(GPIO_PI5); } +/* this is a weak define that we are overriding */ +int board_mmc_init(bd_t *bd) +{ + debug("board_mmc_init called\n"); + + /* Enable muxes, etc. for SDMMC controllers */ + pin_mux_mmc(); + gpio_config_mmc(); + + debug("board_mmc_init: init eMMC\n"); + /* init dev 0, eMMC chip, with 4-bit bus */ + /* The board has an 8-bit bus, but 8-bit doesn't work yet */ + tegra2_mmc_init(0, 4); + + debug("board_mmc_init: init SD slot\n"); + /* init dev 1, SD slot, with 4-bit bus */ + tegra2_mmc_init(1, 4); + + return 0; +} + /* this is a weak define that we are overriding */ int board_mmc_getcd(u8 *cd, struct mmc *mmc) { -- cgit From 9877841f6bba3723f5d21cc58eb99f3417e90725 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 31 Oct 2011 06:51:36 +0000 Subject: tegra2: Modify MMC driver to handle power and cd GPIOs Pass the GPIO numbers for power and card detect to tegra2_mmc_init(), and modify that function to perform all required GPIO initialization. This removes the need for board files to perform these operations. Move board_mmc_getcd() into tegra2_mmc.c now that the driver knows which GPIOs to use. Update affected call-sites in seaboard.c and harmony.c. Note that this change should make all SD ports work on Harmony, since the required GPIO setup is now being performed. v4: Fix prototype of tegra2_mmc_init() in board.h to match driver change. Remove prototype of gpio_config_mmc() from board.h Signed-off-by: Stephen Warren Cc: Andy Fleming Tested-by: Simon Glass Acked-by: Simon Glass Acked-by: Andy Fleming Signed-off-by: Tom Warren --- board/nvidia/common/board.h | 3 +-- board/nvidia/harmony/harmony.c | 27 +++------------------------ board/nvidia/seaboard/seaboard.c | 33 ++------------------------------- 3 files changed, 6 insertions(+), 57 deletions(-) (limited to 'board/nvidia') diff --git a/board/nvidia/common/board.h b/board/nvidia/common/board.h index 344e70283e..35acbca82b 100644 --- a/board/nvidia/common/board.h +++ b/board/nvidia/common/board.h @@ -26,7 +26,6 @@ void tegra2_start(void); void gpio_config_uart(void); -void gpio_config_mmc(void); -int tegra2_mmc_init(int dev_index, int bus_width); +int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio); #endif /* BOARD_H */ diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c index f2c3867251..3cbe820c95 100644 --- a/board/nvidia/harmony/harmony.c +++ b/board/nvidia/harmony/harmony.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef CONFIG_TEGRA2_MMC #include #endif @@ -72,15 +73,6 @@ static void pin_mux_mmc(void) pinmux_tristate_disable(PINGRP_ATC); } -/* - * Routine: gpio_config_mmc - * Description: Set GPIOs for SD card - */ -void gpio_config_mmc(void) -{ - /* Not implemented for now */ -} - /* this is a weak define that we are overriding */ int board_mmc_init(bd_t *bd) { @@ -88,29 +80,16 @@ int board_mmc_init(bd_t *bd) /* Enable muxes, etc. for SDMMC controllers */ pin_mux_mmc(); - gpio_config_mmc(); debug("board_mmc_init: init SD slot J26\n"); /* init dev 0, SD slot J26, with 4-bit bus */ /* The board has an 8-bit bus, but 8-bit doesn't work yet */ - tegra2_mmc_init(0, 4); + tegra2_mmc_init(0, 4, GPIO_PI6, GPIO_PH2); debug("board_mmc_init: init SD slot J5\n"); /* init dev 2, SD slot J5, with 4-bit bus */ - tegra2_mmc_init(2, 4); + tegra2_mmc_init(2, 4, GPIO_PT3, GPIO_PI5); return 0; } - -/* this is a weak define that we are overriding */ -int board_mmc_getcd(u8 *cd, struct mmc *mmc) -{ - debug("board_mmc_getcd called\n"); - /* - * Hard-code CD presence for now. Need to add GPIO inputs - * for Harmony - */ - *cd = 1; - return 0; -} #endif diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c index 22a0e69f06..356d616ab1 100644 --- a/board/nvidia/seaboard/seaboard.c +++ b/board/nvidia/seaboard/seaboard.c @@ -87,19 +87,6 @@ static void pin_mux_mmc(void) pinmux_tristate_disable(PINGRP_ATC); } -/* - * Routine: gpio_config_mmc - * Description: Set GPIOs for SDMMC3 SDIO slot. - */ -void gpio_config_mmc(void) -{ - /* Set EN_VDDIO_SD (GPIO I6) */ - gpio_direction_output(GPIO_PI6, 1); - - /* Config pin as GPI for Card Detect (GPIO I5) */ - gpio_direction_input(GPIO_PI5); -} - /* this is a weak define that we are overriding */ int board_mmc_init(bd_t *bd) { @@ -107,31 +94,15 @@ int board_mmc_init(bd_t *bd) /* Enable muxes, etc. for SDMMC controllers */ pin_mux_mmc(); - gpio_config_mmc(); debug("board_mmc_init: init eMMC\n"); /* init dev 0, eMMC chip, with 4-bit bus */ /* The board has an 8-bit bus, but 8-bit doesn't work yet */ - tegra2_mmc_init(0, 4); + tegra2_mmc_init(0, 4, -1, -1); debug("board_mmc_init: init SD slot\n"); /* init dev 1, SD slot, with 4-bit bus */ - tegra2_mmc_init(1, 4); - - return 0; -} - -/* this is a weak define that we are overriding */ -int board_mmc_getcd(u8 *cd, struct mmc *mmc) -{ - debug("board_mmc_getcd called\n"); - *cd = 1; /* Assume card is inserted, or eMMC */ - - if (IS_SD(mmc)) { - /* Seaboard SDMMC3 = SDIO3_CD = GPIO_PI5 */ - if (gpio_get_value(GPIO_PI5)) - *cd = 0; - } + tegra2_mmc_init(1, 4, GPIO_PI6, GPIO_PI5); return 0; } -- cgit From d5ef19b9b349dc87611357be22e563a99528a422 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 31 Oct 2011 06:51:37 +0000 Subject: tegra2: Add support for Ventana Ventana is a board which is very similar to Seaboard. Support it by re-using board/nvidia/seaboard/seaboard.c with minor run-time conditionals. v5: Makefile: Use cmd_link_o_target, remove unused clean/distclean targets. v6: Make gpio_config_uart_seaboard() static. v7: Add MAINTAINERS entry for Ventana. Tom Warren doesn't have Ventana, so he asked me to add myself for this board. Signed-off-by: Stephen Warren Acked-by: Simon Glass Signed-off-by: Tom Warren --- board/nvidia/seaboard/seaboard.c | 11 +++++++-- board/nvidia/ventana/Makefile | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 board/nvidia/ventana/Makefile (limited to 'board/nvidia') diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c index 356d616ab1..aa77f12ef5 100644 --- a/board/nvidia/seaboard/seaboard.c +++ b/board/nvidia/seaboard/seaboard.c @@ -32,10 +32,10 @@ #include "../common/board.h" /* - * Routine: gpio_config_uart + * Routine: gpio_config_uart_seaboard * Description: Force GPIO_PI3 low on Seaboard so UART4 works. */ -void gpio_config_uart(void) +static void gpio_config_uart_seaboard(void) { int gp = GPIO_PI3; struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE; @@ -56,6 +56,13 @@ void gpio_config_uart(void) writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]); } +void gpio_config_uart(void) +{ + if (machine_is_ventana()) + return; + gpio_config_uart_seaboard(); +} + #ifdef CONFIG_TEGRA2_MMC /* * Routine: pin_mux_mmc diff --git a/board/nvidia/ventana/Makefile b/board/nvidia/ventana/Makefile new file mode 100644 index 0000000000..9e5a87ffe8 --- /dev/null +++ b/board/nvidia/ventana/Makefile @@ -0,0 +1,49 @@ +# +# (C) Copyright 2010,2011 +# NVIDIA Corporation +# +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +ifneq ($(OBJTREE),$(SRCTREE)) +$(shell mkdir -p $(obj)../common) +endif + +LIB = $(obj)lib$(BOARD).o + +COBJS += ../seaboard/seaboard.o +COBJS += ../common/board.o + +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) + +$(LIB): $(obj).depend $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### -- cgit From 5fac236a9703827666df452f093d2849625afd4d Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 6 Oct 2011 12:52:22 +0000 Subject: tegra2: Use new GPIO APIs in gpio_config_uart() ... rather than open-coding the register accesses. However, gpio_request() typically stores the "label" parameter in a global data structure. This causes problems when called from gpio_config_uart(), since the code is running before relocation. To solve this, pass a NULL string to gpio_request(), and modify gpio_request() not to touch the string if it's NULL. Signed-off-by: Stephen Warren Acked-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Tom Warren --- board/nvidia/seaboard/seaboard.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'board/nvidia') diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c index aa77f12ef5..7f2827b8be 100644 --- a/board/nvidia/seaboard/seaboard.c +++ b/board/nvidia/seaboard/seaboard.c @@ -37,23 +37,9 @@ */ static void gpio_config_uart_seaboard(void) { - int gp = GPIO_PI3; - struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE; - struct gpio_ctlr_bank *bank = &gpio->gpio_bank[GPIO_BANK(gp)]; - u32 val; - /* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */ - val = readl(&bank->gpio_config[GPIO_PORT(gp)]); - val |= 1 << GPIO_BIT(gp); - writel(val, &bank->gpio_config[GPIO_PORT(gp)]); - - val = readl(&bank->gpio_out[GPIO_PORT(gp)]); - val &= ~(1 << GPIO_BIT(gp)); - writel(val, &bank->gpio_out[GPIO_PORT(gp)]); - - val = readl(&bank->gpio_dir_out[GPIO_PORT(gp)]); - val |= 1 << GPIO_BIT(gp); - writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]); + gpio_request(GPIO_PI3, NULL); + gpio_direction_output(GPIO_PI3, 0); } void gpio_config_uart(void) -- cgit From e43d6ed932a4fbeb4c53a66bd2b7fc1f802a810e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 5 Nov 2011 03:56:49 +0000 Subject: tegra2: Add arch_cpu_init() to fire up Cortex-A9 We want to move away from a special Tegra2 start-up, and just use arch_cpu_init() instead. However, if we run board_init_f() from boot we need to build it for ARMv4T, since the Tegra's AVP start-up CPU does not support ARMv7. The effect of this is to do the AVP init earlier, and in arch_cpu_init(), rather that board_early_init_f(). Signed-off-by: Simon Glass Signed-off-by: Tom Warren --- board/nvidia/common/board.c | 3 --- board/nvidia/common/board.h | 1 - 2 files changed, 4 deletions(-) (limited to 'board/nvidia') diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 0f12de2097..56850cc8b5 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -125,9 +125,6 @@ int board_early_init_f(void) /* Initialize periph GPIOs */ gpio_config_uart(); - - /* Init UART, scratch regs, and start CPU */ - tegra2_start(); return 0; } #endif /* EARLY_INIT */ diff --git a/board/nvidia/common/board.h b/board/nvidia/common/board.h index 35acbca82b..1f57086602 100644 --- a/board/nvidia/common/board.h +++ b/board/nvidia/common/board.h @@ -24,7 +24,6 @@ #ifndef _BOARD_H_ #define _BOARD_H_ -void tegra2_start(void); void gpio_config_uart(void); int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio); -- cgit From 831a077f11869dfc33ca2316a4bdeba203e8ce60 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 5 Nov 2011 03:56:52 +0000 Subject: tegra2: Enable instruction cache Since low-level init is skipped, the instruction cache is never enabled on Tegra2. This explicitly calls this initialization as soon as the A9 is initialized. Signed-off-by: Simon Glass Signed-off-by: Tom Warren --- board/nvidia/common/board.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'board/nvidia') diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 56850cc8b5..c806a6b3cb 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -114,6 +114,9 @@ int board_init(void) #ifdef CONFIG_BOARD_EARLY_INIT_F int board_early_init_f(void) { + /* We didn't do this init in start.S, so do it now */ + cpu_init_cp15(); + /* Initialize essential common plls */ clock_early_init(); -- cgit