From patchwork Fri Dec 3 00:45:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 376331 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB30jTGQ006411 for ; Fri, 3 Dec 2010 00:45:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758297Ab0LCAp2 (ORCPT ); Thu, 2 Dec 2010 19:45:28 -0500 Received: from mho-02-ewr.mailhop.org ([204.13.248.72]:33813 "EHLO mho-02-ewr.mailhop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758281Ab0LCAp1 (ORCPT ); Thu, 2 Dec 2010 19:45:27 -0500 Received: from c-24-130-172-179.hsd1.ca.comcast.net ([24.130.172.179] helo=baageli.muru.com) by mho-02-ewr.mailhop.org with esmtpa (Exim 4.68) (envelope-from ) id 1POJmB-0006ex-1t; Fri, 03 Dec 2010 00:45:27 +0000 X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 24.130.172.179 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/mailhop/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19WGz3Xc9yLEulm05sbCGSE Subject: [PATCH 1/6] omap2+: Add omap_mux_get_by_name To: linux-arm-kernel@lists.infradead.org From: Tony Lindgren Cc: linux-omap@vger.kernel.org, Dan Murphy Date: Thu, 02 Dec 2010 16:45:18 -0800 Message-ID: <20101203004518.31687.99560.stgit@baageli.muru.com> In-Reply-To: <20101203004040.31687.9476.stgit@baageli.muru.com> References: <20101203004040.31687.9476.stgit@baageli.muru.com> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Dec 2010 00:45:29 +0000 (UTC) diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c index 3d71d93..0fa3d74 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) return -ENODEV; } -static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, - const char *muxname, int val) +static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition, + const char *muxname, + struct omap_mux **found_mux) { + struct omap_mux *mux = NULL; struct omap_mux_entry *e; const char *mode_name; - int found = 0, mode0_len = 0; + int found = 0, found_mode, mode0_len = 0; struct list_head *muxmodes = &partition->muxmodes; mode_name = strchr(muxname, '.'); @@ -168,40 +170,34 @@ static int __init _omap_mux_init_signal(struct omap_mux_partition *partition, } list_for_each_entry(e, muxmodes, node) { - struct omap_mux *m = &e->mux; - char *m0_entry = m->muxnames[0]; + char *m0_entry; int i; + mux = &e->mux; + m0_entry = mux->muxnames[0]; + /* First check for full name in mode0.muxmode format */ if (mode0_len && strncmp(muxname, m0_entry, mode0_len)) continue; /* Then check for muxmode only */ for (i = 0; i < OMAP_MUX_NR_MODES; i++) { - char *mode_cur = m->muxnames[i]; + char *mode_cur = mux->muxnames[i]; if (!mode_cur) continue; if (!strcmp(mode_name, mode_cur)) { - u16 old_mode; - 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_mux = mux; found++; + found_mode = i; } } } - if (found == 1) - return 0; + if (found == 1) { + return found_mode; + } if (found > 1) { 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, 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; } -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; - int ret; list_for_each_entry(partition, &mux_partitions, node) { - ret = _omap_mux_init_signal(partition, muxname, val); - if (!ret) - return ret; + struct omap_mux *mux = NULL; + int mux_mode = _omap_mux_get_by_name(partition, muxname, &mux); + if (mux_mode < 0) + continue; + + *found_partition = partition; + *found_mux = mux; + + return mux_mode; } 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