From patchwork Thu Jun 21 23:41:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10480941 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 362FB604D3 for ; Thu, 21 Jun 2018 23:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26D0428C82 for ; Thu, 21 Jun 2018 23:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B4B128CA2; Thu, 21 Jun 2018 23:41:45 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 7147628C82 for ; Thu, 21 Jun 2018 23:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932936AbeFUXln (ORCPT ); Thu, 21 Jun 2018 19:41:43 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:41180 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932885AbeFUXlm (ORCPT ); Thu, 21 Jun 2018 19:41:42 -0400 Received: by mail-pf0-f194.google.com with SMTP id a11-v6so2270405pff.8 for ; Thu, 21 Jun 2018 16:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=PYQPmdaVeWkbz7cR7TlaYf4ZQORQNP+M1nVZ+y45gng=; b=HRw36oJE84eoThRTRaUw3ASJHyCC9WIsU2Z/IRGoEhhmfz1YV55GBnVhh9Wm0LGBhI PfHEvbxwurRMckM78VyBzK59MPbjUIzc/04ZNeirOdwS2o6khUNPEmiYvjECndWZNVcj Qf9g+Z5wHKK/cQJrQNhnAPLNnaU7EDj4+3LDM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PYQPmdaVeWkbz7cR7TlaYf4ZQORQNP+M1nVZ+y45gng=; b=STGuXw1leIsN5zE7xorg0vKTrAiduykOZgPMaLUZpuqxvCZ23PQo4yWC29cesAiALG pvHBKoTjJjx1g9xfu69d/ry2aLnHDTkY+5a0lk8cWlIdujwTkNTqey6+culKFYTqlt4A FEFVbbe0C3qvNtEX6lk9Zz+r/Bigz3BvA3Mqo1GqENRj7fdANhIDsKZeF4No/Tqr+uVR HoIu7Cdyyf6tfljo8o9wKKB8aGmNOrPnNRHD89mwDu/G/SSdbWi+s/kcjYn+tH9qQk7T Wu8LpyOFdG8aRMU4IQMLz9G7cr1zPvzieObLpRPVW46C0CXpsTHMus/yUf17AEFfaUHh +euQ== X-Gm-Message-State: APt69E0ZWKrHP5MrgMYnTs3LXNEw24JHK6PJ3wXfHlPJkM9Veu3x1fIA /7sz9Y1ZBQ9tvQUPR0R7sty+JA== X-Google-Smtp-Source: ADUXVKI/evqVAC9NsYZciHuzqnab3ry8W9LJ4GD1l4bvPkLrF4ctdZM6FDcPtv12Y852kHCq0Ddw2Q== X-Received: by 2002:a65:630b:: with SMTP id g11-v6mr23972998pgv.303.1529624501679; Thu, 21 Jun 2018 16:41:41 -0700 (PDT) Received: from swboyd.mtv.corp.google.com ([2620:0:1000:1511:d30e:62c6:f82c:ff40]) by smtp.gmail.com with ESMTPSA id y11-v6sm8656178pfn.92.2018.06.21.16.41.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 16:41:41 -0700 (PDT) From: Stephen Boyd To: Jiri Kosina Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Benjamin Tissoires , Hans de Goede , Andy Shevchenko , Dmitry Torokhov , Doug Anderson , devicetree@vger.kernel.org Subject: [PATCH v2] HID: i2c-hid: Add vddl regulator control Date: Thu, 21 Jun 2018 16:41:38 -0700 Message-Id: <20180621234138.30537-1-swboyd@chromium.org> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog 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 Some wacom w9013 devices have a vddl supply for "low valtage" requirements. Add support in this driver to turn on this low voltage supply. We can also drop a handful of error messages because the regulator core is already printing an error when bulk regulators fail to enable or disable. Cc: Benjamin Tissoires Cc: Hans de Goede Cc: Andy Shevchenko Cc: Dmitry Torokhov Cc: Doug Anderson Acked-by: Rob Herring Cc: Signed-off-by: Stephen Boyd --- Changes from v1: * Use the bulk regulator APIs instead of open coding it (Dmitry) .../bindings/input/hid-over-i2c.txt | 3 +- drivers/hid/i2c-hid/i2c-hid.c | 62 +++++++++---------- include/linux/platform_data/i2c-hid.h | 7 +-- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt index 4d3da9d91de4..89e6ab89ba38 100644 --- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt +++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt @@ -26,7 +26,8 @@ device-specific compatible properties, which should be used in addition to the - compatible: * "wacom,w9013" (Wacom W9013 digitizer). Supports: - - vdd-supply + - vdd-supply (3.3V) + - vddl-supply (1.8V) - post-power-on-delay-ms - vdd-supply: phandle of the regulator that provides the supply voltage. diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index c1652bb7bd15..1d83531454c5 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -1002,18 +1002,21 @@ static int i2c_hid_probe(struct i2c_client *client, return client->irq; } - ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL); + ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL); if (!ihid) return -ENOMEM; if (client->dev.of_node) { ret = i2c_hid_of_probe(client, &ihid->pdata); if (ret) - goto err; + return ret; } else if (!platform_data) { ret = i2c_hid_acpi_pdata(client, &ihid->pdata); - if (ret) - goto err; + if (ret) { + dev_err(&client->dev, + "HID register address not provided\n"); + return ret; + } } else { ihid->pdata = *platform_data; } @@ -1021,21 +1024,20 @@ static int i2c_hid_probe(struct i2c_client *client, /* 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); - if (ret != -EPROBE_DEFER) - dev_err(&client->dev, "Failed to get regulator: %d\n", - ret); - goto err; - } + ihid->pdata.supplies[0].supply = "vdd"; + ihid->pdata.supplies[1].supply = "vddl"; + + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); + if (ret < 0) + return ret; - ret = regulator_enable(ihid->pdata.supply); - if (ret < 0) { - dev_err(&client->dev, "Failed to enable regulator: %d\n", - ret); - goto err; - } if (ihid->pdata.post_power_delay_ms) msleep(ihid->pdata.post_power_delay_ms); @@ -1122,11 +1124,9 @@ static int i2c_hid_probe(struct i2c_client *client, pm_runtime_disable(&client->dev); err_regulator: - regulator_disable(ihid->pdata.supply); - -err: + regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); i2c_hid_free_buffers(ihid); - kfree(ihid); return ret; } @@ -1148,9 +1148,8 @@ static int i2c_hid_remove(struct i2c_client *client) if (ihid->bufsize) i2c_hid_free_buffers(ihid); - regulator_disable(ihid->pdata.supply); - - kfree(ihid); + regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); return 0; } @@ -1201,9 +1200,8 @@ static int i2c_hid_suspend(struct device *dev) hid_warn(hid, "Failed to enable irq wake: %d\n", wake_status); } else { - ret = regulator_disable(ihid->pdata.supply); - if (ret < 0) - hid_warn(hid, "Failed to disable supply: %d\n", ret); + regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); } return 0; @@ -1218,9 +1216,11 @@ static int i2c_hid_resume(struct device *dev) int wake_status; if (!device_may_wakeup(&client->dev)) { - ret = regulator_enable(ihid->pdata.supply); - if (ret < 0) - hid_warn(hid, "Failed to enable supply: %d\n", ret); + ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), + ihid->pdata.supplies); + if (ret) + hid_warn(hid, "Failed to enable supplies: %d\n", ret); + if (ihid->pdata.post_power_delay_ms) msleep(ihid->pdata.post_power_delay_ms); } else if (ihid->irq_wake_enabled) { diff --git a/include/linux/platform_data/i2c-hid.h b/include/linux/platform_data/i2c-hid.h index 1fb088239d12..c628bb5e1061 100644 --- a/include/linux/platform_data/i2c-hid.h +++ b/include/linux/platform_data/i2c-hid.h @@ -12,14 +12,13 @@ #ifndef __LINUX_I2C_HID_H #define __LINUX_I2C_HID_H +#include #include -struct regulator; - /** * struct i2chid_platform_data - used by hid over i2c implementation. * @hid_descriptor_address: i2c register where the HID descriptor is stored. - * @supply: regulator for powering on the device. + * @supplies: regulators for powering on the device. * @post_power_delay_ms: delay after powering on before device is usable. * * Note that it is the responsibility of the platform driver (or the acpi 5.0 @@ -35,7 +34,7 @@ struct regulator; */ struct i2c_hid_platform_data { u16 hid_descriptor_address; - struct regulator *supply; + struct regulator_bulk_data supplies[2]; int post_power_delay_ms; };