From nobody Sat Feb 7 21:24:08 2026 Received: from mail-il1-f195.google.com (mail-il1-f195.google.com [209.85.166.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3113E33F8C2 for ; Fri, 17 Oct 2025 19:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728069; cv=none; b=ABrYlfM8ZyU8nC3itEfW2V4nQ/+GKS3XfSLTSgv/0kbYooTmFbBccW4m2IrLpZAgUxd81SWmIDN9fnan/1m87GNNZG2+aoQVre9DLiDv/C38VoHb09ApsFSAjqlx4xA6L0ZGMfYOkNHRJlOBJhkypLOUKkQfV0obBlVJqn7Y+28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728069; c=relaxed/simple; bh=7WrOPVM0gt+b/Q/c9vY/ADstDCH0ZLchyGhM1A9P4gQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YRaNm5Wjtw5WhukcIzDAWG8n97bCap7QJ+DcrpjPOMmApTaRJlFFtmfbVD6hZpQuQjXwjWbAQgFH4/3MvlSUxjSfqpf70P8Ktkg217KbbN+ZB/TrmMS4GB6w49UK3uSmnyKBBY2/0nRWU8ZIbjFt9tWvonDxXbMtorQloVd17GA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=XaqC+Gct; arc=none smtp.client-ip=209.85.166.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="XaqC+Gct" Received: by mail-il1-f195.google.com with SMTP id e9e14a558f8ab-430d098121cso1135455ab.0 for ; Fri, 17 Oct 2025 12:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728066; x=1761332866; darn=vger.kernel.org; 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=nnj3ndeUMae3NyNArAGupVHJsLP7DcySgmrwpRjKSkM=; b=XaqC+GctWKHYCQ69QE3CSwqNingyyvxRnRKsuBSNjpwZ1/hXMUEQI391D3b+ozZc3R KjHkZXReEq5hdqHSGNAezlzaJkPe21TozjrjMNZuEsOfl2AXs3my4MgBCnuSbXqb6P+S V+/66dYUCXBoWX2ZHxaTl1RNGmPmg3ooFuzo6Hjyl801XK4u5ZWZv0WzLvRSWY38IxB/ +Lz9OTTrqDBX8e5e1sd2oeVg718Sho7fjMLps3odM3U1GoeGP62BcHevRbU6aTEv6xMu AkcpsKYciYb1MaM1xCNXodd9U095CSzgyO6JSmSYGJgjVz7iI2c25ks8NxJ89m39ezgl mpAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728066; x=1761332866; 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=nnj3ndeUMae3NyNArAGupVHJsLP7DcySgmrwpRjKSkM=; b=Oi81BrBHAou6AA0EBM20GP4Jl23cwZ/ktd8ifMvL4LZ05YzWB4HG1Tx8QM0HJFafoP ZzjPxTUt3fnao7DNqI/MSQJFbES1IVAxDifkE/+9Ju38rI9t48nT5C57yRyK20OsiV4N c+mB0YgDxitnV8LZfJO7DoZYlKiuwmWU27IJE/CrtrPLnZYtACYDLw5Si94OewZbNOb9 5rKngNwQJeAvADs7XIJfKhvjnOJB+daBqbqDvDCQOhjMCP8QCTQkeOFpF4c3F8i2tQiK Ac8KJLYOiYi+5lCacoofYxNjhvDS4HB23fFPosDSpbvUdxcAePS9dNrS7bPv0hn4hZwk +0tQ== X-Forwarded-Encrypted: i=1; AJvYcCUhu2ZSWjaErdHuaTiacQ+rNZsgxaUW2ub8qsW0THOgLRk48EV5xl0FtaHXfvWcxtUEtpYMhECTSktuZSw=@vger.kernel.org X-Gm-Message-State: AOJu0YylIPRzwJgmAGHghMfa4HHp81DgBLMFXvj7sAMnjLQ3g3F10Gd3 kRgcwTZUZH6IqRk2P60BaMzhrM7evzcrTpf3ds5Xh3OD1+cWam3C3nypg1ZKRRgFO5s5gHVMPlN duLb1mLOaHg== X-Gm-Gg: ASbGncugKakm13rXxRfiTBQG50AEtT3i1RDXCTY3a0+v9Pvtujna2BhCIhO4EKfb86X 0S+0ZdBsPNSd8JoMpIzwO4er0t/QGeCZd4O163vck2i5DTCuhKhnE3gafVzPRsR03mJgtCD4Ezh gkDwigdd3z6LIqFy67Y74n0u1j9IbipwqZawGBwu+ikTb76rauCWoxXlcNmAfw5zrlkjUjpzACe Q60e0YEMOI5FtA00cuatETJrWmRwURb7miu1grSqhL9vosos/ukjUrCZ8xqwRhXsyEPYy8pt0oL xU/9gKQPMUpqnYjLlR/vMCe9m/Tru32Xv2t6iaJO/FCpQV145UtOgeUWVogvRsBbnotDFd37rUl z0NII1u4IPvoJPJkg2jePoR29FlLmqzfN9CBKP6V4SkH6tmetqw1wO1LqXw6lCQzE8X2IuS9zdf LSvM4qKAU9GTg4mkbE96Z4/N8z57esmW/uoHgKw9mByxYDt2UMKAug2A== X-Google-Smtp-Source: AGHT+IHytZYPq3sSfMjOZfFYHMcFE2wOrzrpGR8N8DWI8WbrnQAptaEbQ6cEghvzh0pSWjDXYscmQg== X-Received: by 2002:a92:ca4d:0:b0:430:b05a:ecc3 with SMTP id e9e14a558f8ab-430c525f528mr67642975ab.9.1760728065914; Fri, 17 Oct 2025 12:07:45 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:45 -0700 (PDT) From: Alex Elder To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, vkoul@kernel.org, kishon@kernel.org Cc: dlan@gentoo.org, guodong@riscstar.com, devicetree@vger.kernel.org, linux-phy@lists.infradead.org, spacemit@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/7] dt-bindings: phy: spacemit: add SpacemiT PCIe/combo PHY Date: Fri, 17 Oct 2025 14:07:33 -0500 Message-ID: <20251017190740.306780-2-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Add the Device Tree binding for the PCIe/USB 3.0 combo PHY found in the SpacemiT K1 SoC. This is one of three PCIe PHYs, and is unusual in that only the combo PHY can perform a calibration step needed to determine settings used by the other two PCIe PHYs. Calibration must be done with the combo PHY in PCIe mode, and to allow this to occur independent of the eventual use for the PHY (PCIe or USB) some PCIe-related properties must be supplied: clocks; resets; and a syscon phandle. Reviewed-by: Rob Herring (Arm) Signed-off-by: Alex Elder --- v3: - Added Reviewed-by from Rob Herring - The "phy" reset is listed first .../bindings/phy/spacemit,k1-combo-phy.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-combo= -phy.yaml diff --git a/Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.ya= ml b/Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.yaml new file mode 100644 index 0000000000000..b59476cd78b57 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.yaml @@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/spacemit,k1-combo-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCIe/USB3 Combo PHY + +maintainers: + - Alex Elder + +description: > + Of the three PHYs on the SpacemiT K1 SoC capable of being used for + PCIe, one is a combo PHY that can also be configured for use by a + USB 3 controller. Using PCIe or USB 3 is a board design decision. + + The combo PHY is also the only PCIe PHY that is able to determine + PCIe calibration values to use, and this must be determined before + the other two PCIe PHYs can be used. This calibration must be + performed with the combo PHY in PCIe mode, and is this is done + when the combo PHY is probed. + + The combo PHY uses an external oscillator as a reference clock. + During normal operation, the PCIe or USB port driver is responsible + for ensuring all other clocks needed by a PHY are enabled, and all + resets affecting the PHY are deasserted. However, for the combo + PHY to perform calibration independent of whether it's later used + for PCIe or USB, all PCIe mode clocks and resets must be defined. + +properties: + compatible: + const: spacemit,k1-combo-phy + + reg: + items: + - description: PHY control registers + + clocks: + items: + - description: External oscillator used by the PHY PLL + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus Master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: refclk + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: PHY reset; remains deasserted after initialization + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus Master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: phy + - const: dbi + - const: mstr + - const: slv + + spacemit,apmu: + description: + A phandle that refers to the APMU system controller, whose + regmap is used in setting the mode + $ref: /schemas/types.yaml#/definitions/phandle + + "#phy-cells": + const: 1 + description: + The argument value (PHY_TYPE_PCIE or PHY_TYPE_USB3) determines + whether the PHY operates in PCIe or USB3 mode. + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - spacemit,apmu + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include + phy@c0b10000 { + compatible =3D "spacemit,k1-combo-phy"; + reg =3D <0xc0b10000 0x1000>; + clocks =3D <&vctcxo_24m>, + <&syscon_apmu CLK_PCIE0_DBI>, + <&syscon_apmu CLK_PCIE0_MASTER>, + <&syscon_apmu CLK_PCIE0_SLAVE>; + clock-names =3D "refclk", + "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE0_GLOBAL>, + <&syscon_apmu RESET_PCIE0_DBI>, + <&syscon_apmu RESET_PCIE0_MASTER>, + <&syscon_apmu RESET_PCIE0_SLAVE>; + reset-names =3D "phy", + "dbi", + "mstr", + "slv"; + spacemit,apmu =3D <&syscon_apmu>; + #phy-cells =3D <1>; + }; --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2967879EA for ; Fri, 17 Oct 2025 19:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728070; cv=none; b=nT5CBq5D2rfJ1y0CNMH/MH/FM2UkT4FuHK+p/bMfSVn6wKO/j0dV0+mBB0AXTjh76RIzq2nzkQjuDYp/tpMZO5t1G4Jbn4j/eXMSyPi51pBTZEnR/swgJQEZ49kuBSLBxDhYQeHLwduMzFchwKQIKnC4FhAQOUNtax2TWY/B7+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728070; c=relaxed/simple; bh=LLI/HQYDWhCmej4ouNtvXFhwrmFwQGLMws3w9xIK1/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XrrepiN41xe/VVs4DYyp0FVfBpZmAJGLVO2caGFbSo/WOfRQqkjhadvaRsejTXv6e6A98oI+mihyAhws+/h3kbML9ReJZQHh1pp71kM9Ra5UQwHLkTNX4pBhNx6Zs+dLqcc9md8eaWUCgR+urifG3+jkc82stlZO9UiUSYp4soc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=Je1RL/Fd; arc=none smtp.client-ip=209.85.166.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="Je1RL/Fd" Received: by mail-io1-f68.google.com with SMTP id ca18e2360f4ac-938de0df471so196619039f.2 for ; Fri, 17 Oct 2025 12:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728067; x=1761332867; darn=vger.kernel.org; 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=H/3BQdd3vn0d3oIHDdjobMfykMV90YiIp5S1jVARxr8=; b=Je1RL/FdYh7jK6gjcwQZz0xPkIuPjcqjDnpaYtZ0xInXRmsJ1tYpCreoL1rBcV0qm2 qsFj1zwFPkikT+yVGgtbyNUqV/MOcb1u4X5A+a9SZjej5vTpixKciukwLcDiWLW4YVR/ wTS5hyppbtYDvOYKkN34Yolrm56L9CovtkHJ51FrcA7F/Vysromg9DQBdzba9GyHT17f EJq6WM3FTXfk+Y+63ty5ESD1O3TFgDnJzJ6jeRe4Cf0V+SAnXsv3mbjNGmrkAYndr59V DK279aAeAaaxP9XYaHttx26K6TmCVqzXgZJcmIplk/+CUhq4sQt+17qG+tpieZePJ8KA ECDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728067; x=1761332867; 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=H/3BQdd3vn0d3oIHDdjobMfykMV90YiIp5S1jVARxr8=; b=Xc2lS8897/r6PWWeZy4tdcVUKgg7GEpyAsy9vxvzhgeM53DdsFFICypwYramvsAN9J V9MWVSDtugPVt2CvO0TNwUuJdPOfSJEW2hTYzQSNm1VMma1eHAsRjOjz16nWgfdyAth+ /eI+anrzrhEQot+foIdpIJ1Jk6fPccvK6kypx32+P/sqBtRfk083zNA55PwOpMFh/YGi qjx4SZa9C+KVxV+FlVC2BQxTgpjo9obJBBjs/W3RERsD/6wp2SL4dYO/VIqWIlarA9oD 9Kxjc6yukjXyGmXiMspc9fGW8ACC6ka8eyQCrs3bTbhNQbaMeBeIHRC0LGqRzME6fq+4 YoDQ== X-Forwarded-Encrypted: i=1; AJvYcCWtA8u8Vg++gcA2QyCBvGSwc1k5cq2m6BLD7mWhGx0zOX7y/ENOVBCh0R+m0Wrv/as4WWqrHEtx9tsFTt8=@vger.kernel.org X-Gm-Message-State: AOJu0YyytTEVj5SArEF8nQtUntC7BY1bYr71ZXa6q36vtoXzQdveH7y7 GNIMGB9AOmvsl3VXXM/eXa8JorvlCcV1orzLJrz7VJMlU2bUy7k0ibjcnUfVPmNaYH8= X-Gm-Gg: ASbGncshdHcfcgCwGWgKWc8blSTi3yb6fsXDyYkDt4NwOO767TG1zvj50WuFcWtEWuJ lVv4kywx2WuRMpT2wliGJw9WLiXzdQ2fWvZfxWcRbvRCeaol/uvzeXji25kEH8FqWURcdwvJiVM ye/HC3vX+Y6kkuTaMMlMrQCkNCyNr2Gh2la9GlMsFv2o6vTM2edu4JLF6J3SzSH4TH18U4G236L EN4c+zknEsUkPLMPiCQ8qmyhnZ5LPuorUrIqylw3NUgBHkETaB8p42P3XzzIKYU8sZADBJECUUd Vo/TatmjcuUBj/qJCBeorJdmjNDZ7Mm/d7nHwhCsAjuJnyMI9iFgXCttflnjborNptaGgOgI/JY WSOeLtjDt1hRa7GXrvFnISU0r1QD1JaUboIqAGaStnhoFlDzHXPBca22/jsamhhny8XzOiuJgyA JzWDPehWWy2T+rDMO7bjqGunwsLK8+EvNzuLwCkIPoAToiat27+olS2Q== X-Google-Smtp-Source: AGHT+IHRtsRSfhWCT9BQG3DcVkrpn6NA7ODycaChUBpFYwB1ZdnsTh8SKsqwMx76IAkXTipom5mlHA== X-Received: by 2002:a05:6e02:148d:b0:430:b167:3604 with SMTP id e9e14a558f8ab-430c5209bafmr76757915ab.4.1760728067217; Fri, 17 Oct 2025 12:07:47 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:46 -0700 (PDT) From: Alex Elder To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: ziyao@disroot.org, dlan@gentoo.org, guodong@riscstar.com, devicetree@vger.kernel.org, linux-phy@lists.infradead.org, spacemit@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/7] dt-bindings: phy: spacemit: introduce PCIe PHY Date: Fri, 17 Oct 2025 14:07:34 -0500 Message-ID: <20251017190740.306780-3-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Add the Device Tree binding for two PCIe PHYs present on the SpacemiT K1 SoC. These PHYs are dependent on a separate combo PHY, which determines at probe time the calibration values used by the PCIe-only PHYs. Reviewed-by: Rob Herring (Arm) Signed-off-by: Alex Elder --- v3: - Added Reviewed-by from Rob Herring - A "phy" reset is now required .../bindings/phy/spacemit,k1-pcie-phy.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-pcie-= phy.yaml diff --git a/Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yam= l b/Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yaml new file mode 100644 index 0000000000000..019b28349be75 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/spacemit,k1-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCIe PHY + +maintainers: + - Alex Elder + +description: > + Two PHYs on the SpacemiT K1 SoC used for only for PCIe. These + PHYs must be configured using calibration values that are + determined by a third "combo PHY". The combo PHY determines + these calibration values during probe so they can be used for + the two PCIe-only PHYs. + + The PHY uses an external oscillator as a reference clock. During + normal operation, the PCIe host driver is responsible for ensuring + all other clocks needed by a PHY are enabled, and all resets + affecting the PHY are deasserted. + +properties: + compatible: + const: spacemit,k1-pcie-phy + + reg: + items: + - description: PHY control registers + + clocks: + items: + - description: External oscillator used by the PHY PLL + + clock-names: + const: refclk + + resets: + items: + - description: PHY reset; remains deasserted after initialization + + reset-names: + const: phy + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include + phy@c0c10000 { + compatible =3D "spacemit,k1-pcie-phy"; + reg =3D <0xc0c10000 0x1000>; + clocks =3D <&vctcxo_24m>; + clock-names =3D "refclk"; + resets =3D <&syscon_apmu RESET_PCIE1_GLOBAL>; + reset-names =3D "phy"; + #phy-cells =3D <0>; + }; --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B541246783 for ; Fri, 17 Oct 2025 19:07:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728073; cv=none; b=K6cNwTT76Kmn1iDIwL5lBj6koZzE/RxuWqxnrSoKvMeWnBdx++uDZ3Y69OQZHgn1mPgEAMglu96Wtb/s0fKXQtbB/rbVsvW3QXIvzL5pgDcAWUTBCsRq3oeNQfFbikQrp8tvax3Q5tUQnH6A7jYbzEdbzy22qU95YBn9UwOzS1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728073; c=relaxed/simple; bh=gSA8pzE96CptaNNhmH2TKS9Z/TX8WVfVdY5RfpgB+X0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QnwizQP2ND5UdjQGL/q6e8CpxTOKR3bd6KQjddTEDiwcC3TBaUmbrQWpkMMwkEHm8m6JZdBvIacEgOFI7MmH+GPRXTz+xohLmiZoP1s0wVZmymMldGqzzGGtbzhfh2xVs6GUWeQCEX4AWkNkKCKrWOdBoqJMwSp44R/9LiWX6cc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=B0Xs/t2B; arc=none smtp.client-ip=209.85.166.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="B0Xs/t2B" Received: by mail-io1-f66.google.com with SMTP id ca18e2360f4ac-917be46c59bso223035739f.1 for ; Fri, 17 Oct 2025 12:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728068; x=1761332868; darn=vger.kernel.org; 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=wipx6KUf5lXNnshQnWU8AGb6pBA1b4PqRzR3i29GydQ=; b=B0Xs/t2BZg2MRNTW0WNu8tW8U8O6d1wWBwsDDdRPVKO8t2h8ZkEopykzgoli3yGp6y oK/pSCuA8x55SGWwOu+btU3d0kWcJyMacvmb2SznYHuuXwS1DVSSzWAtzLj+2UUwTkRn 5Dc5p1Md/7n59TLQBm9pOEFwM0XlZJDaA0bhjgdmS9FsUWDYlZaDk1dAC88oPS04sk6Y jn0hugTebhOgvcOxKK2VFeBDzfNpcdFhAnx6NmxcNzUrI3dn2TUNwVYqCJbKIxyoXKSC SdL6Tn25xfyUZwYZY8dvPROUmpSfsSszXb9Z7E9v2T2l3kmMarUFgTumVAEegx2bOsMo ngJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728068; x=1761332868; 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=wipx6KUf5lXNnshQnWU8AGb6pBA1b4PqRzR3i29GydQ=; b=s42NdbqsYNqueeEJ/N+cay5+Q/eHB2eHdrC+Ca3G68v2xZ2mfytrhakM0e6Zj0SF+w v5nWbkW5qOQq6Hhz1MctYV2nrCqiK1HS2EmfWv6RecW5vnmcyJmH3USi3KNslZ5SM5s6 LEfXATtDmASpGWT+DB0a4mFOVKTxs8HrcJwWcC/LFhIu0GpSwABTZPcMRfaovbsf0ePG euOoh+LcKYLhOEG4U5yHLeM/vx+62SsBblE1WiRjQBBpYXgNbjN9VuBa0vwF8hxKi6+l G7kb36CHmAcAmNG/Shb09ixnvgisBzRgvbMl+lK2jbefcPqHYgxWVJWfoEn5nqcUWS6b U1fg== X-Forwarded-Encrypted: i=1; AJvYcCUcRU7McVmaNlXowqbJMg6alDSCbOett3Vz6gPl4IBhjSbAda1VI5/mTevzT2yg1FfvCNad7iWRlZ3tcHg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4zqMGKXR9rQo7DKHrxjXuSIpdp2laTTEzKLK6BlclVTYHS/MS doWEWgmg8UggPZGwapQnFrhegjwcDUwxAZM//D9oDgtn2/TLC0/1GH9APFrTqPtRhWM= X-Gm-Gg: ASbGncs25NNS+4TwsKh5mc9GNvOloAd1O5lkJVkX4RB4dM6H3g1HGYFvbdqIulLcctj Bm2cDDIdXWsfkTmm9azBIr9iKUrwnLpcDDa+dNNyPnjroNyPKLt32xI9omi2zNT1pQIssMtukL4 tZKE3MyPOYz53P96yxjelNsxnu0oTQtrMSZcQNXTltFfLK76AYN6iRXQYYgTS+EjZnMAOCOeRCy UoMKSgFHSUfkFlDSEvGDowIf9g7GFjqNUfLvJwB3YiJLb7A7T17raHXE9o4AJf98Xy+4MPKWdTl 4Ic/JUQ4W90JFnJllgXiLNOvTTY2Y8T9LhK4bxosTWEN3cPytcoqQGC6oOCnp7OFq3jyZouPMTZ u60xJKkZa4jmjLWOwNh7rphPxaYi/uFhgJmC1VpDZQadOCYJHESCXZBuJQMvAbUFLOljmDD16Dh unjLM6tuA2sQMfoFk6SWzkB9Y2jvK0CRP/0+bAs3jeJMA= X-Google-Smtp-Source: AGHT+IGlmzrh73wRb0y67T37imaj4fcl25NZgeEColbyy8xRcDJKg9j4yQIgu1HP8DHaZFDT+Smbzg== X-Received: by 2002:a05:6e02:188b:b0:430:b05a:ecb3 with SMTP id e9e14a558f8ab-430c52899ddmr71652585ab.9.1760728068556; Fri, 17 Oct 2025 12:07:48 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:48 -0700 (PDT) From: Alex Elder To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, bhelgaas@google.com, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org Cc: dlan@gentoo.org, guodong@riscstar.com, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, spacemit@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] dt-bindings: pci: spacemit: introduce PCIe host controller Date: Fri, 17 Oct 2025 14:07:35 -0500 Message-ID: <20251017190740.306780-4-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Add the Device Tree binding for the PCIe root complex found on the SpacemiT K1 SoC. This device is derived from the Synopsys Designware PCIe IP. It supports up to three PCIe ports operating at PCIe gen 2 link speeds (5 GT/sec). One of the ports uses a combo PHY, which is typically used to support a USB 3 port. Signed-off-by: Alex Elder --- v3: - Remove the "num-viewport" property - A "phy" reset is no longer required .../bindings/pci/spacemit,k1-pcie-host.yaml | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/spacemit,k1-pcie-= host.yaml diff --git a/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.ya= ml b/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file mode 100644 index 0000000000000..89f8b6b579c6e --- /dev/null +++ b/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml @@ -0,0 +1,147 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/spacemit,k1-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCI Express Host Controller + +maintainers: + - Alex Elder + +description: > + The SpacemiT K1 SoC PCIe host controller is based on the Synopsys + DesignWare PCIe IP. The controller uses the DesignWare built-in + MSI interrupt controller, and supports 256 MSIs. + +allOf: + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: spacemit,k1-pcie + + reg: + items: + - description: DesignWare PCIe registers + - description: ATU address space + - description: PCIe configuration space + - description: Link control registers + + reg-names: + items: + - const: dbi + - const: atu + - const: config + - const: link + + spacemit,apmu: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + A phandle that refers to the APMU system controller, whose + regmap is used in managing resets and link state, along with + and offset of its reset control register. + items: + - items: + - description: phandle to APMU system controller + - description: register offset + + clocks: + items: + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: dbi + - const: mstr + - const: slv + + interrupts: + items: + - description: Interrupt used for MSIs + + interrupt-names: + const: msi + + phys: + maxItems: 1 + + vpcie3v3-supply: + description: + A phandle for 3.3v regulator to use for PCIe + + device_type: + const: pci + +required: + - compatible + - reg + - reg-names + - spacemit,apmu + - "#address-cells" + - "#size-cells" + - ranges + - clocks + - clock-names + - resets + - reset-names + - interrupts + - interrupt-names + - phys + - vpcie3v3-supply + - device_type + +unevaluatedProperties: false + +examples: + - | + #include + pcie@ca400000 { + compatible =3D "spacemit,k1-pcie"; + reg =3D <0xca400000 0x00001000>, + <0xca700000 0x0001ff24>, + <0x9f000000 0x00002000>, + <0xc0c20000 0x00001000>; + reg-names =3D "dbi", + "atu", + "config", + "link"; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0x00000000 0x9f002000 0x0 0x00100000>, + <0x02000000 0x0 0x90000000 0x90000000 0x0 0x0f000000>; + interrupts =3D <142>; + interrupt-names =3D "msi"; + clocks =3D <&syscon_apmu CLK_PCIE1_DBI>, + <&syscon_apmu CLK_PCIE1_MASTER>, + <&syscon_apmu CLK_PCIE1_SLAVE>; + clock-names =3D "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE1_DBI>, + <&syscon_apmu RESET_PCIE1_MASTER>, + <&syscon_apmu RESET_PCIE1_SLAVE>; + reset-names =3D "dbi", + "mstr", + "slv"; + phys =3D <&pcie1_phy>; + vpcie3v3-supply =3D <&pcie_vcc_3v3>; + device_type =3D "pci"; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&pcie1_3_cfg>; + spacemit,apmu =3D <&syscon_apmu 0x3d4>; + }; --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EEA81E51EA for ; Fri, 17 Oct 2025 19:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728074; cv=none; b=K2CqX8KZSJRhhqLHc6IZZhYJ+wXKIBVvteWQqTZixfzetoD0cbK2j2xHmPGkjcCcOOvwyDuIRRmgU0BhFUEit1aOl7+rASIe3rjWCs2Q7e6rQ2Y7bVgqJaUnZKTms0nmq6kK7EFzukLhxAF5NBigCA9ZVSwIK4XuQPphGiteJqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728074; c=relaxed/simple; bh=9CGfjzQALEPjuL2n5Ur3pAPKfTG2/fjdy0onfQNDAv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=avbspWABFBsY3mAkkLAg6zIfqSmvGCA9Mr31tquz7s2j5Gk1356bZl4V3JcpZwKWxn6Xpx/LJ4TyXYBDe04yVf/LXQ/l8wmqygITWxRAmjG8GFoTE5cp5hg/fo7AIkwV6WbE2fNcFATnnyTjxHdMXYTfgiZjNShGOxig7FrTfc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=E+0KVHjg; arc=none smtp.client-ip=209.85.166.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="E+0KVHjg" Received: by mail-il1-f193.google.com with SMTP id e9e14a558f8ab-430abca3354so20079915ab.2 for ; Fri, 17 Oct 2025 12:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728070; x=1761332870; darn=vger.kernel.org; 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=EekIgc7trZnADljnJ11X8FOJgycgzt5WvMr0sifaZ7I=; b=E+0KVHjgJuXJGE5oQ4iC+YQ3LSbkOAqu8yR76v5ROZVYXdN4aqfJiqp3qLyvfr6fLH WVrZxGcGMoM53GLqKVtmNmYRR2i/L8AH5mP0KjWne9tfoo+ns668lVpwZyh7X00kqKII GmbuvzAQXnPZ6QCtlIiro4NvLUJ6GKwQEAGtXWoB3+RDGPuhrVNNsUByxfHm2A+601f7 wX8LFY+eANaM6RLcHGzEFtGXJuFAYXVzERAcZQ9jOM+h1tNP//b/DIPKYVURybTZIoK9 1aVVzElFB7K9++PRcsn8gVn907fAEYA5iympLLufpgTwhKDrzt7V2U20oIkUQIVfKw24 TILw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728070; x=1761332870; 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=EekIgc7trZnADljnJ11X8FOJgycgzt5WvMr0sifaZ7I=; b=luh+yhBWrOVDM/NIAVRKT2mmLCg7etKjrphuVFo0+tV6mhZ3NkL/KXIV4stSZ/1iBD 8Ok6IscOuFkf5eqgaD4ebaewHkb5WWQEpJRTUQPoh133pjASLrbHba+QY0cM2KLi4kKg tK20ApCigDpE7bWlz6LIj+7Yv1FtTBOLVUhHkKUrGi0wvRMmeWM28JvrYFThkDtHcqq4 q4PdGOU7mxu07ouJsIqQAyv3QcTz+avVQEHCrqXUEa2wn+nf4ZFmhBvE7K2WYGR2NfzY RO7m2TNtWp4mfc6FDHF+Uu4EUGyLwXScOHBJ8+LwVn6xEgframVJ2OWtuwTPuFiEI70S 45Yg== X-Forwarded-Encrypted: i=1; AJvYcCV+wUeDxAxoSirAtH5KEruyx0YLkGs2cW6bG7hf2DDOkG/07JUL70I7bnlwvonaM80WrsSPBWI5TQgYqPE=@vger.kernel.org X-Gm-Message-State: AOJu0YxNLaPBq3gR8D8djs2dGagcmLk5nnlrLNlcgPZUhCtnxyL8aWZY pYgrLWf2Fs5jgnv0T1lTCjX0QEnDuH1mCtVenPGU4BwRMk2T9niLoNog8FYVIXAQlJQ= X-Gm-Gg: ASbGncu9N53QA0dhDRqFWoP4EbEoMCx81mNgLVze2lvC5nDWYI0+e+pGGi+Z7/JgWmS mAMp4Jpm4uc4+O7pmyU4sxA9RKFB7E0cM21niKgfXO1OpkQvYs6XQnvTTTSJTYR/+c8AajjJ8gb xNUO2A2YWKJCa2mNNqrNEo9GDwp/VallSX6UJXu9xn6BzsMhGUlNpaqbAuHZYu6auOuQJLvEu2k UIk380/RUj+RX1QdTsQrVEZFXooCF4L5P1hI3en2Z50jJWr9RSafKslxk94JXGTLxwCiZ2fkW96 EHIGxXfVeGH8xCrHD3N+Szx79RaPWflRHTu8c/E1TloNblwOlP/4rCWll/kwez+7etP8pBiKIBF TYMLx3W8M6HQJxGMjUKrKUbK74A0iBtGS1ZBgrM9QdcgRMEp7Ob0pDm5nsZ95Z0yL4z4/cg2OAa H8VI0m98xXawthJvSjHBmaRu1xp9EkK/gvaIGTOP8QUb4/camQTAPbPQ== X-Google-Smtp-Source: AGHT+IH3i+IMS8k8Lakh3upYV4nsw+knQzR4pQm2d8vBa3F+4XypZZMovF0gsS4oC2bH0TDlAVpO+A== X-Received: by 2002:a05:6e02:3e06:b0:430:ad98:981b with SMTP id e9e14a558f8ab-430c520929emr57660055ab.5.1760728069802; Fri, 17 Oct 2025 12:07:49 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:49 -0700 (PDT) From: Alex Elder To: vkoul@kernel.org, kishon@kernel.org Cc: p.zabel@pengutronix.de, dlan@gentoo.org, aurelien@aurel32.net, guodong@riscstar.com, linux-phy@lists.infradead.org, spacemit@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Junzhong Pan Subject: [PATCH v3 4/7] phy: spacemit: introduce PCIe/combo PHY Date: Fri, 17 Oct 2025 14:07:36 -0500 Message-ID: <20251017190740.306780-5-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Introduce a driver that supports three PHYs found on the SpacemiT K1 SoC. The first PHY is a combo PHY that can be configured for use for either USB 3 or PCIe. The other two PHYs support PCIe only. All three PHYs must be programmed with an 8 bit receiver termination value, which must be determined dynamically. Only the combo PHY is able to determine this value. The combo PHY performs a special calibration step at probe time to discover this, and that value is used to program each PHY that operates in PCIe mode. The combo PHY must therefore be probed before either of the PCIe-only PHYs will be used. Each PHY has an internal PLL driven from an external oscillator. This PLL started when the PHY is first initialized, and stays on thereafter. During normal operation, the USB or PCIe driver using the PHY must ensure (other) clocks and resets are set up properly. However PCIe mode clocks are enabled and resets are de-asserted temporarily by this driver to perform the calibration step on the combo PHY. Tested-by: Junzhong Pan Signed-off-by: Alex Elder --- v2: - We now get and deassert the "phy" reset for all three PHYs - Error handling and putting of clocks has been corrected drivers/phy/Kconfig | 11 + drivers/phy/Makefile | 1 + drivers/phy/phy-spacemit-k1-pcie.c | 670 +++++++++++++++++++++++++++++ 3 files changed, 682 insertions(+) create mode 100644 drivers/phy/phy-spacemit-k1-pcie.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 678dd0452f0aa..1984c2e56122e 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -101,6 +101,17 @@ config PHY_NXP_PTN3222 schemes. It supports all three USB 2.0 data rates: Low Speed, Full Speed and High Speed. =20 +config PHY_SPACEMIT_K1_PCIE + tristate "PCIe and combo PHY driver for the SpacemiT K1 SoC" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on HAS_IOMEM + depends on OF + select GENERIC_PHY + default ARCH_SPACEMIT + help + Enable support for the PCIe and USB 3 combo PHY and two + PCIe-only PHYs used in the SpacemiT K1 SoC. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index bfb27fb5a4942..a206133a35151 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PHY_SNPS_EUSB2) +=3D phy-snps-eusb2.o obj-$(CONFIG_USB_LGM_PHY) +=3D phy-lgm-usb.o obj-$(CONFIG_PHY_AIROHA_PCIE) +=3D phy-airoha-pcie.o obj-$(CONFIG_PHY_NXP_PTN3222) +=3D phy-nxp-ptn3222.o +obj-$(CONFIG_PHY_SPACEMIT_K1_PCIE) +=3D phy-spacemit-k1-pcie.o obj-y +=3D allwinner/ \ amlogic/ \ broadcom/ \ diff --git a/drivers/phy/phy-spacemit-k1-pcie.c b/drivers/phy/phy-spacemit-= k1-pcie.c new file mode 100644 index 0000000000000..75477bea7f700 --- /dev/null +++ b/drivers/phy/phy-spacemit-k1-pcie.c @@ -0,0 +1,670 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * SpacemiT K1 PCIe and PCIe/USB 3 combo PHY driver + * + * Copyright (C) 2025 by RISCstar Solutions Corporation. All rights reser= ved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * Three PCIe ports are supported in the SpacemiT K1 SoC, and this driver + * supports their PHYs. + * + * The PHY for PCIe port A is different from the PHYs for ports B and C: + * - It has one lane, while ports B and C have two + * - It is a combo PHY can be used for PCIe or USB 3 + * - It can automatically calibrate PCIe TX and RX termination settings + * + * The PHY functionality for PCIe ports B and C is identical: + * - They have two PCIe lanes (but can be restricted to 1 via device tree) + * - They are used for PCIe only + * - They are configured using TX and RX values computed for port A + * + * A given board is designed to use the combo PHY for either PCIe or USB 3. + * Whether the combo PHY is configured for PCIe or USB 3 is specified in + * device tree using a phandle plus an argument. The argument indicates + * the type (either PHY_TYPE_PCIE or PHY_TYPE_USB3). + * + * Each PHY has a reset that it gets and deasserts during initialization. + * Each depends also on other clocks and resets provided by the controller + * hardware (PCIe or USB) it is associated with. The controller drivers + * are required to enable any clocks and de-assert any resets that affect + * PHY operation. In addition each PHY implements an internal PLL, driven + * by an external (24 MHz) oscillator. + * + * PCIe PHYs must be programmed with RX and TX calibration values. The + * combo PHY is the only one that can determine these values. They are + * determined by temporarily enabling the combo PHY in PCIe mode at probe + * time (if necessary). This calibration only needs to be done once, and + * when it has completed the TX and RX values are saved. + * + * To allow the combo PHY to be enabled for calibration, the resets and + * clocks it uses in PCIe mode must be supplied. + */ + +struct k1_pcie_phy { + struct device *dev; /* PHY provider device */ + struct phy *phy; + void __iomem *regs; + u32 pcie_lanes; /* Max (1 or 2) unless limited by DT */ + struct clk *pll; + struct clk_hw pll_hw; /* Private PLL clock */ + + /* The remaining fields are only used for the combo PHY */ + u32 type; /* PHY_TYPE_PCIE or PHY_TYPE_USB3 */ + struct regmap *pmu; /* MMIO regmap (no errors) */ +}; + +#define CALIBRATION_TIMEOUT 500000 /* For combo PHY (usec) */ +#define PLL_TIMEOUT 500000 /* For PHY PLL lock (usec) */ +#define POLL_DELAY 500 /* Time between polls (usec) */ + +/* Selecting the combo PHY operating mode requires APMU regmap access */ +#define SYSCON_APMU "spacemit,apmu" + +/* PMU space, for selecting between PCIe and USB 3 mode (combo PHY only) */ + +#define PMUA_USB_PHY_CTRL0 0x0110 +#define COMBO_PHY_SEL BIT(3) /* 0: PCIe; 1: USB 3 */ + +#define PCIE_CLK_RES_CTRL 0x03cc +#define PCIE_APP_HOLD_PHY_RST BIT(30) + +/* PHY register space */ + +/* Offset between lane 0 and lane 1 registers when there are two */ +#define PHY_LANE_OFFSET 0x0400 + +/* PHY PLL configuration */ +#define PCIE_PU_ADDR_CLK_CFG 0x0008 +#define PLL_READY BIT(0) /* read-only */ +#define CFG_INTERNAL_TIMER_ADJ GENMASK(10, 7) +#define TIMER_ADJ_USB 0x2 +#define TIMER_ADJ_PCIE 0x6 +#define CFG_SW_PHY_INIT_DONE BIT(11) /* We set after PLL config */ + +#define PCIE_RC_DONE_STATUS 0x0018 +#define CFG_FORCE_RCV_RETRY BIT(10) /* Used for PCIe */ + +/* PCIe PHY lane calibration; assumes 24MHz input clock */ +#define PCIE_RC_CAL_REG2 0x0020 +#define RC_CAL_TOGGLE BIT(22) +#define CLKSEL GENMASK(31, 29) +#define CLKSEL_24M 0x3 + +/* Additional PHY PLL configuration (USB 3 and PCIe) */ +#define PCIE_PU_PLL_1 0x0048 +#define REF_100_WSSC BIT(12) /* 1: input is 100MHz, SSC */ +#define FREF_SEL GENMASK(15, 13) +#define FREF_24M 0x1 +#define SSC_DEP_SEL GENMASK(19, 16) +#define SSC_DEP_NONE 0x0 +#define SSC_DEP_5000PPM 0xa + +/* PCIe PHY configuration */ +#define PCIE_PU_PLL_2 0x004c +#define GEN_REF100 BIT(4) /* 1: generate 100MHz clk */ + +#define PCIE_RX_REG1 0x0050 +#define EN_RTERM BIT(3) +#define AFE_RTERM_REG GENMASK(11, 8) + +#define PCIE_RX_REG2 0x0054 +#define RX_RTERM_SEL BIT(5) /* 0: use AFE_RTERM_REG value */ + +#define PCIE_LTSSM_DIS_ENTRY 0x005c +#define CFG_REFCLK_MODE GENMASK(9, 8) +#define RFCLK_MODE_DRIVER 0x1 +#define OVRD_REFCLK_MODE BIT(10) /* 1: use CFG_RFCLK_MODE */ + +#define PCIE_TX_REG1 0x0064 +#define TX_RTERM_REG GENMASK(15, 12) +#define TX_RTERM_SEL BIT(25) /* 1: use TX_RTERM_REG */ + +/* Zeroed for the combo PHY operating in USB mode */ +#define USB3_TEST_CTRL 0x0068 + +/* PHY calibration values, determined by the combo PHY at probe time */ +#define PCIE_RCAL_RESULT 0x0084 /* Port A PHY only */ +#define RTERM_VALUE_RX GENMASK(3, 0) +#define RTERM_VALUE_TX GENMASK(7, 4) +#define R_TUNE_DONE BIT(10) + +static u32 k1_phy_rterm =3D ~0; /* Invalid initial value */ + +/* Save the RX and TX receiver termination values */ +static void k1_phy_rterm_set(u32 val) +{ + k1_phy_rterm =3D val & (RTERM_VALUE_RX | RTERM_VALUE_TX); +} + +static bool k1_phy_rterm_valid(void) +{ + /* Valid if no bits outside those we care about are set */ + return !(k1_phy_rterm & ~(RTERM_VALUE_RX | RTERM_VALUE_TX)); +} + +static u32 k1_phy_rterm_rx(void) +{ + return FIELD_GET(RTERM_VALUE_RX, k1_phy_rterm); +} + +static u32 k1_phy_rterm_tx(void) +{ + return FIELD_GET(RTERM_VALUE_TX, k1_phy_rterm); +} + +/* Only the combo PHY has a PMU pointer defined */ +static bool k1_phy_port_a(struct k1_pcie_phy *k1_phy) +{ + return !!k1_phy->pmu; +} + +/* The PLL clocks are driven by the external oscillator */ +static const struct clk_parent_data k1_pcie_phy_data[] =3D { + { .fw_name =3D "refclk", }, +}; + +static struct k1_pcie_phy *clk_hw_to_k1_phy(struct clk_hw *clk_hw) +{ + return container_of(clk_hw, struct k1_pcie_phy, pll_hw); +} + +/* USB mode only works on the combo PHY, which has only one lane */ +static void k1_pcie_phy_pll_prepare_usb(struct k1_pcie_phy *k1_phy) +{ + void __iomem *regs =3D k1_phy->regs; + u32 val; + + val =3D readl(regs + PCIE_PU_ADDR_CLK_CFG); + val &=3D ~CFG_INTERNAL_TIMER_ADJ; + val |=3D FIELD_PREP(CFG_INTERNAL_TIMER_ADJ, TIMER_ADJ_USB); + writel(val, regs + PCIE_PU_ADDR_CLK_CFG); + + val =3D readl(regs + PCIE_PU_PLL_1); + val &=3D ~SSC_DEP_SEL; + val |=3D FIELD_PREP(SSC_DEP_SEL, SSC_DEP_5000PPM); + writel(val, regs + PCIE_PU_PLL_1); +} + +/* Perform PCIe-specific register updates before starting the PLL clock */ +static void k1_pcie_phy_pll_prepare_pcie(struct k1_pcie_phy *k1_phy) +{ + void __iomem *regs =3D k1_phy->regs; + u32 val; + u32 i; + + for (i =3D 0; i < k1_phy->pcie_lanes; i++) { + val =3D readl(regs + PCIE_PU_ADDR_CLK_CFG); + val &=3D ~CFG_INTERNAL_TIMER_ADJ; + val |=3D FIELD_PREP(CFG_INTERNAL_TIMER_ADJ, TIMER_ADJ_PCIE); + writel(val, regs + PCIE_PU_ADDR_CLK_CFG); + + regs +=3D PHY_LANE_OFFSET; /* Next lane */ + } + + regs =3D k1_phy->regs; + val =3D readl(regs + PCIE_RC_DONE_STATUS); + val |=3D CFG_FORCE_RCV_RETRY; + writel(val, regs + PCIE_RC_DONE_STATUS); + + val =3D readl(regs + PCIE_PU_PLL_1); + val &=3D ~SSC_DEP_SEL; + val |=3D FIELD_PREP(SSC_DEP_SEL, SSC_DEP_NONE); + writel(val, regs + PCIE_PU_PLL_1); + + val =3D readl(regs + PCIE_PU_PLL_2); + val |=3D GEN_REF100; /* Enable 100 MHz PLL output clock */ + writel(val, regs + PCIE_PU_PLL_2); +} + +static int k1_pcie_phy_pll_prepare(struct clk_hw *clk_hw) +{ + struct k1_pcie_phy *k1_phy =3D clk_hw_to_k1_phy(clk_hw); + void __iomem *regs =3D k1_phy->regs; + u32 val; + u32 i; + + if (k1_phy_port_a(k1_phy) && k1_phy->type =3D=3D PHY_TYPE_USB3) + k1_pcie_phy_pll_prepare_usb(k1_phy); + else + k1_pcie_phy_pll_prepare_pcie(k1_phy); + + /* + * Disable 100 MHz input reference with spread-spectrum + * clocking and select the 24 MHz clock input frequency + */ + val =3D readl(regs + PCIE_PU_PLL_1); + val &=3D ~REF_100_WSSC; + val &=3D ~FREF_SEL; + val |=3D FIELD_PREP(FREF_SEL, FREF_24M); + writel(val, regs + PCIE_PU_PLL_1); + + /* Mark PLL configuration done on all lanes */ + for (i =3D 0; i < k1_phy->pcie_lanes; i++) { + val =3D readl(regs + PCIE_PU_ADDR_CLK_CFG); + val |=3D CFG_SW_PHY_INIT_DONE; + writel(val, regs + PCIE_PU_ADDR_CLK_CFG); + + regs +=3D PHY_LANE_OFFSET; /* Next lane */ + } + + /* + * Wait for indication the PHY PLL is locked. Lanes for ports + * B and C share a PLL, so it's enough to sample just lane 0. + */ + return readl_poll_timeout(k1_phy->regs + PCIE_PU_ADDR_CLK_CFG, + val, val & PLL_READY, + POLL_DELAY, PLL_TIMEOUT); +} + +/* Prepare implies enable, and once enabled, it's always on */ +static const struct clk_ops k1_pcie_phy_pll_ops =3D { + .prepare =3D k1_pcie_phy_pll_prepare, +}; + +/* We represent the PHY PLL as a private clock */ +static int k1_pcie_phy_pll_setup(struct k1_pcie_phy *k1_phy) +{ + struct clk_hw *hw =3D &k1_phy->pll_hw; + struct device *dev =3D k1_phy->dev; + struct clk_init_data init =3D { }; + char *name; + int ret; + + name =3D kasprintf(GFP_KERNEL, "pcie%u_phy_pll", k1_phy->phy->id); + if (!name) + return -ENOMEM; + + init.name =3D name; + init.ops =3D &k1_pcie_phy_pll_ops; + init.parent_data =3D k1_pcie_phy_data; + init.num_parents =3D ARRAY_SIZE(k1_pcie_phy_data); + + hw->init =3D &init; + + ret =3D devm_clk_hw_register(dev, hw); + + kfree(name); /* __clk_register() duplicates the name we provide */ + + if (ret) + return ret; + + k1_phy->pll =3D devm_clk_hw_get_clk(dev, hw, "pll"); + if (IS_ERR(k1_phy->pll)) + return PTR_ERR(k1_phy->pll); + + return 0; +} + +/* Select PCIe or USB 3 mode for the combo PHY. */ +static void k1_combo_phy_sel(struct k1_pcie_phy *k1_phy, bool usb) +{ + struct regmap *pmu =3D k1_phy->pmu; + + /* Only change it if it's not already in the desired state */ + if (!regmap_test_bits(pmu, PMUA_USB_PHY_CTRL0, COMBO_PHY_SEL) =3D=3D usb) + regmap_assign_bits(pmu, PMUA_USB_PHY_CTRL0, COMBO_PHY_SEL, usb); +} + +static void k1_pcie_phy_init_pcie(struct k1_pcie_phy *k1_phy) +{ + u32 rx_rterm =3D k1_phy_rterm_rx(); + u32 tx_rterm =3D k1_phy_rterm_tx(); + void __iomem *regs; + u32 val; + int i; + + /* For the combo PHY, set PHY to PCIe mode */ + if (k1_phy_port_a(k1_phy)) + k1_combo_phy_sel(k1_phy, false); + + regs =3D k1_phy->regs; + for (i =3D 0; i < k1_phy->pcie_lanes; i++) { + val =3D readl(regs + PCIE_RX_REG1); + + /* Set RX analog front-end receiver termination value */ + val &=3D ~AFE_RTERM_REG; + val |=3D FIELD_PREP(AFE_RTERM_REG, rx_rterm); + + /* And enable refclock receiver termination */ + val |=3D EN_RTERM; + writel(val, regs + PCIE_RX_REG1); + + val =3D readl(regs + PCIE_RX_REG2); + /* Use PCIE_RX_REG1 AFE_RTERM_REG value */ + val &=3D ~RX_RTERM_SEL; + writel(val, regs + PCIE_RX_REG2); + + val =3D readl(regs + PCIE_TX_REG1); + + /* Set TX driver termination value */ + val &=3D ~TX_RTERM_REG; + val |=3D FIELD_PREP(TX_RTERM_REG, tx_rterm); + + /* Use PCIE_TX_REG1 TX_RTERM_REG value */ + val |=3D TX_RTERM_SEL; + writel(val, regs + PCIE_TX_REG1); + + /* Set the input clock to 24 MHz, and clear RC_CAL_TOGGLE */ + val =3D readl(regs + PCIE_RC_CAL_REG2); + val &=3D CLKSEL; + val |=3D FIELD_PREP(CLKSEL, CLKSEL_24M); + val &=3D ~RC_CAL_TOGGLE; + writel(val, regs + PCIE_RC_CAL_REG2); + + /* Now trigger recalibration by setting RC_CAL_TOGGLE again */ + val |=3D RC_CAL_TOGGLE; + writel(val, regs + PCIE_RC_CAL_REG2); + + val =3D readl(regs + PCIE_LTSSM_DIS_ENTRY); + /* Override the reference clock; set to refclk driver mode */ + val |=3D OVRD_REFCLK_MODE; + val &=3D ~CFG_REFCLK_MODE; + val |=3D FIELD_PREP(CFG_REFCLK_MODE, RFCLK_MODE_DRIVER); + writel(val, regs + PCIE_LTSSM_DIS_ENTRY); + + regs +=3D PHY_LANE_OFFSET; /* Next lane */ + } +} + +/* Only called for combo PHY */ +static void k1_pcie_phy_init_usb(struct k1_pcie_phy *k1_phy) +{ + k1_combo_phy_sel(k1_phy, true); + + /* We're not doing any testing */ + writel(0, k1_phy->regs + USB3_TEST_CTRL); +} + +static int k1_pcie_phy_init(struct phy *phy) +{ + struct k1_pcie_phy *k1_phy =3D phy_get_drvdata(phy); + + /* Note: port type is only valid for port A (both checks needed) */ + if (k1_phy_port_a(k1_phy) && k1_phy->type =3D=3D PHY_TYPE_USB3) + k1_pcie_phy_init_usb(k1_phy); + else + k1_pcie_phy_init_pcie(k1_phy); + + + return clk_prepare_enable(k1_phy->pll); +} + +static int k1_pcie_phy_exit(struct phy *phy) +{ + struct k1_pcie_phy *k1_phy =3D phy_get_drvdata(phy); + + clk_disable_unprepare(k1_phy->pll); + + return 0; +} + +static const struct phy_ops k1_pcie_phy_ops =3D { + .init =3D k1_pcie_phy_init, + .exit =3D k1_pcie_phy_exit, + .owner =3D THIS_MODULE, +}; + +/* + * Get values needed for calibrating PHYs operating in PCIe mode. Only + * the combo PHY is able to do this, and its calibration values are used + * for configuring all PCIe PHYs. + * + * We always need to de-assert the "global" reset on the combo PHY, + * because the USB driver depends on it. If used for PCIe, that driver + * will (also) de-assert this, but by leaving it de-asserted for the + * combo PHY, the USB driver doesn't have to do this. Note: although + * SpacemiT refers to this as the global reset, we name the "phy" reset. + * + * In addition, we guarantee the APP_HOLD_PHY_RESET bit is clear for the + * combo PHY, so the USB driver doesn't have to manage that either. The + * PCIe driver is free to change this bit for normal operation. + * + * Calibration only needs to be done once. It's possible calibration has + * already completed (e.g., it might have happened in the boot loader, or + * -EPROBE_DEFER might result in this function being called again). So we + * check that early too, to avoid doing it more than once. + * + * Otherwise we temporarily power up the PHY using the PCIe app clocks + * and resets, wait for the hardware to indicate calibration is done, + * grab the value, then shut the PHY down again. + */ +static int k1_pcie_combo_phy_calibrate(struct k1_pcie_phy *k1_phy) +{ + struct reset_control_bulk_data resets[] =3D { + { .id =3D "dbi", }, + { .id =3D "mstr", }, + { .id =3D "slv", }, + }; + struct clk_bulk_data clocks[] =3D { + { .id =3D "dbi", }, + { .id =3D "mstr", }, + { .id =3D "slv", }, + }; + struct device *dev =3D k1_phy->dev; + int ret =3D 0; + int val; + + /* Nothing to do if we already set the receiver termination value */ + if (k1_phy_rterm_valid()) + return 0; + + /* + * We also guarantee the APP_HOLD_PHY_RESET bit is clear. We can + * leave this bit clear even if an error happens below. + */ + regmap_assign_bits(k1_phy->pmu, PCIE_CLK_RES_CTRL, + PCIE_APP_HOLD_PHY_RST, false); + + /* If the calibration already completed (e.g. by U-Boot), we're done */ + val =3D readl(k1_phy->regs + PCIE_RCAL_RESULT); + if (val & R_TUNE_DONE) + goto out_tune_done; + + /* Put the PHY into PCIe mode */ + k1_combo_phy_sel(k1_phy, false); + + /* Get and enable the PCIe app clocks */ + ret =3D clk_bulk_get(dev, ARRAY_SIZE(clocks), clocks); + if (ret < 0) + goto out_tune_done; + ret =3D clk_bulk_prepare_enable(ARRAY_SIZE(clocks), clocks); + if (ret) + goto out_put_clocks; + + /* Get the PCIe application resets (not the PHY reset) */ + ret =3D reset_control_bulk_get_shared(dev, ARRAY_SIZE(resets), resets); + if (ret) + goto out_disable_clocks; + + /* De-assert the PCIe application resets */ + ret =3D reset_control_bulk_deassert(ARRAY_SIZE(resets), resets); + if (ret) + goto out_put_resets; + + /* + * This is the core activity here. Wait for the hardware to + * signal that it has completed calibration/tuning. Once it + * has, the register value will contain the values we'll + * use to configure PCIe PHYs. + */ + ret =3D readl_poll_timeout(k1_phy->regs + PCIE_RCAL_RESULT, + val, val & R_TUNE_DONE, + POLL_DELAY, CALIBRATION_TIMEOUT); + + /* Clean up. We're done with the resets and clocks */ + reset_control_bulk_assert(ARRAY_SIZE(resets), resets); +out_put_resets: + reset_control_bulk_put(ARRAY_SIZE(resets), resets); +out_disable_clocks: + clk_bulk_disable_unprepare(ARRAY_SIZE(clocks), clocks); +out_put_clocks: + clk_bulk_put(ARRAY_SIZE(clocks), clocks); +out_tune_done: + /* If we got the value without timing out, set k1_phy_rterm */ + if (!ret) + k1_phy_rterm_set(val); + + return ret; +} + +static struct phy * +k1_pcie_combo_phy_xlate(struct device *dev, const struct of_phandle_args *= args) +{ + struct k1_pcie_phy *k1_phy =3D dev_get_drvdata(dev); + u32 type; + + /* The argument specifying the PHY mode is required */ + if (args->args_count !=3D 1) + return ERR_PTR(-EINVAL); + + /* We only support PCIe and USB 3 mode */ + type =3D args->args[0]; + if (type !=3D PHY_TYPE_PCIE && type !=3D PHY_TYPE_USB3) + return ERR_PTR(-EINVAL); + + /* This PHY can only be used once */ + if (k1_phy->type !=3D PHY_NONE) + return ERR_PTR(-EBUSY); + + k1_phy->type =3D type; + + return k1_phy->phy; +} + +/* Use the maximum number of PCIe lanes unless limited by device tree */ +static u32 k1_pcie_num_lanes(struct k1_pcie_phy *k1_phy, bool port_a) +{ + struct device *dev =3D k1_phy->dev; + u32 count =3D 0; + u32 max; + int ret; + + ret =3D of_property_read_u32(dev_of_node(dev), "num-lanes", &count); + if (count =3D=3D 1) + return 1; + + if (count =3D=3D 2 && !port_a) + return 2; + + max =3D port_a ? 1 : 2; + if (ret !=3D -EINVAL) + dev_warn(dev, "bad lane count %u for port; using %u\n", + count, max); + + return max; +} + +static int k1_pcie_combo_phy_probe(struct k1_pcie_phy *k1_phy) +{ + struct device *dev =3D k1_phy->dev; + struct regmap *regmap; + int ret; + + /* Setting the PHY mode requires access to the PMU regmap */ + regmap =3D syscon_regmap_lookup_by_phandle(dev_of_node(dev), SYSCON_APMU); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), "failed to get PMU\n"); + k1_phy->pmu =3D regmap; + + ret =3D k1_pcie_combo_phy_calibrate(k1_phy); + if (ret) + return dev_err_probe(dev, ret, "calibration failed\n"); + + /* Needed by k1_pcie_combo_phy_xlate(), which also sets k1_phy->type */ + dev_set_drvdata(dev, k1_phy); + + return 0; +} + +static int k1_pcie_phy_probe(struct platform_device *pdev) +{ + struct phy *(*xlate)(struct device *dev, + const struct of_phandle_args *args); + struct device *dev =3D &pdev->dev; + struct reset_control *phy_reset; + struct phy_provider *provider; + struct k1_pcie_phy *k1_phy; + bool probing_port_a; + int ret; + + xlate =3D of_device_get_match_data(dev); + probing_port_a =3D xlate =3D=3D k1_pcie_combo_phy_xlate; + + /* Only the combo PHY can calibrate, so it must probe first */ + if (!k1_phy_rterm_valid() && !probing_port_a) + return -EPROBE_DEFER; + + k1_phy =3D devm_kzalloc(dev, sizeof(*k1_phy), GFP_KERNEL); + if (!k1_phy) + return -ENOMEM; + k1_phy->dev =3D dev; + + k1_phy->regs =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(k1_phy->regs)) + return dev_err_probe(dev, PTR_ERR(k1_phy->regs), + "error mapping registers\n"); + + /* De-assert the PHY (global) reset and leave it that way */ + phy_reset =3D devm_reset_control_get_exclusive_deasserted(dev, "phy"); + if (IS_ERR(phy_reset)) + return PTR_ERR(phy_reset); + + if (probing_port_a) { + ret =3D k1_pcie_combo_phy_probe(k1_phy); + if (ret) + return dev_err_probe(dev, ret, + "error probing combo phy\n"); + } + + k1_phy->pcie_lanes =3D k1_pcie_num_lanes(k1_phy, probing_port_a); + + k1_phy->phy =3D devm_phy_create(dev, NULL, &k1_pcie_phy_ops); + if (IS_ERR(k1_phy->phy)) + return dev_err_probe(dev, PTR_ERR(k1_phy->phy), + "error creating phy\n"); + phy_set_drvdata(k1_phy->phy, k1_phy); + + ret =3D k1_pcie_phy_pll_setup(k1_phy); + if (ret) + return dev_err_probe(dev, ret, "error initializing clock\n"); + + provider =3D devm_of_phy_provider_register(dev, xlate); + if (IS_ERR(provider)) + return dev_err_probe(dev, PTR_ERR(provider), + "error registering provider\n"); + return 0; +} + +static const struct of_device_id k1_pcie_phy_of_match[] =3D { + { .compatible =3D "spacemit,k1-combo-phy", k1_pcie_combo_phy_xlate, }, + { .compatible =3D "spacemit,k1-pcie-phy", of_phy_simple_xlate, }, + { }, +}; +MODULE_DEVICE_TABLE(of, k1_pcie_phy_of_match); + +static struct platform_driver k1_pcie_phy_driver =3D { + .probe =3D k1_pcie_phy_probe, + .driver =3D { + .of_match_table =3D k1_pcie_phy_of_match, + .name =3D "spacemit-k1-pcie-phy", + } +}; +module_platform_driver(k1_pcie_phy_driver); + +MODULE_DESCRIPTION("SpacemiT K1 PCIe and USB 3 PHY driver"); +MODULE_LICENSE("GPL"); --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75DD433291C for ; Fri, 17 Oct 2025 19:07:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728075; cv=none; b=sWA6uBlCyksmbyCvk+l6BFKN9nGMheGHJMXch0pLiJJz5vv/eI8rm8zr+pNMYC4Xs9ex19PnSlsk+I8o3q2gYdVazemcfhDFjDnZvCW4BHRgRy2i+uQefcwDktA+mw6oigJelGsosNarI7s0A9V1LN9kLFutTZLLw7P9+rjAbEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728075; c=relaxed/simple; bh=3mV6Y1WOOnfPKpyXTGqoq5GDygMnEHONP6TWtDKbvhA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgvcklvZyF5PR8dX+LH5+VIb0ARHP4nRVHhJT49uvSaRTgflMpK6B92VvT0PH6C/cJBLmRaGtJX2s+WLuEYiP0hd7sBCloVvz55wo0NN7VOkrP62nnJGWAG+oDyVL1+Qe/s7H4XLodV+nyLOMEqT/ytflwWC5ei5CTIaxNbNma4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=OqPAh6mn; arc=none smtp.client-ip=209.85.166.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="OqPAh6mn" Received: by mail-io1-f66.google.com with SMTP id ca18e2360f4ac-88703c873d5so92023739f.3 for ; Fri, 17 Oct 2025 12:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728071; x=1761332871; darn=vger.kernel.org; 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=mBS3fVW3ZRZzI3XYsea9198twRBcVje3YAE1Y91+/ig=; b=OqPAh6mnPy24mPVamNbPYktV35IJs+mndo5ZWYQgI7b6fQ+gDk+nps/zqxCdSJkPr7 xVzlZ/Qtf6j+IH6ru+NwiKRiqSebXZ0V0uF6H5qqkjGo/rWSi5TAabOYwSaZygnQj31e DmYup+yvH2Jv3187b6o/LvR0PG9hft6AL7fVJ+H4IKFkVbifKTzJIZAtvIGLrt8oR15q 1tmzjUTCyuooN8kPHCiku39czATxKystvmRsRL1BVVQXZ1NfZ+vsiEN+kBoXXrAnD0tj vnM+gdb6u2C7PG3lv7qawpZNmg2k7I+IwSgFg332+8JVcTd2/JdYoS88rWeiW4G14RYv vA4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728071; x=1761332871; 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=mBS3fVW3ZRZzI3XYsea9198twRBcVje3YAE1Y91+/ig=; b=Zwxks32XjO6+9G56h7xJ8f46tf2U9tJOqsXW2QStn0MtCuKnduRzgKvuS0+HlbriPx t2LAa+PN/jrp65p0E9y0rcA2g1mBcS8IvDyRU4/5PakXv/WvjC7iexygdot8lNTIPgK3 Q1M+w+OogBSnSB8cD+y8CKXFG6fzTIYYDNAomnj+odhvv4bu1BeN/+tg0mX5yQ3yD2ZQ qKYC183pHgPdaeaqA6l/+HYlB3h1Gq1RUjLHsASygqEc+7270AVk2sO2KHUA0XGZdtAb 47lGMKDr/4JTvjv+7FLHeQLs6QpUc+3mR70nCKQQZ7+EsW0ORkYT3jNBleW4Lqqf2ZYt LdjQ== X-Forwarded-Encrypted: i=1; AJvYcCXh9B1QzggCCNK2AuDjTuwn5ZzH4q978u5BDmaQsuD3yDrw3uoJpE5epSz6Y9Xv7m86obmyqRAv1kRW2C0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3HCTEsx9SQ/MisAfds+J4oMTKxYxIUe1lACuQbBgsYvpBySyR y9yqkdqMZ4tw/Ed5BOiYggKVxlFKKQL4Oqt8PQS9FqPPokV3L2239VpBGkyUrJAjo5w= X-Gm-Gg: ASbGncu+IJ8CDRMwPdr6FvmpQxnBmf8wtCoC3Q78WH4ix54gLYdRnW4Z6XQnKEF6mj1 Cl7hDUkVgU+PYDfRfgsFLp4FFN8fPya007lIVBiqkx7Yj0LM3Mw5HVbG913n26Tcj3cfnsLh2gi PE6yEFcJXXYnx25ajkNUciV3zflIq8xqcr0oOm2U+E1ReVUcY+WK+TStcY3R46HSjlOYk6vsR8O FsWo7nitz4zVZk3E+bZAKDG0AEsbYrDb8ZEgzkL3n4hyW4XoyWm9LFsqi/gAPoqdpoDYeIYpf4o S69lzEmcslvqFgnGKKuUDPpQQE8jC7uzcfODPVwOg79IhgI6BLGVT91XuTKxZ/4b0yfSZXNVpEs hrd5OPw+8gMyY3KwO2xN3i/rVdmO+VjbRKi6j0H1a229DYIMWkpg0BVFrSq5/HXBQFQ12lozIiZ WYDIwcwx+aHj9SSYwD+j8QPbN1J+rpPi5OLhMunmL1S6o= X-Google-Smtp-Source: AGHT+IFSD3ud0FH/nM9iJN+g9sMr1JqpEpGEFCYkT3M5Aw2WpbvXFn8tHrpdxelIlXuQ7y/UBoZgiQ== X-Received: by 2002:a92:cd82:0:b0:426:39a:90f1 with SMTP id e9e14a558f8ab-430c527dc54mr68263485ab.18.1760728071278; Fri, 17 Oct 2025 12:07:51 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:50 -0700 (PDT) From: Alex Elder To: lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org, bhelgaas@google.com Cc: dlan@gentoo.org, p.zabel@pengutronix.de, christian.bruel@foss.st.com, thippeswamy.havalige@amd.com, krishna.chundru@oss.qualcomm.com, mayank.rana@oss.qualcomm.com, qiang.yu@oss.qualcomm.com, shradha.t@samsung.com, inochiama@gmail.com, guodong@riscstar.com, linux-pci@vger.kernel.org, spacemit@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/7] PCI: spacemit: introduce SpacemiT PCIe host driver Date: Fri, 17 Oct 2025 14:07:37 -0500 Message-ID: <20251017190740.306780-6-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Introduce a driver for the PCIe host controller found in the SpacemiT K1 SoC. The hardware is derived from the Synopsys DesignWare PCIe IP. The driver supports three PCIe ports that operate at PCIe gen2 transfer rates (5 GT/sec). The first port uses a combo PHY, which may be configured for use for USB 3 instead. Signed-off-by: Alex Elder --- drivers/pci/controller/dwc/Kconfig | 10 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-spacemit-k1.c | 311 ++++++++++++++++++ 3 files changed, 322 insertions(+) create mode 100644 drivers/pci/controller/dwc/pcie-spacemit-k1.c diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dw= c/Kconfig index 349d4657393c9..ede59b34c99ba 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -509,6 +509,16 @@ config PCI_KEYSTONE_EP on DesignWare hardware and therefore the driver re-uses the DesignWare core functions to implement the driver. =20 +config PCIE_SPACEMIT_K1 + tristate "SpacemiT K1 PCIe controller (host mode)" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on PCI && OF && HAS_IOMEM + select PCIE_DW_HOST + default ARCH_SPACEMIT + help + Enables support for the PCIe controller in the K1 SoC operating + in host mode. + config PCIE_VISCONTI_HOST bool "Toshiba Visconti PCIe controller" depends on ARCH_VISCONTI || COMPILE_TEST diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/d= wc/Makefile index 7ae28f3b0fb39..662b0a219ddc4 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_PCIE_UNIPHIER) +=3D pcie-uniphier.o obj-$(CONFIG_PCIE_UNIPHIER_EP) +=3D pcie-uniphier-ep.o obj-$(CONFIG_PCIE_VISCONTI_HOST) +=3D pcie-visconti.o obj-$(CONFIG_PCIE_RCAR_GEN4) +=3D pcie-rcar-gen4.o +obj-$(CONFIG_PCIE_SPACEMIT_K1) +=3D pcie-spacemit-k1.o obj-$(CONFIG_PCIE_STM32_HOST) +=3D pcie-stm32.o obj-$(CONFIG_PCIE_STM32_EP) +=3D pcie-stm32-ep.o =20 diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/co= ntroller/dwc/pcie-spacemit-k1.c new file mode 100644 index 0000000000000..e3264e37f4fc2 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c @@ -0,0 +1,311 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * SpacemiT K1 PCIe host driver + * + * Copyright (C) 2025 by RISCstar Solutions Corporation. All rights reser= ved. + * Copyright (c) 2023, spacemit Corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie-designware.h" + +#define PCI_VENDOR_ID_SPACEMIT 0x201f +#define PCI_DEVICE_ID_SPACEMIT_K1 0x0001 + +/* Offsets and field definitions for link management registers */ + +#define K1_PHY_AHB_IRQ_EN 0x0000 +#define PCIE_INTERRUPT_EN BIT(0) + +#define K1_PHY_AHB_LINK_STS 0x0004 +#define SMLH_LINK_UP BIT(1) +#define RDLH_LINK_UP BIT(12) + +#define INTR_ENABLE 0x0014 +#define MSI_CTRL_INT BIT(11) + +/* Some controls require APMU regmap access */ +#define SYSCON_APMU "spacemit,apmu" + +/* Offsets and field definitions for APMU registers */ + +#define PCIE_CLK_RESET_CONTROL 0x0000 +#define LTSSM_EN BIT(6) +#define PCIE_AUX_PWR_DET BIT(9) +#define PCIE_RC_PERST BIT(12) /* 1: assert PERST# */ +#define APP_HOLD_PHY_RST BIT(30) +#define DEVICE_TYPE_RC BIT(31) /* 0: endpoint; 1: RC */ + +#define PCIE_CONTROL_LOGIC 0x0004 +#define PCIE_SOFT_RESET BIT(0) + +struct k1_pcie { + struct dw_pcie pci; + struct phy *phy; + void __iomem *link; + struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */ + u32 pmu_off; +}; + +#define to_k1_pcie(dw_pcie) \ + platform_get_drvdata(to_platform_device((dw_pcie)->dev)) + +static void k1_pcie_toggle_soft_reset(struct k1_pcie *k1) +{ + u32 offset; + u32 val; + + /* + * Write, then read back to guarantee it has reached the device + * before we start the delay. + */ + offset =3D k1->pmu_off + PCIE_CONTROL_LOGIC; + regmap_set_bits(k1->pmu, offset, PCIE_SOFT_RESET); + regmap_read(k1->pmu, offset, &val); + + mdelay(2); + + regmap_clear_bits(k1->pmu, offset, PCIE_SOFT_RESET); +} + +/* Enable app clocks, deassert resets */ +static int k1_pcie_activate(struct k1_pcie *k1) +{ + struct dw_pcie *pci =3D &k1->pci; + int ret; + + ret =3D clk_bulk_prepare_enable(ARRAY_SIZE(pci->app_clks), pci->app_clks); + if (ret) + return ret; + + ret =3D reset_control_bulk_deassert(ARRAY_SIZE(pci->app_rsts), + pci->app_rsts); + if (ret) + goto err_disable_clks; + + return 0; + +err_disable_clks: + clk_bulk_disable_unprepare(ARRAY_SIZE(pci->app_clks), pci->app_clks); + + return ret; +} + +/* Assert resets, disable app clocks */ +static void k1_pcie_deactivate(struct k1_pcie *k1) +{ + struct dw_pcie *pci =3D &k1->pci; + + reset_control_bulk_assert(ARRAY_SIZE(pci->app_rsts), pci->app_rsts); + clk_bulk_disable_unprepare(ARRAY_SIZE(pci->app_clks), pci->app_clks); +} + +static int k1_pcie_init(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 offset; + u32 mask; + u32 val; + int ret; + + k1_pcie_toggle_soft_reset(k1); + + ret =3D k1_pcie_activate(k1); + if (ret) + return ret; + + ret =3D phy_init(k1->phy); + if (ret) { + k1_pcie_deactivate(k1); + + return ret; + } + + /* Set the PCI vendor and device ID */ + dw_pcie_dbi_ro_wr_en(pci); + dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, PCI_VENDOR_ID_SPACEMIT); + dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, PCI_DEVICE_ID_SPACEMIT_K1); + dw_pcie_dbi_ro_wr_dis(pci); + + /* + * Assert fundamental reset (drive PERST# low). Put the port in + * root complex mode, and indicate that Vaux (3.3v) is present. + */ + mask =3D PCIE_RC_PERST; + mask |=3D DEVICE_TYPE_RC | PCIE_AUX_PWR_DET; + + /* + * Write, then read back to guarantee it has reached the device + * before we start the delay. + */ + offset =3D k1->pmu_off + PCIE_CLK_RESET_CONTROL; + regmap_set_bits(k1->pmu, offset, mask); + regmap_read(k1->pmu, offset, &val); + + mdelay(PCIE_T_PVPERL_MS); + + /* Deassert fundamental reset (drive PERST# high) */ + regmap_clear_bits(k1->pmu, offset, PCIE_RC_PERST); + + return 0; +} + +static void k1_pcie_deinit(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + struct k1_pcie *k1 =3D to_k1_pcie(pci); + + /* Assert fundamental reset (drive PERST# low) */ + regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, + PCIE_RC_PERST); + + phy_exit(k1->phy); + + k1_pcie_deactivate(k1); +} + +static const struct dw_pcie_host_ops k1_pcie_host_ops =3D { + .init =3D k1_pcie_init, + .deinit =3D k1_pcie_deinit, +}; + +static bool k1_pcie_link_up(struct dw_pcie *pci) +{ + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 val; + + val =3D readl_relaxed(k1->link + K1_PHY_AHB_LINK_STS); + + return (val & RDLH_LINK_UP) && (val & SMLH_LINK_UP); +} + +static int k1_pcie_start_link(struct dw_pcie *pci) +{ + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 val; + + /* Stop holding the PHY in reset, and enable link training */ + regmap_update_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, + APP_HOLD_PHY_RST | LTSSM_EN, LTSSM_EN); + + /* Enable the MSI interrupt */ + writel_relaxed(MSI_CTRL_INT, k1->link + INTR_ENABLE); + + /* Top-level interrupt enable */ + val =3D readl_relaxed(k1->link + K1_PHY_AHB_IRQ_EN); + val |=3D PCIE_INTERRUPT_EN; + writel_relaxed(val, k1->link + K1_PHY_AHB_IRQ_EN); + + return 0; +} + +static void k1_pcie_stop_link(struct dw_pcie *pci) +{ + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 val; + + /* Disable interrupts */ + val =3D readl_relaxed(k1->link + K1_PHY_AHB_IRQ_EN); + val &=3D ~PCIE_INTERRUPT_EN; + writel_relaxed(val, k1->link + K1_PHY_AHB_IRQ_EN); + + writel_relaxed(0, k1->link + INTR_ENABLE); + + /* Disable the link and hold the PHY in reset */ + regmap_update_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, + APP_HOLD_PHY_RST | LTSSM_EN, APP_HOLD_PHY_RST); +} + +static const struct dw_pcie_ops k1_pcie_ops =3D { + .link_up =3D k1_pcie_link_up, + .start_link =3D k1_pcie_start_link, + .stop_link =3D k1_pcie_stop_link, +}; + +static int k1_pcie_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct k1_pcie *k1; + int ret; + + k1 =3D devm_kzalloc(dev, sizeof(*k1), GFP_KERNEL); + if (!k1) + return -ENOMEM; + + k1->pmu =3D syscon_regmap_lookup_by_phandle_args(dev_of_node(dev), + SYSCON_APMU, 1, + &k1->pmu_off); + if (IS_ERR(k1->pmu)) + return dev_err_probe(dev, PTR_ERR(k1->pmu), + "failed to lookup PMU registers\n"); + + k1->link =3D devm_platform_ioremap_resource_byname(pdev, "link"); + if (!k1->link) + return dev_err_probe(dev, -ENOMEM, + "failed to map \"link\" registers\n"); + + ret =3D devm_regulator_get_enable(dev, "vpcie3v3"); + if (ret) + return dev_err_probe(dev, ret, + "failed to get \"vpcie3v3\" supply\n"); + + /* Hold the PHY in reset until we start the link */ + regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, + APP_HOLD_PHY_RST); + + k1->phy =3D devm_phy_get(dev, NULL); + if (IS_ERR(k1->phy)) + return dev_err_probe(dev, PTR_ERR(k1->phy), + "failed to get PHY\n"); + + k1->pci.dev =3D dev; + k1->pci.ops =3D &k1_pcie_ops; + dw_pcie_cap_set(&k1->pci, REQ_RES); + + k1->pci.pp.ops =3D &k1_pcie_host_ops; + k1->pci.pp.num_vectors =3D MAX_MSI_IRQS; + + platform_set_drvdata(pdev, k1); + + ret =3D dw_pcie_host_init(&k1->pci.pp); + if (ret) + return dev_err_probe(dev, ret, "failed to initialize host\n"); + + return 0; +} + +static void k1_pcie_remove(struct platform_device *pdev) +{ + struct k1_pcie *k1 =3D platform_get_drvdata(pdev); + + dw_pcie_host_deinit(&k1->pci.pp); +} + +static const struct of_device_id k1_pcie_of_match_table[] =3D { + { .compatible =3D "spacemit,k1-pcie", }, + { }, +}; + +static struct platform_driver k1_pcie_driver =3D { + .probe =3D k1_pcie_probe, + .remove =3D k1_pcie_remove, + .driver =3D { + .name =3D "spacemit-k1-pcie", + .of_match_table =3D k1_pcie_of_match_table, + .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, + }, +}; +module_platform_driver(k1_pcie_driver); --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9E0E336EC3 for ; Fri, 17 Oct 2025 19:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728077; cv=none; b=kIKpv8soWriywswU+9p51x3AxNJQ2LPOsKfBGPrObUvb8J5yMg6wXINMjHwM2cmrc81ThldMf7zr21Dlu48heY4g3gY7dfLwJkHKbsHpzqTA4eXNFE0axEElzV8ITOFKepK67iCRgmTFUOty38s7KA0VCzhaRoEelEKAZF7In4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728077; c=relaxed/simple; bh=ENUIv7Y5invqW9/JGzvHqg+snh4IuRykpfxDvM9mXnw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OsYu64kUdbcVDhg/4hWUM/YagS1gnGfkqcyfuq1D8kLkcUvCzgXhKWHSMDuW4ipyQqGCHw715xK4f2w4wbet5JGDnOQDzUXzRzkyijb8ljIJcbBm9/CY7MQNyGJKkE5zChueluLga3qDkLB7LEhvfI5qMCopCm+cTDoh2F3pogw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=g7Bw5wPU; arc=none smtp.client-ip=209.85.166.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="g7Bw5wPU" Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-430d098121cso1135875ab.0 for ; Fri, 17 Oct 2025 12:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728074; x=1761332874; darn=vger.kernel.org; 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=sfI/HxKZ5aLnk6gHq9CwlPfs/i+7HssnS2IuZUrc0Ms=; b=g7Bw5wPUbKKexD070DW7f5b/zvz8RKv4dL7L1KlYgBiqlPcGryG+mLbtnrF6JpJLeK ZkhN5SX5p6mBxtJHhoPG+6oB3C9cjJn/i0/HLxwuNTF6J/TX+xlr6B/+zeHBmNQsa1U3 9hk+S9ZtHIztOZLeg1IBN9jS5OTwTzegs2cb7p/UEdHd17sJfbSm/LooM2J0FVYiAu9L IJ7FpzbQwoPemxN03PJpF0uq5OpbX/MUJXdt6ZA9a91K20pdqP2QaGqcjz1pPd7cshpg 4lCYMG0cYjGEruBQDYT8olKVvZ5arqvu+cykYaL5G4NmNqwZgHGckd02NRViGduEqOyi 4fTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728074; x=1761332874; 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=sfI/HxKZ5aLnk6gHq9CwlPfs/i+7HssnS2IuZUrc0Ms=; b=K7VqWJmiLgxGhiN9VA2VDW/SI4SCWD9LB9sdCMeyMmfm/J9roVRu/EQaaYumhADbeC Qt1LKYQBfpdMjInlE/Q7bvxJdngXJBew+/JOZegiyS9NlwT7R3aQA4kiCSk+P2ocbPcJ L4I7J9MHPdJDgEVmd0Zshdp3rWbEcGrsfETpB8z/c1iMFAD6NyjfXsEcoJwNyIWm8xNq XxjTjkj1cCZSZuvSl8Qn/tGTMsGmrOHosVWhnZEenCoMwvLD3fS7ZwLwM408fEcqMysp kho08Fethb3ziWCcJiS7TgTOVaiMeAL5LVTKbb1dt8BzfrfkxE1GnQUPAvVciNAW5bQp 4KUw== X-Forwarded-Encrypted: i=1; AJvYcCWEuV9OvAGLSrpUyGTqw8PhLoORWeB7tXMYxxuJzdMLA6TABAkwQlTPmNaXK1ywPvzy3ZFnFH9zTqzD9P8=@vger.kernel.org X-Gm-Message-State: AOJu0YxVWZJzyfokIGfOqB4377KFZQ6Swc7b6b5FrXVhBq1VKgAhVp9W HZOR9MM6fRTURlxCaqdqqG31lLr4QiTg68TaPnxko3/f1YxXCn8K5q9/+8y541t9nX6Jb7ofLAq 308yLVuw= X-Gm-Gg: ASbGncvThbBg6qjsjSV0FJtD3WFwyI418bSasvwrozjhldIxBhVIR3XSSwQeYu94MvL M5tX/NCPPwJaT5GPN1xf2ycISU0c7LXRfcOa6ThWvLCe/iSQx/AyLmIjikxTW/pTMNE9jlhpcM7 APBlJxAcA5O2nxr3PWGv9Bo0iNt2jkTnFOLDNtc+AsmskSLKYqQPK7mqciozY7WtNXEeV1fGE4b MASMzFr3o/S0kiJLNsHriJCd+tlVfZTK71IjcuCtUZWuGDL8FQY1ftVm14FsxjAx6Exmw9362SV lWOBuTkhBpoTPUg9HmCt7fNzEs1znDd+3FdteBSa3vL0IR7b3KIA+pGVBm8uQfNm1q3K3+RGZGK r4Mck4TEedtXdmTulkAwtuxOH+ZLPuZ5e7a7jV70LyiVBx2fGAH6jZVE3ygn0J0wtw68eAq9xkh gc9fwd8EnwSpQ3jpunnvC8EmYxYFVaKSLQKmWH0lOsD9kbQKBJ2L4+cA== X-Google-Smtp-Source: AGHT+IGgZuyks8/SPpqGraEYOHD64JLctbaQzahczxp3t8Isq+v66Q/LNb1tqq+q1CnCV61aP2fWQA== X-Received: by 2002:a05:6e02:1a42:b0:430:b338:e55 with SMTP id e9e14a558f8ab-430c53068c3mr81229225ab.29.1760728072707; Fri, 17 Oct 2025 12:07:52 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:52 -0700 (PDT) From: Alex Elder To: dlan@gentoo.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/7] riscv: dts: spacemit: add a PCIe regulator Date: Fri, 17 Oct 2025 14:07:38 -0500 Message-ID: <20251017190740.306780-7-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Define a 3.3v fixed voltage regulator to be used by PCIe on the Banana Pi BPI-F3. On this platform, this regulator is always on. Signed-off-by: Alex Elder --- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/b= oot/dts/spacemit/k1-bananapi-f3.dts index 2aaaff77831e1..046ad441b7b4e 100644 --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts @@ -30,6 +30,14 @@ led1 { default-state =3D "on"; }; }; + + pcie_vcc_3v3: pcie-vcc3v3 { + compatible =3D "regulator-fixed"; + regulator-name =3D "PCIE_VCC3V3"; + regulator-min-microvolt =3D <3300000>; + regulator-max-microvolt =3D <3300000>; + regulator-always-on; + }; }; =20 &emmc { --=20 2.48.1 From nobody Sat Feb 7 21:24:08 2026 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C8F1336ED6 for ; Fri, 17 Oct 2025 19:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728078; cv=none; b=XsV/Ah3x5j28AfVQAs2DgNNcrGFPE1AROMAzUHHZXtwY645x7VCOh+7+fwIAYBNiqwp3E0hKhLd9uSXZbwVbtyqdMMTK0ReXwdlmZc3kUFqW2p1KRroaXDzJXEECY4RJ+NW06HuWJl+tQ2Hx8jv/v2eiInKY3iWKgG9pS1eYycY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760728078; c=relaxed/simple; bh=WajF4YomrPeBXnIl6Pb3JlCid5sH+q3PqlRmRFnM64M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lYHJ6OxcARt4zM2DuBU2q3rNdxzijneZPEZuohUAF7NsO7dgXo6ArylQUD+ODDBZaf5LtbeVO+81r+vJvoZQgUCtvGGLCeWw4pPQh6oesnGTa6Wu94zlprD+OfLWPkJIeysbCjYPd53xpZgK7MPNyWwjAYP0eAVyy9lChOgrzMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=BI1JSznC; arc=none smtp.client-ip=209.85.166.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="BI1JSznC" Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-430c6eef4b9so5617005ab.0 for ; Fri, 17 Oct 2025 12:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1760728074; x=1761332874; darn=vger.kernel.org; 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=jVuMJueWnAkYuh5TQkXI6Y6hYDpxc+wPv4az6s1+IXE=; b=BI1JSznCJQVu8HcPUgDTAQuOhTaRkkcOci1TLcZRawBo7s2toK+JEezxBETa56oVj/ 45ajGUjSGBSiBeG40XNbOIoY9aKeYyO3vz8JveA8WSHGTiXou0QqUSAz54n+462ZRnlO i4c00gYeeMi/A5fTmZPI7rNswwLKSXZ45UnOWGNniRA44uco79N/5EY539YCigPt+2mH NyD32Qh2bCkfX245tyaUoavunareRpbofiUrZj/csFfjjE21e4n2o0WKG+Nvn4P4pVq/ v0FdHH7Cmjpd2/jLNO5JQkQqD5EqRItGjexErn3xIIUIRjtCmf5X08U6yv5q5mlhNJN0 lfVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760728074; x=1761332874; 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=jVuMJueWnAkYuh5TQkXI6Y6hYDpxc+wPv4az6s1+IXE=; b=xKxThf+elE0naobpaRROZrurNZODON24aKn9qA926AUYEqRiycpavmlJ3WAnHtc6Ew QdZODl8nJV0+qmbRtwxSrou4GyROD56zGOwBdDLB4QVfdFJCG/YtZeU5vQ1XAwvgj3jf Xyg3KsWBYPIDDOP69AvmpflyAzWjb5+asGQyDM3zWftjxyx8h9zf5yDKW1ialFFUF3Om UoT4iI+mo6ME7PnMCYk7vsHH+uaGYKNf4hebWyr3FjbZRjhCbr2Ei15mgNuid+7q360C Ehdaw3jbtqNA0Q/UKudENwkZSI+C/F6Vc4IGuFNEC0NtxiTeWceSDMcJB80c8+9jwJYH q2fg== X-Forwarded-Encrypted: i=1; AJvYcCWmeKG9cn+QYTkCI4bgGQR4a6TmDxKm1vMolGADeQu5yT/SnKAXEgul0oGMNZ0SRix1uewCgfXa7auH1Ls=@vger.kernel.org X-Gm-Message-State: AOJu0YwUIODKL2YaYbKGlCxzEtgFu7r9S8x8YnyjQ9h0iiq981fSeMLU 4fG35jFoP14DqFUM6sIbQEYnzGYYOMoM6DfGkxbHF8Akgjvx4WxT/ZVNS35ueCjqYGg= X-Gm-Gg: ASbGncuYTEZVG+PwemLPVRbA+n9zad+cVW8yxwGJAy4JXn+9C1nfGZyb0LQDtRNyu4U Pf4LsXNGY+8hHU/lrCZ9YqsD1nakftFathcffEj6zdhgXUkCjQynH/xhhCUEuTBaJUh50QE0tQ7 0558OVKyPUQHmnZPLD/0NCOAe0XA0SQC75Q+LzLCMpl3BZr+eCcwtgii0u5iZIakxxxxnTF47yn HllF6JrsSKmaJ5n9/7K274iyq5zotY2MyqTCkx5gpZmjF2ZCDomzor1/Ypagi7RN37YjLMfySX5 mZ17FC/XdQR7MJzTKuux3j8mflygBLjPbFUeaukUbAHxehUfZPmOxSB+hPN8hbiKEP7ZQ5UYUhI va2vrMwM5xSvbQAkmSJFwuoyrXVm4NWEidUSxepJAa2AEhQVhfVez0DgC8qND4CGVHmbuA4OgJZ iZxMblu7HaJqmXba6J0tDE7Qsx5DrwpN6/JAiXeMHFN9fu7sYv9fiD2w== X-Google-Smtp-Source: AGHT+IES/rfKhlvARUhnX0tfzUfrV5BOC+gvOxLXp1w4hAUg6/0iisUNrZFn1K7mYG1Jq6GYnw5WKw== X-Received: by 2002:a92:cd83:0:b0:430:ae8b:d2d8 with SMTP id e9e14a558f8ab-430c526926cmr72010455ab.15.1760728074017; Fri, 17 Oct 2025 12:07:54 -0700 (PDT) Received: from zippy.localdomain (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5a8a9768b98sm153462173.46.2025.10.17.12.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 12:07:53 -0700 (PDT) From: Alex Elder To: dlan@gentoo.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, guodong@riscstar.com, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 7/7] riscv: dts: spacemit: PCIe and PHY-related updates Date: Fri, 17 Oct 2025 14:07:39 -0500 Message-ID: <20251017190740.306780-8-elder@riscstar.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251017190740.306780-1-elder@riscstar.com> References: <20251017190740.306780-1-elder@riscstar.com> 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 Content-Type: text/plain; charset="utf-8" Define PCIe and PHY-related Device Tree nodes for the SpacemiT K1 SoC. Enable the combo PHY and the two PCIe-only PHYs on the Banana Pi BPI-F3 board. The combo PHY is used for USB on this board, and that will be enabled when USB 3 support is accepted. The combo PHY must perform a calibration step to determine configuration values used by the PCIe-only PHYs. As a result, it must be enabled if either of the other two PHYs is enabled. Signed-off-by: Alex Elder --- .../boot/dts/spacemit/k1-bananapi-f3.dts | 30 ++++ arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 33 ++++ arch/riscv/boot/dts/spacemit/k1.dtsi | 146 ++++++++++++++++++ 3 files changed, 209 insertions(+) diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/b= oot/dts/spacemit/k1-bananapi-f3.dts index 046ad441b7b4e..6d566780aed9d 100644 --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts @@ -40,6 +40,12 @@ pcie_vcc_3v3: pcie-vcc3v3 { }; }; =20 +&combo_phy { + pinctrl-names =3D "default"; + pinctrl-0 =3D <&pcie0_3_cfg>; + status =3D "okay"; +}; + &emmc { bus-width =3D <8>; mmc-hs400-1_8v; @@ -100,6 +106,30 @@ &pdma { status =3D "okay"; }; =20 +&pcie1_phy { + pinctrl-names =3D "default"; + pinctrl-0 =3D <&pcie1_3_cfg>; + status =3D "okay"; +}; + +&pcie2_phy { + pinctrl-names =3D "default"; + pinctrl-0 =3D <&pcie2_4_cfg>; + status =3D "okay"; +}; + +&pcie1 { + phys =3D <&pcie1_phy>; + vpcie3v3-supply =3D <&pcie_vcc_3v3>; + status =3D "okay"; +}; + +&pcie2 { + phys =3D <&pcie2_phy>; + vpcie3v3-supply =3D <&pcie_vcc_3v3>; + status =3D "okay"; +}; + &uart0 { pinctrl-names =3D "default"; pinctrl-0 =3D <&uart0_2_cfg>; diff --git a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi b/arch/riscv/boot= /dts/spacemit/k1-pinctrl.dtsi index aff19c86d5ff3..5bacb6aff23f8 100644 --- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi +++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi @@ -69,6 +69,39 @@ uart0-2-pins { }; }; =20 + pcie0_3_cfg: pcie0-3-cfg { + pcie0-3-pins { + pinmux =3D , /* PERST# */ + , /* WAKE# */ + ; /* CLKREQ# */ + + bias-pull-up =3D <0>; + drive-strength =3D <21>; + }; + }; + + pcie1_3_cfg: pcie1-3-cfg { + pcie1-3-pins { + pinmux =3D , /* PERST# */ + , /* WAKE# */ + ; /* CLKREQ# */ + + bias-pull-up =3D <0>; + drive-strength =3D <21>; + }; + }; + + pcie2_4_cfg: pcie2-4-cfg { + pcie2-4-pins { + pinmux =3D , /* PERST# */ + , /* WAKE# */ + ; /* CLKREQ# */ + + bias-pull-up =3D <0>; + drive-strength =3D <21>; + }; + }; + pwm14_1_cfg: pwm14-1-cfg { pwm14-1-pins { pinmux =3D ; diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spa= cemit/k1.dtsi index 6cdcd80a7c83b..214216fdecd32 100644 --- a/arch/riscv/boot/dts/spacemit/k1.dtsi +++ b/arch/riscv/boot/dts/spacemit/k1.dtsi @@ -4,6 +4,7 @@ */ =20 #include +#include =20 /dts-v1/; / { @@ -358,6 +359,52 @@ syscon_rcpu2: system-controller@c0888000 { #reset-cells =3D <1>; }; =20 + combo_phy: phy@c0b10000 { + compatible =3D "spacemit,k1-combo-phy"; + reg =3D <0x0 0xc0b10000 0x0 0x1000>; + clocks =3D <&vctcxo_24m>, + <&syscon_apmu CLK_PCIE0_DBI>, + <&syscon_apmu CLK_PCIE0_MASTER>, + <&syscon_apmu CLK_PCIE0_SLAVE>; + clock-names =3D "refclk", + "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE0_GLOBAL>, + <&syscon_apmu RESET_PCIE0_DBI>, + <&syscon_apmu RESET_PCIE0_MASTER>, + <&syscon_apmu RESET_PCIE0_SLAVE>; + reset-names =3D "phy", + "dbi", + "mstr", + "slv"; + #phy-cells =3D <1>; + spacemit,apmu =3D <&syscon_apmu>; + status =3D "disabled"; + }; + + pcie1_phy: phy@c0c10000 { + compatible =3D "spacemit,k1-pcie-phy"; + reg =3D <0x0 0xc0c10000 0x0 0x1000>; + clocks =3D <&vctcxo_24m>; + clock-names =3D "refclk"; + resets =3D <&syscon_apmu RESET_PCIE1_GLOBAL>; + reset-names =3D "phy"; + #phy-cells =3D <0>; + status =3D "disabled"; + }; + + pcie2_phy: phy@c0d10000 { + compatible =3D "spacemit,k1-pcie-phy"; + reg =3D <0x0 0xc0d10000 0x0 0x1000>; + clocks =3D <&vctcxo_24m>; + clock-names =3D "refclk"; + resets =3D <&syscon_apmu RESET_PCIE2_GLOBAL>; + reset-names =3D "phy"; + #phy-cells =3D <0>; + status =3D "disabled"; + }; + syscon_apbc: system-controller@d4015000 { compatible =3D "spacemit,k1-syscon-apbc"; reg =3D <0x0 0xd4015000 0x0 0x1000>; @@ -847,6 +894,105 @@ pcie-bus { #size-cells =3D <2>; dma-ranges =3D <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, <0x0 0xb8000000 0x1 0x38000000 0x3 0x48000000>; + pcie0: pcie@ca000000 { + compatible =3D "spacemit,k1-pcie"; + reg =3D <0x0 0xca000000 0x0 0x00001000>, + <0x0 0xca300000 0x0 0x0001ff24>, + <0x0 0x8f000000 0x0 0x00002000>, + <0x0 0xc0b20000 0x0 0x00001000>; + reg-names =3D "dbi", + "atu", + "config", + "link"; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0x00000000 0x0 0x8f002000 0x0 0x00100000>, + <0x02000000 0x0 0x80000000 0x0 0x80000000 0x0 0x0f000000>; + interrupts =3D <141>; + interrupt-names =3D "msi"; + clocks =3D <&syscon_apmu CLK_PCIE0_DBI>, + <&syscon_apmu CLK_PCIE0_MASTER>, + <&syscon_apmu CLK_PCIE0_SLAVE>; + clock-names =3D "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE0_DBI>, + <&syscon_apmu RESET_PCIE0_MASTER>, + <&syscon_apmu RESET_PCIE0_SLAVE>; + reset-names =3D "dbi", + "mstr", + "slv"; + device_type =3D "pci"; + spacemit,apmu =3D <&syscon_apmu 0x03cc>; + status =3D "disabled"; + }; + + pcie1: pcie@ca400000 { + compatible =3D "spacemit,k1-pcie"; + reg =3D <0x0 0xca400000 0x0 0x00001000>, + <0x0 0xca700000 0x0 0x0001ff24>, + <0x0 0x9f000000 0x0 0x00002000>, + <0x0 0xc0c20000 0x0 0x00001000>; + reg-names =3D "dbi", + "atu", + "config", + "link"; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0x00000000 0x0 0x9f002000 0x0 0x00100000>, + <0x02000000 0x0 0x90000000 0x0 0x90000000 0x0 0x0f000000>; + interrupts =3D <142>; + interrupt-names =3D "msi"; + clocks =3D <&syscon_apmu CLK_PCIE1_DBI>, + <&syscon_apmu CLK_PCIE1_MASTER>, + <&syscon_apmu CLK_PCIE1_SLAVE>; + clock-names =3D "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE1_DBI>, + <&syscon_apmu RESET_PCIE1_MASTER>, + <&syscon_apmu RESET_PCIE1_SLAVE>; + reset-names =3D "dbi", + "mstr", + "slv"; + device_type =3D "pci"; + spacemit,apmu =3D <&syscon_apmu 0x3d4>; + status =3D "disabled"; + }; + + pcie2: pcie@ca800000 { + compatible =3D "spacemit,k1-pcie"; + reg =3D <0x0 0xca800000 0x0 0x00001000>, + <0x0 0xcab00000 0x0 0x0001ff24>, + <0x0 0xb7000000 0x0 0x00002000>, + <0x0 0xc0d20000 0x0 0x00001000>; + reg-names =3D "dbi", + "atu", + "config", + "link"; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0x00000000 0x0 0xb7002000 0x0 0x00100000>, + <0x42000000 0x0 0xa0000000 0x0 0xa0000000 0x0 0x10000000>, + <0x02000000 0x0 0xb0000000 0x0 0xb0000000 0x0 0x07000000>; + interrupts =3D <143>; + interrupt-names =3D "msi"; + clocks =3D <&syscon_apmu CLK_PCIE2_DBI>, + <&syscon_apmu CLK_PCIE2_MASTER>, + <&syscon_apmu CLK_PCIE2_SLAVE>; + clock-names =3D "dbi", + "mstr", + "slv"; + resets =3D <&syscon_apmu RESET_PCIE2_DBI>, + <&syscon_apmu RESET_PCIE2_MASTER>, + <&syscon_apmu RESET_PCIE2_SLAVE>; + reset-names =3D "dbi", + "mstr", + "slv"; + device_type =3D "pci"; + spacemit,apmu =3D <&syscon_apmu 0x3dc>; + status =3D "disabled"; + }; }; =20 storage-bus { --=20 2.48.1