diff options
author | Tony Lindgren <tony@atomide.com> | 2007-05-01 10:36:00 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-05-01 10:36:00 -0400 |
commit | d3af5abe9a809becbe4b413144b607844560d445 (patch) | |
tree | 12c22ab6a438fa9eb7c51b06adcb67583ff1186b /drivers/mmc/host/omap.c | |
parent | 46a6730e3ff9add5089ddd007f998b97fb4e8571 (diff) |
mmc-omap: Clean up omap set_ios and make MMC_POWER_ON work
Move divisor calculation into a separate function and re-arrange the
init order to make MMC_POWER_ON work.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/host/omap.c')
-rw-r--r-- | drivers/mmc/host/omap.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index fc044a5ed64e..1914e65d4db1 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -936,33 +936,41 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on) | |||
936 | } | 936 | } |
937 | } | 937 | } |
938 | 938 | ||
939 | static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 939 | static int mmc_omap_calc_divisor(struct mmc_host *mmc, struct mmc_ios *ios) |
940 | { | 940 | { |
941 | struct mmc_omap_host *host = mmc_priv(mmc); | 941 | struct mmc_omap_host *host = mmc_priv(mmc); |
942 | int func_clk_rate = clk_get_rate(host->fclk); | ||
942 | int dsor; | 943 | int dsor; |
943 | int realclock, i; | ||
944 | |||
945 | realclock = ios->clock; | ||
946 | 944 | ||
947 | if (ios->clock == 0) | 945 | if (ios->clock == 0) |
948 | dsor = 0; | 946 | return 0; |
949 | else { | ||
950 | int func_clk_rate = clk_get_rate(host->fclk); | ||
951 | |||
952 | dsor = func_clk_rate / realclock; | ||
953 | if (dsor < 1) | ||
954 | dsor = 1; | ||
955 | 947 | ||
956 | if (func_clk_rate / dsor > realclock) | 948 | dsor = func_clk_rate / ios->clock; |
957 | dsor++; | 949 | if (dsor < 1) |
950 | dsor = 1; | ||
958 | 951 | ||
959 | if (dsor > 250) | 952 | if (func_clk_rate / dsor > ios->clock) |
960 | dsor = 250; | ||
961 | dsor++; | 953 | dsor++; |
962 | 954 | ||
963 | if (ios->bus_width == MMC_BUS_WIDTH_4) | 955 | if (dsor > 250) |
964 | dsor |= 1 << 15; | 956 | dsor = 250; |
965 | } | 957 | dsor++; |
958 | |||
959 | if (ios->bus_width == MMC_BUS_WIDTH_4) | ||
960 | dsor |= 1 << 15; | ||
961 | |||
962 | return dsor; | ||
963 | } | ||
964 | |||
965 | static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | ||
966 | { | ||
967 | struct mmc_omap_host *host = mmc_priv(mmc); | ||
968 | int dsor; | ||
969 | int i; | ||
970 | |||
971 | dsor = mmc_omap_calc_divisor(mmc, ios); | ||
972 | host->bus_mode = ios->bus_mode; | ||
973 | host->hw_bus_mode = host->bus_mode; | ||
966 | 974 | ||
967 | switch (ios->power_mode) { | 975 | switch (ios->power_mode) { |
968 | case MMC_POWER_OFF: | 976 | case MMC_POWER_OFF: |
@@ -977,9 +985,6 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
977 | break; | 985 | break; |
978 | } | 986 | } |
979 | 987 | ||
980 | host->bus_mode = ios->bus_mode; | ||
981 | host->hw_bus_mode = host->bus_mode; | ||
982 | |||
983 | clk_enable(host->fclk); | 988 | clk_enable(host->fclk); |
984 | 989 | ||
985 | /* On insanely high arm_per frequencies something sometimes | 990 | /* On insanely high arm_per frequencies something sometimes |