Skip to contentSkip to conversation

Apple M1 Support

PATCH Superseded Mark Kettenis 5 participants 32 messages Oct 3, 2021 – Oct 15, 2021

Subsystems (8)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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

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                    |  19 +
 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                        |  56 ++
 doc/board/index.rst                           |   1 +
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 drivers/core/device.c                         |   8 +
 drivers/iommu/Kconfig                         |  23 +
 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                       |  38 ++
 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 +
 39 files changed, 1525 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 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
#1 lore raw

PATCH v2 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+		if (ret)
+			goto fail;
+	}
+
 	ret = device_get_dma_constraints(dev);
 	if (ret)
 		goto fail;
drivers/iommu/Kconfig new file +13 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# 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.
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -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
index e7edd409f3..56aa981613 100644
@@ -61,6 +61,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
new file mode 100644
index 0000000000..d17a06a6f3
@@ -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_probe(struct udevice *dev);
+#else
+static inline int dev_iommu_probe(struct udevice *dev)
+{
+	return 0;
+}
+#endif
+
+#endif
Signature · 1 line
2.33.0
#2 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Hi Mark,

Quoted 86 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +1 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#

drivers/iommu/Kconfig line 11

Quoted 10 lines
drivers/iommu/Kconfig new file +10 -0
+# 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.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Quoted 19 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +2 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*

drivers/iommu/iommu-uclass.c line 12

Quoted 10 lines
drivers/iommu/iommu-uclass.c new file +10 -0
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 61 lines
drivers/iommu/iommu-uclass.c new file +26 -0
+       for (i = 0; i < count; i++) {
+               ret = dev_read_phandle_with_args(dev, "iommus",
+                                                "#iommu-cells", 0, i, &args);
+               if (ret) {
+                       debug("%s: dev_read_phandle_with_args failed: %d\n",
+                             __func__, ret);
+                       return ret;
+               }
+
+               ret = uclass_get_device_by_ofnode(UCLASS_IOMMU, args.node,
+                                                 &dev_iommu);
+               if (ret) {
+                       debug("%s: uclass_get_device_by_ofnode failed: %d\n",
+                             __func__, ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+#endif
+
+UCLASS_DRIVER(iommu) = {
+       .id             = UCLASS_IOMMU,
+       .name           = "iommu",
+};
include/dm/uclass-id.h +1 -0
index e7edd409f3..56aa981613 100644
@@ -61,6 +61,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 -1
new file mode 100644
index 0000000000..d17a06a6f3
@@ -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_probe(struct udevice *dev);
+#else
+static inline int dev_iommu_probe(struct udevice *dev)
+{
+       return 0;
+}
+#endif
+
+#endif
--
Quoted 2 lines

2.33.0

Regards,
Simon

#3 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Quoted 97 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

Quoted 67 lines
Quoted 61 lines
drivers/iommu/iommu-uclass.c new file +26 -0
+       for (i = 0; i < count; i++) {
+               ret = dev_read_phandle_with_args(dev, "iommus",
+                                                "#iommu-cells", 0, i, &args);
+               if (ret) {
+                       debug("%s: dev_read_phandle_with_args failed: %d\n",
+                             __func__, ret);
+                       return ret;
+               }
+
+               ret = uclass_get_device_by_ofnode(UCLASS_IOMMU, args.node,
+                                                 &dev_iommu);
+               if (ret) {
+                       debug("%s: uclass_get_device_by_ofnode failed: %d\n",
+                             __func__, ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+#endif
+
+UCLASS_DRIVER(iommu) = {
+       .id             = UCLASS_IOMMU,
+       .name           = "iommu",
+};
include/dm/uclass-id.h +1 -0
index e7edd409f3..56aa981613 100644
@@ -61,6 +61,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 -1
new file mode 100644
index 0000000000..d17a06a6f3
@@ -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_probe(struct udevice *dev);
+#else
+static inline int dev_iommu_probe(struct udevice *dev)
+{
+       return 0;
+}
+#endif
+
+#endif
--
Quoted 2 lines

2.33.0

Regards,
Simon

#4 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Hi Mark,

Quoted 157 lines · Mark Kettenis
Quoted 98 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 5 lines

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

We do plan to sync these at some point, so don't worry about that. We have bigger problems than the bindings.

But without this it is not discoverable in U-Boot so no one knows what the driver is referring to.

Regards,
Simon

#5 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Quoted 163 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:20:21 -0600

Hi Mark,

Quoted 157 lines · Mark Kettenis
Quoted 98 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 8 lines
Quoted 5 lines

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

We do plan to sync these at some point, so don't worry about that. We have bigger problems than the bindings.

Well, at this point they're so much out of date that I don't look there unless I'm looking for someting that I know to be u-boot specific.

Quoted 2 lines

But without this it is not discoverable in U-Boot so no one knows what the driver is referring to.

Really? The canonical place for device tree bindings that aren't part of the device tree specification itself *is* the Linux kernel tree.

#6 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Hi Mark,

Quoted 177 lines · Mark Kettenis
Quoted 164 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:20:21 -0600

Hi Mark,

Quoted 157 lines · Mark Kettenis
Quoted 98 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 8 lines
Quoted 5 lines

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

We do plan to sync these at some point, so don't worry about that. We have bigger problems than the bindings.

Well, at this point they're so much out of date that I don't look there unless I'm looking for someting that I know to be u-boot specific.

Quoted 5 lines
Quoted 2 lines

But without this it is not discoverable in U-Boot so no one knows what the driver is referring to.

Really? The canonical place for device tree bindings that aren't part of the device tree specification itself *is* the Linux kernel tree.

Yes please, these should be in the U-Boot tree at this point. If they move out of the kernel into some other repo then we can revisit it. I don't really understand your reluctance. I hope that what you say will be true at some point, but as you probably know there are some U-Boot bindings which are not in that repo.

Regards,
Simon

#7 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Quoted 186 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:55:19 -0600

Hi Mark,

Quoted 180 lines · Mark Kettenis
Quoted 164 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:20:21 -0600

Hi Mark,

Quoted 157 lines · Mark Kettenis
Quoted 98 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 8 lines
Quoted 5 lines

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

We do plan to sync these at some point, so don't worry about that. We have bigger problems than the bindings.

Well, at this point they're so much out of date that I don't look there unless I'm looking for someting that I know to be u-boot specific.

Quoted 2 lines

But without this it is not discoverable in U-Boot so no one knows what the driver is referring to.

Quoted 8 lines
Quoted 2 lines

Really? The canonical place for device tree bindings that aren't part of the device tree specification itself *is* the Linux kernel tree.

Yes please, these should be in the U-Boot tree at this point. If they move out of the kernel into some other repo then we can revisit it. I don't really understand your reluctance. I hope that what you say will be true at some point, but as you probably know there are some U-Boot bindings which are not in that repo.

Should I still add my Signed-off-by on files copied verbatim from the Linux kernel sources?

#8 lore raw

Re: [PATCH v2 1/7] iommu: Add IOMMU uclass

Hi Mark,

Quoted 190 lines · Mark Kettenis
Quoted 190 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:55:19 -0600

Hi Mark,

Quoted 182 lines · Mark Kettenis
Quoted 164 lines

From: Simon Glass <[email protected]>
Date: Thu, 14 Oct 2021 14:20:21 -0600

Hi Mark,

Quoted 157 lines · Mark Kettenis
Quoted 98 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:34 -0600

Hi Mark,

Quoted 91 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.

---
 drivers/Kconfig              |  2 ++
 drivers/Makefile             |  1 +
 drivers/core/device.c        |  8 +++++++
 drivers/iommu/Kconfig        | 13 +++++++++++
 drivers/iommu/Makefile       |  3 +++
 drivers/iommu/iommu-uclass.c | 45 ++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |  1 +
 include/iommu.h              | 16 +++++++++++++
 8 files changed, 89 insertions(+)
 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
drivers/Kconfig +2 -0
index 417d6f88c2..b26ca8cf70 100644
@@ -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
index fd218c9056..166aeb9817 100644
@@ -109,6 +109,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
index 29668f6fb3..5f480ad443 100644
@@ -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_probe(dev);
+               if (ret)
+                       goto fail;
+       }
+
        ret = device_get_dma_constraints(dev);
        if (ret)
                goto fail;
drivers/iommu/Kconfig new file +6 -0
new file mode 100644
index 0000000000..8cb377560e
@@ -0,0 +1,13 @@
+#
+# IOMMU devices
+#
+
+menu "IOMMU device drivers"
+
Quoted 8 lines

drivers/iommu/Kconfig line 11

Quoted 5 lines
drivers/iommu/Kconfig new file +5 -0
+config IOMMU
+       bool "Enable Driver Model for IOMMU drivers"
+       depends on DM
+       help
+         Enable driver model for IOMMU devices.

Need at least three lines. What is an IOMMU? How does it relate to other devices?

Not sure if I can describe what an IOMMU is in just a few lines, but I'll try.

Quoted 25 lines
Quoted 25 lines
drivers/iommu/Kconfig new file +2 -0
+
+endmenu
drivers/iommu/Makefile new file +3 -0
new file mode 100644
index 0000000000..f1ceb10150
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_IOMMU) += iommu-uclass.o
drivers/iommu/iommu-uclass.c new file +8 -0
new file mode 100644
index 0000000000..5c55df3066
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <[email protected]>
+ */
+
+#define LOG_CATEGORY UCLASS_IOMMU
+
+#include <common.h>
Quoted 8 lines

drivers/iommu/iommu-uclass.c line 12

Quoted 4 lines
drivers/iommu/iommu-uclass.c new file +4 -0
+#include <dm.h>
+
+#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+int dev_iommu_probe(struct udevice *dev)

Can we rename to dev_iommus_enable()? I like to keep probe for use by DM itself so it is confusing to talk about probing in a context other than probing a single device.

Sure. That was one of the names I considered myself when writing the code.

Quoted 9 lines

drivers/iommu/iommu-uclass.c line 19

Quoted 7 lines
drivers/iommu/iommu-uclass.c new file +7 -0
+{
+       struct ofnode_phandle_args args;
+       struct udevice *dev_iommu;
+       int i, count, ret = 0;
+
+       count = dev_count_phandle_with_args(dev, "iommus",
+                                           "#iommu-cells", 0);

Do you have a binding file you can add to docs/device-tree-bindings ?

Quoted 8 lines
Quoted 5 lines

The binding is available in Documentation/bindings/iommu/iommu.txt in the Linux tree. But I don't think copying it into the u-boot tree makes sense. It will just get out of date. Especially because this will hopefully be converted into a proper DT schema in the near future.

We do plan to sync these at some point, so don't worry about that. We have bigger problems than the bindings.

Well, at this point they're so much out of date that I don't look there unless I'm looking for someting that I know to be u-boot specific.

Quoted 2 lines

But without this it is not discoverable in U-Boot so no one knows what the driver is referring to.

Really? The canonical place for device tree bindings that aren't part of the device tree specification itself *is* the Linux kernel tree.

Quoted 8 lines
Quoted 5 lines

Yes please, these should be in the U-Boot tree at this point. If they move out of the kernel into some other repo then we can revisit it. I don't really understand your reluctance. I hope that what you say will be true at some point, but as you probably know there are some U-Boot bindings which are not in that repo.

Should I still add my Signed-off-by on files copied verbatim from the Linux kernel sources?

Yes that's my understanding..."The Signed-off-by: tag indicates that the signer was involved in the development of the patch, or that he/she was in the patch's delivery path"

That's why I sometimes add a tag when applying a patch, e.g. if I make a minor tweak.

Regards,
Simon

#9 lore raw

PATCH v2 2/7 test: Add tests for IOMMU uclass

In reply to Mark Kettenis

Add 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
index 962bdbe556..ce561c17ef 100644
@@ -752,6 +752,11 @@
 		vss-microvolts = <0>;
 	};
 
+	iommu: iommu@0 {
+		compatible = "sandbox,iommu";
+		#iommu-cells = <0>;
+	};
+
 	irq: irq {
 		compatible = "sandbox,irq";
 		interrupt-controller;
@@ -1199,6 +1204,7 @@
 
 	usb_1: usb@1 {
 		compatible = "sandbox,usb";
+		iommus = <&iommu>;
 		hub {
 			compatible = "usb-hub";
 			usb,device-class = <9>;
configs/sandbox64_defconfig +1 -0
index f7098b4969..54893dc303 100644
@@ -129,6 +129,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
index ea08a9e5bd..e7726b6de9 100644
@@ -166,6 +166,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
index a6e2544dc1..fc831253ec 100644
@@ -106,6 +106,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
index 88443f5ab2..d1b82821eb 100644
@@ -125,6 +125,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
index 77dd83cf6f..d91cac492b 100644
@@ -127,6 +127,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
index f1ceb10150..af1c6bbb7a 100644
@@ -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
new file mode 100644
index 0000000000..c8161a40ae
@@ -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
index 55162e9499..7de013f636 100644
@@ -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
new file mode 100644
index 0000000000..94174a7482
@@ -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
Reviewed-by on v2 2/7
#10 lore raw

Re: [PATCH v2 2/7] test: Add tests for IOMMU uclass

Quoted 4 lines · Mark Kettenis

Add a set of tests for the IOMMU uclass.

Quoted 15 lines
---
 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

You could add the CONFIG options to sandbox's Kconfig in arch/Kconfig

#11 lore raw

Re: [PATCH v2 2/7] test: Add tests for IOMMU uclass

Quoted 24 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:36 -0600

Quoted 4 lines · Mark Kettenis

Add a set of tests for the IOMMU uclass.

Quoted 15 lines
---
 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
Quoted 3 lines

You could add the CONFIG options to sandbox's Kconfig in arch/Kconfig

The codebase is a bit inconsistent in that respect isn't it?

#12 lore raw

Re: [PATCH v2 2/7] test: Add tests for IOMMU uclass

Hi Mark,

Quoted 25 lines · Mark Kettenis
Quoted 25 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:36 -0600

Quoted 19 lines · Mark Kettenis

Add 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
Quoted 5 lines
Quoted 3 lines

You could add the CONFIG options to sandbox's Kconfig in arch/Kconfig

The codebase is a bit inconsistent in that respect isn't it?

Do you mean sometimes it is in defconfig and sometimes in Kconfig? Yes.

For the sandbox board, we try to enable everything
For the other boards that use the sandbox arch, we have to enable what is needed to run tests, but not necessarily every feature

Regards,
Simon

#13 lore raw

PATCH v2 3/7 arm: apple: Add initial support for Apple's M1 SoC

In reply to 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.

---
 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          |  14 +++
 include/configs/apple.h             |  38 +++++++
 8 files changed, 274 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
index b5bd3284cd..4948dad4df 100644
@@ -895,6 +895,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
@@ -1932,6 +1951,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
index c68e598a67..44178c204b 100644
@@ -51,6 +51,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
new file mode 100644
index 0000000000..66cab91b2a
@@ -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
new file mode 100644
index 0000000000..e74a8c9df1
@@ -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
new file mode 100644
index 0000000000..e1c0d91cef
@@ -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 +14 -0
new file mode 100644
index 0000000000..a7ae15576b
@@ -0,0 +1,14 @@
+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_GENERATE_SMBIOS_TABLE is not set
include/configs/apple.h new file +38 -0
new file mode 100644
index 0000000000..1c246af002
@@ -0,0 +1,38 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_LOAD_ADDR	0x880000000
+
+#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
Reviewed-by on v2 3/7
#14 lore raw

Re: [PATCH v2 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.

Quoted 16 lines
---
 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          |  14 +++
 include/configs/apple.h             |  38 +++++++
 8 files changed, 274 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

As mentioned, please convert to a sysreset driver soon, before the release.

#15 lore raw

PATCH v2 4/7 serial: s5p: Add Apple M1 support

In reply to 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.

---
 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
index 4948dad4df..876d9c4044 100644
@@ -899,6 +899,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
index a7ae15576b..674b74b90b 100644
@@ -12,3 +12,7 @@ CONFIG_USB_STORAGE=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="usb start"
 # 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
index 93348c0929..033d160579 100644
@@ -272,7 +272,7 @@ config DEBUG_EFI_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
@@ -719,7 +719,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
Reviewed-by on v2 4/7
#16 lore raw

Re: [PATCH v2 4/7] serial: s5p: Add Apple M1 support

Hi Mark,

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.

Quoted 9 lines
---
 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
Quoted 4 lines
drivers/serial/serial_s5p.c +0 -0
index 6d09952a5d..53a7b0bd1b 100644

[..]

drivers/serial/serial_s5p.c int s5p_serial_setbrg(struct udevice *dev, int baudrate) · line 119

Quoted 6 lines
drivers/serial/serial_s5p.c +1 -1
@@ -93,7 +116,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
        struct s5p_uart *const uart = plat->reg;
        u32 uclk;
 
-#ifdef CONFIG_CLK_EXYNOS
+#if CONFIG_IS_ENABLED(CLK_EXYNOS) || CONFIG_IS_ENABLED(ARCH_APPLE)

I really don't like making this any worse.

Does this work?

ret = clk_get_by_index(...)
if (ret && ret != -ENOSYS)
return ret

drivers/serial/serial_s5p.c int s5p_serial_setbrg(struct udevice *dev, int baudrate) · line 134

Quoted 12 lines
drivers/serial/serial_s5p.c +1 -1
        struct clk clk;
        u32 ret;
 
@@ -105,7 +128,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
        uclk = get_uart_clk(plat->port_id);
 #endif
 
-       s5p_serial_baud(uart, uclk, baudrate);
+       s5p_serial_baud(uart, plat->reg_width, uclk, baudrate);
 
        return 0;
 }

[..]

Regards,
Simon

#17 lore raw

Re: [PATCH v2 4/7] serial: s5p: Add Apple M1 support

Quoted 39 lines

From: Simon Glass <[email protected]>
Date: Mon, 11 Oct 2021 11:00:39 -0600

Hi Mark,

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.

Quoted 9 lines
---
 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
Quoted 4 lines
drivers/serial/serial_s5p.c +0 -0
index 6d09952a5d..53a7b0bd1b 100644

[..]

drivers/serial/serial_s5p.c int s5p_serial_setbrg(struct udevice *dev, int baudrate) · line 119

Quoted 6 lines
drivers/serial/serial_s5p.c +1 -1
@@ -93,7 +116,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
        struct s5p_uart *const uart = plat->reg;
        u32 uclk;
 
-#ifdef CONFIG_CLK_EXYNOS
+#if CONFIG_IS_ENABLED(CLK_EXYNOS) || CONFIG_IS_ENABLED(ARCH_APPLE)

I really don't like making this any worse.

Quoted 5 lines

Does this work?

ret = clk_get_by_index(...)
if (ret && ret != -ENOSYS)
return ret

The problem really is that I'm trying to avoid having to define get_uart_clock() for the new platform. So I need an #if of some sorts to avoid that code. I really think the current diff is the cleanest I can come up.

Quoted 17 lines

drivers/serial/serial_s5p.c int s5p_serial_setbrg(struct udevice *dev, int baudrate) · line 134

Quoted 12 lines
drivers/serial/serial_s5p.c +1 -1
        struct clk clk;
        u32 ret;
 
@@ -105,7 +128,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
        uclk = get_uart_clk(plat->port_id);
 #endif
 
-       s5p_serial_baud(uart, uclk, baudrate);
+       s5p_serial_baud(uart, plat->reg_width, uclk, baudrate);
 
        return 0;
 }

[..]

Regards,
Simon

#18 lore raw

PATCH v2 5/7 iommu: Add Apple DART driver

In reply to 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.

---
 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
index 876d9c4044..91bf6a122a 100644
@@ -906,6 +906,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
index 8cb377560e..51694c168c 100644
@@ -10,4 +10,14 @@ config IOMMU
 	help
 	  Enable driver model for IOMMU devices.
 
+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
index af1c6bbb7a..e3e0900e17 100644
@@ -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
Reviewed-by on v2 5/7
#19 lore raw

Re: [PATCH v2 5/7] iommu: Add Apple DART driver

Quoted 5 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.

Quoted 9 lines
---
 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
#20 lore raw

PATCH v2 6/7 arm: dts: apple: Add preliminary device trees

In reply to 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.

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

---
 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
index fc16a57e60..65152d3ddf 100644
@@ -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
index 674b74b90b..e7c347af74 100644
@@ -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
new file mode 100644
index 0000000000..9ac56a7e6d
@@ -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
new file mode 100644
index 0000000000..ea0a6f4665
@@ -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
new file mode 100644
index 0000000000..ad4a43481d
@@ -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
Reviewed-by on v2 6/7
#21 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

Quoted 10 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.

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

Quoted 17 lines
---
 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
maintainer
#22 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

In reply to Mark Kettenis
Quoted 5 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.

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

Rob

#23 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

Hi Rob,

Quoted 14 lines · Rob Herring
Quoted 5 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.

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

Quoted 8 lines

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

This is something I have brought in, as U-Boot DT maintainer, to provide some sort of reference in U-Boot as to what is actually built. It allows people to see the devices and also ensures that the build system does build a devicetree. The existing OF_PRIOR_STAGE is being removed and OF_BOARD is becoming a bool, with OF_SEPARATE the standard approach.

We have a few examples where this is not done (e.g. qemu-arm) but I am working on fixing that. It has led to discussions about whether U-Boot is entitled to having its own things in the DT, etc. etc. The whole area is in flux at present. If you want some background:

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Regards,
Simon

#24 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

In reply to Rob Herring
Quoted 2 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 13:36:29 -0500

Hi Rob,

Quoted 9 lines · Mark Kettenis
Quoted 5 lines

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.

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Not synched at the moment. It is based on what was in 5.13 or 5.14, but with lots of stuff added so specifying a version would be misleading. It should be mostly aligned with the bindings that are making their way into 5.15 or 5.16 though.

Hopefully now that the power domains are getting addressed we'll have something that can be synchronized soon. I was explicitly encouraged to start upstreaming the U-Boot code even though not all the DT bindings had been sorted out.

Quoted 6 lines
Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

The U-Boot maintainers insist there is a DT for each supported system in the U-Boot tree.

Quoted 4 lines

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

You're preaching to the choir ;).

Must admit that it is somewhat convenient for me to have a somewhat complete DT for these devices at the moment. But in the long run I think it will just confuse people. That said, I plan to be aggressive in keeping the U-Boot tree synchronized with Linux.

Cheers,

Mark

maintainer
#25 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

Quoted 13 lines · Mark Kettenis
Quoted 3 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 13:36:29 -0500

Hi Rob,

Quoted 7 lines · Mark Kettenis
Quoted 5 lines

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.

Quoted 7 lines
Quoted 2 lines

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Not synched at the moment. It is based on what was in 5.13 or 5.14, but with lots of stuff added so specifying a version would be misleading. It should be mostly aligned with the bindings that are making their way into 5.15 or 5.16 though.

This and what's added or preliminary would be good to have in the commit msg.

Quoted 4 lines

Hopefully now that the power domains are getting addressed we'll have something that can be synchronized soon. I was explicitly encouraged to start upstreaming the U-Boot code even though not all the DT bindings had been sorted out.

In general, sounds like a recipe for getting out of sync and bindings never getting documented properly without any checks in place. The good news is checking that is at least possible now.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

The U-Boot maintainers insist there is a DT for each supported system in the U-Boot tree.

Ok, fair enough.

Quoted 6 lines
Quoted 4 lines

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

You're preaching to the choir ;).

Good.

Quoted 4 lines

Must admit that it is somewhat convenient for me to have a somewhat complete DT for these devices at the moment. But in the long run I think it will just confuse people. That said, I plan to be aggressive in keeping the U-Boot tree synchronized with Linux.

What I'd like to see here is some sort of automatic synchronization. The idea I have here is just a list of boards to sync from the kernel tree to wherever. The requirement to get on the list would be passing schema validation and would be a declaration of stability (there's been numerous discussions over the years of how to declare a DT stable or unstable). It would perhaps also include passing validation on an older schema. I'm not sure how well that would catch compatibility issues, but that's the only idea I've come up with besides just testing of mixed versions. I'm happy to do the tooling to support that if we have a board/device to put in the list and u-boot folks agree to use it. I suppose even if just m1n1 used it to start with, I'd be willing to do the tooling.

Rob

#26 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

Hi Rob,

Quoted 60 lines · Rob Herring
Quoted 13 lines · Mark Kettenis
Quoted 3 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 13:36:29 -0500

Hi Rob,

Quoted 7 lines · Mark Kettenis
Quoted 5 lines

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.

Quoted 7 lines
Quoted 2 lines

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Not synched at the moment. It is based on what was in 5.13 or 5.14, but with lots of stuff added so specifying a version would be misleading. It should be mostly aligned with the bindings that are making their way into 5.15 or 5.16 though.

This and what's added or preliminary would be good to have in the commit msg.

Quoted 4 lines

Hopefully now that the power domains are getting addressed we'll have something that can be synchronized soon. I was explicitly encouraged to start upstreaming the U-Boot code even though not all the DT bindings had been sorted out.

In general, sounds like a recipe for getting out of sync and bindings never getting documented properly without any checks in place. The good news is checking that is at least possible now.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

The U-Boot maintainers insist there is a DT for each supported system in the U-Boot tree.

Ok, fair enough.

Quoted 6 lines
Quoted 4 lines

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

You're preaching to the choir ;).

Good.

Quoted 4 lines

Must admit that it is somewhat convenient for me to have a somewhat complete DT for these devices at the moment. But in the long run I think it will just confuse people. That said, I plan to be aggressive in keeping the U-Boot tree synchronized with Linux.

Quoted 12 lines

What I'd like to see here is some sort of automatic synchronization. The idea I have here is just a list of boards to sync from the kernel tree to wherever. The requirement to get on the list would be passing schema validation and would be a declaration of stability (there's been numerous discussions over the years of how to declare a DT stable or unstable). It would perhaps also include passing validation on an older schema. I'm not sure how well that would catch compatibility issues, but that's the only idea I've come up with besides just testing of mixed versions. I'm happy to do the tooling to support that if we have a board/device to put in the list and u-boot folks agree to use it. I suppose even if just m1n1 used it to start with, I'd be willing to do the tooling.

That sounds great to me. Yes m1n1 is a good first target since it is new, but I'm pretty sure there are quite a few other SoCs that could move over right away.

Ideally we would add it to U-Boot CI too, so that pull requests warn or fail if something wrong is added. Of course it is probably a no-no to make U-Boot CI due to comparisons with another tree over which we have no control, but perhaps we can head in that direction.

+Tom Rini too as he has been looking at this.

Regards,
Simon

#27 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

Quoted 80 lines · Simon Glass

Hi Rob,

Quoted 60 lines · Rob Herring
Quoted 13 lines · Mark Kettenis
Quoted 3 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 13:36:29 -0500

Hi Rob,

Quoted 7 lines · Mark Kettenis
Quoted 5 lines

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.

Quoted 7 lines
Quoted 2 lines

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Not synched at the moment. It is based on what was in 5.13 or 5.14, but with lots of stuff added so specifying a version would be misleading. It should be mostly aligned with the bindings that are making their way into 5.15 or 5.16 though.

This and what's added or preliminary would be good to have in the commit msg.

Quoted 4 lines

Hopefully now that the power domains are getting addressed we'll have something that can be synchronized soon. I was explicitly encouraged to start upstreaming the U-Boot code even though not all the DT bindings had been sorted out.

In general, sounds like a recipe for getting out of sync and bindings never getting documented properly without any checks in place. The good news is checking that is at least possible now.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

The U-Boot maintainers insist there is a DT for each supported system in the U-Boot tree.

Ok, fair enough.

Quoted 6 lines
Quoted 4 lines

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

You're preaching to the choir ;).

Good.

Quoted 4 lines

Must admit that it is somewhat convenient for me to have a somewhat complete DT for these devices at the moment. But in the long run I think it will just confuse people. That said, I plan to be aggressive in keeping the U-Boot tree synchronized with Linux.

Quoted 12 lines

What I'd like to see here is some sort of automatic synchronization. The idea I have here is just a list of boards to sync from the kernel tree to wherever. The requirement to get on the list would be passing schema validation and would be a declaration of stability (there's been numerous discussions over the years of how to declare a DT stable or unstable). It would perhaps also include passing validation on an older schema. I'm not sure how well that would catch compatibility issues, but that's the only idea I've come up with besides just testing of mixed versions. I'm happy to do the tooling to support that if we have a board/device to put in the list and u-boot folks agree to use it. I suppose even if just m1n1 used it to start with, I'd be willing to do the tooling.

That sounds great to me. Yes m1n1 is a good first target since it is new, but I'm pretty sure there are quite a few other SoCs that could move over right away.

Quoted 6 lines

Ideally we would add it to U-Boot CI too, so that pull requests warn or fail if something wrong is added. Of course it is probably a no-no to make U-Boot CI due to comparisons with another tree over which we have no control, but perhaps we can head in that direction.

+Tom Rini too as he has been looking at this.

I guess the first priority is that so long as _everything_ is in sync, it doesn't super matter if we have an otherwise redundant copy of files in-tree.

And we need to get our DTS files back in sync with upstream, which is the case for some platforms, and not others. But once we get that sorted out, we need to do more regular resyncs, and hopefully once DTS files have settled down, because they all pass validation and for example incorrect names get fixed, it will be less of an issue to more automatically resync DTS files, that are fully validated at least.

Signature · 1 line
Tom
#28 lore raw

Re: [PATCH v2 6/7] arm: dts: apple: Add preliminary device trees

In reply to Rob Herring
Quoted 2 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 14:48:46 -0500

Hi Rob,

Trimming the CC list a bit and adding marcan.

Quoted 17 lines · Mark Kettenis
Quoted 16 lines
Quoted 3 lines

From: Rob Herring <[email protected]>
Date: Mon, 11 Oct 2021 13:36:29 -0500

Hi Rob,

Quoted 9 lines · Mark Kettenis
Quoted 5 lines

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.

So not synchronized currently? If it is sync'ed, you should specify which version you got.

Quoted 6 lines
Quoted 4 lines

Not synched at the moment. It is based on what was in 5.13 or 5.14, but with lots of stuff added so specifying a version would be misleading. It should be mostly aligned with the bindings that are making their way into 5.15 or 5.16 though.

This and what's added or preliminary would be good to have in the commit msg.

Sure. I added that information to the commit message for v4.

Quoted 35 lines
Quoted 4 lines

Hopefully now that the power domains are getting addressed we'll have something that can be synchronized soon. I was explicitly encouraged to start upstreaming the U-Boot code even though not all the DT bindings had been sorted out.

In general, sounds like a recipe for getting out of sync and bindings never getting documented properly without any checks in place. The good news is checking that is at least possible now.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

These device trees are provided as a reference only as U-Boot uses the device tree passed by the m1n1 bootloader.

If reference only, why do they need to be checked in here? We're trying to get to fewer copies both of dtbs at runtime and dts files in source trees.

The U-Boot maintainers insist there is a DT for each supported system in the U-Boot tree.

Ok, fair enough.

Quoted 6 lines
Quoted 4 lines

I mainly bring it up here because this is a platform with multiple OS targets, following the model that DT comes from the firmware, and should be free of schema validation warnings. In other words, it's a good candidate to define best practices.

You're preaching to the choir ;).

Good.

Quoted 4 lines

Must admit that it is somewhat convenient for me to have a somewhat complete DT for these devices at the moment. But in the long run I think it will just confuse people. That said, I plan to be aggressive in keeping the U-Boot tree synchronized with Linux.

Quoted 12 lines

What I'd like to see here is some sort of automatic synchronization. The idea I have here is just a list of boards to sync from the kernel tree to wherever. The requirement to get on the list would be passing schema validation and would be a declaration of stability (there's been numerous discussions over the years of how to declare a DT stable or unstable). It would perhaps also include passing validation on an older schema. I'm not sure how well that would catch compatibility issues, but that's the only idea I've come up with besides just testing of mixed versions. I'm happy to do the tooling to support that if we have a board/device to put in the list and u-boot folks agree to use it. I suppose even if just m1n1 used it to start with, I'd be willing to do the tooling.

Sounds interesting.

One of the things we would want to do a ship device trees for new models with m1n1 as soon as we get our hands on the hardware such that the they can be used with existing distro kernels as soon as possible. Under the assumption that the new hardware is compatible with the old of course. That means those new device trees should pass validation.

But as soon as the device tree for a model is available in the Linux tree, we probably want to be rather strict in synching it to m1n1.

Thanks,

Mark

#29 lore raw

PATCH v2 7/7 doc: board: apple: Add Apple M1 documentation

In reply to Mark Kettenis

Provide preliminary instructions on how to get U-Boot to run on Apple Silicon Macs.

---
 doc/board/apple/index.rst |  9 +++++++
 doc/board/apple/m1.rst    | 56 +++++++++++++++++++++++++++++++++++++++
 doc/board/index.rst       |  1 +
 3 files changed, 66 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
new file mode 100644
index 0000000000..8446847818
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Apple
+=====
+
+.. toctree::
+   :maxdepth: 2
+
+   m1
doc/board/apple/m1.rst new file +56 -0

56 lines not on this page · raw message

doc/board/index.rst +1 -0
index 33087074fa..0add55b5d3 100644
@@ -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
Reviewed-by on v2 7/7
#30 lore raw

Re: [PATCH v2 7/7] doc: board: apple: Add Apple M1 documentation

Quoted 4 lines · Mark Kettenis

Provide preliminary instructions on how to get U-Boot to run on Apple Silicon Macs.

Quoted 8 lines
---
 doc/board/apple/index.rst |  9 +++++++
 doc/board/apple/m1.rst    | 56 +++++++++++++++++++++++++++++++++++++++
 doc/board/index.rst       |  1 +
 3 files changed, 66 insertions(+)
 create mode 100644 doc/board/apple/index.rst
 create mode 100644 doc/board/apple/m1.rst
#31 lore raw
In reply to Mark Kettenis

Hi Mark,

Quoted 6 lines · Mark Kettenis

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.

Quoted 8 lines

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.

Please do this soon. We can easily change a compatible string later if needed, but having strange code in there provides a bad example for others.

Regards,
Simon