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)
Sun, Nov 3, 6:14 PM
Unknown Object (File)
Oct 9 2024, 8:02 PM
Unknown Object (File)
Oct 9 2024, 8:01 PM
Unknown Object (File)
Oct 9 2024, 8:00 PM
Unknown Object (File)
Oct 9 2024, 8:00 PM
Unknown Object (File)
Oct 9 2024, 7:30 PM
Unknown Object (File)
Oct 1 2024, 3:51 AM
Unknown Object (File)
Sep 30 2024, 3:39 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 55293
Build 52182: arc lint + arc unit

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

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.