Index: head/sys/dev/uart/uart_bus_isa.c =================================================================== --- head/sys/dev/uart/uart_bus_isa.c (revision 133734) +++ head/sys/dev/uart/uart_bus_isa.c (revision 133735) @@ -1,167 +1,169 @@ /* * Copyright (c) 2001 M. Warner Losh. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include +#include static int uart_isa_probe(device_t dev); static device_method_t uart_isa_methods[] = { /* Device interface */ + DEVMETHOD(device_identify, uart_cpu_identify), DEVMETHOD(device_probe, uart_isa_probe), DEVMETHOD(device_attach, uart_bus_attach), DEVMETHOD(device_detach, uart_bus_detach), { 0, 0 } }; static driver_t uart_isa_driver = { uart_driver_name, uart_isa_methods, sizeof(struct uart_softc), }; static struct isa_pnp_id isa_ns8250_ids[] = { {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */ {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */ {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */ {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */ /* Devices that do not have a compatid */ {0x12206804, NULL}, /* ACH2012 - 5634BTS 56K Video Ready Modem */ {0x7602a904, NULL}, /* AEI0276 - 56K v.90 Fax Modem (LKT) */ {0x00007905, NULL}, /* AKY0000 - 56K Plug&Play Modem */ {0x21107905, NULL}, /* AKY1021 - 56K Plug&Play Modem */ {0x01405407, NULL}, /* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */ {0x56039008, NULL}, /* BDP0356 - Best Data 56x2 */ {0x56159008, NULL}, /* BDP1556 - B.D. Smart One 56SPS,Voice Modem*/ {0x36339008, NULL}, /* BDP3336 - Best Data Prods. 336F */ {0x0014490a, NULL}, /* BRI1400 - Boca 33.6 PnP */ {0x0015490a, NULL}, /* BRI1500 - Internal Fax Data */ {0x0034490a, NULL}, /* BRI3400 - Internal ACF Modem */ {0x0094490a, NULL}, /* BRI9400 - Boca K56Flex PnP */ {0x00b4490a, NULL}, /* BRIB400 - Boca 56k PnP */ {0x0030320d, NULL}, /* CIR3000 - Cirrus Logic V43 */ {0x0100440e, NULL}, /* CRD0001 - Cardinal MVP288IV ? */ {0x01308c0e, NULL}, /* CTL3001 - Creative Labs Phoneblaster */ {0x36033610, NULL}, /* DAV0336 - DAVICOM 336PNP MODEM */ {0x01009416, NULL}, /* ETT0001 - E-Tech Bullet 33k6 PnP */ {0x0000aa1a, NULL}, /* FUJ0000 - FUJITSU Modem 33600 PNP/I2 */ {0x1200c31e, NULL}, /* GVC0012 - VF1128HV-R9 (win modem?) */ {0x0303c31e, NULL}, /* GVC0303 - MaxTech 33.6 PnP D/F/V */ {0x0505c31e, NULL}, /* GVC0505 - GVC 56k Faxmodem */ {0x0116c31e, NULL}, /* GVC1601 - Rockwell V.34 Plug & Play Modem */ {0x0050c31e, NULL}, /* GVC5000 - some GVC modem */ {0x3800f91e, NULL}, /* GWY0038 - Telepath with v.90 */ {0x9062f91e, NULL}, /* GWY6290 - Telepath with x2 Technology */ {0x8100e425, NULL}, /* IOD0081 - I-O DATA DEVICE,INC. IFML-560 */ {0x71004d24, NULL}, /* IBM0071 - IBM ThinkPad 240 IrDA controller*/ {0x21002534, NULL}, /* MAE0021 - Jetstream Int V.90 56k Voice Series 2*/ {0x0000f435, NULL}, /* MOT0000 - Motorola ModemSURFR 33.6 Intern */ {0x5015f435, NULL}, /* MOT1550 - Motorola ModemSURFR 56K Modem */ {0xf015f435, NULL}, /* MOT15F0 - Motorola VoiceSURFR 56K Modem */ {0x6045f435, NULL}, /* MOT4560 - Motorola ? */ {0x61e7a338, NULL}, /* NECE761 - 33.6Modem */ {0x0160633a, NULL}, /* NSC6001 - National Semi's IrDA Controller*/ {0x08804f3f, NULL}, /* OZO8008 - Zoom (33.6k Modem) */ {0x0f804f3f, NULL}, /* OZO800f - Zoom 2812 (56k Modem) */ {0x39804f3f, NULL}, /* OZO8039 - Zoom 56k flex */ {0x00914f3f, NULL}, /* OZO9100 - Zoom 2919 (K56 Faxmodem) */ {0x3024a341, NULL}, /* PMC2430 - Pace 56 Voice Internal Modem */ {0x1000eb49, NULL}, /* ROK0010 - Rockwell ? */ {0x1200b23d, NULL}, /* RSS0012 - OMRON ME5614ISA */ {0x5002734a, NULL}, /* RSS0250 - 5614Jx3(G) Internal Modem */ {0x6202734a, NULL}, /* RSS0262 - 5614Jx3[G] V90+K56Flex Modem */ {0x1010104d, NULL}, /* SHP1010 - Rockwell 33600bps Modem */ {0x10f0a34d, NULL}, /* SMCF010 - SMC IrCC*/ {0xc100ad4d, NULL}, /* SMM00C1 - Leopard 56k PnP */ {0x9012b04e, NULL}, /* SUP1290 - Supra ? */ {0x1013b04e, NULL}, /* SUP1310 - SupraExpress 336i PnP */ {0x8013b04e, NULL}, /* SUP1380 - SupraExpress 288i PnP Voice */ {0x8113b04e, NULL}, /* SUP1381 - SupraExpress 336i PnP Voice */ {0x5016b04e, NULL}, /* SUP1650 - Supra 336i Sp Intl */ {0x7016b04e, NULL}, /* SUP1670 - Supra 336i V+ Intl */ {0x7420b04e, NULL}, /* SUP2070 - Supra ? */ {0x8020b04e, NULL}, /* SUP2080 - Supra ? */ {0x8420b04e, NULL}, /* SUP2084 - SupraExpress 56i PnP */ {0x7121b04e, NULL}, /* SUP2171 - SupraExpress 56i Sp? */ {0x8024b04e, NULL}, /* SUP2480 - Supra ? */ {0x01007256, NULL}, /* USR0001 - U.S. Robotics Inc., Sportster W */ {0x02007256, NULL}, /* USR0002 - U.S. Robotics Inc. Sportster 33. */ {0x04007256, NULL}, /* USR0004 - USR Sportster 14.4k */ {0x06007256, NULL}, /* USR0006 - USR Sportster 33.6k */ {0x11007256, NULL}, /* USR0011 - USR ? */ {0x01017256, NULL}, /* USR0101 - USR ? */ {0x30207256, NULL}, /* USR2030 - U.S.Robotics Inc. Sportster 560 */ {0x50207256, NULL}, /* USR2050 - U.S.Robotics Inc. Sportster 33. */ {0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */ {0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */ {0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */ {0x50307256, NULL}, /* USR3050 - U.S. Robotics 56K FAX INT */ {0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */ {0x90307256, NULL}, /* USR3090 - USR ? */ {0x70917256, NULL}, /* USR9170 - U.S. Robotics 56K FAX INT */ {0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */ {0x04f0235c, NULL}, /* WACF004 - Wacom Tablet PC Screen*/ {0x0300695c, NULL}, /* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */ {0x01a0896a, NULL}, /* ZTIA001 - Zoom Internal V90 Faxmodem */ {0x61f7896a, NULL}, /* ZTIF761 - Zoom ComStar 33.6 */ {0} }; static int uart_isa_probe(device_t dev) { struct uart_softc *sc; device_t parent; parent = device_get_parent(dev); sc = device_get_softc(dev); if (!ISA_PNP_PROBE(parent, dev, isa_ns8250_ids)) { sc->sc_class = &uart_ns8250_class; return (uart_bus_probe(dev, 0, 0, 0, 0)); } /* Add checks for non-ns8250 IDs here. */ sc->sc_class = &uart_ns8250_class; return (uart_bus_probe(dev, 0, 0, 0, 0)); } DRIVER_MODULE(uart, isa, uart_isa_driver, uart_devclass, 0, 0); Index: head/sys/dev/uart/uart_cpu.h =================================================================== --- head/sys/dev/uart/uart_cpu.h (revision 133734) +++ head/sys/dev/uart/uart_cpu.h (revision 133735) @@ -1,120 +1,121 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _DEV_UART_CPU_H_ #define _DEV_UART_CPU_H_ /* * Low-level operations for use by console and/or debug port support. */ struct uart_ops { int (*probe)(struct uart_bas *); void (*init)(struct uart_bas *, int, int, int, int); void (*term)(struct uart_bas *); void (*putc)(struct uart_bas *, int); int (*poll)(struct uart_bas *); int (*getc)(struct uart_bas *); }; extern struct uart_ops uart_i8251_ops; extern struct uart_ops uart_ns8250_ops; extern struct uart_ops uart_sab82532_ops; extern struct uart_ops uart_z8530_ops; extern bus_space_tag_t uart_bus_space_io; extern bus_space_tag_t uart_bus_space_mem; /* * Console and debug port device info. */ struct uart_softc; struct uart_devinfo { SLIST_ENTRY(uart_devinfo) next; struct uart_ops ops; struct uart_bas bas; int baudrate; int databits; int stopbits; int parity; int type; #define UART_DEV_CONSOLE 0 #define UART_DEV_DBGPORT 1 #define UART_DEV_KEYBOARD 2 int (*attach)(struct uart_softc*); int (*detach)(struct uart_softc*); void *cookie; /* Type dependent use. */ }; int uart_cpu_eqres(struct uart_bas *, struct uart_bas *); int uart_cpu_getdev(int, struct uart_devinfo *); int uart_getenv(int, struct uart_devinfo *); void uart_add_sysdev(struct uart_devinfo *); +void uart_cpu_identify(driver_t *, device_t); /* * Operations for low-level access to the UART. Primarily for use * by console and debug port logic. */ static __inline int uart_probe(struct uart_devinfo *di) { return (di->ops.probe(&di->bas)); } static __inline void uart_init(struct uart_devinfo *di) { di->ops.init(&di->bas, di->baudrate, di->databits, di->stopbits, di->parity); } static __inline void uart_term(struct uart_devinfo *di) { di->ops.term(&di->bas); } static __inline void uart_putc(struct uart_devinfo *di, int c) { di->ops.putc(&di->bas, c); } static __inline int uart_poll(struct uart_devinfo *di) { return (di->ops.poll(&di->bas)); } static __inline int uart_getc(struct uart_devinfo *di) { return (di->ops.getc(&di->bas)); } #endif /* _DEV_UART_CPU_H_ */ Index: head/sys/dev/uart/uart_cpu_alpha.c =================================================================== --- head/sys/dev/uart/uart_cpu_alpha.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_alpha.c (revision 133735) @@ -1,125 +1,131 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { struct ctb *ctb; unsigned int i, ivar; uart_bus_space_io = busspace_isa_io; uart_bus_space_mem = busspace_isa_mem; if (devtype == UART_DEV_CONSOLE) { ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); if (ctb->ctb_term_type != CTB_PRINTERPORT) return (ENXIO); boothowto |= RB_SERIAL; di->ops = uart_ns8250_ops; di->bas.chan = 0; di->bas.bst = uart_bus_space_io; if (bus_space_map(di->bas.bst, 0x3f8, 8, 0, &di->bas.bsh) != 0) return (ENXIO); di->bas.regshft = 0; di->bas.rclk = 0; di->baudrate = 9600; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; return (0); } /* Check the environment. */ if (uart_getenv(devtype, di) == 0) return (0); /* * Scan the hints. We only try units 0 to 3 (inclusive). This * covers the ISA legacy where 4 UARTs had their resources * predefined. */ for (i = 0; i < 4; i++) { if (resource_int_value("uart", i, "flags", &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, "port", &ivar) != 0 || ivar == 0) continue; /* * Got it. Fill in the instance and return it. We assume we * only have ns8250 and successors on alpha. */ di->ops = uart_ns8250_ops; di->bas.chan = 0; di->bas.bst = uart_bus_space_io; if (bus_space_map(di->bas.bst, ivar, 8, 0, &di->bas.bsh) != 0) continue; di->bas.regshft = 0; di->bas.rclk = 0; if (resource_int_value("uart", i, "baud", &ivar) != 0) ivar = 0; di->baudrate = ivar; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; return (0); } return (ENXIO); } + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ + +} Index: head/sys/dev/uart/uart_cpu_amd64.c =================================================================== --- head/sys/dev/uart/uart_cpu_amd64.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_amd64.c (revision 133735) @@ -1,101 +1,107 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include bus_space_tag_t uart_bus_space_io = AMD64_BUS_SPACE_IO; bus_space_tag_t uart_bus_space_mem = AMD64_BUS_SPACE_MEM; int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { unsigned int i, ivar; /* Check the environment. */ if (uart_getenv(devtype, di) == 0) return (0); /* * Scan the hints. We only try units 0 to 3 (inclusive). This * covers the ISA legacy where 4 UARTs had their resources * predefined. */ for (i = 0; i < 4; 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, "port", &ivar) != 0 || ivar == 0) continue; /* * Got it. Fill in the instance and return it. We only have * ns8250 and successors on i386. */ di->ops = uart_ns8250_ops; di->bas.chan = 0; di->bas.bst = uart_bus_space_io; if (bus_space_map(di->bas.bst, ivar, 8, 0, &di->bas.bsh) != 0) continue; di->bas.regshft = 0; di->bas.rclk = 0; if (resource_int_value("uart", i, "baud", &ivar) != 0) ivar = 0; di->baudrate = ivar; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; return (0); } return (ENXIO); } + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ + +} Index: head/sys/dev/uart/uart_cpu_i386.c =================================================================== --- head/sys/dev/uart/uart_cpu_i386.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_i386.c (revision 133735) @@ -1,101 +1,107 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include bus_space_tag_t uart_bus_space_io = I386_BUS_SPACE_IO; bus_space_tag_t uart_bus_space_mem = I386_BUS_SPACE_MEM; int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { unsigned int i, ivar; /* Check the environment. */ if (uart_getenv(devtype, di) == 0) return (0); /* * Scan the hints. We only try units 0 to 3 (inclusive). This * covers the ISA legacy where 4 UARTs had their resources * predefined. */ for (i = 0; i < 4; 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, "port", &ivar) != 0 || ivar == 0) continue; /* * Got it. Fill in the instance and return it. We only have * ns8250 and successors on i386. */ di->ops = uart_ns8250_ops; di->bas.chan = 0; di->bas.bst = uart_bus_space_io; if (bus_space_map(di->bas.bst, ivar, 8, 0, &di->bas.bsh) != 0) continue; di->bas.regshft = 0; di->bas.rclk = 0; if (resource_int_value("uart", i, "baud", &ivar) != 0) ivar = 0; di->baudrate = ivar; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; return (0); } return (ENXIO); } + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ + +} Index: head/sys/dev/uart/uart_cpu_ia64.c =================================================================== --- head/sys/dev/uart/uart_cpu_ia64.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_ia64.c (revision 133735) @@ -1,106 +1,112 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include bus_space_tag_t uart_bus_space_io = IA64_BUS_SPACE_IO; bus_space_tag_t uart_bus_space_mem = IA64_BUS_SPACE_MEM; static int dig64_to_uart_parity[] = { UART_PARITY_NONE, UART_PARITY_NONE, UART_PARITY_EVEN, UART_PARITY_ODD, UART_PARITY_MARK, UART_PARITY_SPACE }; int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { struct dig64_hcdp_table *tbl; struct dig64_hcdp_entry *ent; bus_addr_t addr; unsigned int i; /* * Use the DIG64 HCDP table if present. */ if (bootinfo.bi_hcdp != 0) { tbl = (void*)IA64_PHYS_TO_RR7(bootinfo.bi_hcdp); for (i = 0; i < tbl->entries; i++) { ent = tbl->entry + i; if (devtype == UART_DEV_CONSOLE && ent->type != DIG64_HCDP_CONSOLE) continue; if (devtype == UART_DEV_DBGPORT && ent->type != DIG64_HCDP_DBGPORT) continue; addr = ent->address.addr_high; addr = (addr << 32) + ent->address.addr_low; di->ops = uart_ns8250_ops; di->bas.chan = 0; di->bas.bst = (ent->address.addr_space == 0) ? uart_bus_space_mem : uart_bus_space_io; if (bus_space_map(di->bas.bst, addr, 8, 0, &di->bas.bsh) != 0) continue; di->bas.regshft = 0; di->bas.rclk = ent->pclock << 4; /* We don't deal with 64-bit baud rates. */ di->baudrate = ent->baud_low; di->databits = ent->databits; di->stopbits = ent->stopbits; di->parity = (ent->parity >= 6) ? UART_PARITY_NONE : dig64_to_uart_parity[ent->parity]; return (0); } /* FALLTHROUGH */ } /* Check the environment. */ return (uart_getenv(devtype, di)); } + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ + +} Index: head/sys/dev/uart/uart_cpu_pc98.c =================================================================== --- head/sys/dev/uart/uart_cpu_pc98.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_pc98.c (revision 133735) @@ -1,106 +1,112 @@ /* * Copyright (c) 2003 M. Warner Losh, Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include bus_space_tag_t uart_bus_space_io = I386_BUS_SPACE_IO; bus_space_tag_t uart_bus_space_mem = I386_BUS_SPACE_MEM; int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return (0); /* XXX */ } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { unsigned int i, ivar, flags; /* Check the environment. */ if (uart_getenv(devtype, di) == 0) return (0); /* * There is a serial port on all pc98 hardware. It is 8251 or * an enhance version of that. Some pc98 have the second serial * port which is 16550A compatible. However, for the sio driver, * flags selected which type of uart was in the sytem. We use * something similar to sort things out. */ for (i = 0; i < 1; i++) { if (resource_int_value("uart", i, "flags", &flags)) continue; if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(flags)) continue; if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(flags)) 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, "port", &ivar) != 0 || ivar == 0) continue; /* * Got it. Fill in the instance and return it. We have * both i8251 an ns8250 and successors on pc98. */ if (flags & 0x100) di->ops = uart_ns8250_ops; else di->ops = uart_i8251_ops; di->bas.chan = 0; di->bas.bst = uart_bus_space_io; if (bus_space_map(di->bas.bst, ivar, 8, 0, &di->bas.bsh) != 0) continue; di->bas.regshft = 0; di->bas.rclk = 0; if (resource_int_value("uart", i, "baud", &ivar) != 0) ivar = 0; di->baudrate = ivar; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; return (0); } return (ENXIO); } + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ + +} Index: head/sys/dev/uart/uart_cpu_sparc64.c =================================================================== --- head/sys/dev/uart/uart_cpu_sparc64.c (revision 133734) +++ head/sys/dev/uart/uart_cpu_sparc64.c (revision 133735) @@ -1,242 +1,288 @@ /* * Copyright (c) 2003, 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); +#include "opt_isa.h" + #include #include #include #include +#include +#include #include #include +#include + #include +#include #include +#include +#include + bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; static struct bus_space_tag bst_store[3]; static int uart_cpu_channel(char *dev) { char alias[64]; phandle_t aliases; int len; strcpy(alias, dev); if ((aliases = OF_finddevice("/aliases")) != -1) OF_getprop(aliases, dev, alias, sizeof(alias)); len = strlen(alias); if (len < 2 || alias[len - 2] != ':' || alias[len - 1] < 'a' || alias[len - 1] > 'b') return (0); return (alias[len - 1] - 'a' + 1); } int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh) ? 1 : 0); } /* * Get the address of the UART that is selected as the console, if the * console is an UART of course. Note that we enforce that both stdin and * stdout are selected. * Note that the currently active console (i.e. /chosen/stdout and * /chosen/stdin) may not be the same as the device selected in the * environment (ie /options/output-device and /options/input-device) because * keyboard and screen were selected but the keyboard was unplugged or the * user has changed the environment. In the latter case I would assume that * the user expects that FreeBSD uses the new console setting. * For weirder configurations, use ofw_console(4). */ static phandle_t uart_cpu_getdev_console(phandle_t options, char *dev, size_t devsz) { char buf[32]; phandle_t input; if (OF_getprop(options, "input-device", dev, devsz) == -1) return (-1); if ((input = OF_finddevice(dev)) == -1) return (-1); if (OF_getprop(options, "output-device", buf, sizeof(buf)) == -1) return (-1); if (!strcmp(dev, "keyboard") && !strcmp(buf, "screen")) { phandle_t chosen; ihandle_t stdin, stdout; if ((chosen = OF_finddevice("/chosen")) == -1) return (-1); if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) return (-1); if ((input = OF_instance_to_package(stdin)) == -1) return (-1); if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) return (-1); if (OF_instance_to_package(stdout) != input) return (-1); snprintf(dev, devsz, "ttya"); } else if (OF_finddevice(buf) != input) return (-1); if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) return (-1); if (strcmp(buf, "serial") != 0) return (-1); return (input); } /* * Get the address of the UART that's selected as the debug port. Since * there's no place for this in the OF, we use the kernel environment * variable "hw.uart.dbgport". Note however that the variable is not a * list of attributes. It's single device name or alias, as known by * the OF. */ static phandle_t uart_cpu_getdev_dbgport(phandle_t options, char *dev, size_t devsz) { char buf[32]; phandle_t input; if (!getenv_string("hw.uart.dbgport", dev, devsz)) return (-1); if ((input = OF_finddevice(dev)) == -1) return (-1); if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) return (-1); if (strcmp(buf, "serial") != 0) return (-1); return (input); } static phandle_t uart_cpu_getdev_keyboard(phandle_t root, char *dev, size_t devsz) { char buf[32]; phandle_t child, node; child = OF_child(root); while (child != 0 && child != -1) { if (OF_getprop(child, "device_type", buf, sizeof(buf)) != -1 && !strcmp(buf, "serial") && OF_getprop(child, "keyboard", buf, sizeof(buf)) != -1) { OF_getprop(child, "name", dev, devsz); return (child); } if ((node = uart_cpu_getdev_keyboard(child, dev, devsz)) != -1) return (node); child = OF_peer(child); } return (-1); } int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { char buf[32], dev[32], compat[32]; phandle_t input, options; bus_addr_t addr; int baud, bits, error, space, stop; char flag, par; if ((options = OF_finddevice("/options")) == -1) return (ENXIO); switch (devtype) { case UART_DEV_CONSOLE: input = uart_cpu_getdev_console(options, dev, sizeof(dev)); break; case UART_DEV_DBGPORT: input = uart_cpu_getdev_dbgport(options, dev, sizeof(dev)); break; case UART_DEV_KEYBOARD: input = uart_cpu_getdev_keyboard(OF_peer(0), dev, sizeof(dev)); break; default: input = -1; break; } if (input == -1) return (ENXIO); error = OF_decode_addr(input, &space, &addr); if (error) return (error); /* Get the device class. */ if (OF_getprop(input, "name", buf, sizeof(buf)) == -1) return (ENXIO); if (OF_getprop(input, "compatible", compat, sizeof(compat)) == -1) compat[0] = '\0'; di->bas.regshft = 0; di->bas.rclk = 0; if (!strcmp(buf, "se")) { di->ops = uart_sab82532_ops; di->bas.chan = uart_cpu_channel(dev); addr += 64 * (di->bas.chan - 1); } else if (!strcmp(buf, "zs")) { di->ops = uart_z8530_ops; di->bas.chan = uart_cpu_channel(dev); di->bas.regshft = 1; addr += 4 - 4 * (di->bas.chan - 1); } else if (!strcmp(buf, "su") || !strcmp(buf, "su_pnp") || !strcmp(compat, "su") || !strcmp(compat, "su16550")) { di->ops = uart_ns8250_ops; di->bas.chan = 0; } else return (ENXIO); /* Fill in the device info. */ di->bas.bst = &bst_store[devtype]; di->bas.bsh = sparc64_fake_bustag(space, addr, di->bas.bst); /* Get the line settings. */ if (devtype == UART_DEV_KEYBOARD) di->baudrate = 1200; else di->baudrate = 9600; di->databits = 8; di->stopbits = 1; di->parity = UART_PARITY_NONE; snprintf(buf, sizeof(buf), "%s-mode", dev); if (OF_getprop(options, buf, buf, sizeof(buf)) == -1) return (0); if (sscanf(buf, "%d,%d,%c,%d,%c", &baud, &bits, &par, &stop, &flag) != 5) return (0); di->baudrate = baud; di->databits = bits; di->stopbits = stop; di->parity = (par == 'n') ? UART_PARITY_NONE : (par == 'o') ? UART_PARITY_ODD : UART_PARITY_EVEN; return (0); +} + +void +uart_cpu_identify(driver_t *driver, device_t parent) +{ +#ifdef DEV_ISA + char buf[32]; + struct isa_regs reg; + device_t child; + phandle_t node; + ofw_isa_intr_t intr; +#endif + +#ifdef DEV_ISA + if (strcmp(device_get_name(parent), "isa") == 0) { + if ((node = ofw_bus_get_node(device_get_parent(parent))) == 0) + return; + for (node = OF_child(node); node != 0; node = OF_peer(node)) { + if (OF_getprop(node, "name", buf, sizeof(buf)) == -1) + continue; + if (strcmp(buf, "serial") != 0) + continue; + if ((OF_getprop(node, "reg", ®, + sizeof(reg)) == -1) || + (OF_getprop(node, "interrupts", &intr, + sizeof(intr)) == -1)) + continue; + if ((child = BUS_ADD_CHILD(parent, ISA_ORDER_SENSITIVE, + uart_driver_name, -1)) == NULL) + return; + bus_set_resource(child, SYS_RES_IOPORT, 0, + ISA_REG_PHYS(®), reg.size); + bus_set_resource(child, SYS_RES_IRQ, 0, intr, 1); + } + } +#endif } Index: head/sys/modules/uart/Makefile =================================================================== --- head/sys/modules/uart/Makefile (revision 133734) +++ head/sys/modules/uart/Makefile (revision 133735) @@ -1,18 +1,23 @@ # $FreeBSD$ .PATH: ${.CURDIR}/../../dev/uart .if ${MACHINE_ARCH} == "sparc64" uart_bus_ebus= uart_bus_ebus.c ofw_bus_if= ofw_bus_if.h +ofw_pci_if= ofw_pci_if.h +opt_isa= opt_isa.h .endif KMOD= uart SRCS= uart_bus_acpi.c ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \ uart_bus_pci.c uart_bus_puc.c uart_core.c uart_cpu_${MACHINE}.c \ uart_dbg.c uart_dev_i8251.c uart_dev_ns8250.c uart_dev_sab82532.c \ uart_dev_z8530.c uart_if.c uart_subr.c uart_tty.c -SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \ - power_if.h uart_if.h pccarddevs.h +SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} ${ofw_pci_if} \ + ${opt_isa} pci_if.h power_if.h uart_if.h pccarddevs.h + +opt_isa.h: + echo "#define DEV_ISA 1" > ${.TARGET} .include