From patchwork Tue Mar 10 09:26:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 10834 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2A9Ro2Q032002 for ; Tue, 10 Mar 2009 09:27:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753411AbZCJJ1t (ORCPT ); Tue, 10 Mar 2009 05:27:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753181AbZCJJ1s (ORCPT ); Tue, 10 Mar 2009 05:27:48 -0400 Received: from smtp.nokia.com ([192.100.105.134]:37532 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753411AbZCJJ1s (ORCPT ); Tue, 10 Mar 2009 05:27:48 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n2A9R4O2010659 for ; Tue, 10 Mar 2009 04:27:44 -0500 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 10 Mar 2009 11:27:04 +0200 Received: from mgw-int01.ntc.nokia.com ([172.21.143.96]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 10 Mar 2009 11:27:03 +0200 Received: from localhost.localdomain (esdhcp043100.research.nokia.com [172.21.43.100]) by mgw-int01.ntc.nokia.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id n2A9R2NP030769; Tue, 10 Mar 2009 11:27:02 +0200 From: Jani Nikula To: linux-omap@vger.kernel.org Cc: ext-jani.1.nikula@nokia.com Subject: [PATCH] ARM: OMAP: Fix GPIO switch initial output state handling Date: Tue, 10 Mar 2009 11:26:21 +0200 Message-Id: <1236677181-16601-1-git-send-email-ext-jani.1.nikula@nokia.com> X-Mailer: git-send-email 1.6.0.4 X-OriginalArrivalTime: 10 Mar 2009 09:27:03.0763 (UTC) FILETIME=[5F7C7A30:01C9A162] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The switchover to cross-platform GPIO interface unexpectedly caused all output GPIO switches to be set to high state by default, unlike the original OMAP code. Introduce a new GPIO switch flag to define the initial state. Unless the flag is set, the default is now low state. Also store the state of output switches directly into the switch struct instead of trying to read an output GPIO. Signed-off-by: Jani Nikula --- arch/arm/plat-omap/gpio-switch.c | 13 +++++++++---- arch/arm/plat-omap/include/mach/gpio-switch.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm/plat-omap/gpio-switch.c b/arch/arm/plat-omap/gpio-switch.c index 2b5665d..b278024 100644 --- a/arch/arm/plat-omap/gpio-switch.c +++ b/arch/arm/plat-omap/gpio-switch.c @@ -286,12 +286,17 @@ static int __init new_switch(struct gpio_switch *sw) /* input: 1, output: 0 */ direction = !(sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT); - if (direction) + if (direction) { gpio_direction_input(sw->gpio); - else - gpio_direction_output(sw->gpio, true); + sw->state = gpio_sw_get_state(sw); + } else { + int state = sw->state = + !!(sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT_INIT_HIGH); - sw->state = gpio_sw_get_state(sw); + if (sw->flags & OMAP_GPIO_SWITCH_FLAG_INVERTED) + state = !state; + gpio_direction_output(sw->gpio, state); + } r = 0; r |= device_create_file(&sw->pdev.dev, &dev_attr_state); diff --git a/arch/arm/plat-omap/include/mach/gpio-switch.h b/arch/arm/plat-omap/include/mach/gpio-switch.h index a143253..107d23f 100644 --- a/arch/arm/plat-omap/include/mach/gpio-switch.h +++ b/arch/arm/plat-omap/include/mach/gpio-switch.h @@ -29,6 +29,7 @@ #define OMAP_GPIO_SWITCH_TYPE_ACTIVITY 0x0002 #define OMAP_GPIO_SWITCH_FLAG_INVERTED 0x0001 #define OMAP_GPIO_SWITCH_FLAG_OUTPUT 0x0002 +#define OMAP_GPIO_SWITCH_FLAG_OUTPUT_INIT_HIGH 0x0004 struct omap_gpio_switch { const char *name;