Skip to content

riscv64: add sg2042 support #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9cbfe73
FROMLIST: dt-bindings: pci: Add Sophgo SG2042 PCIe host
unicornx Jun 4, 2025
9aee9bf
FROMLIST: PCI: sg2042: Add Sophgo SG2042 PCIe driver
unicornx Jun 4, 2025
fe5df3d
FROMLIST: dt-bindings: mfd: syscon: Add sg2042 pcie ctrl compatible
unicornx Jun 4, 2025
b0b0320
FROMLIST: riscv: sophgo: dts: add pcie controllers for SG2042
unicornx Jun 4, 2025
7e5c394
FROMLIST: riscv: sophgo: dts: enable pcie for PioneerBox
unicornx Jun 4, 2025
1b8cc1f
UPSTREAM: riscv: dts: sophgo: sg2042: add pinctrl support
inochisa Feb 11, 2025
8e36c96
UPSTREAM: riscv: sophgo: dts: Add spi controller for SG2042
sycamoremoon Jun 4, 2025
588773e
FROMLIST: dt-bindings: net: sophgo,sg2044-dwmac: Add support for Soph…
inochisa Jun 4, 2025
189ed9f
FROMLIST: net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC
inochisa Jun 4, 2025
62fcb41
FROMLIST: net: stmmac: platform: Add snps,dwmac-5.00a IP compatible s…
inochisa Jun 4, 2025
a265b9d
FROMLIST: riscv: dts: sophgo: add ethernet GMAC device for sg2042
inochisa Jun 4, 2025
bf4830d
FROMLIST: riscv: Move vendor errata definitions into vendorid_list.h
guoren83 Jun 4, 2025
3529cdf
FROMLIST: riscv: qspinlock: errata: Add ERRATA_THEAD_WRITE_ONCE fixup
guoren83 Jun 4, 2025
9320d35
FROMLIST: riscv: dts: sophgo: Add xtheadvector to the sg2042 devicetree
RevySR Jun 4, 2025
b831f19
FROMLIST: riscv: dts: sophgo: add ziccrse for sg2042
RevySR Jun 4, 2025
695ca3a
FROMLIST: riscv: dts: sophgo: add zfh for sg2042
RevySR Jun 4, 2025
2486164
FROMLIST: dt-bindings: riscv: add Sophgo SG2042_EVB_V1.X bindings
RevySR Jun 4, 2025
a0446d8
FROMLIST: riscv: dts: sophgo: add Sophgo SG2042_EVB_V1.X board device…
RevySR Jun 4, 2025
c9c9ce0
FROMLIST: dt-bindings: riscv: add Sophgo SG2042_EVB_V2.0 bindings
RevySR Jun 4, 2025
b0f2362
FROMLIST: riscv: dts: sophgo: add Sophgo SG2042_EVB_V2.0 board device…
RevySR Jun 4, 2025
17b8671
FROMLIST: riscv: vector: Fix context save/restore with xtheadvector
RevySR Jun 4, 2025
74fa466
FROMLIST: spi: dt-bindings: spi-sg2044-nor: Add SOPHGO SG2042
sycamoremoon Jun 4, 2025
dbfcc8d
FROMLIST: mtd: spi-nor: Add GD25LB512ME GigaDevice flash_info
sycamoremoon Jun 4, 2025
56bb2bd
FROMLIST: riscv: dts: sophgo: Add SPI NOR node for SG2042
sycamoremoon Jun 4, 2025
87eadda
SOPHGO: riscv: kexec: Add image loader for kexec file
xingxg2022 Jun 4, 2025
f35d9ca
REVYOS: pcie: sg2042: pcie_rc1 use msi as msi-parent
RevySR Jun 4, 2025
7768115
REVYOS: dts: sophgo: sg2042: move pcie domain config into board devic…
inochisa Jun 4, 2025
6c4c38f
REVYOS: dts: sophgo: sg2042: add pcie port for sg2042 EVB V1.X/V2.0
inochisa Jun 4, 2025
3eb11eb
REVYOS: riscv: dts: sophgo: enable pcie_rc for Sophgo SG2042_EVB_V1.X
RevySR Jun 4, 2025
805efed
REVYOS: riscv: dts: sophgo: enable pcie_rc for Sophgo SG2042_EVB_V2.0
RevySR Jun 4, 2025
af08386
REVYOS: riscv: dts: sophgo: Enable SPI NOR node for SG2042_EVB_V1/V2
RevySR Jun 4, 2025
43234a6
RISCV64: REVYOS: dts: sophgo: sg2042: sync old kernel numa-id
RevySR Jun 4, 2025
a6f9777
RISCV64: REVYOS: Revert "riscv: Enable pcpu page first chunk allocator"
RevySR Jun 4, 2025
a20a0b7
RISCV64: REVYOS: Revert "NUMA: early use of cpu_to_node() returns 0 i…
RevySR Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/mfd/syscon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ select:
- rockchip,rk3576-qos
- rockchip,rk3588-qos
- rockchip,rv1126-qos
- sophgo,sg2042-pcie-ctrl
- st,spear1340-misc
- stericsson,nomadik-pmu
- starfive,jh7100-sysmain
Expand Down Expand Up @@ -215,6 +216,7 @@ properties:
- rockchip,rk3576-qos
- rockchip,rk3588-qos
- rockchip,rv1126-qos
- sophgo,sg2042-pcie-ctrl
- st,spear1340-misc
- stericsson,nomadik-pmu
- starfive,jh7100-sysmain
Expand Down
4 changes: 4 additions & 0 deletions Documentation/devicetree/bindings/net/snps,dwmac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ select:
- snps,dwmac-4.00
- snps,dwmac-4.10a
- snps,dwmac-4.20a
- snps,dwmac-5.00a
- snps,dwmac-5.10a
- snps,dwmac-5.20
- snps,dwmac-5.30a
Expand Down Expand Up @@ -97,11 +98,13 @@ properties:
- snps,dwmac-4.00
- snps,dwmac-4.10a
- snps,dwmac-4.20a
- snps,dwmac-5.00a
- snps,dwmac-5.10a
- snps,dwmac-5.20
- snps,dwmac-5.30a
- snps,dwxgmac
- snps,dwxgmac-2.10
- sophgo,sg2042-dwmac
- sophgo,sg2044-dwmac
- starfive,jh7100-dwmac
- starfive,jh7110-dwmac
Expand Down Expand Up @@ -634,6 +637,7 @@ allOf:
- snps,dwmac-4.00
- snps,dwmac-4.10a
- snps,dwmac-4.20a
- snps,dwmac-5.00a
- snps,dwmac-5.10a
- snps,dwmac-5.20
- snps,dwmac-5.30a
Expand Down
11 changes: 8 additions & 3 deletions Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ select:
contains:
enum:
- sophgo,sg2044-dwmac
- sophgo,sg2042-dwmac
required:
- compatible

properties:
compatible:
items:
- const: sophgo,sg2044-dwmac
- const: snps,dwmac-5.30a
oneOf:
- items:
- const: sophgo,sg2042-dwmac
- const: snps,dwmac-5.00a
- items:
- const: sophgo,sg2044-dwmac
- const: snps,dwmac-5.30a

reg:
maxItems: 1
Expand Down
147 changes: 147 additions & 0 deletions Documentation/devicetree/bindings/pci/sophgo,sg2042-pcie-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# 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 <[email protected]>

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:
type: object
$ref: /schemas/interrupt-controller/msi-controller.yaml#
unevaluatedProperties: false

properties:
compatible:
items:
- const: sophgo,sg2042-pcie-msi

interrupts:
maxItems: 1

interrupt-names:
const: msi

msi-parent: true

sophgo,link-id:
$ref: /schemas/types.yaml#/definitions/uint32
description: |
SG2042 uses Cadence IP, every IP is composed of 2 cores (called link0
& link1 as Cadence's term). Each core corresponds to a host bridge,
and each host bridge has only one root port. Their configuration
registers are completely independent. SG2042 integrates two Cadence IPs,
so there can actually be up to four host bridges. "sophgo,link-id" is
used to identify which core/link the PCIe host bridge node corresponds to.

The Cadence IP has two modes of operation, selected by a strap pin.

In the single-link mode, the Cadence PCIe core instance associated
with Link0 is connected to all the lanes and the Cadence PCIe core
instance associated with Link1 is inactive.

In the dual-link mode, the Cadence PCIe core instance associated
with Link0 is connected to the lower half of the lanes and the
Cadence PCIe core instance associated with Link1 is connected to
the upper half of the lanes.

SG2042 contains 2 Cadence IPs and configures the Cores as below:

+-- Core (Link0) <---> pcie_rc0 +-----------------+
| | |
Cadence IP 1 --+ | cdns_pcie0_ctrl |
| | |
+-- Core (Link1) <---> disabled +-----------------+

+-- Core (Link0) <---> pcie_rc1 +-----------------+
| | |
Cadence IP 2 --+ | cdns_pcie1_ctrl |
| | |
+-- Core (Link1) <---> pcie_rc2 +-----------------+

pcie_rcX is PCIe node ("sophgo,sg2042-pcie-host") defined in DTS.

Sophgo defines some new register files to add support for their MSI
controller inside PCIe. These new register files are defined in DTS as
syscon node ("sophgo,sg2042-pcie-ctrl"), i.e. "cdns_pcie0_ctrl" /
"cdns_pcie1_ctrl". cdns_pcieX_ctrl contains some registers shared by
pcie_rcX, even two RC (Link)s may share different bits of the same
register. For example, cdns_pcie1_ctrl contains registers shared by
link0 & link1 for Cadence IP 2.

"sophgo,link-id" is defined to distinguish the two RC's in one Cadence IP,
so we can know what registers (bits) we should use.

sophgo,syscon-pcie-ctrl:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Phandle to the PCIe System Controller DT node. It's required to
access some MSI operation registers shared by PCIe RCs.

allOf:
- $ref: cdns-pcie-host.yaml#

required:
- compatible
- reg
- reg-names
- vendor-id
- device-id
- sophgo,link-id
- sophgo,syscon-pcie-ctrl

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>

pcie@62000000 {
compatible = "sophgo,sg2042-pcie-host";
device_type = "pci";
reg = <0x62000000 0x00800000>,
<0x48000000 0x00001000>;
reg-names = "reg", "cfg";
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x81000000 0 0x00000000 0xde000000 0 0x00010000>,
<0x82000000 0 0xd0400000 0xd0400000 0 0x0d000000>;
bus-range = <0x00 0xff>;
vendor-id = <0x1f1c>;
device-id = <0x2042>;
cdns,no-bar-match-nbits = <48>;
sophgo,link-id = <0>;
sophgo,syscon-pcie-ctrl = <&cdns_pcie1_ctrl>;
msi-parent = <&msi_pcie>;
msi_pcie: msi {
compatible = "sophgo,sg2042-pcie-msi";
msi-controller;
interrupt-parent = <&intc>;
interrupts = <123 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "msi";
};
};
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/riscv/sophgo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ properties:
- items:
- enum:
- milkv,pioneer
- sophgo,sg2042-evb-v1
- sophgo,sg2042-evb-v2
- const: sophgo,sg2042

additionalProperties: true
Expand Down
7 changes: 6 additions & 1 deletion Documentation/devicetree/bindings/spi/spi-sg2044-nor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ allOf:

properties:
compatible:
const: sophgo,sg2044-spifmc-nor
oneOf:
- const: sophgo,sg2044-spifmc-nor
- items:
- enum:
- sophgo,sg2042-spifmc-nor
- const: sophgo,sg2044-spifmc-nor

reg:
maxItems: 1
Expand Down
4 changes: 1 addition & 3 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ config RISCV
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAS_UBSAN
select ARCH_HAS_VDSO_ARCH_DATA if GENERIC_VDSO_DATA_STORE
select ARCH_KEEP_MEMBLOCK if ACPI
select ARCH_KEEP_MEMBLOCK
select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
Expand Down Expand Up @@ -491,9 +491,7 @@ config NUMA
depends on SMP && MMU
select ARCH_SUPPORTS_NUMA_BALANCING
select GENERIC_ARCH_NUMA
select HAVE_SETUP_PER_CPU_AREA
select NEED_PER_CPU_EMBED_FIRST_CHUNK
select NEED_PER_CPU_PAGE_FIRST_CHUNK
select OF_NUMA
select USE_PERCPU_NUMA_NODE_ID
help
Expand Down
19 changes: 19 additions & 0 deletions arch/riscv/Kconfig.errata
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,23 @@ config ERRATA_THEAD_GHOSTWRITE

If you don't know what to do here, say "Y".

config ERRATA_THEAD_WRITE_ONCE
bool "Apply T-Head WRITE_ONCE errata"
depends on ERRATA_THEAD
default y
help
The early version of T-Head C9xx cores of sg2042 & th1520 have a store
merge buffer delay problem. The store merge buffer could improve the
store queue performance by merging multi-store requests, but when there
are no continued store requests, the prior single store request would be
waiting in the store queue for a long time. That would cause signifi-
cant problems for communication between multi-cores. Appending a
fence w.o could immediately flush the store merge buffer and let other
cores see the write result.

This will apply the WRITE_ONCE errata to handle the non-standard beh-
avior via appending a fence w.o instruction for WRITE_ONCE().

If you don't know what to do here, say "Y".

endmenu # "CPU errata selection"
2 changes: 2 additions & 0 deletions arch/riscv/boot/dts/sophgo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dtb-$(CONFIG_ARCH_SOPHGO) += cv1800b-milkv-duo.dtb
dtb-$(CONFIG_ARCH_SOPHGO) += cv1812h-huashan-pi.dtb
dtb-$(CONFIG_ARCH_SOPHGO) += sg2002-licheerv-nano-b.dtb
dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-milkv-pioneer.dtb
dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-evb-v1.dtb
dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-evb-v2.dtb
Loading