Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ti: add support for clock latching to mux clocks

Latching the clock settings is needed with certain clocks, where
the setting is "cached" in HW before doing the actual re-programming
of the clock source. This patch adds support for clock latching to
the mux clock.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

+11 -3
+1
drivers/clk/ti/clock.h
··· 34 34 u32 *table; 35 35 u32 mask; 36 36 u8 shift; 37 + s8 latch; 37 38 u8 flags; 38 39 }; 39 40
+10 -3
drivers/clk/ti/mux.c
··· 86 86 } 87 87 val |= index << mux->shift; 88 88 ti_clk_ll_ops->clk_writel(val, &mux->reg); 89 + ti_clk_latch(&mux->reg, mux->latch); 89 90 90 91 return 0; 91 92 } ··· 101 100 const char * const *parent_names, 102 101 u8 num_parents, unsigned long flags, 103 102 struct clk_omap_reg *reg, u8 shift, u32 mask, 104 - u8 clk_mux_flags, u32 *table) 103 + s8 latch, u8 clk_mux_flags, u32 *table) 105 104 { 106 105 struct clk_omap_mux *mux; 107 106 struct clk *clk; ··· 122 121 memcpy(&mux->reg, reg, sizeof(*reg)); 123 122 mux->shift = shift; 124 123 mux->mask = mask; 124 + mux->latch = latch; 125 125 mux->flags = clk_mux_flags; 126 126 mux->table = table; 127 127 mux->hw.init = &init; ··· 162 160 flags |= CLK_SET_RATE_PARENT; 163 161 164 162 return _register_mux(NULL, setup->name, mux->parents, mux->num_parents, 165 - flags, &reg, mux->bit_shift, mask, 163 + flags, &reg, mux->bit_shift, mask, -EINVAL, 166 164 mux_flags, NULL); 167 165 } 168 166 ··· 181 179 u8 clk_mux_flags = 0; 182 180 u32 mask = 0; 183 181 u32 shift = 0; 182 + s32 latch = -EINVAL; 184 183 u32 flags = CLK_SET_RATE_NO_REPARENT; 185 184 186 185 num_parents = of_clk_get_parent_count(node); ··· 200 197 201 198 of_property_read_u32(node, "ti,bit-shift", &shift); 202 199 200 + of_property_read_u32(node, "ti,latch-bit", &latch); 201 + 203 202 if (of_property_read_bool(node, "ti,index-starts-at-one")) 204 203 clk_mux_flags |= CLK_MUX_INDEX_ONE; 205 204 ··· 216 211 mask = (1 << fls(mask)) - 1; 217 212 218 213 clk = _register_mux(NULL, node->name, parent_names, num_parents, 219 - flags, &reg, shift, mask, clk_mux_flags, NULL); 214 + flags, &reg, shift, mask, latch, clk_mux_flags, 215 + NULL); 220 216 221 217 if (!IS_ERR(clk)) 222 218 of_clk_add_provider(node, of_clk_src_simple_get, clk); ··· 240 234 return ERR_PTR(-ENOMEM); 241 235 242 236 mux->shift = setup->bit_shift; 237 + mux->latch = -EINVAL; 243 238 244 239 mux->reg.index = setup->module; 245 240 mux->reg.offset = setup->reg;