rtems_device_driver rtd316_initialize( rtems_device_major_number major, rtems_device_minor_number minor_arg, void *arg ) { int p; console_tbl *ports; console_tbl *port_p; /* * Now allocate array of device structures and fill them in */ ports = calloc( 2, sizeof( console_tbl ) ); port_p = ports; for ( p=0 ; p<2 ; p++ ) { char name[32]; sprintf( name, "/dev/rtd316_1_%d", p ); printk("Found %s\n", name ); port_p->sDeviceName = strdup( name ); port_p->deviceType = SERIAL_Z85C30; #if 0 port_p->pDeviceFns = &z85c30_fns_polled; #else port_p->pDeviceFns = &z85c30_fns; #endif port_p->deviceProbe = NULL; port_p->pDeviceFlow = NULL; port_p->ulMargin = 16; port_p->ulHysteresis = 8; port_p->pDeviceParams = (void *) 9600; port_p->getRegister = rtd316_com_get_register; port_p->setRegister = rtd316_com_set_register; port_p->getData = NULL; port_p->setData = NULL; port_p->ulClock = RTD_CLOCK_RATE; port_p->ulIntVector = 9; if ( p==0 ) { port_p->ulDataPort = 0; port_p->ulCtrlPort1 = 0x340; port_p->ulCtrlPort2 = 0x341; } else { port_p->ulDataPort = 1; port_p->ulCtrlPort1 = 0x342; port_p->ulCtrlPort2 = 0x343; } port_p++; } /* end ports */ /* * Register the devices */ console_register_devices( ports, 2 ); return RTEMS_SUCCESSFUL; }
rtems_device_driver exar17d15x_initialize( rtems_device_major_number major, rtems_device_minor_number minor_arg, void *arg ) { // int pbus, pdev, pfun; exar17d15x_conf_t conf[MAX_BOARDS]; int boards = 0; int b = 0; int p; console_tbl *ports; console_tbl *port_p; int pbus; int pdev; int pfun; int status; int instance; int i; int total_ports = 0; for ( b=0 ; b<MAX_BOARDS ; b++ ) { conf[b].found = false; } /* * Scan for Serial port boards * * NOTE: There appear to be Exar parts with 2 and 4 ports which would * be easy to support. Just change the hard-coded 8 ports per * board to variable and adjust. * * NOTE: There are likely other board vendors which could be supported * by this. */ for ( instance=0 ; instance < MAX_BOARDS ; instance++ ) { for ( i=0 ; Supported[i].ports != 0 ; i++ ) { status = pci_find_device( Supported[i].vendor, Supported[i].device, instance, &pbus, &pdev, &pfun ); if ( status == PCIB_ERR_SUCCESS ) { boards++; conf[instance].found = true; conf[instance].ports = Supported[i].ports; total_ports += conf[instance].ports; break; } } if ( status != PCIB_ERR_SUCCESS ) continue; pci_read_config_byte( pbus, pdev, pfun, PCI_INTERRUPT_LINE, &conf[instance].irq ); pci_read_config_dword( pbus, pdev, pfun, PCI_BASE_ADDRESS_0, &conf[instance].base ); printk( "Found Exar 17D15x %d at 0x%08lx IRQ %d with %d ports\n", instance, conf[instance].base, conf[instance].irq, conf[instance].ports ); } /* * Now allocate array of device structures and fill them in */ ports = calloc( total_ports, sizeof( console_tbl ) ); port_p = ports; for ( b=0 ; b<MAX_BOARDS ; b++ ) { if ( conf[b].found == false ) continue; for ( p=0 ; p<conf[b].ports ; p++ ) { char name[32]; sprintf( name, "/dev/exar17d15x_%d_%d", b, p ); //printk("Found %s\n", name ); port_p->sDeviceName = strdup( name ); port_p->deviceType = SERIAL_NS16550; #if 1 port_p->pDeviceFns = &ns16550_fns_polled; #else port_p->pDeviceFns = &ns16550_fns; #endif port_p->deviceProbe = NULL; port_p->pDeviceFlow = NULL; port_p->ulMargin = 16; port_p->ulHysteresis = 8; port_p->pDeviceParams = (void *) 9600; port_p->ulCtrlPort1 = conf[b].base + (p * 0x0200); port_p->ulCtrlPort2 = 0; /* NA */ port_p->ulDataPort = 0; /* NA */ port_p->getRegister = xr17d15x_get_register; port_p->setRegister = xr17d15x_set_register; port_p->getData = NULL; /* NA */ port_p->setData = NULL; /* NA */ port_p->ulClock = EXAR_CLOCK_RATE; port_p->ulIntVector = conf[b].irq; port_p++; } /* end ports */ } /* end boards */ /* * Register the devices */ if ( boards ) console_register_devices( ports, total_ports ); return RTEMS_SUCCESSFUL; }