From 8460dc4e8ffc98db62377d1c5502d6aac40f5a64 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 7 Aug 2025 15:43:58 +0100 Subject: [PATCH] [dwgpio] Use fdt_reg() to get GPIO port numbers 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 --- src/drivers/gpio/dwgpio.c | 18 +++++++----------- src/drivers/gpio/dwgpio.h | 6 ++---- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/drivers/gpio/dwgpio.c b/src/drivers/gpio/dwgpio.c index 0b300e0c3..eb3882d08 100644 --- a/src/drivers/gpio/dwgpio.c +++ b/src/drivers/gpio/dwgpio.c @@ -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 */ diff --git a/src/drivers/gpio/dwgpio.h b/src/drivers/gpio/dwgpio.h index 4deb6227c..cee97a6ab 100644 --- a/src/drivers/gpio/dwgpio.h +++ b/src/drivers/gpio/dwgpio.h @@ -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 */ -- 2.47.2