Apple M1 Support
Subsystems (8)
v4 cover Apple M1 Support
This series adds basic support for Apple's M1 SoC to U-Boot. This builds a basic U-Boot that can be used as a payload for the m1n1 boot loader being developed by the Asahi Linux project.
The goal here is to privide an UEFI interface on these machines that allows booting various open source OSes. This initial series provides support for the serial port, framebuffer and the USB 3.1 Type-C ports. It can boot a support OS (e.g. OpenBSD/arm64) from a USB disk.
This version attempts to address most comments. It doesn't add a proper WDT/sysreset driver yet since I prefer to do that once the device tree bindings for that have been ironed out.
ChangeLog:
v2: - Add IOMMU uclass and use it for the DART driver
- Cut back DART driver to only support bypass mode
- Rework the S5P serial support to use more DT stuff
- Update preliminary device trees
v3: - Respin for CONFIG_SYS_LOAD_ADDR kconfig migration
v4: - Copy generic IOMMU DT bindings from Linux
- Explain IOMMU KConfig option
- Rename dev_iommu_probe()
- Indicate how device trees deviate from upstream
- Explain why u-boot-nodtb.bin is used.
Mark Kettenis (7):
iommu: Add IOMMU uclass
test: Add tests for IOMMU uclass
arm: apple: Add initial support for Apple's M1 SoC
serial: s5p: Add Apple M1 support
iommu: Add Apple DART driver
arm: dts: apple: Add preliminary device trees
doc: board: apple: Add Apple M1 documentation
arch/arm/Kconfig | 23 + arch/arm/Makefile | 1 + arch/arm/dts/Makefile | 4 + arch/arm/dts/t8103-j274.dts | 135 +++++ arch/arm/dts/t8103-j293.dts | 97 +++ arch/arm/dts/t8103.dtsi | 560 ++++++++++++++++++ arch/arm/include/asm/arch-m1/uart.h | 41 ++ arch/arm/mach-apple/Kconfig | 18 + arch/arm/mach-apple/Makefile | 4 + arch/arm/mach-apple/board.c | 161 +++++ arch/arm/mach-apple/lowlevel_init.S | 17 + arch/sandbox/dts/test.dts | 6 + configs/apple_m1_defconfig | 20 + configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_noinst_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + doc/board/apple/index.rst | 9 + doc/board/apple/m1.rst | 59 ++ doc/board/index.rst | 1 + doc/device-tree-bindings/iommu/iommu.txt | 206 +++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/core/device.c | 8 + drivers/iommu/Kconfig | 27 + drivers/iommu/Makefile | 6 + drivers/iommu/apple_dart.c | 59 ++ drivers/iommu/iommu-uclass.c | 45 ++ drivers/iommu/sandbox_iommu.c | 18 + drivers/serial/Kconfig | 4 +- drivers/serial/serial_s5p.c | 104 +++- include/configs/apple.h | 36 ++ include/dm/uclass-id.h | 1 + .../interrupt-controller/apple-aic.h | 15 + include/dt-bindings/pinctrl/apple.h | 13 + include/dt-bindings/spmi/spmi.h | 10 + include/iommu.h | 16 + test/dm/Makefile | 1 + test/dm/iommu.c | 28 + 40 files changed, 1737 insertions(+), 24 deletions(-) create mode 100644 arch/arm/dts/t8103-j274.dts create mode 100644 arch/arm/dts/t8103-j293.dts create mode 100644 arch/arm/dts/t8103.dtsi create mode 100644 arch/arm/include/asm/arch-m1/uart.h create mode 100644 arch/arm/mach-apple/Kconfig create mode 100644 arch/arm/mach-apple/Makefile create mode 100644 arch/arm/mach-apple/board.c create mode 100644 arch/arm/mach-apple/lowlevel_init.S create mode 100644 configs/apple_m1_defconfig create mode 100644 doc/board/apple/index.rst create mode 100644 doc/board/apple/m1.rst create mode 100644 doc/device-tree-bindings/iommu/iommu.txt create mode 100644 drivers/iommu/Kconfig create mode 100644 drivers/iommu/Makefile create mode 100644 drivers/iommu/apple_dart.c create mode 100644 drivers/iommu/iommu-uclass.c create mode 100644 drivers/iommu/sandbox_iommu.c create mode 100644 include/configs/apple.h create mode 100644 include/dt-bindings/interrupt-controller/apple-aic.h create mode 100644 include/dt-bindings/pinctrl/apple.h create mode 100644 include/dt-bindings/spmi/spmi.h create mode 100644 include/iommu.h create mode 100644 test/dm/iommu.c
Signature · 1 line
2.33.0
PATCH v4 1/7 iommu: Add IOMMU uclass
This uclass is intended to manage IOMMUs on systems where the IOMMUs are not in bypass mode by default. In that case U-Boot cannot ignore the IOMMUs if it wants to use devices that need to do DMA and sit behind such an IOMMU.
This initial IOMMU uclass implementation does not implement and device ops and is intended for IOMMUs that have a bypass mode that does not require address translation. Support for IOMMUs that do require address translation is planned and device ops will be defined when support for such IOMMUs will be added.
---
ChangeLog:
v4: - Copy generic IOMMU DT bindings from Linux
- Explain IOMMU KConfig option
- Rename dev_iommu_probe()
doc/device-tree-bindings/iommu/iommu.txt | 206 +++++++++++++++++++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/core/device.c | 8 + drivers/iommu/Kconfig | 17 ++ drivers/iommu/Makefile | 3 + drivers/iommu/iommu-uclass.c | 45 +++++ include/dm/uclass-id.h | 1 + include/iommu.h | 16 ++ 9 files changed, 299 insertions(+) create mode 100644 doc/device-tree-bindings/iommu/iommu.txt create mode 100644 drivers/iommu/Kconfig create mode 100644 drivers/iommu/Makefile create mode 100644 drivers/iommu/iommu-uclass.c create mode 100644 include/iommu.h
doc/device-tree-bindings/iommu/iommu.txt new file +206 -0
@@ -0,0 +1,206 @@ +This document describes the generic device tree binding for IOMMUs and their +master(s). + + +IOMMU device node: +================== + +An IOMMU can provide the following services: + +* Remap address space to allow devices to access physical memory ranges that + they otherwise wouldn't be capable of accessing. + + Example: 32-bit DMA to 64-bit physical addresses + +* Implement scatter-gather at page level granularity so that the device does + not have to. + +* Provide system protection against "rogue" DMA by forcing all accesses to go + through the IOMMU and faulting when encountering accesses to unmapped + address regions. + +* Provide address space isolation between multiple contexts. + + Example: Virtualization + +Device nodes compatible with this binding represent hardware with some of the +above capabilities. + +IOMMUs can be single-master or multiple-master. Single-master IOMMU devices +typically have a fixed association to the master device, whereas multiple- +master IOMMU devices can translate accesses from more than one master. + +The device tree node of the IOMMU device's parent bus must contain a valid +"dma-ranges" property that describes how the physical address space of the +IOMMU maps to memory. An empty "dma-ranges" property means that there is a +1:1 mapping from IOMMU to memory. + +Required properties: +-------------------- +- #iommu-cells: The number of cells in an IOMMU specifier needed to encode an + address. + +The meaning of the IOMMU specifier is defined by the device tree binding of +the specific IOMMU. Below are a few examples of typical use-cases: + +- #iommu-cells = <0>: Single master IOMMU devices are not configurable and + therefore no additional information needs to be encoded in the specifier. + This may also apply to multiple master IOMMU devices that do not allow the + association of masters to be configured. Note that an IOMMU can by design + be multi-master yet only expose a single master in a given configuration. + In such cases the number of cells will usually be 1 as in the next case. +- #iommu-cells = <1>: Multiple master IOMMU devices may need to be configured + in order to enable translation for a given master. In such cases the single + address cell corresponds to the master device's ID. In some cases more than + one cell can be required to represent a single master ID. +- #iommu-cells = <4>: Some IOMMU devices allow the DMA window for masters to + be configured. The first cell of the address in this may contain the master + device's ID for example, while the second cell could contain the start of + the DMA window for the given device. The length of the DMA window is given + by the third and fourth cells. + +Note that these are merely examples and real-world use-cases may use different +definitions to represent their individual needs. Always refer to the specific +IOMMU binding for the exact meaning of the cells that make up the specifier. + + +IOMMU master node: +================== + +Devices that access memory through an IOMMU are called masters. A device can +have multiple master interfaces (to one or more IOMMU devices). + +Required properties: +-------------------- +- iommus: A list of phandle and IOMMU specifier pairs that describe the IOMMU + master interfaces of the device. One entry in the list describes one master + interface of the device. + +When an "iommus" property is specified in a device tree node, the IOMMU will +be used for address translation. If a "dma-ranges" property exists in the +device's parent node it will be ignored. An exception to this rule is if the +referenced IOMMU is disabled, in which case the "dma-ranges" property of the +parent shall take effect. Note that merely disabling a device tree node does +not guarantee that the IOMMU is really disabled since the hardware may not +have a means to turn off translation. But it is invalid in such cases to +disable the IOMMU's device tree node in the first place because it would +prevent any driver from properly setting up the translations. + +Optional properties: +-------------------- +- pasid-num-bits: Some masters support multiple address spaces for DMA, by + tagging DMA transactions with an address space identifier. By default, + this is 0, which means that the device only has one address space. + +- dma-can-stall: When present, the master can wait for a transaction to + complete for an indefinite amount of time. Upon translation fault some + IOMMUs, instead of aborting the translation immediately, may first + notify the driver and keep the transaction in flight. This allows the OS + to inspect the fault and, for example, make physical pages resident + before updating the mappings and completing the transaction. Such IOMMU + accepts a limited number of simultaneous stalled transactions before + having to either put back-pressure on the master, or abort new faulting + transactions. + + Firmware has to opt-in stalling, because most buses and masters don't + support it. In particular it isn't compatible with PCI, where + transactions have to complete before a time limit. More generally it + won't work in systems and masters that haven't been designed for + stalling. For example the OS, in order to handle a stalled transaction, + may attempt to retrieve pages from secondary storage in a stalled + domain, leading to a deadlock. + + +Notes: +====== + +One possible extension to the above is to use an "iommus" property along with +a "dma-ranges" property in a bus device node (such as PCI host bridges). This +can be useful to describe how children on the bus relate to the IOMMU if they +are not explicitly listed in the device tree (e.g. PCI devices). However, the +requirements of that use-case haven't been fully determined yet. Implementing +this is therefore not recommended without further discussion and extension of +this binding. + + +Examples: +========= + +Single-master IOMMU: +-------------------- + + iommu { + #iommu-cells = <0>; + }; + + master { + iommus = <&{/iommu}>; + }; + +Multiple-master IOMMU with fixed associations: +---------------------------------------------- + + /* multiple-master IOMMU */ + iommu { + /* + * Masters are statically associated with this IOMMU and share + * the same address translations because the IOMMU does not + * have sufficient information to distinguish between masters. + * + * Consequently address translation is always on or off for + * all masters at any given point in time. + */ + #iommu-cells = <0>; + }; + + /* static association with IOMMU */ + master@1 { + reg = <1>; + iommus = <&{/iommu}>; + }; + + /* static association with IOMMU */ + master@2 { + reg = <2>; + iommus = <&{/iommu}>; + }; + +Multiple-master IOMMU: +---------------------- + + iommu { + /* the specifier represents the ID of the master */ + #iommu-cells = <1>; + }; + + master@1 { + /* device has master ID 42 in the IOMMU */ + iommus = <&{/iommu} 42>; + }; + + master@2 { + /* device has master IDs 23 and 24 in the IOMMU */ + iommus = <&{/iommu} 23>, <&{/iommu} 24>; + }; + +Multiple-master IOMMU with configurable DMA window: +--------------------------------------------------- + + / { + iommu { + /* + * One cell for the master ID and one cell for the + * address of the DMA window. The length of the DMA + * window is encoded in two cells. + * + * The DMA window is the range addressable by the + * master (i.e. the I/O virtual address space). + */ + #iommu-cells = <4>; + }; + + master { + /* master ID 42, 4 GiB DMA window starting at 0 */ + iommus = <&{/iommu} 42 0 0x1 0x0>; + }; + };
drivers/Kconfig +2 -0
@@ -50,6 +50,8 @@ source "drivers/i2c/Kconfig" source "drivers/input/Kconfig" +source "drivers/iommu/Kconfig" + source "drivers/led/Kconfig" source "drivers/mailbox/Kconfig"
drivers/Makefile +1 -0
@@ -102,6 +102,7 @@ obj-y += mtd/ obj-y += pwm/ obj-y += reset/ obj-y += input/ +obj-y += iommu/ # SOC specific infrastructure drivers. obj-y += smem/ obj-y += thermal/
drivers/core/device.c +8 -0
@@ -28,6 +28,7 @@#include <dm/uclass.h> #include <dm/uclass-internal.h> #include <dm/util.h> +#include <iommu.h> #include <linux/err.h> #include <linux/list.h> #include <power-domain.h>
@@ -543,6 +544,13 @@ int device_probe(struct udevice *dev) goto fail; } +if (CONFIG_IS_ENABLED (IOMMU ) && dev->parent && + (device_get_uclass_id (dev) !=UCLASS_IOMMU )) { + ret =dev_iommu_enable (dev); +if (ret) + goto fail; + } + ret =device_get_dma_constraints (dev);if (ret) goto fail;
drivers/iommu/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# IOMMU devices +# + +menu "IOMMU device drivers" + +config IOMMU + bool "Enable Driver Model for IOMMU drivers" + depends on DM + help + Enable driver model for IOMMU devices. An IOMMU maps device + virtiual memory addresses to physical addresses. Devices + that sit behind an IOMMU can typically only access physical + memory if the IOMMU has been programmed to allow access to + that memory. + +endmenu
drivers/iommu/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +45 -0
45 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -62,6 +62,7 @@ enum uclass_id {UCLASS_I2C_MUX ,/* I2C multiplexer */ UCLASS_I2S ,/* I2S bus */ UCLASS_IDE ,/* IDE device */ +UCLASS_IOMMU ,/* IOMMU */ UCLASS_IRQ ,/* Interrupt controller */ UCLASS_KEYBOARD ,/* Keyboard input device */ UCLASS_LED, /* Light-emitting diode (LED) */
include/iommu.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _IOMMU_H +#define _IOMMU_H + +struct udevice ; + +#if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) && \ +CONFIG_IS_ENABLED (IOMMU ) +int dev_iommu_enable (struct udevice *dev); +#else +static inline int dev_iommu_enable (struct udevice *dev) +{ +return 0 ; +} +#endif + +#endif
Signature · 1 line
2.33.0
Re: [PATCH v4 1/7] iommu: Add IOMMU uclass
Quoted 22 lines · Mark Kettenis
This uclass is intended to manage IOMMUs on systems where the IOMMUs are not in bypass mode by default. In that case U-Boot cannot ignore the IOMMUs if it wants to use devices that need to do DMA and sit behind such an IOMMU.
This initial IOMMU uclass implementation does not implement and device ops and is intended for IOMMUs that have a bypass mode that does not require address translation. Support for IOMMUs that do require address translation is planned and device ops will be defined when support for such IOMMUs will be added.
Signed-off-by Mark Kettenis <[email protected]>---
ChangeLog:
v4: - Copy generic IOMMU DT bindings from Linux
- Explain IOMMU KConfig option
- Renamedev_iommu_probe()
Quoted 15 lines
doc/device-tree-bindings/iommu/iommu.txt | 206 +++++++++++++++++++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/core/device.c | 8 + drivers/iommu/Kconfig | 17 ++ drivers/iommu/Makefile | 3 + drivers/iommu/iommu-uclass.c | 45 +++++ include/dm/uclass-id.h | 1 + include/iommu.h | 16 ++ 9 files changed, 299 insertions(+) create mode 100644 doc/device-tree-bindings/iommu/iommu.txt create mode 100644 drivers/iommu/Kconfig create mode 100644 drivers/iommu/Makefile create mode 100644 drivers/iommu/iommu-uclass.c create mode 100644 include/iommu.h
Re: [PATCH v4 1/7] iommu: Add IOMMU uclass
In reply to Mark KettenisQuoted 5 lines · Mark Kettenis
This uclass is intended to manage IOMMUs on systems where the IOMMUs are not in bypass mode by default. In that case U-Boot cannot ignore the IOMMUs if it wants to use devices that need to do DMA and sit behind such an IOMMU.
Quoted 8 lines
This initial IOMMU uclass implementation does not implement and device ops and is intended for IOMMUs that have a bypass mode that does not require address translation. Support for IOMMUs that do require address translation is planned and device ops will be defined when support for such IOMMUs will be added.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 2/7 test: Add tests for IOMMU uclass
In reply to Mark KettenisAdd a set of tests for the IOMMU uclass.
--- arch/sandbox/dts/test.dts | 6 ++++++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_noinst_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + drivers/iommu/Makefile | 2 ++ drivers/iommu/sandbox_iommu.c | 18 ++++++++++++++++++ test/dm/Makefile | 1 + test/dm/iommu.c | 28 ++++++++++++++++++++++++++++ 10 files changed, 60 insertions(+) create mode 100644 drivers/iommu/sandbox_iommu.c create mode 100644 test/dm/iommu.c
arch/sandbox/dts/test.dts +6 -0
@@ -764,6 +764,11 @@ vss-microvolts = <0>; }; + iommu: iommu@0 { + compatible = "sandbox,iommu"; + #iommu-cells = <0>; + }; + irq: irq { compatible = "sandbox,irq"; interrupt-controller;
@@ -1226,6 +1231,7 @@ usb_1: usb@1 { compatible = "sandbox,usb"; + iommus = <&iommu>; hub { compatible = "usb-hub"; usb,device-class = <9>;
configs/sandbox64_defconfig +1 -0
@@ -131,6 +131,7 @@ CONFIG_SPL_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y CONFIG_CROS_EC_KEYB=y CONFIG_I8042_KEYB=y +CONFIG_IOMMU=y CONFIG_LED=y CONFIG_LED_BLINK=y CONFIG_LED_GPIO=y
configs/sandbox_defconfig +1 -0
@@ -169,6 +169,7 @@ CONFIG_SPL_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y CONFIG_CROS_EC_KEYB=y CONFIG_I8042_KEYB=y +CONFIG_IOMMU=y CONFIG_LED=y CONFIG_LED_BLINK=y CONFIG_LED_GPIO=y
configs/sandbox_flattree_defconfig +1 -0
@@ -108,6 +108,7 @@ CONFIG_SPL_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y CONFIG_CROS_EC_KEYB=y CONFIG_I8042_KEYB=y +CONFIG_IOMMU=y CONFIG_LED=y CONFIG_LED_BLINK=y CONFIG_LED_GPIO=y
configs/sandbox_noinst_defconfig +1 -0
@@ -129,6 +129,7 @@ CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y CONFIG_CROS_EC_KEYB=y CONFIG_I8042_KEYB=y +CONFIG_IOMMU=y CONFIG_LED=y CONFIG_LED_BLINK=y CONFIG_LED_GPIO=y
configs/sandbox_spl_defconfig +1 -0
@@ -131,6 +131,7 @@ CONFIG_I2C_MUX=y CONFIG_I2C_ARB_GPIO_CHALLENGE=y CONFIG_CROS_EC_KEYB=y CONFIG_I8042_KEYB=y +CONFIG_IOMMU=y CONFIG_LED=y CONFIG_LED_BLINK=y CONFIG_LED_GPIO=y
drivers/iommu/Makefile +2 -0
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_IOMMU) += iommu-uclass.o + +obj-$(CONFIG_SANDBOX) += sandbox_iommu.o
drivers/iommu/sandbox_iommu.c new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 Mark Kettenis <[email protected]> +*/ + +#include <common.h> +#include <dm.h> + +static const struct udevice_id sandbox_iommu_ids[] = { + { .compatible ="sandbox,iommu" }, + {/* sentinel */ } +}; + +U_BOOT_DRIVER (sandbox_iommu) = { + .name ="sandbox_iommu" , + .id =UCLASS_IOMMU , + .of_match = sandbox_iommu_ids, +};
test/dm/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_SOUND) += i2s.o obj-y += irq.o obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o +obj-$(CONFIG_IOMMU) += iommu.o obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MAILBOX) += mailbox.o obj-$(CONFIG_DM_MDIO) += mdio.o
test/dm/iommu.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 Mark Kettenis <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <dm/uclass-internal.h> +#include <iommu.h> +#include <test/test.h> +#include <test/ut.h> + +static int dm_test_iommu (struct unit_test_state *uts) +{ +struct udevice *dev; + +ut_assertok (uclass_find_device (UCLASS_IOMMU ,0 , &dev)); +ut_assert (!(dev_get_flags (dev) &DM_FLAG_ACTIVATED )); + +/* Probing USB probes the IOMMU through the "iommus" property */ +ut_assertok (uclass_probe_all (UCLASS_USB )); +ut_assert (dev_get_flags (dev) &DM_FLAG_ACTIVATED ); + +return 0 ; +} + +DM_TEST (dm_test_iommu,UT_TESTF_SCAN_FDT );
Signature · 1 line
2.33.0
Re: [PATCH v4 2/7] test: Add tests for IOMMU uclass
Quoted 4 lines · Mark Kettenis
Add a set of tests for the IOMMU uclass.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 3/7 arm: apple: Add initial support for Apple's M1 SoC
In reply to Mark KettenisAdd support for Apple's M1 SoC that is used in "Apple Silicon" Macs. This builds a basic U-Boot that can be used as a payload for the m1n1 boot loader being developed by the Asahi Linux project.
--- arch/arm/Kconfig | 21 ++++ arch/arm/Makefile | 1 + arch/arm/mach-apple/Kconfig | 18 ++++ arch/arm/mach-apple/Makefile | 4 + arch/arm/mach-apple/board.c | 161 ++++++++++++++++++++++++++++ arch/arm/mach-apple/lowlevel_init.S | 17 +++ configs/apple_m1_defconfig | 15 +++ include/configs/apple.h | 36 +++++++ 8 files changed, 273 insertions(+) create mode 100644 arch/arm/mach-apple/Kconfig create mode 100644 arch/arm/mach-apple/Makefile create mode 100644 arch/arm/mach-apple/board.c create mode 100644 arch/arm/mach-apple/lowlevel_init.S create mode 100644 configs/apple_m1_defconfig create mode 100644 include/configs/apple.h
arch/arm/Kconfig +21 -0
@@ -922,6 +922,25 @@ config ARCH_NEXELL select DM select GPIO_EXTRA_HEADER +config ARCH_APPLE + bool "Apple SoCs" + select ARM64 + select BLK + select CMD_USB + select DM + select DM_KEYBOARD + select DM_SERIAL + select DM_USB + select DM_VIDEO + select LINUX_KERNEL_IMAGE_HEADER + select OF_CONTROL + select OF_BOARD + select POSITION_INDEPENDENT + select USB + imply CMD_DM + imply CMD_GPT + imply DISTRO_DEFAULTS + config ARCH_OWL bool "Actions Semi OWL SoCs" select DM
@@ -2016,6 +2035,8 @@ config ISW_ENTRY_ADDR image headers. endif +source "arch/arm/mach-apple/Kconfig" + source "arch/arm/mach-aspeed/Kconfig" source "arch/arm/mach-at91/Kconfig"
arch/arm/Makefile +1 -0
@@ -55,6 +55,7 @@ PLATFORM_CPPFLAGS += $(arch-y) $(tune-y) # Machine directory name. This list is sorted alphanumerically # by CONFIG_* macro name. +machine-$(CONFIG_ARCH_APPLE) += apple machine-$(CONFIG_ARCH_ASPEED) += aspeed machine-$(CONFIG_ARCH_AT91) += at91 machine-$(CONFIG_ARCH_BCM283X) += bcm283x
arch/arm/mach-apple/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +if ARCH_APPLE + +config SYS_TEXT_BASE + default 0x00000000 + +config SYS_CONFIG_NAME + default "apple" + +config SYS_SOC + default "m1" + +config SYS_MALLOC_LEN + default 0x4000000 + +config SYS_MALLOC_F_LEN + default 0x4000 + +endif
arch/arm/mach-apple/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += board.o +obj-y += lowlevel_init.o
arch/arm/mach-apple/board.c new file +161 -0
161 lines not on this page · raw message
arch/arm/mach-apple/lowlevel_init.S new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2021 Mark Kettenis <[email protected]> + */ + +.align 8 +.global fw_dtb_pointer +fw_dtb_pointer: + .quad 0 + +.global save_boot_params +save_boot_params: + /* Stash DTB pointer passed by m1n1 */ + adr x1, fw_dtb_pointer + str x0, [x1] + + b save_boot_params_ret
configs/apple_m1_defconfig new file +15 -0
@@ -0,0 +1,15 @@ +CONFIG_ARM=y +CONFIG_ARCH_APPLE=y +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_MMC is not set +# CONFIG_NET is not set +CONFIG_VIDEO_SIMPLE=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_STORAGE=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="usb start" +CONFIG_SYS_LOAD_ADDR=0x880000000 +# CONFIG_GENERATE_SMBIOS_TABLE is not set
include/configs/apple.h new file +36 -0
@@ -0,0 +1,36 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +#include <linux/sizes.h> + +#define CONFIG_SYS_SDRAM_BASE 0x880000000 + +#define CONFIG_LNX_KRNL_IMG_TEXT_OFFSET_BASE CONFIG_SYS_TEXT_BASE + +/* Environment */ +#define ENV_DEVICE_SETTINGS \ + "stdin=serial,usbkbd\0" \ + "stdout=serial,vidconsole\0" \ + "stderr=serial,vidconsole\0" + +#define ENV_MEM_LAYOUT_SETTINGS \ + "fdt_addr_r=0x960100000\0" \ + "kernel_addr_r=0x960200000\0" + +#if CONFIG_IS_ENABLED (CMD_USB ) +#define BOOT_TARGET_USB (func) func(USB, usb, 0) +#else +#define BOOT_TARGET_USB (func) +#endif + +#define BOOT_TARGET_DEVICES (func) \ + BOOT_TARGET_USB(func) + +#include <config_distro_bootcmd.h> + +#define CONFIG_EXTRA_ENV_SETTINGS \ + ENV_DEVICE_SETTINGS \ + ENV_MEM_LAYOUT_SETTINGS \ + BOOTENV + +#endif
Signature · 1 line
2.33.0
Re: [PATCH v4 3/7] arm: apple: Add initial support for Apple's M1 SoC
Quoted 7 lines · Mark Kettenis
Add support for Apple's M1 SoC that is used in "Apple Silicon" Macs. This builds a basic U-Boot that can be used as a payload for the m1n1 boot loader being developed by the Asahi Linux project.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
After adding a MAINTAINERS entry, applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 4/7 serial: s5p: Add Apple M1 support
In reply to Mark KettenisApple M1 SoCs include an S5L UART which is a variant of the S5P UART. Add support for this variant and enable it by default on Apple SoCs.
--- arch/arm/Kconfig | 1 + arch/arm/include/asm/arch-m1/uart.h | 41 +++++++++++ configs/apple_m1_defconfig | 4 ++ drivers/serial/Kconfig | 4 +- drivers/serial/serial_s5p.c | 104 ++++++++++++++++++++++------ 5 files changed, 130 insertions(+), 24 deletions(-) create mode 100644 arch/arm/include/asm/arch-m1/uart.h
arch/arm/Kconfig +1 -0
@@ -926,6 +926,7 @@ config ARCH_APPLE bool "Apple SoCs" select ARM64 select BLK + select CLK select CMD_USB select DM select DM_KEYBOARD
arch/arm/include/asm/arch-m1/uart.h new file +41 -0
41 lines not on this page · raw message
configs/apple_m1_defconfig +4 -0
@@ -13,3 +13,7 @@ CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="usb start" CONFIG_SYS_LOAD_ADDR=0x880000000 # CONFIG_GENERATE_SMBIOS_TABLE is not set +CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_DEBUG_UART_BASE=0x235200000 +CONFIG_DEBUG_UART_CLOCK=240000
drivers/serial/Kconfig +2 -2
@@ -290,7 +290,7 @@ config DEBUG_SBI_CONSOLE config DEBUG_UART_S5P bool "Samsung S5P" - depends on ARCH_EXYNOS || ARCH_S5PC1XX + depends on ARCH_APPLE || ARCH_EXYNOS || ARCH_S5PC1XX help Select this to enable a debug UART using the serial_s5p driver. You will need to provide parameters to make this work. The driver will
@@ -737,7 +737,7 @@ config ROCKCHIP_SERIAL config S5P_SERIAL bool "Support for Samsung S5P UART" - depends on ARCH_EXYNOS || ARCH_S5PC1XX + depends on ARCH_APPLE || ARCH_EXYNOS || ARCH_S5PC1XX default y help Select this to enable Samsung S5P UART support.
drivers/serial/serial_s5p.c +82 -22
201 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH v4 4/7] serial: s5p: Add Apple M1 support
Quoted 6 lines · Mark Kettenis
Apple M1 SoCs include an S5L UART which is a variant of the S5P UART. Add support for this variant and enable it by default on Apple SoCs.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 5/7 iommu: Add Apple DART driver
In reply to Mark KettenisThe DART is an IOMMU that is used on Apple's M1 SoC. This driver configures the DART such that it operates in bypass mode which is enough to support DMA for the USB3 ports integrated on the SoC.
--- arch/arm/Kconfig | 1 + drivers/iommu/Kconfig | 10 +++++++ drivers/iommu/Makefile | 1 + drivers/iommu/apple_dart.c | 59 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 drivers/iommu/apple_dart.c
arch/arm/Kconfig +1 -0
@@ -933,6 +933,7 @@ config ARCH_APPLE select DM_SERIAL select DM_USB select DM_VIDEO + select IOMMU select LINUX_KERNEL_IMAGE_HEADER select OF_CONTROL select OF_BOARD
drivers/iommu/Kconfig +10 -0
@@ -14,4 +14,14 @@ config IOMMU memory if the IOMMU has been programmed to allow access to that memory. +config APPLE_DART + bool "Apple DART support" + depends on IOMMU && ARCH_APPLE + default y + help + Enable support for the DART on Apple SoCs. The DART is Apple's + IOMMU implementation. The driver performs the necessary + configuration to put the DART into bypass mode such that it can + be used transparently by U-Boot. + endmenu
drivers/iommu/Makefile +1 -0
@@ -2,4 +2,5 @@ obj-$(CONFIG_IOMMU) += iommu-uclass.o +obj-$(CONFIG_APPLE_DART) += apple_dart.o obj-$(CONFIG_SANDBOX) += sandbox_iommu.o
drivers/iommu/apple_dart.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.33.0
Re: [PATCH v4 5/7] iommu: Add Apple DART driver
Quoted 6 lines · Mark Kettenis
The DART is an IOMMU that is used on Apple's M1 SoC. This driver configures the DART such that it operates in bypass mode which is enough to support DMA for the USB3 ports integrated on the SoC.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 6/7 arm: dts: apple: Add preliminary device trees
In reply to Mark KettenisAdd preliminary device trees for the Apple M1 mini (2020) and Apple M1 Macbook Pro 13" (2020). Device tree bindings for the Apple M1 SoC are still being formalized and these device trees will be synchronized with the Linux kernel as needed.
The device trees in this commit are based on the initial Apple M1 device trees from Linux 5.13, nodes for dart, pcie, pinctrl, pmgr, usb based on bindings on track for inclusion in Linux 5.15 and 5.16 and nodes for i2c, mailbox, nvme, pmu, spmi and watchdog that don't have a proposed binding yet.
These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.
---
ChangeLog:
v4: - Indicate how device trees deviate from upstream
arch/arm/dts/Makefile | 4 + arch/arm/dts/t8103-j274.dts | 135 +++++ arch/arm/dts/t8103-j293.dts | 97 +++ arch/arm/dts/t8103.dtsi | 560 ++++++++++++++++++ configs/apple_m1_defconfig | 1 + .../interrupt-controller/apple-aic.h | 15 + include/dt-bindings/pinctrl/apple.h | 13 + include/dt-bindings/spmi/spmi.h | 10 + 8 files changed, 835 insertions(+) create mode 100644 arch/arm/dts/t8103-j274.dts create mode 100644 arch/arm/dts/t8103-j293.dts create mode 100644 arch/arm/dts/t8103.dtsi create mode 100644 include/dt-bindings/interrupt-controller/apple-aic.h create mode 100644 include/dt-bindings/pinctrl/apple.h create mode 100644 include/dt-bindings/spmi/spmi.h
arch/arm/dts/Makefile +4 -0
@@ -29,6 +29,10 @@ dtb-$(CONFIG_EXYNOS5) += exynos5250-arndale.dtb \ exynos5422-odroidxu3.dtb dtb-$(CONFIG_EXYNOS7420) += exynos7420-espresso7420.dtb +dtb-$(CONFIG_ARCH_APPLE) += \ + t8103-j274.dtb \ + t8103-j293.dtb + dtb-$(CONFIG_ARCH_DAVINCI) += \ da850-evm.dtb \ da850-lcdk.dtb \
arch/arm/dts/t8103-j274.dts new file +135 -0
135 lines not on this page · raw message
arch/arm/dts/t8103-j293.dts new file +97 -0
97 lines not on this page · raw message
arch/arm/dts/t8103.dtsi new file +560 -0
560 lines not on this page · raw message
configs/apple_m1_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_APPLE=y +CONFIG_DEFAULT_DEVICE_TREE="t8103-j274" # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_MMC is not set # CONFIG_NET is not set
include/dt-bindings/interrupt-controller/apple-aic.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H + +#include <dt-bindings/interrupt-controller/irq.h> + +#define AIC_IRQ 0 +#define AIC_FIQ 1 + +#define AIC_TMR_HV_PHYS 0 +#define AIC_TMR_HV_VIRT 1 +#define AIC_TMR_GUEST_PHYS 2 +#define AIC_TMR_GUEST_VIRT 3 + +#endif
include/dt-bindings/pinctrl/apple.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR MIT */ +/* +* This header provides constants for Apple pinctrl bindings. +*/ + +#ifndef _DT_BINDINGS_PINCTRL_APPLE_H +#define _DT_BINDINGS_PINCTRL_APPLE_H + +#define APPLE_PINMUX (pin, func) ((pin) | ((func) << 16)) +#define APPLE_PIN (pinmux) ((pinmux) & 0xffff) +#define APPLE_FUNC (pinmux) ((pinmux) >> 16) + +#endif /* _DT_BINDINGS_PINCTRL_APPLE_H */
include/dt-bindings/spmi/spmi.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +*/ +#ifndef __DT_BINDINGS_SPMI_H +#define __DT_BINDINGS_SPMI_H + +#define SPMI_USID 0 +#define SPMI_GSID 1 + +#endif
Signature · 1 line
2.33.0
Re: [PATCH v4 6/7] arm: dts: apple: Add preliminary device trees
Quoted 11 lines · Mark Kettenis
Add preliminary device trees for the Apple M1 mini (2020) and Apple M1 Macbook Pro 13" (2020). Device tree bindings for the Apple M1 SoC are still being formalized and these device trees will be synchronized with the Linux kernel as needed.
The device trees in this commit are based on the initial Apple M1 device trees from Linux 5.13, nodes for dart, pcie, pinctrl, pmgr, usb based on bindings on track for inclusion in Linux 5.15 and 5.16 and nodes for i2c, mailbox, nvme, pmu, spmi and watchdog that don't have a proposed binding yet.
Quoted 5 lines
These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v4 7/7 doc: board: apple: Add Apple M1 documentation
In reply to Mark KettenisProvide preliminary instructions on how to get U-Boot to run on Apple Silicon Macs.
---
ChangeLog:
v4:- Explain why u-boot-nodtb.bin is used.
doc/board/apple/index.rst | 9 ++++++ doc/board/apple/m1.rst | 59 +++++++++++++++++++++++++++++++++++++++ doc/board/index.rst | 1 + 3 files changed, 69 insertions(+) create mode 100644 doc/board/apple/index.rst create mode 100644 doc/board/apple/m1.rst
doc/board/apple/index.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Apple +===== + +.. toctree:: + :maxdepth: 2 + + m1
doc/board/apple/m1.rst new file +59 -0
59 lines not on this page · raw message
doc/board/index.rst +1 -0
@@ -10,6 +10,7 @@ Board-specific doc advantech/index AndesTech/index amlogic/index + apple/index atmel/index congatec/index coreboot/index
Signature · 1 line
2.33.0
Re: [PATCH v4 7/7] doc: board: apple: Add Apple M1 documentation
Quoted 5 lines · Mark Kettenis
Provide preliminary instructions on how to get U-Boot to run on Apple Silicon Macs.
Signed-off-by Mark Kettenis <[email protected]>Reviewed-by Simon Glass <[email protected]
Applied to u-boot/master, thanks!
Signature · 1 line
Tom