mirror of
https://github.com/ipxe/ipxe
synced 2025-12-16 17:41:18 +03:00
[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 <mcb30@ipxe.org>
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user