From patchwork Sun Mar 19 20:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kaehn X-Patchwork-Id: 665123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0DFC76196 for ; Sun, 19 Mar 2023 20:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjCSUsO (ORCPT ); Sun, 19 Mar 2023 16:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbjCSUsJ (ORCPT ); Sun, 19 Mar 2023 16:48:09 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 779564494; Sun, 19 Mar 2023 13:48:07 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id c19so11099670qtn.13; Sun, 19 Mar 2023 13:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679258886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9IFtKKERmi0HGnc/lJWv1rhtLxqCIn+aR68TrM9Jz4M=; b=Rlgl6wopi9y85Z0jlFBr8jex8DuEEDf7Qk2q4azhhAgMVROO9y7IbA/pKA+XK2J5sx gQiK83K1Zk8E569TDUkQ3TresRY2yj7EE6aeAV+QFVH41sD0FvaUtI8tJbRWSkks3cbC sX02UCEu5FiRc/aoYljieILce5svmt3BuovHAcy7HSvgyxO7XAhyTKotqHClgsOb2s4B zeS+0MLfIZJVNfgW+dh1m+z5rhrua5I+vuPu5Da7C46nRp+r2lRwV19lPhYHh6oUGflp xmZh5nDUQYIRDK+2LTq1Mscfr+R9fv+XrB5GxS4s9a2iFkMJt9pA3wzsyjggYJo3IGZH uZUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679258886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9IFtKKERmi0HGnc/lJWv1rhtLxqCIn+aR68TrM9Jz4M=; b=XJTx8/k3yfG7fL7Ynnb5+XusBqK3+SjidnYOdwAShlkiUw74m11ZQSNk7r4uwBQH8d bSWucH5stBFYHKvGBQyulbUYp7EycWBY8jv07A/Ycuf7Pi5Y4XSwfOivyVTfPdcp110m hwpB8lzY9j0gyYlm/lldFJY+Y0y6ejav/LY6drUCJQPL7EOvQ0vAJxf2fLCQtWzPndUZ GhGd8jo3zTiBZ7+rQYZkKqhhiOJcE+31KW2fWAQSxbPO3njrIDgUqquXQkdylXsNaPO/ Z+NpyYG6z2oQU+pkLdJTNYAlsmr9l+4rVfXUH74LyWV7Z3mQyFbMLoBt0QDSFWf+SUTT n8hA== X-Gm-Message-State: AO0yUKVNkf4UCZGsZULZYZVgJnP7lcvDnuYFUKU4qqQR4ukTzYJhJnIz OWuuSc2qHjloe2w21/CcC3xQvpulg4Q= X-Google-Smtp-Source: AK7set+vaxLrwhsyEDIhp6Ph21RYYN15wkMUiE5fB3P10q44iA98q7YhLF9+bp/tV47ZHnn/tjPurQ== X-Received: by 2002:a05:622a:1109:b0:3bf:b08f:1dcd with SMTP id e9-20020a05622a110900b003bfb08f1dcdmr23846432qty.38.1679258885784; Sun, 19 Mar 2023 13:48:05 -0700 (PDT) Received: from DANNY-DESKTOP.localdomain (071-013-243-092.res.spectrum.com. [71.13.243.92]) by smtp.gmail.com with ESMTPSA id m24-20020ac866d8000000b003b7e8c04d2esm5186021qtp.64.2023.03.19.13.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 13:48:05 -0700 (PDT) From: Danny Kaehn To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: bartosz.golaszewski@linaro.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, ethan.twardy@plexus.com Subject: [PATCH v9 2/3] HID: usbhid: Share USB device firmware node with child HID device Date: Sun, 19 Mar 2023 15:48:01 -0500 Message-Id: <20230319204802.1364-3-kaehndan@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230319204802.1364-1-kaehndan@gmail.com> References: <20230319204802.1364-1-kaehndan@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org USB HID core now shares its fwnode with its child HID device. Since there can only be one HID device on a USB interface, it is redundant to specify a hid node under the USB device. This allows usb HID device drivers to be described in firmware and make use of device properties. Signed-off-by: Danny Kaehn Reviewed-by: Andy Shevchenko --- drivers/hid/usbhid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 257dd73e37bf..090260d99c84 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1374,6 +1375,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * hid->hiddev_report_event = hiddev_report_event; #endif hid->dev.parent = &intf->dev; + device_set_node(&hid->dev, dev_fwnode(&intf->dev)); hid->bus = BUS_USB; hid->vendor = le16_to_cpu(dev->descriptor.idVendor); hid->product = le16_to_cpu(dev->descriptor.idProduct); From patchwork Sun Mar 19 20:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kaehn X-Patchwork-Id: 665122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B56C77B60 for ; Sun, 19 Mar 2023 20:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230078AbjCSUsP (ORCPT ); Sun, 19 Mar 2023 16:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjCSUsK (ORCPT ); Sun, 19 Mar 2023 16:48:10 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4D65768B; Sun, 19 Mar 2023 13:48:07 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id r5so11130017qtp.4; Sun, 19 Mar 2023 13:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679258887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HrTr039c+6RN5N35ewTG2eYP720SLlYLqSsBbC6Oub8=; b=DxonOl/8K+dvmpWuo+1YenKfHOlFPr30tw66Jg22opyy3IHXlPpOn7dRUNZOT41Tz8 VRPg6q5HnxqAep5WpgHZTHU4/GeovoueOqbCd+GzpGrOVmNx/uWLYZopitxZPPDPl49M sUA1Ol8FDk1CkA5PnpUS4VF81lDITASOygHcbOqP0VfJoLl5ITlfGwokgXy8RbUZwFuU oSB5mI96cXCxeJeozDLEYIrapjy8exR+i2pfCWYNcI9s4S+OIulLm4KQzUFUfEy/EhzG Xzemc8s/PAtDZ23po7mpWP2uWlyFhigw2EDdEygK/OSwwSHiUpt7JLp2yArbpqX39khE kIcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679258887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HrTr039c+6RN5N35ewTG2eYP720SLlYLqSsBbC6Oub8=; b=ROcwb42Z+TCpw48hy0KeORDZPacDIsoOykHg47dlocgXdTxtrzpXMCEHSX4+LY8k/6 PgHS4+13WAhenwr0rTzOCi/XW6M8QSOw+O+6HK5PAYQ/q4behYafJmc/o2+wtsi5tKK6 xi8oRpNpojpEc492ILeDYi+ET2dymcv7JLBpFtyRTjQWWPYvFrqweQAOrbms6BB1O82a xjuMuxHhHM/Tm5wEM9wziUhqu56dXoaxWQCDWfBudcSFJTMOZ/KPnqVV5CmqTIihOzza j5B4kWkoR7PQpI6msBP/840q5iAC1ucBKa2C0i1pvlei2yWu7CjTWzAW31TKQ7YEGI9k ZK3w== X-Gm-Message-State: AO0yUKVfV7Wo8aNT7X/PRYWkaunil1ROFog1OIjeKz7nWCjTnQOHTIkk B+4rU6elPYnjgCq9QvasP4g= X-Google-Smtp-Source: AK7set+q7zCLSBGRHPR1/9WObyNMJyALQo+2AYOd+xNYhamOq9gmtCR4X1wKet5VZSoLbD4joTSPQQ== X-Received: by 2002:a05:622a:1a0e:b0:3bf:c371:789e with SMTP id f14-20020a05622a1a0e00b003bfc371789emr24348536qtb.14.1679258886920; Sun, 19 Mar 2023 13:48:06 -0700 (PDT) Received: from DANNY-DESKTOP.localdomain (071-013-243-092.res.spectrum.com. [71.13.243.92]) by smtp.gmail.com with ESMTPSA id m24-20020ac866d8000000b003b7e8c04d2esm5186021qtp.64.2023.03.19.13.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 13:48:06 -0700 (PDT) From: Danny Kaehn To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: bartosz.golaszewski@linaro.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, ethan.twardy@plexus.com Subject: [PATCH v9 3/3] HID: cp2112: Fwnode Support Date: Sun, 19 Mar 2023 15:48:02 -0500 Message-Id: <20230319204802.1364-4-kaehndan@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230319204802.1364-1-kaehndan@gmail.com> References: <20230319204802.1364-1-kaehndan@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Support describing the CP2112's I2C and GPIO interfaces in firmware. I2C and GPIO child nodes can either be children with names "i2c" and "gpio", or, for ACPI, device nodes with _ADR Zero and One, respectively. Additionally, support configuring the I2C bus speed from the clock-frequency device property. Signed-off-by: Danny Kaehn --- drivers/hid/hid-cp2112.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 27cadadda7c9..9e327763fd90 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1234,6 +1234,10 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) u8 buf[3]; struct cp2112_smbus_config_report config; struct gpio_irq_chip *girq; + struct i2c_timings timings; + struct fwnode_handle *child; + u32 addr; + const char *name; int ret; dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL); @@ -1247,6 +1251,17 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) mutex_init(&dev->lock); + device_for_each_child_node(&hdev->dev, child) { + name = fwnode_get_name(child); + ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr); + + if ((name && strcmp("i2c", name) == 0) || (!ret && addr == 0)) + device_set_node(&dev->adap.dev, child); + else if ((name && strcmp("gpio", name)) == 0 || + (!ret && addr == 1)) + dev->gc.fwnode = child; + } + ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); @@ -1292,6 +1307,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_power_normal; } + i2c_parse_fw_timings(&dev->adap.dev, &timings, true); + + config.clock_speed = cpu_to_be32(timings.bus_freq_hz); config.retry_time = cpu_to_be16(1); ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config),