mirror of
https://github.com/opnsense/src.git
synced 2026-04-23 07:07:24 -04:00
Remove the hardcoded IXP425_UART?_VBASE values in the
uart_ixp425_probe() and uart_cpu_getdev(). Change uart_cpu_getdev() to use hints to find the console. Reviewed by: marcel
This commit is contained in:
parent
631ca44df2
commit
aeefab2b98
5 changed files with 58 additions and 18 deletions
|
|
@ -8,7 +8,7 @@
|
|||
hint.uart.0.at="ixp0"
|
||||
hint.uart.0.addr=0xc8000000
|
||||
hint.uart.0.irq=15
|
||||
#hint.uart.0.flags=0x10
|
||||
hint.uart.0.flags=0x10
|
||||
# USART0 is unit 1
|
||||
hint.uart.1.at="ixp0"
|
||||
hint.uart.1.addr=0xc8001000
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static struct {
|
|||
IXP425_EXP_BUS_CS4_VBASE },
|
||||
};
|
||||
|
||||
static int
|
||||
int
|
||||
getvbase(uint32_t hwbase, uint32_t size, uint32_t *vbase)
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ uint32_t ixp425_sdram_size(void);
|
|||
int ixp425_md_route_interrupt(device_t, device_t, int);
|
||||
void ixp425_md_attach(device_t);
|
||||
|
||||
int getvbase(uint32_t, uint32_t, uint32_t *);
|
||||
|
||||
struct ixp425_ivar {
|
||||
uint32_t addr;
|
||||
int irq;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,15 @@ uart_ixp425_probe(device_t dev)
|
|||
|
||||
sc = device_get_softc(dev);
|
||||
sc->sc_class = &uart_ns8250_class;
|
||||
sc->sc_rrid = 0;
|
||||
sc->sc_rtype = SYS_RES_MEMORY;
|
||||
sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
|
||||
0, ~0, uart_getrange(sc->sc_class), RF_ACTIVE);
|
||||
if (sc->sc_rres == NULL) {
|
||||
return (ENXIO);
|
||||
}
|
||||
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
|
||||
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
|
||||
/*
|
||||
* XXX set UART Unit Enable (0x40) AND
|
||||
* receiver timeout int enable (0x10).
|
||||
|
|
@ -79,9 +88,9 @@ uart_ixp425_probe(device_t dev)
|
|||
* uart_ns8250 carefully avoids touching these bits so we can
|
||||
* just set them here and proceed. But this is fragile...
|
||||
*/
|
||||
bus_space_write_4(&ixp425_a4x_bs_tag,
|
||||
device_get_unit(dev) == 0 ? IXP425_UART0_VBASE : IXP425_UART1_VBASE,
|
||||
IXP425_UART_IER, IXP425_UART_IER_UUE | IXP425_UART_IER_RTOIE);
|
||||
bus_space_write_4(sc->sc_bas.bst, sc->sc_bas.bsh, IXP425_UART_IER,
|
||||
IXP425_UART_IER_UUE | IXP425_UART_IER_RTOIE);
|
||||
bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
|
||||
|
||||
return uart_bus_probe(dev, 0, IXP425_UART_FREQ, 0, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,17 +51,46 @@ uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
|
|||
int
|
||||
uart_cpu_getdev(int devtype, struct uart_devinfo *di)
|
||||
{
|
||||
di->ops = uart_getops(&uart_ns8250_class);
|
||||
di->bas.chan = 0;
|
||||
di->bas.bst = &ixp425_a4x_bs_tag;
|
||||
di->bas.regshft = 0;
|
||||
di->bas.rclk = IXP425_UART_FREQ;
|
||||
di->baudrate = 115200;
|
||||
di->databits = 8;
|
||||
di->stopbits = 1;
|
||||
di->parity = UART_PARITY_NONE;
|
||||
uart_bus_space_io = &ixp425_a4x_bs_tag;
|
||||
uart_bus_space_mem = NULL;
|
||||
di->bas.bsh = IXP425_UART0_VBASE;
|
||||
return (0);
|
||||
uint32_t i, ivar, vaddr;
|
||||
|
||||
/*
|
||||
* Scan the hints. The IXP425 only have 2 serial ports, so only
|
||||
* scan them.
|
||||
*/
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (resource_int_value("uart", i, "flags", &ivar))
|
||||
continue;
|
||||
if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(ivar))
|
||||
continue;
|
||||
if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(ivar))
|
||||
continue;
|
||||
/*
|
||||
* We have a possible device. Make sure it's enabled and
|
||||
* that we have an I/O port.
|
||||
*/
|
||||
if (resource_int_value("uart", i, "disabled", &ivar) == 0 &&
|
||||
ivar != 0)
|
||||
continue;
|
||||
if (resource_int_value("uart", i, "addr", &ivar) != 0 ||
|
||||
ivar == 0)
|
||||
continue;
|
||||
/* Got it. Fill in the instance and return it. */
|
||||
di->ops = uart_getops(&uart_ns8250_class);
|
||||
di->bas.chan = 0;
|
||||
di->bas.bst = &ixp425_a4x_bs_tag;
|
||||
di->bas.regshft = 0;
|
||||
di->bas.rclk = IXP425_UART_FREQ;
|
||||
di->baudrate = 115200;
|
||||
di->databits = 8;
|
||||
di->stopbits = 1;
|
||||
di->parity = UART_PARITY_NONE;
|
||||
uart_bus_space_io = NULL;
|
||||
uart_bus_space_mem = &ixp425_a4x_bs_tag;
|
||||
|
||||
getvbase(ivar, IXP425_REG_SIZE, &vaddr);
|
||||
di->bas.bsh = vaddr;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue