Lines Matching defs:phase
5 * Simple HiSilicon phase clock implementation.
30 static int hisi_phase_regval_to_degrees(struct clk_hisi_phase *phase,
35 for (i = 0; i < phase->phase_num; i++)
36 if (phase->phase_regvals[i] == regval)
37 return phase->phase_degrees[i];
44 struct clk_hisi_phase *phase = to_clk_hisi_phase(hw);
47 regval = readl(phase->reg);
48 regval = (regval & phase->mask) >> phase->shift;
50 return hisi_phase_regval_to_degrees(phase, regval);
53 static int hisi_phase_degrees_to_regval(struct clk_hisi_phase *phase,
58 for (i = 0; i < phase->phase_num; i++)
59 if (phase->phase_degrees[i] == degrees)
60 return phase->phase_regvals[i];
67 struct clk_hisi_phase *phase = to_clk_hisi_phase(hw);
72 regval = hisi_phase_degrees_to_regval(phase, degrees);
76 spin_lock_irqsave(phase->lock, flags);
78 val = readl(phase->reg);
79 val &= ~phase->mask;
80 val |= regval << phase->shift;
81 writel(val, phase->reg);
83 spin_unlock_irqrestore(phase->lock, flags);
97 struct clk_hisi_phase *phase;
100 phase = devm_kzalloc(dev, sizeof(struct clk_hisi_phase), GFP_KERNEL);
101 if (!phase)
110 phase->reg = base + clks->offset;
111 phase->shift = clks->shift;
112 phase->mask = (BIT(clks->width) - 1) << clks->shift;
113 phase->lock = lock;
114 phase->phase_degrees = clks->phase_degrees;
115 phase->phase_regvals = clks->phase_regvals;
116 phase->phase_num = clks->phase_num;
117 phase->hw.init = &init;
119 return devm_clk_register(dev, &phase->hw);