Vengineerの戯言

人生は短いけど、長いです。人生を楽しみましょう!

Apple SoC AシリーズのPCIe Controller

@Vengineerの戯言 : Twitter
SystemVerilogの世界へようこそすべては、SystemC v0.9公開から始まった 

はじめに

2月15日のブログで、下記のように、「Apple M1機の PCI Express は、3ポート?」ということがわかりました。
vengineer.hatenablog.com

昨日、iPhone 7 (A10)から iPhone 12(A14)までの device tree を見つけたので、今日の午前中、各 device tree をにらめっこしていました。
このブログでは、にらめっこした結果、A10からA14までに PCIe Controller がどのようになっているのかもわかったのでまとめたいと思います。

A10からA14までの PCIe Controller

下記の device tree から PCIe Controller 部 (apcie) を調べました。

結果

  • ポート数:A10 - A13 は 4 port、A14 は 3 port
  • 接続デバイス(ポート番号):A10 (0 : s3e, 2 : wlan, 3: baseband)、A11 ( 2 : wlan, 3 : baseband), A12-A13 ( 2 : wlan/bt, 3 : baseband) 、A14 ( 1 : wlan/bt, 2 : baseband)

でした。A10-A13までは何で 4 port だったかはわかりませんが、A14 が 3 ポートになったのは、M1 と同じものを使ったんじゃないでしょうか?

A10 の s3e は何だろうと妄想しましたが、pci-bridge0 というところに、nvme という文字がありましたので、NVMe っぽいですね。

         +--pci-bridge0:
|  |  |  |  +--name 12 bytes: pci-bridge0
|  |  |  |  +--function-dart_force_active 8 bytes: (null)
|  |  |  |  +--msi-vector-base 4 bytes: (null)
|  |  |  |  +--nvme-mode 0 bytes: (null)
|  |  |  |  +--pci-l1pm-control 8 bytes: (null)
|  |  |  |  +--function-nvme_mmu_force_active 8 bytes: (null)
|  |  |  |  +--AAPL,unit-string 9 bytes: 00000000
|  |  |  |  +--t-refclk-to-perst 4 bytes: (null)
|  |  |  |  +--AAPL,phandle 4 bytes: (null)
|  |  |  |  +--clkreq-wait-time 4 bytes: (null)
|  |  |  |  +--#size-cells 4 bytes: (null)
|  |  |  |  +--function-clkreq 16 bytes: (null)
|  |  |  |  +--maximum-link-speed 4 bytes: (null)
|  |  |  |  +--#address-cells 4 bytes: (null)
|  |  |  |  +--function-perst 16 bytes: (null)
|  |  |  |  +--allow-endpoint-reset 0 bytes: (null)
|  |  |  |  +--apcie-port 4 bytes: (null)
|  |  |  |  +--#msi-vectors 4 bytes: (null)

s3e の中にも nvme とあるので、NVMe っぽいですね。A11 からは ans というモジュールか追加され、NVMeは専用回路になったようです。

            +--s3e:
|  |  |  |  |  +--pci-l1pm-control 8 bytes: (null)
|  |  |  |  |  +--#address-cells 4 bytes: (null)
|  |  |  |  |  +--AAPL,phandle 4 bytes: (null)
|  |  |  |  |  +--icc-20us-ma 4 bytes: (null)
|  |  |  |  |  +--AAPL,unit-string 9 bytes: 00000000
|  |  |  |  |  +--pci-phy-tx-eq 4 bytes: (null)
|  |  |  |  |  +--vcc-mv 4 bytes: (null)
|  |  |  |  |  +--icc-1us-ma 4 bytes: (null)
|  |  |  |  |  +--icc-5us-ma 4 bytes: (null)
|  |  |  |  |  +--pci-aspm-default 4 bytes: (null)
|  |  |  |  |  +--disable-pcie-phy-override 4 bytes: (null)
|  |  |  |  |  +--iommu-parent 12 bytes: (null)
|  |  |  |  |  +--function-pcie_port_control 12 bytes: (null)
|  |  |  |  |  +--name 4 bytes: s3e
|  |  |  |  |  +--function-boot_from_host 16 bytes: (null)
|  |  |  |  |  +--pci-phy-rx-eq 4 bytes: (null)
|  |  |  |  |  +--pci-max-latency 4 bytes: (null)
|  |  |  |  |  +--nvme-scratch-virt-region 16 bytes: (null)
|  |  |  |  |  +--icc-duration-idx 4 bytes: (null)
|  |  |  |  |  +--imp-mohm 4 bytes: (null)
|  |  |  |  |  +--indirection-size 4 bytes: (null)
|  |  |  |  |  +--device_type 12 bytes: (null)
|  |  |  |  |  +--#size-cells 4 bytes: (null)
|  |  |  |  |  +--write-perf-mlc-mbps 4 bytes: (null)
|  |  |  |  |  +--write-perf-tlc-mbps 4 bytes: (null)

iPhone 8 Plus (A11) では、下記のように、ans に s4e なるキーワードがあるので、NVMe 決定ですね。

      +--ans:
|  |  |  +--nvme-interrupt-idx 4 bytes: (null)
|  |  |  +--iop-version 4 bytes: (null)
|  |  |  +--clock-gates 4 bytes: (null)
|  |  |  +--function-spi0_sclk_config 16 bytes: (null)
|  |  |  +--AAPL,phandle 4 bytes: (null)
|  |  |  +--power-budget-platform-modes 64 bytes: (null)
|  |  |  +--iommu-parent 4 bytes: (null)
|  |  |  +--namespaces 84 bytes: (null)
|  |  |  +--name 4 bytes: ans
|  |  |  +--interrupt-parent 4 bytes: (null)
|  |  |  +--s4e-bfh-params 36 bytes: (null)

I/O MMU

I/O MMU ですが、PCIe の 各ポートにあるんですが、これ以外に、mapper なるものがありました。A12から wlan/bt の2つの機能が付いたデバイスが接続されていますが、各機能に対して Mapping しているようです。

f:id:Vengineer:20210221124045p:plain

iPhone 11 の場合は、次のようになっていました。

         +--mapper-apcie2-wlan:
|  |  |  |  +--compatible 13 bytes: iommu-mapper 0x69 0x6f 0x6d 0x6d 0x75 0x2d 0x6d 0x61 0x70 0x70 0x65 0x72 0x00
|  |  |  |  +--device_type 12 bytes: (null) 0x64 0x61 0x72 0x74 0x2d 0x6d 0x61 0x70 0x70 0x65 0x72 0x00
|  |  |  |  +--name 19 bytes: mapper-apcie2-wlan
|  |  |  |  +--AAPL,phandle 4 bytes: (null) 0xcd 0x00 0x00 0x00
         +--mapper-apcie2-bt:
|  |  |  |  +--compatible 13 bytes: iommu-mapper 0x69 0x6f 0x6d 0x6d 0x75 0x2d 0x6d 0x61 0x70 0x70 0x65 0x72 0x00
|  |  |  |  +--device_type 12 bytes: (null) 0x64 0x61 0x72 0x74 0x2d 0x6d 0x61 0x70 0x70 0x65 0x72 0x00
|  |  |  |  +--name 17 bytes: mapper-apcie2-bt
|  |  |  |  +--AAPL,phandle 4 bytes: (null) 0xce 0x00 0x00 0x00

PCIe Port の I/O MMU は、16KBではなく、4KB のようです。この部分は従来と同じなんですね。たぶん、PCIe Device の互換性を考えるとそうなるんでしょうね。

      +--dart-apcie2:
|  |  |  +--vm-size 4 bytes: (null) 0x00 0x00 0xe0 0x3f
|  |  |  +--manual-availability 4 bytes: (null) 0x01 0x00 0x00 0x00
|  |  |  +--compatible 11 bytes: dart,t8020 0x64 0x61 0x72 0x74 0x2c 0x74 0x38 0x30 0x32 0x30 0x00
|  |  |  +--page-size 4 bytes: (null) 0x00 0x10 0x00 0x00

終わりに

iPhone 7 (A10) から 12 (A14)の device tree があったので、こういうことも調べられました。

Apple が apcie という独自の PCIe Controller を開発したのは、Apple M1機の PCI Express は、3ポート? でも書きましたが、そのほかに今回分かったこととして、mapper です。1つの PCIe チップに複数の機能が実装されている場合にこれが活躍するようです。

参考ブログ:
vengineer.hatenablog.com

vengineer.hatenablog.com