aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/host/omap.c47
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
939static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 939static 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
965static 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