int pll_vote_clk_enable(struct clk *c) { u32 ena, count; unsigned long flags; struct pll_vote_clk *pllv = to_pll_vote_clk(c); spin_lock_irqsave(&pll_reg_lock, flags); ena = readl_relaxed(PLL_EN_REG(pllv)); ena |= pllv->en_mask; writel_relaxed(ena, PLL_EN_REG(pllv)); spin_unlock_irqrestore(&pll_reg_lock, flags); /* * Use a memory barrier since some PLL status registers are * not within the same 1K segment as the voting registers. */ mb(); /* Wait for pll to enable. */ for (count = ENABLE_WAIT_MAX_LOOPS; count > 0; count--) { if (readl_relaxed(PLL_STATUS_REG(pllv)) & pllv->status_mask) return 0; udelay(1); } WARN("PLL %s didn't enable after voting for it!\n", c->dbg_name); return -ETIMEDOUT; }
int pll_vote_clk_enable(struct clk *c) { u32 ena, count; unsigned long flags; struct pll_vote_clk *pllv = to_pll_vote_clk(c); spin_lock_irqsave(&pll_reg_lock, flags); ena = readl_relaxed(PLL_EN_REG(pllv)); ena |= pllv->en_mask; writel_relaxed(ena, PLL_EN_REG(pllv)); spin_unlock_irqrestore(&pll_reg_lock, flags); mb(); for (count = ENABLE_WAIT_MAX_LOOPS; count > 0; count--) { if (readl_relaxed(PLL_STATUS_REG(pllv)) & pllv->status_mask) return 0; udelay(1); } WARN("PLL %s didn't enable after voting for it!\n", c->dbg_name); return -ETIMEDOUT; }
void pll_vote_clk_disable(struct clk *c) { u32 ena; unsigned long flags; struct pll_vote_clk *pllv = to_pll_vote_clk(c); spin_lock_irqsave(&pll_reg_lock, flags); ena = readl_relaxed(PLL_EN_REG(pllv)); ena &= ~(pllv->en_mask); writel_relaxed(ena, PLL_EN_REG(pllv)); spin_unlock_irqrestore(&pll_reg_lock, flags); }
static enum handoff pll_vote_clk_handoff(struct clk *c) { struct pll_vote_clk *pllv = to_pll_vote_clk(c); if (readl_relaxed(PLL_EN_REG(pllv)) & pllv->en_mask) return HANDOFF_ENABLED_CLK; return HANDOFF_DISABLED_CLK; }
static void __iomem *pll_vote_clk_list_registers(struct clk *c, int n, struct clk_register_data **regs, u32 *size) { struct pll_vote_clk *pllv = to_pll_vote_clk(c); static struct clk_register_data data1[] = { {"APPS_VOTE", 0x0}, }; if (n) return ERR_PTR(-EINVAL); *regs = data1; *size = ARRAY_SIZE(data1); return PLL_EN_REG(pllv); }