Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ properties:
- apple,t6020-cio-reset
- apple,t6030-cio-reset
- apple,t6031-cio-reset
- apple,t6041-cio-reset
- apple,t8122-cio-reset
- apple,t8132-cio-reset
- const: apple,t6000-cio-reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ allOf:
properties:
compatible:
contains:
const: apple,t8132-usb4-acio
enum:
- apple,t6040-usb4-acio
- apple,t8132-usb4-acio
then:
properties:
reg:
Expand Down
44 changes: 44 additions & 0 deletions arch/arm64/boot/dts/apple/t6040-j616s.dts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,47 @@
&scaler0 {
status = "okay";
};

/*
* USB4/Thunderbolt on the left back port (typec0, ACIO0). The loader hands
* the router, adapter and NHI tuning and the DROM over. No PCIe tunnel yet:
* host-to-host (XDomain, thunderbolt-net) and USB4 links only.
*/
&pmgr_cio {
status = "okay";
};

&ps_atc0_cio {
status = "okay";
};

&ps_atc0_pcie {
status = "okay";
};

&ps_atc0_cio_pcie {
status = "okay";
};

&ps_atc0_cio_usb {
status = "okay";
};

&usb4_0_mbox {
status = "okay";
};

&usb4_0_acio {
/delete-property/ apple,pcie-tunnel;
status = "okay";
};

&usb4_0_dart {
/* ADT dart-acio0 vm-base: the NHI addresses its rings below 1 TiB + 4 GiB. */
apple,dma-range = <0x100 0x4000 0x0 0xffff0000>;
status = "okay";
};

&usb4_0_nhi {
status = "okay";
};
63 changes: 52 additions & 11 deletions arch/arm64/boot/dts/apple/t6040-usb4.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
/*
* T6040 USB4/PCIe-C resource description.
*
* Every node remains disabled until the Type-C PHY transition, bootloader
* tuning handoff, and dynamic PCIe RID-to-SID policy are qualified.
* Every node is disabled here; a board enables the routers it has qualified.
*/

/ {
aliases {
usb4-0-rc = &usb4_0_acio;
usb4-0-acio = &usb4_0_acio;
usb4-0-nhi = &usb4_0_nhi;
usb4-0-pcie = &usb4_0_pcie;
usb4-0-pcie-adapter = &usb4_0_acio;
usb4-1-rc = &usb4_1_acio;
usb4-1-acio = &usb4_1_acio;
usb4-1-nhi = &usb4_1_nhi;
usb4-1-pcie = &usb4_1_pcie;
usb4-1-pcie-adapter = &usb4_1_acio;
usb4-2-rc = &usb4_2_acio;
usb4-2-acio = &usb4_2_acio;
usb4-2-nhi = &usb4_2_nhi;
usb4-2-pcie = &usb4_2_pcie;
usb4-2-pcie-adapter = &usb4_2_acio;
Expand All @@ -33,7 +32,10 @@
interrupts = <AIC_IRQ 1791 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "sram-parity";
mboxes = <&usb4_0_mbox>;
resets = <&ps_atc0_cio>;
resets = <&cio_reset 0>;
pinctrl-names = "lstx";
pinctrl-0 = <&usb4_0_lstx_pins>;
lstx-gpios = <&pinctrl_aop 49 GPIO_ACTIVE_HIGH>;
power-domains = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>,
<&ps_atc0_cio_usb>, <&ps_atc0_pcie>;
thunderbolt-switch;
Expand All @@ -50,7 +52,7 @@

port@1 {
reg = <1>;
endpoint { };
usb4_0_acio_tbt: endpoint { };
};
};

Expand Down Expand Up @@ -127,7 +129,10 @@
interrupts = <AIC_IRQ 1839 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "sram-parity";
mboxes = <&usb4_1_mbox>;
resets = <&ps_atc1_cio>;
resets = <&cio_reset 1>;
pinctrl-names = "lstx";
pinctrl-0 = <&usb4_1_lstx_pins>;
lstx-gpios = <&pinctrl_aop 51 GPIO_ACTIVE_HIGH>;
power-domains = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>,
<&ps_atc1_cio_usb>, <&ps_atc1_pcie>;
thunderbolt-switch;
Expand All @@ -144,7 +149,7 @@

port@1 {
reg = <1>;
endpoint { };
usb4_1_acio_tbt: endpoint { };
};
};

Expand Down Expand Up @@ -221,7 +226,10 @@
interrupts = <AIC_IRQ 1887 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "sram-parity";
mboxes = <&usb4_2_mbox>;
resets = <&ps_atc2_cio>;
resets = <&cio_reset 2>;
pinctrl-names = "lstx";
pinctrl-0 = <&usb4_2_lstx_pins>;
lstx-gpios = <&pinctrl_aop 53 GPIO_ACTIVE_HIGH>;
power-domains = <&ps_atc2_cio>, <&ps_atc2_cio_pcie>,
<&ps_atc2_cio_usb>, <&ps_atc2_pcie>;
thunderbolt-switch;
Expand All @@ -238,7 +246,7 @@

port@1 {
reg = <1>;
endpoint { };
usb4_2_acio_tbt: endpoint { };
};
};

Expand Down Expand Up @@ -517,3 +525,36 @@
};
};
};

/ {
/* ADT pmgr reg[44]: AppleT6041PMGR::enableCioReconfig at +0x2024. */
pmgr_cio: power-management@502820000 {
compatible = "apple,t6041-pmgr", "apple,t8103-pmgr", "syscon", "simple-mfd";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x5 0x02820000 0 0x4000>;
/* Enabled together with the routers. */
status = "disabled";

cio_reset: reset-controller@2024 {
compatible = "apple,t6041-cio-reset", "apple,t6000-cio-reset";
reg = <0x2024 0x4>;
#reset-cells = <1>;
};
};
};

&pinctrl_aop {
/* ADT acioN gpio-lstx. */
usb4_0_lstx_pins: usb4-0-lstx-pins {
pinmux = <APPLE_PINMUX(49, 1)>;
};

usb4_1_lstx_pins: usb4-1-lstx-pins {
pinmux = <APPLE_PINMUX(51, 1)>;
};

usb4_2_lstx_pins: usb4-2-lstx-pins {
pinmux = <APPLE_PINMUX(53, 1)>;
};
};
54 changes: 54 additions & 0 deletions arch/arm64/boot/dts/apple/t604x-j614-j616-usb4.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
* MacBook Pro (14-inch and 16-inch, M4 Pro) USB4/Thunderbolt: each Type-C
* port's connector is linked to the USB4 router behind the same ATC PHY
* (ADT acioN atc-phy-parent = atc-phyN): typec0 (left back) to ACIO0,
* typec1 (left front) to ACIO1, typec2 (right) to ACIO2. The routers stay
* disabled, and a port controller skips a link to a disabled router, so this
* changes nothing until a board enables them.
*/

&usb4_0_acio_tbt {
remote-endpoint = <&typec0_con_tbt>;
};

&usb4_1_acio_tbt {
remote-endpoint = <&typec1_con_tbt>;
};

&usb4_2_acio_tbt {
remote-endpoint = <&typec2_con_tbt>;
};

&typec0 {
ports {
port@2 {
reg = <2>;
typec0_con_tbt: endpoint {
remote-endpoint = <&usb4_0_acio_tbt>;
};
};
};
};

&typec1 {
ports {
port@2 {
reg = <2>;
typec1_con_tbt: endpoint {
remote-endpoint = <&usb4_1_acio_tbt>;
};
};
};
};

&typec2 {
ports {
port@2 {
reg = <2>;
typec2_con_tbt: endpoint {
remote-endpoint = <&usb4_2_acio_tbt>;
};
};
};
};
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t604x-j614-j616.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -3444,3 +3444,5 @@
power-domain-names = "sys", "cpu", "mpm", "td", "base", "perf";
status = "okay";
};

#include "t604x-j614-j616-usb4.dtsi"
37 changes: 35 additions & 2 deletions drivers/pci/controller/pcie-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,21 @@ static const struct hw_info t8132_pciec_hw = {
.s2idle_hold_domain = true,
};

static const struct hw_info t6040_pciec_hw = {
.port_msiaddr = PORT_MSIADDR,
.port_msiaddr_hi = PORT_MSIADDR + 4,
.port_perst = PORT_PERST,
.port_rid2sid = PORT_RID2SID,
.port_msimap = PORT_T602X_MSIMAP,
.port_tunctrl = 0x1088,
.max_rid2sid = 256,
.sid_indexed_rid2sid = true,
.tunneled = true,
.t8132_reset = true,
.msimap_by_vector = true,
.s2idle_hold_domain = true,
};

static const struct of_device_id apple_pcie_of_match[];

/**
Expand Down Expand Up @@ -2086,7 +2101,8 @@ static int apple_msi_init(struct apple_pcie *pcie)
* 32-vector slice. Keep endpoint MSI data local, and route its table
* entry to the corresponding shared-window vector.
*/
if (pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw) {
if (pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw ||
pcie->hw == &t6040_pciec_hw) {
struct resource ecam;
u32 expected_base, aic_base;

Expand All @@ -2108,6 +2124,21 @@ static int apple_msi_init(struct apple_pcie *pcie)
default:
goto invalid_slice;
}
} else if (of_machine_is_compatible("apple,t6040")) {
aic_base = 2071;
switch (ecam.start) {
case 0x1c50000000ULL:
expected_base = 0x20;
break;
case 0x1c60000000ULL:
expected_base = 0x40;
break;
case 0x1c70000000ULL:
expected_base = 0x60;
break;
default:
goto invalid_slice;
}
} else if (of_machine_is_compatible("apple,t8132")) {
aic_base = 1506;
switch (ecam.start) {
Expand Down Expand Up @@ -2153,7 +2184,8 @@ static int apple_msi_init(struct apple_pcie *pcie)
}

/* Keep map targets within the supported 8-bit range. */
if ((pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw) &&
if ((pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw ||
pcie->hw == &t6040_pciec_hw) &&
(!pcie->nvecs || pcie->nvecs > 256 ||
pcie->msi_vector_base >
FIELD_MAX(PORT_MSIMAP_TARGET) + 1 - pcie->nvecs)) {
Expand Down Expand Up @@ -4052,6 +4084,7 @@ static const struct dev_pm_ops apple_pcie_pm_ops = {
};

static const struct of_device_id apple_pcie_of_match[] = {
{ .compatible = "apple,t6040-pciec", .data = &t6040_pciec_hw },
{ .compatible = "apple,t8132-pciec", .data = &t8132_pciec_hw },
{ .compatible = "apple,t8122-pciec", .data = &t8122_pciec_hw },
{ .compatible = "apple,t8112-pciec", .data = &t8112_pciec_hw },
Expand Down
Loading
Loading