Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion .github/workflows/dt-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ jobs:

- name: Install the tools
run: |
sudo apt-get update -q
# Avoid the hosted runner's Azure mirror after repeated DNS failures.
# Keep signed Ubuntu archive/security suites and fail on update errors.
if [ -f /etc/apt/apt-mirrors.txt ]; then
printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \
sudo tee /etc/apt/apt-mirrors.txt >/dev/null
fi
sudo apt-get update -q -o APT::Update::Error-Mode=any
sudo apt-get install -y -q flex bison bc libyaml-dev clang-$CLANG_VERSION lld-$CLANG_VERSION llvm-$CLANG_VERSION swig device-tree-compiler
echo "/usr/lib/llvm-$CLANG_VERSION/bin" >> "$GITHUB_PATH"
pip install --quiet dtschema yamllint pylibfdt
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/host-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ jobs:
command -v fdtget >/dev/null || need="$need device-tree-compiler"
dpkg -s "libclang-rt-$CLANG_VERSION-dev" >/dev/null 2>&1 || need="$need libclang-rt-$CLANG_VERSION-dev"
if [ -n "$need" ]; then
sudo apt-get update -q
# Avoid the hosted runner's Azure mirror after repeated DNS failures.
# Keep signed Ubuntu archive/security suites and fail on update errors.
if [ -f /etc/apt/apt-mirrors.txt ]; then
printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \
sudo tee /etc/apt/apt-mirrors.txt >/dev/null
fi
sudo apt-get update -q -o APT::Update::Error-Mode=any
sudo apt-get install -y -q $need
fi
# The tests call clang, ld.lld, cc and gcc by name.
Expand Down
33 changes: 33 additions & 0 deletions Documentation/devicetree/bindings/pci/apple,pcie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ properties:
- items:
- const: apple,t8112-pciec
- const: apple,t8103-pciec
- items:
- const: apple,t8122-pciec
- const: apple,t8103-pciec
- const: apple,t6000-pciec
- const: apple,t6050-pciec
- items:
Expand Down Expand Up @@ -522,6 +525,15 @@ allOf:
- const: debug
- const: ltssm
- enum: [intr2axi, oe-fabric]
- items:
- const: config
- const: rc
- const: port0
- const: fabric
- const: debug
- const: ltssm
- const: oe-fabric
- const: intr2axi
- items:
- const: config
- const: rc
Expand All @@ -547,6 +559,27 @@ allOf:
minItems: 3
maxItems: 3
allOf:
- if:
properties:
compatible:
items:
- const: apple,t8122-pciec
- const: apple,t8103-pciec
then:
properties:
reg:
minItems: 8
maxItems: 8
reg-names:
items:
- const: config
- const: rc
- const: port0
- const: fabric
- const: debug
- const: ltssm
- const: oe-fabric
- const: intr2axi
- if:
properties:
compatible:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ properties:
PCIe adapter configuration space of the USB4 router. Present where
the root complex exposes the adapter separately, so that the tunnel
can be configured before a PCIe-C link is brought up.
- description: MxWrap co-processor control registers, on T8132 and T6050
- description: MxWrap co-processor control registers, on T6030, T8122, T8132 and T6050
- description: PCIe router AP firmware registers, on T6050

reg-names:
Expand Down Expand Up @@ -108,6 +108,14 @@ properties:
apple,pcie-tunnel is present, the domain after them powers its PCIe-C
controller and is enabled only after the USB4 PCIe tunnel is active.

post-init-providers:
$ref: /schemas/types.yaml#/definitions/phandle-array
maxItems: 4
description:
Power-domain suppliers managed explicitly by the router, rather than
required before it can probe, to break their initialization dependency
cycle. On J613 these are the four power domains listed above.

thunderbolt-switch:
type: boolean
description:
Expand Down
13 changes: 13 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-j613.dts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
/dts-v1/;

#include "t8122.dtsi"
#include "t8122-usb4.dtsi"
#include "t8122-j613-j615.dtsi"
#include <dt-bindings/thermal/thermal.h>

/ {
compatible = "apple,j613", "apple,t8122", "apple,arm-platform";
model = "Apple MacBook Air (13-inch, M3, 2024)";

aliases {
usb4-0-pcie = &usb4_0_pcie;
usb4-0-pcie-port = &usb4_0_pcie_port;
usb4-1-pcie = &usb4_1_pcie;
usb4-1-pcie-port = &usb4_1_pcie_port;
usb4-0-pcie-adapter = &usb4_0_acio;
usb4-1-pcie-adapter = &usb4_1_acio;
};

/*
* Fanless: every die sensor throttles both clusters, E weighted 3:1
* and capped at state 3. Trips as on the J700; sustainable-power from
Expand Down Expand Up @@ -432,3 +442,6 @@
/* Per-device factory data from this Mac's own iBoot system container. */
firmware-name = "apple/mesacal-j613.bin";
};

/* Older Stage 2 loaders prune the shared ATC0 suppliers of this unused node. */
/delete-node/ &usb_otg0;
202 changes: 202 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-usb4.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/* J613 ADT PCIe-C windows; DP tunnelling deliberately omitted. */
/ {
usb4_0_pcie_tunnel: usb4-pcie-tunnel-0 {
#address-cells = <2>;
#size-cells = <2>;
ranges;
nonposted-mmio;
/* Preserve the SoC DMA window after moving the virtual container. */
dma-ranges = <0 0 0 0 0xffffffff 0xffffc000>;

usb4_0_pcie_dart: iommu@721008000 {
compatible = "apple,t8122-dart", "apple,t8110-dart";
reg = <0x7 0x21008000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 962 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
/* No bootloader fills this one; the tunnel's cold init needs it. */
apple,tunable =
<0x20c 0x800001b7 0x800001b7>,
<0x220 0xf0f0f 0xf0f0f>,
<0x224 0xffffff 0x80808>,
<0x300 0x1f31 0x1>,
<0x308 0x3ffffffc 0x10000000>,
<0x310 0x3ffffffc 0x3ffffffc>,
<0x318 0x1f31 0x1>,
<0x320 0x3ffffffc 0x1f00000>,
<0x328 0x3ffffffc 0x1f0bffc>;
};

usb4_0_pcie: pcie@730000000 {
compatible = "apple,t8122-pciec", "apple,t8103-pciec";
device_type = "pci";
reg = <0x7 0x30000000 0x0 0x10000000>,
<0x7 0x20000000 0x0 0x4000>,
<0x7 0x21000000 0x0 0x8000>,
<0x7 0x20004000 0x0 0x4000>,
<0x7 0x20200000 0x0 0x4000>,
<0x7 0x21010000 0x0 0x4000>,
<0x7 0x20008000 0x0 0x4000>,
<0x7 0x2100c000 0x0 0x4000>;
reg-names = "config", "rc", "port0", "fabric",
"debug", "ltssm", "oe-fabric", "intr2axi";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 961 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_atc0_cio_pcie>;
resets = <&ps_atc0_pcie>;
apple,pciec-kernel-init;
/*
* m1n1 fills the rc, fabric and debug tunables through the
* usb4-0-pcie alias, but not this one.
*/
apple,tunable-oe-fabric =
<0x4 0x70007 0x40004>,
<0x8 0x1 0x1>,
<0xc 0x1 0x1>,
<0x10 0x801f 0x4>,
<0x18 0x801f 0x4>,
<0x20 0x801f 0x4>;
apple,msi-vector-base = <32>;
msi-controller;
msi-parent = <&usb4_0_pcie>;
msi-ranges = <&aic AIC_IRQ 1107 IRQ_TYPE_EDGE_RISING 32>;
iommu-map = <0x0 &usb4_0_pcie_dart 0x0 0x40>;
iommu-map-mask = <0x3f>;
bus-range = <0x0 0x7f>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x43000000 0x8 0x0
0x8 0x0 0x2 0x0>,
<0x02000000 0x0 0x100000
0xa 0x100000 0x0 0x3ff00000>,
<0x42000000 0x0 0x40000000
0xa 0x40000000 0x0 0x40000000>;

usb4_0_pcie_port: pci@0,0 {
device_type = "pci";
reg = <0x0 0x0 0x0 0x0 0x0>;
external-facing;
/* apple,tunable is filled by the bootloader */
#address-cells = <3>;
#size-cells = <2>;
ranges;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-map-mask = <0 0 0 7>;
interrupt-map = <0 0 0 1 &usb4_0_pcie_port 0 0 0 0>,
<0 0 0 2 &usb4_0_pcie_port 0 0 0 1>,
<0 0 0 3 &usb4_0_pcie_port 0 0 0 2>,
<0 0 0 4 &usb4_0_pcie_port 0 0 0 3>;
};
};
};
};

&usb4_0_acio {
power-domains = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>,
<&ps_atc0_cio_usb>, <&ps_atc0_pcie>;
post-init-providers = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>,
<&ps_atc0_cio_usb>, <&ps_atc0_pcie>;
apple,pcie-tunnel = <&usb4_0_pcie_tunnel>;
};
/ {
usb4_1_pcie_tunnel: usb4-pcie-tunnel-1 {
#address-cells = <2>;
#size-cells = <2>;
ranges;
nonposted-mmio;
/* Preserve the SoC DMA window after moving the virtual container. */
dma-ranges = <0 0 0 0 0xffffffff 0xffffc000>;

usb4_1_pcie_dart: iommu@b21008000 {
compatible = "apple,t8122-dart", "apple,t8110-dart";
reg = <0xb 0x21008000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1020 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
/* No bootloader fills this one; the tunnel's cold init needs it. */
apple,tunable =
<0x20c 0x800001b7 0x800001b7>,
<0x220 0xf0f0f 0xf0f0f>,
<0x224 0xffffff 0x80808>,
<0x300 0x1f31 0x1>,
<0x308 0x3ffffffc 0x10000000>,
<0x310 0x3ffffffc 0x3ffffffc>,
<0x318 0x1f31 0x1>,
<0x320 0x3ffffffc 0x1f00000>,
<0x328 0x3ffffffc 0x1f0bffc>;
};

usb4_1_pcie: pcie@b30000000 {
compatible = "apple,t8122-pciec", "apple,t8103-pciec";
device_type = "pci";
reg = <0xb 0x30000000 0x0 0x10000000>,
<0xb 0x20000000 0x0 0x4000>,
<0xb 0x21000000 0x0 0x8000>,
<0xb 0x20004000 0x0 0x4000>,
<0xb 0x20200000 0x0 0x4000>,
<0xb 0x21010000 0x0 0x4000>,
<0xb 0x20008000 0x0 0x4000>,
<0xb 0x2100c000 0x0 0x4000>;
reg-names = "config", "rc", "port0", "fabric",
"debug", "ltssm", "oe-fabric", "intr2axi";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1019 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_atc1_cio_pcie>;
resets = <&ps_atc1_pcie>;
apple,pciec-kernel-init;
/*
* m1n1 fills the rc, fabric and debug tunables through the
* usb4-1-pcie alias, but not this one.
*/
apple,tunable-oe-fabric =
<0x4 0x70007 0x40004>,
<0xc 0x1 0x1>,
<0xc 0x1 0x1>,
<0x10 0x801f 0x4>,
<0x18 0x801f 0x4>,
<0x20 0x801f 0x4>;
apple,msi-vector-base = <64>;
msi-controller;
msi-parent = <&usb4_1_pcie>;
msi-ranges = <&aic AIC_IRQ 1139 IRQ_TYPE_EDGE_RISING 32>;
iommu-map = <0x0 &usb4_1_pcie_dart 0x0 0x40>;
iommu-map-mask = <0x3f>;
bus-range = <0x0 0x7f>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x43000000 0xc 0x0
0xc 0x0 0x2 0x0>,
<0x02000000 0x0 0x100000
0xe 0x100000 0x0 0x3ff00000>,
<0x42000000 0x0 0x40000000
0xe 0x40000000 0x0 0x40000000>;

usb4_1_pcie_port: pci@0,0 {
device_type = "pci";
reg = <0x0 0x0 0x0 0x0 0x0>;
external-facing;
/* apple,tunable is filled by the bootloader */
#address-cells = <3>;
#size-cells = <2>;
ranges;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-map-mask = <0 0 0 7>;
interrupt-map = <0 0 0 1 &usb4_1_pcie_port 0 0 0 0>,
<0 0 0 2 &usb4_1_pcie_port 0 0 0 1>,
<0 0 0 3 &usb4_1_pcie_port 0 0 0 2>,
<0 0 0 4 &usb4_1_pcie_port 0 0 0 3>;
};
};
};
};

&usb4_1_acio {
power-domains = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>,
<&ps_atc1_cio_usb>, <&ps_atc1_pcie>;
post-init-providers = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>,
<&ps_atc1_cio_usb>, <&ps_atc1_pcie>;
apple,pcie-tunnel = <&usb4_1_pcie_tunnel>;
};
12 changes: 8 additions & 4 deletions arch/arm64/boot/dts/apple/t8122.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1591,8 +1591,10 @@
usb4_0_acio: cio@701ac0000 {
compatible = "apple,t8122-usb4-acio", "apple,t8103-usb4-acio";
reg = <0x7 0x01ac0000 0x0 0xc000>,
<0x7 0x01080000 0x0 0x20000>;
reg-names = "rc", "sram";
<0x7 0x01080000 0x0 0x20000>,
<0x7 0x01e44000 0x0 0x4000>,
<0x7 0x01100000 0x0 0x4000>;
reg-names = "rc", "sram", "pcie-adapter", "cpu";

mboxes = <&usb4_0_mbox>;
resets = <&cio_reset 0>;
Expand Down Expand Up @@ -1758,8 +1760,10 @@
usb4_1_acio: cio@b01ac0000 {
compatible = "apple,t8122-usb4-acio", "apple,t8103-usb4-acio";
reg = <0xb 0x01ac0000 0x0 0xc000>,
<0xb 0x01080000 0x0 0x20000>;
reg-names = "rc", "sram";
<0xb 0x01080000 0x0 0x20000>,
<0xb 0x01e44000 0x0 0x4000>,
<0xb 0x01100000 0x0 0x4000>;
reg-names = "rc", "sram", "pcie-adapter", "cpu";

mboxes = <&usb4_1_mbox>;
resets = <&cio_reset 1>;
Expand Down
24 changes: 24 additions & 0 deletions drivers/pci/controller/pcie-apple-t8122.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef PCIE_APPLE_T8122_H
#define PCIE_APPLE_T8122_H

#define APPLE_T8122_PCIEC0_ECAM 0x730000000ULL
#define APPLE_T8122_PCIEC1_ECAM 0xb30000000ULL
#define APPLE_T8122_PCIEC_AIC_BASE 1075
#define APPLE_T8122_PCIEC0_MSI_BASE 32
#define APPLE_T8122_PCIEC1_MSI_BASE 64

/* Reject unknown apertures instead of assigning another bridge's slice. */
static inline int apple_t8122_msi_vector_base(unsigned long long ecam)
{
switch (ecam) {
case APPLE_T8122_PCIEC0_ECAM:
return APPLE_T8122_PCIEC0_MSI_BASE;
case APPLE_T8122_PCIEC1_ECAM:
return APPLE_T8122_PCIEC1_MSI_BASE;
default:
return -1;
}
}

#endif
Loading
Loading