mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rajat Jain <rajatja@google.com>
To: Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	Rajat Jain <rajatja@google.com>, Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	David Arcari <darcari@redhat.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	HungNien Chen <hn.chen@weidahitech.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Brian Norris <briannorris@chromium.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	dtor@google.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, rajatxjain@gmail.com,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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	[thread overview]
Message-ID: <20171003181922.42827-1-rajatja@google.com> (raw)
In-Reply-To: <20171002213215.32201-1-rajatja@google.com>

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 <rajatja@google.com>
---
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);
-- 
2.14.2.822.g60be5d43e6-goog

  parent reply	other threads:[~2017-10-03 18:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 22:44 [PATCH] HID: i2c-hid: Use device properties (instead of device tree) Rajat Jain
2017-09-30  0:08 ` Brian Norris
2017-10-02 19:27   ` Rajat Jain
2017-10-01 16:18 ` Andy Shevchenko
2017-10-02 19:23   ` Rajat Jain
2017-10-02 21:32   ` [PATCH] HID: i2c-hid: Allow ACPI systems to specify "post-power-on-delay-ms" Rajat Jain
2017-10-03  9:28     ` Andy Shevchenko
2017-10-03 18:24       ` Rajat Jain
2017-10-03 18:19     ` Rajat Jain [this message]
2017-11-21 12:30       ` [PATCH v3] " Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171003181922.42827-1-rajatja@google.com \
    --to=rajatja@google.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=briannorris@chromium.org \
    --cc=darcari@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@google.com \
    --cc=hdegoede@redhat.com \
    --cc=hn.chen@weidahitech.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rajatxjain@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®