From patchwork Sat Jan 28 20:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kaehn X-Patchwork-Id: 648106 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 27A15C27C76 for ; Sat, 28 Jan 2023 20:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234838AbjA1U0M (ORCPT ); Sat, 28 Jan 2023 15:26:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjA1U0L (ORCPT ); Sat, 28 Jan 2023 15:26:11 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C1411674; Sat, 28 Jan 2023 12:26:10 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id jr19so6973642qtb.7; Sat, 28 Jan 2023 12:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=P38nkYr7bVSnQ/H/Vpc3pcdK//hX8r4owD23WxSwUuo=; b=NNf9FVXPbAUHEH9KozmU33JWehbHYV42nVd5M4EZVh+8BQs+/52obsYgTll6f2sdMK LtKzoColyFQbDbbA6NcNdn5PgMphnDZT4e7rZKvoxtVWtrvenP+gAdMcwMcOrawpTxNk u5HQJdgFiTA/Ub4kPxSBdRorj5D2RGiGcXrNl3CeyTtdQrOYjXC5Zz50ROTVYDk70AEM EMULEKqtukI3bAAfzmrUC/fC6QXoXguz/AUxa4ne1vwtPSrVuP1N1FKnGj1i3SOfr30y cF8e/WnBAo/0viPbUHBOMAyAaT/zx6+tIi+iRwo1aZrNrsnSh8UwNOreY3pCz2JwwM8G 6tWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=P38nkYr7bVSnQ/H/Vpc3pcdK//hX8r4owD23WxSwUuo=; b=cPFgOPVEV47CN+W1aanc5kgykzxkicxT/wr8BIp7AUr/y3hm4WJ80m3T2Ym/tM6pyK EidhfpNj0l8/gLTvyddtwVtBjvLh9rZ1NRu+xpIp/YvOrwl/Mfq/fzlp54olRj6Jx9T5 WES4M3GIA7yrEV/dCSf+x+2vN6HmYsehwIKa3fjZ1dBfGYu+GhGgO/8K486+1grpP1K8 3CxbQkwoesQv98gTJ/W5d0+wbbwQl+AOcoMgDdh2jWgt29/tvwFQAfMRI0LVzCPjD/a6 vhwUY0uM+RdHxn0h2/FvTu5Kc4b4u/gSnupQI71cWYiIpjuNUfR3/w/ZJoZMcQvBSmr2 ucyw== X-Gm-Message-State: AO0yUKUpPmTrQdTd+4EXgSF2IOeeKuJN1h7+19j0i/RLlIMgQB07ABCY Z/3/gX6J+GwiYAwrAW3C5mY= X-Google-Smtp-Source: AK7set8DkI2a5r4UZYytvdX4PK6facivD7jG+1vWeFqaL7eN+vCtn5lkjBxPWh4l64BjIu/Ya6sqbg== X-Received: by 2002:ac8:7d41:0:b0:3b8:4b00:575e with SMTP id h1-20020ac87d41000000b003b84b00575emr3719625qtb.35.1674937569359; Sat, 28 Jan 2023 12:26:09 -0800 (PST) Received: from DANNY-DESKTOP.localdomain (071-013-243-092.res.spectrum.com. [71.13.243.92]) by smtp.gmail.com with ESMTPSA id q26-20020a05620a025a00b0071de2b6d439sm52460qkn.49.2023.01.28.12.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 12:26:09 -0800 (PST) From: Danny Kaehn To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org, ethan.twardy@plexus.com Subject: [PATCH 1/4] dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge Date: Sat, 28 Jan 2023 14:26:19 -0600 Message-Id: <20230128202622.12676-2-kaehndan@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230128202622.12676-1-kaehndan@gmail.com> References: <20230128202622.12676-1-kaehndan@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This is a USB HID device which includes an I2C controller and 8 GPIO pins. The binding allows describing the chip's gpio and i2c controller in DT using the subnodes named "gpio" and "i2c", respectively. This is intended to be used in configurations where the CP2112 is permanently connected in hardware. Signed-off-by: Danny Kaehn --- .../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yaml diff --git a/Documentation/devicetree/bindings/hid/silabs,cp2112.yaml b/Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file mode 100644 index 000000000000..49287927c63f --- /dev/null +++ b/Documentation/devicetree/bindings/hid/silabs,cp2112.yaml @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hid/silabs,cp2112.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CP2112 HID USB to SMBus/I2C Bridge + +maintainers: + - Danny Kaehn + +description: + This is a USB HID device which includes an I2C controller and 8 GPIO pins. + While USB devices typically aren't described in DeviceTree, doing so with the + CP2112 allows use of its i2c and gpio controllers with other DT nodes when + the chip is expected to be found on a USB port. + +properties: + compatible: + const: usb10c4,ea90 + reg: + maxItems: 1 + description: The USB port number on the host controller + i2c: + $ref: /schemas/i2c/i2c-controller.yaml# + gpio: + $ref: /schemas/gpio/gpio.yaml# + + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + #include + + usb1 { + #address-cells = <1>; + #size-cells = <0>; + + usb@1 { + compatible = "usb424,2514"; + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + device@1 { /* CP2112 I2C Bridge */ + compatible = "usb10c4,ea90"; + reg = <1>; + + cp2112_i2c0: i2c { + #address-cells = <1>; + #size-cells = <0>; + /* Child I2C Devices can be described as normal here */ + temp@48 { + compatible = "national,lm75"; + reg = <0x48>; + }; + }; + + cp2112_gpio0: gpio { + gpio-controller; + interrupt-controller; + #gpio-cells = <2>; + gpio-line-names = + "TEST0", + "TEST1", + "TEST2", + "TEST3", + "TEST4", + "TEST5", + "TEST6", + "TEST7"; + }; + }; + }; + }; From patchwork Sat Jan 28 20:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kaehn X-Patchwork-Id: 648105 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 1DBFFC636CB for ; Sat, 28 Jan 2023 20:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234854AbjA1U0P (ORCPT ); Sat, 28 Jan 2023 15:26:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234861AbjA1U0O (ORCPT ); Sat, 28 Jan 2023 15:26:14 -0500 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 516F123C5A; Sat, 28 Jan 2023 12:26:13 -0800 (PST) Received: by mail-qv1-xf2f.google.com with SMTP id j9so6383408qvt.0; Sat, 28 Jan 2023 12:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=zjpzg4TvvF5ijVNt6jTclmaBmB/Tsf6MP2Z3c8TENhI=; b=L/DPCADetPtg/QOsFtQGtyT/6BINpDgO0UaDCPp8TmailR5OaD5/T50cVJLpExhZYO bNjt9z/UstDx/4TLi18brrZASVSgmW1SSWSRCfrPPxFu+5jWD/3dUpmQddzmMHPtUvih CaX1VcvKPTUe0s0dshF+oVMqzbqi59IB8k8Re4dVjQ+j9PUI/bz4Oxs8eYOQhg8QEHM5 eLz8MhndtIAc14wBjN8A+BhfHOud87OLJgDjjqJiBlMhctPnVsEt2eTXcC+hnvVCPYL4 FXQgUbQiM6PbpscJ0EOrAK8532Bz+ucvWmN6zFLVbKkkuGmSlReqCBhTy4yX3du99HRf eXmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=zjpzg4TvvF5ijVNt6jTclmaBmB/Tsf6MP2Z3c8TENhI=; b=0k85Wr7ALyJCUwSF5xXQgYRyJzVb3gRxTehTamEGVlV/kiZxy7H28TNboAOIR5hMdY Si3GaDj6wDjbJe/7Aa6chVi5wYhHm2eDrbxyY4iqP5mneKMHcnkptKf2Uv7pyvpMO+2f fQdwzmRsLvRxZU0EWmXRqDFa+TpIRWIjYUGS+R8oQYimFTRl5vuS0DkiMEL2kRBWnfI+ cSfba6irFTYqcAS9rzYHBisBB+1X3aUYF9OHE8b7PKEt4drqyWCc8YmkvgLzRwkhKf0E eepM6+agL6U4ZvYqumyp0P0HbFkbSwd+9KN4J28/tduVnMT5NP1JBtzXKNlBDeJsHcn2 3a8A== X-Gm-Message-State: AO0yUKVlYHCyUcyPijjZLGHgYh88fEP4PV7C5Kb2VQaCtlQ4jOtoOCuK H0NN5rHIpHb6409ZE6uFbC0= X-Google-Smtp-Source: AK7set8wV8BbmblBu4kZSfSb7TtOUKCx68BYFiscFflITiIB+fD0v5vh/46Xbi9HkV9PIG4x2rsn0A== X-Received: by 2002:a05:6214:1712:b0:537:ab77:fbd9 with SMTP id db18-20020a056214171200b00537ab77fbd9mr13570652qvb.28.1674937572300; Sat, 28 Jan 2023 12:26:12 -0800 (PST) Received: from DANNY-DESKTOP.localdomain (071-013-243-092.res.spectrum.com. [71.13.243.92]) by smtp.gmail.com with ESMTPSA id q26-20020a05620a025a00b0071de2b6d439sm52460qkn.49.2023.01.28.12.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 12:26:12 -0800 (PST) From: Danny Kaehn To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org, ethan.twardy@plexus.com Subject: [PATCH 4/4] CP2112 Devicetree Support Date: Sat, 28 Jan 2023 14:26:22 -0600 Message-Id: <20230128202622.12676-5-kaehndan@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230128202622.12676-1-kaehndan@gmail.com> References: <20230128202622.12676-1-kaehndan@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Bind i2c and gpio interfaces to subnodes with names "i2c" and "gpio" if they exist, respectively. This allows the gpio and i2c controllers to be described in DT as usual. Signed-off-by: Danny Kaehn --- drivers/hid/hid-cp2112.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 27cadadda7c9..99e8043e1c34 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1310,6 +1310,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->adap.algo = &smbus_algorithm; dev->adap.algo_data = dev; dev->adap.dev.parent = &hdev->dev; + dev->adap.dev.of_node = of_get_child_by_name(hdev->dev.of_node, "i2c"); snprintf(dev->adap.name, sizeof(dev->adap.name), "CP2112 SMBus Bridge on hidraw%d", ((struct hidraw *)hdev->hidraw)->minor); @@ -1336,6 +1337,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.ngpio = 8; dev->gc.can_sleep = 1; dev->gc.parent = &hdev->dev; +#if defined(CONFIG_OF_GPIO) + dev->gc.of_node = of_get_child_by_name(hdev->dev.of_node, "gpio"); +#endif dev->irq.name = "cp2112-gpio"; dev->irq.irq_startup = cp2112_gpio_irq_startup; @@ -1391,6 +1395,11 @@ static void cp2112_remove(struct hid_device *hdev) struct cp2112_device *dev = hid_get_drvdata(hdev); int i; + of_node_put(dev->adap.dev.of_node); +#if defined(CONFIG_OF_GPIO) + of_node_put(dev->gc.of_node); +#endif + sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group); i2c_del_adapter(&dev->adap);