]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dt] Add DT_ROM() and DT_ID() macros
authorMichael Brown <mcb30@ipxe.org>
Thu, 12 Feb 2026 13:26:12 +0000 (13:26 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 12 Feb 2026 13:29:06 +0000 (13:29 +0000)
Add DT_ROM() and DT_ID() macros following the pattern for PCI_ROM()
and PCI_ID(), to allow for the possibility of including devicetree
network devices within the "all-drivers" build of iPXE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/gpio/dwgpio.c
src/drivers/net/cgem.c
src/drivers/net/dwmac.c
src/drivers/uart/dwuart.c
src/drivers/usb/dwusb.c
src/include/ipxe/devtree.h
src/util/parserom.pl

index eb3882d08550fe66ad8289d2441f9fdcb5e45e19..99e4b5c07fbe6f01e4d929581addac968825cae7 100644 (file)
@@ -105,7 +105,7 @@ static void dwgpio_group_remove ( struct dt_device *dt ) {
 
 /** DesignWare GPIO port group compatible model identifiers */
 static const char * dwgpio_group_ids[] = {
-       "snps,dw-apb-gpio",
+       DT_ID ( "snps,dw-apb-gpio", "DesignWare GPIO" ),
 };
 
 /** DesignWare GPIO port group devicetree driver */
@@ -320,7 +320,7 @@ static void dwgpio_remove ( struct dt_device *dt ) {
 
 /** DesignWare GPIO port compatible model identifiers */
 static const char * dwgpio_ids[] = {
-       "snps,dw-apb-gpio-port",
+       DT_ID ( "snps,dw-apb-gpio-port", "DesignWare GPIO port" ),
 };
 
 /** DesignWare GPIO port devicetree driver */
index c935c8024cd1bb5961bbb91f713b5d846fb5e9f6..26203d7fabcfcc2649f6c34bb2a24dbb75965c6a 100644 (file)
@@ -698,7 +698,7 @@ static void cgem_remove ( struct dt_device *dt ) {
 
 /** Cadence GEM compatible model identifiers */
 static const char * cgem_ids[] = {
-       "sifive,fu540-c000-gem",
+       DT_ROM ( "sifive,fu540-c000-gem", "SiFive GEM" ),
 };
 
 /** Cadence GEM devicetree driver */
index f581a48a47eef3e163c4db4bbc373894396914a8..b6986681bd0eff78ebf139f96d5a30266da142d0 100644 (file)
@@ -649,8 +649,8 @@ static void dwmac_remove ( struct dt_device *dt ) {
 
 /** DesignWare MAC compatible model identifiers */
 static const char * dwmac_ids[] = {
-       "thead,light-dwmac",
-       "snps,dwmac",
+       DT_ROM ( "thead,light-dwmac", "T-Head MAC" ),
+       DT_ROM ( "snps,dwmac", "DesignWare MAC" ),
 };
 
 /** DesignWare MAC devicetree driver */
index ce08e8ebf9de48f9aab51a5ca1ffe7dde7f81ba3..ae8726ebf54d2c570b66d5a01219eaf8c1dcf30e 100644 (file)
@@ -115,8 +115,8 @@ static void dwuart_remove ( struct dt_device *dt ) {
 
 /** DesignWare UART compatible model identifiers */
 static const char * dwuart_ids[] = {
-       "snps,dw-apb-uart",
-       "ns16550a",
+       DT_ID ( "snps,dw-apb-uart", "DesignWare UART" ),
+       DT_ID ( "ns16550a", "NS16550-compatible" ),
 };
 
 /** DesignWare UART devicetree driver */
index 1bae2ce747126c2d9d39f31146f218ef2a0dc3e5..406a4bca4e3ce57e7a6d08e83e8c13583c197678 100644 (file)
@@ -118,7 +118,7 @@ static void dwusb_remove ( struct dt_device *dt ) {
 
 /** DesignWare USB3 compatible model identifiers */
 static const char * dwusb_ids[] = {
-       "snps,dwc3",
+       DT_ID ( "snps,dwc3", "DesignWare USB3" ),
 };
 
 /** DesignWare USB3 devicetree driver */
index 2bf473a3bbabcc60e199a492a66333fca2707ce6..2fdfcbd63dcc6a56cb8eb30b2bbaebc0e3bb7b31 100644 (file)
@@ -27,6 +27,12 @@ struct dt_device {
        void *priv;
 };
 
+/* Define a devicetree device ID */
+#define DT_ID( _name, _desc ) _name
+
+/* Define a devicetree device ID with a corresponding build rule */
+#define DT_ROM( _name, _desc ) DT_ID ( _name, _desc )
+
 /** A devicetree driver */
 struct dt_driver {
        /** Driver name */
index a42bc2b65646a2fab8091f2d0260053236b2b514..d86be589d07fe15c4c5fe89eb75c93c316f5acd3 100755 (executable)
@@ -36,7 +36,7 @@ if ( $debug ) {
 my %RE = (
     'parse_driver_class'    => qr{ drivers/ (\w+?) / }x,
     'parse_family'          => qr{^ (?:\./)? (.*) \..+? $}x,
-    'find_rom_line'         => qr/^ \s* ( (PCI|ISA|USB)_ROM \s*
+    'find_rom_line'         => qr/^ \s* ( (PCI|ISA|USB|DT)_ROM \s*
                                     \( \s* (.*?) \s* \) \s* ) [,;]/msx,
     'find_secboot'          => qr/^ \s* FILE_SECBOOT \s*
                                     \( \s* PERMITTED \s* \) \s* ; \s* $/mx,
@@ -121,6 +121,7 @@ sub process_rom_decl {
     return process_pci_rom($state, $rom_decl) if $rom_type eq "PCI";
     return process_isa_rom($state, $rom_decl) if $rom_type eq "ISA";
     return process_usb_rom($state, $rom_decl) if $rom_type eq "USB";
+    return process_dt_rom($state, $rom_decl) if $rom_type eq "DT";
     return;
 }
 
@@ -180,6 +181,23 @@ sub process_usb_rom {
     return 1;
 }
 
+# Extract values from DT_ROM declaration lines and dispatch to
+# Makefile rule generator
+sub process_dt_rom {
+    my ($state, $decl) = @_;
+    return unless defined $decl;
+    return unless length $decl;
+    (my $image,  $decl) = extract_quoted_string($decl, 'IMAGE');
+    (my $desc,   $decl) = extract_quoted_string($decl, 'DESCRIPTION');
+    $image =~ s/,/-/;
+    if ( $image and $desc ) {
+        print_make_rules( $state, $image, $desc );
+    } else {
+       log_debug("WARNING", "Malformed DT_ROM macro on line $. of $state->{source_file}");
+    }
+    return 1;
+}
+
 # Output Makefile rules for the specified ROM declarations
 sub print_make_rules {
     my ( $state, $image, $desc, $vendor, $device, $dup ) = @_;