From patchwork Tue Oct 15 21:21:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8EBC120D84 for ; Tue, 15 Oct 2013 21:21:21 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id fb1sf17396249pad.9 for ; Tue, 15 Oct 2013 14:21:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=EHx//rJIJZ8uUa/zpxrmSTcTJ5AA+37pXvnTYVTiR88=; b=QnDIH3jzQeBQxL0BsQPIlLvq/f/6/U+/jqmzywk/K2zyXmx9eTZgSck7cfHIy3uA2w ThQEZz0cuRqkIU50whjeJjjUvvGZPzrbK8H71Cs3kJd5iKKoCm9OqvprWn6ycc3Yuaxs MS923dJa9IYrkyt9gXMFJR8QkhocqHdJ6+reivqocblZaUQWdaoCkB91eapfpLp/GBsU MuL70jKQre0KgvcQWsn1Iic59K+ULlMFhJE1E8knm7eCPsiLdcIXBh2bYFcvzQqXoeOw 5Z0w6zwBEmrNhd0jub8dJ7Pi6e11CpeHSXEt1N4HgYT+/Kt8kS4pAX/xAy6aKipVzWv+ rOrA== X-Received: by 10.66.148.8 with SMTP id to8mr25465pab.0.1381872080420; Tue, 15 Oct 2013 14:21:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.96.9 with SMTP id do9ls324593qeb.80.gmail; Tue, 15 Oct 2013 14:21:20 -0700 (PDT) X-Received: by 10.58.255.233 with SMTP id at9mr3366018ved.20.1381872080279; Tue, 15 Oct 2013 14:21:20 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id j9si21460340vcg.85.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:21:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 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.182; Received: by mail-ve0-f182.google.com with SMTP id jx11so1002328veb.41 for ; Tue, 15 Oct 2013 14:21:20 -0700 (PDT) X-Gm-Message-State: ALoCoQn6vSUJbYpqFhmKS0VfwP2emoEKbI0dgdNbjmz+iKRUcSQkY0rEzDoUoWlW7PEYR6DmoxBT X-Received: by 10.220.196.66 with SMTP id ef2mr42282921vcb.7.1381872079971; Tue, 15 Oct 2013 14:21:19 -0700 (PDT) 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 u4csp329379vcz; Tue, 15 Oct 2013 14:21:19 -0700 (PDT) X-Received: by 10.180.187.169 with SMTP id ft9mr21653593wic.14.1381872078999; Tue, 15 Oct 2013 14:21:18 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by mx.google.com with ESMTPS id hc3si73367wib.87.2013.10.15.14.21.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:21:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.180 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.212.180; Received: by mail-wi0-f180.google.com with SMTP id ey11so124191wid.13 for ; Tue, 15 Oct 2013 14:21:18 -0700 (PDT) X-Received: by 10.180.187.236 with SMTP id fv12mr21619104wic.20.1381872078353; Tue, 15 Oct 2013 14:21:18 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id ft19sm397585wic.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:21:17 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Samuel Ortiz , Lee Jones , Linus Walleij Subject: [PATCH 4/5] input: tc3589x-keypad: support probing from device tree Date: Tue, 15 Oct 2013 23:21:11 +0200 Message-Id: <1381872071-23455-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.182 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 --- 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 208de7c..f6ec0d7 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_u8(np, "keypad,num-columns", &plat->kcol); + of_property_read_u8(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);