···442442 select ARCH_REQUIRE_GPIOLIB443443 select CLKDEV_LOOKUP444444 select CLKSRC_MMIO445445+ select HAVE_CLK_PREPARE445446 help446447 Support for Freescale MXS-based family of processors447448
···7474 return 0;7575}76767777-/* This function increments the reference count on the clock and enables the7878- * clock if not already enabled. The parent clock tree is recursively enabled7777+/*7878+ * The clk_enable/clk_disable could be called by drivers in atomic context,7979+ * so they should not really hold mutex. Instead, clk_prepare/clk_unprepare8080+ * can hold a mutex, as the pair will only be called in non-atomic context.8181+ * Before migrating to common clk framework, we can have __clk_enable and8282+ * __clk_disable called in clk_prepare/clk_unprepare with mutex held and8383+ * leave clk_enable/clk_disable as the dummy functions.7984 */8080-int clk_enable(struct clk *clk)8585+int clk_prepare(struct clk *clk)8186{8287 int ret = 0;8388···95909691 return ret;9792}9898-EXPORT_SYMBOL(clk_enable);9393+EXPORT_SYMBOL(clk_prepare);9994100100-/* This function decrements the reference count on the clock and disables101101- * the clock when reference count is 0. The parent clock tree is102102- * recursively disabled103103- */104104-void clk_disable(struct clk *clk)9595+void clk_unprepare(struct clk *clk)10596{10697 if (clk == NULL || IS_ERR(clk))10798 return;···105104 mutex_lock(&clocks_mutex);106105 __clk_disable(clk);107106 mutex_unlock(&clocks_mutex);107107+}108108+EXPORT_SYMBOL(clk_unprepare);109109+110110+int clk_enable(struct clk *clk)111111+{112112+ return 0;113113+}114114+EXPORT_SYMBOL(clk_enable);115115+116116+void clk_disable(struct clk *clk)117117+{118118+ /* nothing to do */108119}109120EXPORT_SYMBOL(clk_disable);110121···179166 return ret;180167181168 if (clk->usecount)182182- clk_enable(parent);169169+ clk_prepare_enable(parent);183170184171 mutex_lock(&clocks_mutex);185172 ret = clk->set_parent(clk, parent);
+1-1
arch/arm/mach-mxs/mach-mx28evk.c
···228228 /* Enable fec phy clock */229229 clk = clk_get_sys("pll2", NULL);230230 if (!IS_ERR(clk))231231- clk_enable(clk);231231+ clk_prepare_enable(clk);232232233233 /* Power up fec phy */234234 ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
···245245246246void __init mxs_timer_init(struct clk *timer_clk, int irq)247247{248248- clk_enable(timer_clk);248248+ clk_prepare_enable(timer_clk);249249250250 /*251251 * Initialize timers to a known state
···328328329329 dev_dbg(&host->pdev->dev, "%s\n", __func__);330330331331- clk_enable(host->clk);331331+ clk_prepare_enable(host->clk);332332 clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);333333334334 /* if it was disabled, re-enable the mode again */···368368369369 writel(VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4 + REG_CLR);370370371371- clk_disable(host->clk);371371+ clk_disable_unprepare(host->clk);372372373373 host->enabled = 0;374374}···668668 line_count = fb_info->fix.smem_len / fb_info->fix.line_length;669669 fb_info->fix.ypanstep = 1;670670671671- clk_enable(host->clk);671671+ clk_prepare_enable(host->clk);672672 host->enabled = 1;673673674674 return 0;···841841842842error_register:843843 if (host->enabled)844844- clk_disable(host->clk);844844+ clk_disable_unprepare(host->clk);845845 fb_destroy_modelist(&fb_info->modelist);846846error_init_fb:847847 kfree(fb_info->pseudo_palette);
+22
include/linux/clk.h
···107107}108108#endif109109110110+/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */111111+static inline int clk_prepare_enable(struct clk *clk)112112+{113113+ int ret;114114+115115+ ret = clk_prepare(clk);116116+ if (ret)117117+ return ret;118118+ ret = clk_enable(clk);119119+ if (ret)120120+ clk_unprepare(clk);121121+122122+ return ret;123123+}124124+125125+/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */126126+static inline void clk_disable_unprepare(struct clk *clk)127127+{128128+ clk_disable(clk);129129+ clk_unprepare(clk);130130+}131131+110132/**111133 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.112134 * This is only valid once the clock source has been enabled.
+2-2
sound/soc/mxs/mxs-saif.c
···210210 return -EBUSY;211211 }212212213213- clk_disable(saif->clk);213213+ clk_disable_unprepare(saif->clk);214214215215 /* disable MCLK output */216216 __raw_writel(BM_SAIF_CTRL_CLKGATE,···264264 if (ret)265265 return ret;266266267267- ret = clk_enable(saif->clk);267267+ ret = clk_prepare_enable(saif->clk);268268 if (ret)269269 return ret;270270