Patchwork [U-Boot,2/2] tegra: nand: add board pinmux

login
register
mail settings
Submitter Lucas Stach
Date Sept. 27, 2012, 9:52 p.m.
Message ID <1348782724-19151-2-git-send-email-dev@lynxeye.de>
Download mbox | patch
Permalink /patch/187484/
State Accepted
Delegated to: Tom Warren
Headers show

Comments

Lucas Stach - Sept. 27, 2012, 9:52 p.m.
Boards may require a different pinmux setup for NAND than the default one.
Add a way to call into board specific code to set this up.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/include/asm/arch-tegra/board.h |  1 +
 drivers/mtd/nand/tegra_nand.c           | 11 ++++++++++-
 2 Dateien geändert, 11 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
Stephen Warren - Sept. 27, 2012, 10:38 p.m.
On 09/27/2012 03:52 PM, Lucas Stach wrote:
> Boards may require a different pinmux setup for NAND than the default one.
> Add a way to call into board specific code to set this up.

> diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c

>  void board_nand_init(void)
>  {
>  	struct nand_chip *nand = &nand_chip[0];
>  
> +	pin_mux_nand();

pin_mux_spi() and pin_mux_usb() are both called from
board/nvidia/common/board.c right before the relevant drivers are
initialized. I think we should centralize the NAND pinmux initialization
there too if possible. That way, when we read the whole pinmux from DT
in the future, there's only one place to go and clean up.

Admittedly, pin_mux_mmc() ends up being called from board_init_mmc()
which is a little unfortunate:-(
Simon Glass - Sept. 27, 2012, 11:08 p.m.
Hi,

On Thu, Sep 27, 2012 at 3:38 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 09/27/2012 03:52 PM, Lucas Stach wrote:
>> Boards may require a different pinmux setup for NAND than the default one.
>> Add a way to call into board specific code to set this up.
>
>> diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c
>
>>  void board_nand_init(void)
>>  {
>>       struct nand_chip *nand = &nand_chip[0];
>>
>> +     pin_mux_nand();
>
> pin_mux_spi() and pin_mux_usb() are both called from
> board/nvidia/common/board.c right before the relevant drivers are
> initialized. I think we should centralize the NAND pinmux initialization
> there too if possible. That way, when we read the whole pinmux from DT
> in the future, there's only one place to go and clean up.
>
> Admittedly, pin_mux_mmc() ends up being called from board_init_mmc()
> which is a little unfortunate:-(

I suspect much of this will become tidier before long with the device
model. It would be nice one day if the Tegra driver could select the
pinmux automatically based on fdt settings.

One problem with putting everything in board files is that there is no
default pinmux. I suppose that doesn't matter, it is only a single
line of code. But someone will need to do a patch to update existing
boards that use NAND.

As I said I'm not convinced that boards will ever be in charge of
pinmux when we move it to fdt. At most the board file will probably
just call a pinmux function to set things up. But perhaps it is just
as likely that we will want the drivers to make that call when they
need the pinmux set up?

Anyway I am fine with the change you propose here, as it doesn't seem
like a weak function makes a lot of sense.

Regards,
Simon

> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Patch

diff --git a/arch/arm/include/asm/arch-tegra/board.h b/arch/arm/include/asm/arch-tegra/board.h
index 7e56df7..be6bf25 100644
--- a/arch/arm/include/asm/arch-tegra/board.h
+++ b/arch/arm/include/asm/arch-tegra/board.h
@@ -43,5 +43,6 @@  void gpio_early_init(void);  /* overrideable GPIO config        */
 
 void pin_mux_usb(void);      /* overrideable USB pinmux setup   */
 void pin_mux_spi(void);      /* overrideable SPI pinmux setup   */
+void pin_mux_nand(void);     /* overrideable NAND pinmux setup  */
 
 #endif
diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c
index 2c1b533..baaea4f 100644
--- a/drivers/mtd/nand/tegra_nand.c
+++ b/drivers/mtd/nand/tegra_nand.c
@@ -28,6 +28,7 @@ 
 #include <nand.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
+#include <asm/arch-tegra/board.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <asm/errno.h>
 #include <asm/gpio.h>
@@ -992,7 +993,6 @@  int tegra_nand_init(struct nand_chip *nand, int devnum)
 	/* Adjust timing for NAND device */
 	setup_timing(config->timing, info->reg);
 
-	funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
 	fdtdec_setup_gpio(&config->wp_gpio);
 	gpio_direction_output(config->wp_gpio.gpio, 1);
 
@@ -1016,10 +1016,19 @@  int tegra_nand_init(struct nand_chip *nand, int devnum)
 	return 0;
 }
 
+void __pin_mux_nand(void)
+{
+	funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
+}
+
+void pin_mux_nand(void) __attribute__((weak, alias("__pin_mux_nand")));
+
 void board_nand_init(void)
 {
 	struct nand_chip *nand = &nand_chip[0];
 
+	pin_mux_nand();
+
 	if (tegra_nand_init(nand, 0))
 		puts("Tegra NAND init failed\n");
 }