]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dwgpio] Use fdt_reg() to get GPIO port numbers master
authorMichael Brown <mcb30@ipxe.org>
Thu, 7 Aug 2025 14:43:58 +0000 (15:43 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 7 Aug 2025 14:49:12 +0000 (15:49 +0100)
DesignWare GPIO port numbers are represented as unsized single-entry
regions.  Use fdt_reg() to obtain the GPIO port number, rather than
requiring access to a region cell size specification stored in the
port group structure.

This allows the field name "regs" in the port group structure to be
repurposed to hold the I/O register base address, which then matches
the common usage in other drivers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/gpio/dwgpio.c
src/drivers/gpio/dwgpio.h

index 0b300e0c3375f5a3f3725fbe4224033949b4c072..eb3882d08550fe66ad8289d2441f9fdcb5e45e19 100644 (file)
@@ -64,15 +64,12 @@ static int dwgpio_group_probe ( struct dt_device *dt, unsigned int offset ) {
        dt_set_drvdata ( dt, group );
 
        /* Map registers */
-       group->base = dt_ioremap ( dt, offset, 0, 0 );
-       if ( ! group->base ) {
+       group->regs = dt_ioremap ( dt, offset, 0, 0 );
+       if ( ! group->regs ) {
                rc = -ENODEV;
                goto err_ioremap;
        }
 
-       /* Get region cell size specification */
-       fdt_reg_cells ( &sysfdt, offset, &group->regs );
-
        /* Probe child ports */
        if ( ( rc = dt_probe_children ( dt, offset ) ) != 0 )
                goto err_children;
@@ -81,7 +78,7 @@ static int dwgpio_group_probe ( struct dt_device *dt, unsigned int offset ) {
 
        dt_remove_children ( dt );
  err_children:
-       iounmap ( group->base );
+       iounmap ( group->regs );
  err_ioremap:
        free ( group );
  err_alloc:
@@ -100,7 +97,7 @@ static void dwgpio_group_remove ( struct dt_device *dt ) {
        dt_remove_children ( dt );
 
        /* Unmap registers */
-       iounmap ( group->base );
+       iounmap ( group->regs );
 
        /* Free device */
        free ( group );
@@ -260,8 +257,7 @@ static int dwgpio_probe ( struct dt_device *dt, unsigned int offset ) {
        group = dt_get_drvdata ( parent );
 
        /* Identify port */
-       if ( ( rc = fdt_reg_address ( &sysfdt, offset, &group->regs, 0,
-                                     &port ) ) != 0 ) {
+       if ( ( rc = fdt_reg ( &sysfdt, offset, &port ) ) != 0 ) {
                DBGC ( dwgpio, "DWGPIO %s could not get port number: %s\n",
                       dwgpio->name, strerror ( rc ) );
                goto err_port;
@@ -271,8 +267,8 @@ static int dwgpio_probe ( struct dt_device *dt, unsigned int offset ) {
               dwgpio->name, parent->name, dwgpio->port, gpios->count );
 
        /* Map registers */
-       dwgpio->swport = ( group->base + DWGPIO_SWPORT ( port ) );
-       dwgpio->ext = ( group->base + DWGPIO_EXT_PORT ( port ) );
+       dwgpio->swport = ( group->regs + DWGPIO_SWPORT ( port ) );
+       dwgpio->ext = ( group->regs + DWGPIO_EXT_PORT ( port ) );
        dwgpio_dump ( dwgpio );
 
        /* Record original register values */
index 4deb6227ce17934677c6a2b94be99bf6e020b367..cee97a6ab1d248f990198100be50e642b4883676 100644 (file)
@@ -53,10 +53,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 /** A DesignWare GPIO port group */
 struct dwgpio_group {
-       /** Register base */
-       void *base;
-       /** Region cell size specification */
-       struct fdt_reg_cells regs;
+       /** Registers */
+       void *regs;
 };
 
 /** A DesignWare GPIO port */