From patchwork Fri Jan 19 12:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 189544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp985887dyb; Fri, 19 Jan 2024 04:59:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRveIFSw66FxNlYdlHCMbyuOLMvB7P9+EJugEC1jD0DBM34GRZZD7wpOXLDXt2R99qrKrn X-Received: by 2002:a50:9e6b:0:b0:558:b5d0:e77a with SMTP id z98-20020a509e6b000000b00558b5d0e77amr1057623ede.36.1705669170395; Fri, 19 Jan 2024 04:59:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705669170; cv=pass; d=google.com; s=arc-20160816; b=ZJX8dduok1o7/bb7rAKEbkHbGojaO+xL8NS9suiappje8xpuRrHW8L3NzVs2GRh2BG CumbBkJvSRJMw+HVzpWbOfZSjx/1EgwZU/0wwwrXZI+GrgWoC3GFEmkIo90vN6qY6r7B ySyFi0YrIVeRN6bZyv8xRMGEijhNh9EHh7hJHoEFza9WcgXINX0Fcey+v5DFBdzeet5R X9RMztVUynStZWi/nn5hDILQ74gfS1M08eNSsk+EQeTb9ou001s70SWaXFPiRFxAxYIp a6aPCnoy4W/RMs+8imPuQqIO6+KIsczx7z3x0JQTL70JAiudsNW+S+jLjACI2n3S8Ijh mpOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SKHbaajHnQvvPjqGOqfRSPnn9K+Y+EmUMUlxyszHpJA=; fh=O+hxQb1tPiWW366IuM3Ct7PQxz5i8S3IpT0spXRM4/E=; b=UwcugSnGCaMPqdBLHh1tA4boGSIOVuCEFoM2n5H5YrmTO3cKXQIpdjOAiXsM2/fg69 ykhresE6AUy5a5I7QLzdY/a3UZz8qdWATBQefP0xKnK04DYqAHf7i3nQo9qz91ayI3We GTJPoDTS+utel1T1MDj7A4HpDPcLgc//xQGrt8ku3kpZ8HVv8ic15GFyhGCF2pjN/Tsl pXsHSeYCxB9CHp4ZN9T8eJBkWJCURk8AJyqNBqaCJt3JAHBNF7sBOR15vGt3wIb621i+ 05l8iBHFnKfE+DUPWCCsZvhJyCHmHZCDi2o/7bQTlQpI7rNhXrfmhty8R9qrWJj+gwQC GARw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HGOGU6Uz; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-31152-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31152-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p13-20020a05640243cd00b0055946387477si5260067edc.605.2024.01.19.04.59.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 04:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31152-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HGOGU6Uz; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-31152-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31152-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0C2B31F22D62 for ; Fri, 19 Jan 2024 12:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7F9A5381E; Fri, 19 Jan 2024 12:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="HGOGU6Uz" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 B6FAE3C470; Fri, 19 Jan 2024 12:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669101; cv=none; b=DGUyF/yuFyLJpR88IAYzUszQsBtmjLsMzDyl8BWh4BuKwNACFBge+IxuY4sP6Gsfe34IEZeCZBoPIoCyWPinFD/sTr7k7OHs8xL8Uqn4wNFcgvkQYXcaeZ57Hl9NyVOHE4hkSAR6U4PlJmoqUK87POoVb0cV2X05k7gymtx9SzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669101; c=relaxed/simple; bh=yMBnHD84devz8pBb0bWiL0F28mWeot+MVGjDOv5Z7as=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VOs1824emG6xxXOQ7s19HF/VC/ww6KDHz2+lz5s72NOC4gOYQFk6JtvpL7kHbgkNhkqu7pytNFXt0hlaBbNRlpWx4d47AMkDpj/igdtXNztZxU5IeP9+ATU2+dEF4aeQvPzpKa4AVqLrMHKlN0CiJQAeLC2YzM+7ANIDyQrKTiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=HGOGU6Uz; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705669098; bh=yMBnHD84devz8pBb0bWiL0F28mWeot+MVGjDOv5Z7as=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HGOGU6UzfoCntF4nff5F3P7Kmb4VSOuGSAJcJt5rGkh7SLFwKkhZELITmVDexpyMy 5jvj5EgS8n3dlezI1Uvk7WRMFjvav5UPYoT78yGrDKncLZd+OmCifztXmolRKsyT5M DAxcRt8/OEBxc51p1n+r6aEcc17NRbdwMxjvYmtfwxxVagPJKeAXbccYQGLhs7+ocF IMdxgebaGpIoKktyclXXGyPmkV8f4hpkv40DSGeVhtYDQ+7yxBe4cZe2WuCfsTPTMV avtiBPrbc9+jP5Aygx1dfIqi60mi83XJbev1FAbF/fJQmbx3m38NPGRgjJ/GV3YfpA wZgML5/d9XoRA== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id B54BB3781FF2; Fri, 19 Jan 2024 12:58:16 +0000 (UTC) From: AngeloGioacchino Del Regno To: gregkh@linuxfoundation.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, heikki.krogerus@linux.intel.com, matthias.bgg@gmail.com, dmitry.baryshkov@linaro.org, neil.armstrong@linaro.org, andersson@kernel.org, nathan@kernel.org, luca.weiss@fairphone.com, tianping.fang@mediatek.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 1/2] dt-bindings: usb: Introduce ITE IT5205 Alt. Mode Passive MUX Date: Fri, 19 Jan 2024 13:58:11 +0100 Message-ID: <20240119125812.239197-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119125812.239197-1-angelogioacchino.delregno@collabora.com> References: <20240119125812.239197-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788523755798947830 X-GMAIL-MSGID: 1788523755798947830 Introduce a binding for the ITE IT5205 Alternate Mode Passive MUX, used for connecting, disconnecting and switching orientation and control the SBU signals for alternate modes on USB Type-C ports. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Conor Dooley --- .../devicetree/bindings/usb/ite,it5205.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ite,it5205.yaml diff --git a/Documentation/devicetree/bindings/usb/ite,it5205.yaml b/Documentation/devicetree/bindings/usb/ite,it5205.yaml new file mode 100644 index 000000000000..36ec4251b5f2 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/ite,it5205.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ite,it5205.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ITE IT5202 Type-C USB Alternate Mode Passive MUX + +maintainers: + - AngeloGioacchino Del Regno + - Tianping Fang + +properties: + compatible: + const: ite,it5205 + + reg: + maxItems: 1 + + vcc-supply: + description: Power supply for VCC pin (3.3V) + + mode-switch: + description: Flag the port as possible handle of altmode switching + type: boolean + + orientation-switch: + description: Flag the port as possible handler of orientation switching + type: boolean + + ite,ovp-enable: + description: Enable Over Voltage Protection functionality + type: boolean + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + A port node to link the IT5205 to a TypeC controller for the purpose of + handling altmode muxing and orientation switching. + +required: + - compatible + - reg + - orientation-switch + - port + +additionalProperties: false + +examples: + - | + #include + i2c2 { + #address-cells = <1>; + #size-cells = <0>; + + typec-mux@48 { + compatible = "ite,it5205"; + reg = <0x48>; + + mode-switch; + orientation-switch; + + vcc-supply = <&mt6359_vibr_ldo_reg>; + + port { + it5205_usbss_sbu: endpoint { + remote-endpoint = <&typec_controller>; + }; + }; + }; + }; +... From patchwork Fri Jan 19 12:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 189546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp985984dyb; Fri, 19 Jan 2024 04:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpVfVk4+x7oTlsyQC7Twj8gf5SCOZOsQg7C2/KTbe1Slu/78To5fO8eLKbeC0sGUZ+KzEL X-Received: by 2002:a0c:cd12:0:b0:681:7439:5a52 with SMTP id b18-20020a0ccd12000000b0068174395a52mr2243036qvm.4.1705669183862; Fri, 19 Jan 2024 04:59:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705669183; cv=pass; d=google.com; s=arc-20160816; b=yBgx12d1pAu9pKReL9e2C3fZ7iCU82r3w2bV410lu/XtO1axnAGfvxLvDh+jaDIcsa ynvaWvk5p8mpgVsJn2D8NaMRhXyqSwDNlP4DHUHwltBoekikchhoF+h6gNMUxYAPcDwH 7H3VzQObKUUtBPvvAOL6tJiYG5u/FM4lIcn/oEbW6czTAgPoA31nl8Y6mjbR0jBkRnSA DEz9ZYgVHv70jIrwN4xHdcKxGiIH45amjkX17wTzspiRSUMT00spgjC+vzCeCICsz/W/ pwMSCRGWDZc10TBAE6a+f7XnVoa77ZQwycfwjjHohzhLQDmFnLEvSDlVvLciMJohTzXl 83Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XQjxeAg4FMlAR2AMfr+/SzZ5fjjHHh8St6fsVL7XDT8=; fh=O+hxQb1tPiWW366IuM3Ct7PQxz5i8S3IpT0spXRM4/E=; b=UmIPV4ndtxTV40lu0dwkha4+nOejOX8h2rdxmA7tDH93fgDMMST51YREs1QYbu1uOH WwBQ609uTELy7gbEmfYU0/BaqcPz8GgAkCySKOQ5b0KaTYiEfIZwZie8V0qn2pWp6IX9 53+6ll7LhX58m5LngrSdY8tx/rndB2yuRDfAChIQdZcEz07oEm8Pv55DaGwFK9lkXlo/ 8gLkVenqvmplVmDxLT0lFgdJCKQVJ/NsNMOpbWqaOPuJHu/a1EsTz9VZTcbMtthklQhv FVEs24QZLTaL8MTR1jbI8Xc0Y5lEKmlF+sphjRG4BFgXHXyqRt6HQiPlkXBJbCYqbjwT zucg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=N2P9Sc6B; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-31153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31153-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s7-20020a0cdc07000000b0068173b3b07asi7230805qvk.430.2024.01.19.04.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 04:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=N2P9Sc6B; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-31153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31153-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 960D11C21C7A for ; Fri, 19 Jan 2024 12:59:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6D0853E1A; Fri, 19 Jan 2024 12:58:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="N2P9Sc6B" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 246DF524BF; Fri, 19 Jan 2024 12:58:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669102; cv=none; b=GR+Zb2C+AZPOwozmJPV2igG341NvsobSn95BbtJAlkjD3B98UtXhRaXzwI/E8CDUWnLIqYuyawHjbLT7z72KuBPTELRGnksTPwaAKo6xowFlFzuU+ubcMH1Igr8nQgCeEVNiN9/M4IAJf5aUM6/pM4/TkpPlqHHv6K1s09qd1HA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669102; c=relaxed/simple; bh=bRnM9eljKI9massoRsV14doqnV7kMIldV5Ltjnszp4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VrDiO671Ljs0LRm7RDkeFuPbXbuaO6wcvHRUXdd2FowALrFBYlWB29WBsLG9MGlBKSDMveMc0mmE29kjIutpqIjfUAiq3T47nBGlSw6JX2SBtfg7rlKSOu7mKLzWVF55/nPUaEXGTbDG4P1Egf/MEjWXI8wqa6hWZW3cTUjrL+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=N2P9Sc6B; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705669099; bh=bRnM9eljKI9massoRsV14doqnV7kMIldV5Ltjnszp4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N2P9Sc6BGA+TNzE9uQk4cQTWX9iyv+LBSg0ELkU1/f1Qd4Ug3tYuDmM3bJO5P9wn7 iT8ClB2U3NTMPOgMNw/Y5EMVFIcP4EzKXtCpXH4MpTxffTuA9AQsoicDMskiRy5zpO dRbb7JWm7W+OC9Nj465yM9A4SJnwUFEuaPSB5MV0K/F513GFuDdIhMbs+WpcVYInxy rVuNFucuoXm4vdRyRsvx7JfESOXOyX39eqzzE6GVNglUNcQZpQGTtqTYQGwSXYaN7P raDJTMOOiWQeRe322exIU3drq5kNmBf4+sui9a0Gtwu/01eLhw64fyFoxUr0MEswBL bshMMphGXwDdA== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 331E4378207E; Fri, 19 Jan 2024 12:58:18 +0000 (UTC) From: AngeloGioacchino Del Regno To: gregkh@linuxfoundation.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, heikki.krogerus@linux.intel.com, matthias.bgg@gmail.com, dmitry.baryshkov@linaro.org, neil.armstrong@linaro.org, andersson@kernel.org, nathan@kernel.org, luca.weiss@fairphone.com, tianping.fang@mediatek.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 2/2] usb: typec: mux: Add ITE IT5205 Alternate Mode Passive MUX driver Date: Fri, 19 Jan 2024 13:58:12 +0100 Message-ID: <20240119125812.239197-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119125812.239197-1-angelogioacchino.delregno@collabora.com> References: <20240119125812.239197-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788523769940317814 X-GMAIL-MSGID: 1788523769940317814 The ITE IT5202 is a USB Type-C Alternate Mode Passive MUX, used for muxing the SBU lines of a Type-C port with DisplayPort altmode and also providing an orientation switch. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Dmitry Baryshkov --- drivers/usb/typec/mux/Kconfig | 10 ++ drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/it5205.c | 294 +++++++++++++++++++++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 drivers/usb/typec/mux/it5205.c diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index d2cb5e733e57..399c7b0983df 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -36,6 +36,16 @@ config TYPEC_MUX_INTEL_PMC control the USB role switch and also the multiplexer/demultiplexer switches used with USB Type-C Alternate Modes. +config TYPEC_MUX_IT5205 + tristate "ITE IT5205 Type-C USB Alt Mode Passive MUX driver" + depends on I2C + select REGMAP_I2C + help + Driver for the ITE IT5205 Type-C USB Alternate Mode Passive MUX + which provides support for muxing DisplayPort and sideband signals + on a common USB Type-C connector. + If compiled as a module, the module will be named it5205. + config TYPEC_MUX_NB7VPQ904M tristate "On Semiconductor NB7VPQ904M Type-C redriver driver" depends on I2C diff --git a/drivers/usb/typec/mux/Makefile b/drivers/usb/typec/mux/Makefile index 57dc9ac6f8dc..bb96f30267af 100644 --- a/drivers/usb/typec/mux/Makefile +++ b/drivers/usb/typec/mux/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_TYPEC_MUX_FSA4480) += fsa4480.o obj-$(CONFIG_TYPEC_MUX_GPIO_SBU) += gpio-sbu-mux.o obj-$(CONFIG_TYPEC_MUX_PI3USB30532) += pi3usb30532.o obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o +obj-$(CONFIG_TYPEC_MUX_IT5205) += it5205.o obj-$(CONFIG_TYPEC_MUX_NB7VPQ904M) += nb7vpq904m.o obj-$(CONFIG_TYPEC_MUX_PTN36502) += ptn36502.o obj-$(CONFIG_TYPEC_MUX_WCD939X_USBSS) += wcd939x-usbss.o diff --git a/drivers/usb/typec/mux/it5205.c b/drivers/usb/typec/mux/it5205.c new file mode 100644 index 000000000000..b68535f80ceb --- /dev/null +++ b/drivers/usb/typec/mux/it5205.c @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ITE IT5205 Type-C USB alternate mode passive mux + * + * Copyright (c) 2020 MediaTek Inc. + * Copyright (c) 2024 Collabora Ltd. + * AngeloGioacchino Del Regno + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IT5205_REG_CHIP_ID(x) (0x4 + (x)) +#define IT5205FN_CHIP_ID 0x35323035 /* "5205" */ + +/* MUX power down register */ +#define IT5205_REG_MUXPDR 0x10 +#define IT5205_MUX_POWER_DOWN BIT(0) + +/* MUX control register */ +#define IT5205_REG_MUXCR 0x11 +#define IT5205_POLARITY_INVERTED BIT(4) +#define IT5205_DP_USB_CTRL_MASK GENMASK(3, 0) +#define IT5205_DP 0x0f +#define IT5205_DP_USB 0x03 +#define IT5205_USB 0x07 + +/* Vref Select Register */ +#define IT5205_REG_VSR 0x10 +#define IT5205_VREF_SELECT_MASK GENMASK(5, 4) +#define IT5205_VREF_SELECT_3_3V 0x00 +#define IT5205_VREF_SELECT_OFF 0x20 + +/* CSBU Over Voltage Protection Register */ +#define IT5205_REG_CSBUOVPSR 0x1e +#define IT5205_OVP_SELECT_MASK GENMASK(5, 4) +#define IT5205_OVP_3_90V 0x00 +#define IT5205_OVP_3_68V 0x10 +#define IT5205_OVP_3_62V 0x20 +#define IT5205_OVP_3_57V 0x30 + +/* CSBU Switch Register */ +#define IT5205_REG_CSBUSR 0x22 +#define IT5205_CSBUSR_SWITCH BIT(0) + +/* Interrupt Switch Register */ +#define IT5205_REG_ISR 0x25 +#define IT5205_ISR_CSBU_MASK BIT(4) +#define IT5205_ISR_CSBU_OVP BIT(0) + +struct it5205 { + struct i2c_client *client; + struct regmap *regmap; + struct typec_switch_dev *sw; + struct typec_mux_dev *mux; +}; + +static int it5205_switch_set(struct typec_switch_dev *sw, enum typec_orientation orientation) +{ + struct it5205 *it = typec_switch_get_drvdata(sw); + + switch (orientation) { + case TYPEC_ORIENTATION_NORMAL: + regmap_update_bits(it->regmap, IT5205_REG_MUXCR, + IT5205_POLARITY_INVERTED, 0); + break; + case TYPEC_ORIENTATION_REVERSE: + regmap_update_bits(it->regmap, IT5205_REG_MUXCR, + IT5205_POLARITY_INVERTED, IT5205_POLARITY_INVERTED); + break; + case TYPEC_ORIENTATION_NONE: + fallthrough; + default: + regmap_write(it->regmap, IT5205_REG_MUXCR, 0); + break; + } + + return 0; +} + +static int it5205_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) +{ + struct it5205 *it = typec_mux_get_drvdata(mux); + u8 val; + + if (state->mode >= TYPEC_STATE_MODAL && + state->alt->svid != USB_TYPEC_DP_SID) + return -EINVAL; + + switch (state->mode) { + case TYPEC_STATE_USB: + val = IT5205_USB; + break; + case TYPEC_DP_STATE_C: + fallthrough; + case TYPEC_DP_STATE_E: + val = IT5205_DP; + break; + case TYPEC_DP_STATE_D: + val = IT5205_DP_USB; + break; + case TYPEC_STATE_SAFE: + fallthrough; + default: + val = 0; + break; + } + + return regmap_update_bits(it->regmap, IT5205_REG_MUXCR, + IT5205_DP_USB_CTRL_MASK, val); +} + +static irqreturn_t it5205_irq_handler(int irq, void *data) +{ + struct it5205 *it = data; + int ret; + u32 val; + + ret = regmap_read(it->regmap, IT5205_REG_ISR, &val); + if (ret) + return IRQ_NONE; + + if (val & IT5205_ISR_CSBU_OVP) { + dev_warn(&it->client->dev, "Overvoltage detected!\n"); + + /* Reset CSBU */ + regmap_update_bits(it->regmap, IT5205_REG_CSBUSR, + IT5205_CSBUSR_SWITCH, 0); + regmap_update_bits(it->regmap, IT5205_REG_CSBUSR, + IT5205_CSBUSR_SWITCH, IT5205_CSBUSR_SWITCH); + } + + return IRQ_HANDLED; +} + +static void it5205_enable_ovp(struct it5205 *it) +{ + /* Select Vref 3.3v */ + regmap_update_bits(it->regmap, IT5205_REG_VSR, + IT5205_VREF_SELECT_MASK, IT5205_VREF_SELECT_3_3V); + + /* Trigger OVP at 3.68V */ + regmap_update_bits(it->regmap, IT5205_REG_CSBUOVPSR, + IT5205_OVP_SELECT_MASK, IT5205_OVP_3_68V); + + /* Unmask OVP interrupt */ + regmap_update_bits(it->regmap, IT5205_REG_ISR, + IT5205_ISR_CSBU_MASK, 0); + + /* Enable CSBU Interrupt */ + regmap_update_bits(it->regmap, IT5205_REG_CSBUSR, + IT5205_CSBUSR_SWITCH, IT5205_CSBUSR_SWITCH); +} + +static const struct regmap_config it5205_regmap = { + .max_register = 0x2f, + .reg_bits = 8, + .val_bits = 8, +}; + +static int it5205_probe(struct i2c_client *client) +{ + struct typec_switch_desc sw_desc = { }; + struct typec_mux_desc mux_desc = { }; + struct device *dev = &client->dev; + struct it5205 *it; + u32 val, chipid = 0; + int i, ret; + + it = devm_kzalloc(dev, sizeof(*it), GFP_KERNEL); + if (!it) + return -ENOMEM; + + ret = devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulator\n"); + + it->client = client; + + it->regmap = devm_regmap_init_i2c(client, &it5205_regmap); + if (IS_ERR(it->regmap)) + return dev_err_probe(dev, PTR_ERR(it->regmap), + "Failed to init regmap\n"); + + /* IT5205 needs a long time to power up after enabling regulator */ + msleep(50); + + /* Unset poweroff bit */ + ret = regmap_write(it->regmap, IT5205_REG_MUXPDR, 0); + if (ret) + return dev_err_probe(dev, ret, "Failed to set power on\n"); + + /* Read the 32 bits ChipID */ + for (i = 3; i >= 0; i--) { + ret = regmap_read(it->regmap, IT5205_REG_CHIP_ID(i), &val); + if (ret) + return ret; + + chipid |= val << (i * 8); + } + + if (chipid != IT5205FN_CHIP_ID) + return dev_err_probe(dev, -EINVAL, + "Unknown ChipID 0x%x\n", chipid); + + /* Initialize as USB mode with default (non-inverted) polarity */ + ret = regmap_write(it->regmap, IT5205_REG_MUXCR, IT5205_USB); + if (ret) + return dev_err_probe(dev, ret, "Cannot set mode to USB\n"); + + sw_desc.drvdata = it; + sw_desc.fwnode = dev_fwnode(dev); + sw_desc.set = it5205_switch_set; + + it->sw = typec_switch_register(dev, &sw_desc); + if (IS_ERR(it->sw)) + return dev_err_probe(dev, PTR_ERR(it->sw), + "failed to register typec switch\n"); + + mux_desc.drvdata = it; + mux_desc.fwnode = dev_fwnode(dev); + mux_desc.set = it5205_mux_set; + + it->mux = typec_mux_register(dev, &mux_desc); + if (IS_ERR(it->mux)) { + typec_switch_unregister(it->sw); + return dev_err_probe(dev, PTR_ERR(it->mux), + "failed to register typec mux\n"); + } + + i2c_set_clientdata(client, it); + + if (of_property_read_bool(dev->of_node, "ite,ovp-enable") && client->irq) { + it5205_enable_ovp(it); + + ret = devm_request_threaded_irq(dev, client->irq, NULL, + it5205_irq_handler, + IRQF_ONESHOT, dev_name(dev), it); + if (ret) { + typec_mux_unregister(it->mux); + typec_switch_unregister(it->sw); + return dev_err_probe(dev, ret, "Failed to request irq\n"); + } + } + + return 0; +} + +static void it5205_remove(struct i2c_client *client) +{ + struct it5205 *it = i2c_get_clientdata(client); + + typec_mux_unregister(it->mux); + typec_switch_unregister(it->sw); +} + +static const struct i2c_device_id it5205_table[] = { + { "it5205" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, it5205_table); + +static const struct of_device_id it5205_of_table[] = { + { .compatible = "ite,it5205" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, it5205_match_table); + +static struct i2c_driver it5205_driver = { + .driver = { + .name = "it5205", + .of_match_table = it5205_of_table, + }, + .probe = it5205_probe, + .remove = it5205_remove, + .id_table = it5205_table, +}; +module_i2c_driver(it5205_driver); + +MODULE_AUTHOR("Tianping Fang "); +MODULE_AUTHOR("AngeloGioacchino Del Regno "); +MODULE_DESCRIPTION("ITE IT5205 alternate mode passive MUX driver"); +MODULE_LICENSE("GPL");