mbox series

[00/18] Apple M1 SoC platform bring-up

Message ID 20210204203951.52105-1-marcan@marcan.st (mailing list archive)
Headers show
Series Apple M1 SoC platform bring-up | expand

Message

Hector Martin Feb. 4, 2021, 8:39 p.m. UTC
This series brings up initial support for the Apple M1 SoC, used in the
2020 Mac Mini, MacBook Pro, and MacBook Air models.

The following features are supported in this initial port:

- UART (samsung-style) with earlycon support
- Interrupts, including affinity and IPIs (Apple Interrupt Controller)
- SMP (through standard spin-table support)
- simplefb-based framebuffer
- Devicetree for the Mac Mini (should work for the others too at this
  stage)

The primary pain points of this port are:

- Apple SoCs require FIQs, as the timers and "fast" IPIs are hardwired
  to the FIQ interrupt line. This patchset introduces FIQ support through
  the alternatives mechanism, so as to not affect other platforms,
  implemented as simply merging IRQs and FIQs. The AIC driver takes care
  of discriminating and routing IRQs to the right users.

- These SoCs blackhole nGnRE writes to internal MMIO ranges, and require
  nGnRnE. There is no obvious right solution to solve this. I do not
  expect the two patches for that in this series to be merged as-is, but
  the commit messages describe the problem and potential solutions. I
  hope we can have a discussion and converge on the right approach to
  solve this problem in the sanest way.

These machines officially support booting unsigned/user-provided
XNU-like kernels, with a very different boot protocol and devicetree
format. We are developing an initial bootloader, m1n1 [1], to take care
of as many hardware peculiarities as possible and present a standard
Linux arm64 boot protocol and device tree. In the future, I expect that
production setups will add U-Boot and perhaps GRUB into the boot chain,
to make the boot process similar to other ARM64 platforms.

The machines expose their debug UART over USB Type C, triggered with
vendor-specific USB-PD commands. Currently, the easiest way to get a
serial console on these machines is to use a second M1 box and a simple
USB C cable [2]. You can also build a DIY interface using an Arduino, a
FUSB302 chip or board, and a 1.2V UART-TTL adapter [3]. In the coming
weeks we will be designing an open hardware project to provide
serial/debug connectivity to these machines (and, hopefully, also
support other UART-over-Type C setups from other vendors). Please
contact me privately if you are interested in getting an early prototype
version of one of these devices.

A quickstart guide to booting Linux kernels on these machines is
available at [4], and we are documenting the hardware at [5].

[1] https://github.com/AsahiLinux/m1n1/
[2] https://github.com/AsahiLinux/macvdmtool/
[3] https://github.com/AsahiLinux/vdmtool/
[4] https://github.com/AsahiLinux/docs/wiki/Developer-Quickstart
[5] https://github.com/AsahiLinux/docs/wiki

== Project Blurb ==

Asahi Linux is an open community project dedicated to developing and
maintaining mainline support for Apple Silicon on Linux. Feel free to
drop by #asahi on freenode to chat with us, or check our website for
more information on the project:

https://asahilinux.org/


Hector Martin (18):
  dt-bindings: vendor-prefixes: add AAPL prefix
  dt-bindings: arm: cpus: Add AAPL,firestorm & icestorm compatibles
  dt-bindings: arm: AAPL: Add bindings for Apple ARM platforms
  arm64: Kconfig: Introduce CONFIG_ARCH_APPLE
  tty: serial: samsung_tty: add support for Apple UARTs
  dt-bindings: serial: samsung: Add AAPL,s5l-uart compatible
  tty: serial: samsung_tty: enable for ARCH_APPLE
  arm64: cpufeature: Add a feature for FIQ support
  arm64: cputype: Add CPU types for the Apple M1 big/little cores
  arm64: Introduce FIQ support
  arm64: Kconfig: Require FIQ support for ARCH_APPLE
  arm64: setup: Use nGnRnE IO mappings for fixmap on Apple platforms
  arm64: ioremap: use nGnRnE mappings on platforms that require it
  dt-bindings: interrupt-controller: Add DT bindings for apple-aic
  irqchip/apple-aic: Add support for the Apple Interrupt Controller
  irqchip/apple-aic: Add SMP / IPI support
  dt-bindings: display: add AAPL,simple-framebuffer
  arm64: apple: Add initial Mac Mini 2020 (M1) devicetree

 .../devicetree/bindings/arm/AAPL.yaml         |  36 ++
 .../devicetree/bindings/arm/cpus.yaml         |   2 +
 .../bindings/display/simple-framebuffer.yaml  |   5 +
 .../interrupt-controller/AAPL,aic.yaml        |  88 +++
 .../bindings/serial/samsung_uart.yaml         |   4 +-
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |  14 +
 arch/arm64/Kconfig                            |  10 +
 arch/arm64/Kconfig.platforms                  |   8 +
 arch/arm64/boot/dts/Makefile                  |   1 +
 arch/arm64/boot/dts/apple/Makefile            |   2 +
 arch/arm64/boot/dts/apple/apple-j274.dts      | 143 +++++
 arch/arm64/include/asm/assembler.h            |   4 +
 arch/arm64/include/asm/cpucaps.h              |   3 +-
 arch/arm64/include/asm/cpufeature.h           |   6 +
 arch/arm64/include/asm/cputype.h              |   6 +
 arch/arm64/include/asm/daifflags.h            |   7 +
 arch/arm64/include/asm/fixmap.h               |  10 +-
 arch/arm64/include/asm/io.h                   |   9 +-
 arch/arm64/include/asm/irqflags.h             |  17 +-
 arch/arm64/kernel/cpufeature.c                |  32 ++
 arch/arm64/kernel/entry.S                     |  27 +-
 arch/arm64/kernel/setup.c                     |  12 +
 drivers/irqchip/Kconfig                       |  10 +
 drivers/irqchip/Makefile                      |   1 +
 drivers/irqchip/irq-apple-aic.c               | 501 ++++++++++++++++++
 drivers/tty/serial/Kconfig                    |   2 +-
 drivers/tty/serial/samsung_tty.c              | 297 +++++++++--
 .../interrupt-controller/apple-aic.h          |  14 +
 include/linux/serial_s3c.h                    |  16 +
 include/uapi/linux/serial_core.h              |   3 +
 31 files changed, 1243 insertions(+), 49 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/AAPL.yaml
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/AAPL,aic.yaml
 create mode 100644 arch/arm64/boot/dts/apple/Makefile
 create mode 100644 arch/arm64/boot/dts/apple/apple-j274.dts
 create mode 100644 drivers/irqchip/irq-apple-aic.c
 create mode 100644 include/dt-bindings/interrupt-controller/apple-aic.h

--
2.30.0

Comments

Arnd Bergmann Feb. 4, 2021, 10:43 p.m. UTC | #1
On Thu, Feb 4, 2021 at 9:39 PM Hector Martin <marcan@marcan.st> wrote:
>
> This series brings up initial support for the Apple M1 SoC, used in the
> 2020 Mac Mini, MacBook Pro, and MacBook Air models.

I like this a lot overall, great work!

As you probably know, the timing would be really tight for a merge
in 5.12, but if we can work out a solution for the FIQ and MMIO
problems quickly and you get Ack's from the relevant maintainers
(arch/arm64, serial, irqchip), I'd be happy to merge all of it through
the soc tree even fairly late this cycle.

> The following features are supported in this initial port:
>
> - UART (samsung-style) with earlycon support
> - Interrupts, including affinity and IPIs (Apple Interrupt Controller)
> - SMP (through standard spin-table support)
> - simplefb-based framebuffer

Side note about simplefb: Ard mentioned on IRC that there is
earlycon support in efifb but not in simplefb. Once we have
a u-boot based boot flow, it would be a great help for boot-time
debugging to use earlycon on the framebuffer for those that don't
have a special uart cable.

An alternative would be to rework the simplefb driver in some
form to allow earlycon without efifb. The earlycon support there
is actually fairly simple, but doing this would raise the question
of whether it can be shared between the two and possibly the
drm/kms based drivers.

> - Devicetree for the Mac Mini (should work for the others too at this
>   stage)
>
> The primary pain points of this port are:
>
> - Apple SoCs require FIQs, as the timers and "fast" IPIs are hardwired
>   to the FIQ interrupt line. This patchset introduces FIQ support through
>   the alternatives mechanism, so as to not affect other platforms,
>   implemented as simply merging IRQs and FIQs. The AIC driver takes care
>   of discriminating and routing IRQs to the right users.
>
> - These SoCs blackhole nGnRE writes to internal MMIO ranges, and require
>   nGnRnE. There is no obvious right solution to solve this. I do not
>   expect the two patches for that in this series to be merged as-is, but
>   the commit messages describe the problem and potential solutions. I
>   hope we can have a discussion and converge on the right approach to
>   solve this problem in the sanest way.

I would add here the cpu enable-method as a third point that needs to
be decided on before we can consider merging it. As I commented
in patch 18, staying with spin-table would be the easiest way to start,
but that means the risk of an incompatible DT change later on.

        Arnd
Hector Martin Feb. 5, 2021, 11:35 a.m. UTC | #2
On 05/02/2021 05.39, Hector Martin wrote:
> This series brings up initial support for the Apple M1 SoC, used in the
> 2020 Mac Mini, MacBook Pro, and MacBook Air models.

Forgot to CC: a few folks involved in the previous related thread, 
sorry! Adding them here, hope everyone got the series via the MLs.

v2 will be CCed to everyone else too.