diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-24 21:45:37 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-24 21:45:37 +0000 |
commit | ec5e81757f7b9937e9fee45bbbdc46de6a0e7211 (patch) | |
tree | 58f12d233f000d6ab1e3b45b90c933c67642c9a3 | |
parent | 5e667b5515dde94b3685ef381e4ce788b52add25 (diff) |
remove freebsd 2 and 3 support, from freebsd via jakemsr@jakemsr.com
-rw-r--r-- | sys/dev/pci/bktr/bktr_os.c | 465 |
1 files changed, 1 insertions, 464 deletions
diff --git a/sys/dev/pci/bktr/bktr_os.c b/sys/dev/pci/bktr/bktr_os.c index 1422c19b9c0..118bf1581db 100644 --- a/sys/dev/pci/bktr/bktr_os.c +++ b/sys/dev/pci/bktr/bktr_os.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_os.c,v 1.16 2003/07/04 14:47:28 mickey Exp $ */ +/* $OpenBSD: bktr_os.c,v 1.17 2004/05/24 21:45:36 mickey Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_os.c,v 1.20 2000/10/20 08:16:53 roger Exp $ */ /* @@ -812,469 +812,6 @@ int bktr_poll( dev_t dev, int events, struct proc *p) #endif /* FreeBSD 4.x specific kernel interface routines */ -/**********************************/ -/* *** FreeBSD 2.2.x and 3.x *** */ -/**********************************/ - -#if ((__FreeBSD__ == 2) || (__FreeBSD__ == 3)) - -static bktr_reg_t brooktree[ NBKTR ]; - -static const char *bktr_probe( pcici_t tag, pcidi_t type ); -static void bktr_attach( pcici_t tag, int unit ); -static void bktr_intr(void *arg) { common_bktr_intr(arg); } - -static u_long bktr_count; - -static struct pci_device bktr_device = { - "bktr", - bktr_probe, - bktr_attach, - &bktr_count -}; - -DATA_SET (pcidevice_set, bktr_device); - -static d_open_t bktr_open; -static d_close_t bktr_close; -static d_read_t bktr_read; -static d_write_t bktr_write; -static d_ioctl_t bktr_ioctl; -static d_mmap_t bktr_mmap; -static d_poll_t bktr_poll; - -#define CDEV_MAJOR 92 -static struct cdevsw bktr_cdevsw = -{ - bktr_open, bktr_close, bktr_read, bktr_write, - bktr_ioctl, nostop, nullreset, nodevtotty, - bktr_poll, bktr_mmap, NULL, "bktr", - NULL, -1 -}; - -static int bktr_devsw_installed; - -static void -bktr_drvinit( void *unused ) -{ - dev_t dev; - - if ( ! bktr_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&bktr_cdevsw, NULL); - bktr_devsw_installed = 1; - } -} - -SYSINIT(bktrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bktr_drvinit,NULL) - -/* - * the boot time probe routine. - */ -static const char * -bktr_probe( pcici_t tag, pcidi_t type ) -{ - unsigned int rev = pci_conf_read( tag, PCIR_REVID) & 0x000000ff; - - if (PCI_VENDOR(type) == PCI_VENDOR_BROOKTREE) - { - switch (PCI_PRODUCT(type)) { - case PCI_PRODUCT_BROOKTREE_BT848: - if (rev == 0x12) return("BrookTree 848A"); - else return("BrookTree 848"); - case PCI_PRODUCT_BROOKTREE_BT849: - return("BrookTree 849A"); - case PCI_PRODUCT_BROOKTREE_BT878: - return("BrookTree 878"); - case PCI_PRODUCT_BROOKTREE_BT879: - return("BrookTree 879"); - } - }; - - return ((char *)0); -} - -/* - * the attach routine. - */ -static void -bktr_attach( pcici_t tag, int unit ) -{ - bktr_ptr_t bktr; - u_long latency; - u_long fun; - unsigned int rev; - unsigned long base; -#ifdef BROOKTREE_IRQ - u_long old_irq, new_irq; -#endif - - bktr = &brooktree[unit]; - - if (unit >= NBKTR) { - printf("brooktree%d: attach: only %d units configured.\n", - unit, NBKTR); - printf("brooktree%d: attach: invalid unit number.\n", unit); - return; - } - - /* build the device name for bktr_name() */ - snprintf(bktr->bktr_xname, sizeof(bktr->bktr_xname), "bktr%d",unit); - - /* Enable Memory Mapping */ - fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); - pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 2); - - /* Enable Bus Mastering */ - fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); - pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 4); - - bktr->tag = tag; - - - /* - * Map control/status registers - */ - pci_map_mem( tag, PCI_MAP_REG_START, (vm_offset_t *) &base, - &bktr->phys_base ); -#if (__FreeBSD_version >= 300000) - bktr->memt = I386_BUS_SPACE_MEM; /* XXX should use proper bus space */ - bktr->memh = (bus_space_handle_t)base; /* XXX functions here */ -#endif - - /* - * Disable the brooktree device - */ - OUTL(bktr, BKTR_INT_MASK, ALL_INTS_DISABLED); - OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_RISC_DISABLED); - -#ifdef BROOKTREE_IRQ /* from the configuration file */ - old_irq = pci_conf_read(tag, PCI_INTERRUPT_REG); - pci_conf_write(tag, PCI_INTERRUPT_REG, BROOKTREE_IRQ); - new_irq = pci_conf_read(tag, PCI_INTERRUPT_REG); - printf("bktr%d: attach: irq changed from %d to %d\n", - unit, (old_irq & 0xff), (new_irq & 0xff)); -#endif - - /* - * setup the interrupt handling routine - */ - pci_map_int(tag, bktr_intr, (void *) bktr, &tty_imask); - - - /* Update the Device Control Register */ - /* on Bt878 and Bt879 cards */ - fun = pci_conf_read(tag, 0x40); - fun = fun | 1; /* Enable writes to the sub-system vendor ID */ - -#if defined( BKTR_430_FX_MODE ) - if (bootverbose) printf("Using 430 FX chipset compatibility mode\n"); - fun = fun | 2; /* Enable Intel 430 FX compatibility mode */ -#endif - -#if defined( BKTR_SIS_VIA_MODE ) - if (bootverbose) printf("Using SiS/VIA chipset compatibility mode\n"); - fun = fun | 4; /* Enable SiS/VIA compatibility mode (usefull for - OPTi chipset motherboards too */ -#endif - pci_conf_write(tag, 0x40, fun); - - - /* XXX call bt848_i2c dependent attach() routine */ -#if defined(BKTR_USE_FREEBSD_SMBUS) - if (bt848_i2c_attach(unit, bktr, &bktr->i2c_sc)) - printf("bktr%d: i2c_attach: can't attach\n", unit); -#endif - - -/* - * PCI latency timer. 32 is a good value for 4 bus mastering slots, if - * you have more than four, then 16 would probably be a better value. - */ -#ifndef BROOKTREE_DEF_LATENCY_VALUE -#define BROOKTREE_DEF_LATENCY_VALUE 10 -#endif - latency = pci_conf_read(tag, PCI_LATENCY_TIMER); - latency = (latency >> 8) & 0xff; - if ( bootverbose ) { - if (latency) - printf("brooktree%d: PCI bus latency is", unit); - else - printf("brooktree%d: PCI bus latency was 0 changing to", - unit); - } - if ( !latency ) { - latency = BROOKTREE_DEF_LATENCY_VALUE; - pci_conf_write(tag, PCI_LATENCY_TIMER, latency<<8); - } - if ( bootverbose ) { - printf(" %d.\n", (int) latency); - } - - - /* read the pci device id and revision id */ - fun = pci_conf_read(tag, PCI_ID_REG); - rev = pci_conf_read(tag, PCIR_REVID) & 0x000000ff; - - /* call the common attach code */ - common_bktr_attach( bktr, unit, fun, rev ); - -} - - -/* - * Special Memory Allocation - */ -vm_offset_t -get_bktr_mem( int unit, unsigned size ) -{ - vm_offset_t addr = 0; - - addr = vm_page_alloc_contig(size, 0x100000, 0xffffffff, 1<<24); - if (addr == 0) - addr = vm_page_alloc_contig(size, 0x100000, 0xffffffff, - PAGE_SIZE); - if (addr == 0) { - printf("bktr%d: Unable to allocate %d bytes of memory.\n", - unit, size); - } - - return( addr ); -} - -/*--------------------------------------------------------- -** -** BrookTree 848 character device driver routines -** -**--------------------------------------------------------- -*/ - - -#define VIDEO_DEV 0x00 -#define TUNER_DEV 0x01 -#define VBI_DEV 0x02 - -#define UNIT(x) ((x) & 0x0f) -#define FUNCTION(x) ((x >> 4) & 0x0f) - - -/* - * - */ -int -bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) -{ - bktr_ptr_t bktr; - int unit; - - unit = UNIT( minor(dev) ); - if (unit >= NBKTR) /* unit out of range */ - return( ENXIO ); - - bktr = &(brooktree[ unit ]); - - if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */ - return( ENXIO ); - - - if (bt848_card != -1) { - if ((bt848_card >> 8 == unit ) && - ( (bt848_card & 0xff) < Bt848_MAX_CARD )) { - if ( bktr->bt848_card != (bt848_card & 0xff) ) { - bktr->bt848_card = (bt848_card & 0xff); - probeCard(bktr, FALSE, unit); - } - } - } - - if (bt848_tuner != -1) { - if ((bt848_tuner >> 8 == unit ) && - ( (bt848_tuner & 0xff) < Bt848_MAX_TUNER )) { - if ( bktr->bt848_tuner != (bt848_tuner & 0xff) ) { - bktr->bt848_tuner = (bt848_tuner & 0xff); - probeCard(bktr, FALSE, unit); - } - } - } - - if (bt848_reverse_mute != -1) { - if ((bt848_reverse_mute >> 8) == unit ) { - bktr->reverse_mute = bt848_reverse_mute & 0xff; - } - } - - if (bt848_slow_msp_audio != -1) { - if ((bt848_slow_msp_audio >> 8) == unit ) { - bktr->slow_msp_audio = (bt848_slow_msp_audio & 0xff); - } - } - - switch ( FUNCTION( minor(dev) ) ) { - case VIDEO_DEV: - return( video_open( bktr ) ); - case TUNER_DEV: - return( tuner_open( bktr ) ); - case VBI_DEV: - return( vbi_open( bktr ) ); - } - return( ENXIO ); -} - - -/* - * - */ -int -bktr_close( dev_t dev, int flags, int fmt, struct proc *p ) -{ - bktr_ptr_t bktr; - int unit; - - unit = UNIT( minor(dev) ); - if (unit >= NBKTR) /* unit out of range */ - return( ENXIO ); - - bktr = &(brooktree[ unit ]); - - switch ( FUNCTION( minor(dev) ) ) { - case VIDEO_DEV: - return( video_close( bktr ) ); - case TUNER_DEV: - return( tuner_close( bktr ) ); - case VBI_DEV: - return( vbi_close( bktr ) ); - } - - return( ENXIO ); -} - -/* - * - */ -int -bktr_read( dev_t dev, struct uio *uio, int ioflag ) -{ - bktr_ptr_t bktr; - int unit; - - unit = UNIT(minor(dev)); - if (unit >= NBKTR) /* unit out of range */ - return( ENXIO ); - - bktr = &(brooktree[unit]); - - switch ( FUNCTION( minor(dev) ) ) { - case VIDEO_DEV: - return( video_read( bktr, unit, dev, uio ) ); - case VBI_DEV: - return( vbi_read( bktr, uio, ioflag ) ); - } - return( ENXIO ); -} - - -/* - * - */ -int -bktr_write( dev_t dev, struct uio *uio, int ioflag ) -{ - return( EINVAL ); /* XXX or ENXIO ? */ -} - -/* - * - */ -int -bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) -{ - bktr_ptr_t bktr; - int unit; - - unit = UNIT(minor(dev)); - if (unit >= NBKTR) /* unit out of range */ - return( ENXIO ); - - bktr = &(brooktree[ unit ]); - - if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */ - return( ENOMEM ); - - switch ( FUNCTION( minor(dev) ) ) { - case VIDEO_DEV: - return( video_ioctl( bktr, unit, cmd, arg, pr ) ); - case TUNER_DEV: - return( tuner_ioctl( bktr, unit, cmd, arg, pr ) ); - } - - return( ENXIO ); -} - -/* - * bktr_mmap. - * Note: 2.2.5/2.2.6/2.2.7/3.0 users must manually - * edit the line below and change "vm_offset_t" to "int" - */ -int bktr_mmap( dev_t dev, vm_offset_t offset, int nprot ) - -{ - int unit; - bktr_ptr_t bktr; - - unit = UNIT(minor(dev)); - - if (unit >= NBKTR || FUNCTION(minor(dev)) > 0) - return( -1 ); - - bktr = &(brooktree[ unit ]); - - if (nprot & PROT_EXEC) - return( -1 ); - - if (offset < 0) - return( -1 ); - - if (offset >= bktr->alloc_pages * PAGE_SIZE) - return( -1 ); - - return( i386_btop(vtophys(bktr->bigbuf) + offset) ); -} - -int bktr_poll( dev_t dev, int events, struct proc *p) -{ - int unit; - bktr_ptr_t bktr; - int revents = 0; - - unit = UNIT(minor(dev)); - - if (unit >= NBKTR) - return( -1 ); - - bktr = &(brooktree[ unit ]); - - disable_intr(); - - if (events & (POLLIN | POLLRDNORM)) { - - switch ( FUNCTION( minor(dev) ) ) { - case VBI_DEV: - if(bktr->vbisize == 0) - selrecord(p, &bktr->vbi_select); - else - revents |= events & (POLLIN | POLLRDNORM); - break; - } - } - - enable_intr(); - - return (revents); -} - - -#endif /* FreeBSD 2.2.x and 3.x specific kernel interface routines */ - /*****************/ /* *** BSDI *** */ |