From patchwork Wed Jun 5 23:12:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Kaehn X-Patchwork-Id: 13687720 Received: from mx0b-0046e701.pphosted.com (mx0b-0046e701.pphosted.com [67.231.157.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6EF123C9; Thu, 6 Jun 2024 00:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.157.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632040; cv=none; b=XnYsZtOn+LSnoqACvWiAwD74MkEnVUY/bzhBcrW+V0nHQ/95a9KO4IH2lHzTTlceNHSmAKIPCSzeJZQz51bnWiHf84xtRKv/63ElQGZofdh8vZDKBmAp/yJzZ3cchnwOxVsR9zp1iKM8mxqmOW0POKyYXrt+9Ir/D2eLD/9Sqq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632040; c=relaxed/simple; bh=bD6OdL68EaJAFx8NMGIrSd33wCJ8XWh9kWoYIyfKz8w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=t3iYcVrVWD8kKJoyZ0ow58idQ/3epo0TeFzQcNU92E44uIdVHDncV5EYrsTl7+m9+nY0Iau8uZkwba+qBokd86TKWnfE1Wx7rMShcbhNhk4GCDtVJBJ0WlzJFZVoLthlcqqjbHjJPXr+pU+fu1yQIxG0uIGisSVVWskikdilfW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com; spf=pass smtp.mailfrom=plexus.com; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b=ePfx+9b1; arc=none smtp.client-ip=67.231.157.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=plexus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b="ePfx+9b1" Received: from pps.filterd (m0341555.ppops.net [127.0.0.1]) by mx0b-0046e701.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 455MCwgq016418; Wed, 5 Jun 2024 23:17:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps1; bh=AhU2D ZJBcuW78r8ntcxANy5fqvNuhWgM86A5vqDna+4=; b=ePfx+9b1hEZnUXUiNyJkF Rwex0Ifqq1TIMT2rV1sXRIDNqmch+f72otO2lrU7F8YIESL9OFaXF5A+RPhyRDqo lFX58PZDhHosbkZNfwOG1zEExNJgWb+BjNz9ZsTDLXSNZ71Boi3BIsZXXyvoq4uC fJqd5RZEsbLwAzTZl56y663Rf+isJ6Nwh2DFS/UK/fnHEPaOejpC2/D6kAKNZcIy vVPC/9XWZ2V3JgdHoZEig9nnwhw1IQWNNsyi+srwBPrtZNL5I8/alr3iHV9WDXcE ei5xsOVOv927jm3SrtnqX8Xt+Brpr1ewLlB9HNM/Sl6Gb5fKX3A0H3VA8UCXphH4 A== Received: from gcc-mail-mx-001.na.plexus.com (outbound.plexus.com [64.215.193.254]) by mx0b-0046e701.pphosted.com (PPS) with ESMTPS id 3yjyu387kk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 23:17:49 +0000 (GMT) Received: from gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) by gcc-mail-mx-001.na.plexus.com (10.255.51.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 5 Jun 2024 23:17:48 +0000 Received: from LNDCL34533.neenah.na.plexus.com (10.255.48.203) by gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) with Microsoft SMTP Server id 15.1.2507.37 via Frontend Transport; Wed, 5 Jun 2024 23:17:48 +0000 From: Danny Kaehn Date: Wed, 5 Jun 2024 18:12:44 -0500 Subject: [PATCH v11 1/4] dt-bindings: i2c: Add CP2112 HID USB to SMBus Bridge Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240605-cp2112-dt-v11-1-d55f0f945a62@plexus.com> References: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> In-Reply-To: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> To: Rob Herring , Krzysztof Kozlowski , Benjamin Tissoires , Andy Shevchenko , Danny Kaehn CC: Jiri Kosina , , , Dmitry Torokhov , Bartosz Golaszewski , Ethan Twardy X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717629180; l=3233; i=danny.kaehn@plexus.com; s=20240605; h=from:subject:message-id; bh=bD6OdL68EaJAFx8NMGIrSd33wCJ8XWh9kWoYIyfKz8w=; b=f6B8R1Cbg4GmuaImdj6iWAkHWF5H4DjMuFBE2OuVNC6ijJUNXEvVQOtuyyN9jhcEds19rR6AY TANKAWTu4ZpDKCep9KeGZQJmJWnIi52Qn7KVeG7HYYr1WWvF7Ch2V1p X-Developer-Key: i=danny.kaehn@plexus.com; a=ed25519; pk=+a/HbfS1U7uuw+5dRHN5PsUDyPWbx4dXDnblK41GI2s= X-Proofpoint-GUID: gWH8qvVIsWnRP6WjBfEgjFps3BggmZJb X-Proofpoint-ORIG-GUID: gWH8qvVIsWnRP6WjBfEgjFps3BggmZJb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406050175 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 --- .../devicetree/bindings/i2c/silabs,cp2112.yaml | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml b/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml new file mode 100644 index 000000000000..0108f2e43c8c --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml @@ -0,0 +1,105 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/silabs,cp2112.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CP2112 HID USB to SMBus/I2C Bridge + +maintainers: + - Danny Kaehn + +description: + The CP2112 is a USB HID device which includes an integrated I2C controller + and 8 GPIO pins. Its GPIO pins can each be configured as inputs, open-drain + outputs, or push-pull outputs. + +properties: + compatible: + const: usb10c4,ea90 + + reg: + maxItems: 1 + description: The USB port number on the host controller + + i2c: + description: The SMBus/I2C controller node for the CP2112 + $ref: /schemas/i2c/i2c-controller.yaml# + unevaluatedProperties: false + + properties: + sda-gpios: + maxItems: 1 + + scl-gpios: + maxItems: 1 + + clock-frequency: + minimum: 10000 + default: 100000 + maximum: 400000 + + interrupt-controller: true + "#interrupt-cells": + const: 2 + + gpio-controller: true + "#gpio-cells": + const: 2 + + gpio-line-names: + minItems: 1 + maxItems: 8 + +patternProperties: + "-hog(-[0-9]+)?$": + type: object + + required: + - gpio-hog + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + #include + + usb { + #address-cells = <1>; + #size-cells = <0>; + + cp2112: device@1 { + compatible = "usb10c4,ea90"; + reg = <1>; + + i2c { + #address-cells = <1>; + #size-cells = <0>; + sda-gpios = <&cp2112 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&cp2112 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + + temp@48 { + compatible = "national,lm75"; + reg = <0x48>; + }; + }; + + gpio-controller; + interrupt-controller; + #gpio-cells = <2>; + gpio-line-names = "CP2112_SDA", "CP2112_SCL", "TEST2", + "TEST3","TEST4", "TEST5", "TEST6"; + + fan-rst-hog { + gpio-hog; + gpios = <7 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "FAN_RST"; + }; + }; + }; From patchwork Wed Jun 5 23:12:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Kaehn X-Patchwork-Id: 13687721 X-Patchwork-Delegate: jikos@jikos.cz Received: from mx0b-0046e701.pphosted.com (mx0b-0046e701.pphosted.com [67.231.157.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DF927E6; Thu, 6 Jun 2024 00:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.157.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632042; cv=none; b=aq2eTt8QQOZVoTOGd4+fE2ivCRuedf2japwB/Jyu9HU45bMQrzCJ12NUX+8gq4vukp1tDAVdha4Xx7mH0+iRdTBCnjznVIjYD6TJEPK+SwnaTQGAoCD+FhRR2Enyp2hGe/8vfHf4N0RHV50HVS6rjhYhT2WtOwC/fOTvplDhMes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632042; c=relaxed/simple; bh=3KQ324a+aNFxbZCXFok2y2weO4PJIGknu/daWhVhMsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=YwSWau/82bQw3frVY+P46lPqWOfKyGaOZwjGTok6IHFD8GI0lD5QTVkeMArJzeISMe6Pox+QRXGlO4qQMxcqLRFwYtiVGiFnyY3LCH/tpm9bdxnrbrAcnRHy9MLe80HKIjWKNmU1DeAbWqQOdnGEuwPit2UcEhlUzXVKFNWBBc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com; spf=pass smtp.mailfrom=plexus.com; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b=epOS53Gb; arc=none smtp.client-ip=67.231.157.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=plexus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b="epOS53Gb" Received: from pps.filterd (m0341555.ppops.net [127.0.0.1]) by mx0b-0046e701.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 455MCwgr016418; Wed, 5 Jun 2024 23:17:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps1; bh=bLKrX vKovutwmShMXcjlyb9MfMXa88poPhCWGdD55zs=; b=epOS53GbklWyAbK6INZfD xANzm7YNgHoyUO4YHPH9L+rTpKarFwJqcHzoBOF3/DFumcIRI2GdkBFUIc2zX/zC 8/SvYp+okHxdK+ipHbaDdTp1Toj1RfuKH0I059in8IMWXNSxf8Q73946FosZiGiY AY1loae7rk+/OfFSjQWxMR0LTZF4EaduTI5S2bgdIAT1yx5mBVamn4pmRScdhxp8 x3bUKdu7tBDyh0bhaLBzQr+RF9RaB1u+Ft7M9hVLKzRFteIF+hOUi2ioYRKvgeIW 27ukj7m3YsYc4wYgVtFImzG1MZ8Cqr71bMuiaAY3PaB3Ns/I1hlcEzxLXAnlf7OW g== Received: from gcc-mail-mx-001.na.plexus.com (outbound.plexus.com [64.215.193.254]) by mx0b-0046e701.pphosted.com (PPS) with ESMTPS id 3yjyu387kk-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 23:17:50 +0000 (GMT) Received: from gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) by gcc-mail-mx-001.na.plexus.com (10.255.51.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 5 Jun 2024 23:17:48 +0000 Received: from LNDCL34533.neenah.na.plexus.com (10.255.48.203) by gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) with Microsoft SMTP Server id 15.1.2507.37 via Frontend Transport; Wed, 5 Jun 2024 23:17:48 +0000 From: Danny Kaehn Date: Wed, 5 Jun 2024 18:12:45 -0500 Subject: [PATCH v11 2/4] HID: usbhid: Share USB device firmware node with child HID device Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240605-cp2112-dt-v11-2-d55f0f945a62@plexus.com> References: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> In-Reply-To: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> To: Rob Herring , Krzysztof Kozlowski , Benjamin Tissoires , Andy Shevchenko , Danny Kaehn CC: Jiri Kosina , , , Dmitry Torokhov , Bartosz Golaszewski , Ethan Twardy X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717629180; l=1293; i=danny.kaehn@plexus.com; s=20240605; h=from:subject:message-id; bh=3KQ324a+aNFxbZCXFok2y2weO4PJIGknu/daWhVhMsU=; b=QKgUhwHbZIeSw9lDNLuu430rukdCxcluVwJCNsqFHRNwfb0xiIRhT08qtRtZeQD0H3bpe0Rl+ w8mlnAubQytCIKz8+V09nTn4sAkaiMBO9vO+NqBQ//+IIQt9ZntD6dL X-Developer-Key: i=danny.kaehn@plexus.com; a=ed25519; pk=+a/HbfS1U7uuw+5dRHN5PsUDyPWbx4dXDnblK41GI2s= X-Proofpoint-GUID: owUuMiyDXE05DgzQ6ijn3gO0OGJq_NmE X-Proofpoint-ORIG-GUID: owUuMiyDXE05DgzQ6ijn3gO0OGJq_NmE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406050175 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 a90ed2ceae84..cb687ea7325c 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 Wed Jun 5 23:12:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Kaehn X-Patchwork-Id: 13687722 X-Patchwork-Delegate: jikos@jikos.cz Received: from mx0b-0046e701.pphosted.com (mx0b-0046e701.pphosted.com [67.231.157.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77DF01361; Thu, 6 Jun 2024 00:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.157.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632525; cv=none; b=V1fdhUH0bLfs6HnwX6j6lVqAyjJMcQdtfQ1iFA/Ja4vhQ6m6SYPtmiIigs2ecTEjIC8RPMkzA2gurPOvd8p4wWVOKPpJjdvfNZooamWJAdDPA+tLrxFixddkYZntkwkXL8MTzziqyvQRyNCrky6oURIyH777roah5rSUJYJjbXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632525; c=relaxed/simple; bh=7lSdRK8+0RYtmNReQjUvhYYc2NdiIGpKwFmZh47w/3k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=daaMC/al9F3P0Uc15Jv9gEhl6DJxoheQ4/XkRxcANvNB6YmRk2Ph1vW8Q8WfwvDy6JmDpcMRHe2Q5XnHHBjcMi/M/dS/jbta4Hx9fT9SLzzVz8bCwmDuVJlzU+fggqH3zAPLocch46E7AoGj8pIDj3fo11v0Qi0o7ZcPQjH3V+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com; spf=pass smtp.mailfrom=plexus.com; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b=bqCD9+p3; arc=none smtp.client-ip=67.231.157.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=plexus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b="bqCD9+p3" Received: from pps.filterd (m0341555.ppops.net [127.0.0.1]) by mx0b-0046e701.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 455MCwgs016418; Wed, 5 Jun 2024 23:17:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps1; bh=UmyUA sz3kYKSjAgdkqW61v+uUxBxpJPTsNMRS4zcWHE=; b=bqCD9+p33aaa8RTfBi0MV qAKVmQWWNAuz1l5rT3uadlMCHK3PXZC2avyHklTflkbhwatZgHjLRc5Qjhitxdfc DlZY0wUwdgrC+nmt5spM5MwvoproHNDcCHezgPlnnO9aDxyZH6WaD4fRe3bjFA2L cKJW0Y2gUroS3SBErqBMw8nN8PJHFZNKwtX3+OFHQmErvWWk7IPieBEENd99PKNv LEvv87VNa42JHTRLWi1MWIcD1FM73V94Htl59UZUS/pRa0Ni8Pnz+A/pgpwssE8v 2A7DxAPP3Zp70nJ0raNJdFk1ra/VNKvydC5TSz5wVR6oyKIl0Tf1NtqD4G7QgVJN g== Received: from gcc-mail-mx-001.na.plexus.com (outbound.plexus.com [64.215.193.254]) by mx0b-0046e701.pphosted.com (PPS) with ESMTPS id 3yjyu387kk-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 23:17:50 +0000 (GMT) Received: from gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) by gcc-mail-mx-001.na.plexus.com (10.255.51.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 5 Jun 2024 23:17:48 +0000 Received: from LNDCL34533.neenah.na.plexus.com (10.255.48.203) by gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) with Microsoft SMTP Server id 15.1.2507.37 via Frontend Transport; Wed, 5 Jun 2024 23:17:48 +0000 From: Danny Kaehn Date: Wed, 5 Jun 2024 18:12:46 -0500 Subject: [PATCH v11 3/4] HID: cp2112: Fwnode Support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240605-cp2112-dt-v11-3-d55f0f945a62@plexus.com> References: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> In-Reply-To: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> To: Rob Herring , Krzysztof Kozlowski , Benjamin Tissoires , Andy Shevchenko , Danny Kaehn CC: Jiri Kosina , , , Dmitry Torokhov , Bartosz Golaszewski , Ethan Twardy X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717629180; l=2253; i=danny.kaehn@plexus.com; s=20240605; h=from:subject:message-id; bh=7lSdRK8+0RYtmNReQjUvhYYc2NdiIGpKwFmZh47w/3k=; b=OseCypQoU0HxxRWRc3RCDXUPSz3N/aiGM8ad4iwzSJu7PIA0j8mW4HTO9U4f0IsEreZFaFBoZ LCLVaeANSDuCyBEE0x3M5Ui3usKdDB6ra+D1KL4o43/CRpKk+93clBm X-Developer-Key: i=danny.kaehn@plexus.com; a=ed25519; pk=+a/HbfS1U7uuw+5dRHN5PsUDyPWbx4dXDnblK41GI2s= X-Proofpoint-GUID: euC60vgAo402uKM1X9xWPyK1CTpdklhW X-Proofpoint-ORIG-GUID: euC60vgAo402uKM1X9xWPyK1CTpdklhW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=950 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406050175 Support describing the CP2112's I2C and GPIO interfaces in firmware. The GPIO chip shares a firmware node with the CP2112. The I2C child node can either be a child with the name "i2c" or, in ACPI, a device node with _ADR Zero. Signed-off-by: Danny Kaehn --- drivers/hid/hid-cp2112.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 20a0d1315d90..b78d81275065 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -27,6 +27,22 @@ #include #include "hid-ids.h" +/** + * enum cp2112_child_acpi_cell_addrs - Child ACPI addresses for CP2112 sub-functions + * @CP2112_I2C_ADR: Address for I2C node + */ +enum cp2112_child_acpi_cell_addrs { + CP2112_I2C_ADR = 0, +}; + +/* + * CP2112 Fwnode child names. + * CP2112 sub-functions can be described by named fwnode children or by ACPI _ADR + */ +static const char * const cp2112_cell_names[] = { + [CP2112_I2C_ADR] = "i2c", +}; + #define CP2112_REPORT_MAX_LENGTH 64 #define CP2112_GPIO_CONFIG_LENGTH 5 #define CP2112_GPIO_GET_LENGTH 2 @@ -1195,7 +1211,10 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) struct cp2112_device *dev; u8 buf[3]; struct cp2112_smbus_config_report config; + struct fwnode_handle *child; struct gpio_irq_chip *girq; + const char *name; + u32 addr; int ret; dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL); @@ -1209,6 +1228,26 @@ 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) { + ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr); + if (ret) { + name = fwnode_get_name(child); + if (!name) + continue; + ret = match_string(cp2112_cell_names, + ARRAY_SIZE(cp2112_cell_names), name); + if (ret < 0) + continue; + addr = ret; + } + + switch (addr) { + case CP2112_I2C_ADR: + device_set_node(&dev->adap.dev, child); + break; + } + } + ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); From patchwork Wed Jun 5 23:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Kaehn X-Patchwork-Id: 13687723 X-Patchwork-Delegate: jikos@jikos.cz Received: from mx0b-0046e701.pphosted.com (mx0b-0046e701.pphosted.com [67.231.157.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073881361; Thu, 6 Jun 2024 00:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.157.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632999; cv=none; b=lzbom+ZpCSHVC8qtYlkEkEnIcEXf2uCatPfjWdxA4JSipBxcImFBhPD49P0tETXOTY4ro2PXbqB3u6vsyQ3lYBt6f0thxniZxpi6iSUSyATl4N27Gs97bmxtyhoT0AhqdN4ukrXVApl8NX/30ropozgndHDlJ2wcF73o2d5V9/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717632999; c=relaxed/simple; bh=iXIn4/cfpRBfQSLNVlHO1LCS5qH4+6FWhqutMxFO+hY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=hwfz5FBNinlJeBwBGBUM2bWPgAgLakNq6wEQPhm6cSPksOZt6fH0a6L8NSDAdTo9Y7q9s7pssT6kzePx0pPAUHtLxdw0evIqsLwpR1+ULFBqI5UcnH2JHEE7c8rkPeihvz0AMk0Y6sWJCu4aEE7zocy48ODEYVPdEUWVxN29gvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com; spf=pass smtp.mailfrom=plexus.com; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b=DK2hbQrF; arc=none smtp.client-ip=67.231.157.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=plexus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=plexus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=plexus.com header.i=@plexus.com header.b="DK2hbQrF" Received: from pps.filterd (m0341555.ppops.net [127.0.0.1]) by mx0b-0046e701.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 455MCwgt016418; Wed, 5 Jun 2024 23:17:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps1; bh=9TM+j 8WAWTNRLztQwA8QKiisx3gl+m0cW1rwMHooefE=; b=DK2hbQrF5vZaIydumQZ2O ghqF78jXF7a9YrG9V9n5pA6Z+J/gYsXLkv109HpndjQX9+X2fCEIJBvyOi5A6MJ+ soAb10eDZ2+I6YIl+vVMtvEZh3iJsuh4B6kMbX+87zNBYKWgfZY8k7hgC/DAAAyt IyQkgmJ0HMovT9VXARIpDz22rwcUboAUD9PSRBWl0rYH2sGDB7OO2AIMMeZMVK3c 5mEp+oAg4mpDAslvKt9rBtYM70xyK4CRQ6TyMGm+V+W0SjOUNmdGZ9122jfGGiPy UBIQ0LolHiegxSH9R8Gd9yq1ffYl/F33ZV7vFoy6DsKf++2OB7foa/NSC3v1ZtRb Q== Received: from gcc-mail-mx-001.na.plexus.com (outbound.plexus.com [64.215.193.254]) by mx0b-0046e701.pphosted.com (PPS) with ESMTPS id 3yjyu387kk-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 23:17:51 +0000 (GMT) Received: from gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) by gcc-mail-mx-001.na.plexus.com (10.255.51.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 5 Jun 2024 23:17:48 +0000 Received: from LNDCL34533.neenah.na.plexus.com (10.255.48.203) by gcc-mail-mx-004.Na.Plexus.com (10.255.51.224) with Microsoft SMTP Server id 15.1.2507.37 via Frontend Transport; Wed, 5 Jun 2024 23:17:48 +0000 From: Danny Kaehn Date: Wed, 5 Jun 2024 18:12:47 -0500 Subject: [PATCH v11 4/4] HID: cp2112: Configure I2C Bus Speed from Firmware Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240605-cp2112-dt-v11-4-d55f0f945a62@plexus.com> References: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> In-Reply-To: <20240605-cp2112-dt-v11-0-d55f0f945a62@plexus.com> To: Rob Herring , Krzysztof Kozlowski , Benjamin Tissoires , Andy Shevchenko , Danny Kaehn CC: Jiri Kosina , , , Dmitry Torokhov , Bartosz Golaszewski , Ethan Twardy X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717629180; l=1099; i=danny.kaehn@plexus.com; s=20240605; h=from:subject:message-id; bh=iXIn4/cfpRBfQSLNVlHO1LCS5qH4+6FWhqutMxFO+hY=; b=aRkxPpiuxFKqA/yJgeKE7Id0yHH0EiaeA2wNYRz2ylGBBU5qUEY6JBpzZMS1DhA4sgSs0ejc5 WptPlo63cADAtRh9vdAkGdBwodkbrD3iliYosXS1mZ99mdwp9XUpjpk X-Developer-Key: i=danny.kaehn@plexus.com; a=ed25519; pk=+a/HbfS1U7uuw+5dRHN5PsUDyPWbx4dXDnblK41GI2s= X-Proofpoint-GUID: asXZZwh37Y5Y9YZpp8b3d8G_SVAax8fv X-Proofpoint-ORIG-GUID: asXZZwh37Y5Y9YZpp8b3d8G_SVAax8fv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406050175 Now that the I2C adapter on the CP2112 can have an associated firmware node, set the bus speed based on firmware configuration Signed-off-by: Danny Kaehn --- drivers/hid/hid-cp2112.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index b78d81275065..547c2cbd410f 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1213,6 +1213,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) struct cp2112_smbus_config_report config; struct fwnode_handle *child; struct gpio_irq_chip *girq; + struct i2c_timings timings; const char *name; u32 addr; int ret; @@ -1293,6 +1294,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),