[U-Boot] [PATCH v2 2/2] Tegra: MMC: Add DT support to MMC driver for all T20 boards

Lucas Stach
2013-02-12T19:41:04Z

Hello Tom,

Am Dienstag, den 12.02.2013, 12:24 -0700 schrieb Tom Warren:
> Lucas,

> >>>
> >> tegra_mmc_init should not be called from every individual board file,
> >> but from the common nvidia tegra board file. Only the pinmux should stay
> >> in the individual board code, same thing as was done to all the other
> >> functions like NAND and USB.
> >
> > True. I was originally just adapting the current config-file driven
> > MMC to DT step-by-step, but you're right - it should be called just
> > once for all boards in the common board file. I'll change it in V3.
>
> I've looked into this some more, and it appears that I can't just add
> a call to tegra_mmc_init() from board_init() in
> boards/nvidia/common/board.c.
>
> board_init() is where the other periphs do their pin_mux and
> xxx_init() calls (USB, SPI, etc.). board_init() is called early in
> board_init_r(), before mmc_initialize() is called. mmc_initialize() is
> needed before tegra_mmc_init() can use the mmc_device struct, etc. So
> tegra_mmc_init() needs to be called after mmc_initialize(), and right
> now that's in each board's board_mmc_init(). In board_mmc_init(),
> each board sets up any power rails needed for SD-card or eMMC access,
> sets up it's pin muxes for MMC, and then calls tegra_mmc_init() to
> parse the DT file and populate the mmc structs.
>
> I could move the pin_mux_mmc() function calls from each board file
> into nvidia/common/board.c's board_init(), but it wouldn't really
> change much. So I'll leave it as it is for now, with pin_mux_mmc() and
> tegra_mmc_init() being called from each board's 'board' file
> (seaboard.c, colibri_t20_iris.c, etc).
>
> Let me know if you see another way to move Tegra MMC init to a common
> board file that doesn't break the MMC driver flow.
>

I didn't look up the flow myself, as I don't have time for that right
now, but I think I've got a pretty good picture from your description.

I think we should really try to make the Tegra MMC init flow as similar
as possible to the other peripherals, so I suggest doing the following:
1. Provide a pin_mux_mmc() (possibly with a weak define as done with
other peripherals). Boards should do pinmux and rail enabling within
this function.
2. Move board_mmc_init() into nvidia/common/board.c, this function
should call into the board specific pinmux function and then call
tegra_mmc_init().

So even while we don't get the complete same flow as for other
peripherals as the board_mmc_init() still has to be a freestanding
function, instead of those things being folded into board_init(), we at
least gain a clear distinction between the board specific parts and
Tegra common code.

Regards,
Lucas