From patchwork Wed Nov 17 18:06:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 333831 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 oAHI7voA004760 for ; Wed, 17 Nov 2010 18:07:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935227Ab0KQSHy (ORCPT ); Wed, 17 Nov 2010 13:07:54 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:55460 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934809Ab0KQSHy (ORCPT ); Wed, 17 Nov 2010 13:07:54 -0500 Received: from dlep33.itg.ti.com ([157.170.170.112]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id oAHI7pFN028171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 17 Nov 2010 12:07:51 -0600 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id oAHI7nrd005377; Wed, 17 Nov 2010 12:07:49 -0600 (CST) Received: from dan-ubuntu (dan-ubuntu.am.dhcp.ti.com [128.247.79.183]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id oAHI7nf20006; Wed, 17 Nov 2010 12:07:49 -0600 (CST) Received: by dan-ubuntu (Postfix, from userid 1000) id A7CD034129C; Wed, 17 Nov 2010 12:06:52 -0600 (CST) From: Dan Murphy To: linux-omap@vger.kernel.org Cc: b-cousson@ti.com, paul@pwsan.com, tony@atomide.com, khilman@deeprootsystems.com, Dan Murphy Subject: [PATCH] OMAP MUX framework changes Date: Wed, 17 Nov 2010 12:06:50 -0600 Message-Id: <1290017211-2217-1-git-send-email-dmurphy@ti.com> X-Mailer: git-send-email 1.7.0.4 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]); Wed, 17 Nov 2010 18:07:58 +0000 (UTC) diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c index 3d71d93..e53d6a3 100644 --- a/arch/arm/mach-omap2/mux.c +++ b/arch/arm/mach-omap2/mux.c @@ -61,7 +61,7 @@ struct omap_mux_partition *omap_mux_get(const char *name) return NULL; } -u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg) +static u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg) { if (partition->flags & OMAP_MUX_REG_8BIT) return __raw_readb(partition->base + reg); @@ -69,7 +69,7 @@ u16 omap_mux_read(struct omap_mux_partition *partition, u16 reg) return __raw_readw(partition->base + reg); } -void omap_mux_write(struct omap_mux_partition *partition, u16 val, +static void omap_mux_write(struct omap_mux_partition *partition, u16 val, u16 reg) { if (partition->flags & OMAP_MUX_REG_8BIT) @@ -81,10 +81,14 @@ void omap_mux_write(struct omap_mux_partition *partition, u16 val, void omap_mux_write_array(struct omap_mux_partition *partition, struct omap_board_mux *board_mux) { - while (board_mux->reg_offset != OMAP_MUX_TERMINATOR) { - omap_mux_write(partition, board_mux->value, - board_mux->reg_offset); - board_mux++; + if (partition) { + while (board_mux->reg_offset != OMAP_MUX_TERMINATOR) { + omap_mux_write(partition, board_mux->value, + board_mux->reg_offset); + board_mux++; + } + } else { + pr_err("%s: Partition was NULL\n", __func__); } } @@ -745,6 +749,63 @@ void omap_mux_set_gpio(u16 val, int gpio) pr_err("%s: Could not set gpio%i\n", __func__, gpio); } +static struct omap_mux *omap_mux_get_by_mux(struct omap_mux_partition *partition, + char *name) +{ + struct omap_mux_entry *e; + int i = 0; + + list_for_each_entry(e, &partition->muxmodes, node) { + struct omap_mux *m = &e->mux; + for (i = 0; i < OMAP_MUX_NR_MODES; i++) { + if (m->muxnames[i] == NULL) + break; + else if (!strcmp(name, m->muxnames[i])) + return m; + } + } + + return NULL; +} + +/* Needed for dynamic muxing of pins for off-idle */ +u16 omap_mux_get_mux(char *mux_name) +{ + struct omap_mux_partition *partition; + struct omap_mux *m; + + list_for_each_entry(partition, &mux_partitions, node) { + m = omap_mux_get_by_mux(partition, mux_name); + if (m) + return omap_mux_read(partition, m->reg_offset); + } + + if (!m || m->reg_offset == OMAP_MUX_TERMINATOR) + pr_err("%s: Could not get mux %s\n", + __func__, mux_name); + + return OMAP_MUX_TERMINATOR; +} + +/* Needed for dynamic muxing pins for off-idle */ +void omap_mux_set_mux(u16 val, char *mux_name) +{ + struct omap_mux_partition *partition; + struct omap_mux *m = NULL; + + list_for_each_entry(partition, &mux_partitions, node) { + m = omap_mux_get_by_mux(partition, mux_name); + if (m) { + omap_mux_write(partition, val, m->reg_offset); + return; + } + } + + if (!m || m->reg_offset == OMAP_MUX_TERMINATOR) + pr_err("%s: Could not set mux %s\n", + __func__, mux_name); +} + static struct omap_mux * __init omap_mux_list_add( struct omap_mux_partition *partition, struct omap_mux *src) diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h index 79076d6..27ce55a 100644 --- a/arch/arm/mach-omap2/mux.h +++ b/arch/arm/mach-omap2/mux.h @@ -190,29 +190,26 @@ u16 omap_mux_get_gpio(int gpio); void omap_mux_set_gpio(u16 val, int gpio); /** - * omap_mux_get() - get a mux partition by name - * @name: Name of the mux partition + * omap_mux_get_mux() - set mux register value based on mux name + * @mux_name: Mux name * */ -struct omap_mux_partition *omap_mux_get(const char *name); +u16 omap_mux_get_mux(char *mux_name); /** - * omap_mux_read() - read mux register - * @partition: Mux partition - * @mux_offset: Offset of the mux register + * omap_mux_set_mux() - set mux register value based on mux name + * @val: New mux register value + * @mux_name: Mux name * */ -u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset); +void omap_mux_set_mux(u16 val, char *mux_name); /** - * omap_mux_write() - write mux register - * @partition: Mux partition - * @val: New mux register value - * @mux_offset: Offset of the mux register + * omap_mux_get() - get a mux partition by name + * @name: Name of the mux partition * - * This should be only needed for dynamic remuxing of non-gpio signals. */ -void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset); +struct omap_mux_partition *omap_mux_get(const char *name); /** * omap_mux_write_array() - write an array of mux registers