From patchwork Wed Apr 9 07:28:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 28062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4145D20062 for ; Wed, 9 Apr 2014 07:28:44 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf9191224oag.0 for ; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=gu1mPzgmlbU/6WrJ8lcW9wZ7LH1+tPEvxpjQy541r3Y=; b=CaA+bb45XxIt/ar9qOVTPea1eLBjRC8NuVD727eaNOtNzAKerc04KBgvvqGeS6lOwk LCgpe01t2gQezZbOscDifsRNfT9v2vsltx/hHrHsQCLHiwsgjrx7AyPAghp3VOmFUmDc BU0DxcfU3rqWWMxU66Rb7cU2KO0u7OVYvPbhxLPmMLm/vliLv3RIRPf8wmmyOVVF8fAc YBo3qKpwIb7epUp8+nNYr2dKpdwg/R3BvM4e31cSgV+XAZtMvWfACiMvh2EOlgn7lk74 /LDTNHhppdm0hM9FANNlmXN6ZCXfKsh7qNOtO44knoPrPAZ3EicejZ4YTGdm5GYuUy3H M42w== X-Gm-Message-State: ALoCoQmWXYuM6Pl4kNgTjKa86JOFMKNKhJ0eGSv+vNnc8zRG91hj+og4jDReWijYI9GowR9t4n9t X-Received: by 10.182.29.196 with SMTP id m4mr4115132obh.26.1397028523723; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.33 with SMTP id q30ls493529qgd.99.gmail; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) X-Received: by 10.58.187.78 with SMTP id fq14mr7208815vec.9.1397028523592; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id sc7si22075vdc.31.2014.04.09.00.28.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 00:28:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 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.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so1701790veb.8 for ; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) X-Received: by 10.220.133.80 with SMTP id e16mr7408237vct.13.1397028523400; Wed, 09 Apr 2014 00:28:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp307670vcv; Wed, 9 Apr 2014 00:28:43 -0700 (PDT) X-Received: by 10.68.161.101 with SMTP id xr5mr10036990pbb.168.1397028522534; Wed, 09 Apr 2014 00:28:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si80825pbl.130.2014.04.09.00.28.41; Wed, 09 Apr 2014 00:28:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932734AbaDIH2T (ORCPT + 9 others); Wed, 9 Apr 2014 03:28:19 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:34584 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932730AbaDIH2R (ORCPT ); Wed, 9 Apr 2014 03:28:17 -0400 Received: by mail-we0-f180.google.com with SMTP id p61so2018608wes.39 for ; Wed, 09 Apr 2014 00:28:16 -0700 (PDT) X-Received: by 10.180.160.166 with SMTP id xl6mr8495475wib.42.1397028496074; Wed, 09 Apr 2014 00:28:16 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id l12sm258656wjr.35.2014.04.09.00.28.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Apr 2014 00:28:15 -0700 (PDT) From: Linus Walleij To: devicetree@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Samuel Ortiz , Lee Jones Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Rutland , Linus Walleij Subject: [RESEND: PATCH 2/2] input: tc3589x-keypad: support probing from device tree Date: Wed, 9 Apr 2014 09:28:11 +0200 Message-Id: <1397028491-15462-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org 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.177 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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 v2->v3: - Use two local u32 variables to avoid weirdness in u8 casting of the resulting values to the pointers. 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 | 66 ++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index 74494a357522..ad7abae69078 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c @@ -296,6 +296,65 @@ 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 cols, rows; + 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", &cols); + of_property_read_u32(np, "keypad,num-rows", &rows); + plat->kcol = (u8) cols; + plat->krow = (u8) rows; + 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); @@ -306,8 +365,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);