From patchwork Fri Sep 13 08:02:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 2882061 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 829E8BFF05 for ; Fri, 13 Sep 2013 08:02:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28A6C203F1 for ; Fri, 13 Sep 2013 08:02:56 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA51120383 for ; Fri, 13 Sep 2013 08:02:54 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKOL2-00048m-FH; Fri, 13 Sep 2013 08:02:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKOL0-0004ZZ-8w; Fri, 13 Sep 2013 08:02:46 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKOKw-0004Yr-JE for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2013 08:02:43 +0000 Received: by mail-la0-f53.google.com with SMTP id el20so710589lab.40 for ; Fri, 13 Sep 2013 01:02:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bF9QlwFGORW7yml8gaFbSy056Vr5Su5Tq6i6H28qzVs=; b=F2vgCWv1tQrxmINDdjhpN4tPNf8yf0har7sepyjdTw09bfwmygCqSKfd6IJvHgb1LT dcOf3vlb7NYmYJXuh7ENJR0YaeWfbU1TDWkJOTQ8uIKkEaFChJ0pGkRNIysHoK94OLos sfW67dEN5Puq/dy2qvKGy6HnUyZGqqf1ce9Ts6p3XpSfLgzUlpBYEMDiR1ZErXiAX1fd GpNor+396QUr6m0W+vnDfTu5ptRVXmNDU5wmlsQhRKikcgbrV09c5ImgIXnpdiLXjvk1 T8Rd0PiIBjgyGk7MwUPZB7X8JtPc55gy2ki190MpFsTR7deyv7lL9/DeP/VsBM91yGUm LOYw== X-Gm-Message-State: ALoCoQnouRwfBP2um/BvbLDFlK29WBTDbhXh+G5yOxdlZOpHGZt5u4uj0UfKE0bszR3cXpRxbWnU X-Received: by 10.112.51.101 with SMTP id j5mr10784060lbo.17.1379059338913; Fri, 13 Sep 2013 01:02:18 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id n15sm3646321laa.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 01:02:18 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lennert Buytenhek , Dan Williams , Mikael Pettersson Subject: [PATCH 3/8 v2] ARM: iop32x: read N2100 power key using gpiolib Date: Fri, 13 Sep 2013 10:02:07 +0200 Message-Id: <1379059327-12613-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130913_040242_778315_FEA48EF0 X-CRM114-Status: GOOD ( 11.69 ) X-Spam-Score: -2.6 (--) Cc: Linus Walleij , Alexandre Courbot , linux-arm-kernel@lists.infradead.org, Aaro Koskinen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Refrain from using the custom gpio_line_get() to read the power key on the N2100, use the gpiolib function gpio_get() instead. Also request the line in the GPIOs initicall, and move the poll timer setup to that inicall so the gpio chip is available before we request this GPIO and start to poll it. Cc: Aaro Koskinen Cc: Lennert Buytenhek Cc: Dan Williams Cc: Mikael Pettersson Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Move the setup and poll init into the new GPIO initialization function to avoid probe order problems. --- arch/arm/mach-iop32x/n2100.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c index 2dba955..dc5addf 100644 --- a/arch/arm/mach-iop32x/n2100.c +++ b/arch/arm/mach-iop32x/n2100.c @@ -306,7 +306,7 @@ static struct timer_list power_button_poll_timer; static void power_button_poll(unsigned long dummy) { - if (gpio_line_get(N2100_POWER_BUTTON) == 0) { + if (gpio_get_value(N2100_POWER_BUTTON) == 0) { ctrl_alt_del(); return; } @@ -322,6 +322,19 @@ static int __init n2100_request_gpios(void) ret = gpio_request(N2100_HARDWARE_RESET, "reset"); if (ret) pr_err("could not request reset GPIO\n"); + ret = gpio_request(N2100_POWER_BUTTON, "power"); + if (ret) + pr_err("could not request power GPIO\n"); + else { + ret = gpio_direction_input(N2100_POWER_BUTTON); + if (ret) + pr_err("could not set power GPIO as input\n"); + } + /* Set up power button poll timer */ + init_timer(&power_button_poll_timer); + power_button_poll_timer.function = power_button_poll; + power_button_poll_timer.expires = jiffies + (HZ / 10); + add_timer(&power_button_poll_timer); return 0; } device_initcall(n2100_request_gpios); @@ -338,11 +351,6 @@ static void __init n2100_init_machine(void) ARRAY_SIZE(n2100_i2c_devices)); pm_power_off = n2100_power_off; - - init_timer(&power_button_poll_timer); - power_button_poll_timer.function = power_button_poll; - power_button_poll_timer.expires = jiffies + (HZ / 10); - add_timer(&power_button_poll_timer); } MACHINE_START(N2100, "Thecus N2100")