diff --git a/arch/arm64/boot/dts/apple/t6050-j714c.dts b/arch/arm64/boot/dts/apple/t6050-j714c.dts index f6da08c085819..7c4ee4736c2e9 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714c.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714c.dts @@ -61,20 +61,34 @@ * PHY and PERST; Linux owns the routing, MSI and the DART. Disabled with its DART * until the boot loader trains it, which also renumbers the bus here to the PCI * core's order. + * + * PCIe port 1: the SD card reader (t6050-sdreader.dtsi), as on J714s. From this + * board's ADT: port1, phy1 and intr2axi1 are apcie0 reg[22], reg[24] and + * reg[25], phy-shared reg[3], its interrupt 1531 (apcie0 interrupts[1]). The + * boot loader leaves the port down and the kernel trains it. */ &pcie0 { reg = <0x1c 0xb0000000 0x0 0x10000000>, <0x4 0x14000000 0x0 0x4000>, <0x4 0x10028000 0x0 0x8000>, <0x4 0x17010000 0x0 0x4000>, - <0x4 0x10024000 0x0 0x4000>; - reg-names = "config", "rc", "port0", "phy0", "intr2axi0"; - interrupts = ; - interrupt-names = "port0"; - - /* The N1's three functions are on DART streams 1-3 */ - iommu-map = <0x100 &dart_apcie0 1 3>; + <0x4 0x10024000 0x0 0x4000>, + <0x4 0x11028000 0x0 0x8000>, + <0x4 0x17014000 0x0 0x4000>, + <0x4 0x11024000 0x0 0x4000>, + <0x4 0x17020000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "phy0", "intr2axi0", "port1", "phy1", "intr2axi1", + "phy-shared"; + interrupts = , + ; + interrupt-names = "port0", "port1"; + + /* The N1's three functions are on DART streams 1-3, the SD reader on stream 1 */ + iommu-map = <0x100 &dart_apcie0 1 3>, + <0x200 &dart_apcie1 1 1>; bus-range = <0 4>; + /* dart_apcie1 probes only once port 1 is up: the host must not wait for it */ + post-init-providers = <&dart_apcie1>; port00: pci@0,0 { device_type = "pci"; @@ -120,6 +134,13 @@ }; }; +#include "t6050-sdreader.dtsi" + +/* The SD reader's power: SMC pcIO output 0 below (ADT pcie-sdreader function-sd_pwr_en) */ +&port01 { + pwren-gpios = <&smc_pcio 0 GPIO_ACTIVE_HIGH>; +}; + /* ATC3 and the PD controller bus nub-spmi-a2: not on this board's ports */ &nub_spmi_a2 { status = "disabled"; @@ -211,11 +232,21 @@ /* * Only the pins a node here names are exposed, as on the J716c: pin 112's register - * takes an SError when read. 80 is PCIe port 0's PERST#, 106 the amps' fault interrupt and - * 107 their shutdown line. + * takes an SError when read. 80 and 81 are PCIe ports 0 and 1's PERST#, 106 the amps' + * fault interrupt and 107 their shutdown line. */ &pinctrl_ap { - gpio-reserved-ranges = <0 80>, <81 25>, <108 113>; + gpio-reserved-ranges = <0 80>, <82 24>, <108 113>; +}; + +/* + * The one SMC pcIO output this board drives, as a pKW8('pcIO', lo, hi) template + * written (hi << 32) | lo with the level in the low bits: + * 0 sd_pwr_en (0x0, 0x190000): ADT pcie-sdreader function-sd_pwr_en, the SD + * reader's power on PCIe port 1 + */ +&smc_pcio { + apple,output-commands = /bits/ 64 <0x0019000000000000>; }; /* @@ -543,3 +574,6 @@ &clpc { apple,high-power-mode; }; + +/* The SD card reader DART's power states (t6050-sdreader.dtsi) */ +#include "t6050-sdreader-power.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6050-j714s.dts b/arch/arm64/boot/dts/apple/t6050-j714s.dts index 7f8f6313c77c3..48359cb24b429 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714s.dts @@ -145,54 +145,31 @@ local-bd-address = [00 00 00 00 00 00]; }; }; +}; - port01: pci@1,0 { - device_type = "pci"; - reg = <0x800 0 0 0 0>; - bus-range = <2 2>; - /* Down at boot: the kernel trains it, powering the reader first */ - apple,link-trained-by-bootloader; - pwren-gpios = <&smc_pcio 0 GPIO_ACTIVE_HIGH>; - /* PERST#: ADT pci-bridge1 function-perst, GPIO 81 */ - reset-gpios = <&pinctrl_ap 81 GPIO_ACTIVE_LOW>; - apple,apcie-config-tunables = <0x140 4 0x1 0x1>, - <0x144 4 0xffffff 0x253770>, - <0x8a8 4 0x1 0x1>, - <0x8ac 4 0x1 0x1>; - apple,pcie-rc-tunables = <0x78 4 0x7000 0x0>, - <0x194 4 0x2 0x2>, - <0xb80 4 0x7f3f3f 0x7f1e1e>, - <0xb88 4 0x7f3f3f 0x7f1e1e>; - apple,pcie-rc-gen3-shadow-tunables = <0x154 4 0xf0f0f0f 0x5050505>, - <0x890 4 0x3000000 0x0>, - <0x8a8 4 0xffff0f 0x1>; - apple,pcie-rc-gen4-shadow-tunables = <0x178 4 0xffff 0x5555>, - <0x890 4 0x3000000 0x1000000>, - <0x8a8 4 0xffff0f 0x1>; - apple,pcie-rc-gen5-shadow-tunables = <0x1ac 4 0xffff 0x5555>, - <0x890 4 0x3000000 0x2000000>, - <0x8a8 4 0xffff0f 0x1>; - - #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 &port01 0 0 0 0>, - <0 0 0 2 &port01 0 0 0 1>, - <0 0 0 3 &port01 0 0 0 2>, - <0 0 0 4 &port01 0 0 0 3>; - - /* The GL9755; card detect and write protect active high (ADT *-polarity = 1) */ - sdhci0: mmc@0,0 { - compatible = "pci17a0,9755"; - reg = <0x20000 0x0 0x0 0x0 0x0>; - cd-inverted; - wp-inverted; - }; - }; +#include "t6050-sdreader.dtsi" + +&port01 { + /* Down at boot: the kernel trains it, powering the reader first */ + pwren-gpios = <&smc_pcio 0 GPIO_ACTIVE_HIGH>; + /* pci-bridge1's link tunables */ + apple,apcie-config-tunables = <0x140 4 0x1 0x1>, + <0x144 4 0xffffff 0x253770>, + <0x8a8 4 0x1 0x1>, + <0x8ac 4 0x1 0x1>; + apple,pcie-rc-tunables = <0x78 4 0x7000 0x0>, + <0x194 4 0x2 0x2>, + <0xb80 4 0x7f3f3f 0x7f1e1e>, + <0xb88 4 0x7f3f3f 0x7f1e1e>; + apple,pcie-rc-gen3-shadow-tunables = <0x154 4 0xf0f0f0f 0x5050505>, + <0x890 4 0x3000000 0x0>, + <0x8a8 4 0xffff0f 0x1>; + apple,pcie-rc-gen4-shadow-tunables = <0x178 4 0xffff 0x5555>, + <0x890 4 0x3000000 0x1000000>, + <0x8a8 4 0xffff0f 0x1>; + apple,pcie-rc-gen5-shadow-tunables = <0x1ac 4 0xffff 0x5555>, + <0x890 4 0x3000000 0x2000000>, + <0x8a8 4 0xffff0f 0x1>; }; /* @@ -206,12 +183,6 @@ gpio-reserved-ranges = <0 80>, <82 24>, <108 26>, <135 1>, <140 81>; }; -/* It answers only once port 1's root complex is up: pcie-apple then enables it */ -&dart_apcie1 { - apple,manual-availability; - status = "okay"; -}; - /* The keyboard backlight: ADT pwm0/kbd-backlight, channel 0 at 25 kHz */ / { aliases { @@ -841,3 +812,6 @@ &isp0 { apple,camera-indicator = <&dcp>; }; + +/* The SD card reader DART's power states (t6050-sdreader.dtsi) */ +#include "t6050-sdreader-power.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6050-j716c.dts b/arch/arm64/boot/dts/apple/t6050-j716c.dts index a097951f39afd..f4a2fb8a8c26f 100644 --- a/arch/arm64/boot/dts/apple/t6050-j716c.dts +++ b/arch/arm64/boot/dts/apple/t6050-j716c.dts @@ -73,24 +73,38 @@ /* * PCIe port 0: the N1 (Wi-Fi and Bluetooth), the only GP port this board uses besides the SD - * reader on port 1 (not yet described). The boot loader trains the link after the SMC releases - * the N1's reset and keeps power, clocks, the PHY and PERST; Linux owns the routing, MSI and - * the DART. Disabled with its DART until the boot loader trains it, which also renumbers the - * bus here to the PCI core's order. + * reader on port 1. The boot loader trains the link after the SMC releases the N1's reset and + * keeps power, clocks, the PHY and PERST; Linux owns the routing, MSI and the DART. Disabled + * with its DART until the boot loader trains it, which also renumbers the bus here to the PCI + * core's order. + * + * PCIe port 1: the SD card reader (t6050-sdreader.dtsi), as on J714s. From this board's ADT: + * port1, phy1 and intr2axi1 are apcie0 reg[22], reg[24] and reg[25], phy-shared reg[3], its + * interrupt 1531 (apcie0 interrupts[1]). The boot loader leaves the port down and the kernel + * trains it. */ &pcie0 { reg = <0x1c 0xb0000000 0x0 0x10000000>, <0x4 0x14000000 0x0 0x4000>, <0x4 0x10028000 0x0 0x8000>, <0x4 0x17010000 0x0 0x4000>, - <0x4 0x10024000 0x0 0x4000>; - reg-names = "config", "rc", "port0", "phy0", "intr2axi0"; - interrupts = ; - interrupt-names = "port0"; - - /* The N1's three functions are on DART streams 1-3 */ - iommu-map = <0x100 &dart_apcie0 1 3>; + <0x4 0x10024000 0x0 0x4000>, + <0x4 0x11028000 0x0 0x8000>, + <0x4 0x17014000 0x0 0x4000>, + <0x4 0x11024000 0x0 0x4000>, + <0x4 0x17020000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "phy0", "intr2axi0", "port1", "phy1", "intr2axi1", + "phy-shared"; + interrupts = , + ; + interrupt-names = "port0", "port1"; + + /* The N1's three functions are on DART streams 1-3, the SD reader on stream 1 */ + iommu-map = <0x100 &dart_apcie0 1 3>, + <0x200 &dart_apcie1 1 1>; bus-range = <0 4>; + /* dart_apcie1 probes only once port 1 is up: the host must not wait for it */ + post-init-providers = <&dart_apcie1>; port00: pci@0,0 { device_type = "pci"; @@ -187,14 +201,14 @@ /* * Pin 112's register (0x29c0001c0) takes an SError when read, so only the pins a node - * here names are exposed: 80 (PCIe port 0's PERST#, ADT pci-bridge0 function-perst), - * 106 and 107 (the speaker amps' fault interrupt and shutdown line), 134 and 139 (the - * jack codec's interrupt and reset), 136 and 137 (speaker ID) and 138 (the Touch ID - * sensor's data-ready line). + * here names are exposed: 80 and 81 (PCIe ports 0 and 1's PERST#, ADT pci-bridge0 and + * pci-bridge1 function-perst), 106 and 107 (the speaker amps' fault interrupt and shutdown + * line), 134 and 139 (the jack codec's interrupt and reset), 136 and 137 (speaker ID) and + * 138 (the Touch ID sensor's data-ready line). * A reserved line cannot be requested, so a node that names a new pin opens it here too. */ &pinctrl_ap { - gpio-reserved-ranges = <0 80>, <81 25>, <108 26>, <135 1>, <140 81>; + gpio-reserved-ranges = <0 80>, <82 24>, <108 26>, <135 1>, <140 81>; }; /* @@ -290,14 +304,26 @@ }; }; -/* This board's PCIO outputs, the trackpad AFE reset (2) among them */ +/* + * This board's PCIO outputs, the trackpad AFE reset (2) among them, and the SD reader's + * power (3), sd_pwr_en pKW8('pcIO', 0x0, 0x190000) + */ &smc_pcio { - apple,output-commands = /bits/ 64 <0x001a000000000000 0x000f000000800000 0x011c000000010000>; + apple,output-commands = /bits/ 64 <0x001a000000000000 0x000f000000800000 0x011c000000010000 + 0x0019000000000000>; }; #include "t6050-peripherals.dtsi" #include "t6050-media.dtsi" +/* After the peripherals, which describe dart-apcie1 (disabled) at the same node */ +#include "t6050-sdreader.dtsi" + +/* The SD reader's power: SMC pcIO output 3 above (ADT pcie-sdreader function-sd_pwr_en) */ +&port01 { + pwren-gpios = <&smc_pcio 3 GPIO_ACTIVE_HIGH>; +}; + #include "t6050-max-atc2.dtsi" /* This unit's host DROM (router UUID from an earlier boot) */ @@ -641,3 +667,6 @@ &clpc { apple,high-power-mode; }; + +/* The SD card reader DART's power states (t6050-sdreader.dtsi) */ +#include "t6050-sdreader-power.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6050-j716s.dts b/arch/arm64/boot/dts/apple/t6050-j716s.dts index 1db9d021fae9c..c25619fb9f3b3 100644 --- a/arch/arm64/boot/dts/apple/t6050-j716s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j716s.dts @@ -90,8 +90,7 @@ }; /* - * PCIe port 0: the N1 (Wi-Fi and Bluetooth). Port 1 is the SD reader, not yet - * described. The registers, interrupt, DART streams and PERST# pin are the + * PCIe port 0: the N1 (Wi-Fi and Bluetooth). The registers, interrupt, DART streams and PERST# pin are the * J716c's: the J716s ADT has the same port. Port 0 and its DART stay disabled * until the boot loader enables them: once it trained the port, or with the * port down because the kernel can train it (port00 names the N1's power @@ -101,6 +100,14 @@ * (reg[5]), pcieclkgen (reg[6]), phy-window (reg[2]) and phy-ip (reg[4]), * the same as the J714c's; the PHY and axi2af windows are cut to what their * lists reach. + * + * PCIe port 1: the SD card reader (t6050-sdreader.dtsi), as on J714s. From this + * board's ADT: port1, phy1 and intr2axi1 are apcie0 reg[22], reg[24] and + * reg[25], its interrupt 1531 (apcie0 interrupts[1]). The reader's power is + * the SMC pcIO output of the ADT's function-sd_pwr_en, but this board's SMC + * gpio node is the gP bank (the N1's power, below), so the kernel cannot + * drive it and does not train the port. Port 1 and its DART stay disabled + * until a boot loader that powers and trains the port enables both. */ &pcie0 { reg = <0x1c 0xb0000000 0x0 0x10000000>, @@ -113,21 +120,27 @@ <0x4 0x16000000 0x0 0x24000>, <0x4 0x15044000 0x0 0x4000>, <0x4 0x17000000 0x0 0x24000>, - <0x4 0x17800000 0x0 0x1b4000>; + <0x4 0x17800000 0x0 0x1b4000>, + <0x4 0x11028000 0x0 0x8000>, + <0x4 0x17014000 0x0 0x4000>, + <0x4 0x11024000 0x0 0x4000>; reg-names = "config", "rc", "port0", "phy0", "intr2axi0", "phy-shared", "phy-common", "axi2af", "pcieclkgen", - "phy-window", "phy-ip"; - interrupts = ; - interrupt-names = "port0"; - - /* The N1's three functions are on DART streams 1-3 */ - iommu-map = <0x100 &dart_apcie0 1 3>; + "phy-window", "phy-ip", "port1", "phy1", "intr2axi1"; + interrupts = , + ; + interrupt-names = "port0", "port1"; + + /* The N1's three functions are on DART streams 1-3, the SD reader on stream 1 */ + iommu-map = <0x100 &dart_apcie0 1 3>, + <0x200 &dart_apcie1 1 1>; bus-range = <0 4>; /* - * dart_apcie0 probes only once this host has the port up: fw_devlink - * must not make the host wait for it (strict mode enforces iommu-map) + * dart_apcie0 and dart_apcie1 probe only once this host has their port + * up: fw_devlink must not make the host wait for them (strict mode + * enforces iommu-map) */ - post-init-providers = <&dart_apcie0>; + post-init-providers = <&dart_apcie0>, <&dart_apcie1>; port00: pci@0,0 { device_type = "pci"; @@ -175,6 +188,17 @@ }; }; +#include "t6050-sdreader.dtsi" + +/* Down at boot: a boot loader that powers and trains port 1 enables both */ +&port01 { + status = "disabled"; +}; + +&dart_apcie1 { + status = "disabled"; +}; + /* It answers only once port 0's root complex is up: pcie-apple then enables it */ &dart_apcie0 { apple,manual-availability; @@ -187,6 +211,7 @@ * 0 dp2hdmi_pwr_en (0x0, 0x1a0000) * 1 hdmi_pwr_en (0x800000, 0xf0000) * 2 afe-reset (0x10000, 0x11c0000) + * and the SD reader's sd_pwr_en (0x0, 0x190000). */ /delete-node/ &smc_pcio; @@ -456,13 +481,13 @@ /* * Pin 112 takes an SError when read (as on the J716c), so only the pins a node - * here names are exposed: 80 (PCIe port 0's PERST#), 106 and 107 (the speaker - * amps' fault interrupt and shutdown line), 134 and 139 (the jack codec's + * here names are exposed: 80 and 81 (PCIe ports 0 and 1's PERST#), 106 and 107 (the + * speaker amps' fault interrupt and shutdown line), 134 and 139 (the jack codec's * interrupt and reset), 136 and 137 (speaker ID) and 138 (the Touch ID sensor's * data-ready line). */ &pinctrl_ap { - gpio-reserved-ranges = <0 80>, <81 25>, <108 26>, <135 1>, <140 81>; + gpio-reserved-ranges = <0 80>, <82 24>, <108 26>, <135 1>, <140 81>; }; /* @@ -951,3 +976,6 @@ /* The GPU and the internal panel, for the boot loader's handoff */ #include "t6050-j716s-gpu-panel.dtsi" + +/* The SD card reader DART's power states (t6050-sdreader.dtsi) */ +#include "t6050-sdreader-power.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6050-j775d.dts b/arch/arm64/boot/dts/apple/t6050-j775d.dts index d39396b6e0290..3d418e74251ac 100644 --- a/arch/arm64/boot/dts/apple/t6050-j775d.dts +++ b/arch/arm64/boot/dts/apple/t6050-j775d.dts @@ -94,6 +94,12 @@ * * Port 0 carries the N1 (Wi-Fi and Bluetooth), described disabled until the boot loader trains * it (pci@0,0 below). + * + * Port 1 carries the SD card reader (t6050-sdreader.dtsi), as on the MacBook Pros. From this + * board's ADT: port1, phy1 and intr2axi1 are apcie0 reg[22], reg[24] and reg[25], its interrupt + * 1531 (apcie0 interrupts[1]). The kernel does not train it here: the bus it would number the + * port is port 3's. Like port 0, it stays disabled with its DART until a boot loader that powers + * and trains it enables both and renumbers the buses. */ &pcie0 { reg = <0x1c 0xb0000000 0x0 0x10000000>, @@ -106,25 +112,31 @@ <0x4 0x13024000 0x0 0x4000>, <0x4 0x10028000 0x0 0x8000>, <0x4 0x17010000 0x0 0x4000>, - <0x4 0x10024000 0x0 0x4000>; + <0x4 0x10024000 0x0 0x4000>, + <0x4 0x11028000 0x0 0x8000>, + <0x4 0x17014000 0x0 0x4000>, + <0x4 0x11024000 0x0 0x4000>; reg-names = "config", "rc", "port2", "phy2", "intr2axi2", "port3", "phy3", "intr2axi3", - "port0", "phy0", "intr2axi0"; + "port0", "phy0", "intr2axi0", + "port1", "phy1", "intr2axi1"; interrupts = , , - ; - interrupt-names = "port2", "port3", "port0"; + , + ; + interrupt-names = "port2", "port3", "port0", "port1"; /* * The boot loader numbers port 2's secondary bus 1 and port 3's 2; - * port 0's is 3 until a boot loader that trains it renumbers all three - * in the PCI core's order. The N1's three functions are on DART - * streams 1-3. + * port 0's is 3 and port 1's 4 until a boot loader that trains them + * renumbers all four in the PCI core's order. The N1's three functions + * are on DART streams 1-3, the SD reader on stream 1. */ iommu-map = <0x100 &dart_apcie2 1 1>, <0x200 &dart_apcie3 1 1>, - <0x300 &dart_apcie0 1 3>; - bus-range = <0 3>; + <0x300 &dart_apcie0 1 3>, + <0x400 &dart_apcie1 1 1>; + bus-range = <0 4>; port03: pci@3,0 { device_type = "pci"; @@ -202,17 +214,29 @@ }; }; +#define T6050_SDREADER_BUS 4 +#include "t6050-sdreader.dtsi" + +/* Down at boot: a boot loader that powers and trains port 1 enables both */ +&port01 { + status = "disabled"; +}; + +&dart_apcie1 { + status = "disabled"; +}; + /* The pins this board's nodes name, and no others */ &pinctrl_ap { /* * Every pin reads cleanly, but only - * the pins a node in this file names are exposed: 80 (PCIe port 0's PERST#, ADT - * pci-bridge0 function-perst), 106 (amp IRQ), 107 (amp shutdown), 134 (jack IRQ) + * the pins a node in this file names are exposed: 80 and 81 (PCIe ports 0 and 1's + * PERST#, ADT pci-bridge0 and pci-bridge1 function-perst), 106 (amp IRQ), 107 (amp shutdown), 134 (jack IRQ) * and 139 (jack codec reset), from the ADT's audio-speaker and audio-codec-output. * A reserved line cannot be requested (gpiolib answers -EINVAL), so a node that * names a new pin of pinctrl_ap opens it here too. */ - gpio-reserved-ranges = <0 80>, <81 25>, <108 26>, <135 4>, <140 81>; + gpio-reserved-ranges = <0 80>, <82 24>, <108 26>, <135 4>, <140 81>; }; /* @@ -576,3 +600,6 @@ &pinctrl_aop { gpio-reserved-ranges = <0 77>, <78 1>, <80 5>; }; + +/* The SD card reader DART's power states (t6050-sdreader.dtsi) */ +#include "t6050-sdreader-power.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6050-sdreader-power.dtsi b/arch/arm64/boot/dts/apple/t6050-sdreader-power.dtsi new file mode 100644 index 0000000000000..9076aeb79aca6 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6050-sdreader-power.dtsi @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * The power states of the SD card reader's DART (t6050-sdreader.dtsi): + * APCIE_SYS_GP and its parents in the ADT power tree, enabled the way the K + * boards enable them (t6050-k114-k116-usb.dtsi). The boot loader keeps them + * on, so Linux holds a vote and never switches them. A board that includes + * t6050-sdreader.dtsi includes this after t6050-peripherals.dtsi, where the + * states are described. + */ + +&ps_fab6_soc { + apple,firmware-owned; + status = "okay"; +}; + +&ps_apcie_gp { + apple,firmware-owned; + status = "okay"; +}; + +&ps_apcie_sys_gp { + apple,firmware-owned; + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t6050-sdreader.dtsi b/arch/arm64/boot/dts/apple/t6050-sdreader.dtsi new file mode 100644 index 0000000000000..fcde39853b807 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6050-sdreader.dtsi @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * The SD card reader of the T6050 MacBook Pros and Mac Studios: a Genesys + * GL9755 on PCIe port 1 of apcie0 (ADT pci-bridge1/pcie-sdreader). Every + * board's ADT gives it the same shape: PERST# is pci-bridge1's function-perst, + * GPIO 81; card detect and write protect are active high (card-detect-polarity + * and write-protect-polarity = 1); its power is the SMC pcIO template of + * function-sd_pwr_en, pKW8('pcIO', 0x0, 0x190000); it is behind dart-apcie1, + * which answers only once the root complex is up. mapper-apcie1 names no + * stream (the bridge requests one at run time), so the reader gets stream 1, + * below the DART's first bypass stream (16). pci-bridge1's function-clkreq + * (GPIO 77) is not described: the driver does not take CLKREQ# lines. + * + * The board includes this after its &pcie0 and gives what differs: + * - pcie0's "port1", "phy1", "intr2axi1" and "phy-shared" registers (apcie0 + * reg[22], reg[24], reg[25] and reg[3]), interrupt 1531 (apcie0 + * interrupts[1]) and an iommu-map entry for the port's bus on dart_apcie1, + * stream 1; + * - T6050_SDREADER_BUS, the port's secondary bus in this tree, if it is not 2; + * - pin 81 open in pinctrl_ap's gpio-reserved-ranges; + * - how the link comes up. On the MacBook Pros the boot loader leaves port 1 + * down and the kernel trains it: the board gives port01 the reader's power, + * pwren-gpios on its SMC pcIO output for sd_pwr_en. Where the boot loader + * trains the port, port01 and dart_apcie1 stay disabled until it does. + */ + +#ifndef T6050_SDREADER_BUS +#define T6050_SDREADER_BUS 2 +#endif + +&pcie0 { + port01: pci@1,0 { + device_type = "pci"; + reg = <0x800 0 0 0 0>; + bus-range = ; + apple,link-trained-by-bootloader; + /* PERST#: ADT pci-bridge1 function-perst, GPIO 81 */ + reset-gpios = <&pinctrl_ap 81 GPIO_ACTIVE_LOW>; + + #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 &port01 0 0 0 0>, + <0 0 0 2 &port01 0 0 0 1>, + <0 0 0 3 &port01 0 0 0 2>, + <0 0 0 4 &port01 0 0 0 3>; + + /* The GL9755; card detect and write protect active high */ + sdhci0: mmc@0,0 { + compatible = "pci17a0,9755"; + reg = <(T6050_SDREADER_BUS << 16) 0x0 0x0 0x0 0x0>; + cd-inverted; + wp-inverted; + }; + }; +}; + +/* + * It answers only once port 1's root complex is up: pcie-apple then enables it. + * It sits in the same apcie block as port 0's DART and takes the same + * APCIE_SYS_GP, as on the K boards and the T6040's apcie1_dart. The board + * enables that state at its end with t6050-sdreader-power.dtsi. + */ +&dart_apcie1 { + power-domains = <&ps_apcie_sys_gp>; + apple,manual-availability; + status = "okay"; +}; +