Converted the isa probe and attach to new-bus so that this driver works
without the (defunct) isa compatibility shims. The new-bus-specific parts are very similar to the ones for the pci probe and attach. This was held up too long waiting for a repo copy to src/sys/dev/cy, so I decided to fix the files in their old place. This gives easier to read and merge diffs anyway. The "count" line in src/sys/conf/files won't be changed until after the repo copy, so old kernel configs that specify a count need not be (and must not be) changed until then. The count is just ignored in the driver. One unfinished detail is dynamic allocation of arrays with <count> and (<count> * 32) entries, and iteration over the arrays. This is now kludged with a fixed count of 10 (up to 10 cards with up to 32 ports each). Prodded by: imp Submitted by: mostly by imp Approved by: imp
This commit is contained in:
parent
cbf67506f6
commit
42d122e125
126
sys/dev/cy/cy.c
126
sys/dev/cy/cy.c
@ -32,7 +32,6 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_compat.h"
|
#include "opt_compat.h"
|
||||||
#include "cy.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
|
|
||||||
|
#include <machine/bus.h>
|
||||||
#include <machine/psl.h>
|
#include <machine/psl.h>
|
||||||
|
#include <sys/rman.h>
|
||||||
|
#include <machine/resource.h>
|
||||||
|
|
||||||
|
#include <isa/isavar.h>
|
||||||
|
|
||||||
#include <i386/isa/isa_device.h>
|
|
||||||
#include <i386/isa/cyreg.h>
|
#include <i386/isa/cyreg.h>
|
||||||
#include <i386/isa/ic/cd1400.h>
|
#include <i386/isa/ic/cd1400.h>
|
||||||
|
|
||||||
#ifndef COMPAT_OLDISA
|
#define NCY 10 /* KLUDGE */
|
||||||
#error "The cy device requires the old isa compatibility shims"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dictionary so that I can name everything *sio* or *com* to compare with
|
* Dictionary so that I can name everything *sio* or *com* to compare with
|
||||||
@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define comstart cystart
|
#define comstart cystart
|
||||||
#define comwakeup cywakeup
|
#define comwakeup cywakeup
|
||||||
#define p_com_addr p_cy_addr
|
#define p_com_addr p_cy_addr
|
||||||
#define sioattach cyattach
|
|
||||||
#define sioclose cyclose
|
#define sioclose cyclose
|
||||||
#define siodriver cydriver
|
#define siodriver cydriver
|
||||||
#define siodtrwakeup cydtrwakeup
|
#define siodtrwakeup cydtrwakeup
|
||||||
@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define sioioctl cyioctl
|
#define sioioctl cyioctl
|
||||||
#define sioopen cyopen
|
#define sioopen cyopen
|
||||||
#define siopoll cypoll
|
#define siopoll cypoll
|
||||||
#define sioprobe cyprobe
|
|
||||||
#define siosettimeout cysettimeout
|
#define siosettimeout cysettimeout
|
||||||
#define siosetwater cysetwater
|
#define siosetwater cysetwater
|
||||||
#define comstop cystop
|
#define comstop cystop
|
||||||
@ -332,25 +331,26 @@ struct com_s {
|
|||||||
u_char obuf2[256];
|
u_char obuf2[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
devclass_t cy_devclass;
|
||||||
|
|
||||||
/* PCI driver entry points. */
|
/* PCI driver entry points. */
|
||||||
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
||||||
driver_intr_t siointr1;
|
driver_intr_t siointr1;
|
||||||
|
|
||||||
static ointhand2_t cyointr;
|
|
||||||
static int cy_units(cy_addr cy_iobase, int cy_align);
|
static int cy_units(cy_addr cy_iobase, int cy_align);
|
||||||
static int sioattach(struct isa_device *dev);
|
|
||||||
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
||||||
static void cd1400_channel_cmd_wait(struct com_s *com);
|
static void cd1400_channel_cmd_wait(struct com_s *com);
|
||||||
static void cd_etc(struct com_s *com, int etc);
|
static void cd_etc(struct com_s *com, int etc);
|
||||||
static int cd_getreg(struct com_s *com, int reg);
|
static int cd_getreg(struct com_s *com, int reg);
|
||||||
static void cd_setreg(struct com_s *com, int reg, int val);
|
static void cd_setreg(struct com_s *com, int reg, int val);
|
||||||
|
static int cy_isa_attach(device_t dev);
|
||||||
|
static int cy_isa_probe(device_t dev);
|
||||||
static timeout_t siodtrwakeup;
|
static timeout_t siodtrwakeup;
|
||||||
static void comhardclose(struct com_s *com);
|
static void comhardclose(struct com_s *com);
|
||||||
static void sioinput(struct com_s *com);
|
static void sioinput(struct com_s *com);
|
||||||
static int commctl(struct com_s *com, int bits, int how);
|
static int commctl(struct com_s *com, int bits, int how);
|
||||||
static int comparam(struct tty *tp, struct termios *t);
|
static int comparam(struct tty *tp, struct termios *t);
|
||||||
static void siopoll(void *arg);
|
static void siopoll(void *arg);
|
||||||
static int sioprobe(struct isa_device *dev);
|
|
||||||
static void siosettimeout(void);
|
static void siosettimeout(void);
|
||||||
static int siosetwater(struct com_s *com, speed_t speed);
|
static int siosetwater(struct com_s *com, speed_t speed);
|
||||||
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
||||||
@ -372,13 +372,21 @@ static int sio_inited;
|
|||||||
static struct com_s *p_com_addr[NSIO];
|
static struct com_s *p_com_addr[NSIO];
|
||||||
#define com_addr(unit) (p_com_addr[unit])
|
#define com_addr(unit) (p_com_addr[unit])
|
||||||
|
|
||||||
struct isa_driver siodriver = {
|
static device_method_t cy_isa_methods[] = {
|
||||||
INTR_TYPE_TTY | INTR_FAST,
|
/* Device interface. */
|
||||||
sioprobe,
|
DEVMETHOD(device_probe, cy_isa_probe),
|
||||||
sioattach,
|
DEVMETHOD(device_attach, cy_isa_attach),
|
||||||
driver_name
|
|
||||||
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
|
|
||||||
|
static driver_t cy_isa_driver = {
|
||||||
|
driver_name,
|
||||||
|
cy_isa_methods,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
|
||||||
|
|
||||||
static d_open_t sioopen;
|
static d_open_t sioopen;
|
||||||
static d_close_t sioclose;
|
static d_close_t sioclose;
|
||||||
@ -423,12 +431,23 @@ static int cy_total_devices;
|
|||||||
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioprobe(dev)
|
cy_isa_probe(device_t dev)
|
||||||
struct isa_device *dev;
|
|
||||||
{
|
{
|
||||||
cy_addr iobase;
|
struct resource *mem_res;
|
||||||
|
cy_addr iobase;
|
||||||
|
int mem_rid;
|
||||||
|
|
||||||
iobase = (cy_addr)dev->id_maddr;
|
if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
|
||||||
|
return (ENXIO);
|
||||||
|
|
||||||
|
mem_rid = 0;
|
||||||
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
|
if (mem_res == NULL) {
|
||||||
|
device_printf(dev, "ioport resource allocation failed\n");
|
||||||
|
return (ENXIO);
|
||||||
|
}
|
||||||
|
iobase = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
||||||
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
||||||
@ -438,7 +457,8 @@ sioprobe(dev)
|
|||||||
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
||||||
DELAY(500);
|
DELAY(500);
|
||||||
|
|
||||||
return (cy_units(iobase, 0) == 0 ? 0 : -1);
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioattach(isdp)
|
cy_isa_attach(device_t dev)
|
||||||
struct isa_device *isdp;
|
|
||||||
{
|
{
|
||||||
int adapter;
|
struct resource *irq_res, *mem_res;
|
||||||
struct com_s *com;
|
void *irq_cookie, *vaddr, *vsc;
|
||||||
|
int irq_rid, mem_rid;
|
||||||
|
|
||||||
com = cyattach_common((cy_addr) isdp->id_maddr, 0);
|
irq_res = NULL;
|
||||||
if (com == NULL)
|
mem_res = NULL;
|
||||||
return (0);
|
|
||||||
adapter = com->unit / CY_MAX_PORTS;
|
|
||||||
|
|
||||||
/*
|
mem_rid = 0;
|
||||||
* XXX
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
* This kludge is to allow ISA/PCI device specifications in the
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
* kernel config file to be in any order.
|
if (mem_res == NULL) {
|
||||||
*/
|
device_printf(dev, "memory resource allocation failed\n");
|
||||||
if (isdp->id_unit != adapter) {
|
goto fail;
|
||||||
printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
|
}
|
||||||
isdp->id_unit = adapter; /* XXX */
|
vaddr = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
|
vsc = cyattach_common(vaddr, 0);
|
||||||
|
if (vsc == NULL) {
|
||||||
|
device_printf(dev, "no ports found!\n");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
isdp->id_ointr = cyointr;
|
irq_rid = 0;
|
||||||
return (1);
|
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
|
||||||
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
|
if (irq_res == NULL) {
|
||||||
|
device_printf(dev, "interrupt resource allocation failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
|
||||||
|
vsc, &irq_cookie) != 0) {
|
||||||
|
device_printf(dev, "interrupt setup failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (irq_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
|
||||||
|
if (mem_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -1106,12 +1148,6 @@ sioinput(com)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cyointr(int unit)
|
|
||||||
{
|
|
||||||
siointr1(com_addr(unit * CY_MAX_PORTS));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
siointr1(vcom)
|
siointr1(vcom)
|
||||||
void *vcom;
|
void *vcom;
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_compat.h"
|
#include "opt_compat.h"
|
||||||
#include "cy.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
|
|
||||||
|
#include <machine/bus.h>
|
||||||
#include <machine/psl.h>
|
#include <machine/psl.h>
|
||||||
|
#include <sys/rman.h>
|
||||||
|
#include <machine/resource.h>
|
||||||
|
|
||||||
|
#include <isa/isavar.h>
|
||||||
|
|
||||||
#include <i386/isa/isa_device.h>
|
|
||||||
#include <i386/isa/cyreg.h>
|
#include <i386/isa/cyreg.h>
|
||||||
#include <i386/isa/ic/cd1400.h>
|
#include <i386/isa/ic/cd1400.h>
|
||||||
|
|
||||||
#ifndef COMPAT_OLDISA
|
#define NCY 10 /* KLUDGE */
|
||||||
#error "The cy device requires the old isa compatibility shims"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dictionary so that I can name everything *sio* or *com* to compare with
|
* Dictionary so that I can name everything *sio* or *com* to compare with
|
||||||
@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define comstart cystart
|
#define comstart cystart
|
||||||
#define comwakeup cywakeup
|
#define comwakeup cywakeup
|
||||||
#define p_com_addr p_cy_addr
|
#define p_com_addr p_cy_addr
|
||||||
#define sioattach cyattach
|
|
||||||
#define sioclose cyclose
|
#define sioclose cyclose
|
||||||
#define siodriver cydriver
|
#define siodriver cydriver
|
||||||
#define siodtrwakeup cydtrwakeup
|
#define siodtrwakeup cydtrwakeup
|
||||||
@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define sioioctl cyioctl
|
#define sioioctl cyioctl
|
||||||
#define sioopen cyopen
|
#define sioopen cyopen
|
||||||
#define siopoll cypoll
|
#define siopoll cypoll
|
||||||
#define sioprobe cyprobe
|
|
||||||
#define siosettimeout cysettimeout
|
#define siosettimeout cysettimeout
|
||||||
#define siosetwater cysetwater
|
#define siosetwater cysetwater
|
||||||
#define comstop cystop
|
#define comstop cystop
|
||||||
@ -332,25 +331,26 @@ struct com_s {
|
|||||||
u_char obuf2[256];
|
u_char obuf2[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
devclass_t cy_devclass;
|
||||||
|
|
||||||
/* PCI driver entry points. */
|
/* PCI driver entry points. */
|
||||||
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
||||||
driver_intr_t siointr1;
|
driver_intr_t siointr1;
|
||||||
|
|
||||||
static ointhand2_t cyointr;
|
|
||||||
static int cy_units(cy_addr cy_iobase, int cy_align);
|
static int cy_units(cy_addr cy_iobase, int cy_align);
|
||||||
static int sioattach(struct isa_device *dev);
|
|
||||||
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
||||||
static void cd1400_channel_cmd_wait(struct com_s *com);
|
static void cd1400_channel_cmd_wait(struct com_s *com);
|
||||||
static void cd_etc(struct com_s *com, int etc);
|
static void cd_etc(struct com_s *com, int etc);
|
||||||
static int cd_getreg(struct com_s *com, int reg);
|
static int cd_getreg(struct com_s *com, int reg);
|
||||||
static void cd_setreg(struct com_s *com, int reg, int val);
|
static void cd_setreg(struct com_s *com, int reg, int val);
|
||||||
|
static int cy_isa_attach(device_t dev);
|
||||||
|
static int cy_isa_probe(device_t dev);
|
||||||
static timeout_t siodtrwakeup;
|
static timeout_t siodtrwakeup;
|
||||||
static void comhardclose(struct com_s *com);
|
static void comhardclose(struct com_s *com);
|
||||||
static void sioinput(struct com_s *com);
|
static void sioinput(struct com_s *com);
|
||||||
static int commctl(struct com_s *com, int bits, int how);
|
static int commctl(struct com_s *com, int bits, int how);
|
||||||
static int comparam(struct tty *tp, struct termios *t);
|
static int comparam(struct tty *tp, struct termios *t);
|
||||||
static void siopoll(void *arg);
|
static void siopoll(void *arg);
|
||||||
static int sioprobe(struct isa_device *dev);
|
|
||||||
static void siosettimeout(void);
|
static void siosettimeout(void);
|
||||||
static int siosetwater(struct com_s *com, speed_t speed);
|
static int siosetwater(struct com_s *com, speed_t speed);
|
||||||
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
||||||
@ -372,13 +372,21 @@ static int sio_inited;
|
|||||||
static struct com_s *p_com_addr[NSIO];
|
static struct com_s *p_com_addr[NSIO];
|
||||||
#define com_addr(unit) (p_com_addr[unit])
|
#define com_addr(unit) (p_com_addr[unit])
|
||||||
|
|
||||||
struct isa_driver siodriver = {
|
static device_method_t cy_isa_methods[] = {
|
||||||
INTR_TYPE_TTY | INTR_FAST,
|
/* Device interface. */
|
||||||
sioprobe,
|
DEVMETHOD(device_probe, cy_isa_probe),
|
||||||
sioattach,
|
DEVMETHOD(device_attach, cy_isa_attach),
|
||||||
driver_name
|
|
||||||
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
|
|
||||||
|
static driver_t cy_isa_driver = {
|
||||||
|
driver_name,
|
||||||
|
cy_isa_methods,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
|
||||||
|
|
||||||
static d_open_t sioopen;
|
static d_open_t sioopen;
|
||||||
static d_close_t sioclose;
|
static d_close_t sioclose;
|
||||||
@ -423,12 +431,23 @@ static int cy_total_devices;
|
|||||||
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioprobe(dev)
|
cy_isa_probe(device_t dev)
|
||||||
struct isa_device *dev;
|
|
||||||
{
|
{
|
||||||
cy_addr iobase;
|
struct resource *mem_res;
|
||||||
|
cy_addr iobase;
|
||||||
|
int mem_rid;
|
||||||
|
|
||||||
iobase = (cy_addr)dev->id_maddr;
|
if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
|
||||||
|
return (ENXIO);
|
||||||
|
|
||||||
|
mem_rid = 0;
|
||||||
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
|
if (mem_res == NULL) {
|
||||||
|
device_printf(dev, "ioport resource allocation failed\n");
|
||||||
|
return (ENXIO);
|
||||||
|
}
|
||||||
|
iobase = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
||||||
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
||||||
@ -438,7 +457,8 @@ sioprobe(dev)
|
|||||||
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
||||||
DELAY(500);
|
DELAY(500);
|
||||||
|
|
||||||
return (cy_units(iobase, 0) == 0 ? 0 : -1);
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioattach(isdp)
|
cy_isa_attach(device_t dev)
|
||||||
struct isa_device *isdp;
|
|
||||||
{
|
{
|
||||||
int adapter;
|
struct resource *irq_res, *mem_res;
|
||||||
struct com_s *com;
|
void *irq_cookie, *vaddr, *vsc;
|
||||||
|
int irq_rid, mem_rid;
|
||||||
|
|
||||||
com = cyattach_common((cy_addr) isdp->id_maddr, 0);
|
irq_res = NULL;
|
||||||
if (com == NULL)
|
mem_res = NULL;
|
||||||
return (0);
|
|
||||||
adapter = com->unit / CY_MAX_PORTS;
|
|
||||||
|
|
||||||
/*
|
mem_rid = 0;
|
||||||
* XXX
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
* This kludge is to allow ISA/PCI device specifications in the
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
* kernel config file to be in any order.
|
if (mem_res == NULL) {
|
||||||
*/
|
device_printf(dev, "memory resource allocation failed\n");
|
||||||
if (isdp->id_unit != adapter) {
|
goto fail;
|
||||||
printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
|
}
|
||||||
isdp->id_unit = adapter; /* XXX */
|
vaddr = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
|
vsc = cyattach_common(vaddr, 0);
|
||||||
|
if (vsc == NULL) {
|
||||||
|
device_printf(dev, "no ports found!\n");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
isdp->id_ointr = cyointr;
|
irq_rid = 0;
|
||||||
return (1);
|
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
|
||||||
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
|
if (irq_res == NULL) {
|
||||||
|
device_printf(dev, "interrupt resource allocation failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
|
||||||
|
vsc, &irq_cookie) != 0) {
|
||||||
|
device_printf(dev, "interrupt setup failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (irq_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
|
||||||
|
if (mem_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -1106,12 +1148,6 @@ sioinput(com)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cyointr(int unit)
|
|
||||||
{
|
|
||||||
siointr1(com_addr(unit * CY_MAX_PORTS));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
siointr1(vcom)
|
siointr1(vcom)
|
||||||
void *vcom;
|
void *vcom;
|
||||||
|
@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define PLX_9060 0x0c
|
#define PLX_9060 0x0c
|
||||||
#define PLX_9080 0x0d
|
#define PLX_9080 0x0d
|
||||||
|
|
||||||
|
extern devclass_t cy_devclass;
|
||||||
|
|
||||||
void *cyattach_common(u_char volatile *iobase, int cy_align);
|
void *cyattach_common(u_char volatile *iobase, int cy_align);
|
||||||
driver_intr_t cyintr;
|
driver_intr_t cyintr;
|
||||||
|
|
||||||
@ -86,8 +88,6 @@ static driver_t cy_pci_driver = {
|
|||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static devclass_t cy_devclass;
|
|
||||||
|
|
||||||
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
|
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
|
||||||
MODULE_DEPEND(cy, pci, 1, 1, 1);
|
MODULE_DEPEND(cy, pci, 1, 1, 1);
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_compat.h"
|
#include "opt_compat.h"
|
||||||
#include "cy.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
|
|
||||||
|
#include <machine/bus.h>
|
||||||
#include <machine/psl.h>
|
#include <machine/psl.h>
|
||||||
|
#include <sys/rman.h>
|
||||||
|
#include <machine/resource.h>
|
||||||
|
|
||||||
|
#include <isa/isavar.h>
|
||||||
|
|
||||||
#include <i386/isa/isa_device.h>
|
|
||||||
#include <i386/isa/cyreg.h>
|
#include <i386/isa/cyreg.h>
|
||||||
#include <i386/isa/ic/cd1400.h>
|
#include <i386/isa/ic/cd1400.h>
|
||||||
|
|
||||||
#ifndef COMPAT_OLDISA
|
#define NCY 10 /* KLUDGE */
|
||||||
#error "The cy device requires the old isa compatibility shims"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dictionary so that I can name everything *sio* or *com* to compare with
|
* Dictionary so that I can name everything *sio* or *com* to compare with
|
||||||
@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define comstart cystart
|
#define comstart cystart
|
||||||
#define comwakeup cywakeup
|
#define comwakeup cywakeup
|
||||||
#define p_com_addr p_cy_addr
|
#define p_com_addr p_cy_addr
|
||||||
#define sioattach cyattach
|
|
||||||
#define sioclose cyclose
|
#define sioclose cyclose
|
||||||
#define siodriver cydriver
|
#define siodriver cydriver
|
||||||
#define siodtrwakeup cydtrwakeup
|
#define siodtrwakeup cydtrwakeup
|
||||||
@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define sioioctl cyioctl
|
#define sioioctl cyioctl
|
||||||
#define sioopen cyopen
|
#define sioopen cyopen
|
||||||
#define siopoll cypoll
|
#define siopoll cypoll
|
||||||
#define sioprobe cyprobe
|
|
||||||
#define siosettimeout cysettimeout
|
#define siosettimeout cysettimeout
|
||||||
#define siosetwater cysetwater
|
#define siosetwater cysetwater
|
||||||
#define comstop cystop
|
#define comstop cystop
|
||||||
@ -332,25 +331,26 @@ struct com_s {
|
|||||||
u_char obuf2[256];
|
u_char obuf2[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
devclass_t cy_devclass;
|
||||||
|
|
||||||
/* PCI driver entry points. */
|
/* PCI driver entry points. */
|
||||||
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
void *cyattach_common(cy_addr cy_iobase, int cy_align);
|
||||||
driver_intr_t siointr1;
|
driver_intr_t siointr1;
|
||||||
|
|
||||||
static ointhand2_t cyointr;
|
|
||||||
static int cy_units(cy_addr cy_iobase, int cy_align);
|
static int cy_units(cy_addr cy_iobase, int cy_align);
|
||||||
static int sioattach(struct isa_device *dev);
|
|
||||||
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
static void cd1400_channel_cmd(struct com_s *com, int cmd);
|
||||||
static void cd1400_channel_cmd_wait(struct com_s *com);
|
static void cd1400_channel_cmd_wait(struct com_s *com);
|
||||||
static void cd_etc(struct com_s *com, int etc);
|
static void cd_etc(struct com_s *com, int etc);
|
||||||
static int cd_getreg(struct com_s *com, int reg);
|
static int cd_getreg(struct com_s *com, int reg);
|
||||||
static void cd_setreg(struct com_s *com, int reg, int val);
|
static void cd_setreg(struct com_s *com, int reg, int val);
|
||||||
|
static int cy_isa_attach(device_t dev);
|
||||||
|
static int cy_isa_probe(device_t dev);
|
||||||
static timeout_t siodtrwakeup;
|
static timeout_t siodtrwakeup;
|
||||||
static void comhardclose(struct com_s *com);
|
static void comhardclose(struct com_s *com);
|
||||||
static void sioinput(struct com_s *com);
|
static void sioinput(struct com_s *com);
|
||||||
static int commctl(struct com_s *com, int bits, int how);
|
static int commctl(struct com_s *com, int bits, int how);
|
||||||
static int comparam(struct tty *tp, struct termios *t);
|
static int comparam(struct tty *tp, struct termios *t);
|
||||||
static void siopoll(void *arg);
|
static void siopoll(void *arg);
|
||||||
static int sioprobe(struct isa_device *dev);
|
|
||||||
static void siosettimeout(void);
|
static void siosettimeout(void);
|
||||||
static int siosetwater(struct com_s *com, speed_t speed);
|
static int siosetwater(struct com_s *com, speed_t speed);
|
||||||
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
|
||||||
@ -372,13 +372,21 @@ static int sio_inited;
|
|||||||
static struct com_s *p_com_addr[NSIO];
|
static struct com_s *p_com_addr[NSIO];
|
||||||
#define com_addr(unit) (p_com_addr[unit])
|
#define com_addr(unit) (p_com_addr[unit])
|
||||||
|
|
||||||
struct isa_driver siodriver = {
|
static device_method_t cy_isa_methods[] = {
|
||||||
INTR_TYPE_TTY | INTR_FAST,
|
/* Device interface. */
|
||||||
sioprobe,
|
DEVMETHOD(device_probe, cy_isa_probe),
|
||||||
sioattach,
|
DEVMETHOD(device_attach, cy_isa_attach),
|
||||||
driver_name
|
|
||||||
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
|
|
||||||
|
static driver_t cy_isa_driver = {
|
||||||
|
driver_name,
|
||||||
|
cy_isa_methods,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
|
||||||
|
|
||||||
static d_open_t sioopen;
|
static d_open_t sioopen;
|
||||||
static d_close_t sioclose;
|
static d_close_t sioclose;
|
||||||
@ -423,12 +431,23 @@ static int cy_total_devices;
|
|||||||
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioprobe(dev)
|
cy_isa_probe(device_t dev)
|
||||||
struct isa_device *dev;
|
|
||||||
{
|
{
|
||||||
cy_addr iobase;
|
struct resource *mem_res;
|
||||||
|
cy_addr iobase;
|
||||||
|
int mem_rid;
|
||||||
|
|
||||||
iobase = (cy_addr)dev->id_maddr;
|
if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
|
||||||
|
return (ENXIO);
|
||||||
|
|
||||||
|
mem_rid = 0;
|
||||||
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
|
if (mem_res == NULL) {
|
||||||
|
device_printf(dev, "ioport resource allocation failed\n");
|
||||||
|
return (ENXIO);
|
||||||
|
}
|
||||||
|
iobase = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
|
||||||
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
|
||||||
@ -438,7 +457,8 @@ sioprobe(dev)
|
|||||||
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
|
||||||
DELAY(500);
|
DELAY(500);
|
||||||
|
|
||||||
return (cy_units(iobase, 0) == 0 ? 0 : -1);
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sioattach(isdp)
|
cy_isa_attach(device_t dev)
|
||||||
struct isa_device *isdp;
|
|
||||||
{
|
{
|
||||||
int adapter;
|
struct resource *irq_res, *mem_res;
|
||||||
struct com_s *com;
|
void *irq_cookie, *vaddr, *vsc;
|
||||||
|
int irq_rid, mem_rid;
|
||||||
|
|
||||||
com = cyattach_common((cy_addr) isdp->id_maddr, 0);
|
irq_res = NULL;
|
||||||
if (com == NULL)
|
mem_res = NULL;
|
||||||
return (0);
|
|
||||||
adapter = com->unit / CY_MAX_PORTS;
|
|
||||||
|
|
||||||
/*
|
mem_rid = 0;
|
||||||
* XXX
|
mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
|
||||||
* This kludge is to allow ISA/PCI device specifications in the
|
0ul, ~0ul, 0ul, RF_ACTIVE);
|
||||||
* kernel config file to be in any order.
|
if (mem_res == NULL) {
|
||||||
*/
|
device_printf(dev, "memory resource allocation failed\n");
|
||||||
if (isdp->id_unit != adapter) {
|
goto fail;
|
||||||
printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
|
}
|
||||||
isdp->id_unit = adapter; /* XXX */
|
vaddr = rman_get_virtual(mem_res);
|
||||||
|
|
||||||
|
vsc = cyattach_common(vaddr, 0);
|
||||||
|
if (vsc == NULL) {
|
||||||
|
device_printf(dev, "no ports found!\n");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
isdp->id_ointr = cyointr;
|
irq_rid = 0;
|
||||||
return (1);
|
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
|
||||||
|
RF_SHAREABLE | RF_ACTIVE);
|
||||||
|
if (irq_res == NULL) {
|
||||||
|
device_printf(dev, "interrupt resource allocation failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
|
||||||
|
vsc, &irq_cookie) != 0) {
|
||||||
|
device_printf(dev, "interrupt setup failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (irq_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
|
||||||
|
if (mem_res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
|
||||||
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -1106,12 +1148,6 @@ sioinput(com)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cyointr(int unit)
|
|
||||||
{
|
|
||||||
siointr1(com_addr(unit * CY_MAX_PORTS));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
siointr1(vcom)
|
siointr1(vcom)
|
||||||
void *vcom;
|
void *vcom;
|
||||||
|
@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define PLX_9060 0x0c
|
#define PLX_9060 0x0c
|
||||||
#define PLX_9080 0x0d
|
#define PLX_9080 0x0d
|
||||||
|
|
||||||
|
extern devclass_t cy_devclass;
|
||||||
|
|
||||||
void *cyattach_common(u_char volatile *iobase, int cy_align);
|
void *cyattach_common(u_char volatile *iobase, int cy_align);
|
||||||
driver_intr_t cyintr;
|
driver_intr_t cyintr;
|
||||||
|
|
||||||
@ -86,8 +88,6 @@ static driver_t cy_pci_driver = {
|
|||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static devclass_t cy_devclass;
|
|
||||||
|
|
||||||
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
|
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
|
||||||
MODULE_DEPEND(cy, pci, 1, 1, 1);
|
MODULE_DEPEND(cy, pci, 1, 1, 1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user