From nobody Mon Feb 9 10:52:59 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1C9C246798; Thu, 15 Jan 2026 06:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459425; cv=none; b=nCLeazT53/G5zneo1gPpC++zcAje9683otwuIdRyTuKmXezrBbPfjdjZNUAu4LGOpxFjwCzfEeVlSbwuQDu05tugPbr51P3Ulhu+dmq7iH+mmQkrYmWbn4DaY/PFtkj3f25Weiroi3mRkgMWoJH+DO3bZ1rWJTEUgKf+pLCtHU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459425; c=relaxed/simple; bh=PCbBvucDj+zutptctE4rfxrZKax2o/ZnTSOHfz4l0Eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lHxiXrEuUpgZM0rXNIKMucRGX0/YpMIwu+AW100IlNxmyTJpIs4CQqAUGkad4OWrCIvJSqrNmWx4OFpD/d63LFO997nx52PsO5VBCP0Hnc/1ochKprqH99x/M8KKnV1PI86xTO9t5dWrEFb+i/5lC3NFws9KS0Uiufw5PsTmcMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from duge-virtual-machine (unknown [223.160.207.69]) by APP-01 (Coremail) with SMTP id qwCowAAn0GtWjGhpw5fDBA--.30809S3; Thu, 15 Jan 2026 14:42:42 +0800 (CST) From: Jiayu Du To: conor@kernel.org Cc: vkoul@kernel.org, neil.armstrong@linaro.org, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, jiayu.riscv@isrc.iscas.ac.cn, 18771902331@163.com, cyy@cyyself.name, TroyMitchell988@gmail.com, kingxukai@zohomail.com, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, gaohan@iscas.ac.cn Subject: [PATCH v2 1/4] dt-bindings: phy: Add Canaan K230 USB PHY Date: Thu, 15 Jan 2026 14:42:19 +0800 Message-ID: <20260115064223.21926-2-jiayu.riscv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> References: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAAn0GtWjGhpw5fDBA--.30809S3 X-Coremail-Antispam: 1UD129KBjvJXoW7CrWrJw4fCr18KrWUtryrZwb_yoW8GF48pa s7uF92grsagF4ayws3KF18Ca43ArWkCFyfKr13t34UKF1DW3WYy3yakry5Zw1UJFs7CFWj vFZa9Fy7Kr1qyw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc7CjxVAaw2AFwI0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAI cVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7sRRFks3UUUUU== X-CM-SenderInfo: 5mld534oul2uny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" K230 SoC USB PHY requires configuring registers for control and configuration. Add USB phy bindings for K230 SoC. Signed-off-by: Jiayu Du Reviewed-by: Rob Herring (Arm) --- .../bindings/phy/canaan,k230-usb-phy.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/canaan,k230-usb-p= hy.yaml diff --git a/Documentation/devicetree/bindings/phy/canaan,k230-usb-phy.yaml= b/Documentation/devicetree/bindings/phy/canaan,k230-usb-phy.yaml new file mode 100644 index 000000000000..be54efd612ac --- /dev/null +++ b/Documentation/devicetree/bindings/phy/canaan,k230-usb-phy.yaml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/canaan,k230-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Canaan K230 USB2.0 PHY + +maintainers: + - Jiayu Du + +properties: + compatible: + const: canaan,k230-usb-phy + + reg: + maxItems: 1 + + "#phy-cells": + const: 1 + +required: + - compatible + - reg + - "#phy-cells" + +additionalProperties: false + +examples: + - | + usbphy: usb-phy@91585000 { + compatible =3D "canaan,k230-usb-phy"; + reg =3D <0x0 0x91585000 0x0 0x400>; + #phy-cells =3D <1>; + }; --=20 2.52.0 From nobody Mon Feb 9 10:52:59 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F38032D0620; Thu, 15 Jan 2026 06:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459421; cv=none; b=duc4fmxjRlRcEVK3m5Z7JZHV2qE9UuzPf+oNrDv5JYOaQ96I6fDPKdpBpb+ZTJKo73Zns1ng7u7RS7LOWAesmfQeO3ZlVpdwpSz/I17UOVZ5dwljfCfsZyt0WKKGDPqf0ACO0Tk9LjRlq9g+dpYejRpau264qcjU9ehh6KkXxFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459421; c=relaxed/simple; bh=QFRlpOrF1GoMvkpqnwoBl3pjQJ98KpiTbXUh4J+HAIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i4xaaJ/DdreBSKAgigvF+ZcvzaVk99lgd6XvSsGrM8crHHPFonkYvNzEG++W9DH55VBgxpSX6WWL4ECEs0Dqiwbu28+9UWc5Gocu756RCjsny2lDklxfOLgnl5nOyJXxnolM+VScARTVFPxkQFBMjMmdUHwmRfo/jQtdSInmw0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from duge-virtual-machine (unknown [223.160.207.69]) by APP-01 (Coremail) with SMTP id qwCowAAn0GtWjGhpw5fDBA--.30809S4; Thu, 15 Jan 2026 14:42:57 +0800 (CST) From: Jiayu Du To: conor@kernel.org Cc: vkoul@kernel.org, neil.armstrong@linaro.org, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, jiayu.riscv@isrc.iscas.ac.cn, 18771902331@163.com, cyy@cyyself.name, TroyMitchell988@gmail.com, kingxukai@zohomail.com, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, gaohan@iscas.ac.cn Subject: [PATCH v2 2/4] dt-bindings: usb: dwc2: Add support for Canaan K230 SoC Date: Thu, 15 Jan 2026 14:42:20 +0800 Message-ID: <20260115064223.21926-3-jiayu.riscv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> References: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAAn0GtWjGhpw5fDBA--.30809S4 X-Coremail-Antispam: 1UD129KBjvdXoW7JrW3JFWkWw4DZw1ruF1xXwb_yoW3uFg_Z3 ZruF4rCFWDJFySqr4qyFs2kF15Zw47trn7uF1qqFn8Cw4j9ws8Wa4ktw13Ar1rCF4Uurn5 urs3JrZFgFs7WjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbv8FF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84 ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2 KfnxnUUI43ZEXa7sRRnYFPUUUUU== X-CM-SenderInfo: 5mld534oul2uny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" Add 'canaan,k230-usb' compatible string with 'snps,dwc2' as fallback for the DWC2 IP which is used by Canaan K230. Signed-off-by: Jiayu Du --- Documentation/devicetree/bindings/usb/dwc2.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc2.yaml b/Documentatio= n/devicetree/bindings/usb/dwc2.yaml index 6c3a10991b8b..352487c6392a 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.yaml +++ b/Documentation/devicetree/bindings/usb/dwc2.yaml @@ -17,6 +17,9 @@ properties: compatible: oneOf: - const: brcm,bcm2835-usb + - items: + - const: canaan,k230-usb + - const: snps,dwc2 - const: hisilicon,hi6220-usb - const: ingenic,jz4775-otg - const: ingenic,jz4780-otg --=20 2.52.0 From nobody Mon Feb 9 10:52:59 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE8F92DC767; Thu, 15 Jan 2026 06:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459427; cv=none; b=an5it2UXGjHPwWdwqzeqk3tKUytFl1yS1XhqnJv9h6kQIHzi2OCI2OMOnUrgh+yJ6Vp1qI3GzDItIHUX3JoKreZkJsTw6v/3kB6jV2lzJ7Nsdcor6yCUgvlqGExAHSp1HFN4S6AWA4We3uI5qA6MbLWAcbyjCaGmdmYHba/2+o0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459427; c=relaxed/simple; bh=G4mAmnpa9oUjVGLKfLAYHitBYxirYXE9YxiZGYJoNRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IsFEtwbqlJE8ymAxr+D7o7DlRjyUr6cBVlRjirw/iN61a4PVrO2V+lGhXyRELfuXWQIg0OTqd+go1pw34uA3X6YuikVTCyqupqkw5deugq7rOZFpfOYbHdm3OaLcYmc+Gf+l87Ki/InkwHBb1VHckEVMtL+MPLisuaM+YQHJoXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from duge-virtual-machine (unknown [223.160.207.69]) by APP-01 (Coremail) with SMTP id qwCowAAn0GtWjGhpw5fDBA--.30809S5; Thu, 15 Jan 2026 14:43:01 +0800 (CST) From: Jiayu Du To: conor@kernel.org Cc: vkoul@kernel.org, neil.armstrong@linaro.org, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, jiayu.riscv@isrc.iscas.ac.cn, 18771902331@163.com, cyy@cyyself.name, TroyMitchell988@gmail.com, kingxukai@zohomail.com, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, gaohan@iscas.ac.cn Subject: [PATCH v2 3/4] phy: usb: Add driver for Canaan K230 USB 2.0 PHY Date: Thu, 15 Jan 2026 14:42:21 +0800 Message-ID: <20260115064223.21926-4-jiayu.riscv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> References: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAAn0GtWjGhpw5fDBA--.30809S5 X-Coremail-Antispam: 1UD129KBjvJXoW3Kw47tw4xuw15trWktFWkZwb_yoWDtw47pF WrA34fKrn7tF4fCw4xGFWDGFyFqanFyry7tw12k398XFy7tr1UZa4ftryrZrnYyFs8GrW3 t3Z8Xay29FsrCw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc7CjxVAaw2AFwI0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAI cVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVF xhVjvjDU0xZFpf9x0pRWv3bUUUUU= X-CM-SenderInfo: 5mld534oul2uny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" Add driver for the USB 2.0 PHY in Canaan K230 SoC, which supports PHY initialization and power management. Add Kconfig/Makefile under drivers/phy/canaan/. Signed-off-by: Jiayu Du --- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/canaan/Kconfig | 14 ++ drivers/phy/canaan/Makefile | 2 + drivers/phy/canaan/phy-k230-usb.c | 271 ++++++++++++++++++++++++++++++ 5 files changed, 289 insertions(+) create mode 100644 drivers/phy/canaan/Kconfig create mode 100644 drivers/phy/canaan/Makefile create mode 100644 drivers/phy/canaan/phy-k230-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 678dd0452f0a..95e630749350 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -105,6 +105,7 @@ source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" +source "drivers/phy/canaan/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig" source "drivers/phy/ingenic/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index bfb27fb5a494..f07c68f2e283 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -17,6 +17,7 @@ obj-y +=3D allwinner/ \ amlogic/ \ broadcom/ \ cadence/ \ + canaan/ \ freescale/ \ hisilicon/ \ ingenic/ \ diff --git a/drivers/phy/canaan/Kconfig b/drivers/phy/canaan/Kconfig new file mode 100644 index 000000000000..1ff8831846d5 --- /dev/null +++ b/drivers/phy/canaan/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Canaan platforms +# +config PHY_CANAAN_USB + tristate "Canaan USB2 PHY Driver" + depends on (ARCH_CANAAN || COMPILE_TEST) && OF + select GENERIC_PHY + help + Enable this driver to support the USB 2.0 PHY controller + on Canaan K230 RISC-V SoCs. This PHY controller + provides physical layer functionality for USB 2.0 devices. + If you have a Canaan K230 board and need USB 2.0 support, + say Y or M here. diff --git a/drivers/phy/canaan/Makefile b/drivers/phy/canaan/Makefile new file mode 100644 index 000000000000..d73857ba284e --- /dev/null +++ b/drivers/phy/canaan/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PHY_CANAAN_USB) +=3D phy-k230-usb.o diff --git a/drivers/phy/canaan/phy-k230-usb.c b/drivers/phy/canaan/phy-k23= 0-usb.c new file mode 100644 index 000000000000..e4bd98aa4e89 --- /dev/null +++ b/drivers/phy/canaan/phy-k230-usb.c @@ -0,0 +1,271 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Canaan usb PHY driver + * + * Copyright (C) 2025 Jiayu Du + */ + +#include +#include +#include +#include +#include + +#define CTL0_OFFSET 0x00 +#define CTL1_OFFSET 0x04 +#define TEST_CTL3_OFFSET 0x0c + +#define USB_IDPULLUP0 BIT(4) +#define USB_DMPULLDOWN0 BIT(8) +#define USB_DPPULLDOWN0 BIT(9) + +#define MAX_PHYS 2 + +/* USB control register 0 in HiSysConfig system controller */ +/* PLL Integral Path Tune */ +#define USB_CTL0_PLLITUNE_MASK GENMASK(23, 22) + +/* PLL Proportional Path Tune */ +#define USB_CTL0_PLLPTUNE_MASK GENMASK(21, 18) + +/* PLL Bandwidth Adjustment */ +#define USB_CTL0_PLLBTUNE_MASK GENMASK(17, 17) + +/* VReg18 Bypass Control */ +#define USB_CTL0_VREGBYPASS_MASK GENMASK(16, 16) + +/* Retention Mode Enable */ +#define USB_CTL0_RETENABLEN_MASK GENMASK(15, 15) + +/* Reserved Request Input */ +#define USB_CTL0_RESREQIN_MASK GENMASK(14, 14) + +/* External VBUS Valid Select */ +#define USB_CTL0_VBUSVLDEXTSEL0_MASK GENMASK(13, 13) + +/* OTG Block Disable Control */ +#define USB_CTL0_OTGDISABLE0_MASK GENMASK(12, 12) + +/* Drive VBUS Enable */ +#define USB_CTL0_DRVVBUS0_MASK GENMASK(11, 11) + +/* Autoresume Mode Enable */ +#define USB_CTL0_AUTORSMENB0_MASK GENMASK(10, 10) + +/* HS Transceiver Asynchronous Control */ +#define USB_CTL0_HSXCVREXTCTL0_MASK GENMASK(9, 9) + +/* USB 1.1 Transmit Data */ +#define USB_CTL0_FSDATAEXT0_MASK GENMASK(8, 8) + +/* USB 1.1 SE0 Generation */ +#define USB_CTL0_FSSE0EXT0_MASK GENMASK(7, 7) + +/* USB 1.1 Data Enable */ +#define USB_CTL0_TXENABLEN0_MASK GENMASK(6, 6) + +/* Disconnect Threshold */ +#define USB_CTL0_COMPDISTUNE0_MASK GENMASK(5, 3) + +/* Squelch Threshold */ +#define USB_CTL0_SQRXTUNE0_MASK GENMASK(2, 0) + +/* USB control register 1 in HiSysConfig system controller */ +/* Data Detect Voltage */ +#define USB_CTL1_VDATREFTUNE0_MASK GENMASK(23, 22) + +/* VBUS Valid Threshold */ +#define USB_CTL1_OTGTUNE0_MASK GENMASK(21, 19) + +/* Transmitter High-Speed Crossover */ +#define USB_CTL1_TXHSXVTUNE0_MASK GENMASK(18, 17) + +/* FS/LS Source Impedance */ +#define USB_CTL1_TXFSLSTUNE0_MASK GENMASK(16, 13) + +/* HS DC Voltage Level */ +#define USB_CTL1_TXVREFTUNE0_MASK GENMASK(12, 9) + +/* HS Transmitter Rise/Fall Time */ +#define USB_CTL1_TXRISETUNE0_MASK GENMASK(8, 7) + +/* USB Source Impedance */ +#define USB_CTL1_TXRESTUNE0_MASK GENMASK(6, 5) + +/* HS Transmitter Pre-Emphasis Current Control */ +#define USB_CTL1_TXPREEMPAMPTUNE0_MASK GENMASK(4, 3) + +/* HS Transmitter Pre-Emphasis Duration Control */ +#define USB_CTL1_TXPREEMPPULSETUNE0_MASK GENMASK(2, 2) + +/* charging detection */ +#define USB_CTL1_CHRGSRCPUENB0_MASK GENMASK(1, 0) + +#define K230_PHY_CTL0_VAL \ +( \ + FIELD_PREP(USB_CTL0_PLLITUNE_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_PLLPTUNE_MASK, 0xc) | \ + FIELD_PREP(USB_CTL0_PLLBTUNE_MASK, 0x1) | \ + FIELD_PREP(USB_CTL0_VREGBYPASS_MASK, 0x1) | \ + FIELD_PREP(USB_CTL0_RETENABLEN_MASK, 0x1) | \ + FIELD_PREP(USB_CTL0_RESREQIN_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_VBUSVLDEXTSEL0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_OTGDISABLE0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_DRVVBUS0_MASK, 0x1) | \ + FIELD_PREP(USB_CTL0_AUTORSMENB0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_HSXCVREXTCTL0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_FSDATAEXT0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_FSSE0EXT0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_TXENABLEN0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL0_COMPDISTUNE0_MASK, 0x3) | \ + FIELD_PREP(USB_CTL0_SQRXTUNE0_MASK, 0x3) \ +) + +#define K230_PHY_CTL1_VAL \ +( \ + FIELD_PREP(USB_CTL1_VDATREFTUNE0_MASK, 0x1) | \ + FIELD_PREP(USB_CTL1_OTGTUNE0_MASK, 0x3) | \ + FIELD_PREP(USB_CTL1_TXHSXVTUNE0_MASK, 0x3) | \ + FIELD_PREP(USB_CTL1_TXFSLSTUNE0_MASK, 0x3) | \ + FIELD_PREP(USB_CTL1_TXVREFTUNE0_MASK, 0x3) | \ + FIELD_PREP(USB_CTL1_TXRISETUNE0_MASK, 0x1) | \ + FIELD_PREP(USB_CTL1_TXRESTUNE0_MASK, 0x1) | \ + FIELD_PREP(USB_CTL1_TXPREEMPAMPTUNE0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL1_TXPREEMPPULSETUNE0_MASK, 0x0) | \ + FIELD_PREP(USB_CTL1_CHRGSRCPUENB0_MASK, 0x0) \ +) +struct k230_usb_phy_global { + u32 reg_test_offset[MAX_PHYS]; + u32 reg_ctl_offset[MAX_PHYS]; + void __iomem *base; +}; + +struct k230_usb_phy_instance { + struct k230_usb_phy_global *global; + int index; +}; + +static int k230_usb_phy_power_on(struct phy *_phy) +{ + struct k230_usb_phy_instance *phy_inst =3D phy_get_drvdata(_phy); + struct k230_usb_phy_global *global =3D phy_inst->global; + u32 val; + + writel(K230_PHY_CTL0_VAL, global->base + + global->reg_ctl_offset[phy_inst->index] + CTL0_OFFSET); + + writel(K230_PHY_CTL1_VAL, global->base + + global->reg_ctl_offset[phy_inst->index] + CTL1_OFFSET); + + val =3D readl(global->base + + global->reg_test_offset[phy_inst->index] + + TEST_CTL3_OFFSET); + + val |=3D USB_IDPULLUP0; + if (phy_inst->index =3D=3D 1) + val |=3D (USB_DMPULLDOWN0 | USB_DPPULLDOWN0); + else + val &=3D ~(USB_DMPULLDOWN0 | USB_DPPULLDOWN0); + + writel(val, global->base + + global->reg_test_offset[phy_inst->index] + + TEST_CTL3_OFFSET); + + return 0; +} + +static int k230_usb_phy_power_off(struct phy *_phy) +{ + struct k230_usb_phy_instance *phy_inst =3D phy_get_drvdata(_phy); + struct k230_usb_phy_global *global =3D phy_inst->global; + u32 val; + + val =3D readl(global->base + + global->reg_test_offset[phy_inst->index] + + TEST_CTL3_OFFSET); + + val &=3D ~(USB_DMPULLDOWN0 | USB_DPPULLDOWN0); + + writel(val, global->base + + global->reg_test_offset[phy_inst->index] + + TEST_CTL3_OFFSET); + + return 0; +} + +static const struct phy_ops k230_usb_phy_ops =3D { + .power_on =3D k230_usb_phy_power_on, + .power_off =3D k230_usb_phy_power_off, + .owner =3D THIS_MODULE, +}; + +static struct phy *k230_usb_phy_xlate(struct device *dev, + const struct of_phandle_args *args) +{ + struct k230_usb_phy_global *global =3D dev_get_drvdata(dev); + struct k230_usb_phy_instance *phy_inst; + struct phy *phy; + + if (args->args[0] >=3D MAX_PHYS) + return ERR_PTR(-EINVAL); + + phy_inst =3D devm_kzalloc(dev, sizeof(*phy_inst), GFP_KERNEL); + if (!phy_inst) + return ERR_PTR(-ENOMEM); + + phy_inst->global =3D global; + phy_inst->index =3D args->args[0]; + + phy =3D devm_phy_create(dev, NULL, &k230_usb_phy_ops); + if (IS_ERR(phy)) + return ERR_PTR(PTR_ERR(phy)); + + phy_set_drvdata(phy, phy_inst); + + return phy; +} + +static int k230_usb_phy_probe(struct platform_device *pdev) +{ + struct k230_usb_phy_global *global; + struct device *dev =3D &pdev->dev; + struct phy_provider *provider; + + global =3D devm_kzalloc(dev, sizeof(*global), GFP_KERNEL); + if (!global) + return -ENOMEM; + dev_set_drvdata(dev, global); + + global->base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(global->base)) + return dev_err_probe(dev, PTR_ERR(global->base), + "ioremap failed\n"); + + global->reg_test_offset[0] =3D 0x70; + global->reg_ctl_offset[0] =3D 0xb0; + global->reg_test_offset[1] =3D 0x90; + global->reg_ctl_offset[1] =3D 0xb8; + + provider =3D devm_of_phy_provider_register(dev, k230_usb_phy_xlate); + + return 0; +} + +static const struct of_device_id k230_usb_phy_of_match[] =3D { + { .compatible =3D "canaan,k230-usb-phy" }, + {} +}; +MODULE_DEVICE_TABLE(of, k230_usb_phy_of_match); + +static struct platform_driver k230_usb_phy_driver =3D { + .probe =3D k230_usb_phy_probe, + .driver =3D { + .name =3D "k230-usb-phy", + .of_match_table =3D k230_usb_phy_of_match, + }, +}; +module_platform_driver(k230_usb_phy_driver); + +MODULE_DESCRIPTION("Canaan Kendryte K230 USB 2.0 PHY driver"); +MODULE_AUTHOR("Jiayu Du "); +MODULE_LICENSE("GPL"); --=20 2.52.0 From nobody Mon Feb 9 10:52:59 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C8BE246798; Thu, 15 Jan 2026 06:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459429; cv=none; b=YiNRa6gvo4Fku122UjQsrIk//tQgTX3u83Ie+zMXZ9eVYAnDboubdiWrP69j6LRxDERgU1mIthcznUeAFwc0GaXzhUWSzAlI+zyXBnWrqPihEIy676scx0fEOCevLdx5I/qVKFqNS1+vODLsXu5ypUI7PxbmNUx1jbMlU9kCjKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459429; c=relaxed/simple; bh=8/WH8O7wukAw8VXt3i+oTo+Ql5h3pBg67X3wOlCMvgA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X22PmZDS7fe39+Ya4ItE363Bttzgk86nCWEB+mzDt3E5dg/llTWf1e0ZW9HnDGVNNE7w7KTf4arzfDvH6LlJcZ2dDKNLyL1H2aL+YL1aBt3cgpAImx+KFeyxGvHs5MdFjDAZeVohVvCFblRmct73600qkhbAhqgy2BX0VJyTRj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from duge-virtual-machine (unknown [223.160.207.69]) by APP-01 (Coremail) with SMTP id qwCowAAn0GtWjGhpw5fDBA--.30809S6; Thu, 15 Jan 2026 14:43:06 +0800 (CST) From: Jiayu Du To: conor@kernel.org Cc: vkoul@kernel.org, neil.armstrong@linaro.org, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, jiayu.riscv@isrc.iscas.ac.cn, 18771902331@163.com, cyy@cyyself.name, TroyMitchell988@gmail.com, kingxukai@zohomail.com, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, gaohan@iscas.ac.cn Subject: [PATCH v2 4/4] riscv: dts: canaan: Add syscon and USB nodes for K230 Date: Thu, 15 Jan 2026 14:42:22 +0800 Message-ID: <20260115064223.21926-5-jiayu.riscv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> References: <20260115064223.21926-1-jiayu.riscv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAAn0GtWjGhpw5fDBA--.30809S6 X-Coremail-Antispam: 1UD129KBjvJXoW7tF1xZr1fCrykZF47JFy5Jwb_yoW8tw4xp3 srCFZ8G3sagr4S93Wak34vgF1fGF4kGFyfWrn8AryUGr4UZas09w1fJ34fXFyUXw47J3y2 9F9YqryxKF4jyw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmv14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26r4j6F4UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_ Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x IIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_ Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8c xan2IY04v7MxkF7I0En4kS14v26r4a6rW5MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4U MIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJV WUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUv cSsGvfC2KfnxnUUI43ZEXa7sRRjg43UUUUU== X-CM-SenderInfo: 5mld534oul2uny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" Add top syscon and USB PHY subdevice nodes, USB0/USB1 dwc2 controller to K230 DTSI, and enable UART0 and USB0/USB1 in DshanPI DT. Signed-off-by: Jiayu Du --- .../boot/dts/canaan/k230-canmv-dshanpi.dts | 17 +++++++++ arch/riscv/boot/dts/canaan/k230.dtsi | 35 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/arch/riscv/boot/dts/canaan/k230-canmv-dshanpi.dts b/arch/riscv= /boot/dts/canaan/k230-canmv-dshanpi.dts index 4f95b534ee87..55197cfc25b4 100644 --- a/arch/riscv/boot/dts/canaan/k230-canmv-dshanpi.dts +++ b/arch/riscv/boot/dts/canaan/k230-canmv-dshanpi.dts @@ -80,3 +80,20 @@ &uart0 { pinctrl-0 =3D <&uart0_pins>; status =3D "okay"; }; + +&usb0 { + vusb_d-supply =3D <&vdd_3v3>; + vusb_a-supply =3D <&vdd_1v8>; + status =3D "okay"; +}; + +&usb1 { + dr_mode =3D "host"; + vusb_d-supply =3D <&vdd_3v3>; + vusb_a-supply =3D <&vdd_1v8>; + status =3D "okay"; +}; + +&usbphy { + status =3D "okay"; +}; diff --git a/arch/riscv/boot/dts/canaan/k230.dtsi b/arch/riscv/boot/dts/can= aan/k230.dtsi index b815a65e02b9..6dcb086f7046 100644 --- a/arch/riscv/boot/dts/canaan/k230.dtsi +++ b/arch/riscv/boot/dts/canaan/k230.dtsi @@ -148,5 +148,40 @@ uart4: serial@91404000 { reg-shift =3D <2>; status =3D "disabled"; }; + + usb0: usb@91500000 { + compatible =3D "canaan,k230-usb", "snps,dwc2"; + reg =3D <0x0 0x91500000 0x0 0x40000>; + interrupts =3D <173 IRQ_TYPE_LEVEL_HIGH>; + clocks =3D <&sysclk K230_HS_USB0_AHB_GATE>; + clock-names =3D "otg"; + g-rx-fifo-size =3D <512>; + g-np-tx-fifo-size =3D <64>; + g-tx-fifo-size =3D <512 1024 64 64 64 64>; + phys =3D <&usbphy 0>; + phy-names =3D "usb2-phy"; + status =3D "disabled"; + }; + + usb1: usb@91540000 { + compatible =3D "canaan,k230-usb", "snps,dwc2"; + reg =3D <0x0 0x91540000 0x0 0x40000>; + interrupts =3D <174 IRQ_TYPE_LEVEL_HIGH>; + clocks =3D <&sysclk K230_HS_USB1_AHB_GATE>; + clock-names =3D "otg"; + g-rx-fifo-size =3D <512>; + g-np-tx-fifo-size =3D <64>; + g-tx-fifo-size =3D <512 1024 64 64 64 64>; + phys =3D <&usbphy 1>; + phy-names =3D "usb2-phy"; + status =3D "disabled"; + }; + + usbphy: usb-phy@91585000 { + compatible =3D "canaan,k230-usb-phy"; + reg =3D <0x0 0x91585000 0x0 0x400>; + #phy-cells =3D <1>; + status =3D "disabled"; + }; }; }; --=20 2.52.0