提交 8419fdba 编写于 作者: T Tony Lindgren

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: NTony Lindgren <tony@atomide.com>
上级 05fad3e7
...@@ -151,12 +151,14 @@ int __init omap_mux_init_gpio(int gpio, int val) ...@@ -151,12 +151,14 @@ int __init omap_mux_init_gpio(int gpio, int val)
return -ENODEV; return -ENODEV;
} }
static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition,
const char *muxname, int val) const char *muxname,
struct omap_mux **found_mux)
{ {
struct omap_mux *mux = NULL;
struct omap_mux_entry *e; struct omap_mux_entry *e;
const char *mode_name; const char *mode_name;
int found = 0, mode0_len = 0; int found = 0, found_mode, mode0_len = 0;
struct list_head *muxmodes = &partition->muxmodes; struct list_head *muxmodes = &partition->muxmodes;
mode_name = strchr(muxname, '.'); mode_name = strchr(muxname, '.');
...@@ -168,40 +170,34 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, ...@@ -168,40 +170,34 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition,
} }
list_for_each_entry(e, muxmodes, node) { list_for_each_entry(e, muxmodes, node) {
struct omap_mux *m = &e->mux; char *m0_entry;
char *m0_entry = m->muxnames[0];
int i; int i;
mux = &e->mux;
m0_entry = mux->muxnames[0];
/* First check for full name in mode0.muxmode format */ /* First check for full name in mode0.muxmode format */
if (mode0_len && strncmp(muxname, m0_entry, mode0_len)) if (mode0_len && strncmp(muxname, m0_entry, mode0_len))
continue; continue;
/* Then check for muxmode only */ /* Then check for muxmode only */
for (i = 0; i < OMAP_MUX_NR_MODES; i++) { for (i = 0; i < OMAP_MUX_NR_MODES; i++) {
char *mode_cur = m->muxnames[i]; char *mode_cur = mux->muxnames[i];
if (!mode_cur) if (!mode_cur)
continue; continue;
if (!strcmp(mode_name, mode_cur)) { if (!strcmp(mode_name, mode_cur)) {
u16 old_mode; *found_mux = mux;
u16 mux_mode;
old_mode = omap_mux_read(partition,
m->reg_offset);
mux_mode = val | i;
pr_debug("%s: Setting signal "
"%s.%s 0x%04x -> 0x%04x\n", __func__,
m0_entry, muxname, old_mode, mux_mode);
omap_mux_write(partition, mux_mode,
m->reg_offset);
found++; found++;
found_mode = i;
} }
} }
} }
if (found == 1) if (found == 1) {
return 0; return found_mode;
}
if (found > 1) { if (found > 1) {
pr_err("%s: Multiple signal paths (%i) for %s\n", __func__, 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,24 +205,51 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition,
return -EINVAL; return -EINVAL;
} }
pr_err("%s: Could not set signal %s\n", __func__, muxname); pr_err("%s: Could not find signal %s\n", __func__, muxname);
return -ENODEV; return -ENODEV;
} }
int __init omap_mux_init_signal(const char *muxname, int val) static int __init
omap_mux_get_by_name(const char *muxname,
struct omap_mux_partition **found_partition,
struct omap_mux **found_mux)
{ {
struct omap_mux_partition *partition; struct omap_mux_partition *partition;
int ret;
list_for_each_entry(partition, &mux_partitions, node) { list_for_each_entry(partition, &mux_partitions, node) {
ret = _omap_mux_init_signal(partition, muxname, val); struct omap_mux *mux = NULL;
if (!ret) int mux_mode = _omap_mux_get_by_name(partition, muxname, &mux);
return ret; if (mux_mode < 0)
continue;
*found_partition = partition;
*found_mux = mux;
return mux_mode;
} }
return -ENODEV; return -ENODEV;
}
int __init omap_mux_init_signal(const char *muxname, int val)
{
struct omap_mux_partition *partition = NULL;
struct omap_mux *mux = NULL;
u16 old_mode;
int mux_mode;
mux_mode = omap_mux_get_by_name(muxname, &partition, &mux);
if (mux_mode < 0)
return mux_mode;
old_mode = omap_mux_read(partition, mux->reg_offset);
mux_mode |= val;
pr_debug("%s: Setting signal %s 0x%04x -> 0x%04x\n",
__func__, muxname, old_mode, mux_mode);
omap_mux_write(partition, mux_mode, mux->reg_offset);
return 0;
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册