Ejemplo n.º 1
0
int omap2_clk_enable(struct clk *clk)
{
	int ret = 0;

	if (clk->usecount++ == 0) {
#ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once clkdm f/w is in place */
		if (clk->clkdm)
			omap2_clkdm_clk_enable(clk->clkdm, clk);
#endif

		if (clk->parent) {
			ret = omap2_clk_enable(clk->parent);
			if (ret)
				goto err;
		}

		ret = _omap2_clk_enable(clk);
		if (ret) {
			if (clk->parent)
				omap2_clk_disable(clk->parent);

			goto err;
		}
	}
	return ret;

err:
#ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once clkdm f/w is in place */
	if (clk->clkdm)
		omap2_clkdm_clk_disable(clk->clkdm, clk);
#endif
	clk->usecount--;
	return ret;
}
Ejemplo n.º 2
0
int omap2_clk_enable(struct clk *clk)
{
    int ret = 0;

    if (clk->usecount++ == 0) {
        if (clk->clkdm)
            omap2_clkdm_clk_enable(clk->clkdm, clk);

        if (clk->parent) {
            ret = omap2_clk_enable(clk->parent);
            if (ret)
                goto err;
        }

        ret = _omap2_clk_enable(clk);
        if (ret) {
            if (clk->parent)
                omap2_clk_disable(clk->parent);

            goto err;
        }
    }
    return ret;

err:
    if (clk->clkdm)
        omap2_clkdm_clk_disable(clk->clkdm, clk);
    clk->usecount--;
    return ret;
}
Ejemplo n.º 3
0
Archivo: clock.c Proyecto: 274914765/C
int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
{
    void __iomem *src_addr;
    u32 field_val, field_mask, reg_val, parent_div;

    if (unlikely(clk->flags & CONFIG_PARTICIPANT))
        return -EINVAL;

    if (!clk->clksel)
        return -EINVAL;

    field_val = omap2_clksel_get_src_field(&src_addr, new_parent,
                           &field_mask, clk, &parent_div);
    if (src_addr == 0)
        return -EINVAL;

    if (clk->usecount > 0)
        _omap2_clk_disable(clk);

    /* Set new source value (previous dividers if any in effect) */
    reg_val = __raw_readl(src_addr) & ~field_mask;
    reg_val |= (field_val << __ffs(field_mask));
    __raw_writel(reg_val, src_addr);
    wmb();

    if (clk->flags & DELAYED_APP && cpu_is_omap24xx()) {
        __raw_writel(OMAP24XX_VALID_CONFIG, OMAP24XX_PRCM_CLKCFG_CTRL);
        wmb();
    }

    if (clk->usecount > 0)
        _omap2_clk_enable(clk);

    clk->parent = new_parent;

    /* CLKSEL clocks follow their parents' rates, divided by a divisor */
    clk->rate = new_parent->rate;

    if (parent_div > 0)
        clk->rate /= parent_div;

    pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
         clk->name, clk->parent->name, clk->rate);

    if (unlikely(clk->flags & RATE_PROPAGATES))
        propagate_rate(clk);

    return 0;
}
Ejemplo n.º 4
0
Archivo: clock.c Proyecto: 274914765/C
int omap2_clk_enable(struct clk *clk)
{
    int ret = 0;

    if (clk->usecount++ == 0) {
        if (likely((u32)clk->parent))
            ret = omap2_clk_enable(clk->parent);

        if (unlikely(ret != 0)) {
            clk->usecount--;
            return ret;
        }

        ret = _omap2_clk_enable(clk);

        if (unlikely(ret != 0) && clk->parent) {
            omap2_clk_disable(clk->parent);
            clk->usecount--;
        }
    }

    return ret;
}