cy_pci.c (116192) | cy_pci.c (123104) |
---|---|
1/* 2 * Copyright (c) 1996, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * Cyclades Y PCI serial interface driver 30 */ 31 32#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1996, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * Cyclades Y PCI serial interface driver 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/cy/cy_pci.c 116192 2003-06-11 06:34:30Z obrien $"); | 33__FBSDID("$FreeBSD: head/sys/dev/cy/cy_pci.c 123104 2003-12-02 12:36:00Z bde $"); |
34 35#include "opt_cy_pci_fastintr.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/bus.h> 41 --- 19 unchanged lines hidden (view full) --- 61#define CY_PLX_9060_ICS_LOCAL_IENABLE 0x800 62 63/* Cyclom-Y Custom Register for PLX ID. */ 64#define PLX_VER 0x3400 65#define PLX_9050 0x0b 66#define PLX_9060 0x0c 67#define PLX_9080 0x0d 68 | 34 35#include "opt_cy_pci_fastintr.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/bus.h> 41 --- 19 unchanged lines hidden (view full) --- 61#define CY_PLX_9060_ICS_LOCAL_IENABLE 0x800 62 63/* Cyclom-Y Custom Register for PLX ID. */ 64#define PLX_VER 0x3400 65#define PLX_9050 0x0b 66#define PLX_9060 0x0c 67#define PLX_9080 0x0d 68 |
69extern int cyattach_common(void *, int); /* Not exactly correct */ 70extern void cyintr(int); | 69void *cyattach_common(u_char volatile *iobase, int cy_align); 70driver_intr_t cyintr; |
71 72static int cy_pci_attach(device_t dev); 73static int cy_pci_probe(device_t dev); 74 75static device_method_t cy_pci_methods[] = { 76 /* Device interface. */ 77 DEVMETHOD(device_probe, cy_pci_probe), 78 DEVMETHOD(device_attach, cy_pci_attach), --- 26 unchanged lines hidden (view full) --- 105 return (0); 106} 107 108static int 109cy_pci_attach(dev) 110 device_t dev; 111{ 112 struct resource *ioport_res, *irq_res, *mem_res; | 71 72static int cy_pci_attach(device_t dev); 73static int cy_pci_probe(device_t dev); 74 75static device_method_t cy_pci_methods[] = { 76 /* Device interface. */ 77 DEVMETHOD(device_probe, cy_pci_probe), 78 DEVMETHOD(device_attach, cy_pci_attach), --- 26 unchanged lines hidden (view full) --- 105 return (0); 106} 107 108static int 109cy_pci_attach(dev) 110 device_t dev; 111{ 112 struct resource *ioport_res, *irq_res, *mem_res; |
113 void *irq_cookie, *vaddr; | 113 void *irq_cookie, *vaddr, *vsc; |
114 u_int32_t ioport; | 114 u_int32_t ioport; |
115 int adapter, irq_setup, ioport_rid, irq_rid, mem_rid; | 115 int irq_setup, ioport_rid, irq_rid, mem_rid; |
116 u_char plx_ver; 117 118 ioport_res = NULL; 119 irq_res = NULL; 120 mem_res = NULL; 121 122 ioport_rid = CY_PCI_BASE_ADDR1; 123 ioport_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &ioport_rid, --- 8 unchanged lines hidden (view full) --- 132 mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid, 133 0ul, ~0ul, 0ul, RF_ACTIVE); 134 if (mem_res == NULL) { 135 device_printf(dev, "memory resource allocation failed\n"); 136 goto fail; 137 } 138 vaddr = rman_get_virtual(mem_res); 139 | 116 u_char plx_ver; 117 118 ioport_res = NULL; 119 irq_res = NULL; 120 mem_res = NULL; 121 122 ioport_rid = CY_PCI_BASE_ADDR1; 123 ioport_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &ioport_rid, --- 8 unchanged lines hidden (view full) --- 132 mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid, 133 0ul, ~0ul, 0ul, RF_ACTIVE); 134 if (mem_res == NULL) { 135 device_printf(dev, "memory resource allocation failed\n"); 136 goto fail; 137 } 138 vaddr = rman_get_virtual(mem_res); 139 |
140 adapter = cyattach_common(vaddr, 1); 141 if (adapter < 0) { | 140 vsc = cyattach_common(vaddr, 1); 141 if (vsc == NULL) { |
142 device_printf(dev, "no ports found!\n"); 143 goto fail; 144 } 145 | 142 device_printf(dev, "no ports found!\n"); 143 goto fail; 144 } 145 |
146 /* 147 * Allocate our interrupt. 148 * XXX Using the ISA interrupt handler directly is a bit of a violation 149 * since it doesn't actually take the same argument. For PCI, the 150 * argument is a void * token, but for ISA it is a unit. Since 151 * there is no overlap in PCI/ISA unit numbers for this driver, and 152 * since the ISA driver must handle the interrupt anyway, we use 153 * the unit number as the token even for PCI. 154 */ | |
155 irq_rid = 0; 156 irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul, 157 RF_SHAREABLE | RF_ACTIVE); 158 if (irq_res == NULL) { 159 device_printf(dev, "interrupt resource allocation failed\n"); 160 goto fail; 161 } 162#ifdef CY_PCI_FASTINTR 163 irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, | 146 irq_rid = 0; 147 irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul, 148 RF_SHAREABLE | RF_ACTIVE); 149 if (irq_res == NULL) { 150 device_printf(dev, "interrupt resource allocation failed\n"); 151 goto fail; 152 } 153#ifdef CY_PCI_FASTINTR 154 irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, |
164 (driver_intr_t *)cyintr, (void *)adapter, &irq_cookie); | 155 cyintr, vsc, &irq_cookie); |
165#else 166 irq_setup = ENXIO; 167#endif 168 if (irq_setup != 0) 169 irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY, | 156#else 157 irq_setup = ENXIO; 158#endif 159 if (irq_setup != 0) 160 irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY, |
170 (driver_intr_t *)cyintr, (void *)adapter, &irq_cookie); | 161 cyintr, vsc, &irq_cookie); |
171 if (irq_setup != 0) { 172 device_printf(dev, "interrupt setup failed\n"); 173 goto fail; 174 } 175 176 /* 177 * Enable the "local" interrupt input to generate a 178 * PCI interrupt. --- 29 unchanged lines hidden --- | 162 if (irq_setup != 0) { 163 device_printf(dev, "interrupt setup failed\n"); 164 goto fail; 165 } 166 167 /* 168 * Enable the "local" interrupt input to generate a 169 * PCI interrupt. --- 29 unchanged lines hidden --- |