forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/clk/ti/mux.c
....@@ -91,10 +91,39 @@
9191 return 0;
9292 }
9393
94
+/**
95
+ * clk_mux_save_context - Save the parent selcted in the mux
96
+ * @hw: pointer struct clk_hw
97
+ *
98
+ * Save the parent mux value.
99
+ */
100
+static int clk_mux_save_context(struct clk_hw *hw)
101
+{
102
+ struct clk_omap_mux *mux = to_clk_omap_mux(hw);
103
+
104
+ mux->saved_parent = ti_clk_mux_get_parent(hw);
105
+ return 0;
106
+}
107
+
108
+/**
109
+ * clk_mux_restore_context - Restore the parent in the mux
110
+ * @hw: pointer struct clk_hw
111
+ *
112
+ * Restore the saved parent mux value.
113
+ */
114
+static void clk_mux_restore_context(struct clk_hw *hw)
115
+{
116
+ struct clk_omap_mux *mux = to_clk_omap_mux(hw);
117
+
118
+ ti_clk_mux_set_parent(hw, mux->saved_parent);
119
+}
120
+
94121 const struct clk_ops ti_clk_mux_ops = {
95122 .get_parent = ti_clk_mux_get_parent,
96123 .set_parent = ti_clk_mux_set_parent,
97124 .determine_rate = __clk_mux_determine_rate,
125
+ .save_context = clk_mux_save_context,
126
+ .restore_context = clk_mux_restore_context,
98127 };
99128
100129 static struct clk *_register_mux(struct device *dev, const char *name,
....@@ -105,7 +134,7 @@
105134 {
106135 struct clk_omap_mux *mux;
107136 struct clk *clk;
108
- struct clk_init_data init = {};
137
+ struct clk_init_data init;
109138
110139 /* allocate the mux */
111140 mux = kzalloc(sizeof(*mux), GFP_KERNEL);
....@@ -114,7 +143,7 @@
114143
115144 init.name = name;
116145 init.ops = &ti_clk_mux_ops;
117
- init.flags = flags | CLK_IS_BASIC;
146
+ init.flags = flags;
118147 init.parent_names = parent_names;
119148 init.num_parents = num_parents;
120149
....@@ -133,37 +162,6 @@
133162 kfree(mux);
134163
135164 return clk;
136
-}
137
-
138
-struct clk *ti_clk_register_mux(struct ti_clk *setup)
139
-{
140
- struct ti_clk_mux *mux;
141
- u32 flags;
142
- u8 mux_flags = 0;
143
- struct clk_omap_reg reg;
144
- u32 mask;
145
-
146
- mux = setup->data;
147
- flags = CLK_SET_RATE_NO_REPARENT;
148
-
149
- mask = mux->num_parents;
150
- if (!(mux->flags & CLKF_INDEX_STARTS_AT_ONE))
151
- mask--;
152
-
153
- mask = (1 << fls(mask)) - 1;
154
- reg.index = mux->module;
155
- reg.offset = mux->reg;
156
- reg.ptr = NULL;
157
-
158
- if (mux->flags & CLKF_INDEX_STARTS_AT_ONE)
159
- mux_flags |= CLK_MUX_INDEX_ONE;
160
-
161
- if (mux->flags & CLKF_SET_RATE_PARENT)
162
- flags |= CLK_SET_RATE_PARENT;
163
-
164
- return _register_mux(NULL, setup->name, mux->parents, mux->num_parents,
165
- flags, &reg, mux->bit_shift, mask, -EINVAL,
166
- mux_flags, NULL);
167165 }
168166
169167 /**
....@@ -186,7 +184,7 @@
186184
187185 num_parents = of_clk_get_parent_count(node);
188186 if (num_parents < 2) {
189
- pr_err("mux-clock %s must have parents\n", node->name);
187
+ pr_err("mux-clock %pOFn must have parents\n", node);
190188 return;
191189 }
192190 parent_names = kzalloc((sizeof(char *) * num_parents), GFP_KERNEL);
....@@ -278,7 +276,7 @@
278276 num_parents = of_clk_get_parent_count(node);
279277
280278 if (num_parents < 2) {
281
- pr_err("%s must have parents\n", node->name);
279
+ pr_err("%pOFn must have parents\n", node);
282280 goto cleanup;
283281 }
284282