diff options
author | Tony Lindgren <tony@atomide.com> | 2010-12-22 21:42:35 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-12-22 21:42:35 -0500 |
commit | 8419fdbaf2118a0a169441be82f09f7be93a5ca1 (patch) | |
tree | 0a534e9f31f6b88f9cd90ceb3222359a2903e275 /arch/arm/mach-omap2/mux.c | |
parent | 05fad3e72e98e57274b8930a08f8b476048f5022 (diff) |
omap2+: Add omap_mux_get_by_name
Do this by splitting _omap_mux_init_signal as it already has most
of the necessary features.
Based on an earlier patch by Dan Murphy <dmurphy@ti.com>.
Cc: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mux.c')
-rw-r--r-- | arch/arm/mach-omap2/mux.c | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c index 3d71d93caab2..0fa3d74125bc 100644 --- a/arch/arm/mach-omap2/mux.c +++ b/arch/arm/mach-omap2/mux.c | |||
@@ -151,12 +151,14 @@ int __init omap_mux_init_gpio(int gpio, int val) | |||
151 | return -ENODEV; | 151 | return -ENODEV; |
152 | } | 152 | } |
153 | 153 | ||
154 | static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, | 154 | static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition, |
155 | const char *muxname, int val) | 155 | const char *muxname, |
156 | struct omap_mux **found_mux) | ||
156 | { | 157 | { |
158 | struct omap_mux *mux = NULL; | ||
157 | struct omap_mux_entry *e; | 159 | struct omap_mux_entry *e; |
158 | const char *mode_name; | 160 | const char *mode_name; |
159 | int found = 0, mode0_len = 0; | 161 | int found = 0, found_mode, mode0_len = 0; |
160 | struct list_head *muxmodes = &partition->muxmodes; | 162 | struct list_head *muxmodes = &partition->muxmodes; |
161 | 163 | ||
162 | mode_name = strchr(muxname, '.'); | 164 | mode_name = strchr(muxname, '.'); |
@@ -168,40 +170,34 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, | |||
168 | } | 170 | } |
169 | 171 | ||
170 | list_for_each_entry(e, muxmodes, node) { | 172 | list_for_each_entry(e, muxmodes, node) { |
171 | struct omap_mux *m = &e->mux; | 173 | char *m0_entry; |
172 | char *m0_entry = m->muxnames[0]; | ||
173 | int i; | 174 | int i; |
174 | 175 | ||
176 | mux = &e->mux; | ||
177 | m0_entry = mux->muxnames[0]; | ||
178 | |||
175 | /* First check for full name in mode0.muxmode format */ | 179 | /* First check for full name in mode0.muxmode format */ |
176 | if (mode0_len && strncmp(muxname, m0_entry, mode0_len)) | 180 | if (mode0_len && strncmp(muxname, m0_entry, mode0_len)) |
177 | continue; | 181 | continue; |
178 | 182 | ||
179 | /* Then check for muxmode only */ | 183 | /* Then check for muxmode only */ |
180 | for (i = 0; i < OMAP_MUX_NR_MODES; i++) { | 184 | for (i = 0; i < OMAP_MUX_NR_MODES; i++) { |
181 | char *mode_cur = m->muxnames[i]; | 185 | char *mode_cur = mux->muxnames[i]; |
182 | 186 | ||
183 | if (!mode_cur) | 187 | if (!mode_cur) |
184 | continue; | 188 | continue; |
185 | 189 | ||
186 | if (!strcmp(mode_name, mode_cur)) { | 190 | if (!strcmp(mode_name, mode_cur)) { |
187 | u16 old_mode; | 191 | *found_mux = mux; |
188 | u16 mux_mode; | ||
189 | |||
190 | old_mode = omap_mux_read(partition, | ||
191 | m->reg_offset); | ||
192 | mux_mode = val | i; | ||
193 | pr_debug("%s: Setting signal " | ||
194 | "%s.%s 0x%04x -> 0x%04x\n", __func__, | ||
195 | m0_entry, muxname, old_mode, mux_mode); | ||
196 | omap_mux_write(partition, mux_mode, | ||
197 | m->reg_offset); | ||
198 | found++; | 192 | found++; |
193 | found_mode = i; | ||
199 | } | 194 | } |
200 | } | 195 | } |
201 | } | 196 | } |
202 | 197 | ||
203 | if (found == 1) | 198 | if (found == 1) { |
204 | return 0; | 199 | return found_mode; |
200 | } | ||
205 | 201 | ||
206 | if (found > 1) { | 202 | if (found > 1) { |
207 | pr_err("%s: Multiple signal paths (%i) for %s\n", __func__, | 203 | pr_err("%s: Multiple signal paths (%i) for %s\n", __func__, |
@@ -209,24 +205,51 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, | |||
209 | return -EINVAL; | 205 | return -EINVAL; |
210 | } | 206 | } |
211 | 207 | ||
212 | pr_err("%s: Could not set signal %s\n", __func__, muxname); | 208 | pr_err("%s: Could not find signal %s\n", __func__, muxname); |
213 | 209 | ||
214 | return -ENODEV; | 210 | return -ENODEV; |
215 | } | 211 | } |
216 | 212 | ||
217 | int __init omap_mux_init_signal(const char *muxname, int val) | 213 | static int __init |
214 | omap_mux_get_by_name(const char *muxname, | ||
215 | struct omap_mux_partition **found_partition, | ||
216 | struct omap_mux **found_mux) | ||
218 | { | 217 | { |
219 | struct omap_mux_partition *partition; | 218 | struct omap_mux_partition *partition; |
220 | int ret; | ||
221 | 219 | ||
222 | list_for_each_entry(partition, &mux_partitions, node) { | 220 | list_for_each_entry(partition, &mux_partitions, node) { |
223 | ret = _omap_mux_init_signal(partition, muxname, val); | 221 | struct omap_mux *mux = NULL; |
224 | if (!ret) | 222 | int mux_mode = _omap_mux_get_by_name(partition, muxname, &mux); |
225 | return ret; | 223 | if (mux_mode < 0) |
224 | continue; | ||
225 | |||
226 | *found_partition = partition; | ||
227 | *found_mux = mux; | ||
228 | |||
229 | return mux_mode; | ||
226 | } | 230 | } |
227 | 231 | ||
228 | return -ENODEV; | 232 | return -ENODEV; |
233 | } | ||
229 | 234 | ||
235 | int __init omap_mux_init_signal(const char *muxname, int val) | ||
236 | { | ||
237 | struct omap_mux_partition *partition = NULL; | ||
238 | struct omap_mux *mux = NULL; | ||
239 | u16 old_mode; | ||
240 | int mux_mode; | ||
241 | |||
242 | mux_mode = omap_mux_get_by_name(muxname, &partition, &mux); | ||
243 | if (mux_mode < 0) | ||
244 | return mux_mode; | ||
245 | |||
246 | old_mode = omap_mux_read(partition, mux->reg_offset); | ||
247 | mux_mode |= val; | ||
248 | pr_debug("%s: Setting signal %s 0x%04x -> 0x%04x\n", | ||
249 | __func__, muxname, old_mode, mux_mode); | ||
250 | omap_mux_write(partition, mux_mode, mux->reg_offset); | ||
251 | |||
252 | return 0; | ||
230 | } | 253 | } |
231 | 254 | ||
232 | #ifdef CONFIG_DEBUG_FS | 255 | #ifdef CONFIG_DEBUG_FS |