Lines Matching +full:clock +full:- +full:div
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include "sdhci-pltfm.h"
23 static void sdhci_cns3xxx_set_clock(struct sdhci_host *host, unsigned int clock) in sdhci_cns3xxx_set_clock() argument
25 struct device *dev = mmc_dev(host->mmc); in sdhci_cns3xxx_set_clock()
26 int div = 1; in sdhci_cns3xxx_set_clock() local
30 host->mmc->actual_clock = 0; in sdhci_cns3xxx_set_clock()
34 if (clock == 0) in sdhci_cns3xxx_set_clock()
37 while (host->max_clk / div > clock) { in sdhci_cns3xxx_set_clock()
42 if (div < 4) in sdhci_cns3xxx_set_clock()
43 div += 1; in sdhci_cns3xxx_set_clock()
44 else if (div < 256) in sdhci_cns3xxx_set_clock()
45 div *= 2; in sdhci_cns3xxx_set_clock()
50 dev_dbg(dev, "desired SD clock: %d, actual: %d\n", in sdhci_cns3xxx_set_clock()
51 clock, host->max_clk / div); in sdhci_cns3xxx_set_clock()
54 if (div != 3) in sdhci_cns3xxx_set_clock()
55 div >>= 1; in sdhci_cns3xxx_set_clock()
57 clk = div << SDHCI_DIVIDER_SHIFT; in sdhci_cns3xxx_set_clock()
65 dev_warn(dev, "clock is unstable"); in sdhci_cns3xxx_set_clock()
68 timeout--; in sdhci_cns3xxx_set_clock()
100 .name = "sdhci-cns3xxx",