From patchwork Tue Nov 12 14:13:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21464 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 921AC23FBE for ; Tue, 12 Nov 2013 14:13:47 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id q10sf7033843pdj.9 for ; Tue, 12 Nov 2013 06:13:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=P4RTlVYm34l2M4qGZ2LxIn+S5yAKDG3hDMSG7I2cIuk=; b=mOJBjypeWR8bheqRnTpZsledaJnbQYOEk92H99MzsbTWG5W/oBkyCZ19reeccQwo5A PjMgSYXc355+kSeX31//Du4QfMEaMiXrxVeyfzenJAPOM1xdQSqHqB1cX2r3zW1xHfYX RbLSsq9zMjMV3foAX8fqZUgvzg+RDnduCWfa1OcyAuo92gxnehaUzobJE87C4RCDwMED kFBXNi4bG2JEru36W5WhELqxi/VjDFZamg2UN9J9eKPqQUV4xq4jgyETRwYsSu9l6Ik4 p8RsVcqMBliEyztsvV6ruYuoAZ9AuQZWuW+aRxGuKt7F1FQG50XEfnm3hTlnf2mOqP9m pPBw== X-Gm-Message-State: ALoCoQnjXQyBn49VaiHDgkyuswYku+TQ6mrOC7zdHKvMPDN2iU6pHvj9DNbG0xaIpRq5kfZ3CUQF X-Received: by 10.66.164.41 with SMTP id yn9mr11689172pab.7.1384265626754; Tue, 12 Nov 2013 06:13:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.9 with SMTP id kq9ls119265qeb.48.gmail; Tue, 12 Nov 2013 06:13:46 -0800 (PST) X-Received: by 10.220.17.131 with SMTP id s3mr10360527vca.20.1384265626626; Tue, 12 Nov 2013 06:13:46 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id v1si9483231vdh.113.2013.11.12.06.13.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Nov 2013 06:13:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id oz11so3254785veb.3 for ; Tue, 12 Nov 2013 06:13:46 -0800 (PST) X-Received: by 10.220.174.200 with SMTP id u8mr29332837vcz.6.1384265626513; Tue, 12 Nov 2013 06:13:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp165582vcz; Tue, 12 Nov 2013 06:13:46 -0800 (PST) X-Received: by 10.194.21.225 with SMTP id y1mr1358999wje.60.1384265625188; Tue, 12 Nov 2013 06:13:45 -0800 (PST) Received: from mail-wg0-f54.google.com (mail-wg0-f54.google.com [74.125.82.54]) by mx.google.com with ESMTPS id cl1si7820348wib.45.2013.11.12.06.13.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Nov 2013 06:13:45 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.54 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.82.54; Received: by mail-wg0-f54.google.com with SMTP id y10so2481262wgg.33 for ; Tue, 12 Nov 2013 06:13:44 -0800 (PST) X-Received: by 10.194.201.225 with SMTP id kd1mr9267446wjc.35.1384265624672; Tue, 12 Nov 2013 06:13:44 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id bs15sm45026927wib.10.2013.11.12.06.13.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2013 06:13:43 -0800 (PST) From: Linus Walleij To: devicetree@vger.kernel.org, Samuel Ortiz , Lee Jones Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Rutland , Linus Walleij Subject: [PATCH 4/5 v2] input: tc3589x-keypad: support probing from device tree Date: Tue, 12 Nov 2013 15:13:38 +0100 Message-Id: <1384265618-10590-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Implement device tree probing for the tc3589x keypad driver. This is modeled on the STMPE keypad driver and tested on the Ux500 TVK1281618 UIB. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix rows/columns binding to read two u32's insead of two u8 /bits/ as noted by Mark Rutland. --- drivers/input/keyboard/tc3589x-keypad.c | 63 +++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index 208de7cbb7fa..7b6637d8cfbc 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c @@ -297,6 +297,62 @@ static void tc3589x_keypad_close(struct input_dev *input) tc3589x_keypad_disable(keypad); } +#ifdef CONFIG_OF +static const struct tc3589x_keypad_platform_data * +tc3589x_keypad_of_probe(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct tc3589x_keypad_platform_data *plat; + u32 debounce_ms; + int proplen; + + if (!np) + return ERR_PTR(-ENODEV); + + plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); + if (!plat) + return ERR_PTR(-ENOMEM); + + of_property_read_u32(np, "keypad,num-columns", &plat->kcol); + of_property_read_u32(np, "keypad,num-rows", &plat->krow); + if (!plat->krow || !plat->kcol || + plat->krow > TC_KPD_ROWS || plat->kcol > TC_KPD_COLUMNS) { + dev_err(dev, + "keypad columns/rows not properly specified (%ux%u)\n", + plat->kcol, plat->krow); + return ERR_PTR(-EINVAL); + } + + if (!of_get_property(np, "linux,keymap", &proplen)) { + dev_err(dev, "property linux,keymap not found\n"); + return ERR_PTR(-ENOENT); + } + + plat->no_autorepeat = of_property_read_bool(np, "linux,no-autorepeat"); + plat->enable_wakeup = of_property_read_bool(np, "linux,wakeup"); + + /* The custom delay format is ms/16 */ + of_property_read_u32(np, "debounce-delay-ms", &debounce_ms); + if (debounce_ms) + plat->debounce_period = debounce_ms * 16; + else + plat->debounce_period = TC_KPD_DEBOUNCE_PERIOD; + + plat->settle_time = TC_KPD_SETTLE_TIME; + /* FIXME: should be property of the IRQ resource? */ + plat->irqtype = IRQF_TRIGGER_FALLING; + + return plat; +} +#else +static inline const struct tc3589x_keypad_platform_data * +tc3589x_keypad_of_probe(struct device *dev) +{ + return ERR_PTR(-ENODEV); +} +#endif + + static int tc3589x_keypad_probe(struct platform_device *pdev) { struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent); @@ -307,8 +363,11 @@ static int tc3589x_keypad_probe(struct platform_device *pdev) plat = tc3589x->pdata->keypad; if (!plat) { - dev_err(&pdev->dev, "invalid keypad platform data\n"); - return -EINVAL; + plat = tc3589x_keypad_of_probe(&pdev->dev); + if (IS_ERR(plat)) { + dev_err(&pdev->dev, "invalid keypad platform data\n"); + return PTR_ERR(plat); + } } irq = platform_get_irq(pdev, 0);