diff mbox

[U-Boot,04/11] tegra20: switch over tamonten platform to use tablebased pinmux

Message ID 1359046100-19385-5-git-send-email-dev@lynxeye.de
State Deferred
Delegated to: Tom Warren
Headers show

Commit Message

Lucas Stach Jan. 24, 2013, 4:48 p.m. UTC
Init pinmux in one shot, in order to avoid any conflicts.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 board/avionic-design/common/tamonten.c | 133 ++++++++++++++++++++++++++++-----
 include/configs/medcom-wide.h          |   3 +
 include/configs/plutux.h               |   3 +
 include/configs/tec.h                  |   3 +
 4 files changed, 125 insertions(+), 17 deletions(-)

Comments

Stephen Warren Jan. 25, 2013, 10:04 p.m. UTC | #1
On 01/24/2013 08:48 AM, Lucas Stach wrote:
> Init pinmux in one shot, in order to avoid any conflicts.

> diff --git a/board/avionic-design/common/tamonten.c b/board/avionic-design/common/tamonten.c

> +static struct pingroup_config tamonten_pinmux[] = {
> +	PINMUX_ENTRY(ATA, IDE, NORMAL, NORMAL), /* GPIO */
> +	PINMUX_ENTRY(ATB, SDIO4, NORMAL, NORMAL), /* MMC */
...

I believe this initializes every single pingroup on the SoC to
something. In order to prevent any behavior changes, wouldn't it be
better to first fill in this table only with entries that achieve the
same pinmux programming that used to be performed by the C code you're
removing? Then, a separate later patch could fill in missing items in
the pinmux table. I think that'd end up being much safer and easier to
validate.
Lucas Stach Jan. 25, 2013, 10:11 p.m. UTC | #2
Am Freitag, den 25.01.2013, 14:04 -0800 schrieb Stephen Warren:
> On 01/24/2013 08:48 AM, Lucas Stach wrote:
> > Init pinmux in one shot, in order to avoid any conflicts.
> 
> > diff --git a/board/avionic-design/common/tamonten.c b/board/avionic-design/common/tamonten.c
> 
> > +static struct pingroup_config tamonten_pinmux[] = {
> > +	PINMUX_ENTRY(ATA, IDE, NORMAL, NORMAL), /* GPIO */
> > +	PINMUX_ENTRY(ATB, SDIO4, NORMAL, NORMAL), /* MMC */
> ...
> 
> I believe this initializes every single pingroup on the SoC to
> something. In order to prevent any behavior changes, wouldn't it be
> better to first fill in this table only with entries that achieve the
> same pinmux programming that used to be performed by the C code you're
> removing? Then, a separate later patch could fill in missing items in
> the pinmux table. I think that'd end up being much safer and easier to
> validate.
> 

As I wrote in the cover letter this initializes the pinmux to the same
values the Linux kernel uses. I don't consider it a safer approach to
pull out the old pinmux from the C Code and then later building a
conflict free full muxtable out of this.

However I made sure to go through the C Code to see which pads need to
be un-tristated. At that time I cross-checked the table with the
functions used by the C Code. But as a human I'm not safe from mistakes.

Regards,
Lucas
diff mbox

Patch

diff --git a/board/avionic-design/common/tamonten.c b/board/avionic-design/common/tamonten.c
index e6a932e..f072407 100644
--- a/board/avionic-design/common/tamonten.c
+++ b/board/avionic-design/common/tamonten.c
@@ -3,6 +3,8 @@ 
  *  NVIDIA Corporation <www.nvidia.com>
  *  (C) Copyright 2011-2012
  *  Avionic Design GmbH <www.avionic-design.de>
+ *  (C) Copyright 2013
+ *  Lucas Stach
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -28,7 +30,6 @@ 
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/funcmux.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/tegra.h>
 #include <asm/arch-tegra/board.h>
@@ -50,28 +51,126 @@  void gpio_early_init(void)
 #endif
 
 #ifdef CONFIG_TEGRA_MMC
-/*
- * Routine: pin_mux_mmc
- * Description: setup the pin muxes/tristate values for the SDMMC(s)
- */
-static void pin_mux_mmc(void)
-{
-	funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT);
-	/* for write-protect GPIO PI6 */
-	pinmux_tristate_disable(PINGRP_ATA);
-	/* for CD GPIO PH2 */
-	pinmux_tristate_disable(PINGRP_ATD);
-}
-
 /* this is a weak define that we are overriding */
 int board_mmc_init(bd_t *bd)
 {
-	/* Enable muxes, etc. for SDMMC controllers */
-	pin_mux_mmc();
-
 	/* init dev 0, SD slot, with 4-bit bus */
 	tegra_mmc_init(0, 4, GPIO_PI6, GPIO_PH2);
 
 	return 0;
 }
 #endif
+
+static struct pingroup_config tamonten_pinmux[] = {
+	PINMUX_ENTRY(ATA, IDE, NORMAL, NORMAL), /* GPIO */
+	PINMUX_ENTRY(ATB, SDIO4, NORMAL, NORMAL), /* MMC */
+	PINMUX_ENTRY(ATC, NAND, NORMAL, TRISTATE),
+	PINMUX_ENTRY(ATD, GMI, NORMAL, NORMAL), /* GPIO */
+	PINMUX_ENTRY(ATE, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(CDEV1, PLLA_OUT, NORMAL, TRISTATE),
+	PINMUX_ENTRY(CDEV2, PLLP_OUT4, NORMAL, TRISTATE),
+	PINMUX_ENTRY(CRTP, CRT, NORMAL, TRISTATE),
+	PINMUX_ENTRY(CSUS, VI_SENSOR_CLK, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DAP1, DAP1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DAP2, DAP2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DAP3, DAP3, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DAP4, DAP4, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DDC, RSVD4, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTA, SDIO2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTB, RSVD1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTC, RSVD1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTD, SDIO2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTE, RSVD1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(DTF, I2C3, NORMAL, TRISTATE),
+	PINMUX_ENTRY(GMA, SDIO4, NORMAL, NORMAL), /* MMC */
+	PINMUX_ENTRY(GMB, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(GMC, UARTD, NORMAL, NORMAL), /* UART D */
+	PINMUX_ENTRY(GMD, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(GME, SDIO4, NORMAL, NORMAL), /* MMC */
+	PINMUX_ENTRY(GPU, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(GPU7, RTCK, NORMAL, NORMAL), /* JTAG RTCK */
+	PINMUX_ENTRY(GPV, PCIE, NORMAL, TRISTATE),
+	PINMUX_ENTRY(HDINT, HDMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(I2CP, I2C, NORMAL, TRISTATE),
+	PINMUX_ENTRY(IRRX, UARTA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(IRTX, UARTA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCA, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCB, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCC, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCD, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCE, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(KBCF, KBC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LCSN, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD2, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD3, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD4, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD5, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD6, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD7, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD8, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD9, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD10, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD11, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD12, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD13, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD14, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD15, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD16, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LD17, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LDC, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LDI, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LHP0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LHP1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LHP2, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LHS, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LM0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LM1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LPP, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LPW0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LPW1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LPW2, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSC0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSC1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSCK, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSDA, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSDI, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LSPI, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LVP0, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LVP1, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(LVS, DISPA, NORMAL, TRISTATE),
+	PINMUX_ENTRY(OWC, RSVD2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(PTA, RSVD4, NORMAL, TRISTATE),
+	PINMUX_ENTRY(RM, I2C, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SDB, PWM, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SDC, PWM, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SDD, PWM, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SDIO1, SDIO1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SLXA, PCIE, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SLXC, SPDIF, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SLXD, SPDIF, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SLXK, PCIE, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPDI, RSVD2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPDO, RSVD2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIA, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIB, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIC, GMI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPID, SPI1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIE, SPI1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIF, SPI1, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIG, SPI2_ALT, NORMAL, TRISTATE),
+	PINMUX_ENTRY(SPIH, SPI2_ALT, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UAA, ULPI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UAB, ULPI, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UAC, RSVD2, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UAD, UARTB, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UCA, UARTC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UCB, UARTC, NORMAL, TRISTATE),
+	PINMUX_ENTRY(UDA, ULPI, NORMAL, TRISTATE),
+};
+
+void pinmux_init(void)
+{
+	pinmux_config_table(tamonten_pinmux, ARRAY_SIZE(tamonten_pinmux));
+}
diff --git a/include/configs/medcom-wide.h b/include/configs/medcom-wide.h
index bae4ba0..a2913ee 100644
--- a/include/configs/medcom-wide.h
+++ b/include/configs/medcom-wide.h
@@ -28,6 +28,9 @@ 
 
 #include "tegra20-common.h"
 
+/* Enable tablebased pinmux */
+#define CONFIG_TEGRA_TABLEBASED_PINMUX
+
 /* Enable fdt support for Medcom-Wide. Flash the image in u-boot-dtb.bin */
 #define CONFIG_DEFAULT_DEVICE_TREE	tegra20-medcom-wide
 #define CONFIG_OF_CONTROL
diff --git a/include/configs/plutux.h b/include/configs/plutux.h
index deee237..5a02c27 100644
--- a/include/configs/plutux.h
+++ b/include/configs/plutux.h
@@ -28,6 +28,9 @@ 
 
 #include "tegra20-common.h"
 
+/* Enable tablebased pinmux */
+#define CONFIG_TEGRA_TABLEBASED_PINMUX
+
 /* Enable fdt support for Plutux. Flash the image in u-boot-dtb.bin */
 #define CONFIG_DEFAULT_DEVICE_TREE	tegra20-plutux
 #define CONFIG_OF_CONTROL
diff --git a/include/configs/tec.h b/include/configs/tec.h
index caeb9cd..74c56d8 100644
--- a/include/configs/tec.h
+++ b/include/configs/tec.h
@@ -28,6 +28,9 @@ 
 
 #include "tegra20-common.h"
 
+/* Enable tablebased pinmux */
+#define CONFIG_TEGRA_TABLEBASED_PINMUX
+
 /* Enable fdt support for TEC. Flash the image in u-boot-dtb.bin */
 #define CONFIG_DEFAULT_DEVICE_TREE	tegra20-tec
 #define CONFIG_OF_CONTROL