From patchwork Tue Oct 3 18:19:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 9983329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10BEC602B8 for ; Tue, 3 Oct 2017 18:19:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE3A628470 for ; Tue, 3 Oct 2017 18:19:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E29D528722; Tue, 3 Oct 2017 18:19:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 732D828470 for ; Tue, 3 Oct 2017 18:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751001AbdJCSTg (ORCPT ); Tue, 3 Oct 2017 14:19:36 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:51886 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbdJCSTf (ORCPT ); Tue, 3 Oct 2017 14:19:35 -0400 Received: by mail-pg0-f43.google.com with SMTP id u144so2473778pgb.8 for ; Tue, 03 Oct 2017 11:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=vXibYLVkBumuUYaQ97CjpVkMLml28gHq5+PnvUnLEUQ=; b=bPXq/faFihDYOwZ72+DOsUBUXX6g1winL+lpbWxIq7F3kfBSprzlTrItNaz3IkSsNa KogSj6YlSzrSocvl8p9R0uZBTyf6w2GDpk93Sf4NC6Daf0DM6lSGLB9M0Bp5M0WvAiR7 801l4y0VzTFVxLIUSrRHArlOHBSTsZU2J0uHDImeSqEJpbFvwP97Cw2dw1uu6XEACdss S4VpFdyOdqF6mwTZ5zUPUXQZoDLD81jt70QlyfS+8+PL3p3ii/wgAKbba4K8Zz14NS+w OeQS/VIMaZlb0oqnajI24qCMnRWmHco+EOdhjZZE6B9ThRVA+vHSgv8xdTl6xB5KMdis A1HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vXibYLVkBumuUYaQ97CjpVkMLml28gHq5+PnvUnLEUQ=; b=AvKAcvWIx1nYdQ8hMNF9yG6HRlF9L52tPFnyKDEzBlnh7uv3M4zq6SWQbwrOiAf6Pw 4OoDtR3iZhFqNjF74aUJvZqjhOw9C0Tj65ygJDj+P8QTnOJwYjrFODKVVa1I1ifT8tE2 LE3qrqx+AL18lDCAsOt1z0vGyaraxC5I9hrkhYn1sL1ATO401hNjL/fnszrazfpoGI98 UkAmy+x2UQvuzzwmmnOkVwqdV4XMAAEl30zyr/CHI5vLAEs0G5SMVLyg7Arbf36wQwem deEjExa2Fj39yHKEVi9iZA4ihmn29uKibRYH2PKp05FsWZLZhBI0qrYV7lWtChaNfKTc yfkA== X-Gm-Message-State: AMCzsaUxU+HDEsRVVp3NSjosV+7lNx7hCSS2nWlfMzPq4Xe6ATAywAnl zXOAyyBEVEGWfK8/ehNkfrda4w== X-Google-Smtp-Source: AOwi7QD2nlY5cQOeQcF2ip/lLXCfdDGvBIUYYi3XJ+7C9BZi5nv/bGM3Oz4vs66fKyh7cmAL39+FJA== X-Received: by 10.99.137.72 with SMTP id v69mr9449322pgd.130.1507054774498; Tue, 03 Oct 2017 11:19:34 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([172.22.112.48]) by smtp.gmail.com with ESMTPSA id g16sm2350517pfd.87.2017.10.03.11.19.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 11:19:33 -0700 (PDT) From: Rajat Jain To: Jarkko Nikula , Rajat Jain , Jiri Kosina , Benjamin Tissoires , David Arcari , Mika Westerberg , HungNien Chen , Hans de Goede , Brian Norris , Dmitry Torokhov , dtor@google.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rajatxjain@gmail.com, Andy Shevchenko Subject: [PATCH v3] HID: i2c-hid: Allow ACPI systems to specify "post-power-on-delay-ms" Date: Tue, 3 Oct 2017 11:19:21 -0700 Message-Id: <20171003181922.42827-1-rajatja@google.com> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog In-Reply-To: <20171002213215.32201-1-rajatja@google.com> References: <20171002213215.32201-1-rajatja@google.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The property "post-power-on-delay-ms" allows a platform to specify the delay needed after power-on, but only via device trees currently. Use device_property_* instead of of_* reads to allow ACPI systems to also provide the same information. This is useful for Wacom hardware on ACPI systems. Signed-off-by: Rajat Jain --- v3: introduce i2c_hid_fwnode_probe() to parse common device_properties. Also fixup the binding doc to indicate that regulator isn't a requirement for "post-power-on-delay-ms" v2: Don't change any other existing logic, only read "post-power-on-delay-ms" in i2c_hid_acpi_pdata() also. v1: Try to unify everything using device properties, convert i2c_hid_of_probe() to i2c_hid_fwnode_probe() and call i2c_hid_acpi_pdata() if can't get HID register address using device_property. .../devicetree/bindings/input/hid-over-i2c.txt | 2 +- drivers/hid/i2c-hid/i2c-hid.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt index 28e8bd8b7d64..4d3da9d91de4 100644 --- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt +++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt @@ -31,7 +31,7 @@ device-specific compatible properties, which should be used in addition to the - vdd-supply: phandle of the regulator that provides the supply voltage. - post-power-on-delay-ms: time required by the device after enabling its regulators - before it is ready for communication. Must be used with 'vdd-supply'. + or powering it on, before it is ready for communication. Example: diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 77396145d2d0..741a457dfe61 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -928,11 +928,6 @@ static int i2c_hid_of_probe(struct i2c_client *client, } pdata->hid_descriptor_address = val; - ret = of_property_read_u32(dev->of_node, "post-power-on-delay-ms", - &val); - if (!ret) - pdata->post_power_delay_ms = val; - return 0; } @@ -949,6 +944,16 @@ static inline int i2c_hid_of_probe(struct i2c_client *client, } #endif +static void i2c_hid_fwnode_probe(struct i2c_client *client, + struct i2c_hid_platform_data *pdata) +{ + u32 val; + + if (!device_property_read_u32(&client->dev, "post-power-on-delay-ms", + &val)) + pdata->post_power_delay_ms = val; +} + static int i2c_hid_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { @@ -992,6 +997,9 @@ static int i2c_hid_probe(struct i2c_client *client, ihid->pdata = *platform_data; } + /* Parse platform agnostic common properties from ACPI / device tree */ + i2c_hid_fwnode_probe(client, &ihid->pdata); + ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd"); if (IS_ERR(ihid->pdata.supply)) { ret = PTR_ERR(ihid->pdata.supply);