From patchwork Sun May 13 12:44:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 8576 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A41F223EAB for ; Sun, 13 May 2012 12:44:32 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 69EE3A187DD for ; Sun, 13 May 2012 12:44:32 +0000 (UTC) Received: by mail-ob0-f180.google.com with SMTP id un3so3901196obb.11 for ; Sun, 13 May 2012 05:44:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=i11Ll+NfsFPXqDaGKQVJ0vLd/uQMx+7PmPpTtxwUGfQ=; b=DMIuP17sMOOiYx7BS+Ua0ekeVYSa178D+U1MzFbPqSimSO7hLcXcbnl5P0Idl2ZHvl uqfFYotAP0HmfK+Zg+u8ku/NLrlB8RBtPZ33Kr7H+ZLESF5gSSBTbktdCy0YxSFgaLF5 /QdHXpj6p5b+XT6AA3FyO6/P53Uq63nVVDWHEUfQkSJSW10rR9Hu2/HzrfOBTQO30zPB nEQF3caXMGuQ3AHrSfOxi4/MV4/+gPHjr5I5i3qm3BJQgd6PTUyhQNEFYrlMwXnId3WZ N1dRqkkPQdhj0rAeXrG2aqSBJKmYPYmicZEDqpdizLqXyK9pa/KeGnLnhxe37XNns46K fffQ== Received: by 10.50.10.225 with SMTP id l1mr2406051igb.1.1336913072015; Sun, 13 May 2012 05:44:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp286750ibj; Sun, 13 May 2012 05:44:31 -0700 (PDT) Received: by 10.213.120.193 with SMTP id e1mr767810ebr.124.1336913070854; Sun, 13 May 2012 05:44:30 -0700 (PDT) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com. [207.126.144.139]) by mx.google.com with SMTP id p2si4572632eef.202.2012.05.13.05.44.28 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 May 2012 05:44:30 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKT6+srD+uES0Rm8M9mQo6GvuRjjTrY7sh@postini.com; Sun, 13 May 2012 12:44:30 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 169A48A; Sun, 13 May 2012 12:44:28 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id ABEF420B1; Sun, 13 May 2012 12:44:27 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 23F8FA807B; Sun, 13 May 2012 14:44:22 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 13 May 2012 14:44:26 +0200 From: Linus Walleij To: Dmitry Torokhov Cc: , Naveen Kumar Gaddipati , Linus Walleij Subject: [PATCH 7/7] input/nomadik-ske: add sysfs file to enable/disble SKE keypad Date: Sun, 13 May 2012 14:44:25 +0200 Message-ID: <1336913065-10224-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmAnLjk9VrN6CJkHRsIIhMnxTM2zP4DH0WGslldqbjgajGRmF0UEOd12WY7m3oG1gIMP/mD From: Naveen Kumar Gaddipati This sysfs file can force the SKE keypad into GPIO mode (low power) from userspace if the device knows that it is going to go into a mode where the keyboard is not going to be interactive. Signed-off-by: Naveen Kumar Gaddipati Signed-off-by: Linus Walleij --- drivers/input/keyboard/nomadik-ske-keypad.c | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index d2cb4df..74ee59d 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c @@ -193,6 +193,58 @@ static void ske_mode_enable(struct ske_keypad *keypad, bool enable) } } +static void ske_enable(struct ske_keypad *keypad, bool enable) +{ + keypad->enable = enable; + if (keypad->enable) { + enable_irq(keypad->irq); + ske_mode_enable(keypad, true); + } else { + ske_mode_enable(keypad, false); + disable_irq(keypad->irq); + } +} + +static ssize_t ske_show_attr_enable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct platform_device *pdev = to_platform_device(dev); + struct ske_keypad *keypad = platform_get_drvdata(pdev); + return sprintf(buf, "%d\n", keypad->enable); +} + +static ssize_t ske_store_attr_enable(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct platform_device *pdev = to_platform_device(dev); + struct ske_keypad *keypad = platform_get_drvdata(pdev); + unsigned long val; + + if (strict_strtoul(buf, 0, &val)) + return -EINVAL; + + if ((val != 0) && (val != 1)) + return -EINVAL; + + if (keypad->enable != val) { + keypad->enable = val ? true : false; + ske_enable(keypad, keypad->enable); + } + return count; +} + +static DEVICE_ATTR(enable, S_IWUSR | S_IRUGO, + ske_show_attr_enable, ske_store_attr_enable); + +static struct attribute *ske_keypad_attrs[] = { + &dev_attr_enable.attr, + NULL, +}; + +static struct attribute_group ske_attr_group = { + .attrs = ske_keypad_attrs, +}; + static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col) { int row = 0, code, pos; @@ -634,10 +686,19 @@ no_wakeup: goto out_unregisterinput; } + /* sysfs implementation for dynamic enable/disable the input event */ + ret = sysfs_create_group(&pdev->dev.kobj, &ske_attr_group); + if (ret) { + dev_err(&pdev->dev, "failed to create sysfs entries\n"); + goto out_free_irq; + } + platform_set_drvdata(pdev, keypad); return 0; +out_free_irq: + free_irq(keypad->irq, keypad); out_unregisterinput: input_unregister_device(input); input = NULL; @@ -666,6 +727,7 @@ static int __devexit ske_keypad_remove(struct platform_device *pdev) cancel_delayed_work_sync(&keypad->scan_work); input_unregister_device(keypad->input); + sysfs_remove_group(&pdev->dev.kobj, &ske_attr_group); if (keypad->enable) clk_disable(keypad->clk); clk_put(keypad->clk);