From nobody Fri Oct 3 16:46:06 2025 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (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 A07C530CD8E; Thu, 28 Aug 2025 02:17:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347426; cv=none; b=LM0ZISwJDq6CfoShTPZiEy9a299Z6pgiK+haI57pyQH2fOtclyKvxsz+ZSjE2wWpOYmBkNtGDvPUlXXg3+Y5WS75ZTn/APheaT5aIBVbJXIXCg9F6zJyjejB3ltWmicjB5zNSf0xFZUAgFiA5OWVxQXxCegXD1OL5SiWkV027fk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347426; c=relaxed/simple; bh=Vb4oqaAF4AAxL3ENJorO5f5xQALMvDpa1QKstivrv7o=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DmOt4GzfeVcrPVKr8nOJMVSrU9AYj9eFVUk/iMn3Io15grGULyJg0hPW2E6yFi0NJnpfQoukJPZWw4uel5QesRy6zo6fhBZiAu9jWcAhnNG2QEQava0QXDlJcER/2G39i+QNUFpHfkLd2fQCxHCU49T4yQS8GnrJ5Gde2/JvEM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AAmTaQs3; arc=none smtp.client-ip=209.85.161.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AAmTaQs3" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-61e06547f73so420270eaf.2; Wed, 27 Aug 2025 19:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756347424; x=1756952224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wGcfuQl3yrFvMTXn2qxpt2B+zvl/KTrt/bi1+ryxB9w=; b=AAmTaQs3s/2BzP+H6ZS56xdR+v8uaNd9/wXfMUNqV7ypX397P8Yf40n7I61lmRu3Cb tXhKRgtHpyY5EoOtbdYTha7UrC1f853ZX7dO+uvMLLBqfRrUsgBXBsHvjOW4lFV0TiBc UkZxTWO8craedvO0oBZTkFKj21pB9Rk2xD4OIuZ76UHE8f/WIiovMCXkCcqaYW6HHBCg Or5nWKm925/GesONlnMmc77z85i68VPaiNtw2nf8RV2ocOwa1byERgp0f9/s3iZmXfxO Cgs+A3DIeBgSrS3keWc/Zr/7GW3HM0w/i65Ssp1M6V+pk4Ka8oVFq9NQIB2T+65av9Eg 6X3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756347424; x=1756952224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wGcfuQl3yrFvMTXn2qxpt2B+zvl/KTrt/bi1+ryxB9w=; b=Kzy7Ev/4NCUnMFPm7A4hswT846J0dUJmmpwhHAtntrc7LcBjLtHLoUS+8Cqiq/xqIq bLjBCtUv9XDnzF6dCLOx560/q79zt4dHF7tgF8Yjt2A7iyz/qrd+QGKMcxXw5Ix5WCPX dLw2ZVIdCbJ+4Y6XwWfcn1eTLE3HqhmBbbegK5cGrFwoaeEPIeANDZlStbqllz+SyPto OJRW/bQh5KBratuCpNS2SOSDeyQIo4mP64dUV/5neVK6w4FJkqDX+DyvgWQriGTZjrrq D6dJbr+NzLxBTB4mIVeqECpRIMvIdqh+imgcE/6tABULez3CfkgFsLpuhcXgfu8yrwDZ GBSA== X-Forwarded-Encrypted: i=1; AJvYcCVTMuGHsBc9xHJSRYOC7MQQXC9RV/FpcOONp43/tzaBLgwmZNxGWbrpTOQmxrl5e+cHA3MPwS1BMLD6@vger.kernel.org, AJvYcCWSMtQqjCXYNVM23NAApOAdutQgwkQYA+ZsaK6wKCBbZTzoUSs55gptLSGg4Ew70YuIrkoAkwkMGATSwJ6i@vger.kernel.org, AJvYcCWb3TTbxT4YxC3suqUQ9udB4zKS5+QhGcsNZsw3JnbERW7AbjyXiVaGNPotXHHwUT/nCXmQKvSYLpc3@vger.kernel.org X-Gm-Message-State: AOJu0Yz2qeTQB6XiLHCjiX5oZP1GWLSLBzkhmabQaXHFsddetaLiaaYh GZUAfhWMR63SIeGtecODwIk2SDUTS+foAie6NwDmZnjyUjlmhSdcrPCP X-Gm-Gg: ASbGnctg3cdTFshclb6xPKnH8Pjgf+hjUj/Hfh/VTGn+fsaev64bES7RNgV13TqwbmP Uw1uE2xPlHQ9mC2xGu655syiTtILTAwXBehjh84mnippQpFvZbTcNerB6n9pVqVA506tXoWnrri PoI+dC1Lzrlp8YJY0RNjwX2QiVSFGQNZJ0iU6Ohnt1XyeU/EpCY5DAi3k41M5FZjhjCNwrJ+3my MlRGjCFnZDh5OUW8c8US5ZMgbZHOSJFW0TxTMv4uJ2mfNrt6AKbGJqpkdQ9oJfj8cD824Rehukp s05zd7Zb//n7yD1Ee+bYFLSSY8dqqJ5/pTke1y8ZHeBJQ0IYsesM6EvNgqUjQ2KIbyr5mYOWvpm c63Ny3eKmsj8ozhU32MJKl7tn0syAwyrbtM7hkYcDaVI= X-Google-Smtp-Source: AGHT+IH2Q5rRfVSJUWNf+uE6eBwAzJ9xOs26TnCu8U9MzwRkPuvLFqxwmj/xUnRfEFrOQCUo3+by3A== X-Received: by 2002:a05:6808:4f50:b0:435:774c:c443 with SMTP id 5614622812f47-4378516a635mr10246498b6e.8.1756347423714; Wed, 27 Aug 2025 19:17:03 -0700 (PDT) Received: from localhost.localdomain ([122.8.183.87]) by smtp.gmail.com with ESMTPSA id 5614622812f47-437967dbedasm2276940b6e.13.2025.08.27.19.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 19:17:02 -0700 (PDT) From: Chen Wang To: kwilczynski@kernel.org, u.kleine-koenig@baylibre.com, aou@eecs.berkeley.edu, alex@ghiti.fr, arnd@arndb.de, bwawrzyn@cisco.com, bhelgaas@google.com, unicorn_wang@outlook.com, conor+dt@kernel.org, 18255117159@163.com, inochiama@gmail.com, kishon@kernel.org, krzk+dt@kernel.org, lpieralisi@kernel.org, mani@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org, s-vadapalli@ti.com, tglx@linutronix.de, thomas.richard@bootlin.com, sycamoremoon376@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org, sophgo@lists.linux.dev, rabenda.cn@gmail.com, chao.wei@sophgo.com, xiaoguang.xing@sophgo.com, fengchun.li@sophgo.com Subject: [PATCH 1/5] dt-bindings: pci: Add Sophgo SG2042 PCIe host Date: Thu, 28 Aug 2025 10:16:54 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" From: Chen Wang Add binding for Sophgo SG2042 PCIe host controller. Signed-off-by: Chen Wang Reviewed-by: Rob Herring (Arm) --- .../bindings/pci/sophgo,sg2042-pcie-host.yaml | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/sophgo,sg2042-pci= e-host.yaml diff --git a/Documentation/devicetree/bindings/pci/sophgo,sg2042-pcie-host.= yaml b/Documentation/devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml new file mode 100644 index 000000000000..2cca3d113d11 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/sophgo,sg2042-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo SG2042 PCIe Host (Cadence PCIe Wrapper) + +description: + Sophgo SG2042 PCIe host controller is based on the Cadence PCIe core. + +maintainers: + - Chen Wang + +properties: + compatible: + const: sophgo,sg2042-pcie-host + + reg: + maxItems: 2 + + reg-names: + items: + - const: reg + - const: cfg + + vendor-id: + const: 0x1f1c + + device-id: + const: 0x2042 + + msi-parent: true + +allOf: + - $ref: cdns-pcie-host.yaml# + +required: + - compatible + - reg + - reg-names + - vendor-id + - device-id + +unevaluatedProperties: false + +examples: + - | + #include + + pcie@62000000 { + compatible =3D "sophgo,sg2042-pcie-host"; + device_type =3D "pci"; + reg =3D <0x62000000 0x00800000>, + <0x48000000 0x00001000>; + reg-names =3D "reg", "cfg"; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x81000000 0 0x00000000 0xde000000 0 0x00010000>, + <0x82000000 0 0xd0400000 0xd0400000 0 0x0d000000>; + bus-range =3D <0x00 0xff>; + vendor-id =3D <0x1f1c>; + device-id =3D <0x2042>; + cdns,no-bar-match-nbits =3D <48>; + msi-parent =3D <&msi>; + }; --=20 2.34.1 From nobody Fri Oct 3 16:46:06 2025 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 3037C199931; Thu, 28 Aug 2025 02:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347447; cv=none; b=UUUTop5DnWU5EMmBhOOkDxESS2OrtkGY8Y3VQJvwLT60V6XWxJvw7jo2J6yYuDsef5uUHs8DKz8yUATY33J4c3N1SfZU/MbaiThjvp0RgGxdmMPpUbtlHvOtvAgy2D++KQ/645Ejfw4+KfiuE7IzJmBApl/3y2ydaJnrk3h+ZXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347447; c=relaxed/simple; bh=5f2mmt9u33RfwW27TpFBKhySW3NJY0la1B1vEYqwVz8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QNXZom3I8f3FIcGeack0GMJbkbf9/wf8oG/19VBisy2blz8Ad2/48aSHdsJEcu1vcSxetaRbf0Anxw5ShI4rHBAmXY2iyK78buuVsgVl6z9T67eX/YKU/YQcbzRZ1ccfu/dBim72xMZx7o0pGPkgme5/upHcGB+inh3v+c+6xec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N0ASwa8x; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N0ASwa8x" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-74381e2079fso427572a34.0; Wed, 27 Aug 2025 19:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756347445; x=1756952245; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4cMD9oVw7wzB9jTZgK3seO4aPiDIfpeTKPhUfVzD+DA=; b=N0ASwa8xkJAE+y/0y8ljLU3iqxycL0s5NLM+p7BTx1owmFcpjJzRORCK9+tT3egQ3w bod3t+HvTUrNApD/HJHCnaoE16vatWLIOyqHzUMBKtqTQp9VD/Nl64UM+mBwe4DJupot La2XrRgBrB84Hrx+BhamAdNr4ztlNsc3ZpZP+9gCXidObTouJt4qu4fMKlywTbuHnCiW Yt5g95gC0h53R038LZYwdLakub3Q7y10U3OK6NOR84H8AdT4sausCfAbyJgpCFHxJl/d 1KemKq9yM6jZCtkjSljUvx2e5CegBQ+10XlHC8sG6ZsJoLsszVo+xFeGxockD6qtwKBz f6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756347445; x=1756952245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4cMD9oVw7wzB9jTZgK3seO4aPiDIfpeTKPhUfVzD+DA=; b=fy1mQYjVL/Zp4lAv8hDHhP/5iELzrVipDvI8nwn8Erp0+N3fQxUCQzo2oSiOAr/oRl uRDdxP9Vi7o3gaRvdTJmQYjvC8gbjdqayTatl8oZR48yNo0i/2WSreoG8B9glS+tP5cY 3NMY7fA352RxILLxm1l+rydHBZbzElV2MuvokJAn5nDLxyL9awNLgVOREuxzXIfqRR9p i6tLjb4JjENxiwmBGyo4j0aeXIhwiFPprKMlJ5+OD9x20EZ9oMUPkbhtv5w/Sr90VpuJ 14z5A0IXv5WWS9DDxtvNHVXc3XjjLLcw6ESGEdkf9x78ttS43xnaEadGDN7jbmuiwB+f 7Sxg== X-Forwarded-Encrypted: i=1; AJvYcCXDnIjjqWTKcChvF40GKoHsnJq8wMR0X+7YKp9oZdgJFDKMuh3diDAWwqzSeM/B/EG1Sr8TqG5ToIoF@vger.kernel.org, AJvYcCXNKecu9XduCsYDY4XKIJe8s3wP2woYfvV+fByOIz4PdofYHm61j7RjUUBuP9ifG5aW7/Zb3re5u452Tn5P@vger.kernel.org, AJvYcCXPZdL0tcEK7mo+5VgSi9VMP50h2ifQbYE9b10rBDPw6cOSSfGebYjJSWAg/sSA4ud2xbTNncDJNr8i@vger.kernel.org X-Gm-Message-State: AOJu0YwC79AOj5wlvDbm2bFRmeoNQlpccdoWTYTLWY8RNrqCSJAxuQqK cpx2yTdvZbppV/3V56ndVkfKjMpYhTfAkgLuJn2SgVJGBbMOc2rPnReI X-Gm-Gg: ASbGncsR7JHyzekq9CaMkD8dYjHaaTHOUnTjsWfnDwsKTgzWEiUmkhy1ezTOHJhFsDT onyUp6BwMAIjYbRFpvwkWZOGNDOaAVOfk7dptMGPMBtovSPHfnqDif4D+wzxbAwOR+rc3Y56fLr ORXkTGjB8n6Cfh6IMGcHlCaTzIm95tLFGAl/bZdYoC808YYZnFt3odIGo8/kEFjPcBeoq7DCsTU f9/dvOyliVvF26p5q+xs8wHAdAP237QjFjMD/DOsKPsd8eZ6xpPx/72dcZy8AXZYcok+OGLoy7T mVywSUrLliyqy4XRzJd3YwSpuTwvjp10pWqAz1vx6FriYtpk9yANZXs1u7I0fCI62R7a26KUoO2 V76RB3ZY44lPLK/p7WlUk6qCodAUtq9yVaUcMIcRmFA8= X-Google-Smtp-Source: AGHT+IFUMTBN0ewK0J12WWwmbqPZ20vlkC0r+3NLs/KDPeS4FrNivKz6PhTVcy1KC85aKvA34B7Fow== X-Received: by 2002:a05:6830:6b06:b0:73e:9857:9839 with SMTP id 46e09a7af769-7450048644amr11399123a34.0.1756347445072; Wed, 27 Aug 2025 19:17:25 -0700 (PDT) Received: from localhost.localdomain ([122.8.183.87]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7454eb2816csm63490a34.26.2025.08.27.19.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 19:17:24 -0700 (PDT) From: Chen Wang To: kwilczynski@kernel.org, u.kleine-koenig@baylibre.com, aou@eecs.berkeley.edu, alex@ghiti.fr, arnd@arndb.de, bwawrzyn@cisco.com, bhelgaas@google.com, unicorn_wang@outlook.com, conor+dt@kernel.org, 18255117159@163.com, inochiama@gmail.com, kishon@kernel.org, krzk+dt@kernel.org, lpieralisi@kernel.org, mani@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org, s-vadapalli@ti.com, tglx@linutronix.de, thomas.richard@bootlin.com, sycamoremoon376@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org, sophgo@lists.linux.dev, rabenda.cn@gmail.com, chao.wei@sophgo.com, xiaoguang.xing@sophgo.com, fengchun.li@sophgo.com Subject: [PATCH 2/5] PCI: cadence: Fix NULL pointer error for ops Date: Thu, 28 Aug 2025 10:17:17 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" From: Chen Wang ops of struct cdns_pcie may be NULL, direct use will result in a null pointer error. Add checking of pcie->ops before using it. Fixes: 40d957e6f9eb ("PCI: cadence: Add support to start link and verify li= nk status") Signed-off-by: Chen Wang --- drivers/pci/controller/cadence/pcie-cadence-host.c | 2 +- drivers/pci/controller/cadence/pcie-cadence.c | 4 ++-- drivers/pci/controller/cadence/pcie-cadence.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/p= ci/controller/cadence/pcie-cadence-host.c index 59a4631de79f..fffd63d6665e 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -531,7 +531,7 @@ static int cdns_pcie_host_init_address_translation(stru= ct cdns_pcie_rc *rc) cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(0), addr1); cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(0), desc1); =20 - if (pcie->ops->cpu_addr_fixup) + if (pcie->ops && pcie->ops->cpu_addr_fixup) cpu_addr =3D pcie->ops->cpu_addr_fixup(pcie, cpu_addr); =20 addr0 =3D CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(12) | diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/co= ntroller/cadence/pcie-cadence.c index 70a19573440e..61806bbd8aa3 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.c +++ b/drivers/pci/controller/cadence/pcie-cadence.c @@ -92,7 +92,7 @@ void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie= , u8 busnr, u8 fn, cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1); =20 /* Set the CPU address */ - if (pcie->ops->cpu_addr_fixup) + if (pcie->ops && pcie->ops->cpu_addr_fixup) cpu_addr =3D pcie->ops->cpu_addr_fixup(pcie, cpu_addr); =20 addr0 =3D CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) | @@ -123,7 +123,7 @@ void cdns_pcie_set_outbound_region_for_normal_msg(struc= t cdns_pcie *pcie, } =20 /* Set the CPU address */ - if (pcie->ops->cpu_addr_fixup) + if (pcie->ops && pcie->ops->cpu_addr_fixup) cpu_addr =3D pcie->ops->cpu_addr_fixup(pcie, cpu_addr); =20 addr0 =3D CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(17) | diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/co= ntroller/cadence/pcie-cadence.h index 1d81c4bf6c6d..2f07ba661bda 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -468,7 +468,7 @@ static inline u32 cdns_pcie_ep_fn_readl(struct cdns_pci= e *pcie, u8 fn, u32 reg) =20 static inline int cdns_pcie_start_link(struct cdns_pcie *pcie) { - if (pcie->ops->start_link) + if (pcie->ops && pcie->ops->start_link) return pcie->ops->start_link(pcie); =20 return 0; @@ -476,13 +476,13 @@ static inline int cdns_pcie_start_link(struct cdns_pc= ie *pcie) =20 static inline void cdns_pcie_stop_link(struct cdns_pcie *pcie) { - if (pcie->ops->stop_link) + if (pcie->ops && pcie->ops->stop_link) pcie->ops->stop_link(pcie); } =20 static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) { - if (pcie->ops->link_up) + if (pcie->ops && pcie->ops->link_up) return pcie->ops->link_up(pcie); =20 return true; --=20 2.34.1 From nobody Fri Oct 3 16:46:06 2025 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 4AEC5199931; Thu, 28 Aug 2025 02:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347471; cv=none; b=RUKAqoRBzUVP70TBpatPYGOBzrnk/8rVnBtCbsBZ5iFxTAiimAZCd4z7CtfKLmD1mD1YWa1ZmNaHzkJEySzleaOzQn0PZZlGW3zw60WuRCbtXZUXs6cLrKfAGY3apGZiqGm5rCYEBw5LsKNtkbJz2nmwtc+LDux/waU55rGEcRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347471; c=relaxed/simple; bh=jsp3ZxCFIwxUfMwp0GyT+wPOde8wDXy/DnjM645DC7A=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BJ09MYwFA7L4qDnRERgwfxs164tZMJJ+0Xh1cbZqoS1tK7G814OXSpVGqB2ouudUE3RiIpvG97dqYSNwXaPr+xtEo9hqmnbppF4V92aj0ccVnBR7fPsGTfi7I5qahaeKNwUan+8oHhq7dEvzV7phKJxIXrEn/38I17OpWBPLGz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GvuVSQdq; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GvuVSQdq" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-31597d3b410so160589fac.1; Wed, 27 Aug 2025 19:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756347469; x=1756952269; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G1J0WFYBhSOi86+35mD2mRHFDAZtuR1uDJv4Cz+MRN0=; b=GvuVSQdqJyOm7l6rUnxPE9PAx/+wINJkyBp00RVn9ilkAwWEZ2r8ngJvq3XFNI3Vdc WK5M/MPkmpgNQU9viDrqtpWvW3Vnfjbyb5CFwosHC4vQJWFK+PzhtFlC6j3KTitx697Q +1Peo8yP3dyTecgsLv59Z+YVE2MtVdiD55J9u7BMqr/ZLpaxch/MkfYebXC2ntzy4Z86 ruqorZ0VBYWa6BlYpa9HQCeBFGRbW+IZfqrHDeNJOQdnOl576tEcDYUB3ImAeT2Fekeg 4o0WKehBtGeCItDG/aPypH+7nbt+Y9KXmzzNdDBu4yhBUpvfWQD8Ec2RZbRwE1eBra8q 6Gkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756347469; x=1756952269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G1J0WFYBhSOi86+35mD2mRHFDAZtuR1uDJv4Cz+MRN0=; b=ANNSSHHcKnHKsxjZZOWfJT+1UkQp2byl4y+VAsiOkMz0sHIpSf8m33r388n7h05/N3 imKOMr5AwfYX4UtC9pb7Jyoifz4m52PPeKHx2mWw+z3Dnzk574fz213MuEdRd7igQGnS InR52p8hDLaQpz2/3lbIb3DiVce263iKBCrQUVlId9rAnKIBZGvVF3Ce/PpnA8W/ZgCm /0MPzN1pMxAXhyfwdmOxQLNbg/ps10mIapiPPxP5uwysLZvk1F+tPEno7Fs5zDuUoYqD D83qTF7m5kjIabEk28s1KC6xq1NC/jFBud9EINXQr45p7jMMdZiIkb1/qXU6vW2oGBjy M3ow== X-Forwarded-Encrypted: i=1; AJvYcCU5SMq9A2ScWNK5x8ustlpjGDZST2h69uU3/6fyTVVPdt8PLkrh/RXMb0pDqaEnZUGL5vcFMVugxS3dcbh0@vger.kernel.org, AJvYcCVlLUQiJxDtYYjFuPzFW1r3lkCMjsU5CgCqVEpLF3SBc4D0ul3RUKvyMUAMyG19+OxvFiu7caMnaUjb@vger.kernel.org, AJvYcCWD5JjIZEM5+y+npAsYy4ugT4TQ3dbiuN3HyCxSQjO0JWadUPzcEKcodE3w8DSeevYKw90tn0qzAh5K@vger.kernel.org X-Gm-Message-State: AOJu0YzclEdZbXjs1Qsh+nujbB0OGsOlBb3zOm7l3lv2XSh+8ZyMYJjT 3XVHEHjt4LIwup8U1xEL7Bm29dISxM0l8G+vsfy+ouDhnSsAPpCCHS17 X-Gm-Gg: ASbGncu6v9+zPK2mCO+G+MlffsiCYt3c/K2TcmBZKtihBw5OaMYmuBzWmnjOdtki1ro L1iaF54EfbJuvUs8j4L4fhoY0xiWEnpSy5vIHDQPHATFHVEmXuzszHiNVlpuAjYk6K0NNVVCBcx K4vlKWA9UCHLC6pAEIDdLBBzN9/hlVY9nmoVhGLBZ6MQO26pALXUovudWU5gwWUFFDCzlQdZVIl 0XP9CbPovo1I4w07V+oFLQfUNbzt5KL7J4raE7kBx5R7Z2onhx6q6K07GAntOgUoKbqhGYvj8IC o8vmQH5mWJyOZjl/FNLmDEBWTlrGuAgRpCvDy0AQr5ja6/YeIPwSysDeg4TPUNcoTW2Q4doD9Ei qu9ypVjkGt2xG4tPXxaYS2AMSBwFtaVhBjrYHOUVoxhk= X-Google-Smtp-Source: AGHT+IHsxuJu7jkWvWsps1igHiY/UUiFcSFtA/FN5HQqjKuBeXruePrLDEHJj7TO/JjdqRVkSNwrvw== X-Received: by 2002:a05:6871:e387:b0:315:8a2a:3f59 with SMTP id 586e51a60fabf-3158a2a4cf7mr1544247fac.21.1756347469269; Wed, 27 Aug 2025 19:17:49 -0700 (PDT) Received: from localhost.localdomain ([122.8.183.87]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-314f7a2dc16sm3674563fac.12.2025.08.27.19.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 19:17:47 -0700 (PDT) From: Chen Wang To: kwilczynski@kernel.org, u.kleine-koenig@baylibre.com, aou@eecs.berkeley.edu, alex@ghiti.fr, arnd@arndb.de, bwawrzyn@cisco.com, bhelgaas@google.com, unicorn_wang@outlook.com, conor+dt@kernel.org, 18255117159@163.com, inochiama@gmail.com, kishon@kernel.org, krzk+dt@kernel.org, lpieralisi@kernel.org, mani@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org, s-vadapalli@ti.com, tglx@linutronix.de, thomas.richard@bootlin.com, sycamoremoon376@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org, sophgo@lists.linux.dev, rabenda.cn@gmail.com, chao.wei@sophgo.com, xiaoguang.xing@sophgo.com, fengchun.li@sophgo.com Subject: [PATCH 3/5] PCI: sg2042: Add Sophgo SG2042 PCIe driver Date: Thu, 28 Aug 2025 10:17:40 +0800 Message-Id: <1df25b33f0ea90a81c34c18cadedd38526a30f01.1756344464.git.unicorn_wang@outlook.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" From: Chen Wang Add support for PCIe controller in SG2042 SoC. The controller uses the Cadence PCIe core programmed by pcie-cadence*.c. The PCIe controller will work in host mode only. Signed-off-by: Chen Wang --- drivers/pci/controller/cadence/Kconfig | 12 ++ drivers/pci/controller/cadence/Makefile | 1 + drivers/pci/controller/cadence/pcie-sg2042.c | 134 +++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/pci/controller/cadence/pcie-sg2042.c diff --git a/drivers/pci/controller/cadence/Kconfig b/drivers/pci/controlle= r/cadence/Kconfig index 666e16b6367f..b1f1941d5208 100644 --- a/drivers/pci/controller/cadence/Kconfig +++ b/drivers/pci/controller/cadence/Kconfig @@ -42,6 +42,17 @@ config PCIE_CADENCE_PLAT_EP endpoint mode. This PCIe controller may be embedded into many different vendors SoCs. =20 +config PCIE_SG2042 + bool "Sophgo SG2042 PCIe controller (host mode)" + depends on ARCH_SOPHGO || COMPILE_TEST + depends on OF + depends on PCI_MSI + select PCIE_CADENCE_HOST + help + Say Y here if you want to support the Sophgo SG2042 PCIe platform + controller in host mode. Sophgo SG2042 PCIe controller uses Cadence + PCIe core. + config PCI_J721E tristate select PCIE_CADENCE_HOST if PCI_J721E_HOST !=3D n @@ -67,4 +78,5 @@ config PCI_J721E_EP Say Y here if you want to support the TI J721E PCIe platform controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe core. + endmenu diff --git a/drivers/pci/controller/cadence/Makefile b/drivers/pci/controll= er/cadence/Makefile index 9bac5fb2f13d..4df4456d9539 100644 --- a/drivers/pci/controller/cadence/Makefile +++ b/drivers/pci/controller/cadence/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PCIE_CADENCE_HOST) +=3D pcie-cadence-host.o obj-$(CONFIG_PCIE_CADENCE_EP) +=3D pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE_PLAT) +=3D pcie-cadence-plat.o obj-$(CONFIG_PCI_J721E) +=3D pci-j721e.o +obj-$(CONFIG_PCIE_SG2042) +=3D pcie-sg2042.o diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c b/drivers/pci/con= troller/cadence/pcie-sg2042.c new file mode 100644 index 000000000000..fe434dc2967e --- /dev/null +++ b/drivers/pci/controller/cadence/pcie-sg2042.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * pcie-sg2042 - PCIe controller driver for Sophgo SG2042 SoC + * + * Copyright (C) 2025 Sophgo Technology Inc. + * Copyright (C) 2025 Chen Wang + */ + +#include +#include +#include +#include +#include + +#include "pcie-cadence.h" + +/* + * SG2042 only support 4-byte aligned access, so for the rootbus (i.e. to = read + * the Root Port itself, read32 is required. For non-rootbus (i.e. to read + * the PCIe peripheral registers, supports 1/2/4 byte aligned access, so + * directly using read should be fine. + * + * The same is true for write. + */ +static int sg2042_pcie_config_read(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 *value) +{ + if (pci_is_root_bus(bus)) + return pci_generic_config_read32(bus, devfn, where, size, + value); + + return pci_generic_config_read(bus, devfn, where, size, value); +} + +static int sg2042_pcie_config_write(struct pci_bus *bus, unsigned int devf= n, + int where, int size, u32 value) +{ + if (pci_is_root_bus(bus)) + return pci_generic_config_write32(bus, devfn, where, size, + value); + + return pci_generic_config_write(bus, devfn, where, size, value); +} + +static struct pci_ops sg2042_pcie_host_ops =3D { + .map_bus =3D cdns_pci_map_bus, + .read =3D sg2042_pcie_config_read, + .write =3D sg2042_pcie_config_write, +}; + +static int sg2042_pcie_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct pci_host_bridge *bridge; + struct cdns_pcie *pcie; + struct cdns_pcie_rc *rc; + int ret; + + pcie =3D devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) + return -ENOMEM; + + bridge =3D devm_pci_alloc_host_bridge(dev, sizeof(*rc)); + if (!bridge) { + dev_err(dev, "Failed to alloc host bridge!\n"); + return -ENOMEM; + } + + bridge->ops =3D &sg2042_pcie_host_ops; + + rc =3D pci_host_bridge_priv(bridge); + pcie =3D &rc->pcie; + pcie->dev =3D dev; + + platform_set_drvdata(pdev, pcie); + + pm_runtime_enable(dev); + + ret =3D pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "pm_runtime_get_sync failed\n"); + goto err_get_sync; + } + + ret =3D cdns_pcie_init_phy(dev, pcie); + if (ret) { + dev_err(dev, "Failed to init phy!\n"); + goto err_get_sync; + } + + ret =3D cdns_pcie_host_setup(rc); + if (ret < 0) { + dev_err(dev, "Failed to setup host!\n"); + goto err_host_setup; + } + + return 0; + +err_host_setup: + cdns_pcie_disable_phy(pcie); + +err_get_sync: + pm_runtime_put(dev); + pm_runtime_disable(dev); + + return ret; +} + +static void sg2042_pcie_shutdown(struct platform_device *pdev) +{ + struct cdns_pcie *pcie =3D platform_get_drvdata(pdev); + struct device *dev =3D &pdev->dev; + + cdns_pcie_disable_phy(pcie); + + pm_runtime_put(dev); + pm_runtime_disable(dev); +} + +static const struct of_device_id sg2042_pcie_of_match[] =3D { + { .compatible =3D "sophgo,sg2042-pcie-host" }, + {}, +}; + +static struct platform_driver sg2042_pcie_driver =3D { + .driver =3D { + .name =3D "sg2042-pcie", + .of_match_table =3D sg2042_pcie_of_match, + .pm =3D &cdns_pcie_pm_ops, + }, + .probe =3D sg2042_pcie_probe, + .shutdown =3D sg2042_pcie_shutdown, +}; +builtin_platform_driver(sg2042_pcie_driver); --=20 2.34.1 From nobody Fri Oct 3 16:46:06 2025 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 13A2F7260A; Thu, 28 Aug 2025 02:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347491; cv=none; b=equfo4UkvyVqo4nTj4PWKGNAAo58pDvqu7MGOLesA9Y80koBk8pnYtL6fUeDX14UZVtjvIbhOBiCvXYs7W1UybDqED1HdZitsBPlf8/o/JWmOCKC8XKxUR8aTpCQ0Lvap6N0ENJaWfF7emhDr681MKZOZRbirUj19Yl9zlMFA/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347491; c=relaxed/simple; bh=TVeTlkxDwqekJxD6/BHcDv8RS0hvaJMteIaNKw3WWyM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dTl9+gOijawxBAKa0sX5njLfYIufPJUtpxQ73G5PF21xUOYYs1j4ex+Bj3u5Tn94N2WHxK0iJwAn7i5S1IzlTboftFUKjQ+ElQeSy7CWS24ZeSc5ldIAs2aH1SQI2decaz1BpA9N5XJm2gFUzLhbGY2tEyzuI0QsGd2ntysUvm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b2Cuiw58; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b2Cuiw58" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-74381efd643so209046a34.1; Wed, 27 Aug 2025 19:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756347489; x=1756952289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lw9R9KQylny50IUlY0ox7tSDg7XfT5zo+Jx/4FOsYMk=; b=b2Cuiw58bTwPX13TdEW8rVx+NiMV1mVsHSM+HKp7nG2WXGvfePOdjymr5CdVTOtCeA /WywCnqGIQw4Z+Kt2zQOrU39PDdUc1XS3/gKmhb1MUonVYbeaAAWRStaHvFAAiLrlYz4 gFe+uHXPw/jYz8JXw5jJHGxtbk8Crq61QMpN6XuKpnF11qDVAbTiTlFKK8Ezf73UFqkq CTcKnFFY5GVz+QZrabIv5LfbPIM2o9DCe/jvrGLqrHYFR2L+ynC5e+QYM7Jm7MgCgG2F sEvmS0joHKbu9+keR+g93Jq3RumaI6pbv7XgmEM8YyWWy/sN7aj3FiAXMaGztXWeWsTi SQ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756347489; x=1756952289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lw9R9KQylny50IUlY0ox7tSDg7XfT5zo+Jx/4FOsYMk=; b=G20hRhqoNjoJcR/3DgXtZANneujSIHQp9NbWe/l5AEailPivqU1X0cOtZOBR1ISKIe vR5ez+J5p1YGkAYAJp2G2A6Han4d5Gb+1+YOe7L3H+eRNwfo8zil/YmLKVpOpV7+ycaA ZZn4kufMaDtEFc2BjBePcfZAVaIpYnCoxO+6ceiBFUu96WwSgWBMNKYkqpAPKAdIV9/f rC1D5ftwI4j/nrh0A9vlM9vExsDbK7t1r0uIr9BMF8iJdEQoZDbZ2v5ityggV6e7Qbny JJI11ZMx8raU8AOcSx1iE3twxMf/U9WrPyLbs9O/dI+uqZjAT4e+ekT4Xv+GZ7ywAGU7 eLXQ== X-Forwarded-Encrypted: i=1; AJvYcCU3IvRAvdZ8lYaaGfcANvCs53V+NSBugGXExWRFP9rnXvOeGrNVUazpeAYtz3pVAZVqicMGXNrIoovD@vger.kernel.org, AJvYcCVYbvU1t8vMxtlK0tipiEBRNwqDBqren+IDk9CWkLwoSYiFzCFndYSjNL+xogJVqSWAwrxSUJJH2cxx@vger.kernel.org, AJvYcCVmZbC+2x/OWjVsOkTzPAK6ophNiX4bk3NS3PV1oMyPdDLFHqtAzcUPIpao7mHnAhtYLzVxjS5DQMT7QZ7p@vger.kernel.org X-Gm-Message-State: AOJu0YxdhiFWKXlD2+FKNEz7OMKl7lJMqTnLVNlNVle+T4M7ipiA2SJO zSQjkUw5gDg2fun35YQPMatJ1cCRsJ+OSZiDbMKdKYmNXyTMAHfKs3oH X-Gm-Gg: ASbGncuQu3LZmrEsp9ZzRBwOA+55KL85lg3+ONYkTPUNZUNKhYf+wmuJTTaKZd1jWBC q0y4QPhKTiVwHHuEzZkg2JUTIcjj5ip3NbBQM6stKdlIUpYxjs2bFDDOxqjagATaTzgFxX4nRhL bN9uvSspU470VfGy45jl/YuotB0KMM4sHMQLDyxMFIX6yvaL8Y2p2M2KOKxezj83POXkIbrZ3mP Q5u8+9kwoxulJ2Cuq+DgP8bdqN8Ri4nA3N+7UzToZhxmqIA/OQGfYfRg9tP7b7sUroSaIbZNS+F m3zRC6ueGsLsOjxlQSTi7sooM7L43W/JBi6uNTN7Hn8hQQu0kQgThlywwyGZwjAvBLrHVEPPJJe DU6S4cwU863wwBW7Bjc1vlrWqb170Took X-Google-Smtp-Source: AGHT+IGLh44dGgjMBAdZ8+L1YTxNe6vactvoL8NAqKvzlPhnz8iFt3JVHKV663JR1fRhVGA14N15DQ== X-Received: by 2002:a05:6808:118d:b0:435:6cc4:9753 with SMTP id 5614622812f47-43785190f04mr9072791b6e.8.1756347489002; Wed, 27 Aug 2025 19:18:09 -0700 (PDT) Received: from localhost.localdomain ([122.8.183.87]) by smtp.gmail.com with ESMTPSA id 5614622812f47-437967be68bsm2311340b6e.4.2025.08.27.19.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 19:18:08 -0700 (PDT) From: Chen Wang To: kwilczynski@kernel.org, u.kleine-koenig@baylibre.com, aou@eecs.berkeley.edu, alex@ghiti.fr, arnd@arndb.de, bwawrzyn@cisco.com, bhelgaas@google.com, unicorn_wang@outlook.com, conor+dt@kernel.org, 18255117159@163.com, inochiama@gmail.com, kishon@kernel.org, krzk+dt@kernel.org, lpieralisi@kernel.org, mani@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org, s-vadapalli@ti.com, tglx@linutronix.de, thomas.richard@bootlin.com, sycamoremoon376@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org, sophgo@lists.linux.dev, rabenda.cn@gmail.com, chao.wei@sophgo.com, xiaoguang.xing@sophgo.com, fengchun.li@sophgo.com Subject: [PATCH 4/5] riscv: sophgo: dts: add pcie controllers for SG2042 Date: Thu, 28 Aug 2025 10:18:00 +0800 Message-Id: <96df911a622547c6c987895fefde9110f3fcac03.1756344464.git.unicorn_wang@outlook.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" From: Chen Wang Add PCIe controller nodes in DTS for Sophgo SG2042. Default they are disabled. Signed-off-by: Chen Wang --- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/sg2042.dtsi b/arch/riscv/boot/dts/s= ophgo/sg2042.dtsi index b3e4d3c18fdc..346aba5bd9bf 100644 --- a/arch/riscv/boot/dts/sophgo/sg2042.dtsi +++ b/arch/riscv/boot/dts/sophgo/sg2042.dtsi @@ -220,6 +220,72 @@ clkgen: clock-controller@7030012000 { #clock-cells =3D <1>; }; =20 + pcie_rc0: pcie@7060000000 { + compatible =3D "sophgo,sg2042-pcie-host"; + device_type =3D "pci"; + reg =3D <0x70 0x60000000 0x0 0x02000000>, + <0x40 0x00000000 0x0 0x00001000>; + reg-names =3D "reg", "cfg"; + linux,pci-domain =3D <0>; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0xc0000000 0x40 0xc0000000 0x0 0x00400000= >, + <0x42000000 0x0 0xd0000000 0x40 0xd0000000 0x0 0x10000000>, + <0x02000000 0x0 0xe0000000 0x40 0xe0000000 0x0 0x20000000>, + <0x43000000 0x42 0x00000000 0x42 0x00000000 0x2 0x00000000>, + <0x03000000 0x41 0x00000000 0x41 0x00000000 0x1 0x00000000>; + bus-range =3D <0x0 0xff>; + vendor-id =3D <0x1f1c>; + device-id =3D <0x2042>; + cdns,no-bar-match-nbits =3D <48>; + msi-parent =3D <&msi>; + status =3D "disabled"; + }; + + pcie_rc1: pcie@7062000000 { + compatible =3D "sophgo,sg2042-pcie-host"; + device_type =3D "pci"; + reg =3D <0x70 0x62000000 0x0 0x00800000>, + <0x48 0x00000000 0x0 0x00001000>; + reg-names =3D "reg", "cfg"; + linux,pci-domain =3D <1>; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0xc0800000 0x48 0xc0800000 0x0 0x00400000= >, + <0x42000000 0x0 0xd0000000 0x48 0xd0000000 0x0 0x10000000>, + <0x02000000 0x0 0xe0000000 0x48 0xe0000000 0x0 0x20000000>, + <0x03000000 0x49 0x00000000 0x49 0x00000000 0x1 0x00000000>, + <0x43000000 0x4a 0x00000000 0x4a 0x00000000 0x2 0x00000000>; + bus-range =3D <0x0 0xff>; + vendor-id =3D <0x1f1c>; + device-id =3D <0x2042>; + cdns,no-bar-match-nbits =3D <48>; + msi-parent =3D <&msi>; + status =3D "disabled"; + }; + + pcie_rc2: pcie@7062800000 { + compatible =3D "sophgo,sg2042-pcie-host"; + device_type =3D "pci"; + reg =3D <0x70 0x62800000 0x0 0x00800000>, + <0x4c 0x00000000 0x0 0x00001000>; + reg-names =3D "reg", "cfg"; + linux,pci-domain =3D <2>; + #address-cells =3D <3>; + #size-cells =3D <2>; + ranges =3D <0x01000000 0x0 0xc0c00000 0x4c 0xc0c00000 0x0 0x00400000= >, + <0x42000000 0x0 0xf8000000 0x4c 0xf8000000 0x0 0x04000000>, + <0x02000000 0x0 0xfc000000 0x4c 0xfc000000 0x0 0x04000000>, + <0x43000000 0x4e 0x00000000 0x4e 0x00000000 0x2 0x00000000>, + <0x03000000 0x4d 0x00000000 0x4d 0x00000000 0x1 0x00000000>; + bus-range =3D <0x0 0xff>; + vendor-id =3D <0x1f1c>; + device-id =3D <0x2042>; + cdns,no-bar-match-nbits =3D <48>; + msi-parent =3D <&msi>; + status =3D "disabled"; + }; + clint_mswi: interrupt-controller@7094000000 { compatible =3D "sophgo,sg2042-aclint-mswi", "thead,c900-aclint-mswi"; reg =3D <0x00000070 0x94000000 0x00000000 0x00004000>; --=20 2.34.1 From nobody Fri Oct 3 16:46:06 2025 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 37D341DD9D3; Thu, 28 Aug 2025 02:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347511; cv=none; b=gEytCX9DrJzy7hltsmiNAtQXfDeFxaAUEkQM0OyS3T7a7k+pd15JLDK3S6oLv440rcYd0BA5Chz2Wnhkx37OSF/OHbaYQvLeayv7JhJNUOk8wjau02wGWZ6xUIulRcyQy1CGaK1UUtfgc/K8F3Tt4GwWpnQT0VFyjojbH+VYGKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756347511; c=relaxed/simple; bh=2/X0kqXymzl0rSIfFuIwI8HKliLYoWUEKgTpcTzr93w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AcZ8fRL8+ebzpXlCNT8quS0j+JmESJv/3h9o+8BatJMdwlK2D+T6+b7oyc41OwjOXHXRehlc3Vm2+3tJle01bKQy2knYRkEdblMeJ8HnkjsWIF/vGGZhtz1b3LoVlB2KEKFjSekeeMGSgJ+2TzYIsDLGgH2I4/VOaAVFSOKnf1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EphEOE94; arc=none smtp.client-ip=209.85.161.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EphEOE94" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-61bf9ef4cc0so334674eaf.0; Wed, 27 Aug 2025 19:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756347509; x=1756952309; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0G0wcA4QwYMRGmntWmLFL5l/S4VJ8/gFReFfYA7/kyM=; b=EphEOE94Ei+VcQoHTvtSgz8bGwMLj/5sS+caKF7Lmq5u2vc+8OVeLnqDpCN7SknmDg IgGQujZV9Mh1OiYRJ2w8FMqqG1aabx0tXafofPgoFU/E/fY1EANoycPnBhQHojvvHy0l LyP0nCuS2lZ81R6A7fNaTT2bqzdW7sNqzJdx/tji4xt+bgkDaBZBYiNBhmKwbEhcZZQz DTgtsFRDBFismEZOuxrNk87ZoIN0aNew61uLwVKXKtK2M1+AVMiYhvHE0yYQjq6HlVhX kMkWz9cxAxLQdhkWjHrUc9ULIlUEyDa1yh31zpwecGaqcGWQc4+oUDiNrUtj3sjM2lcQ ZIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756347509; x=1756952309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0G0wcA4QwYMRGmntWmLFL5l/S4VJ8/gFReFfYA7/kyM=; b=aCJc+v0ql/hZ3BXN22lG6ACGIwpyjT8a6x5jNGnQeq28sgQ8A0Zkgg5wYSQuEWhLbh epv5mKrRak3gSBf3vmDB9tPXxxDkYUlQ22gdVbqtLIVs8DXwTaR1JGdyzg5GIgxLCjzW RKbgTUNaGhEFQdOOgjYhkCxNMVNCTqkXvJEAx+QCaF7cXBAmkypGC/Tr7SJKSq3o96nP VT5A0LNOvbU4YCd3UF0V3pnfR7p6O62h9u8ygUffuP53QvUWa2hoeSaL3TlOhi/LShjg tcDpkddK5ijvOkOXTBhd0eDx70cRG1JcAy2J8yyr4mh/biw6OxG+l1oRTcTpInT6M6Ce C3dQ== X-Forwarded-Encrypted: i=1; AJvYcCVKYY6EdnwRnPggQTzuKWkMR4EP73/+uE1EnPObzG/XowIUbibzNoNwUH9HulolZRmSfx+GNNtmQbPE@vger.kernel.org, AJvYcCWeOshQ1o9h0hds0TJD0uVwV6wYbI79et3qZKr/z7ImDeBPSx3UOriZOW/EsT0ziHfu9q3JekjHsh+npOt6@vger.kernel.org, AJvYcCX3OhYoQPWUbgaqqdIUPVQuQpBPnE5XVfGQ3w6B0BC8xQ75cRPFVbzivI94BmTXS3sp+tZ4xYNKLM7w@vger.kernel.org X-Gm-Message-State: AOJu0Yz+AxZmkBtD/aWtvbjuObs69hWlJ1Z3/XqMzHMy0Sk/4J38t8q0 k5kXeGHWAqjeYNQvazICO5dGrrUOMnvHvN3pIZMz1MHU8W3OtGWr1Su1 X-Gm-Gg: ASbGncsDbxsiR/x6yHQF+6qGenHDZPvnkkcCVr13R/UyPnOcLhgeR+1xr9V5Zh1zzfg b13/fVlbu3fjLOtZwtIFWY23KnIfCZU4VPrjiB13vJBVrg/JAR2Ivz/FgSyxU8s/d1mT83S/ZQC hwkSyClQ4tNVqREFAhNF5eBLw14zzWoGSI/JU6SMCxtbMYodaBRz/7O33NvR7d+ynnb6PhZUO6M UHdpjYRF5QgLr6t79Ue4NpwQ9GFFVEtACCOj4zgJVpwvdZJO46f/OwAeWmuk+0KayMi3r7CyPb6 LnHly7kGt9zjhrkNYxpZGMcMr3UgUiF2TZKM4KSFOp4zLrDCjs/DgdE8emO/yaLKHiBNONgE63R 56z7Xc7UZglCIpvWuJPdEXpuvf2r6TALg3hQHzqOxtE4= X-Google-Smtp-Source: AGHT+IF/5cS+VdOAcxsOTaHXrHFbinFo1G+/jQXnldj08eaTRkfdS8GuJweSxJytLqtORzEjgcBxBQ== X-Received: by 2002:a05:6808:690c:b0:40c:f220:67fd with SMTP id 5614622812f47-43785196da3mr10882798b6e.9.1756347509153; Wed, 27 Aug 2025 19:18:29 -0700 (PDT) Received: from localhost.localdomain ([122.8.183.87]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7450e297684sm3494054a34.19.2025.08.27.19.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 19:18:28 -0700 (PDT) From: Chen Wang To: kwilczynski@kernel.org, u.kleine-koenig@baylibre.com, aou@eecs.berkeley.edu, alex@ghiti.fr, arnd@arndb.de, bwawrzyn@cisco.com, bhelgaas@google.com, unicorn_wang@outlook.com, conor+dt@kernel.org, 18255117159@163.com, inochiama@gmail.com, kishon@kernel.org, krzk+dt@kernel.org, lpieralisi@kernel.org, mani@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org, s-vadapalli@ti.com, tglx@linutronix.de, thomas.richard@bootlin.com, sycamoremoon376@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org, sophgo@lists.linux.dev, rabenda.cn@gmail.com, chao.wei@sophgo.com, xiaoguang.xing@sophgo.com, fengchun.li@sophgo.com Subject: [PATCH 5/5] riscv: sophgo: dts: enable pcie for PioneerBox Date: Thu, 28 Aug 2025 10:18:21 +0800 Message-Id: <3c2fef69e80a3e4dde47a9449b49f679211a0c2e.1756344464.git.unicorn_wang@outlook.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" From: Chen Wang Enable pcie controllers for PioneerBox, which uses SG2042 SoC. Signed-off-by: Chen Wang --- arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts b/arch/ris= cv/boot/dts/sophgo/sg2042-milkv-pioneer.dts index ef3a602172b1..6574d8e0b369 100644 --- a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +++ b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts @@ -128,6 +128,18 @@ uart0-rx-pins { }; }; =20 +&pcie_rc0 { + status =3D "okay"; +}; + +&pcie_rc1 { + status =3D "okay"; +}; + +&pcie_rc2 { + status =3D "okay"; +}; + &sd { pinctrl-0 =3D <&sd_cfg>; pinctrl-names =3D "default"; --=20 2.34.1