Page MenuHomeFreeBSD

dev/uart: Support setting the register io width
ClosedPublic

Authored by andrew on Jan 8 2024, 5:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 28, 9:06 PM
Unknown Object (File)
Fri, May 10, 5:16 AM
Unknown Object (File)
Fri, May 10, 5:15 AM
Unknown Object (File)
Fri, May 10, 3:39 AM
Unknown Object (File)
Thu, May 9, 10:34 PM
Unknown Object (File)
May 2 2024, 11:24 AM
Unknown Object (File)
Mar 25 2024, 10:36 PM
Unknown Object (File)
Mar 21 2024, 1:19 PM
Subscribers
None

Details

Summary

Some uarts require a specific register width. Support setting this in
the kernel environment.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

andrew requested review of this revision.Jan 8 2024, 5:26 PM
andrew created this revision.

With this, we can initialize all the fields in uart_bas. I like it, module a minor quibble.

sys/dev/uart/uart_subr.c
232–233

What should we initialize regiowidth to? Some drivers don't seem to initialize it at all.
The default is '1' :

static inline void
uart_setreg(struct uart_bas *bas, int reg, int value)
{

        switch (uart_regiowidth(bas)) {
        case 4:
                bus_space_write_4(bas->bst, bas->bsh, uart_regofs(bas, reg), value);
                break;
        case 2:
                bus_space_write_2(bas->bst, bas->bsh, uart_regofs(bas, reg), value);
                break;
        default:
                bus_space_write_1(bas->bst, bas->bsh, uart_regofs(bas, reg), value);
                break;
        }
}

but that breaks

sys/dev/uart/uart_cpu_acpi.c:		di->bas.regiowidth = 8;

silently :(.

tl;dr: I think we should explicitly initialize it here to 1. One of us should fix uart.h's uart_getreg and uart_setreg to have a 8 case (though that might be a landmine if we still have platforms without bus_space_write_8, but I thought that was a 'base' requirement of 32-bit platforms these days).

This revision is now accepted and ready to land.Jan 8 2024, 6:23 PM
This revision now requires review to proceed.Jan 9 2024, 12:16 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 13 2024, 11:53 AM
This revision was automatically updated to reflect the committed changes.