]> git.baikalelectronics.ru Git - uboot.git/commit
mmc: tmio: Reorder TMIO clock handling
authorMarek Vasut <marek.vasut+renesas@gmail.com>
Thu, 15 Nov 2018 21:01:33 +0000 (22:01 +0100)
committerMarek Vasut <marex@denx.de>
Mon, 3 Dec 2018 11:51:16 +0000 (12:51 +0100)
commit8a9cd90b5b38a1d94cd598eee9c608d00ff01d22
treeceaf8eb2340f219a590f801145e5fe743ef01420
parentbac6481cdb9bf8d852d248846cf50157c7fe75a5
mmc: tmio: Reorder TMIO clock handling

Reorder the tmio_sd_set_clk_rate() function such that it handles all
of the clock requiests correctly. Specifically, before this patch,
clock request with (mmc->clock == 0 && mmc->clk_disable) could leave
the clock enabled, as the function would exit on if (!mmc->clock)
condition on top and will not handle the mmc->clk_disable at all.

Rather than band-aid fixing just that particular problem, reorder
the entire function to make it easier to understand and verify that
all the cases are covered. The function has three sections now:

First, if mmc->clock != 0, we calculate divider for the SD block.
Second, if mmc->clock != 0 and SD block clock are enabled and
           current divider is not equal to the new divider, then
           stop the clock and update the divider.
Third, if mmc->clk_disable is set, disable the clock, otherwise
       enable the clock. This happens independently of divider
       update now.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/mmc/tmio-common.c