Compare commits

34 Commits

Author SHA1 Message Date
Han Gao
7511e969db REVYOS: HACK: xe: force DG1/DG2/ATS/PVC use xe driver
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
976719aa19 SOPHGO: riscv: dts: sophgo: sg2044: Add eFUSE device
Add eFUSE controller node for SG2044.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
d635b991c9 SOPHGO: nvmem: Add Sophgo SG2044 eFuse driver
Sophgo SoCs such as SG2044 contain eFuses used to store
factory-programmed data.

As for SG2044, HW automatically loads the eFuse content
into shadow registers which are organized as 32bit values
exposed as MMIO.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
0058b6e54f SOPHGO: dt-bindings: nvmem: Add SG2044 eFuse controller
Sophgo SG2044 uses eFuses used to store factory-programmed data
such as ROM patch, public keys and other factory information.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
1c82dc3707 FROMLIST: net: stmmac: dwmac-sophgo: Add phy interface filter
As the SG2042 has an internal rx delay, the delay should be removed
when initializing the mac, otherwise the phy will be misconfigurated.

Fixes: 543009e2d4 ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Tested-by: Han Gao <rabenda.cn@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20251103030526.1092365-4-inochiama@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
32e4b7e5de FROMLIST: net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay
The "phy-mode" property of devicetree indicates whether the PCB has
delay now, which means the mac needs to modify the PHY mode based
on whether there is an internal delay in the mac.

This modification is similar for many ethernet drivers. To simplify
code, define the helper phy_fix_phy_mode_for_mac_delays(speed, mac_txid,
mac_rxid) to fix PHY mode based on whether mac adds internal delay.

Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://lore.kernel.org/r/20251103030526.1092365-3-inochiama@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:31 +08:00
Inochi Amaoto
60da8f9adf FROMLIST: dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
As the ethernet controller of SG2044 and SG2042 only supports
RGMII phy. Add phy-mode property to restrict the value.

Also, since SG2042 has internal rx delay in its mac, make
only "rgmii-txid" and "rgmii-id" valid for phy-mode.

Fixes: e281c48a73 ("dt-bindings: net: sophgo,sg2044-dwmac: Add support for Sophgo SG2042 dwmac")
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20251103030526.1092365-2-inochiama@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:31 +08:00
Chen Wang
fabf96dc31 FROMLIST: riscv: sophgo: dts: enable PCIe for SG2042_EVB_V2.0
Enable PCIe controllers for Sophgo SG2042_EVB_V2.0 board,
which uses SG2042 SoC.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/r/50a753f9b8cbd5a90b5b2df737f87fc77a9b33a7.1760929111.git.unicorn_wang@outlook.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:31 +08:00
Chen Wang
29b43247d8 FROMLIST: riscv: sophgo: dts: enable PCIe for SG2042_EVB_V1.X
Enable PCIe controllers for Sophgo SG2042_EVB_V1.X board,
which uses SG2042 SoC.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/r/1ad96631cc9d9d7403a2bed5585d856fa101a2ef.1760929111.git.unicorn_wang@outlook.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
2456e83d9e FROMLIST: riscv: sophgo: dts: enable PCIe for PioneerBox
Enable PCIe controllers for PioneerBox, which uses SG2042 SoC.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/r/ec474c5eefb79626dd6a4d65454da9109aaf2f4d.1760929111.git.unicorn_wang@outlook.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
a0a4993d57 FROMLIST: riscv: sophgo: dts: add PCIe controllers for SG2042
Add PCIe controller nodes in DTS for Sophgo SG2042.
Default they are disabled.

Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/r/b34d819cd763482e0ecbc5c5ea721f0101d1f844.1760929111.git.unicorn_wang@outlook.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Zixian Zeng
a0936f8e6c FROMLIST: riscv: dts: sophgo: Enable SPI NOR node for SG2042_EVB_V2
Enable SPI NOR node for SG2042_EVB_V2 device tree

According to SG2042_EVB_V2 schematic, SPI-NOR Flash cannot support QSPI
due to hardware design. Thus spi-(tx|rx)-bus-width must be set to 1.

Signed-off-by: Zixian Zeng <sycamoremoon376@gmail.com>
Link: https://lore.kernel.org/r/20250916-sfg-spidts-v2-4-b5d9024fe1c8@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Zixian Zeng
b50707145e FROMLIST: riscv: dts: sophgo: Enable SPI NOR node for SG2042_EVB_V1
Enable SPI NOR node for SG2042_EVB_V1 device tree

According to SG2042_EVB_V1 schematic, SPI-NOR Flash cannot support QSPI
due to hardware design. Thus spi-(tx|rx)-bus-width must be set to 1.

Signed-off-by: Zixian Zeng <sycamoremoon376@gmail.com>
Link: https://lore.kernel.org/r/20250916-sfg-spidts-v2-3-b5d9024fe1c8@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Zixian Zeng
b0fd11e572 FROMLIST: riscv: dts: sophgo: Enable SPI NOR node for PioneerBox
Enable SPI NOR node for PioneerBox device tree

According to PioneerBox schematic, SPI-NOR Flash cannot support QSPI
due to hardware design. Thus spi-(tx|rx)-bus-width must be set to 1.

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Tested-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Zixian Zeng <sycamoremoon376@gmail.com>
Link: https://lore.kernel.org/r/20250916-sfg-spidts-v2-2-b5d9024fe1c8@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Zixian Zeng
ddfcc372ac FROMLIST: riscv: dts: sophgo: Add SPI NOR node for SG2042
Add SPI NOR controller node for SG2042

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Tested-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Zixian Zeng <sycamoremoon376@gmail.com>
Link: https://lore.kernel.org/r/20250916-sfg-spidts-v2-1-b5d9024fe1c8@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
f6819b4343 BACKPORT: FROMLIST: drm/ttm: downgrade cached to write_combined when snooping not available
As we can now acquire the presence of the full DMA coherency (snooping
capability) from ttm_device, we can now map the CPU side memory as
write-combined when cached is requested and snooping is not avilable.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Link: https://lore.kernel.org/r/20240629052247.2653363-3-uwu@icenowy.me
[ Han Gao: add conditional compilation for dma coherent operations ]
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
fc5d914ad1 BACKPORT: FROMLIST: drm/ttm: save the device's DMA coherency status in ttm_device
Currently TTM utilizes cached memory regardless of whether the device
have full DMA coherency (can snoop CPU cache).

Save the device's DMA coherency status in struct ttm_device, to allow
further support of devices w/o snooping capability (the capability
missing on at least one part of the transmission between the CPU and the
device).

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Link: https://lore.kernel.org/r/20240629052247.2653363-2-uwu@icenowy.me
[ Han Gao: add conditional compilation for dma_coherent ]
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Inochi Amaoto
a687990d16 FROMLIST: perf vendor events riscv: add T-HEAD C920V2 JSON support
T-HEAD C920 has a V2 iteration, which supports Sscompmf. The V2
iteration supports the same perf events as V1.

Reuse T-HEAD c900-legacy JSON file for T-HEAD C920V2.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Link: https://lore.kernel.org/r/20251014014830.613399-1-inochiama@gmail.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Ilpo Järvinen
d30ef862ea FROMLIST: PCI: Release BAR0 of an integrated bridge to allow GPU BAR resize
Resizing BAR to a larger size has to release upstream bridge windows in
order make the bridge windows larger as well (and to potential relocate
them into a larger free block within iomem space). Some GPUs have an
integrated PCI switch that has BAR0. The resource allocation assigns
space for that BAR0 as it does for any resource.

An extra resource on a bridge will pin its upstream bridge window in
place which prevents BAR resize for anything beneath that bridge.

Nothing in the pcieport driver provided by PCI core, which typically is
the driver bound to these bridges, requires that BAR0. Because of that,
releasing the extra BAR does not seem to have notable downsides but
comes with a clear upside.

Therefore, release BAR0 of such switches using a quirk and clear its
flags to prevent any new invocation of the resource assignment
algorithm from assigning the resource again.

Due to other siblings within the PCI hierarchy of all the devices
integrated into the GPU, some other devices may still have to be
manually removed before the resize is free of any bridge window pins.
Such siblings can be released through sysfs to unpin windows while
leaving access to GPU's sysfs entries required for initiating the
resize operation, whereas removing the topmost bridge this quirk
targets would result in removing the GPU device as well so no manual
workaround for this problem exists.

Reported-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/linux-pci/fl6tx5ztvttg7txmz2ps7oyd745wg3lwcp3h7esmvnyg26n44y@owo2ojiu2mov/
Link: https://lore.kernel.org/intel-xe/20250721173057.867829-1-uwu@icenowy.me/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/intel-xe/fafda2a3-fc63-ce97-d22b-803f771a4d19@linux.intel.com
Link: https://lore.kernel.org/r/20250918-xe-pci-rebar-2-v1-1-6c094702a074@intel.com
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Guo Ren (Alibaba DAMO Academy)
0d94e08ccd FROMLIST: riscv: errata: Add ERRATA_THEAD_WRITE_ONCE fixup
The early version of XuanTie C910 core has 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 not
continued store requests, the prior single store request would be
waiting in the store queue for a long time. That would cause
significant problems for communication between multi-cores. This
problem was found on sg2042 & th1520 platforms with the qspinlock
lock torture test.

So 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
behavior via appending a fence w.o instruction for WRITE_ONCE().

This problem is only observed on the sg2042 hardware platform by
running the lock_torture test program for half an hour. The problem
was not found in the user space application, because interrupt can
break the livelock.

Reviewed-by: Leonardo Bras <leobras@redhat.com>
Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
Link: https://lore.kernel.org/r/20250713155321.2064856-3-guoren@kernel.org
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
4584bdc055 FROMLIST: drm/ttm: add pgprot handling for RISC-V
The RISC-V Svpbmt privileged extension provides support for overriding
page memory coherency attributes, and, along with vendor extensions like
Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.

Adapt the codepath that maps ttm_write_combined to pgprot_writecombine
and ttm_noncached to pgprot_noncached to RISC-V, to allow proper page
access attributes.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Tested-by: Han Gao <rabenda.cn@gmail.com>
Link: https://lore.kernel.org/r/20251020053523.731353-1-uwu@icenowy.me
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Han Gao
e10701958c UPSTREAM: riscv: acpi: avoid errors caused by probing DT devices when ACPI is used
Similar to the ARM64 commit 3505f30fb6a9s ("ARM64 / ACPI: If we chose
to boot from acpi then disable FDT"), let's not do DT hardware probing
if ACPI is enabled in early boot.  This avoids errors caused by
repeated driver probing.

Signed-off-by: Han Gao <rabenda.cn@gmail.com>
Link: https://lore.kernel.org/r/20250910112401.552987-1-rabenda.cn@gmail.com
[pjw@kernel.org: cleaned up patch description and subject]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
(cherry picked from commit 69a8b62a7aa1e54ff7623064f6507fa29c1d0d4e)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
c1a77b7c98 UPSTREAM: riscv: sophgo: dts: sg2044: Change msi irq type to IRQ_TYPE_EDGE_RISING
Fix msi irq type to be the correct type, although this field is not used yet.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Inochi Amaoto <inochiama@gmail.com> # Sophgo SRD3-10
Link: https://lore.kernel.org/all/c38b9b1682af978473705b7e70b6faaa36fe5024.1756953919.git.unicorn_wang@outlook.com

(cherry picked from commit 8aefd2724451dedea1368d3915ab2dd5ecebc3cb)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
bb71965e04 UPSTREAM: riscv: sophgo: dts: sg2042: Change msi irq type to IRQ_TYPE_EDGE_RISING
Fix msi irq type to be the correct type, although this field is not used yet.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/831c1b650c575380d56ef3e2faed9bee278c9006.1756953919.git.unicorn_wang@outlook.com

(cherry picked from commit a4bd4c330d5deaaa54db3a2ca4d2dd402d3a7248)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
8f84ccc4a0 UPSTREAM: irqchip/sg2042-msi: Set irq type according to DT configuration
Read the device tree configuration and use it to set the interrupt type.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Inochi Amaoto <inochiama@gmail.com> # Sophgo SRD3-10
Link: https://lore.kernel.org/all/b22d2b0a00a96161253435d17b3c66538f3ba1c2.1756953919.git.unicorn_wang@outlook.com
(cherry picked from commit c2616c5696e85efb2679499d7260f7766b93cff6)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
cbae1415e4 UPSTREAM: PCI: sg2042: Add Sophgo SG2042 PCIe driver
Add support for PCIe controller in Sophgo SG2042 SoC. The controller uses
the Cadence PCIe core programmed by pcie-cadence* common driver. The PCIe
controller in SG2042 works in host mode only, supporting data rate up to 16
GT/s and lanes up to x16 or x8.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
[mani: reworded description and minor code cleanups]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/01b0a57cd9dba8bed7c1f2d52997046c2c6f042b.1757643388.git.unicorn_wang@outlook.com
(cherry picked from commit 1c72774df028429836eec3394212f2921bb830fc)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
4075edbaf6 UPSTREAM: PCI: cadence: Check for the existence of cdns_pcie::ops before using it
cdns_pcie::ops might not be populated by all the Cadence glue drivers. This
is going to be true for the upcoming Sophgo platform which doesn't set the
ops.

Hence, add a check to prevent NULL pointer dereference.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
[mani: reworded subject and description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/35182ee1d972dfcd093a964e11205efcebbdc044.1757643388.git.unicorn_wang@outlook.com
(cherry picked from commit 49a6c160ad4812476f8ae1a8f4ed6d15adfa6c09)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:30 +08:00
Chen Wang
ae8312b68b UPSTREAM: dt-bindings: pci: Add Sophgo SG2042 PCIe host
Add binding for Sophgo SG2042 PCIe host controller.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/2755f145755b6096247c26852b63671a6fea4dbf.1757643388.git.unicorn_wang@outlook.com
(cherry picked from commit 4e4a4f58bed19e1a3a5a7c3a18ce3b927b76fcd3)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Han Gao
f363d8ceb6 UPSTREAM: dts: sophgo: sg2042: added numa id description
According to the description of [1], sg2042 is divided into 4 numa.
STREAM test performance will improve.

Before:
Function    Best Rate MB/s  Avg time     Min time     Max time
Copy:           10739.7     0.015687     0.014898     0.016385
Scale:          10865.9     0.015628     0.014725     0.016757
Add:            10622.3     0.023276     0.022594     0.023899
Triad:          10583.4     0.023653     0.022677     0.024761

After:
Function    Best Rate MB/s  Avg time     Min time     Max time
Copy:           34254.9     0.005142     0.004671     0.005995
Scale:          37735.5     0.004752     0.004240     0.005407
Add:            44206.8     0.005983     0.005429     0.006461
Triad:          43040.6     0.006320     0.005576     0.006996

[1] https://github.com/sophgo/sophgo-doc/blob/main/SG2042/TRM/source/pic/mesh.png

Signed-off-by: Han Gao <rabenda.cn@gmail.com>
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/r/20250910105531.519897-1-rabenda.cn@gmail.com
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Chen Wang <wangchen20@iscas.ac.cn>
(cherry picked from commit 4d94abded400a5194b929c26b3aa07fb9485fe35)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Guo Ren (Alibaba DAMO Academy)
47d5f72bdd UPSTREAM: riscv: Move vendor errata definitions to new header
Move vendor errata definitions into errata_list_vendors.h.

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: Han Gao <rabenda.cn@gmail.com>
Link: https://lore.kernel.org/r/20250713155321.2064856-2-guoren@kernel.org
[pjw@kernel.org: updated to apply and to make the whitespace consistent]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
(cherry picked from commit 16d18e3eaf29be1d987f5238ec03226f15dad5f5)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Inochi Amaoto
cadb2c992c UPSTREAM: irqchip/sg2042-msi: Set MSI_FLAG_MULTI_PCI_MSI flags for SG2044
The MSI controller on SG2044 has the ability to allocate multiple PCI MSI
interrupts. So the PCIe controller driver can use this feature if the
hardware supports multiple PCI MSI interrupts.

Add the MSI_FLAG_MULTI_PCI_MSI flag to the supported_flags of SG2044
msi_parent_ops to enable this functionality.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Chen Wang <unicorn_wang@outlook.com> # Pioneerbox
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/all/20250813232835.43458-5-inochiama@gmail.com

(cherry picked from commit 7ee4a5a2ec3748facfb4ca96e4cce6cabbdecab2)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Inochi Amaoto
293f6e7522 UPSTREAM: irqchip/sifive-plic: Respect mask state when setting affinity
plic_set_affinity() always calls plic_irq_enable(), which clears up the
priority setting even the interrupt is only masked. This unmasks the
interrupt unexpectly.

Replace the plic_irq_enable/disable() with plic_irq_toggle() to avoid
changing the priority setting.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nam Cao <namcao@linutronix.de> # VisionFive 2
Tested-by: Chen Wang <unicorn_wang@outlook.com> # Pioneerbox
Reviewed-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/all/20250811002633.55275-1-inochiama@gmail.com
Link: https://lore.kernel.org/lkml/20250722224513.22125-1-inochiama@gmail.com/
(cherry picked from commit adecf78df945f4c7a1d29111b0002827f487df51)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Yunhui Cui
e3f9a37335 UPSTREAM: riscv: introduce ioremap_wc()
Compared with IO attributes, NC attributes can improve performance,
specifically in these aspects: Relaxed Order, Gathering, Supports Read
Speculation, Supports Unaligned Access.

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250722091504.45974-2-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
(cherry picked from commit 3a8ee3a9f4f6caca192fd2fdc88c1ce56c521b38)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
Jessica Liu
ae5ada48b7 UPSTREAM: riscv: mmap(): use unsigned offset type in riscv_sys_mmap
The variable type of offset should be consistent with the relevant
interfaces of mmap which described in commit 295f10061a ("syscalls:
mmap(): use unsigned offset type consistently"). Otherwise, a user input
with the top bit set would result in a negative page offset rather than a
large one.

Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
Tested-by: Han Gao <rabenda.cn@gmail.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Link: https://lore.kernel.org/r/20250801104948133AaMr5S6E382PbNNhoJgHA@zte.com.cn
[pjw@kernel.org: hand-applied mangled patch; fixed checkpatch error]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
(cherry picked from commit 316b60b984d5be9b86047cdf3bf16d51c7c70cc5)
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
2025-11-03 17:08:29 +08:00
43 changed files with 1043 additions and 40 deletions

View File

@@ -70,6 +70,25 @@ required:
allOf: allOf:
- $ref: snps,dwmac.yaml# - $ref: snps,dwmac.yaml#
- if:
properties:
compatible:
contains:
const: sophgo,sg2042-dwmac
then:
properties:
phy-mode:
enum:
- rgmii-txid
- rgmii-id
else:
properties:
phy-mode:
enum:
- rgmii
- rgmii-rxid
- rgmii-txid
- rgmii-id
unevaluatedProperties: false unevaluatedProperties: false

View File

@@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/nvmem/sophgo,efuse.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Sophgo SoC eFuse-based NVMEM
description:
Sophgo SoCs contain factory-programmed eFuses used to store ROM patch,
public key and other factory information.
maintainers:
- Inochi Amaoto <inochiama@gmail.com>
allOf:
- $ref: nvmem.yaml#
properties:
compatible:
enum:
- sophgo,sg2044-efuse
reg:
maxItems: 1
clocks:
minItems: 1
items:
- description: Core clock
- description: APB clock
clock-names:
minItems: 1
items:
- const: core
- const: apb
resets:
maxItems: 1
required:
- compatible
- reg
- clocks
unevaluatedProperties: false
examples:
- |
efuse@40000000 {
compatible = "sophgo,sg2044-efuse";
reg = <0x40000000 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
clocks = <&clk 0>,
<&clk 1>;
clock-names = "core", "apb";
};
...

View File

@@ -0,0 +1,64 @@
# 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 <unicorn_wang@outlook.com>
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
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>;
msi-parent = <&msi>;
};

View File

@@ -130,4 +130,21 @@ config ERRATA_THEAD_GHOSTWRITE
If you don't know what to do here, say "Y". 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().
endmenu # "CPU errata selection" endmenu # "CPU errata selection"

View File

@@ -272,6 +272,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache0>; next-level-cache = <&l2_cache0>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu0_intc: interrupt-controller { cpu0_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -299,6 +300,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache0>; next-level-cache = <&l2_cache0>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu1_intc: interrupt-controller { cpu1_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -326,6 +328,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache0>; next-level-cache = <&l2_cache0>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu2_intc: interrupt-controller { cpu2_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -353,6 +356,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache0>; next-level-cache = <&l2_cache0>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu3_intc: interrupt-controller { cpu3_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -380,6 +384,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache1>; next-level-cache = <&l2_cache1>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu4_intc: interrupt-controller { cpu4_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -407,6 +412,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache1>; next-level-cache = <&l2_cache1>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu5_intc: interrupt-controller { cpu5_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -434,6 +440,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache1>; next-level-cache = <&l2_cache1>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu6_intc: interrupt-controller { cpu6_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -461,6 +468,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache1>; next-level-cache = <&l2_cache1>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu7_intc: interrupt-controller { cpu7_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -488,6 +496,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache4>; next-level-cache = <&l2_cache4>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu8_intc: interrupt-controller { cpu8_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -515,6 +524,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache4>; next-level-cache = <&l2_cache4>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu9_intc: interrupt-controller { cpu9_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -542,6 +552,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache4>; next-level-cache = <&l2_cache4>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu10_intc: interrupt-controller { cpu10_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -569,6 +580,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache4>; next-level-cache = <&l2_cache4>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu11_intc: interrupt-controller { cpu11_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -596,6 +608,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache5>; next-level-cache = <&l2_cache5>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu12_intc: interrupt-controller { cpu12_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -623,6 +636,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache5>; next-level-cache = <&l2_cache5>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu13_intc: interrupt-controller { cpu13_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -650,6 +664,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache5>; next-level-cache = <&l2_cache5>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu14_intc: interrupt-controller { cpu14_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -677,6 +692,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache5>; next-level-cache = <&l2_cache5>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu15_intc: interrupt-controller { cpu15_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -704,6 +720,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache2>; next-level-cache = <&l2_cache2>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu16_intc: interrupt-controller { cpu16_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -731,6 +748,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache2>; next-level-cache = <&l2_cache2>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu17_intc: interrupt-controller { cpu17_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -758,6 +776,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache2>; next-level-cache = <&l2_cache2>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu18_intc: interrupt-controller { cpu18_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -785,6 +804,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache2>; next-level-cache = <&l2_cache2>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu19_intc: interrupt-controller { cpu19_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -812,6 +832,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache3>; next-level-cache = <&l2_cache3>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu20_intc: interrupt-controller { cpu20_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -839,6 +860,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache3>; next-level-cache = <&l2_cache3>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu21_intc: interrupt-controller { cpu21_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -866,6 +888,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache3>; next-level-cache = <&l2_cache3>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu22_intc: interrupt-controller { cpu22_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -893,6 +916,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache3>; next-level-cache = <&l2_cache3>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <0>;
cpu23_intc: interrupt-controller { cpu23_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -920,6 +944,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache6>; next-level-cache = <&l2_cache6>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu24_intc: interrupt-controller { cpu24_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -947,6 +972,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache6>; next-level-cache = <&l2_cache6>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu25_intc: interrupt-controller { cpu25_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -974,6 +1000,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache6>; next-level-cache = <&l2_cache6>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu26_intc: interrupt-controller { cpu26_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1001,6 +1028,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache6>; next-level-cache = <&l2_cache6>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu27_intc: interrupt-controller { cpu27_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1028,6 +1056,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache7>; next-level-cache = <&l2_cache7>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu28_intc: interrupt-controller { cpu28_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1055,6 +1084,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache7>; next-level-cache = <&l2_cache7>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu29_intc: interrupt-controller { cpu29_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1082,6 +1112,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache7>; next-level-cache = <&l2_cache7>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu30_intc: interrupt-controller { cpu30_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1109,6 +1140,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache7>; next-level-cache = <&l2_cache7>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <1>;
cpu31_intc: interrupt-controller { cpu31_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1136,6 +1168,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache8>; next-level-cache = <&l2_cache8>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu32_intc: interrupt-controller { cpu32_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1163,6 +1196,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache8>; next-level-cache = <&l2_cache8>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu33_intc: interrupt-controller { cpu33_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1190,6 +1224,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache8>; next-level-cache = <&l2_cache8>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu34_intc: interrupt-controller { cpu34_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1217,6 +1252,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache8>; next-level-cache = <&l2_cache8>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu35_intc: interrupt-controller { cpu35_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1244,6 +1280,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache9>; next-level-cache = <&l2_cache9>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu36_intc: interrupt-controller { cpu36_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1271,6 +1308,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache9>; next-level-cache = <&l2_cache9>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu37_intc: interrupt-controller { cpu37_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1298,6 +1336,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache9>; next-level-cache = <&l2_cache9>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu38_intc: interrupt-controller { cpu38_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1325,6 +1364,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache9>; next-level-cache = <&l2_cache9>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu39_intc: interrupt-controller { cpu39_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1352,6 +1392,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache12>; next-level-cache = <&l2_cache12>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu40_intc: interrupt-controller { cpu40_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1379,6 +1420,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache12>; next-level-cache = <&l2_cache12>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu41_intc: interrupt-controller { cpu41_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1406,6 +1448,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache12>; next-level-cache = <&l2_cache12>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu42_intc: interrupt-controller { cpu42_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1433,6 +1476,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache12>; next-level-cache = <&l2_cache12>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu43_intc: interrupt-controller { cpu43_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1460,6 +1504,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache13>; next-level-cache = <&l2_cache13>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu44_intc: interrupt-controller { cpu44_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1487,6 +1532,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache13>; next-level-cache = <&l2_cache13>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu45_intc: interrupt-controller { cpu45_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1514,6 +1560,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache13>; next-level-cache = <&l2_cache13>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu46_intc: interrupt-controller { cpu46_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1541,6 +1588,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache13>; next-level-cache = <&l2_cache13>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu47_intc: interrupt-controller { cpu47_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1568,6 +1616,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache10>; next-level-cache = <&l2_cache10>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu48_intc: interrupt-controller { cpu48_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1595,6 +1644,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache10>; next-level-cache = <&l2_cache10>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu49_intc: interrupt-controller { cpu49_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1622,6 +1672,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache10>; next-level-cache = <&l2_cache10>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu50_intc: interrupt-controller { cpu50_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1649,6 +1700,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache10>; next-level-cache = <&l2_cache10>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu51_intc: interrupt-controller { cpu51_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1676,6 +1728,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache11>; next-level-cache = <&l2_cache11>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu52_intc: interrupt-controller { cpu52_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1703,6 +1756,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache11>; next-level-cache = <&l2_cache11>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu53_intc: interrupt-controller { cpu53_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1730,6 +1784,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache11>; next-level-cache = <&l2_cache11>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu54_intc: interrupt-controller { cpu54_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1757,6 +1812,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache11>; next-level-cache = <&l2_cache11>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <2>;
cpu55_intc: interrupt-controller { cpu55_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1784,6 +1840,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache14>; next-level-cache = <&l2_cache14>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu56_intc: interrupt-controller { cpu56_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1811,6 +1868,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache14>; next-level-cache = <&l2_cache14>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu57_intc: interrupt-controller { cpu57_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1838,6 +1896,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache14>; next-level-cache = <&l2_cache14>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu58_intc: interrupt-controller { cpu58_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1865,6 +1924,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache14>; next-level-cache = <&l2_cache14>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu59_intc: interrupt-controller { cpu59_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1892,6 +1952,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache15>; next-level-cache = <&l2_cache15>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu60_intc: interrupt-controller { cpu60_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1919,6 +1980,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache15>; next-level-cache = <&l2_cache15>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu61_intc: interrupt-controller { cpu61_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1946,6 +2008,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache15>; next-level-cache = <&l2_cache15>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu62_intc: interrupt-controller { cpu62_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";
@@ -1973,6 +2036,7 @@
d-cache-sets = <512>; d-cache-sets = <512>;
next-level-cache = <&l2_cache15>; next-level-cache = <&l2_cache15>;
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
numa-node-id = <3>;
cpu63_intc: interrupt-controller { cpu63_intc: interrupt-controller {
compatible = "riscv,cpu-intc"; compatible = "riscv,cpu-intc";

View File

@@ -164,6 +164,18 @@
}; };
}; };
&pcie_rc0 {
status = "okay";
};
&pcie_rc1 {
status = "okay";
};
&pcie_rc2 {
status = "okay";
};
&pinctrl { &pinctrl {
emmc_cfg: sdhci-emmc-cfg { emmc_cfg: sdhci-emmc-cfg {
sdhci-emmc-wp-pins { sdhci-emmc-wp-pins {
@@ -238,6 +250,30 @@
status = "okay"; status = "okay";
}; };
&spifmc0 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
};
};
&spifmc1 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
};
};
&uart0 { &uart0 {
pinctrl-0 = <&uart0_cfg>; pinctrl-0 = <&uart0_cfg>;
pinctrl-names = "default"; pinctrl-names = "default";

View File

@@ -152,6 +152,18 @@
}; };
}; };
&pcie_rc0 {
status = "okay";
};
&pcie_rc1 {
status = "okay";
};
&pcie_rc2 {
status = "okay";
};
&pinctrl { &pinctrl {
emmc_cfg: sdhci-emmc-cfg { emmc_cfg: sdhci-emmc-cfg {
sdhci-emmc-wp-pins { sdhci-emmc-wp-pins {
@@ -226,6 +238,18 @@
status = "okay"; status = "okay";
}; };
&spifmc1 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
};
};
&uart0 { &uart0 {
pinctrl-0 = <&uart0_cfg>; pinctrl-0 = <&uart0_cfg>;
pinctrl-names = "default"; pinctrl-names = "default";

View File

@@ -128,6 +128,18 @@
}; };
}; };
&pcie_rc0 {
status = "okay";
};
&pcie_rc2 {
status = "okay";
};
&pcie_rc3 {
status = "okay";
};
&sd { &sd {
pinctrl-0 = <&sd_cfg>; pinctrl-0 = <&sd_cfg>;
pinctrl-names = "default"; pinctrl-names = "default";
@@ -138,6 +150,30 @@
status = "okay"; status = "okay";
}; };
&spifmc0 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
};
};
&spifmc1 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;
};
};
&uart0 { &uart0 {
pinctrl-0 = <&uart0_cfg>; pinctrl-0 = <&uart0_cfg>;
pinctrl-names = "default"; pinctrl-names = "default";

View File

@@ -19,6 +19,26 @@
#size-cells = <2>; #size-cells = <2>;
dma-noncoherent; dma-noncoherent;
distance-map {
compatible = "numa-distance-map-v1";
distance-matrix = <0 0 10>,
<0 1 15>,
<0 2 25>,
<0 3 30>,
<1 0 15>,
<1 1 10>,
<1 2 30>,
<1 3 25>,
<2 0 25>,
<2 1 30>,
<2 2 10>,
<2 3 15>,
<3 0 30>,
<3 1 25>,
<3 2 15>,
<3 3 10>;
};
aliases { aliases {
serial0 = &uart0; serial0 = &uart0;
}; };
@@ -48,6 +68,30 @@
interrupt-parent = <&intc>; interrupt-parent = <&intc>;
ranges; ranges;
spifmc0: spi@7000180000 {
compatible = "sophgo,sg2042-spifmc-nor";
reg = <0x70 0x00180000 0x0 0x1000000>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&clkgen GATE_CLK_AHB_SF>;
interrupt-parent = <&intc>;
interrupts = <108 IRQ_TYPE_LEVEL_HIGH>;
resets = <&rstgen RST_SF0>;
status = "disabled";
};
spifmc1: spi@7002180000 {
compatible = "sophgo,sg2042-spifmc-nor";
reg = <0x70 0x02180000 0x0 0x1000000>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&clkgen GATE_CLK_AHB_SF>;
interrupt-parent = <&intc>;
interrupts = <109 IRQ_TYPE_LEVEL_HIGH>;
resets = <&rstgen RST_SF1>;
status = "disabled";
};
i2c0: i2c@7030005000 { i2c0: i2c@7030005000 {
compatible = "snps,designware-i2c"; compatible = "snps,designware-i2c";
reg = <0x70 0x30005000 0x0 0x1000>; reg = <0x70 0x30005000 0x0 0x1000>;
@@ -190,7 +234,7 @@
reg-names = "clr", "doorbell"; reg-names = "clr", "doorbell";
msi-controller; msi-controller;
#msi-cells = <0>; #msi-cells = <0>;
msi-ranges = <&intc 64 IRQ_TYPE_LEVEL_HIGH 32>; msi-ranges = <&intc 64 IRQ_TYPE_EDGE_RISING 32>;
}; };
rpgate: clock-controller@7030010368 { rpgate: clock-controller@7030010368 {
@@ -220,6 +264,94 @@
#clock-cells = <1>; #clock-cells = <1>;
}; };
pcie_rc0: pcie@7060000000 {
compatible = "sophgo,sg2042-pcie-host";
device_type = "pci";
reg = <0x70 0x60000000 0x0 0x00800000>,
<0x40 0x00000000 0x0 0x00001000>;
reg-names = "reg", "cfg";
linux,pci-domain = <0>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x01000000 0x0 0x00000000 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 = <0x0 0xff>;
vendor-id = <0x1f1c>;
device-id = <0x2042>;
cdns,no-bar-match-nbits = <48>;
msi-parent = <&msi>;
status = "disabled";
};
pcie_rc1: pcie@7060800000 {
compatible = "sophgo,sg2042-pcie-host";
device_type = "pci";
reg = <0x70 0x60800000 0x0 0x00800000>,
<0x44 0x00000000 0x0 0x00001000>;
reg-names = "reg", "cfg";
linux,pci-domain = <1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x01000000 0x0 0x00000000 0x44 0xc0400000 0x0 0x00400000>,
<0x42000000 0x0 0xd0000000 0x44 0xd0000000 0x0 0x10000000>,
<0x02000000 0x0 0xe0000000 0x44 0xe0000000 0x0 0x20000000>,
<0x43000000 0x46 0x00000000 0x46 0x00000000 0x2 0x00000000>,
<0x03000000 0x45 0x00000000 0x45 0x00000000 0x1 0x00000000>;
bus-range = <0x0 0xff>;
vendor-id = <0x1f1c>;
device-id = <0x2042>;
cdns,no-bar-match-nbits = <48>;
msi-parent = <&msi>;
status = "disabled";
};
pcie_rc2: pcie@7062000000 {
compatible = "sophgo,sg2042-pcie-host";
device_type = "pci";
reg = <0x70 0x62000000 0x0 0x00800000>,
<0x48 0x00000000 0x0 0x00001000>;
reg-names = "reg", "cfg";
linux,pci-domain = <2>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x01000000 0x0 0x00000000 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 = <0x0 0xff>;
vendor-id = <0x1f1c>;
device-id = <0x2042>;
cdns,no-bar-match-nbits = <48>;
msi-parent = <&msi>;
status = "disabled";
};
pcie_rc3: pcie@7062800000 {
compatible = "sophgo,sg2042-pcie-host";
device_type = "pci";
reg = <0x70 0x62800000 0x0 0x00800000>,
<0x4c 0x00000000 0x0 0x00001000>;
reg-names = "reg", "cfg";
linux,pci-domain = <3>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x01000000 0x0 0x00000000 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 = <0x0 0xff>;
vendor-id = <0x1f1c>;
device-id = <0x2042>;
cdns,no-bar-match-nbits = <48>;
msi-parent = <&msi>;
status = "disabled";
};
clint_mswi: interrupt-controller@7094000000 { clint_mswi: interrupt-controller@7094000000 {
compatible = "sophgo,sg2042-aclint-mswi", "thead,c900-aclint-mswi"; compatible = "sophgo,sg2042-aclint-mswi", "thead,c900-aclint-mswi";
reg = <0x00000070 0x94000000 0x00000000 0x00004000>; reg = <0x00000070 0x94000000 0x00000000 0x00004000>;

View File

@@ -36,6 +36,10 @@
status = "okay"; status = "okay";
}; };
&efuse0 {
status = "okay";
};
&gmac0 { &gmac0 {
phy-handle = <&phy0>; phy-handle = <&phy0>;
phy-mode = "rgmii-id"; phy-mode = "rgmii-id";

View File

@@ -214,7 +214,7 @@
reg-names = "clr", "doorbell"; reg-names = "clr", "doorbell";
#msi-cells = <0>; #msi-cells = <0>;
msi-controller; msi-controller;
msi-ranges = <&intc 352 IRQ_TYPE_LEVEL_HIGH 512>; msi-ranges = <&intc 352 IRQ_TYPE_EDGE_RISING 512>;
status = "disabled"; status = "disabled";
}; };
@@ -408,6 +408,18 @@
status = "disabled"; status = "disabled";
}; };
efuse0: efuse@7040000000 {
compatible = "sophgo,sg2044-efuse";
reg = <0x70 0x40000000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <1>;
clocks = <&clk CLK_GATE_EFUSE>,
<&clk CLK_GATE_APB_EFUSE>;
clock-names = "core", "apb";
resets = <&rst RST_EFUSE0>;
status = "disabled";
};
i2c0: i2c@7040005000 { i2c0: i2c@7040005000 {
compatible = "sophgo,sg2044-i2c", "snps,designware-i2c"; compatible = "sophgo,sg2044-i2c", "snps,designware-i2c";
reg = <0x70 0x40005000 0x0 0x1000>; reg = <0x70 0x40005000 0x0 0x1000>;

View File

@@ -168,6 +168,23 @@ static bool errata_probe_ghostwrite(unsigned int stage,
return true; return true;
} }
static bool errata_probe_write_once(unsigned int stage,
unsigned long arch_id, unsigned long impid)
{
if (!IS_ENABLED(CONFIG_ERRATA_THEAD_WRITE_ONCE))
return false;
/* target-c9xx cores report arch_id and impid as 0 */
if (arch_id != 0 || impid != 0)
return false;
if (stage == RISCV_ALTERNATIVES_BOOT ||
stage == RISCV_ALTERNATIVES_MODULE)
return true;
return false;
}
static u32 thead_errata_probe(unsigned int stage, static u32 thead_errata_probe(unsigned int stage,
unsigned long archid, unsigned long impid) unsigned long archid, unsigned long impid)
{ {
@@ -183,6 +200,9 @@ static u32 thead_errata_probe(unsigned int stage,
errata_probe_ghostwrite(stage, archid, impid); errata_probe_ghostwrite(stage, archid, impid);
if (errata_probe_write_once(stage, archid, impid))
cpu_req_errata |= BIT(ERRATA_THEAD_WRITE_ONCE);
return cpu_req_errata; return cpu_req_errata;
} }

View File

@@ -10,24 +10,7 @@
#include <asm/insn-def.h> #include <asm/insn-def.h>
#include <asm/hwcap.h> #include <asm/hwcap.h>
#include <asm/vendorid_list.h> #include <asm/vendorid_list.h>
#include <asm/errata_list_vendors.h>
#ifdef CONFIG_ERRATA_ANDES
#define ERRATA_ANDES_NO_IOCP 0
#define ERRATA_ANDES_NUMBER 1
#endif
#ifdef CONFIG_ERRATA_SIFIVE
#define ERRATA_SIFIVE_CIP_453 0
#define ERRATA_SIFIVE_CIP_1200 1
#define ERRATA_SIFIVE_NUMBER 2
#endif
#ifdef CONFIG_ERRATA_THEAD
#define ERRATA_THEAD_MAE 0
#define ERRATA_THEAD_PMU 1
#define ERRATA_THEAD_GHOSTWRITE 2
#define ERRATA_THEAD_NUMBER 3
#endif
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__

View File

@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef ASM_ERRATA_LIST_VENDORS_H
#define ASM_ERRATA_LIST_VENDORS_H
#ifdef CONFIG_ERRATA_ANDES
#define ERRATA_ANDES_NO_IOCP 0
#define ERRATA_ANDES_NUMBER 1
#endif
#ifdef CONFIG_ERRATA_SIFIVE
#define ERRATA_SIFIVE_CIP_453 0
#define ERRATA_SIFIVE_CIP_1200 1
#define ERRATA_SIFIVE_NUMBER 2
#endif
#ifdef CONFIG_ERRATA_THEAD
#define ERRATA_THEAD_MAE 0
#define ERRATA_THEAD_PMU 1
#define ERRATA_THEAD_GHOSTWRITE 2
#define ERRATA_THEAD_WRITE_ONCE 3
#define ERRATA_THEAD_NUMBER 4
#endif
#endif /* ASM_ERRATA_LIST_VENDORS_H */

View File

@@ -28,6 +28,10 @@
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1) #define IO_SPACE_LIMIT (PCI_IO_SIZE - 1)
#define PCI_IOBASE ((void __iomem *)PCI_IO_START) #define PCI_IOBASE ((void __iomem *)PCI_IO_START)
#define ioremap_wc(addr, size) \
ioremap_prot((addr), (size), __pgprot(_PAGE_KERNEL_NC))
#endif /* CONFIG_MMU */ #endif /* CONFIG_MMU */
/* /*

View File

@@ -203,6 +203,7 @@ extern struct pt_alloc_ops pt_ops __meminitdata;
#define PAGE_TABLE __pgprot(_PAGE_TABLE) #define PAGE_TABLE __pgprot(_PAGE_TABLE)
#define _PAGE_KERNEL_NC ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_NOCACHE)
#define _PAGE_IOREMAP ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_IO) #define _PAGE_IOREMAP ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_IO)
#define PAGE_KERNEL_IO __pgprot(_PAGE_IOREMAP) #define PAGE_KERNEL_IO __pgprot(_PAGE_IOREMAP)

View File

@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
#include <linux/compiler_types.h>
#include <asm/alternative-macros.h>
#include <asm/vendorid_list.h>
#include <asm/errata_list_vendors.h>
#if defined(CONFIG_ERRATA_THEAD_WRITE_ONCE) && !defined(NO_ALTERNATIVE)
#define write_once_fence() \
do { \
asm volatile(ALTERNATIVE( \
"nop", \
"fence w, o", \
THEAD_VENDOR_ID, \
ERRATA_THEAD_WRITE_ONCE, \
CONFIG_ERRATA_THEAD_WRITE_ONCE) \
: : : "memory"); \
} while (0)
#define __WRITE_ONCE(x, val) \
do { \
*(volatile typeof(x) *)&(x) = (val); \
write_once_fence(); \
} while (0)
#endif /* defined(CONFIG_ERRATA_THEAD_WRITE_ONCE) && !defined(NO_ALTERNATIVE) */
#include <asm-generic/rwonce.h>
#endif /* __ASM_RWONCE_H */

View File

@@ -330,11 +330,14 @@ void __init setup_arch(char **cmdline_p)
/* Parse the ACPI tables for possible boot-time configuration */ /* Parse the ACPI tables for possible boot-time configuration */
acpi_boot_table_init(); acpi_boot_table_init();
if (acpi_disabled) {
#if IS_ENABLED(CONFIG_BUILTIN_DTB) #if IS_ENABLED(CONFIG_BUILTIN_DTB)
unflatten_and_copy_device_tree(); unflatten_and_copy_device_tree();
#else #else
unflatten_device_tree(); unflatten_device_tree();
#endif #endif
}
misc_mem_init(); misc_mem_init();
init_resources(); init_resources();

View File

@@ -10,7 +10,7 @@
static long riscv_sys_mmap(unsigned long addr, unsigned long len, static long riscv_sys_mmap(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags, unsigned long prot, unsigned long flags,
unsigned long fd, off_t offset, unsigned long fd, unsigned long offset,
unsigned long page_shift_offset) unsigned long page_shift_offset)
{ {
if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))

View File

@@ -307,6 +307,14 @@ pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res,
caching = res->bus.caching; caching = res->bus.caching;
} }
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
/* Downgrade cached mapping for non-snooping devices */
if (!bo->bdev->dma_coherent && caching == ttm_cached)
caching = ttm_write_combined;
#endif
return ttm_prot_from_caching(caching, tmp); return ttm_prot_from_caching(caching, tmp);
} }
EXPORT_SYMBOL(ttm_io_prot); EXPORT_SYMBOL(ttm_io_prot);

View File

@@ -246,6 +246,12 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func
list_add_tail(&bdev->device_list, &glob->device_list); list_add_tail(&bdev->device_list, &glob->device_list);
mutex_unlock(&ttm_global_mutex); mutex_unlock(&ttm_global_mutex);
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
bdev->dma_coherent = dev->dma_coherent;
#endif
return 0; return 0;
} }
EXPORT_SYMBOL(ttm_device_init); EXPORT_SYMBOL(ttm_device_init);

View File

@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
#endif /* CONFIG_UML */ #endif /* CONFIG_UML */
#endif /* __i386__ || __x86_64__ */ #endif /* __i386__ || __x86_64__ */
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \
defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \
defined(__riscv)
if (caching == ttm_write_combined) if (caching == ttm_write_combined)
tmp = pgprot_writecombine(tmp); tmp = pgprot_writecombine(tmp);
else else

View File

@@ -154,6 +154,14 @@ static void ttm_tt_init_fields(struct ttm_tt *ttm,
enum ttm_caching caching, enum ttm_caching caching,
unsigned long extra_pages) unsigned long extra_pages)
{ {
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
/* Downgrade cached mapping for non-snooping devices */
if (!bo->bdev->dma_coherent && caching == ttm_cached)
caching = ttm_write_combined;
#endif
ttm->num_pages = (PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT) + extra_pages; ttm->num_pages = (PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT) + extra_pages;
ttm->page_flags = page_flags; ttm->page_flags = page_flags;
ttm->dma_address = NULL; ttm->dma_address = NULL;

View File

@@ -242,7 +242,7 @@ static const struct xe_device_desc dg1_desc = {
.has_gsc_nvm = 1, .has_gsc_nvm = 1,
.has_heci_gscfi = 1, .has_heci_gscfi = 1,
.max_gt_per_tile = 1, .max_gt_per_tile = 1,
.require_force_probe = true, .require_force_probe = false,
}; };
static const u16 dg2_g10_ids[] = { INTEL_DG2_G10_IDS(NOP), INTEL_ATS_M150_IDS(NOP), 0 }; static const u16 dg2_g10_ids[] = { INTEL_DG2_G10_IDS(NOP), INTEL_ATS_M150_IDS(NOP), 0 };
@@ -266,7 +266,7 @@ static const struct xe_device_desc ats_m_desc = {
.pre_gmdid_media_ip = &media_ip_xehpm, .pre_gmdid_media_ip = &media_ip_xehpm,
.dma_mask_size = 46, .dma_mask_size = 46,
.max_gt_per_tile = 1, .max_gt_per_tile = 1,
.require_force_probe = true, .require_force_probe = false,
DG2_FEATURES, DG2_FEATURES,
.has_display = false, .has_display = false,
@@ -277,7 +277,7 @@ static const struct xe_device_desc dg2_desc = {
.pre_gmdid_media_ip = &media_ip_xehpm, .pre_gmdid_media_ip = &media_ip_xehpm,
.dma_mask_size = 46, .dma_mask_size = 46,
.max_gt_per_tile = 1, .max_gt_per_tile = 1,
.require_force_probe = true, .require_force_probe = false,
DG2_FEATURES, DG2_FEATURES,
.has_display = true, .has_display = true,
@@ -295,7 +295,7 @@ static const __maybe_unused struct xe_device_desc pvc_desc = {
.has_heci_gscfi = 1, .has_heci_gscfi = 1,
.max_gt_per_tile = 1, .max_gt_per_tile = 1,
.max_remote_tiles = 1, .max_remote_tiles = 1,
.require_force_probe = true, .require_force_probe = false,
.has_mbx_power_limits = false, .has_mbx_power_limits = false,
}; };

View File

@@ -30,6 +30,7 @@ struct sg204x_msi_chip_info {
* @doorbell_addr: see TRM, 10.1.32, GP_INTR0_SET * @doorbell_addr: see TRM, 10.1.32, GP_INTR0_SET
* @irq_first: First vectors number that MSIs starts * @irq_first: First vectors number that MSIs starts
* @num_irqs: Number of vectors for MSIs * @num_irqs: Number of vectors for MSIs
* @irq_type: IRQ type for MSIs
* @msi_map: mapping for allocated MSI vectors. * @msi_map: mapping for allocated MSI vectors.
* @msi_map_lock: Lock for msi_map * @msi_map_lock: Lock for msi_map
* @chip_info: chip specific infomations * @chip_info: chip specific infomations
@@ -41,6 +42,7 @@ struct sg204x_msi_chipdata {
u32 irq_first; u32 irq_first;
u32 num_irqs; u32 num_irqs;
unsigned int irq_type;
unsigned long *msi_map; unsigned long *msi_map;
struct mutex msi_map_lock; struct mutex msi_map_lock;
@@ -137,14 +139,14 @@ static int sg204x_msi_parent_domain_alloc(struct irq_domain *domain, unsigned in
fwspec.fwnode = domain->parent->fwnode; fwspec.fwnode = domain->parent->fwnode;
fwspec.param_count = 2; fwspec.param_count = 2;
fwspec.param[0] = data->irq_first + hwirq; fwspec.param[0] = data->irq_first + hwirq;
fwspec.param[1] = IRQ_TYPE_EDGE_RISING; fwspec.param[1] = data->irq_type;
ret = irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec); ret = irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec);
if (ret) if (ret)
return ret; return ret;
d = irq_domain_get_irq_data(domain->parent, virq); d = irq_domain_get_irq_data(domain->parent, virq);
return d->chip->irq_set_type(d, IRQ_TYPE_EDGE_RISING); return d->chip->irq_set_type(d, data->irq_type);
} }
static int sg204x_msi_middle_domain_alloc(struct irq_domain *domain, unsigned int virq, static int sg204x_msi_middle_domain_alloc(struct irq_domain *domain, unsigned int virq,
@@ -212,6 +214,7 @@ static const struct msi_parent_ops sg2042_msi_parent_ops = {
MSI_FLAG_PCI_MSI_STARTUP_PARENT) MSI_FLAG_PCI_MSI_STARTUP_PARENT)
#define SG2044_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \ #define SG2044_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
MSI_FLAG_MULTI_PCI_MSI | \
MSI_FLAG_PCI_MSIX) MSI_FLAG_PCI_MSIX)
static const struct msi_parent_ops sg2044_msi_parent_ops = { static const struct msi_parent_ops sg2044_msi_parent_ops = {
@@ -297,6 +300,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
} }
data->irq_first = (u32)args.args[0]; data->irq_first = (u32)args.args[0];
data->irq_type = (unsigned int)args.args[1];
data->num_irqs = (u32)args.args[args.nargs - 1]; data->num_irqs = (u32)args.args[args.nargs - 1];
mutex_init(&data->msi_map_lock); mutex_init(&data->msi_map_lock);

View File

@@ -179,12 +179,14 @@ static int plic_set_affinity(struct irq_data *d,
if (cpu >= nr_cpu_ids) if (cpu >= nr_cpu_ids)
return -EINVAL; return -EINVAL;
plic_irq_disable(d); /* Invalidate the original routing entry */
plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0);
irq_data_update_effective_affinity(d, cpumask_of(cpu)); irq_data_update_effective_affinity(d, cpumask_of(cpu));
/* Setting the new routing entry if irq is enabled */
if (!irqd_irq_disabled(d)) if (!irqd_irq_disabled(d))
plic_irq_enable(d); plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1);
return IRQ_SET_MASK_OK_DONE; return IRQ_SET_MASK_OK_DONE;
} }

View File

@@ -7,11 +7,16 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/property.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include "stmmac_platform.h" #include "stmmac_platform.h"
struct sophgo_dwmac_data {
bool has_internal_rx_delay;
};
static int sophgo_sg2044_dwmac_init(struct platform_device *pdev, static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat, struct plat_stmmacenet_data *plat_dat,
struct stmmac_resources *stmmac_res) struct stmmac_resources *stmmac_res)
@@ -32,6 +37,7 @@ static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
static int sophgo_dwmac_probe(struct platform_device *pdev) static int sophgo_dwmac_probe(struct platform_device *pdev)
{ {
struct plat_stmmacenet_data *plat_dat; struct plat_stmmacenet_data *plat_dat;
const struct sophgo_dwmac_data *data;
struct stmmac_resources stmmac_res; struct stmmac_resources stmmac_res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
@@ -50,11 +56,23 @@ static int sophgo_dwmac_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
data = device_get_match_data(&pdev->dev);
if (data && data->has_internal_rx_delay) {
plat_dat->phy_interface = phy_fix_phy_mode_for_mac_delays(plat_dat->phy_interface,
false, true);
if (plat_dat->phy_interface == PHY_INTERFACE_MODE_NA)
return -EINVAL;
}
return stmmac_dvr_probe(dev, plat_dat, &stmmac_res); return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
} }
static const struct sophgo_dwmac_data sg2042_dwmac_data = {
.has_internal_rx_delay = true,
};
static const struct of_device_id sophgo_dwmac_match[] = { static const struct of_device_id sophgo_dwmac_match[] = {
{ .compatible = "sophgo,sg2042-dwmac" }, { .compatible = "sophgo,sg2042-dwmac", .data = &sg2042_dwmac_data },
{ .compatible = "sophgo,sg2044-dwmac" }, { .compatible = "sophgo,sg2044-dwmac" },
{ /* sentinel */ } { /* sentinel */ }
}; };

View File

@@ -101,6 +101,49 @@ const char *phy_rate_matching_to_str(int rate_matching)
} }
EXPORT_SYMBOL_GPL(phy_rate_matching_to_str); EXPORT_SYMBOL_GPL(phy_rate_matching_to_str);
/**
* phy_fix_phy_mode_for_mac_delays - Convenience function for fixing PHY
* mode based on whether mac adds internal delay
*
* @interface: The current interface mode of the port
* @mac_txid: True if the mac adds internal tx delay
* @mac_rxid: True if the mac adds internal rx delay
*
* Return fixed PHY mode, or PHY_INTERFACE_MODE_NA if the interface can
* not apply the internal delay
*/
phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
bool mac_txid, bool mac_rxid)
{
if (!phy_interface_mode_is_rgmii(interface))
return interface;
if (mac_txid && mac_rxid) {
if (interface == PHY_INTERFACE_MODE_RGMII_ID)
return PHY_INTERFACE_MODE_RGMII;
return PHY_INTERFACE_MODE_NA;
}
if (mac_txid) {
if (interface == PHY_INTERFACE_MODE_RGMII_ID)
return PHY_INTERFACE_MODE_RGMII_RXID;
if (interface == PHY_INTERFACE_MODE_RGMII_TXID)
return PHY_INTERFACE_MODE_RGMII;
return PHY_INTERFACE_MODE_NA;
}
if (mac_rxid) {
if (interface == PHY_INTERFACE_MODE_RGMII_ID)
return PHY_INTERFACE_MODE_RGMII_TXID;
if (interface == PHY_INTERFACE_MODE_RGMII_RXID)
return PHY_INTERFACE_MODE_RGMII;
return PHY_INTERFACE_MODE_NA;
}
return interface;
}
EXPORT_SYMBOL_GPL(phy_fix_phy_mode_for_mac_delays);
/** /**
* phy_interface_num_ports - Return the number of links that can be carried by * phy_interface_num_ports - Return the number of links that can be carried by
* a given MAC-PHY physical link. Returns 0 if this is * a given MAC-PHY physical link. Returns 0 if this is

View File

@@ -335,6 +335,18 @@ config NVMEM_SNVS_LPGPR
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called nvmem-snvs-lpgpr. will be called nvmem-snvs-lpgpr.
config NVMEM_SOPHGO_EFUSE
tristate "Sophgo eFuse support"
depends on ARCH_SOPHGO || COMPILE_TEST
default ARCH_SOPHGO
help
Say y here to enable support for reading eFuses on Sophgo SoCs
such as the CV1800B. These are e.g. used to store factory programmed
calibration data required for the builtin ethernet PHY.
This driver can also be built as a module. If so, the module will
be called nvmem-sophgo-efuse.
config NVMEM_SPMI_SDAM config NVMEM_SPMI_SDAM
tristate "SPMI SDAM Support" tristate "SPMI SDAM Support"
depends on SPMI depends on SPMI

View File

@@ -68,6 +68,8 @@ obj-$(CONFIG_NVMEM_SC27XX_EFUSE) += nvmem-sc27xx-efuse.o
nvmem-sc27xx-efuse-y := sc27xx-efuse.o nvmem-sc27xx-efuse-y := sc27xx-efuse.o
obj-$(CONFIG_NVMEM_SNVS_LPGPR) += nvmem_snvs_lpgpr.o obj-$(CONFIG_NVMEM_SNVS_LPGPR) += nvmem_snvs_lpgpr.o
nvmem_snvs_lpgpr-y := snvs_lpgpr.o nvmem_snvs_lpgpr-y := snvs_lpgpr.o
obj-$(CONFIG_NVMEM_SOPHGO_EFUSE) += nvmem-sophgo-efuse.o
nvmem-sophgo-efuse-y := sophgo-efuse.o
obj-$(CONFIG_NVMEM_SPMI_SDAM) += nvmem_qcom-spmi-sdam.o obj-$(CONFIG_NVMEM_SPMI_SDAM) += nvmem_qcom-spmi-sdam.o
nvmem_qcom-spmi-sdam-y += qcom-spmi-sdam.o nvmem_qcom-spmi-sdam-y += qcom-spmi-sdam.o
obj-$(CONFIG_NVMEM_SPRD_EFUSE) += nvmem_sprd_efuse.o obj-$(CONFIG_NVMEM_SPRD_EFUSE) += nvmem_sprd_efuse.o

View File

@@ -0,0 +1,176 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Sophgo SoC eFuse driver
*/
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/cleanup.h>
#include <linux/iopoll.h>
#include <linux/math.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/nvmem-provider.h>
#include <linux/platform_device.h>
#define SG2044_EFUSE_CONTENT_SIZE 0x400
#define SG2044_EFUSE_MD 0x000
#define SG2044_EFUSE_ADR 0x004
#define SG2044_EFUSE_RD_DATA 0x00c
#define SG2044_EFUSE_MODE GENMASK(1, 0)
#define SG2044_EFUSE_MODE_READ 2
#define SG2044_EFUSE_BOOT_DONE BIT(7)
#define SG2044_BOOT_TIMEOUT 10000
#define SG2044_EFUSE_ADR_ADDR GENMASK(7, 0)
#define SG2044_EFUSE_ALIGN 4
struct sophgo_efuses {
void __iomem *base;
struct clk_bulk_data *clks;
int num_clks;
struct mutex mutex;
};
static int sg2044_efuse_wait_mode(struct sophgo_efuses *efuse)
{
u32 value;
return readl_poll_timeout(efuse->base + SG2044_EFUSE_MD, value,
FIELD_GET(SG2044_EFUSE_MODE, value) == 0,
1, SG2044_BOOT_TIMEOUT);
}
static int sg2044_efuse_set_mode(struct sophgo_efuses *efuse, int mode)
{
u32 val = readl(efuse->base + SG2044_EFUSE_MD);
val &= ~SG2044_EFUSE_MODE;
val |= FIELD_PREP(SG2044_EFUSE_MODE, mode);
writel(val, efuse->base + SG2044_EFUSE_MD);
return sg2044_efuse_wait_mode(efuse);
}
static u32 sg2044_efuses_read_strip(struct sophgo_efuses *efuse,
unsigned int offset, u32 *strip)
{
u32 val = FIELD_PREP(SG2044_EFUSE_ADR_ADDR, offset);
int ret;
guard(mutex)(&efuse->mutex);
writel(val, efuse->base + SG2044_EFUSE_ADR);
ret = sg2044_efuse_set_mode(efuse, SG2044_EFUSE_MODE_READ);
if (ret < 0)
return ret;
*strip = readl(efuse->base + SG2044_EFUSE_RD_DATA);
return 0;
}
static int sg2044_efuses_read(void *context, unsigned int offset, void *val,
size_t bytes)
{
struct sophgo_efuses *efuse = context;
unsigned int start, start_offset, end, i;
u32 value;
u8 *buf;
int ret;
start = rounddown(offset, SG2044_EFUSE_ALIGN);
end = roundup(offset + bytes, SG2044_EFUSE_ALIGN);
start_offset = offset - start;
start /= SG2044_EFUSE_ALIGN;
end /= SG2044_EFUSE_ALIGN;
ret = readl_poll_timeout(efuse->base + SG2044_EFUSE_MD, value,
(value & SG2044_EFUSE_BOOT_DONE),
1, SG2044_BOOT_TIMEOUT);
if (ret < 0)
return ret;
buf = kzalloc(end - start, GFP_KERNEL);
if (!buf)
return -ENOMEM;
for (i = start; i < end; i++) {
ret = sg2044_efuses_read_strip(efuse, i, &value);
if (ret)
goto failed;
memcpy(&buf[(i - start) * 4], &value, SG2044_EFUSE_ALIGN);
}
memcpy(val, buf + start_offset, bytes);
failed:
kfree(buf);
return ret;
}
static int sophgo_efuses_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct sophgo_efuses *efuse;
struct nvmem_config config = {
.dev = &pdev->dev,
.add_legacy_fixed_of_cells = true,
.read_only = true,
.reg_read = sg2044_efuses_read,
.stride = 1,
.word_size = 1,
.name = "sophgo-efuse",
.id = NVMEM_DEVID_AUTO,
.root_only = true,
};
efuse = devm_kzalloc(dev, sizeof(*efuse), GFP_KERNEL);
if (!efuse)
return -ENOMEM;
efuse->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(efuse->base))
return PTR_ERR(efuse->base);
efuse->num_clks = devm_clk_bulk_get_all_enabled(&pdev->dev, &efuse->clks);
if (efuse->num_clks < 0)
return dev_err_probe(dev, efuse->num_clks, "failed to get clocks\n");
config.priv = efuse;
config.size = SG2044_EFUSE_CONTENT_SIZE;
return PTR_ERR_OR_ZERO(devm_nvmem_register(config.dev, &config));
}
static const struct of_device_id sophgo_efuses_of_match[] = {
{ .compatible = "sophgo,sg2044-efuse", },
{}
};
MODULE_DEVICE_TABLE(of, sophgo_efuses_of_match);
static struct platform_driver sophgo_efuses_driver = {
.driver = {
.name = "sophgo_efuse",
.of_match_table = sophgo_efuses_of_match,
},
.probe = sophgo_efuses_probe,
};
module_platform_driver(sophgo_efuses_driver);
MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
MODULE_DESCRIPTION("Sophgo efuse driver");
MODULE_LICENSE("GPL");

View File

@@ -42,6 +42,15 @@ config PCIE_CADENCE_PLAT_EP
endpoint mode. This PCIe controller may be embedded into many endpoint mode. This PCIe controller may be embedded into many
different vendors SoCs. different vendors SoCs.
config PCIE_SG2042_HOST
tristate "Sophgo SG2042 PCIe controller (host mode)"
depends on OF && (ARCH_SOPHGO || COMPILE_TEST)
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 config PCI_J721E
tristate tristate
select PCIE_CADENCE_HOST if PCI_J721E_HOST != n select PCIE_CADENCE_HOST if PCI_J721E_HOST != n
@@ -67,4 +76,5 @@ config PCI_J721E_EP
Say Y here if you want to support the TI J721E PCIe platform Say Y here if you want to support the TI J721E PCIe platform
controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe
core. core.
endmenu endmenu

View File

@@ -4,3 +4,4 @@ obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o
obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o
obj-$(CONFIG_PCI_J721E) += pci-j721e.o obj-$(CONFIG_PCI_J721E) += pci-j721e.o
obj-$(CONFIG_PCIE_SG2042_HOST) += pcie-sg2042.o

View File

@@ -531,7 +531,7 @@ static int cdns_pcie_host_init_address_translation(struct 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_PCI_ADDR1(0), addr1);
cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(0), desc1); cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(0), desc1);
if (pcie->ops->cpu_addr_fixup) if (pcie->ops && pcie->ops->cpu_addr_fixup)
cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr); cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr);
addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(12) | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(12) |

View File

@@ -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); cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1);
/* Set the CPU address */ /* Set the CPU address */
if (pcie->ops->cpu_addr_fixup) if (pcie->ops && pcie->ops->cpu_addr_fixup)
cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr); cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr);
addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) |
@@ -123,7 +123,7 @@ void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie,
} }
/* Set the CPU address */ /* Set the CPU address */
if (pcie->ops->cpu_addr_fixup) if (pcie->ops && pcie->ops->cpu_addr_fixup)
cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr); cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr);
addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(17) | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(17) |

View File

@@ -468,7 +468,7 @@ static inline u32 cdns_pcie_ep_fn_readl(struct cdns_pcie *pcie, u8 fn, u32 reg)
static inline int cdns_pcie_start_link(struct cdns_pcie *pcie) 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); return pcie->ops->start_link(pcie);
return 0; return 0;
@@ -476,13 +476,13 @@ static inline int cdns_pcie_start_link(struct cdns_pcie *pcie)
static inline void cdns_pcie_stop_link(struct cdns_pcie *pcie) 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); pcie->ops->stop_link(pcie);
} }
static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) 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); return pcie->ops->link_up(pcie);
return true; return true;

View File

@@ -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 <unicorn_wang@outlook.com>
*/
#include <linux/mod_devicetable.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include "pcie-cadence.h"
/*
* SG2042 only supports 4-byte aligned access, so for the rootbus (i.e. to
* read/write the Root Port itself, read32/write32 is required. For
* non-rootbus (i.e. to read/write the PCIe peripheral registers, supports
* 1/2/4 byte aligned access, so directly using read/write should be fine.
*/
static struct pci_ops sg2042_pcie_root_ops = {
.map_bus = cdns_pci_map_bus,
.read = pci_generic_config_read32,
.write = pci_generic_config_write32,
};
static struct pci_ops sg2042_pcie_child_ops = {
.map_bus = cdns_pci_map_bus,
.read = pci_generic_config_read,
.write = pci_generic_config_write,
};
static int sg2042_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct pci_host_bridge *bridge;
struct cdns_pcie *pcie;
struct cdns_pcie_rc *rc;
int ret;
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rc));
if (!bridge)
return dev_err_probe(dev, -ENOMEM, "Failed to alloc host bridge!\n");
bridge->ops = &sg2042_pcie_root_ops;
bridge->child_ops = &sg2042_pcie_child_ops;
rc = pci_host_bridge_priv(bridge);
pcie = &rc->pcie;
pcie->dev = dev;
platform_set_drvdata(pdev, pcie);
pm_runtime_set_active(dev);
pm_runtime_no_callbacks(dev);
devm_pm_runtime_enable(dev);
ret = cdns_pcie_init_phy(dev, pcie);
if (ret)
return dev_err_probe(dev, ret, "Failed to init phy!\n");
ret = cdns_pcie_host_setup(rc);
if (ret) {
dev_err_probe(dev, ret, "Failed to setup host!\n");
cdns_pcie_disable_phy(pcie);
return ret;
}
return 0;
}
static void sg2042_pcie_remove(struct platform_device *pdev)
{
struct cdns_pcie *pcie = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
struct cdns_pcie_rc *rc;
rc = container_of(pcie, struct cdns_pcie_rc, pcie);
cdns_pcie_host_disable(rc);
cdns_pcie_disable_phy(pcie);
pm_runtime_disable(dev);
}
static int sg2042_pcie_suspend_noirq(struct device *dev)
{
struct cdns_pcie *pcie = dev_get_drvdata(dev);
cdns_pcie_disable_phy(pcie);
return 0;
}
static int sg2042_pcie_resume_noirq(struct device *dev)
{
struct cdns_pcie *pcie = dev_get_drvdata(dev);
int ret;
ret = cdns_pcie_enable_phy(pcie);
if (ret) {
dev_err(dev, "failed to enable PHY\n");
return ret;
}
return 0;
}
static DEFINE_NOIRQ_DEV_PM_OPS(sg2042_pcie_pm_ops,
sg2042_pcie_suspend_noirq,
sg2042_pcie_resume_noirq);
static const struct of_device_id sg2042_pcie_of_match[] = {
{ .compatible = "sophgo,sg2042-pcie-host" },
{},
};
MODULE_DEVICE_TABLE(of, sg2042_pcie_of_match);
static struct platform_driver sg2042_pcie_driver = {
.driver = {
.name = "sg2042-pcie",
.of_match_table = sg2042_pcie_of_match,
.pm = pm_sleep_ptr(&sg2042_pcie_pm_ops),
},
.probe = sg2042_pcie_probe,
.remove = sg2042_pcie_remove,
};
module_platform_driver(sg2042_pcie_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("PCIe controller driver for SG2042 SoCs");
MODULE_AUTHOR("Chen Wang <unicorn_wang@outlook.com>");

View File

@@ -6338,3 +6338,26 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9750, pci_mask_replay_timer_timeout);
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_GLI, 0x9755, pci_mask_replay_timer_timeout);
#endif #endif
/*
* PCI switches integrated into Intel Arc GPUs have BAR0 that prevents
* resizing the BARs of the GPU device due to that bridge BAR0 pinning the
* bridge window it's under in place. Nothing in pcieport requires that
* BAR0.
*
* Release and disable BAR0 permanently by clearing its flags to prevent
* anything from assigning it again.
*/
static void pci_release_bar0(struct pci_dev *pdev)
{
struct resource *res = pci_resource_n(pdev, 0);
if (!res->parent)
return;
pci_release_resource(pdev, 0);
res->flags = 0;
}
DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_INTEL, 0x4fa0, pci_release_bar0);
DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_INTEL, 0x4fa1, pci_release_bar0);
DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_INTEL, 0xe2ff, pci_release_bar0);

View File

@@ -50,10 +50,12 @@
__READ_ONCE(x); \ __READ_ONCE(x); \
}) })
#ifndef __WRITE_ONCE
#define __WRITE_ONCE(x, val) \ #define __WRITE_ONCE(x, val) \
do { \ do { \
*(volatile typeof(x) *)&(x) = (val); \ *(volatile typeof(x) *)&(x) = (val); \
} while (0) } while (0)
#endif
#define WRITE_ONCE(x, val) \ #define WRITE_ONCE(x, val) \
do { \ do { \

View File

@@ -47,7 +47,8 @@ enum ttm_caching {
/** /**
* @ttm_cached: Fully cached like normal system memory, requires that * @ttm_cached: Fully cached like normal system memory, requires that
* devices snoop the CPU cache on accesses. * devices snoop the CPU cache on accesses. Downgraded to
* ttm_write_combined when the snooping capaiblity is missing.
*/ */
ttm_cached ttm_cached
}; };

View File

@@ -225,6 +225,15 @@ struct ttm_device {
*/ */
const struct ttm_device_funcs *funcs; const struct ttm_device_funcs *funcs;
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
/**
* @dma_coherent: if the device backed is dma-coherent.
*/
bool dma_coherent;
#endif
/** /**
* @sysman: Resource manager for the system domain. * @sysman: Resource manager for the system domain.
* Access via ttm_manager_type. * Access via ttm_manager_type.

View File

@@ -1795,6 +1795,9 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
return phydev->is_pseudo_fixed_link; return phydev->is_pseudo_fixed_link;
} }
phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
bool mac_txid, bool mac_rxid);
int phy_save_page(struct phy_device *phydev); int phy_save_page(struct phy_device *phydev);
int phy_select_page(struct phy_device *phydev, int page); int phy_select_page(struct phy_device *phydev, int page);
int phy_restore_page(struct phy_device *phydev, int oldpage, int ret); int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);

View File

@@ -20,5 +20,6 @@
0x489-0x8000000000000008-0x[[:xdigit:]]+,v1,sifive/p550,core 0x489-0x8000000000000008-0x[[:xdigit:]]+,v1,sifive/p550,core
0x489-0x8000000000000[1-6]08-0x[9b][[:xdigit:]]+,v1,sifive/p650,core 0x489-0x8000000000000[1-6]08-0x[9b][[:xdigit:]]+,v1,sifive/p650,core
0x5b7-0x0-0x0,v1,thead/c900-legacy,core 0x5b7-0x0-0x0,v1,thead/c900-legacy,core
0x5b7-0x80000000090c0d00-0x2047000,v1,thead/c900-legacy,core
0x67e-0x80000000db0000[89]0-0x[[:xdigit:]]+,v1,starfive/dubhe-80,core 0x67e-0x80000000db0000[89]0-0x[[:xdigit:]]+,v1,starfive/dubhe-80,core
0x31e-0x8000000000008a45-0x[[:xdigit:]]+,v1,andes/ax45,core 0x31e-0x8000000000008a45-0x[[:xdigit:]]+,v1,andes/ax45,core
1 # Format:
20 0x489-0x8000000000000008-0x[[:xdigit:]]+,v1,sifive/p550,core
21 0x489-0x8000000000000[1-6]08-0x[9b][[:xdigit:]]+,v1,sifive/p650,core
22 0x5b7-0x0-0x0,v1,thead/c900-legacy,core
23 0x5b7-0x80000000090c0d00-0x2047000,v1,thead/c900-legacy,core
24 0x67e-0x80000000db0000[89]0-0x[[:xdigit:]]+,v1,starfive/dubhe-80,core
25 0x31e-0x8000000000008a45-0x[[:xdigit:]]+,v1,andes/ax45,core