diff options
33 files changed, 1537 insertions, 906 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index f2a79481f1c1..a6c1ebd18d0f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -3293,6 +3293,11 @@ L: vtun@office.satix.net | |||
3293 | W: http://vtun.sourceforge.net/tun | 3293 | W: http://vtun.sourceforge.net/tun |
3294 | S: Maintained | 3294 | S: Maintained |
3295 | 3295 | ||
3296 | TURBOCHANNEL SUBSYSTEM | ||
3297 | P: Maciej W. Rozycki | ||
3298 | M: macro@linux-mips.org | ||
3299 | S: Maintained | ||
3300 | |||
3296 | U14-34F SCSI DRIVER | 3301 | U14-34F SCSI DRIVER |
3297 | P: Dario Ballabio | 3302 | P: Dario Ballabio |
3298 | M: ballabio_dario@emc.com | 3303 | M: ballabio_dario@emc.com |
diff --git a/arch/mips/dec/Makefile b/arch/mips/dec/Makefile index ed181fdc3ac9..8b790c2900d5 100644 --- a/arch/mips/dec/Makefile +++ b/arch/mips/dec/Makefile | |||
@@ -6,6 +6,7 @@ obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \ | |||
6 | kn02-irq.o kn02xa-berr.o reset.o setup.o time.o | 6 | kn02-irq.o kn02xa-berr.o reset.o setup.o time.o |
7 | 7 | ||
8 | obj-$(CONFIG_PROM_CONSOLE) += promcon.o | 8 | obj-$(CONFIG_PROM_CONSOLE) += promcon.o |
9 | obj-$(CONFIG_TC) += tc.o | ||
9 | obj-$(CONFIG_CPU_HAS_WB) += wbflush.o | 10 | obj-$(CONFIG_CPU_HAS_WB) += wbflush.o |
10 | 11 | ||
11 | EXTRA_AFLAGS := $(CFLAGS) | 12 | EXTRA_AFLAGS := $(CFLAGS) |
diff --git a/arch/mips/dec/prom/identify.c b/arch/mips/dec/prom/identify.c index 81d5e878ddce..c4e3c1ea0d48 100644 --- a/arch/mips/dec/prom/identify.c +++ b/arch/mips/dec/prom/identify.c | |||
@@ -88,6 +88,7 @@ static inline void prom_init_kn02(void) | |||
88 | { | 88 | { |
89 | dec_kn_slot_base = KN02_SLOT_BASE; | 89 | dec_kn_slot_base = KN02_SLOT_BASE; |
90 | dec_kn_slot_size = KN02_SLOT_SIZE; | 90 | dec_kn_slot_size = KN02_SLOT_SIZE; |
91 | dec_tc_bus = 1; | ||
91 | 92 | ||
92 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN02_RTC); | 93 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN02_RTC); |
93 | } | 94 | } |
@@ -96,6 +97,7 @@ static inline void prom_init_kn02xa(void) | |||
96 | { | 97 | { |
97 | dec_kn_slot_base = KN02XA_SLOT_BASE; | 98 | dec_kn_slot_base = KN02XA_SLOT_BASE; |
98 | dec_kn_slot_size = IOASIC_SLOT_SIZE; | 99 | dec_kn_slot_size = IOASIC_SLOT_SIZE; |
100 | dec_tc_bus = 1; | ||
99 | 101 | ||
100 | ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL); | 102 | ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL); |
101 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY); | 103 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY); |
@@ -105,6 +107,7 @@ static inline void prom_init_kn03(void) | |||
105 | { | 107 | { |
106 | dec_kn_slot_base = KN03_SLOT_BASE; | 108 | dec_kn_slot_base = KN03_SLOT_BASE; |
107 | dec_kn_slot_size = IOASIC_SLOT_SIZE; | 109 | dec_kn_slot_size = IOASIC_SLOT_SIZE; |
110 | dec_tc_bus = 1; | ||
108 | 111 | ||
109 | ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL); | 112 | ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL); |
110 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY); | 113 | dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY); |
diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c index 1058e2f409bb..b8a5e75ba0ab 100644 --- a/arch/mips/dec/setup.c +++ b/arch/mips/dec/setup.c | |||
@@ -53,6 +53,8 @@ unsigned long dec_kn_slot_base, dec_kn_slot_size; | |||
53 | EXPORT_SYMBOL(dec_kn_slot_base); | 53 | EXPORT_SYMBOL(dec_kn_slot_base); |
54 | EXPORT_SYMBOL(dec_kn_slot_size); | 54 | EXPORT_SYMBOL(dec_kn_slot_size); |
55 | 55 | ||
56 | int dec_tc_bus; | ||
57 | |||
56 | spinlock_t ioasic_ssr_lock; | 58 | spinlock_t ioasic_ssr_lock; |
57 | 59 | ||
58 | volatile u32 *ioasic_base; | 60 | volatile u32 *ioasic_base; |
diff --git a/arch/mips/dec/tc.c b/arch/mips/dec/tc.c new file mode 100644 index 000000000000..732027c79834 --- /dev/null +++ b/arch/mips/dec/tc.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * TURBOchannel architecture calls. | ||
3 | * | ||
4 | * Copyright (c) Harald Koerfgen, 1998 | ||
5 | * Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki | ||
6 | * Copyright (c) 2005 James Simmons | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU | ||
9 | * General Public License. See the file "COPYING" in the main | ||
10 | * directory of this archive for more details. | ||
11 | */ | ||
12 | #include <linux/compiler.h> | ||
13 | #include <linux/errno.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/tc.h> | ||
17 | #include <linux/types.h> | ||
18 | |||
19 | #include <asm/addrspace.h> | ||
20 | #include <asm/bootinfo.h> | ||
21 | #include <asm/paccess.h> | ||
22 | |||
23 | #include <asm/dec/interrupts.h> | ||
24 | #include <asm/dec/prom.h> | ||
25 | #include <asm/dec/system.h> | ||
26 | |||
27 | /* | ||
28 | * Protected read byte from TURBOchannel slot space. | ||
29 | */ | ||
30 | int tc_preadb(u8 *valp, void __iomem *addr) | ||
31 | { | ||
32 | return get_dbe(*valp, (u8 *)addr); | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * Get TURBOchannel bus information as specified by the spec, plus | ||
37 | * the slot space base address and the number of slots. | ||
38 | */ | ||
39 | int __init tc_bus_get_info(struct tc_bus *tbus) | ||
40 | { | ||
41 | if (!dec_tc_bus) | ||
42 | return -ENXIO; | ||
43 | |||
44 | memcpy(&tbus->info, rex_gettcinfo(), sizeof(tbus->info)); | ||
45 | tbus->slot_base = CPHYSADDR((long)rex_slot_address(0)); | ||
46 | |||
47 | switch (mips_machtype) { | ||
48 | case MACH_DS5000_200: | ||
49 | tbus->num_tcslots = 7; | ||
50 | break; | ||
51 | case MACH_DS5000_2X0: | ||
52 | case MACH_DS5900: | ||
53 | tbus->ext_slot_base = 0x20000000; | ||
54 | tbus->ext_slot_size = 0x20000000; | ||
55 | /* fall through */ | ||
56 | case MACH_DS5000_1XX: | ||
57 | tbus->num_tcslots = 3; | ||
58 | break; | ||
59 | case MACH_DS5000_XX: | ||
60 | tbus->num_tcslots = 2; | ||
61 | default: | ||
62 | break; | ||
63 | } | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Get the IRQ for the specified slot. | ||
69 | */ | ||
70 | void __init tc_device_get_irq(struct tc_dev *tdev) | ||
71 | { | ||
72 | switch (tdev->slot) { | ||
73 | case 0: | ||
74 | tdev->interrupt = dec_interrupt[DEC_IRQ_TC0]; | ||
75 | break; | ||
76 | case 1: | ||
77 | tdev->interrupt = dec_interrupt[DEC_IRQ_TC1]; | ||
78 | break; | ||
79 | case 2: | ||
80 | tdev->interrupt = dec_interrupt[DEC_IRQ_TC2]; | ||
81 | break; | ||
82 | /* | ||
83 | * Yuck! DS5000/200 onboard devices | ||
84 | */ | ||
85 | case 5: | ||
86 | tdev->interrupt = dec_interrupt[DEC_IRQ_TC5]; | ||
87 | break; | ||
88 | case 6: | ||
89 | tdev->interrupt = dec_interrupt[DEC_IRQ_TC6]; | ||
90 | break; | ||
91 | default: | ||
92 | tdev->interrupt = -1; | ||
93 | break; | ||
94 | } | ||
95 | } | ||
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 4f2ffbd81dc1..38f41a593b12 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2545,7 +2545,7 @@ config RIONET_RX_SIZE | |||
2545 | 2545 | ||
2546 | config FDDI | 2546 | config FDDI |
2547 | bool "FDDI driver support" | 2547 | bool "FDDI driver support" |
2548 | depends on (PCI || EISA) | 2548 | depends on (PCI || EISA || TC) |
2549 | help | 2549 | help |
2550 | Fiber Distributed Data Interface is a high speed local area network | 2550 | Fiber Distributed Data Interface is a high speed local area network |
2551 | design; essentially a replacement for high speed Ethernet. FDDI can | 2551 | design; essentially a replacement for high speed Ethernet. FDDI can |
@@ -2555,11 +2555,31 @@ config FDDI | |||
2555 | will say N. | 2555 | will say N. |
2556 | 2556 | ||
2557 | config DEFXX | 2557 | config DEFXX |
2558 | tristate "Digital DEFEA and DEFPA adapter support" | 2558 | tristate "Digital DEFTA/DEFEA/DEFPA adapter support" |
2559 | depends on FDDI && (PCI || EISA) | 2559 | depends on FDDI && (PCI || EISA || TC) |
2560 | help | 2560 | ---help--- |
2561 | This is support for the DIGITAL series of EISA (DEFEA) and PCI | 2561 | This is support for the DIGITAL series of TURBOchannel (DEFTA), |
2562 | (DEFPA) controllers which can connect you to a local FDDI network. | 2562 | EISA (DEFEA) and PCI (DEFPA) controllers which can connect you |
2563 | to a local FDDI network. | ||
2564 | |||
2565 | To compile this driver as a module, choose M here: the module | ||
2566 | will be called defxx. If unsure, say N. | ||
2567 | |||
2568 | config DEFXX_MMIO | ||
2569 | bool | ||
2570 | prompt "Use MMIO instead of PIO" if PCI || EISA | ||
2571 | depends on DEFXX | ||
2572 | default n if PCI || EISA | ||
2573 | default y | ||
2574 | ---help--- | ||
2575 | This instructs the driver to use EISA or PCI memory-mapped I/O | ||
2576 | (MMIO) as appropriate instead of programmed I/O ports (PIO). | ||
2577 | Enabling this gives an improvement in processing time in parts | ||
2578 | of the driver, but it may cause problems with EISA (DEFEA) | ||
2579 | adapters. TURBOchannel does not have the concept of I/O ports, | ||
2580 | so MMIO is always used for these (DEFTA) adapters. | ||
2581 | |||
2582 | If unsure, say N. | ||
2563 | 2583 | ||
2564 | config SKFP | 2584 | config SKFP |
2565 | tristate "SysKonnect FDDI PCI support" | 2585 | tristate "SysKonnect FDDI PCI support" |
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c index dc3ab3b5c8cb..07d2731c1aa8 100644 --- a/drivers/net/defxx.c +++ b/drivers/net/defxx.c | |||
@@ -10,10 +10,12 @@ | |||
10 | * | 10 | * |
11 | * Abstract: | 11 | * Abstract: |
12 | * A Linux device driver supporting the Digital Equipment Corporation | 12 | * A Linux device driver supporting the Digital Equipment Corporation |
13 | * FDDI EISA and PCI controller families. Supported adapters include: | 13 | * FDDI TURBOchannel, EISA and PCI controller families. Supported |
14 | * adapters include: | ||
14 | * | 15 | * |
15 | * DEC FDDIcontroller/EISA (DEFEA) | 16 | * DEC FDDIcontroller/TURBOchannel (DEFTA) |
16 | * DEC FDDIcontroller/PCI (DEFPA) | 17 | * DEC FDDIcontroller/EISA (DEFEA) |
18 | * DEC FDDIcontroller/PCI (DEFPA) | ||
17 | * | 19 | * |
18 | * The original author: | 20 | * The original author: |
19 | * LVS Lawrence V. Stefani <lstefani@yahoo.com> | 21 | * LVS Lawrence V. Stefani <lstefani@yahoo.com> |
@@ -193,24 +195,27 @@ | |||
193 | * 14 Aug 2004 macro Fix device names reported. | 195 | * 14 Aug 2004 macro Fix device names reported. |
194 | * 14 Jun 2005 macro Use irqreturn_t. | 196 | * 14 Jun 2005 macro Use irqreturn_t. |
195 | * 23 Oct 2006 macro Big-endian host support. | 197 | * 23 Oct 2006 macro Big-endian host support. |
198 | * 14 Dec 2006 macro TURBOchannel support. | ||
196 | */ | 199 | */ |
197 | 200 | ||
198 | /* Include files */ | 201 | /* Include files */ |
199 | 202 | #include <linux/bitops.h> | |
200 | #include <linux/module.h> | ||
201 | #include <linux/kernel.h> | ||
202 | #include <linux/string.h> | ||
203 | #include <linux/errno.h> | ||
204 | #include <linux/ioport.h> | ||
205 | #include <linux/slab.h> | ||
206 | #include <linux/interrupt.h> | ||
207 | #include <linux/pci.h> | ||
208 | #include <linux/delay.h> | 203 | #include <linux/delay.h> |
204 | #include <linux/dma-mapping.h> | ||
205 | #include <linux/eisa.h> | ||
206 | #include <linux/errno.h> | ||
207 | #include <linux/fddidevice.h> | ||
209 | #include <linux/init.h> | 208 | #include <linux/init.h> |
209 | #include <linux/interrupt.h> | ||
210 | #include <linux/ioport.h> | ||
211 | #include <linux/kernel.h> | ||
212 | #include <linux/module.h> | ||
210 | #include <linux/netdevice.h> | 213 | #include <linux/netdevice.h> |
211 | #include <linux/fddidevice.h> | 214 | #include <linux/pci.h> |
212 | #include <linux/skbuff.h> | 215 | #include <linux/skbuff.h> |
213 | #include <linux/bitops.h> | 216 | #include <linux/slab.h> |
217 | #include <linux/string.h> | ||
218 | #include <linux/tc.h> | ||
214 | 219 | ||
215 | #include <asm/byteorder.h> | 220 | #include <asm/byteorder.h> |
216 | #include <asm/io.h> | 221 | #include <asm/io.h> |
@@ -219,8 +224,8 @@ | |||
219 | 224 | ||
220 | /* Version information string should be updated prior to each new release! */ | 225 | /* Version information string should be updated prior to each new release! */ |
221 | #define DRV_NAME "defxx" | 226 | #define DRV_NAME "defxx" |
222 | #define DRV_VERSION "v1.09" | 227 | #define DRV_VERSION "v1.10" |
223 | #define DRV_RELDATE "2006/10/23" | 228 | #define DRV_RELDATE "2006/12/14" |
224 | 229 | ||
225 | static char version[] __devinitdata = | 230 | static char version[] __devinitdata = |
226 | DRV_NAME ": " DRV_VERSION " " DRV_RELDATE | 231 | DRV_NAME ": " DRV_VERSION " " DRV_RELDATE |
@@ -235,12 +240,41 @@ static char version[] __devinitdata = | |||
235 | */ | 240 | */ |
236 | #define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128) | 241 | #define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128) |
237 | 242 | ||
243 | #define __unused __attribute__ ((unused)) | ||
244 | |||
245 | #ifdef CONFIG_PCI | ||
246 | #define DFX_BUS_PCI(dev) (dev->bus == &pci_bus_type) | ||
247 | #else | ||
248 | #define DFX_BUS_PCI(dev) 0 | ||
249 | #endif | ||
250 | |||
251 | #ifdef CONFIG_EISA | ||
252 | #define DFX_BUS_EISA(dev) (dev->bus == &eisa_bus_type) | ||
253 | #else | ||
254 | #define DFX_BUS_EISA(dev) 0 | ||
255 | #endif | ||
256 | |||
257 | #ifdef CONFIG_TC | ||
258 | #define DFX_BUS_TC(dev) (dev->bus == &tc_bus_type) | ||
259 | #else | ||
260 | #define DFX_BUS_TC(dev) 0 | ||
261 | #endif | ||
262 | |||
263 | #ifdef CONFIG_DEFXX_MMIO | ||
264 | #define DFX_MMIO 1 | ||
265 | #else | ||
266 | #define DFX_MMIO 0 | ||
267 | #endif | ||
268 | |||
238 | /* Define module-wide (static) routines */ | 269 | /* Define module-wide (static) routines */ |
239 | 270 | ||
240 | static void dfx_bus_init(struct net_device *dev); | 271 | static void dfx_bus_init(struct net_device *dev); |
272 | static void dfx_bus_uninit(struct net_device *dev); | ||
241 | static void dfx_bus_config_check(DFX_board_t *bp); | 273 | static void dfx_bus_config_check(DFX_board_t *bp); |
242 | 274 | ||
243 | static int dfx_driver_init(struct net_device *dev, const char *print_name); | 275 | static int dfx_driver_init(struct net_device *dev, |
276 | const char *print_name, | ||
277 | resource_size_t bar_start); | ||
244 | static int dfx_adap_init(DFX_board_t *bp, int get_buffers); | 278 | static int dfx_adap_init(DFX_board_t *bp, int get_buffers); |
245 | 279 | ||
246 | static int dfx_open(struct net_device *dev); | 280 | static int dfx_open(struct net_device *dev); |
@@ -273,13 +307,13 @@ static void dfx_xmt_flush(DFX_board_t *bp); | |||
273 | 307 | ||
274 | /* Define module-wide (static) variables */ | 308 | /* Define module-wide (static) variables */ |
275 | 309 | ||
276 | static struct net_device *root_dfx_eisa_dev; | 310 | static struct pci_driver dfx_pci_driver; |
311 | static struct eisa_driver dfx_eisa_driver; | ||
312 | static struct tc_driver dfx_tc_driver; | ||
277 | 313 | ||
278 | 314 | ||
279 | /* | 315 | /* |
280 | * ======================= | 316 | * ======================= |
281 | * = dfx_port_write_byte = | ||
282 | * = dfx_port_read_byte = | ||
283 | * = dfx_port_write_long = | 317 | * = dfx_port_write_long = |
284 | * = dfx_port_read_long = | 318 | * = dfx_port_read_long = |
285 | * ======================= | 319 | * ======================= |
@@ -291,12 +325,11 @@ static struct net_device *root_dfx_eisa_dev; | |||
291 | * None | 325 | * None |
292 | * | 326 | * |
293 | * Arguments: | 327 | * Arguments: |
294 | * bp - pointer to board information | 328 | * bp - pointer to board information |
295 | * offset - register offset from base I/O address | 329 | * offset - register offset from base I/O address |
296 | * data - for dfx_port_write_byte and dfx_port_write_long, this | 330 | * data - for dfx_port_write_long, this is a value to write; |
297 | * is a value to write. | 331 | * for dfx_port_read_long, this is a pointer to store |
298 | * for dfx_port_read_byte and dfx_port_read_byte, this | 332 | * the read value |
299 | * is a pointer to store the read value. | ||
300 | * | 333 | * |
301 | * Functional Description: | 334 | * Functional Description: |
302 | * These routines perform the correct operation to read or write | 335 | * These routines perform the correct operation to read or write |
@@ -310,7 +343,7 @@ static struct net_device *root_dfx_eisa_dev; | |||
310 | * registers using the register offsets defined in DEFXX.H. | 343 | * registers using the register offsets defined in DEFXX.H. |
311 | * | 344 | * |
312 | * PCI port block base addresses are assigned by the PCI BIOS or system | 345 | * PCI port block base addresses are assigned by the PCI BIOS or system |
313 | * firmware. There is one 128 byte port block which can be accessed. It | 346 | * firmware. There is one 128 byte port block which can be accessed. It |
314 | * allows for I/O mapping of both PDQ and PFI registers using the register | 347 | * allows for I/O mapping of both PDQ and PFI registers using the register |
315 | * offsets defined in DEFXX.H. | 348 | * offsets defined in DEFXX.H. |
316 | * | 349 | * |
@@ -318,7 +351,7 @@ static struct net_device *root_dfx_eisa_dev; | |||
318 | * None | 351 | * None |
319 | * | 352 | * |
320 | * Assumptions: | 353 | * Assumptions: |
321 | * bp->base_addr is a valid base I/O address for this adapter. | 354 | * bp->base is a valid base I/O address for this adapter. |
322 | * offset is a valid register offset for this adapter. | 355 | * offset is a valid register offset for this adapter. |
323 | * | 356 | * |
324 | * Side Effects: | 357 | * Side Effects: |
@@ -329,69 +362,135 @@ static struct net_device *root_dfx_eisa_dev; | |||
329 | * advantage of strict data type checking. | 362 | * advantage of strict data type checking. |
330 | */ | 363 | */ |
331 | 364 | ||
332 | static inline void dfx_port_write_byte( | 365 | static inline void dfx_writel(DFX_board_t *bp, int offset, u32 data) |
333 | DFX_board_t *bp, | 366 | { |
334 | int offset, | 367 | writel(data, bp->base.mem + offset); |
335 | u8 data | 368 | mb(); |
336 | ) | 369 | } |
337 | 370 | ||
338 | { | 371 | static inline void dfx_outl(DFX_board_t *bp, int offset, u32 data) |
339 | u16 port = bp->base_addr + offset; | 372 | { |
373 | outl(data, bp->base.port + offset); | ||
374 | } | ||
340 | 375 | ||
341 | outb(data, port); | 376 | static void dfx_port_write_long(DFX_board_t *bp, int offset, u32 data) |
342 | } | 377 | { |
378 | struct device __unused *bdev = bp->bus_dev; | ||
379 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
380 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
343 | 381 | ||
344 | static inline void dfx_port_read_byte( | 382 | if (dfx_use_mmio) |
345 | DFX_board_t *bp, | 383 | dfx_writel(bp, offset, data); |
346 | int offset, | 384 | else |
347 | u8 *data | 385 | dfx_outl(bp, offset, data); |
348 | ) | 386 | } |
349 | 387 | ||
350 | { | ||
351 | u16 port = bp->base_addr + offset; | ||
352 | 388 | ||
353 | *data = inb(port); | 389 | static inline void dfx_readl(DFX_board_t *bp, int offset, u32 *data) |
354 | } | 390 | { |
391 | mb(); | ||
392 | *data = readl(bp->base.mem + offset); | ||
393 | } | ||
355 | 394 | ||
356 | static inline void dfx_port_write_long( | 395 | static inline void dfx_inl(DFX_board_t *bp, int offset, u32 *data) |
357 | DFX_board_t *bp, | 396 | { |
358 | int offset, | 397 | *data = inl(bp->base.port + offset); |
359 | u32 data | 398 | } |
360 | ) | ||
361 | 399 | ||
362 | { | 400 | static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data) |
363 | u16 port = bp->base_addr + offset; | 401 | { |
402 | struct device __unused *bdev = bp->bus_dev; | ||
403 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
404 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
364 | 405 | ||
365 | outl(data, port); | 406 | if (dfx_use_mmio) |
366 | } | 407 | dfx_readl(bp, offset, data); |
408 | else | ||
409 | dfx_inl(bp, offset, data); | ||
410 | } | ||
367 | 411 | ||
368 | static inline void dfx_port_read_long( | ||
369 | DFX_board_t *bp, | ||
370 | int offset, | ||
371 | u32 *data | ||
372 | ) | ||
373 | 412 | ||
374 | { | 413 | /* |
375 | u16 port = bp->base_addr + offset; | 414 | * ================ |
415 | * = dfx_get_bars = | ||
416 | * ================ | ||
417 | * | ||
418 | * Overview: | ||
419 | * Retrieves the address range used to access control and status | ||
420 | * registers. | ||
421 | * | ||
422 | * Returns: | ||
423 | * None | ||
424 | * | ||
425 | * Arguments: | ||
426 | * bdev - pointer to device information | ||
427 | * bar_start - pointer to store the start address | ||
428 | * bar_len - pointer to store the length of the area | ||
429 | * | ||
430 | * Assumptions: | ||
431 | * I am sure there are some. | ||
432 | * | ||
433 | * Side Effects: | ||
434 | * None | ||
435 | */ | ||
436 | static void dfx_get_bars(struct device *bdev, | ||
437 | resource_size_t *bar_start, resource_size_t *bar_len) | ||
438 | { | ||
439 | int dfx_bus_pci = DFX_BUS_PCI(bdev); | ||
440 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); | ||
441 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
442 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
376 | 443 | ||
377 | *data = inl(port); | 444 | if (dfx_bus_pci) { |
378 | } | 445 | int num = dfx_use_mmio ? 0 : 1; |
379 | 446 | ||
447 | *bar_start = pci_resource_start(to_pci_dev(bdev), num); | ||
448 | *bar_len = pci_resource_len(to_pci_dev(bdev), num); | ||
449 | } | ||
450 | if (dfx_bus_eisa) { | ||
451 | unsigned long base_addr = to_eisa_device(bdev)->base_addr; | ||
452 | resource_size_t bar; | ||
453 | |||
454 | if (dfx_use_mmio) { | ||
455 | bar = inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_2); | ||
456 | bar <<= 8; | ||
457 | bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_1); | ||
458 | bar <<= 8; | ||
459 | bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_0); | ||
460 | bar <<= 16; | ||
461 | *bar_start = bar; | ||
462 | bar = inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_2); | ||
463 | bar <<= 8; | ||
464 | bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_1); | ||
465 | bar <<= 8; | ||
466 | bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_0); | ||
467 | bar <<= 16; | ||
468 | *bar_len = (bar | PI_MEM_ADD_MASK_M) + 1; | ||
469 | } else { | ||
470 | *bar_start = base_addr; | ||
471 | *bar_len = PI_ESIC_K_CSR_IO_LEN; | ||
472 | } | ||
473 | } | ||
474 | if (dfx_bus_tc) { | ||
475 | *bar_start = to_tc_dev(bdev)->resource.start + | ||
476 | PI_TC_K_CSR_OFFSET; | ||
477 | *bar_len = PI_TC_K_CSR_LEN; | ||
478 | } | ||
479 | } | ||
380 | 480 | ||
381 | /* | 481 | /* |
382 | * ============= | 482 | * ================ |
383 | * = dfx_init_one_pci_or_eisa = | 483 | * = dfx_register = |
384 | * ============= | 484 | * ================ |
385 | * | 485 | * |
386 | * Overview: | 486 | * Overview: |
387 | * Initializes a supported FDDI EISA or PCI controller | 487 | * Initializes a supported FDDI controller |
388 | * | 488 | * |
389 | * Returns: | 489 | * Returns: |
390 | * Condition code | 490 | * Condition code |
391 | * | 491 | * |
392 | * Arguments: | 492 | * Arguments: |
393 | * pdev - pointer to pci device information (NULL for EISA) | 493 | * bdev - pointer to device information |
394 | * ioaddr - pointer to port (NULL for PCI) | ||
395 | * | 494 | * |
396 | * Functional Description: | 495 | * Functional Description: |
397 | * | 496 | * |
@@ -407,56 +506,74 @@ static inline void dfx_port_read_long( | |||
407 | * initialized and the board resources are read and stored in | 506 | * initialized and the board resources are read and stored in |
408 | * the device structure. | 507 | * the device structure. |
409 | */ | 508 | */ |
410 | static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr) | 509 | static int __devinit dfx_register(struct device *bdev) |
411 | { | 510 | { |
412 | static int version_disp; | 511 | static int version_disp; |
413 | char *print_name = DRV_NAME; | 512 | int dfx_bus_pci = DFX_BUS_PCI(bdev); |
513 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
514 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
515 | char *print_name = bdev->bus_id; | ||
414 | struct net_device *dev; | 516 | struct net_device *dev; |
415 | DFX_board_t *bp; /* board pointer */ | 517 | DFX_board_t *bp; /* board pointer */ |
518 | resource_size_t bar_start = 0; /* pointer to port */ | ||
519 | resource_size_t bar_len = 0; /* resource length */ | ||
416 | int alloc_size; /* total buffer size used */ | 520 | int alloc_size; /* total buffer size used */ |
417 | int err; | 521 | struct resource *region; |
522 | int err = 0; | ||
418 | 523 | ||
419 | if (!version_disp) { /* display version info if adapter is found */ | 524 | if (!version_disp) { /* display version info if adapter is found */ |
420 | version_disp = 1; /* set display flag to TRUE so that */ | 525 | version_disp = 1; /* set display flag to TRUE so that */ |
421 | printk(version); /* we only display this string ONCE */ | 526 | printk(version); /* we only display this string ONCE */ |
422 | } | 527 | } |
423 | 528 | ||
424 | if (pdev != NULL) | ||
425 | print_name = pci_name(pdev); | ||
426 | |||
427 | dev = alloc_fddidev(sizeof(*bp)); | 529 | dev = alloc_fddidev(sizeof(*bp)); |
428 | if (!dev) { | 530 | if (!dev) { |
429 | printk(KERN_ERR "%s: unable to allocate fddidev, aborting\n", | 531 | printk(KERN_ERR "%s: Unable to allocate fddidev, aborting\n", |
430 | print_name); | 532 | print_name); |
431 | return -ENOMEM; | 533 | return -ENOMEM; |
432 | } | 534 | } |
433 | 535 | ||
434 | /* Enable PCI device. */ | 536 | /* Enable PCI device. */ |
435 | if (pdev != NULL) { | 537 | if (dfx_bus_pci && pci_enable_device(to_pci_dev(bdev))) { |
436 | err = pci_enable_device (pdev); | 538 | printk(KERN_ERR "%s: Cannot enable PCI device, aborting\n", |
437 | if (err) goto err_out; | 539 | print_name); |
438 | ioaddr = pci_resource_start (pdev, 1); | 540 | goto err_out; |
439 | } | 541 | } |
440 | 542 | ||
441 | SET_MODULE_OWNER(dev); | 543 | SET_MODULE_OWNER(dev); |
442 | if (pdev != NULL) | 544 | SET_NETDEV_DEV(dev, bdev); |
443 | SET_NETDEV_DEV(dev, &pdev->dev); | 545 | |
546 | bp = netdev_priv(dev); | ||
547 | bp->bus_dev = bdev; | ||
548 | dev_set_drvdata(bdev, dev); | ||
444 | 549 | ||
445 | bp = dev->priv; | 550 | dfx_get_bars(bdev, &bar_start, &bar_len); |
446 | 551 | ||
447 | if (!request_region(ioaddr, | 552 | if (dfx_use_mmio) |
448 | pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, | 553 | region = request_mem_region(bar_start, bar_len, print_name); |
449 | print_name)) { | 554 | else |
555 | region = request_region(bar_start, bar_len, print_name); | ||
556 | if (!region) { | ||
450 | printk(KERN_ERR "%s: Cannot reserve I/O resource " | 557 | printk(KERN_ERR "%s: Cannot reserve I/O resource " |
451 | "0x%x @ 0x%lx, aborting\n", print_name, | 558 | "0x%lx @ 0x%lx, aborting\n", |
452 | pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, ioaddr); | 559 | print_name, (long)bar_len, (long)bar_start); |
453 | err = -EBUSY; | 560 | err = -EBUSY; |
454 | goto err_out; | 561 | goto err_out_disable; |
455 | } | 562 | } |
456 | 563 | ||
457 | /* Initialize new device structure */ | 564 | /* Set up I/O base address. */ |
565 | if (dfx_use_mmio) { | ||
566 | bp->base.mem = ioremap_nocache(bar_start, bar_len); | ||
567 | if (!bp->base.mem) { | ||
568 | printk(KERN_ERR "%s: Cannot map MMIO\n", print_name); | ||
569 | goto err_out_region; | ||
570 | } | ||
571 | } else { | ||
572 | bp->base.port = bar_start; | ||
573 | dev->base_addr = bar_start; | ||
574 | } | ||
458 | 575 | ||
459 | dev->base_addr = ioaddr; /* save port (I/O) base address */ | 576 | /* Initialize new device structure */ |
460 | 577 | ||
461 | dev->get_stats = dfx_ctl_get_stats; | 578 | dev->get_stats = dfx_ctl_get_stats; |
462 | dev->open = dfx_open; | 579 | dev->open = dfx_open; |
@@ -465,22 +582,12 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr) | |||
465 | dev->set_multicast_list = dfx_ctl_set_multicast_list; | 582 | dev->set_multicast_list = dfx_ctl_set_multicast_list; |
466 | dev->set_mac_address = dfx_ctl_set_mac_address; | 583 | dev->set_mac_address = dfx_ctl_set_mac_address; |
467 | 584 | ||
468 | if (pdev == NULL) { | 585 | if (dfx_bus_pci) |
469 | /* EISA board */ | 586 | pci_set_master(to_pci_dev(bdev)); |
470 | bp->bus_type = DFX_BUS_TYPE_EISA; | ||
471 | bp->next = root_dfx_eisa_dev; | ||
472 | root_dfx_eisa_dev = dev; | ||
473 | } else { | ||
474 | /* PCI board */ | ||
475 | bp->bus_type = DFX_BUS_TYPE_PCI; | ||
476 | bp->pci_dev = pdev; | ||
477 | pci_set_drvdata (pdev, dev); | ||
478 | pci_set_master (pdev); | ||
479 | } | ||
480 | 587 | ||
481 | if (dfx_driver_init(dev, print_name) != DFX_K_SUCCESS) { | 588 | if (dfx_driver_init(dev, print_name, bar_start) != DFX_K_SUCCESS) { |
482 | err = -ENODEV; | 589 | err = -ENODEV; |
483 | goto err_out_region; | 590 | goto err_out_unmap; |
484 | } | 591 | } |
485 | 592 | ||
486 | err = register_netdev(dev); | 593 | err = register_netdev(dev); |
@@ -499,44 +606,28 @@ err_out_kfree: | |||
499 | sizeof(PI_CONSUMER_BLOCK) + | 606 | sizeof(PI_CONSUMER_BLOCK) + |
500 | (PI_ALIGN_K_DESC_BLK - 1); | 607 | (PI_ALIGN_K_DESC_BLK - 1); |
501 | if (bp->kmalloced) | 608 | if (bp->kmalloced) |
502 | pci_free_consistent(pdev, alloc_size, | 609 | dma_free_coherent(bdev, alloc_size, |
503 | bp->kmalloced, bp->kmalloced_dma); | 610 | bp->kmalloced, bp->kmalloced_dma); |
611 | |||
612 | err_out_unmap: | ||
613 | if (dfx_use_mmio) | ||
614 | iounmap(bp->base.mem); | ||
615 | |||
504 | err_out_region: | 616 | err_out_region: |
505 | release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN); | 617 | if (dfx_use_mmio) |
618 | release_mem_region(bar_start, bar_len); | ||
619 | else | ||
620 | release_region(bar_start, bar_len); | ||
621 | |||
622 | err_out_disable: | ||
623 | if (dfx_bus_pci) | ||
624 | pci_disable_device(to_pci_dev(bdev)); | ||
625 | |||
506 | err_out: | 626 | err_out: |
507 | free_netdev(dev); | 627 | free_netdev(dev); |
508 | return err; | 628 | return err; |
509 | } | 629 | } |
510 | 630 | ||
511 | static int __devinit dfx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
512 | { | ||
513 | return dfx_init_one_pci_or_eisa(pdev, 0); | ||
514 | } | ||
515 | |||
516 | static int __init dfx_eisa_init(void) | ||
517 | { | ||
518 | int rc = -ENODEV; | ||
519 | int i; /* used in for loops */ | ||
520 | u16 port; /* temporary I/O (port) address */ | ||
521 | u32 slot_id; /* EISA hardware (slot) ID read from adapter */ | ||
522 | |||
523 | DBG_printk("In dfx_eisa_init...\n"); | ||
524 | |||
525 | /* Scan for FDDI EISA controllers */ | ||
526 | |||
527 | for (i=0; i < DFX_MAX_EISA_SLOTS; i++) /* only scan for up to 16 EISA slots */ | ||
528 | { | ||
529 | port = (i << 12) + PI_ESIC_K_SLOT_ID; /* port = I/O address for reading slot ID */ | ||
530 | slot_id = inl(port); /* read EISA HW (slot) ID */ | ||
531 | if ((slot_id & 0xF0FFFFFF) == DEFEA_PRODUCT_ID) | ||
532 | { | ||
533 | port = (i << 12); /* recalc base addr */ | ||
534 | |||
535 | if (dfx_init_one_pci_or_eisa(NULL, port) == 0) rc = 0; | ||
536 | } | ||
537 | } | ||
538 | return rc; | ||
539 | } | ||
540 | 631 | ||
541 | /* | 632 | /* |
542 | * ================ | 633 | * ================ |
@@ -544,7 +635,7 @@ static int __init dfx_eisa_init(void) | |||
544 | * ================ | 635 | * ================ |
545 | * | 636 | * |
546 | * Overview: | 637 | * Overview: |
547 | * Initializes EISA and PCI controller bus-specific logic. | 638 | * Initializes the bus-specific controller logic. |
548 | * | 639 | * |
549 | * Returns: | 640 | * Returns: |
550 | * None | 641 | * None |
@@ -560,7 +651,7 @@ static int __init dfx_eisa_init(void) | |||
560 | * None | 651 | * None |
561 | * | 652 | * |
562 | * Assumptions: | 653 | * Assumptions: |
563 | * dev->base_addr has already been set with the proper | 654 | * bp->base has already been set with the proper |
564 | * base I/O address for this device. | 655 | * base I/O address for this device. |
565 | * | 656 | * |
566 | * Side Effects: | 657 | * Side Effects: |
@@ -571,87 +662,103 @@ static int __init dfx_eisa_init(void) | |||
571 | 662 | ||
572 | static void __devinit dfx_bus_init(struct net_device *dev) | 663 | static void __devinit dfx_bus_init(struct net_device *dev) |
573 | { | 664 | { |
574 | DFX_board_t *bp = dev->priv; | 665 | DFX_board_t *bp = netdev_priv(dev); |
575 | u8 val; /* used for I/O read/writes */ | 666 | struct device *bdev = bp->bus_dev; |
667 | int dfx_bus_pci = DFX_BUS_PCI(bdev); | ||
668 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); | ||
669 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
670 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
671 | u8 val; | ||
576 | 672 | ||
577 | DBG_printk("In dfx_bus_init...\n"); | 673 | DBG_printk("In dfx_bus_init...\n"); |
578 | 674 | ||
579 | /* | 675 | /* Initialize a pointer back to the net_device struct */ |
580 | * Initialize base I/O address field in bp structure | ||
581 | * | ||
582 | * Note: bp->base_addr is the same as dev->base_addr. | ||
583 | * It's useful because often we'll need to read | ||
584 | * or write registers where we already have the | ||
585 | * bp pointer instead of the dev pointer. Having | ||
586 | * the base address in the bp structure will | ||
587 | * save a pointer dereference. | ||
588 | * | ||
589 | * IMPORTANT!! This field must be defined before | ||
590 | * any of the dfx_port_* inline functions are | ||
591 | * called. | ||
592 | */ | ||
593 | |||
594 | bp->base_addr = dev->base_addr; | ||
595 | |||
596 | /* And a pointer back to the net_device struct */ | ||
597 | bp->dev = dev; | 676 | bp->dev = dev; |
598 | 677 | ||
599 | /* Initialize adapter based on bus type */ | 678 | /* Initialize adapter based on bus type */ |
600 | 679 | ||
601 | if (bp->bus_type == DFX_BUS_TYPE_EISA) | 680 | if (dfx_bus_tc) |
602 | { | 681 | dev->irq = to_tc_dev(bdev)->interrupt; |
603 | /* Get the interrupt level from the ESIC chip */ | 682 | if (dfx_bus_eisa) { |
604 | 683 | unsigned long base_addr = to_eisa_device(bdev)->base_addr; | |
605 | dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val); | ||
606 | switch ((val & PI_CONFIG_STAT_0_M_IRQ) >> PI_CONFIG_STAT_0_V_IRQ) | ||
607 | { | ||
608 | case PI_CONFIG_STAT_0_IRQ_K_9: | ||
609 | dev->irq = 9; | ||
610 | break; | ||
611 | |||
612 | case PI_CONFIG_STAT_0_IRQ_K_10: | ||
613 | dev->irq = 10; | ||
614 | break; | ||
615 | 684 | ||
616 | case PI_CONFIG_STAT_0_IRQ_K_11: | 685 | /* Get the interrupt level from the ESIC chip. */ |
617 | dev->irq = 11; | 686 | val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0); |
618 | break; | 687 | val &= PI_CONFIG_STAT_0_M_IRQ; |
688 | val >>= PI_CONFIG_STAT_0_V_IRQ; | ||
619 | 689 | ||
620 | case PI_CONFIG_STAT_0_IRQ_K_15: | 690 | switch (val) { |
621 | dev->irq = 15; | 691 | case PI_CONFIG_STAT_0_IRQ_K_9: |
622 | break; | 692 | dev->irq = 9; |
623 | } | 693 | break; |
624 | |||
625 | /* Enable access to I/O on the board by writing 0x03 to Function Control Register */ | ||
626 | 694 | ||
627 | dfx_port_write_byte(bp, PI_ESIC_K_FUNCTION_CNTRL, PI_ESIC_K_FUNCTION_CNTRL_IO_ENB); | 695 | case PI_CONFIG_STAT_0_IRQ_K_10: |
696 | dev->irq = 10; | ||
697 | break; | ||
628 | 698 | ||
629 | /* Set the I/O decode range of the board */ | 699 | case PI_CONFIG_STAT_0_IRQ_K_11: |
700 | dev->irq = 11; | ||
701 | break; | ||
630 | 702 | ||
631 | val = ((dev->base_addr >> 12) << PI_IO_CMP_V_SLOT); | 703 | case PI_CONFIG_STAT_0_IRQ_K_15: |
632 | dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_0_1, val); | 704 | dev->irq = 15; |
633 | dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_1_1, val); | 705 | break; |
706 | } | ||
634 | 707 | ||
635 | /* Enable access to rest of module (including PDQ and packet memory) */ | 708 | /* |
709 | * Enable memory decoding (MEMCS0) and/or port decoding | ||
710 | * (IOCS1/IOCS0) as appropriate in Function Control | ||
711 | * Register. One of the port chip selects seems to be | ||
712 | * used for the Burst Holdoff register, but this bit of | ||
713 | * documentation is missing and as yet it has not been | ||
714 | * determined which of the two. This is also the reason | ||
715 | * the size of the decoded port range is twice as large | ||
716 | * as one required by the PDQ. | ||
717 | */ | ||
636 | 718 | ||
637 | dfx_port_write_byte(bp, PI_ESIC_K_SLOT_CNTRL, PI_SLOT_CNTRL_M_ENB); | 719 | /* Set the decode range of the board. */ |
720 | val = ((bp->base.port >> 12) << PI_IO_CMP_V_SLOT); | ||
721 | outb(base_addr + PI_ESIC_K_IO_ADD_CMP_0_1, val); | ||
722 | outb(base_addr + PI_ESIC_K_IO_ADD_CMP_0_0, 0); | ||
723 | outb(base_addr + PI_ESIC_K_IO_ADD_CMP_1_1, val); | ||
724 | outb(base_addr + PI_ESIC_K_IO_ADD_CMP_1_0, 0); | ||
725 | val = PI_ESIC_K_CSR_IO_LEN - 1; | ||
726 | outb(base_addr + PI_ESIC_K_IO_ADD_MASK_0_1, (val >> 8) & 0xff); | ||
727 | outb(base_addr + PI_ESIC_K_IO_ADD_MASK_0_0, val & 0xff); | ||
728 | outb(base_addr + PI_ESIC_K_IO_ADD_MASK_1_1, (val >> 8) & 0xff); | ||
729 | outb(base_addr + PI_ESIC_K_IO_ADD_MASK_1_0, val & 0xff); | ||
730 | |||
731 | /* Enable the decoders. */ | ||
732 | val = PI_FUNCTION_CNTRL_M_IOCS1 | PI_FUNCTION_CNTRL_M_IOCS0; | ||
733 | if (dfx_use_mmio) | ||
734 | val |= PI_FUNCTION_CNTRL_M_MEMCS0; | ||
735 | outb(base_addr + PI_ESIC_K_FUNCTION_CNTRL, val); | ||
638 | 736 | ||
639 | /* | 737 | /* |
640 | * Map PDQ registers into I/O space. This is done by clearing a bit | 738 | * Enable access to the rest of the module |
641 | * in Burst Holdoff register. | 739 | * (including PDQ and packet memory). |
642 | */ | 740 | */ |
741 | val = PI_SLOT_CNTRL_M_ENB; | ||
742 | outb(base_addr + PI_ESIC_K_SLOT_CNTRL, val); | ||
643 | 743 | ||
644 | dfx_port_read_byte(bp, PI_ESIC_K_BURST_HOLDOFF, &val); | 744 | /* |
645 | dfx_port_write_byte(bp, PI_ESIC_K_BURST_HOLDOFF, (val & ~PI_BURST_HOLDOFF_M_MEM_MAP)); | 745 | * Map PDQ registers into memory or port space. This is |
746 | * done with a bit in the Burst Holdoff register. | ||
747 | */ | ||
748 | val = inb(base_addr + PI_DEFEA_K_BURST_HOLDOFF); | ||
749 | if (dfx_use_mmio) | ||
750 | val |= PI_BURST_HOLDOFF_V_MEM_MAP; | ||
751 | else | ||
752 | val &= ~PI_BURST_HOLDOFF_V_MEM_MAP; | ||
753 | outb(base_addr + PI_DEFEA_K_BURST_HOLDOFF, val); | ||
646 | 754 | ||
647 | /* Enable interrupts at EISA bus interface chip (ESIC) */ | 755 | /* Enable interrupts at EISA bus interface chip (ESIC) */ |
648 | 756 | val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0); | |
649 | dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val); | 757 | val |= PI_CONFIG_STAT_0_M_INT_ENB; |
650 | dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, (val | PI_CONFIG_STAT_0_M_INT_ENB)); | 758 | outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, val); |
651 | } | 759 | } |
652 | else | 760 | if (dfx_bus_pci) { |
653 | { | 761 | struct pci_dev *pdev = to_pci_dev(bdev); |
654 | struct pci_dev *pdev = bp->pci_dev; | ||
655 | 762 | ||
656 | /* Get the interrupt level from the PCI Configuration Table */ | 763 | /* Get the interrupt level from the PCI Configuration Table */ |
657 | 764 | ||
@@ -660,17 +767,70 @@ static void __devinit dfx_bus_init(struct net_device *dev) | |||
660 | /* Check Latency Timer and set if less than minimal */ | 767 | /* Check Latency Timer and set if less than minimal */ |
661 | 768 | ||
662 | pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val); | 769 | pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val); |
663 | if (val < PFI_K_LAT_TIMER_MIN) /* if less than min, override with default */ | 770 | if (val < PFI_K_LAT_TIMER_MIN) { |
664 | { | ||
665 | val = PFI_K_LAT_TIMER_DEF; | 771 | val = PFI_K_LAT_TIMER_DEF; |
666 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val); | 772 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val); |
667 | } | 773 | } |
668 | 774 | ||
669 | /* Enable interrupts at PCI bus interface chip (PFI) */ | 775 | /* Enable interrupts at PCI bus interface chip (PFI) */ |
776 | val = PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB; | ||
777 | dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, val); | ||
778 | } | ||
779 | } | ||
670 | 780 | ||
671 | dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, (PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB)); | 781 | /* |
672 | } | 782 | * ================== |
783 | * = dfx_bus_uninit = | ||
784 | * ================== | ||
785 | * | ||
786 | * Overview: | ||
787 | * Uninitializes the bus-specific controller logic. | ||
788 | * | ||
789 | * Returns: | ||
790 | * None | ||
791 | * | ||
792 | * Arguments: | ||
793 | * dev - pointer to device information | ||
794 | * | ||
795 | * Functional Description: | ||
796 | * Perform bus-specific logic uninitialization. | ||
797 | * | ||
798 | * Return Codes: | ||
799 | * None | ||
800 | * | ||
801 | * Assumptions: | ||
802 | * bp->base has already been set with the proper | ||
803 | * base I/O address for this device. | ||
804 | * | ||
805 | * Side Effects: | ||
806 | * Interrupts are disabled at the adapter bus-specific logic. | ||
807 | */ | ||
808 | |||
809 | static void __devinit dfx_bus_uninit(struct net_device *dev) | ||
810 | { | ||
811 | DFX_board_t *bp = netdev_priv(dev); | ||
812 | struct device *bdev = bp->bus_dev; | ||
813 | int dfx_bus_pci = DFX_BUS_PCI(bdev); | ||
814 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); | ||
815 | u8 val; | ||
816 | |||
817 | DBG_printk("In dfx_bus_uninit...\n"); | ||
818 | |||
819 | /* Uninitialize adapter based on bus type */ | ||
820 | |||
821 | if (dfx_bus_eisa) { | ||
822 | unsigned long base_addr = to_eisa_device(bdev)->base_addr; | ||
823 | |||
824 | /* Disable interrupts at EISA bus interface chip (ESIC) */ | ||
825 | val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0); | ||
826 | val &= ~PI_CONFIG_STAT_0_M_INT_ENB; | ||
827 | outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, val); | ||
828 | } | ||
829 | if (dfx_bus_pci) { | ||
830 | /* Disable interrupts at PCI bus interface chip (PFI) */ | ||
831 | dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 0); | ||
673 | } | 832 | } |
833 | } | ||
674 | 834 | ||
675 | 835 | ||
676 | /* | 836 | /* |
@@ -705,18 +865,16 @@ static void __devinit dfx_bus_init(struct net_device *dev) | |||
705 | 865 | ||
706 | static void __devinit dfx_bus_config_check(DFX_board_t *bp) | 866 | static void __devinit dfx_bus_config_check(DFX_board_t *bp) |
707 | { | 867 | { |
868 | struct device __unused *bdev = bp->bus_dev; | ||
869 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); | ||
708 | int status; /* return code from adapter port control call */ | 870 | int status; /* return code from adapter port control call */ |
709 | u32 slot_id; /* EISA-bus hardware id (DEC3001, DEC3002,...) */ | ||
710 | u32 host_data; /* LW data returned from port control call */ | 871 | u32 host_data; /* LW data returned from port control call */ |
711 | 872 | ||
712 | DBG_printk("In dfx_bus_config_check...\n"); | 873 | DBG_printk("In dfx_bus_config_check...\n"); |
713 | 874 | ||
714 | /* Configuration check only valid for EISA adapter */ | 875 | /* Configuration check only valid for EISA adapter */ |
715 | 876 | ||
716 | if (bp->bus_type == DFX_BUS_TYPE_EISA) | 877 | if (dfx_bus_eisa) { |
717 | { | ||
718 | dfx_port_read_long(bp, PI_ESIC_K_SLOT_ID, &slot_id); | ||
719 | |||
720 | /* | 878 | /* |
721 | * First check if revision 2 EISA controller. Rev. 1 cards used | 879 | * First check if revision 2 EISA controller. Rev. 1 cards used |
722 | * PDQ revision B, so no workaround needed in this case. Rev. 3 | 880 | * PDQ revision B, so no workaround needed in this case. Rev. 3 |
@@ -724,14 +882,11 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp) | |||
724 | * case, either. Only Rev. 2 cards used either Rev. D or E | 882 | * case, either. Only Rev. 2 cards used either Rev. D or E |
725 | * chips, so we must verify the chip revision on Rev. 2 cards. | 883 | * chips, so we must verify the chip revision on Rev. 2 cards. |
726 | */ | 884 | */ |
727 | 885 | if (to_eisa_device(bdev)->id.driver_data == DEFEA_PROD_ID_2) { | |
728 | if (slot_id == DEFEA_PROD_ID_2) | ||
729 | { | ||
730 | /* | 886 | /* |
731 | * Revision 2 FDDI EISA controller found, so let's check PDQ | 887 | * Revision 2 FDDI EISA controller found, |
732 | * revision of adapter. | 888 | * so let's check PDQ revision of adapter. |
733 | */ | 889 | */ |
734 | |||
735 | status = dfx_hw_port_ctrl_req(bp, | 890 | status = dfx_hw_port_ctrl_req(bp, |
736 | PI_PCTRL_M_SUB_CMD, | 891 | PI_PCTRL_M_SUB_CMD, |
737 | PI_SUB_CMD_K_PDQ_REV_GET, | 892 | PI_SUB_CMD_K_PDQ_REV_GET, |
@@ -805,13 +960,20 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp) | |||
805 | */ | 960 | */ |
806 | 961 | ||
807 | static int __devinit dfx_driver_init(struct net_device *dev, | 962 | static int __devinit dfx_driver_init(struct net_device *dev, |
808 | const char *print_name) | 963 | const char *print_name, |
964 | resource_size_t bar_start) | ||
809 | { | 965 | { |
810 | DFX_board_t *bp = dev->priv; | 966 | DFX_board_t *bp = netdev_priv(dev); |
811 | int alloc_size; /* total buffer size needed */ | 967 | struct device *bdev = bp->bus_dev; |
812 | char *top_v, *curr_v; /* virtual addrs into memory block */ | 968 | int dfx_bus_pci = DFX_BUS_PCI(bdev); |
813 | dma_addr_t top_p, curr_p; /* physical addrs into memory block */ | 969 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); |
814 | u32 data; /* host data register value */ | 970 | int dfx_bus_tc = DFX_BUS_TC(bdev); |
971 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
972 | int alloc_size; /* total buffer size needed */ | ||
973 | char *top_v, *curr_v; /* virtual addrs into memory block */ | ||
974 | dma_addr_t top_p, curr_p; /* physical addrs into memory block */ | ||
975 | u32 data, le32; /* host data register value */ | ||
976 | char *board_name = NULL; | ||
815 | 977 | ||
816 | DBG_printk("In dfx_driver_init...\n"); | 978 | DBG_printk("In dfx_driver_init...\n"); |
817 | 979 | ||
@@ -860,8 +1022,8 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
860 | print_name); | 1022 | print_name); |
861 | return(DFX_K_FAILURE); | 1023 | return(DFX_K_FAILURE); |
862 | } | 1024 | } |
863 | data = cpu_to_le32(data); | 1025 | le32 = cpu_to_le32(data); |
864 | memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); | 1026 | memcpy(&bp->factory_mac_addr[0], &le32, sizeof(u32)); |
865 | 1027 | ||
866 | if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, | 1028 | if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, |
867 | &data) != DFX_K_SUCCESS) { | 1029 | &data) != DFX_K_SUCCESS) { |
@@ -869,8 +1031,8 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
869 | print_name); | 1031 | print_name); |
870 | return(DFX_K_FAILURE); | 1032 | return(DFX_K_FAILURE); |
871 | } | 1033 | } |
872 | data = cpu_to_le32(data); | 1034 | le32 = cpu_to_le32(data); |
873 | memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); | 1035 | memcpy(&bp->factory_mac_addr[4], &le32, sizeof(u16)); |
874 | 1036 | ||
875 | /* | 1037 | /* |
876 | * Set current address to factory address | 1038 | * Set current address to factory address |
@@ -880,20 +1042,18 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
880 | */ | 1042 | */ |
881 | 1043 | ||
882 | memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN); | 1044 | memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN); |
883 | if (bp->bus_type == DFX_BUS_TYPE_EISA) | 1045 | if (dfx_bus_tc) |
884 | printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, " | 1046 | board_name = "DEFTA"; |
885 | "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", | 1047 | if (dfx_bus_eisa) |
886 | print_name, dev->base_addr, dev->irq, | 1048 | board_name = "DEFEA"; |
887 | dev->dev_addr[0], dev->dev_addr[1], | 1049 | if (dfx_bus_pci) |
888 | dev->dev_addr[2], dev->dev_addr[3], | 1050 | board_name = "DEFPA"; |
889 | dev->dev_addr[4], dev->dev_addr[5]); | 1051 | pr_info("%s: %s at %saddr = 0x%llx, IRQ = %d, " |
890 | else | 1052 | "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", |
891 | printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, " | 1053 | print_name, board_name, dfx_use_mmio ? "" : "I/O ", |
892 | "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n", | 1054 | (long long)bar_start, dev->irq, |
893 | print_name, dev->base_addr, dev->irq, | 1055 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], |
894 | dev->dev_addr[0], dev->dev_addr[1], | 1056 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); |
895 | dev->dev_addr[2], dev->dev_addr[3], | ||
896 | dev->dev_addr[4], dev->dev_addr[5]); | ||
897 | 1057 | ||
898 | /* | 1058 | /* |
899 | * Get memory for descriptor block, consumer block, and other buffers | 1059 | * Get memory for descriptor block, consumer block, and other buffers |
@@ -908,8 +1068,9 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
908 | #endif | 1068 | #endif |
909 | sizeof(PI_CONSUMER_BLOCK) + | 1069 | sizeof(PI_CONSUMER_BLOCK) + |
910 | (PI_ALIGN_K_DESC_BLK - 1); | 1070 | (PI_ALIGN_K_DESC_BLK - 1); |
911 | bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size, | 1071 | bp->kmalloced = top_v = dma_alloc_coherent(bp->bus_dev, alloc_size, |
912 | &bp->kmalloced_dma); | 1072 | &bp->kmalloced_dma, |
1073 | GFP_ATOMIC); | ||
913 | if (top_v == NULL) { | 1074 | if (top_v == NULL) { |
914 | printk("%s: Could not allocate memory for host buffers " | 1075 | printk("%s: Could not allocate memory for host buffers " |
915 | "and structures!\n", print_name); | 1076 | "and structures!\n", print_name); |
@@ -1219,14 +1380,15 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers) | |||
1219 | 1380 | ||
1220 | static int dfx_open(struct net_device *dev) | 1381 | static int dfx_open(struct net_device *dev) |
1221 | { | 1382 | { |
1383 | DFX_board_t *bp = netdev_priv(dev); | ||
1222 | int ret; | 1384 | int ret; |
1223 | DFX_board_t *bp = dev->priv; | ||
1224 | 1385 | ||
1225 | DBG_printk("In dfx_open...\n"); | 1386 | DBG_printk("In dfx_open...\n"); |
1226 | 1387 | ||
1227 | /* Register IRQ - support shared interrupts by passing device ptr */ | 1388 | /* Register IRQ - support shared interrupts by passing device ptr */ |
1228 | 1389 | ||
1229 | ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name, dev); | 1390 | ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name, |
1391 | dev); | ||
1230 | if (ret) { | 1392 | if (ret) { |
1231 | printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); | 1393 | printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); |
1232 | return ret; | 1394 | return ret; |
@@ -1309,7 +1471,7 @@ static int dfx_open(struct net_device *dev) | |||
1309 | 1471 | ||
1310 | static int dfx_close(struct net_device *dev) | 1472 | static int dfx_close(struct net_device *dev) |
1311 | { | 1473 | { |
1312 | DFX_board_t *bp = dev->priv; | 1474 | DFX_board_t *bp = netdev_priv(dev); |
1313 | 1475 | ||
1314 | DBG_printk("In dfx_close...\n"); | 1476 | DBG_printk("In dfx_close...\n"); |
1315 | 1477 | ||
@@ -1645,7 +1807,7 @@ static void dfx_int_type_0_process(DFX_board_t *bp) | |||
1645 | 1807 | ||
1646 | static void dfx_int_common(struct net_device *dev) | 1808 | static void dfx_int_common(struct net_device *dev) |
1647 | { | 1809 | { |
1648 | DFX_board_t *bp = dev->priv; | 1810 | DFX_board_t *bp = netdev_priv(dev); |
1649 | PI_UINT32 port_status; /* Port Status register */ | 1811 | PI_UINT32 port_status; /* Port Status register */ |
1650 | 1812 | ||
1651 | /* Process xmt interrupts - frequent case, so always call this routine */ | 1813 | /* Process xmt interrupts - frequent case, so always call this routine */ |
@@ -1715,18 +1877,16 @@ static void dfx_int_common(struct net_device *dev) | |||
1715 | 1877 | ||
1716 | static irqreturn_t dfx_interrupt(int irq, void *dev_id) | 1878 | static irqreturn_t dfx_interrupt(int irq, void *dev_id) |
1717 | { | 1879 | { |
1718 | struct net_device *dev = dev_id; | 1880 | struct net_device *dev = dev_id; |
1719 | DFX_board_t *bp; /* private board structure pointer */ | 1881 | DFX_board_t *bp = netdev_priv(dev); |
1720 | 1882 | struct device *bdev = bp->bus_dev; | |
1721 | /* Get board pointer only if device structure is valid */ | 1883 | int dfx_bus_pci = DFX_BUS_PCI(bdev); |
1722 | 1884 | int dfx_bus_eisa = DFX_BUS_EISA(bdev); | |
1723 | bp = dev->priv; | 1885 | int dfx_bus_tc = DFX_BUS_TC(bdev); |
1724 | |||
1725 | /* See if we're already servicing an interrupt */ | ||
1726 | 1886 | ||
1727 | /* Service adapter interrupts */ | 1887 | /* Service adapter interrupts */ |
1728 | 1888 | ||
1729 | if (bp->bus_type == DFX_BUS_TYPE_PCI) { | 1889 | if (dfx_bus_pci) { |
1730 | u32 status; | 1890 | u32 status; |
1731 | 1891 | ||
1732 | dfx_port_read_long(bp, PFI_K_REG_STATUS, &status); | 1892 | dfx_port_read_long(bp, PFI_K_REG_STATUS, &status); |
@@ -1750,10 +1910,12 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id) | |||
1750 | PFI_MODE_M_DMA_ENB)); | 1910 | PFI_MODE_M_DMA_ENB)); |
1751 | 1911 | ||
1752 | spin_unlock(&bp->lock); | 1912 | spin_unlock(&bp->lock); |
1753 | } else { | 1913 | } |
1914 | if (dfx_bus_eisa) { | ||
1915 | unsigned long base_addr = to_eisa_device(bdev)->base_addr; | ||
1754 | u8 status; | 1916 | u8 status; |
1755 | 1917 | ||
1756 | dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status); | 1918 | status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0); |
1757 | if (!(status & PI_CONFIG_STAT_0_M_PEND)) | 1919 | if (!(status & PI_CONFIG_STAT_0_M_PEND)) |
1758 | return IRQ_NONE; | 1920 | return IRQ_NONE; |
1759 | 1921 | ||
@@ -1761,15 +1923,35 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id) | |||
1761 | 1923 | ||
1762 | /* Disable interrupts at the ESIC */ | 1924 | /* Disable interrupts at the ESIC */ |
1763 | status &= ~PI_CONFIG_STAT_0_M_INT_ENB; | 1925 | status &= ~PI_CONFIG_STAT_0_M_INT_ENB; |
1764 | dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status); | 1926 | outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, status); |
1765 | 1927 | ||
1766 | /* Call interrupt service routine for this adapter */ | 1928 | /* Call interrupt service routine for this adapter */ |
1767 | dfx_int_common(dev); | 1929 | dfx_int_common(dev); |
1768 | 1930 | ||
1769 | /* Reenable interrupts at the ESIC */ | 1931 | /* Reenable interrupts at the ESIC */ |
1770 | dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status); | 1932 | status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0); |
1771 | status |= PI_CONFIG_STAT_0_M_INT_ENB; | 1933 | status |= PI_CONFIG_STAT_0_M_INT_ENB; |
1772 | dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status); | 1934 | outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, status); |
1935 | |||
1936 | spin_unlock(&bp->lock); | ||
1937 | } | ||
1938 | if (dfx_bus_tc) { | ||
1939 | u32 status; | ||
1940 | |||
1941 | dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &status); | ||
1942 | if (!(status & (PI_PSTATUS_M_RCV_DATA_PENDING | | ||
1943 | PI_PSTATUS_M_XMT_DATA_PENDING | | ||
1944 | PI_PSTATUS_M_SMT_HOST_PENDING | | ||
1945 | PI_PSTATUS_M_UNSOL_PENDING | | ||
1946 | PI_PSTATUS_M_CMD_RSP_PENDING | | ||
1947 | PI_PSTATUS_M_CMD_REQ_PENDING | | ||
1948 | PI_PSTATUS_M_TYPE_0_PENDING))) | ||
1949 | return IRQ_NONE; | ||
1950 | |||
1951 | spin_lock(&bp->lock); | ||
1952 | |||
1953 | /* Call interrupt service routine for this adapter */ | ||
1954 | dfx_int_common(dev); | ||
1773 | 1955 | ||
1774 | spin_unlock(&bp->lock); | 1956 | spin_unlock(&bp->lock); |
1775 | } | 1957 | } |
@@ -1823,7 +2005,7 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id) | |||
1823 | 2005 | ||
1824 | static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev) | 2006 | static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev) |
1825 | { | 2007 | { |
1826 | DFX_board_t *bp = dev->priv; | 2008 | DFX_board_t *bp = netdev_priv(dev); |
1827 | 2009 | ||
1828 | /* Fill the bp->stats structure with driver-maintained counters */ | 2010 | /* Fill the bp->stats structure with driver-maintained counters */ |
1829 | 2011 | ||
@@ -2009,8 +2191,8 @@ static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev) | |||
2009 | */ | 2191 | */ |
2010 | 2192 | ||
2011 | static void dfx_ctl_set_multicast_list(struct net_device *dev) | 2193 | static void dfx_ctl_set_multicast_list(struct net_device *dev) |
2012 | { | 2194 | { |
2013 | DFX_board_t *bp = dev->priv; | 2195 | DFX_board_t *bp = netdev_priv(dev); |
2014 | int i; /* used as index in for loop */ | 2196 | int i; /* used as index in for loop */ |
2015 | struct dev_mc_list *dmi; /* ptr to multicast addr entry */ | 2197 | struct dev_mc_list *dmi; /* ptr to multicast addr entry */ |
2016 | 2198 | ||
@@ -2124,8 +2306,8 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev) | |||
2124 | 2306 | ||
2125 | static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr) | 2307 | static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr) |
2126 | { | 2308 | { |
2127 | DFX_board_t *bp = dev->priv; | ||
2128 | struct sockaddr *p_sockaddr = (struct sockaddr *)addr; | 2309 | struct sockaddr *p_sockaddr = (struct sockaddr *)addr; |
2310 | DFX_board_t *bp = netdev_priv(dev); | ||
2129 | 2311 | ||
2130 | /* Copy unicast address to driver-maintained structs and update count */ | 2312 | /* Copy unicast address to driver-maintained structs and update count */ |
2131 | 2313 | ||
@@ -2764,9 +2946,9 @@ static int dfx_rcv_init(DFX_board_t *bp, int get_buffers) | |||
2764 | 2946 | ||
2765 | my_skb_align(newskb, 128); | 2947 | my_skb_align(newskb, 128); |
2766 | bp->descr_block_virt->rcv_data[i + j].long_1 = | 2948 | bp->descr_block_virt->rcv_data[i + j].long_1 = |
2767 | (u32)pci_map_single(bp->pci_dev, newskb->data, | 2949 | (u32)dma_map_single(bp->bus_dev, newskb->data, |
2768 | NEW_SKB_SIZE, | 2950 | NEW_SKB_SIZE, |
2769 | PCI_DMA_FROMDEVICE); | 2951 | DMA_FROM_DEVICE); |
2770 | /* | 2952 | /* |
2771 | * p_rcv_buff_va is only used inside the | 2953 | * p_rcv_buff_va is only used inside the |
2772 | * kernel so we put the skb pointer here. | 2954 | * kernel so we put the skb pointer here. |
@@ -2880,17 +3062,17 @@ static void dfx_rcv_queue_process( | |||
2880 | 3062 | ||
2881 | my_skb_align(newskb, 128); | 3063 | my_skb_align(newskb, 128); |
2882 | skb = (struct sk_buff *)bp->p_rcv_buff_va[entry]; | 3064 | skb = (struct sk_buff *)bp->p_rcv_buff_va[entry]; |
2883 | pci_unmap_single(bp->pci_dev, | 3065 | dma_unmap_single(bp->bus_dev, |
2884 | bp->descr_block_virt->rcv_data[entry].long_1, | 3066 | bp->descr_block_virt->rcv_data[entry].long_1, |
2885 | NEW_SKB_SIZE, | 3067 | NEW_SKB_SIZE, |
2886 | PCI_DMA_FROMDEVICE); | 3068 | DMA_FROM_DEVICE); |
2887 | skb_reserve(skb, RCV_BUFF_K_PADDING); | 3069 | skb_reserve(skb, RCV_BUFF_K_PADDING); |
2888 | bp->p_rcv_buff_va[entry] = (char *)newskb; | 3070 | bp->p_rcv_buff_va[entry] = (char *)newskb; |
2889 | bp->descr_block_virt->rcv_data[entry].long_1 = | 3071 | bp->descr_block_virt->rcv_data[entry].long_1 = |
2890 | (u32)pci_map_single(bp->pci_dev, | 3072 | (u32)dma_map_single(bp->bus_dev, |
2891 | newskb->data, | 3073 | newskb->data, |
2892 | NEW_SKB_SIZE, | 3074 | NEW_SKB_SIZE, |
2893 | PCI_DMA_FROMDEVICE); | 3075 | DMA_FROM_DEVICE); |
2894 | } else | 3076 | } else |
2895 | skb = NULL; | 3077 | skb = NULL; |
2896 | } else | 3078 | } else |
@@ -3010,7 +3192,7 @@ static int dfx_xmt_queue_pkt( | |||
3010 | ) | 3192 | ) |
3011 | 3193 | ||
3012 | { | 3194 | { |
3013 | DFX_board_t *bp = dev->priv; | 3195 | DFX_board_t *bp = netdev_priv(dev); |
3014 | u8 prod; /* local transmit producer index */ | 3196 | u8 prod; /* local transmit producer index */ |
3015 | PI_XMT_DESCR *p_xmt_descr; /* ptr to transmit descriptor block entry */ | 3197 | PI_XMT_DESCR *p_xmt_descr; /* ptr to transmit descriptor block entry */ |
3016 | XMT_DRIVER_DESCR *p_xmt_drv_descr; /* ptr to transmit driver descriptor */ | 3198 | XMT_DRIVER_DESCR *p_xmt_drv_descr; /* ptr to transmit driver descriptor */ |
@@ -3116,8 +3298,8 @@ static int dfx_xmt_queue_pkt( | |||
3116 | */ | 3298 | */ |
3117 | 3299 | ||
3118 | p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN)); | 3300 | p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN)); |
3119 | p_xmt_descr->long_1 = (u32)pci_map_single(bp->pci_dev, skb->data, | 3301 | p_xmt_descr->long_1 = (u32)dma_map_single(bp->bus_dev, skb->data, |
3120 | skb->len, PCI_DMA_TODEVICE); | 3302 | skb->len, DMA_TO_DEVICE); |
3121 | 3303 | ||
3122 | /* | 3304 | /* |
3123 | * Verify that descriptor is actually available | 3305 | * Verify that descriptor is actually available |
@@ -3220,10 +3402,10 @@ static int dfx_xmt_done(DFX_board_t *bp) | |||
3220 | 3402 | ||
3221 | /* Return skb to operating system */ | 3403 | /* Return skb to operating system */ |
3222 | comp = bp->rcv_xmt_reg.index.xmt_comp; | 3404 | comp = bp->rcv_xmt_reg.index.xmt_comp; |
3223 | pci_unmap_single(bp->pci_dev, | 3405 | dma_unmap_single(bp->bus_dev, |
3224 | bp->descr_block_virt->xmt_data[comp].long_1, | 3406 | bp->descr_block_virt->xmt_data[comp].long_1, |
3225 | p_xmt_drv_descr->p_skb->len, | 3407 | p_xmt_drv_descr->p_skb->len, |
3226 | PCI_DMA_TODEVICE); | 3408 | DMA_TO_DEVICE); |
3227 | dev_kfree_skb_irq(p_xmt_drv_descr->p_skb); | 3409 | dev_kfree_skb_irq(p_xmt_drv_descr->p_skb); |
3228 | 3410 | ||
3229 | /* | 3411 | /* |
@@ -3344,10 +3526,10 @@ static void dfx_xmt_flush( DFX_board_t *bp ) | |||
3344 | 3526 | ||
3345 | /* Return skb to operating system */ | 3527 | /* Return skb to operating system */ |
3346 | comp = bp->rcv_xmt_reg.index.xmt_comp; | 3528 | comp = bp->rcv_xmt_reg.index.xmt_comp; |
3347 | pci_unmap_single(bp->pci_dev, | 3529 | dma_unmap_single(bp->bus_dev, |
3348 | bp->descr_block_virt->xmt_data[comp].long_1, | 3530 | bp->descr_block_virt->xmt_data[comp].long_1, |
3349 | p_xmt_drv_descr->p_skb->len, | 3531 | p_xmt_drv_descr->p_skb->len, |
3350 | PCI_DMA_TODEVICE); | 3532 | DMA_TO_DEVICE); |
3351 | dev_kfree_skb(p_xmt_drv_descr->p_skb); | 3533 | dev_kfree_skb(p_xmt_drv_descr->p_skb); |
3352 | 3534 | ||
3353 | /* Increment transmit error counter */ | 3535 | /* Increment transmit error counter */ |
@@ -3375,13 +3557,44 @@ static void dfx_xmt_flush( DFX_board_t *bp ) | |||
3375 | bp->cons_block_virt->xmt_rcv_data = prod_cons; | 3557 | bp->cons_block_virt->xmt_rcv_data = prod_cons; |
3376 | } | 3558 | } |
3377 | 3559 | ||
3378 | static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct net_device *dev) | 3560 | /* |
3561 | * ================== | ||
3562 | * = dfx_unregister = | ||
3563 | * ================== | ||
3564 | * | ||
3565 | * Overview: | ||
3566 | * Shuts down an FDDI controller | ||
3567 | * | ||
3568 | * Returns: | ||
3569 | * Condition code | ||
3570 | * | ||
3571 | * Arguments: | ||
3572 | * bdev - pointer to device information | ||
3573 | * | ||
3574 | * Functional Description: | ||
3575 | * | ||
3576 | * Return Codes: | ||
3577 | * None | ||
3578 | * | ||
3579 | * Assumptions: | ||
3580 | * It compiles so it should work :-( (PCI cards do :-) | ||
3581 | * | ||
3582 | * Side Effects: | ||
3583 | * Device structures for FDDI adapters (fddi0, fddi1, etc) are | ||
3584 | * freed. | ||
3585 | */ | ||
3586 | static void __devexit dfx_unregister(struct device *bdev) | ||
3379 | { | 3587 | { |
3380 | DFX_board_t *bp = dev->priv; | 3588 | struct net_device *dev = dev_get_drvdata(bdev); |
3589 | DFX_board_t *bp = netdev_priv(dev); | ||
3590 | int dfx_bus_pci = DFX_BUS_PCI(bdev); | ||
3591 | int dfx_bus_tc = DFX_BUS_TC(bdev); | ||
3592 | int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; | ||
3593 | resource_size_t bar_start = 0; /* pointer to port */ | ||
3594 | resource_size_t bar_len = 0; /* resource length */ | ||
3381 | int alloc_size; /* total buffer size used */ | 3595 | int alloc_size; /* total buffer size used */ |
3382 | 3596 | ||
3383 | unregister_netdev(dev); | 3597 | unregister_netdev(dev); |
3384 | release_region(dev->base_addr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN ); | ||
3385 | 3598 | ||
3386 | alloc_size = sizeof(PI_DESCR_BLOCK) + | 3599 | alloc_size = sizeof(PI_DESCR_BLOCK) + |
3387 | PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX + | 3600 | PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX + |
@@ -3391,78 +3604,141 @@ static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct ne | |||
3391 | sizeof(PI_CONSUMER_BLOCK) + | 3604 | sizeof(PI_CONSUMER_BLOCK) + |
3392 | (PI_ALIGN_K_DESC_BLK - 1); | 3605 | (PI_ALIGN_K_DESC_BLK - 1); |
3393 | if (bp->kmalloced) | 3606 | if (bp->kmalloced) |
3394 | pci_free_consistent(pdev, alloc_size, bp->kmalloced, | 3607 | dma_free_coherent(bdev, alloc_size, |
3395 | bp->kmalloced_dma); | 3608 | bp->kmalloced, bp->kmalloced_dma); |
3609 | |||
3610 | dfx_bus_uninit(dev); | ||
3611 | |||
3612 | dfx_get_bars(bdev, &bar_start, &bar_len); | ||
3613 | if (dfx_use_mmio) { | ||
3614 | iounmap(bp->base.mem); | ||
3615 | release_mem_region(bar_start, bar_len); | ||
3616 | } else | ||
3617 | release_region(bar_start, bar_len); | ||
3618 | |||
3619 | if (dfx_bus_pci) | ||
3620 | pci_disable_device(to_pci_dev(bdev)); | ||
3621 | |||
3396 | free_netdev(dev); | 3622 | free_netdev(dev); |
3397 | } | 3623 | } |
3398 | 3624 | ||
3399 | static void __devexit dfx_remove_one (struct pci_dev *pdev) | ||
3400 | { | ||
3401 | struct net_device *dev = pci_get_drvdata(pdev); | ||
3402 | 3625 | ||
3403 | dfx_remove_one_pci_or_eisa(pdev, dev); | 3626 | static int __devinit __unused dfx_dev_register(struct device *); |
3404 | pci_set_drvdata(pdev, NULL); | 3627 | static int __devexit __unused dfx_dev_unregister(struct device *); |
3405 | } | ||
3406 | 3628 | ||
3407 | static struct pci_device_id dfx_pci_tbl[] = { | 3629 | #ifdef CONFIG_PCI |
3408 | { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI, PCI_ANY_ID, PCI_ANY_ID, }, | 3630 | static int __devinit dfx_pci_register(struct pci_dev *, |
3409 | { 0, } | 3631 | const struct pci_device_id *); |
3632 | static void __devexit dfx_pci_unregister(struct pci_dev *); | ||
3633 | |||
3634 | static struct pci_device_id dfx_pci_table[] = { | ||
3635 | { PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) }, | ||
3636 | { } | ||
3410 | }; | 3637 | }; |
3411 | MODULE_DEVICE_TABLE(pci, dfx_pci_tbl); | 3638 | MODULE_DEVICE_TABLE(pci, dfx_pci_table); |
3412 | 3639 | ||
3413 | static struct pci_driver dfx_driver = { | 3640 | static struct pci_driver dfx_pci_driver = { |
3414 | .name = "defxx", | 3641 | .name = "defxx", |
3415 | .probe = dfx_init_one, | 3642 | .id_table = dfx_pci_table, |
3416 | .remove = __devexit_p(dfx_remove_one), | 3643 | .probe = dfx_pci_register, |
3417 | .id_table = dfx_pci_tbl, | 3644 | .remove = __devexit_p(dfx_pci_unregister), |
3418 | }; | 3645 | }; |
3419 | 3646 | ||
3420 | static int dfx_have_pci; | 3647 | static __devinit int dfx_pci_register(struct pci_dev *pdev, |
3421 | static int dfx_have_eisa; | 3648 | const struct pci_device_id *ent) |
3422 | 3649 | { | |
3650 | return dfx_register(&pdev->dev); | ||
3651 | } | ||
3423 | 3652 | ||
3424 | static void __exit dfx_eisa_cleanup(void) | 3653 | static void __devexit dfx_pci_unregister(struct pci_dev *pdev) |
3425 | { | 3654 | { |
3426 | struct net_device *dev = root_dfx_eisa_dev; | 3655 | dfx_unregister(&pdev->dev); |
3656 | } | ||
3657 | #endif /* CONFIG_PCI */ | ||
3658 | |||
3659 | #ifdef CONFIG_EISA | ||
3660 | static struct eisa_device_id dfx_eisa_table[] = { | ||
3661 | { "DEC3001", DEFEA_PROD_ID_1 }, | ||
3662 | { "DEC3002", DEFEA_PROD_ID_2 }, | ||
3663 | { "DEC3003", DEFEA_PROD_ID_3 }, | ||
3664 | { "DEC3004", DEFEA_PROD_ID_4 }, | ||
3665 | { } | ||
3666 | }; | ||
3667 | MODULE_DEVICE_TABLE(eisa, dfx_eisa_table); | ||
3668 | |||
3669 | static struct eisa_driver dfx_eisa_driver = { | ||
3670 | .id_table = dfx_eisa_table, | ||
3671 | .driver = { | ||
3672 | .name = "defxx", | ||
3673 | .bus = &eisa_bus_type, | ||
3674 | .probe = dfx_dev_register, | ||
3675 | .remove = __devexit_p(dfx_dev_unregister), | ||
3676 | }, | ||
3677 | }; | ||
3678 | #endif /* CONFIG_EISA */ | ||
3679 | |||
3680 | #ifdef CONFIG_TC | ||
3681 | static struct tc_device_id const dfx_tc_table[] = { | ||
3682 | { "DEC ", "PMAF-FA " }, | ||
3683 | { "DEC ", "PMAF-FD " }, | ||
3684 | { "DEC ", "PMAF-FS " }, | ||
3685 | { "DEC ", "PMAF-FU " }, | ||
3686 | { } | ||
3687 | }; | ||
3688 | MODULE_DEVICE_TABLE(tc, dfx_tc_table); | ||
3689 | |||
3690 | static struct tc_driver dfx_tc_driver = { | ||
3691 | .id_table = dfx_tc_table, | ||
3692 | .driver = { | ||
3693 | .name = "defxx", | ||
3694 | .bus = &tc_bus_type, | ||
3695 | .probe = dfx_dev_register, | ||
3696 | .remove = __devexit_p(dfx_dev_unregister), | ||
3697 | }, | ||
3698 | }; | ||
3699 | #endif /* CONFIG_TC */ | ||
3427 | 3700 | ||
3428 | while (dev) | 3701 | static int __devinit __unused dfx_dev_register(struct device *dev) |
3429 | { | 3702 | { |
3430 | struct net_device *tmp; | 3703 | int status; |
3431 | DFX_board_t *bp; | ||
3432 | 3704 | ||
3433 | bp = (DFX_board_t*)dev->priv; | 3705 | status = dfx_register(dev); |
3434 | tmp = bp->next; | 3706 | if (!status) |
3435 | dfx_remove_one_pci_or_eisa(NULL, dev); | 3707 | get_device(dev); |
3436 | dev = tmp; | 3708 | return status; |
3437 | } | ||
3438 | } | 3709 | } |
3439 | 3710 | ||
3440 | static int __init dfx_init(void) | 3711 | static int __devexit __unused dfx_dev_unregister(struct device *dev) |
3441 | { | 3712 | { |
3442 | int rc_pci, rc_eisa; | 3713 | put_device(dev); |
3443 | 3714 | dfx_unregister(dev); | |
3444 | rc_pci = pci_register_driver(&dfx_driver); | 3715 | return 0; |
3445 | if (rc_pci >= 0) dfx_have_pci = 1; | 3716 | } |
3446 | 3717 | ||
3447 | rc_eisa = dfx_eisa_init(); | ||
3448 | if (rc_eisa >= 0) dfx_have_eisa = 1; | ||
3449 | 3718 | ||
3450 | return ((rc_eisa < 0) ? 0 : rc_eisa) + ((rc_pci < 0) ? 0 : rc_pci); | 3719 | static int __devinit dfx_init(void) |
3720 | { | ||
3721 | int status; | ||
3722 | |||
3723 | status = pci_register_driver(&dfx_pci_driver); | ||
3724 | if (!status) | ||
3725 | status = eisa_driver_register(&dfx_eisa_driver); | ||
3726 | if (!status) | ||
3727 | status = tc_register_driver(&dfx_tc_driver); | ||
3728 | return status; | ||
3451 | } | 3729 | } |
3452 | 3730 | ||
3453 | static void __exit dfx_cleanup(void) | 3731 | static void __devexit dfx_cleanup(void) |
3454 | { | 3732 | { |
3455 | if (dfx_have_pci) | 3733 | tc_unregister_driver(&dfx_tc_driver); |
3456 | pci_unregister_driver(&dfx_driver); | 3734 | eisa_driver_unregister(&dfx_eisa_driver); |
3457 | if (dfx_have_eisa) | 3735 | pci_unregister_driver(&dfx_pci_driver); |
3458 | dfx_eisa_cleanup(); | ||
3459 | |||
3460 | } | 3736 | } |
3461 | 3737 | ||
3462 | module_init(dfx_init); | 3738 | module_init(dfx_init); |
3463 | module_exit(dfx_cleanup); | 3739 | module_exit(dfx_cleanup); |
3464 | MODULE_AUTHOR("Lawrence V. Stefani"); | 3740 | MODULE_AUTHOR("Lawrence V. Stefani"); |
3465 | MODULE_DESCRIPTION("DEC FDDIcontroller EISA/PCI (DEFEA/DEFPA) driver " | 3741 | MODULE_DESCRIPTION("DEC FDDIcontroller TC/EISA/PCI (DEFTA/DEFEA/DEFPA) driver " |
3466 | DRV_VERSION " " DRV_RELDATE); | 3742 | DRV_VERSION " " DRV_RELDATE); |
3467 | MODULE_LICENSE("GPL"); | 3743 | MODULE_LICENSE("GPL"); |
3468 | 3744 | ||
diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h index 2ce8f97253eb..19a6f64df198 100644 --- a/drivers/net/defxx.h +++ b/drivers/net/defxx.h | |||
@@ -26,6 +26,7 @@ | |||
26 | * 12-Sep-96 LVS Removed packet request header pointers. | 26 | * 12-Sep-96 LVS Removed packet request header pointers. |
27 | * 04 Aug 2003 macro Converted to the DMA API. | 27 | * 04 Aug 2003 macro Converted to the DMA API. |
28 | * 23 Oct 2006 macro Big-endian host support. | 28 | * 23 Oct 2006 macro Big-endian host support. |
29 | * 14 Dec 2006 macro TURBOchannel support. | ||
29 | */ | 30 | */ |
30 | 31 | ||
31 | #ifndef _DEFXX_H_ | 32 | #ifndef _DEFXX_H_ |
@@ -1471,9 +1472,17 @@ typedef union | |||
1471 | 1472 | ||
1472 | #endif /* __BIG_ENDIAN */ | 1473 | #endif /* __BIG_ENDIAN */ |
1473 | 1474 | ||
1475 | /* Define TC PDQ CSR offset and length */ | ||
1476 | |||
1477 | #define PI_TC_K_CSR_OFFSET 0x100000 | ||
1478 | #define PI_TC_K_CSR_LEN 0x40 /* 64 bytes */ | ||
1479 | |||
1474 | /* Define EISA controller register offsets */ | 1480 | /* Define EISA controller register offsets */ |
1475 | 1481 | ||
1476 | #define PI_ESIC_K_BURST_HOLDOFF 0x040 | 1482 | #define PI_ESIC_K_CSR_IO_LEN 0x80 /* 128 bytes */ |
1483 | |||
1484 | #define PI_DEFEA_K_BURST_HOLDOFF 0x040 | ||
1485 | |||
1477 | #define PI_ESIC_K_SLOT_ID 0xC80 | 1486 | #define PI_ESIC_K_SLOT_ID 0xC80 |
1478 | #define PI_ESIC_K_SLOT_CNTRL 0xC84 | 1487 | #define PI_ESIC_K_SLOT_CNTRL 0xC84 |
1479 | #define PI_ESIC_K_MEM_ADD_CMP_0 0xC85 | 1488 | #define PI_ESIC_K_MEM_ADD_CMP_0 0xC85 |
@@ -1488,14 +1497,14 @@ typedef union | |||
1488 | #define PI_ESIC_K_MEM_ADD_LO_CMP_0 0xC8E | 1497 | #define PI_ESIC_K_MEM_ADD_LO_CMP_0 0xC8E |
1489 | #define PI_ESIC_K_MEM_ADD_LO_CMP_1 0xC8F | 1498 | #define PI_ESIC_K_MEM_ADD_LO_CMP_1 0xC8F |
1490 | #define PI_ESIC_K_MEM_ADD_LO_CMP_2 0xC90 | 1499 | #define PI_ESIC_K_MEM_ADD_LO_CMP_2 0xC90 |
1491 | #define PI_ESIC_K_IO_CMP_0_0 0xC91 | 1500 | #define PI_ESIC_K_IO_ADD_CMP_0_0 0xC91 |
1492 | #define PI_ESIC_K_IO_CMP_0_1 0xC92 | 1501 | #define PI_ESIC_K_IO_ADD_CMP_0_1 0xC92 |
1493 | #define PI_ESIC_K_IO_CMP_1_0 0xC93 | 1502 | #define PI_ESIC_K_IO_ADD_CMP_1_0 0xC93 |
1494 | #define PI_ESIC_K_IO_CMP_1_1 0xC94 | 1503 | #define PI_ESIC_K_IO_ADD_CMP_1_1 0xC94 |
1495 | #define PI_ESIC_K_IO_CMP_2_0 0xC95 | 1504 | #define PI_ESIC_K_IO_ADD_CMP_2_0 0xC95 |
1496 | #define PI_ESIC_K_IO_CMP_2_1 0xC96 | 1505 | #define PI_ESIC_K_IO_ADD_CMP_2_1 0xC96 |
1497 | #define PI_ESIC_K_IO_CMP_3_0 0xC97 | 1506 | #define PI_ESIC_K_IO_ADD_CMP_3_0 0xC97 |
1498 | #define PI_ESIC_K_IO_CMP_3_1 0xC98 | 1507 | #define PI_ESIC_K_IO_ADD_CMP_3_1 0xC98 |
1499 | #define PI_ESIC_K_IO_ADD_MASK_0_0 0xC99 | 1508 | #define PI_ESIC_K_IO_ADD_MASK_0_0 0xC99 |
1500 | #define PI_ESIC_K_IO_ADD_MASK_0_1 0xC9A | 1509 | #define PI_ESIC_K_IO_ADD_MASK_0_1 0xC9A |
1501 | #define PI_ESIC_K_IO_ADD_MASK_1_0 0xC9B | 1510 | #define PI_ESIC_K_IO_ADD_MASK_1_0 0xC9B |
@@ -1518,11 +1527,16 @@ typedef union | |||
1518 | #define PI_ESIC_K_INPUT_PORT 0xCAC | 1527 | #define PI_ESIC_K_INPUT_PORT 0xCAC |
1519 | #define PI_ESIC_K_OUTPUT_PORT 0xCAD | 1528 | #define PI_ESIC_K_OUTPUT_PORT 0xCAD |
1520 | #define PI_ESIC_K_FUNCTION_CNTRL 0xCAE | 1529 | #define PI_ESIC_K_FUNCTION_CNTRL 0xCAE |
1521 | #define PI_ESIC_K_CSR_IO_LEN PI_ESIC_K_FUNCTION_CNTRL+1 /* always last reg + 1 */ | ||
1522 | 1530 | ||
1523 | /* Define the value all drivers must write to the function control register. */ | 1531 | /* Define the bits in the function control register. */ |
1524 | 1532 | ||
1525 | #define PI_ESIC_K_FUNCTION_CNTRL_IO_ENB 0x03 | 1533 | #define PI_FUNCTION_CNTRL_M_IOCS0 0x01 |
1534 | #define PI_FUNCTION_CNTRL_M_IOCS1 0x02 | ||
1535 | #define PI_FUNCTION_CNTRL_M_IOCS2 0x04 | ||
1536 | #define PI_FUNCTION_CNTRL_M_IOCS3 0x08 | ||
1537 | #define PI_FUNCTION_CNTRL_M_MEMCS0 0x10 | ||
1538 | #define PI_FUNCTION_CNTRL_M_MEMCS1 0x20 | ||
1539 | #define PI_FUNCTION_CNTRL_M_DMA 0x80 | ||
1526 | 1540 | ||
1527 | /* Define the bits in the slot control register. */ | 1541 | /* Define the bits in the slot control register. */ |
1528 | 1542 | ||
@@ -1540,6 +1554,10 @@ typedef union | |||
1540 | #define PI_BURST_HOLDOFF_V_RESERVED 1 | 1554 | #define PI_BURST_HOLDOFF_V_RESERVED 1 |
1541 | #define PI_BURST_HOLDOFF_V_MEM_MAP 0 | 1555 | #define PI_BURST_HOLDOFF_V_MEM_MAP 0 |
1542 | 1556 | ||
1557 | /* Define the implicit mask of the Memory Address Mask Register. */ | ||
1558 | |||
1559 | #define PI_MEM_ADD_MASK_M 0x3ff | ||
1560 | |||
1543 | /* | 1561 | /* |
1544 | * Define the fields in the IO Compare registers. | 1562 | * Define the fields in the IO Compare registers. |
1545 | * The driver must initialize the slot field with the slot ID shifted by the | 1563 | * The driver must initialize the slot field with the slot ID shifted by the |
@@ -1577,6 +1595,7 @@ typedef union | |||
1577 | #define DEFEA_PROD_ID_1 0x0130A310 /* DEC product 300, rev 1 */ | 1595 | #define DEFEA_PROD_ID_1 0x0130A310 /* DEC product 300, rev 1 */ |
1578 | #define DEFEA_PROD_ID_2 0x0230A310 /* DEC product 300, rev 2 */ | 1596 | #define DEFEA_PROD_ID_2 0x0230A310 /* DEC product 300, rev 2 */ |
1579 | #define DEFEA_PROD_ID_3 0x0330A310 /* DEC product 300, rev 3 */ | 1597 | #define DEFEA_PROD_ID_3 0x0330A310 /* DEC product 300, rev 3 */ |
1598 | #define DEFEA_PROD_ID_4 0x0430A310 /* DEC product 300, rev 4 */ | ||
1580 | 1599 | ||
1581 | /**********************************************/ | 1600 | /**********************************************/ |
1582 | /* Digital PFI Specification v1.0 Definitions */ | 1601 | /* Digital PFI Specification v1.0 Definitions */ |
@@ -1633,12 +1652,6 @@ typedef union | |||
1633 | #define PFI_STATUS_V_FIFO_EMPTY 1 | 1652 | #define PFI_STATUS_V_FIFO_EMPTY 1 |
1634 | #define PFI_STATUS_V_DMA_IN_PROGRESS 0 | 1653 | #define PFI_STATUS_V_DMA_IN_PROGRESS 0 |
1635 | 1654 | ||
1636 | #define DFX_MAX_EISA_SLOTS 16 /* maximum number of EISA slots to scan */ | ||
1637 | #define DFX_MAX_NUM_BOARDS 8 /* maximum number of adapters supported */ | ||
1638 | |||
1639 | #define DFX_BUS_TYPE_PCI 0 /* type code for DEC FDDIcontroller/PCI */ | ||
1640 | #define DFX_BUS_TYPE_EISA 1 /* type code for DEC FDDIcontroller/EISA */ | ||
1641 | |||
1642 | #define DFX_FC_PRH2_PRH1_PRH0 0x54003820 /* Packet Request Header bytes + FC */ | 1655 | #define DFX_FC_PRH2_PRH1_PRH0 0x54003820 /* Packet Request Header bytes + FC */ |
1643 | #define DFX_PRH0_BYTE 0x20 /* Packet Request Header byte 0 */ | 1656 | #define DFX_PRH0_BYTE 0x20 /* Packet Request Header byte 0 */ |
1644 | #define DFX_PRH1_BYTE 0x38 /* Packet Request Header byte 1 */ | 1657 | #define DFX_PRH1_BYTE 0x38 /* Packet Request Header byte 1 */ |
@@ -1756,10 +1769,11 @@ typedef struct DFX_board_tag | |||
1756 | /* Store device, bus-specific, and parameter information for this adapter */ | 1769 | /* Store device, bus-specific, and parameter information for this adapter */ |
1757 | 1770 | ||
1758 | struct net_device *dev; /* pointer to device structure */ | 1771 | struct net_device *dev; /* pointer to device structure */ |
1759 | struct net_device *next; | 1772 | union { |
1760 | u32 bus_type; /* bus type (0 == PCI, 1 == EISA) */ | 1773 | void __iomem *mem; |
1761 | u16 base_addr; /* base I/O address (same as dev->base_addr) */ | 1774 | int port; |
1762 | struct pci_dev * pci_dev; | 1775 | } base; /* base address */ |
1776 | struct device *bus_dev; | ||
1763 | u32 full_duplex_enb; /* FDDI Full Duplex enable (1 == on, 2 == off) */ | 1777 | u32 full_duplex_enb; /* FDDI Full Duplex enable (1 == on, 2 == off) */ |
1764 | u32 req_ttrt; /* requested TTRT value (in 80ns units) */ | 1778 | u32 req_ttrt; /* requested TTRT value (in 80ns units) */ |
1765 | u32 burst_size; /* adapter burst size (enumerated) */ | 1779 | u32 burst_size; /* adapter burst size (enumerated) */ |
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c index 3c912ee29da0..8b5334c56f0a 100644 --- a/drivers/scsi/NCR53C9x.c +++ b/drivers/scsi/NCR53C9x.c | |||
@@ -528,12 +528,16 @@ void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs) | |||
528 | /* Allocate structure and insert basic data such as SCSI chip frequency | 528 | /* Allocate structure and insert basic data such as SCSI chip frequency |
529 | * data and a pointer to the device | 529 | * data and a pointer to the device |
530 | */ | 530 | */ |
531 | struct NCR_ESP* esp_allocate(struct scsi_host_template *tpnt, void *esp_dev) | 531 | struct NCR_ESP* esp_allocate(struct scsi_host_template *tpnt, void *esp_dev, |
532 | int hotplug) | ||
532 | { | 533 | { |
533 | struct NCR_ESP *esp, *elink; | 534 | struct NCR_ESP *esp, *elink; |
534 | struct Scsi_Host *esp_host; | 535 | struct Scsi_Host *esp_host; |
535 | 536 | ||
536 | esp_host = scsi_register(tpnt, sizeof(struct NCR_ESP)); | 537 | if (hotplug) |
538 | esp_host = scsi_host_alloc(tpnt, sizeof(struct NCR_ESP)); | ||
539 | else | ||
540 | esp_host = scsi_register(tpnt, sizeof(struct NCR_ESP)); | ||
537 | if(!esp_host) | 541 | if(!esp_host) |
538 | panic("Cannot register ESP SCSI host"); | 542 | panic("Cannot register ESP SCSI host"); |
539 | esp = (struct NCR_ESP *) esp_host->hostdata; | 543 | esp = (struct NCR_ESP *) esp_host->hostdata; |
diff --git a/drivers/scsi/NCR53C9x.h b/drivers/scsi/NCR53C9x.h index 521e3f842cfd..d85cb73a9f69 100644 --- a/drivers/scsi/NCR53C9x.h +++ b/drivers/scsi/NCR53C9x.h | |||
@@ -652,7 +652,7 @@ extern int nesps, esps_in_use, esps_running; | |||
652 | 652 | ||
653 | /* External functions */ | 653 | /* External functions */ |
654 | extern void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs); | 654 | extern void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs); |
655 | extern struct NCR_ESP *esp_allocate(struct scsi_host_template *, void *); | 655 | extern struct NCR_ESP *esp_allocate(struct scsi_host_template *, void *, int); |
656 | extern void esp_deallocate(struct NCR_ESP *); | 656 | extern void esp_deallocate(struct NCR_ESP *); |
657 | extern void esp_release(void); | 657 | extern void esp_release(void); |
658 | extern void esp_initialize(struct NCR_ESP *); | 658 | extern void esp_initialize(struct NCR_ESP *); |
diff --git a/drivers/scsi/blz1230.c b/drivers/scsi/blz1230.c index 329a8f297b31..23f7c24ab809 100644 --- a/drivers/scsi/blz1230.c +++ b/drivers/scsi/blz1230.c | |||
@@ -121,7 +121,8 @@ int __init blz1230_esp_detect(struct scsi_host_template *tpnt) | |||
121 | */ | 121 | */ |
122 | address = ZTWO_VADDR(board); | 122 | address = ZTWO_VADDR(board); |
123 | eregs = (struct ESP_regs *)(address + REAL_BLZ1230_ESP_ADDR); | 123 | eregs = (struct ESP_regs *)(address + REAL_BLZ1230_ESP_ADDR); |
124 | esp = esp_allocate(tpnt, (void *)board+REAL_BLZ1230_ESP_ADDR); | 124 | esp = esp_allocate(tpnt, (void *)board + REAL_BLZ1230_ESP_ADDR, |
125 | 0); | ||
125 | 126 | ||
126 | esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7)); | 127 | esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7)); |
127 | udelay(5); | 128 | udelay(5); |
diff --git a/drivers/scsi/blz2060.c b/drivers/scsi/blz2060.c index b6c137b97350..b6203ec00961 100644 --- a/drivers/scsi/blz2060.c +++ b/drivers/scsi/blz2060.c | |||
@@ -100,7 +100,7 @@ int __init blz2060_esp_detect(struct scsi_host_template *tpnt) | |||
100 | unsigned long board = z->resource.start; | 100 | unsigned long board = z->resource.start; |
101 | if (request_mem_region(board+BLZ2060_ESP_ADDR, | 101 | if (request_mem_region(board+BLZ2060_ESP_ADDR, |
102 | sizeof(struct ESP_regs), "NCR53C9x")) { | 102 | sizeof(struct ESP_regs), "NCR53C9x")) { |
103 | esp = esp_allocate(tpnt, (void *)board+BLZ2060_ESP_ADDR); | 103 | esp = esp_allocate(tpnt, (void *)board + BLZ2060_ESP_ADDR, 0); |
104 | 104 | ||
105 | /* Do command transfer with programmed I/O */ | 105 | /* Do command transfer with programmed I/O */ |
106 | esp->do_pio_cmds = 1; | 106 | esp->do_pio_cmds = 1; |
diff --git a/drivers/scsi/cyberstorm.c b/drivers/scsi/cyberstorm.c index 7c7cfb54e897..c6b98a42e89d 100644 --- a/drivers/scsi/cyberstorm.c +++ b/drivers/scsi/cyberstorm.c | |||
@@ -126,7 +126,7 @@ int __init cyber_esp_detect(struct scsi_host_template *tpnt) | |||
126 | sizeof(struct ESP_regs)); | 126 | sizeof(struct ESP_regs)); |
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | esp = esp_allocate(tpnt, (void *)board+CYBER_ESP_ADDR); | 129 | esp = esp_allocate(tpnt, (void *)board + CYBER_ESP_ADDR, 0); |
130 | 130 | ||
131 | /* Do command transfer with programmed I/O */ | 131 | /* Do command transfer with programmed I/O */ |
132 | esp->do_pio_cmds = 1; | 132 | esp->do_pio_cmds = 1; |
diff --git a/drivers/scsi/cyberstormII.c b/drivers/scsi/cyberstormII.c index d88cb9cf091e..e336e853e66f 100644 --- a/drivers/scsi/cyberstormII.c +++ b/drivers/scsi/cyberstormII.c | |||
@@ -98,7 +98,7 @@ int __init cyberII_esp_detect(struct scsi_host_template *tpnt) | |||
98 | address = (unsigned long)ZTWO_VADDR(board); | 98 | address = (unsigned long)ZTWO_VADDR(board); |
99 | eregs = (struct ESP_regs *)(address + CYBERII_ESP_ADDR); | 99 | eregs = (struct ESP_regs *)(address + CYBERII_ESP_ADDR); |
100 | 100 | ||
101 | esp = esp_allocate(tpnt, (void *)board+CYBERII_ESP_ADDR); | 101 | esp = esp_allocate(tpnt, (void *)board + CYBERII_ESP_ADDR, 0); |
102 | 102 | ||
103 | esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7)); | 103 | esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7)); |
104 | udelay(5); | 104 | udelay(5); |
diff --git a/drivers/scsi/dec_esp.c b/drivers/scsi/dec_esp.c index c29ccbc44693..d42ad663ffee 100644 --- a/drivers/scsi/dec_esp.c +++ b/drivers/scsi/dec_esp.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * 20001005 - Initialization fixes for 2.4.0-test9 | 18 | * 20001005 - Initialization fixes for 2.4.0-test9 |
19 | * Florian Lohoff <flo@rfc822.org> | 19 | * Florian Lohoff <flo@rfc822.org> |
20 | * | 20 | * |
21 | * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki | 21 | * Copyright (C) 2002, 2003, 2005, 2006 Maciej W. Rozycki |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
32 | #include <linux/stat.h> | 32 | #include <linux/stat.h> |
33 | #include <linux/tc.h> | ||
33 | 34 | ||
34 | #include <asm/dma.h> | 35 | #include <asm/dma.h> |
35 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
@@ -42,7 +43,6 @@ | |||
42 | #include <asm/dec/ioasic_ints.h> | 43 | #include <asm/dec/ioasic_ints.h> |
43 | #include <asm/dec/machtype.h> | 44 | #include <asm/dec/machtype.h> |
44 | #include <asm/dec/system.h> | 45 | #include <asm/dec/system.h> |
45 | #include <asm/dec/tc.h> | ||
46 | 46 | ||
47 | #define DEC_SCSI_SREG 0 | 47 | #define DEC_SCSI_SREG 0 |
48 | #define DEC_SCSI_DMAREG 0x40000 | 48 | #define DEC_SCSI_DMAREG 0x40000 |
@@ -98,51 +98,33 @@ static irqreturn_t scsi_dma_merr_int(int, void *); | |||
98 | static irqreturn_t scsi_dma_err_int(int, void *); | 98 | static irqreturn_t scsi_dma_err_int(int, void *); |
99 | static irqreturn_t scsi_dma_int(int, void *); | 99 | static irqreturn_t scsi_dma_int(int, void *); |
100 | 100 | ||
101 | static int dec_esp_detect(struct scsi_host_template * tpnt); | 101 | static struct scsi_host_template dec_esp_template = { |
102 | 102 | .module = THIS_MODULE, | |
103 | static int dec_esp_release(struct Scsi_Host *shost) | ||
104 | { | ||
105 | if (shost->irq) | ||
106 | free_irq(shost->irq, NULL); | ||
107 | if (shost->io_port && shost->n_io_port) | ||
108 | release_region(shost->io_port, shost->n_io_port); | ||
109 | scsi_unregister(shost); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static struct scsi_host_template driver_template = { | ||
114 | .proc_name = "dec_esp", | ||
115 | .proc_info = esp_proc_info, | ||
116 | .name = "NCR53C94", | 103 | .name = "NCR53C94", |
117 | .detect = dec_esp_detect, | ||
118 | .slave_alloc = esp_slave_alloc, | ||
119 | .slave_destroy = esp_slave_destroy, | ||
120 | .release = dec_esp_release, | ||
121 | .info = esp_info, | 104 | .info = esp_info, |
122 | .queuecommand = esp_queue, | 105 | .queuecommand = esp_queue, |
123 | .eh_abort_handler = esp_abort, | 106 | .eh_abort_handler = esp_abort, |
124 | .eh_bus_reset_handler = esp_reset, | 107 | .eh_bus_reset_handler = esp_reset, |
108 | .slave_alloc = esp_slave_alloc, | ||
109 | .slave_destroy = esp_slave_destroy, | ||
110 | .proc_info = esp_proc_info, | ||
111 | .proc_name = "dec_esp", | ||
125 | .can_queue = 7, | 112 | .can_queue = 7, |
126 | .this_id = 7, | ||
127 | .sg_tablesize = SG_ALL, | 113 | .sg_tablesize = SG_ALL, |
128 | .cmd_per_lun = 1, | 114 | .cmd_per_lun = 1, |
129 | .use_clustering = DISABLE_CLUSTERING, | 115 | .use_clustering = DISABLE_CLUSTERING, |
130 | }; | 116 | }; |
131 | 117 | ||
132 | 118 | static struct NCR_ESP *dec_esp_platform; | |
133 | #include "scsi_module.c" | ||
134 | 119 | ||
135 | /***************************************************************** Detection */ | 120 | /***************************************************************** Detection */ |
136 | static int dec_esp_detect(struct scsi_host_template * tpnt) | 121 | static int dec_esp_platform_probe(void) |
137 | { | 122 | { |
138 | struct NCR_ESP *esp; | 123 | struct NCR_ESP *esp; |
139 | struct ConfigDev *esp_dev; | 124 | int err = 0; |
140 | int slot; | ||
141 | unsigned long mem_start; | ||
142 | 125 | ||
143 | if (IOASIC) { | 126 | if (IOASIC) { |
144 | esp_dev = 0; | 127 | esp = esp_allocate(&dec_esp_template, NULL, 1); |
145 | esp = esp_allocate(tpnt, (void *) esp_dev); | ||
146 | 128 | ||
147 | /* Do command transfer with programmed I/O */ | 129 | /* Do command transfer with programmed I/O */ |
148 | esp->do_pio_cmds = 1; | 130 | esp->do_pio_cmds = 1; |
@@ -200,112 +182,175 @@ static int dec_esp_detect(struct scsi_host_template * tpnt) | |||
200 | /* Check for differential SCSI-bus */ | 182 | /* Check for differential SCSI-bus */ |
201 | esp->diff = 0; | 183 | esp->diff = 0; |
202 | 184 | ||
185 | err = request_irq(esp->irq, esp_intr, IRQF_DISABLED, | ||
186 | "ncr53c94", esp->ehost); | ||
187 | if (err) | ||
188 | goto err_alloc; | ||
189 | err = request_irq(dec_interrupt[DEC_IRQ_ASC_MERR], | ||
190 | scsi_dma_merr_int, IRQF_DISABLED, | ||
191 | "ncr53c94 error", esp->ehost); | ||
192 | if (err) | ||
193 | goto err_irq; | ||
194 | err = request_irq(dec_interrupt[DEC_IRQ_ASC_ERR], | ||
195 | scsi_dma_err_int, IRQF_DISABLED, | ||
196 | "ncr53c94 overrun", esp->ehost); | ||
197 | if (err) | ||
198 | goto err_irq_merr; | ||
199 | err = request_irq(dec_interrupt[DEC_IRQ_ASC_DMA], scsi_dma_int, | ||
200 | IRQF_DISABLED, "ncr53c94 dma", esp->ehost); | ||
201 | if (err) | ||
202 | goto err_irq_err; | ||
203 | |||
203 | esp_initialize(esp); | 204 | esp_initialize(esp); |
204 | 205 | ||
205 | if (request_irq(esp->irq, esp_intr, IRQF_DISABLED, | 206 | err = scsi_add_host(esp->ehost, NULL); |
206 | "ncr53c94", esp->ehost)) | 207 | if (err) { |
207 | goto err_dealloc; | 208 | printk(KERN_ERR "ESP: Unable to register adapter\n"); |
208 | if (request_irq(dec_interrupt[DEC_IRQ_ASC_MERR], | 209 | goto err_irq_dma; |
209 | scsi_dma_merr_int, IRQF_DISABLED, | 210 | } |
210 | "ncr53c94 error", esp->ehost)) | 211 | |
211 | goto err_free_irq; | 212 | scsi_scan_host(esp->ehost); |
212 | if (request_irq(dec_interrupt[DEC_IRQ_ASC_ERR], | ||
213 | scsi_dma_err_int, IRQF_DISABLED, | ||
214 | "ncr53c94 overrun", esp->ehost)) | ||
215 | goto err_free_irq_merr; | ||
216 | if (request_irq(dec_interrupt[DEC_IRQ_ASC_DMA], | ||
217 | scsi_dma_int, IRQF_DISABLED, | ||
218 | "ncr53c94 dma", esp->ehost)) | ||
219 | goto err_free_irq_err; | ||
220 | 213 | ||
214 | dec_esp_platform = esp; | ||
221 | } | 215 | } |
222 | 216 | ||
223 | if (TURBOCHANNEL) { | 217 | return 0; |
224 | while ((slot = search_tc_card("PMAZ-AA")) >= 0) { | 218 | |
225 | claim_tc_card(slot); | 219 | err_irq_dma: |
226 | 220 | free_irq(dec_interrupt[DEC_IRQ_ASC_DMA], esp->ehost); | |
227 | esp_dev = 0; | 221 | err_irq_err: |
228 | esp = esp_allocate(tpnt, (void *) esp_dev); | 222 | free_irq(dec_interrupt[DEC_IRQ_ASC_ERR], esp->ehost); |
229 | 223 | err_irq_merr: | |
230 | mem_start = get_tc_base_addr(slot); | 224 | free_irq(dec_interrupt[DEC_IRQ_ASC_MERR], esp->ehost); |
231 | 225 | err_irq: | |
232 | /* Store base addr into esp struct */ | 226 | free_irq(esp->irq, esp->ehost); |
233 | esp->slot = CPHYSADDR(mem_start); | 227 | err_alloc: |
234 | 228 | esp_deallocate(esp); | |
235 | esp->dregs = 0; | 229 | scsi_host_put(esp->ehost); |
236 | esp->eregs = (void *)CKSEG1ADDR(mem_start + | 230 | return err; |
237 | DEC_SCSI_SREG); | 231 | } |
238 | esp->do_pio_cmds = 1; | 232 | |
239 | 233 | static int __init dec_esp_probe(struct device *dev) | |
240 | /* Set the command buffer */ | 234 | { |
241 | esp->esp_command = (volatile unsigned char *) pmaz_cmd_buffer; | 235 | struct NCR_ESP *esp; |
242 | 236 | resource_size_t start, len; | |
243 | /* get virtual dma address for command buffer */ | 237 | int err; |
244 | esp->esp_command_dvma = virt_to_phys(pmaz_cmd_buffer); | 238 | |
245 | 239 | esp = esp_allocate(&dec_esp_template, NULL, 1); | |
246 | esp->cfreq = get_tc_speed(); | 240 | |
247 | 241 | dev_set_drvdata(dev, esp); | |
248 | esp->irq = get_tc_irq_nr(slot); | 242 | |
249 | 243 | start = to_tc_dev(dev)->resource.start; | |
250 | /* Required functions */ | 244 | len = to_tc_dev(dev)->resource.end - start + 1; |
251 | esp->dma_bytes_sent = &dma_bytes_sent; | 245 | |
252 | esp->dma_can_transfer = &dma_can_transfer; | 246 | if (!request_mem_region(start, len, dev->bus_id)) { |
253 | esp->dma_dump_state = &dma_dump_state; | 247 | printk(KERN_ERR "%s: Unable to reserve MMIO resource\n", |
254 | esp->dma_init_read = &pmaz_dma_init_read; | 248 | dev->bus_id); |
255 | esp->dma_init_write = &pmaz_dma_init_write; | 249 | err = -EBUSY; |
256 | esp->dma_ints_off = &pmaz_dma_ints_off; | 250 | goto err_alloc; |
257 | esp->dma_ints_on = &pmaz_dma_ints_on; | ||
258 | esp->dma_irq_p = &dma_irq_p; | ||
259 | esp->dma_ports_p = &dma_ports_p; | ||
260 | esp->dma_setup = &pmaz_dma_setup; | ||
261 | |||
262 | /* Optional functions */ | ||
263 | esp->dma_barrier = 0; | ||
264 | esp->dma_drain = &pmaz_dma_drain; | ||
265 | esp->dma_invalidate = 0; | ||
266 | esp->dma_irq_entry = 0; | ||
267 | esp->dma_irq_exit = 0; | ||
268 | esp->dma_poll = 0; | ||
269 | esp->dma_reset = 0; | ||
270 | esp->dma_led_off = 0; | ||
271 | esp->dma_led_on = 0; | ||
272 | |||
273 | esp->dma_mmu_get_scsi_one = pmaz_dma_mmu_get_scsi_one; | ||
274 | esp->dma_mmu_get_scsi_sgl = 0; | ||
275 | esp->dma_mmu_release_scsi_one = 0; | ||
276 | esp->dma_mmu_release_scsi_sgl = 0; | ||
277 | esp->dma_advance_sg = 0; | ||
278 | |||
279 | if (request_irq(esp->irq, esp_intr, IRQF_DISABLED, | ||
280 | "PMAZ_AA", esp->ehost)) { | ||
281 | esp_deallocate(esp); | ||
282 | release_tc_card(slot); | ||
283 | continue; | ||
284 | } | ||
285 | esp->scsi_id = 7; | ||
286 | esp->diff = 0; | ||
287 | esp_initialize(esp); | ||
288 | } | ||
289 | } | 251 | } |
290 | 252 | ||
291 | if(nesps) { | 253 | /* Store base addr into esp struct. */ |
292 | printk("ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, esps_in_use); | 254 | esp->slot = start; |
293 | esps_running = esps_in_use; | 255 | |
294 | return esps_in_use; | 256 | esp->dregs = 0; |
257 | esp->eregs = (void *)CKSEG1ADDR(start + DEC_SCSI_SREG); | ||
258 | esp->do_pio_cmds = 1; | ||
259 | |||
260 | /* Set the command buffer. */ | ||
261 | esp->esp_command = (volatile unsigned char *)pmaz_cmd_buffer; | ||
262 | |||
263 | /* Get virtual dma address for command buffer. */ | ||
264 | esp->esp_command_dvma = virt_to_phys(pmaz_cmd_buffer); | ||
265 | |||
266 | esp->cfreq = tc_get_speed(to_tc_dev(dev)->bus); | ||
267 | |||
268 | esp->irq = to_tc_dev(dev)->interrupt; | ||
269 | |||
270 | /* Required functions. */ | ||
271 | esp->dma_bytes_sent = &dma_bytes_sent; | ||
272 | esp->dma_can_transfer = &dma_can_transfer; | ||
273 | esp->dma_dump_state = &dma_dump_state; | ||
274 | esp->dma_init_read = &pmaz_dma_init_read; | ||
275 | esp->dma_init_write = &pmaz_dma_init_write; | ||
276 | esp->dma_ints_off = &pmaz_dma_ints_off; | ||
277 | esp->dma_ints_on = &pmaz_dma_ints_on; | ||
278 | esp->dma_irq_p = &dma_irq_p; | ||
279 | esp->dma_ports_p = &dma_ports_p; | ||
280 | esp->dma_setup = &pmaz_dma_setup; | ||
281 | |||
282 | /* Optional functions. */ | ||
283 | esp->dma_barrier = 0; | ||
284 | esp->dma_drain = &pmaz_dma_drain; | ||
285 | esp->dma_invalidate = 0; | ||
286 | esp->dma_irq_entry = 0; | ||
287 | esp->dma_irq_exit = 0; | ||
288 | esp->dma_poll = 0; | ||
289 | esp->dma_reset = 0; | ||
290 | esp->dma_led_off = 0; | ||
291 | esp->dma_led_on = 0; | ||
292 | |||
293 | esp->dma_mmu_get_scsi_one = pmaz_dma_mmu_get_scsi_one; | ||
294 | esp->dma_mmu_get_scsi_sgl = 0; | ||
295 | esp->dma_mmu_release_scsi_one = 0; | ||
296 | esp->dma_mmu_release_scsi_sgl = 0; | ||
297 | esp->dma_advance_sg = 0; | ||
298 | |||
299 | err = request_irq(esp->irq, esp_intr, IRQF_DISABLED, "PMAZ_AA", | ||
300 | esp->ehost); | ||
301 | if (err) { | ||
302 | printk(KERN_ERR "%s: Unable to get IRQ %d\n", | ||
303 | dev->bus_id, esp->irq); | ||
304 | goto err_resource; | ||
305 | } | ||
306 | |||
307 | esp->scsi_id = 7; | ||
308 | esp->diff = 0; | ||
309 | esp_initialize(esp); | ||
310 | |||
311 | err = scsi_add_host(esp->ehost, dev); | ||
312 | if (err) { | ||
313 | printk(KERN_ERR "%s: Unable to register adapter\n", | ||
314 | dev->bus_id); | ||
315 | goto err_irq; | ||
295 | } | 316 | } |
317 | |||
318 | scsi_scan_host(esp->ehost); | ||
319 | |||
296 | return 0; | 320 | return 0; |
297 | 321 | ||
298 | err_free_irq_err: | 322 | err_irq: |
299 | free_irq(dec_interrupt[DEC_IRQ_ASC_ERR], scsi_dma_err_int); | 323 | free_irq(esp->irq, esp->ehost); |
300 | err_free_irq_merr: | 324 | |
301 | free_irq(dec_interrupt[DEC_IRQ_ASC_MERR], scsi_dma_merr_int); | 325 | err_resource: |
302 | err_free_irq: | 326 | release_mem_region(start, len); |
303 | free_irq(esp->irq, esp_intr); | 327 | |
304 | err_dealloc: | 328 | err_alloc: |
305 | esp_deallocate(esp); | 329 | esp_deallocate(esp); |
306 | return 0; | 330 | scsi_host_put(esp->ehost); |
331 | return err; | ||
332 | } | ||
333 | |||
334 | static void __exit dec_esp_platform_remove(void) | ||
335 | { | ||
336 | struct NCR_ESP *esp = dec_esp_platform; | ||
337 | |||
338 | free_irq(esp->irq, esp->ehost); | ||
339 | esp_deallocate(esp); | ||
340 | scsi_host_put(esp->ehost); | ||
341 | dec_esp_platform = NULL; | ||
307 | } | 342 | } |
308 | 343 | ||
344 | static void __exit dec_esp_remove(struct device *dev) | ||
345 | { | ||
346 | struct NCR_ESP *esp = dev_get_drvdata(dev); | ||
347 | |||
348 | free_irq(esp->irq, esp->ehost); | ||
349 | esp_deallocate(esp); | ||
350 | scsi_host_put(esp->ehost); | ||
351 | } | ||
352 | |||
353 | |||
309 | /************************************************************* DMA Functions */ | 354 | /************************************************************* DMA Functions */ |
310 | static irqreturn_t scsi_dma_merr_int(int irq, void *dev_id) | 355 | static irqreturn_t scsi_dma_merr_int(int irq, void *dev_id) |
311 | { | 356 | { |
@@ -576,3 +621,67 @@ static void pmaz_dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp | |||
576 | { | 621 | { |
577 | sp->SCp.ptr = (char *)virt_to_phys(sp->request_buffer); | 622 | sp->SCp.ptr = (char *)virt_to_phys(sp->request_buffer); |
578 | } | 623 | } |
624 | |||
625 | |||
626 | #ifdef CONFIG_TC | ||
627 | static int __init dec_esp_tc_probe(struct device *dev); | ||
628 | static int __exit dec_esp_tc_remove(struct device *dev); | ||
629 | |||
630 | static const struct tc_device_id dec_esp_tc_table[] = { | ||
631 | { "DEC ", "PMAZ-AA " }, | ||
632 | { } | ||
633 | }; | ||
634 | MODULE_DEVICE_TABLE(tc, dec_esp_tc_table); | ||
635 | |||
636 | static struct tc_driver dec_esp_tc_driver = { | ||
637 | .id_table = dec_esp_tc_table, | ||
638 | .driver = { | ||
639 | .name = "dec_esp", | ||
640 | .bus = &tc_bus_type, | ||
641 | .probe = dec_esp_tc_probe, | ||
642 | .remove = __exit_p(dec_esp_tc_remove), | ||
643 | }, | ||
644 | }; | ||
645 | |||
646 | static int __init dec_esp_tc_probe(struct device *dev) | ||
647 | { | ||
648 | int status = dec_esp_probe(dev); | ||
649 | if (!status) | ||
650 | get_device(dev); | ||
651 | return status; | ||
652 | } | ||
653 | |||
654 | static int __exit dec_esp_tc_remove(struct device *dev) | ||
655 | { | ||
656 | put_device(dev); | ||
657 | dec_esp_remove(dev); | ||
658 | return 0; | ||
659 | } | ||
660 | #endif | ||
661 | |||
662 | static int __init dec_esp_init(void) | ||
663 | { | ||
664 | int status; | ||
665 | |||
666 | status = tc_register_driver(&dec_esp_tc_driver); | ||
667 | if (!status) | ||
668 | dec_esp_platform_probe(); | ||
669 | |||
670 | if (nesps) { | ||
671 | pr_info("ESP: Total of %d ESP hosts found, " | ||
672 | "%d actually in use.\n", nesps, esps_in_use); | ||
673 | esps_running = esps_in_use; | ||
674 | } | ||
675 | |||
676 | return status; | ||
677 | } | ||
678 | |||
679 | static void __exit dec_esp_exit(void) | ||
680 | { | ||
681 | dec_esp_platform_remove(); | ||
682 | tc_unregister_driver(&dec_esp_tc_driver); | ||
683 | } | ||
684 | |||
685 | |||
686 | module_init(dec_esp_init); | ||
687 | module_exit(dec_esp_exit); | ||
diff --git a/drivers/scsi/fastlane.c b/drivers/scsi/fastlane.c index 2a1c5c22b9e0..4266a2139b5f 100644 --- a/drivers/scsi/fastlane.c +++ b/drivers/scsi/fastlane.c | |||
@@ -142,7 +142,7 @@ int __init fastlane_esp_detect(struct scsi_host_template *tpnt) | |||
142 | if (board < 0x1000000) { | 142 | if (board < 0x1000000) { |
143 | goto err_release; | 143 | goto err_release; |
144 | } | 144 | } |
145 | esp = esp_allocate(tpnt, (void *)board+FASTLANE_ESP_ADDR); | 145 | esp = esp_allocate(tpnt, (void *)board + FASTLANE_ESP_ADDR, 0); |
146 | 146 | ||
147 | /* Do command transfer with programmed I/O */ | 147 | /* Do command transfer with programmed I/O */ |
148 | esp->do_pio_cmds = 1; | 148 | esp->do_pio_cmds = 1; |
diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c index bfac4441d89f..19dd4b962e18 100644 --- a/drivers/scsi/jazz_esp.c +++ b/drivers/scsi/jazz_esp.c | |||
@@ -75,7 +75,7 @@ static int jazz_esp_detect(struct scsi_host_template *tpnt) | |||
75 | */ | 75 | */ |
76 | if (1) { | 76 | if (1) { |
77 | esp_dev = NULL; | 77 | esp_dev = NULL; |
78 | esp = esp_allocate(tpnt, (void *) esp_dev); | 78 | esp = esp_allocate(tpnt, esp_dev, 0); |
79 | 79 | ||
80 | /* Do command transfer with programmed I/O */ | 80 | /* Do command transfer with programmed I/O */ |
81 | esp->do_pio_cmds = 1; | 81 | esp->do_pio_cmds = 1; |
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c index 3586fac9be9a..bcb49021b7e2 100644 --- a/drivers/scsi/mac_esp.c +++ b/drivers/scsi/mac_esp.c | |||
@@ -351,7 +351,7 @@ int mac_esp_detect(struct scsi_host_template * tpnt) | |||
351 | for (chipnum = 0; chipnum < chipspresent; chipnum ++) { | 351 | for (chipnum = 0; chipnum < chipspresent; chipnum ++) { |
352 | struct NCR_ESP * esp; | 352 | struct NCR_ESP * esp; |
353 | 353 | ||
354 | esp = esp_allocate(tpnt, (void *) NULL); | 354 | esp = esp_allocate(tpnt, NULL, 0); |
355 | esp->eregs = (struct ESP_regs *) get_base(chipnum); | 355 | esp->eregs = (struct ESP_regs *) get_base(chipnum); |
356 | 356 | ||
357 | esp->dma_irq_p = &esp_dafb_dma_irq_p; | 357 | esp->dma_irq_p = &esp_dafb_dma_irq_p; |
diff --git a/drivers/scsi/mca_53c9x.c b/drivers/scsi/mca_53c9x.c index 998a8bbc1a4b..d693d0f21395 100644 --- a/drivers/scsi/mca_53c9x.c +++ b/drivers/scsi/mca_53c9x.c | |||
@@ -122,7 +122,7 @@ static int mca_esp_detect(struct scsi_host_template *tpnt) | |||
122 | if ((slot = mca_find_adapter(*id_to_check, 0)) != | 122 | if ((slot = mca_find_adapter(*id_to_check, 0)) != |
123 | MCA_NOTFOUND) | 123 | MCA_NOTFOUND) |
124 | { | 124 | { |
125 | esp = esp_allocate(tpnt, (void *) NULL); | 125 | esp = esp_allocate(tpnt, NULL, 0); |
126 | 126 | ||
127 | pos[0] = mca_read_stored_pos(slot, 2); | 127 | pos[0] = mca_read_stored_pos(slot, 2); |
128 | pos[1] = mca_read_stored_pos(slot, 3); | 128 | pos[1] = mca_read_stored_pos(slot, 3); |
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c index c116a6ae3c54..26a6d55faf3e 100644 --- a/drivers/scsi/oktagon_esp.c +++ b/drivers/scsi/oktagon_esp.c | |||
@@ -133,7 +133,7 @@ int oktagon_esp_detect(struct scsi_host_template *tpnt) | |||
133 | eregs = (struct ESP_regs *)(address + OKTAGON_ESP_ADDR); | 133 | eregs = (struct ESP_regs *)(address + OKTAGON_ESP_ADDR); |
134 | 134 | ||
135 | /* This line was 5 lines lower */ | 135 | /* This line was 5 lines lower */ |
136 | esp = esp_allocate(tpnt, (void *)board+OKTAGON_ESP_ADDR); | 136 | esp = esp_allocate(tpnt, (void *)board + OKTAGON_ESP_ADDR, 0); |
137 | 137 | ||
138 | /* we have to shift the registers only one bit for oktagon */ | 138 | /* we have to shift the registers only one bit for oktagon */ |
139 | esp->shift = 1; | 139 | esp->shift = 1; |
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c index 6b60536ac92b..80fb3f88af2e 100644 --- a/drivers/scsi/sun3x_esp.c +++ b/drivers/scsi/sun3x_esp.c | |||
@@ -53,7 +53,7 @@ int sun3x_esp_detect(struct scsi_host_template *tpnt) | |||
53 | struct ConfigDev *esp_dev; | 53 | struct ConfigDev *esp_dev; |
54 | 54 | ||
55 | esp_dev = 0; | 55 | esp_dev = 0; |
56 | esp = esp_allocate(tpnt, (void *) esp_dev); | 56 | esp = esp_allocate(tpnt, esp_dev, 0); |
57 | 57 | ||
58 | /* Do command transfer with DMA */ | 58 | /* Do command transfer with DMA */ |
59 | esp->do_pio_cmds = 0; | 59 | esp->do_pio_cmds = 0; |
diff --git a/drivers/tc/Makefile b/drivers/tc/Makefile index 83b5bd75ce26..967342692211 100644 --- a/drivers/tc/Makefile +++ b/drivers/tc/Makefile | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | # Object file lists. | 5 | # Object file lists. |
6 | 6 | ||
7 | obj-$(CONFIG_TC) += tc.o | 7 | obj-$(CONFIG_TC) += tc.o tc-driver.o |
8 | obj-$(CONFIG_ZS) += zs.o | 8 | obj-$(CONFIG_ZS) += zs.o |
9 | obj-$(CONFIG_VT) += lk201.o lk201-map.o lk201-remap.o | 9 | obj-$(CONFIG_VT) += lk201.o lk201-map.o lk201-remap.o |
10 | 10 | ||
diff --git a/drivers/tc/tc-driver.c b/drivers/tc/tc-driver.c new file mode 100644 index 000000000000..16b5bae63c74 --- /dev/null +++ b/drivers/tc/tc-driver.c | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * TURBOchannel driver services. | ||
3 | * | ||
4 | * Copyright (c) 2005 James Simmons | ||
5 | * Copyright (c) 2006 Maciej W. Rozycki | ||
6 | * | ||
7 | * Loosely based on drivers/dio/dio-driver.c and | ||
8 | * drivers/pci/pci-driver.c. | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU | ||
11 | * General Public License. See the file "COPYING" in the main | ||
12 | * directory of this archive for more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/tc.h> | ||
18 | |||
19 | /** | ||
20 | * tc_register_driver - register a new TC driver | ||
21 | * @drv: the driver structure to register | ||
22 | * | ||
23 | * Adds the driver structure to the list of registered drivers | ||
24 | * Returns a negative value on error, otherwise 0. | ||
25 | * If no error occurred, the driver remains registered even if | ||
26 | * no device was claimed during registration. | ||
27 | */ | ||
28 | int tc_register_driver(struct tc_driver *tdrv) | ||
29 | { | ||
30 | return driver_register(&tdrv->driver); | ||
31 | } | ||
32 | EXPORT_SYMBOL(tc_register_driver); | ||
33 | |||
34 | /** | ||
35 | * tc_unregister_driver - unregister a TC driver | ||
36 | * @drv: the driver structure to unregister | ||
37 | * | ||
38 | * Deletes the driver structure from the list of registered TC drivers, | ||
39 | * gives it a chance to clean up by calling its remove() function for | ||
40 | * each device it was responsible for, and marks those devices as | ||
41 | * driverless. | ||
42 | */ | ||
43 | void tc_unregister_driver(struct tc_driver *tdrv) | ||
44 | { | ||
45 | driver_unregister(&tdrv->driver); | ||
46 | } | ||
47 | EXPORT_SYMBOL(tc_unregister_driver); | ||
48 | |||
49 | /** | ||
50 | * tc_match_device - tell if a TC device structure has a matching | ||
51 | * TC device ID structure | ||
52 | * @tdrv: the TC driver to earch for matching TC device ID strings | ||
53 | * @tdev: the TC device structure to match against | ||
54 | * | ||
55 | * Used by a driver to check whether a TC device present in the | ||
56 | * system is in its list of supported devices. Returns the matching | ||
57 | * tc_device_id structure or %NULL if there is no match. | ||
58 | */ | ||
59 | const struct tc_device_id *tc_match_device(struct tc_driver *tdrv, | ||
60 | struct tc_dev *tdev) | ||
61 | { | ||
62 | const struct tc_device_id *id = tdrv->id_table; | ||
63 | |||
64 | if (id) { | ||
65 | while (id->name[0] || id->vendor[0]) { | ||
66 | if (strcmp(tdev->name, id->name) == 0 && | ||
67 | strcmp(tdev->vendor, id->vendor) == 0) | ||
68 | return id; | ||
69 | id++; | ||
70 | } | ||
71 | } | ||
72 | return NULL; | ||
73 | } | ||
74 | EXPORT_SYMBOL(tc_match_device); | ||
75 | |||
76 | /** | ||
77 | * tc_bus_match - Tell if a device structure has a matching | ||
78 | * TC device ID structure | ||
79 | * @dev: the device structure to match against | ||
80 | * @drv: the device driver to search for matching TC device ID strings | ||
81 | * | ||
82 | * Used by a driver to check whether a TC device present in the | ||
83 | * system is in its list of supported devices. Returns 1 if there | ||
84 | * is a match or 0 otherwise. | ||
85 | */ | ||
86 | static int tc_bus_match(struct device *dev, struct device_driver *drv) | ||
87 | { | ||
88 | struct tc_dev *tdev = to_tc_dev(dev); | ||
89 | struct tc_driver *tdrv = to_tc_driver(drv); | ||
90 | const struct tc_device_id *id; | ||
91 | |||
92 | id = tc_match_device(tdrv, tdev); | ||
93 | if (id) | ||
94 | return 1; | ||
95 | |||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | struct bus_type tc_bus_type = { | ||
100 | .name = "tc", | ||
101 | .match = tc_bus_match, | ||
102 | }; | ||
103 | EXPORT_SYMBOL(tc_bus_type); | ||
104 | |||
105 | static int __init tc_driver_init(void) | ||
106 | { | ||
107 | return bus_register(&tc_bus_type); | ||
108 | } | ||
109 | |||
110 | postcore_initcall(tc_driver_init); | ||
diff --git a/drivers/tc/tc.c b/drivers/tc/tc.c index 4a51e56f85b6..f77f62a4b325 100644 --- a/drivers/tc/tc.c +++ b/drivers/tc/tc.c | |||
@@ -1,254 +1,193 @@ | |||
1 | /* | 1 | /* |
2 | * tc-init: We assume the TURBOchannel to be up and running so | 2 | * TURBOchannel bus services. |
3 | * just probe for Modules and fill in the global data structure | ||
4 | * tc_bus. | ||
5 | * | 3 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | 4 | * Copyright (c) Harald Koerfgen, 1998 |
7 | * License. See the file "COPYING" in the main directory of this archive | 5 | * Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki |
8 | * for more details. | 6 | * Copyright (c) 2005 James Simmons |
9 | * | 7 | * |
10 | * Copyright (c) Harald Koerfgen, 1998 | 8 | * This file is subject to the terms and conditions of the GNU |
11 | * Copyright (c) 2001, 2003, 2005 Maciej W. Rozycki | 9 | * General Public License. See the file "COPYING" in the main |
10 | * directory of this archive for more details. | ||
12 | */ | 11 | */ |
12 | #include <linux/compiler.h> | ||
13 | #include <linux/errno.h> | ||
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/ioport.h> | ||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/list.h> | ||
15 | #include <linux/module.h> | 18 | #include <linux/module.h> |
16 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/tc.h> | ||
17 | #include <linux/types.h> | 21 | #include <linux/types.h> |
18 | 22 | ||
19 | #include <asm/addrspace.h> | ||
20 | #include <asm/errno.h> | ||
21 | #include <asm/io.h> | 23 | #include <asm/io.h> |
22 | #include <asm/paccess.h> | ||
23 | 24 | ||
24 | #include <asm/dec/machtype.h> | 25 | static struct tc_bus tc_bus = { |
25 | #include <asm/dec/prom.h> | 26 | .name = "TURBOchannel", |
26 | #include <asm/dec/tcinfo.h> | 27 | }; |
27 | #include <asm/dec/tcmodule.h> | ||
28 | #include <asm/dec/interrupts.h> | ||
29 | |||
30 | MODULE_LICENSE("GPL"); | ||
31 | slot_info tc_bus[MAX_SLOT]; | ||
32 | static int num_tcslots; | ||
33 | static tcinfo *info; | ||
34 | 28 | ||
35 | /* | 29 | /* |
36 | * Interface to the world. Read comment in include/asm-mips/tc.h. | 30 | * Probing for TURBOchannel modules. |
37 | */ | 31 | */ |
38 | 32 | static void __init tc_bus_add_devices(struct tc_bus *tbus) | |
39 | int search_tc_card(const char *name) | ||
40 | { | ||
41 | int slot; | ||
42 | slot_info *sip; | ||
43 | |||
44 | for (slot = 0; slot < num_tcslots; slot++) { | ||
45 | sip = &tc_bus[slot]; | ||
46 | if ((sip->flags & FREE) && | ||
47 | (strncmp(sip->name, name, strlen(name)) == 0)) { | ||
48 | return slot; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | return -ENODEV; | ||
53 | } | ||
54 | |||
55 | void claim_tc_card(int slot) | ||
56 | { | ||
57 | if (tc_bus[slot].flags & IN_USE) { | ||
58 | printk("claim_tc_card: attempting to claim a card already in use\n"); | ||
59 | return; | ||
60 | } | ||
61 | tc_bus[slot].flags &= ~FREE; | ||
62 | tc_bus[slot].flags |= IN_USE; | ||
63 | } | ||
64 | |||
65 | void release_tc_card(int slot) | ||
66 | { | 33 | { |
67 | if (tc_bus[slot].flags & FREE) { | 34 | resource_size_t slotsize = tbus->info.slot_size << 20; |
68 | printk("release_tc_card: " | 35 | resource_size_t extslotsize = tbus->ext_slot_size; |
69 | "attempting to release a card already free\n"); | 36 | resource_size_t slotaddr; |
70 | return; | 37 | resource_size_t extslotaddr; |
71 | } | 38 | resource_size_t devsize; |
72 | tc_bus[slot].flags &= ~IN_USE; | 39 | void __iomem *module; |
73 | tc_bus[slot].flags |= FREE; | 40 | struct tc_dev *tdev; |
74 | } | ||
75 | |||
76 | unsigned long get_tc_base_addr(int slot) | ||
77 | { | ||
78 | return tc_bus[slot].base_addr; | ||
79 | } | ||
80 | |||
81 | unsigned long get_tc_irq_nr(int slot) | ||
82 | { | ||
83 | return tc_bus[slot].interrupt; | ||
84 | } | ||
85 | |||
86 | unsigned long get_tc_speed(void) | ||
87 | { | ||
88 | return 100000 * (10000 / (unsigned long)info->clk_period); | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * Probing for TURBOchannel modules | ||
93 | */ | ||
94 | static void __init tc_probe(unsigned long startaddr, unsigned long size, | ||
95 | int slots) | ||
96 | { | ||
97 | unsigned long slotaddr; | ||
98 | int i, slot, err; | 41 | int i, slot, err; |
99 | long offset; | ||
100 | u8 pattern[4]; | 42 | u8 pattern[4]; |
101 | volatile u8 *module; | 43 | long offset; |
102 | 44 | ||
103 | for (slot = 0; slot < slots; slot++) { | 45 | for (slot = 0; slot < tbus->num_tcslots; slot++) { |
104 | slotaddr = startaddr + slot * size; | 46 | slotaddr = tbus->slot_base + slot * slotsize; |
105 | module = ioremap_nocache(slotaddr, size); | 47 | extslotaddr = tbus->ext_slot_base + slot * extslotsize; |
48 | module = ioremap_nocache(slotaddr, slotsize); | ||
106 | BUG_ON(!module); | 49 | BUG_ON(!module); |
107 | 50 | ||
108 | offset = OLDCARD; | 51 | offset = TC_OLDCARD; |
109 | 52 | ||
110 | err = 0; | 53 | err = 0; |
111 | err |= get_dbe(pattern[0], module + OLDCARD + TC_PATTERN0); | 54 | err |= tc_preadb(pattern + 0, module + offset + TC_PATTERN0); |
112 | err |= get_dbe(pattern[1], module + OLDCARD + TC_PATTERN1); | 55 | err |= tc_preadb(pattern + 1, module + offset + TC_PATTERN1); |
113 | err |= get_dbe(pattern[2], module + OLDCARD + TC_PATTERN2); | 56 | err |= tc_preadb(pattern + 2, module + offset + TC_PATTERN2); |
114 | err |= get_dbe(pattern[3], module + OLDCARD + TC_PATTERN3); | 57 | err |= tc_preadb(pattern + 3, module + offset + TC_PATTERN3); |
115 | if (err) { | 58 | if (err) |
116 | iounmap(module); | 59 | goto out_err; |
117 | continue; | ||
118 | } | ||
119 | 60 | ||
120 | if (pattern[0] != 0x55 || pattern[1] != 0x00 || | 61 | if (pattern[0] != 0x55 || pattern[1] != 0x00 || |
121 | pattern[2] != 0xaa || pattern[3] != 0xff) { | 62 | pattern[2] != 0xaa || pattern[3] != 0xff) { |
122 | offset = NEWCARD; | 63 | offset = TC_NEWCARD; |
123 | 64 | ||
124 | err = 0; | 65 | err = 0; |
125 | err |= get_dbe(pattern[0], module + TC_PATTERN0); | 66 | err |= tc_preadb(pattern + 0, |
126 | err |= get_dbe(pattern[1], module + TC_PATTERN1); | 67 | module + offset + TC_PATTERN0); |
127 | err |= get_dbe(pattern[2], module + TC_PATTERN2); | 68 | err |= tc_preadb(pattern + 1, |
128 | err |= get_dbe(pattern[3], module + TC_PATTERN3); | 69 | module + offset + TC_PATTERN1); |
129 | if (err) { | 70 | err |= tc_preadb(pattern + 2, |
130 | iounmap(module); | 71 | module + offset + TC_PATTERN2); |
131 | continue; | 72 | err |= tc_preadb(pattern + 3, |
132 | } | 73 | module + offset + TC_PATTERN3); |
74 | if (err) | ||
75 | goto out_err; | ||
133 | } | 76 | } |
134 | 77 | ||
135 | if (pattern[0] != 0x55 || pattern[1] != 0x00 || | 78 | if (pattern[0] != 0x55 || pattern[1] != 0x00 || |
136 | pattern[2] != 0xaa || pattern[3] != 0xff) { | 79 | pattern[2] != 0xaa || pattern[3] != 0xff) |
137 | iounmap(module); | 80 | goto out_err; |
138 | continue; | 81 | |
82 | /* Found a board, allocate it an entry in the list */ | ||
83 | tdev = kzalloc(sizeof(*tdev), GFP_KERNEL); | ||
84 | if (!tdev) { | ||
85 | printk(KERN_ERR "tc%x: unable to allocate tc_dev\n", | ||
86 | slot); | ||
87 | goto out_err; | ||
139 | } | 88 | } |
89 | sprintf(tdev->dev.bus_id, "tc%x", slot); | ||
90 | tdev->bus = tbus; | ||
91 | tdev->dev.parent = &tbus->dev; | ||
92 | tdev->dev.bus = &tc_bus_type; | ||
93 | tdev->slot = slot; | ||
140 | 94 | ||
141 | tc_bus[slot].base_addr = slotaddr; | ||
142 | for (i = 0; i < 8; i++) { | 95 | for (i = 0; i < 8; i++) { |
143 | tc_bus[slot].firmware[i] = | 96 | tdev->firmware[i] = |
144 | module[TC_FIRM_VER + offset + 4 * i]; | 97 | readb(module + offset + TC_FIRM_VER + 4 * i); |
145 | tc_bus[slot].vendor[i] = | 98 | tdev->vendor[i] = |
146 | module[TC_VENDOR + offset + 4 * i]; | 99 | readb(module + offset + TC_VENDOR + 4 * i); |
147 | tc_bus[slot].name[i] = | 100 | tdev->name[i] = |
148 | module[TC_MODULE + offset + 4 * i]; | 101 | readb(module + offset + TC_MODULE + 4 * i); |
149 | } | 102 | } |
150 | tc_bus[slot].firmware[8] = 0; | 103 | tdev->firmware[8] = 0; |
151 | tc_bus[slot].vendor[8] = 0; | 104 | tdev->vendor[8] = 0; |
152 | tc_bus[slot].name[8] = 0; | 105 | tdev->name[8] = 0; |
153 | /* | 106 | |
154 | * Looks unneccesary, but we may change | 107 | pr_info("%s: %s %s %s\n", tdev->dev.bus_id, tdev->vendor, |
155 | * TC? in the future | 108 | tdev->name, tdev->firmware); |
156 | */ | 109 | |
157 | switch (slot) { | 110 | devsize = readb(module + offset + TC_SLOT_SIZE); |
158 | case 0: | 111 | devsize <<= 22; |
159 | tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC0]; | 112 | if (devsize <= slotsize) { |
160 | break; | 113 | tdev->resource.start = slotaddr; |
161 | case 1: | 114 | tdev->resource.end = slotaddr + devsize - 1; |
162 | tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC1]; | 115 | } else if (devsize <= extslotsize) { |
163 | break; | 116 | tdev->resource.start = extslotaddr; |
164 | case 2: | 117 | tdev->resource.end = extslotaddr + devsize - 1; |
165 | tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC2]; | 118 | } else { |
166 | break; | 119 | printk(KERN_ERR "%s: Cannot provide slot space " |
167 | /* | 120 | "(%dMiB required, up to %dMiB supported)\n", |
168 | * Yuck! DS5000/200 onboard devices | 121 | tdev->dev.bus_id, devsize >> 20, |
169 | */ | 122 | max(slotsize, extslotsize) >> 20); |
170 | case 5: | 123 | kfree(tdev); |
171 | tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC5]; | 124 | goto out_err; |
172 | break; | ||
173 | case 6: | ||
174 | tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC6]; | ||
175 | break; | ||
176 | default: | ||
177 | tc_bus[slot].interrupt = -1; | ||
178 | break; | ||
179 | } | 125 | } |
126 | tdev->resource.name = tdev->name; | ||
127 | tdev->resource.flags = IORESOURCE_MEM; | ||
128 | |||
129 | tc_device_get_irq(tdev); | ||
180 | 130 | ||
131 | device_register(&tdev->dev); | ||
132 | list_add_tail(&tdev->node, &tbus->devices); | ||
133 | |||
134 | out_err: | ||
181 | iounmap(module); | 135 | iounmap(module); |
182 | } | 136 | } |
183 | } | 137 | } |
184 | 138 | ||
185 | /* | 139 | /* |
186 | * the main entry | 140 | * The main entry. |
187 | */ | 141 | */ |
188 | static int __init tc_init(void) | 142 | static int __init tc_init(void) |
189 | { | 143 | { |
190 | int tc_clock; | 144 | /* Initialize the TURBOchannel bus */ |
191 | int i; | 145 | if (tc_bus_get_info(&tc_bus)) |
192 | unsigned long slot0addr; | ||
193 | unsigned long slot_size; | ||
194 | |||
195 | if (!TURBOCHANNEL) | ||
196 | return 0; | 146 | return 0; |
197 | 147 | ||
198 | for (i = 0; i < MAX_SLOT; i++) { | 148 | INIT_LIST_HEAD(&tc_bus.devices); |
199 | tc_bus[i].base_addr = 0; | 149 | strcpy(tc_bus.dev.bus_id, "tc"); |
200 | tc_bus[i].name[0] = 0; | 150 | device_register(&tc_bus.dev); |
201 | tc_bus[i].vendor[0] = 0; | 151 | |
202 | tc_bus[i].firmware[0] = 0; | 152 | if (tc_bus.info.slot_size) { |
203 | tc_bus[i].interrupt = -1; | 153 | unsigned int tc_clock = tc_get_speed(&tc_bus) / 100000; |
204 | tc_bus[i].flags = FREE; | 154 | |
205 | } | 155 | pr_info("tc: TURBOchannel rev. %d at %d.%d MHz " |
206 | 156 | "(with%s parity)\n", tc_bus.info.revision, | |
207 | info = rex_gettcinfo(); | 157 | tc_clock / 10, tc_clock % 10, |
208 | slot0addr = CPHYSADDR((long)rex_slot_address(0)); | 158 | tc_bus.info.parity ? "" : "out"); |
209 | 159 | ||
210 | switch (mips_machtype) { | 160 | tc_bus.resource[0].start = tc_bus.slot_base; |
211 | case MACH_DS5000_200: | 161 | tc_bus.resource[0].end = tc_bus.slot_base + |
212 | num_tcslots = 7; | 162 | (tc_bus.info.slot_size << 20) * |
213 | break; | 163 | tc_bus.num_tcslots - 1; |
214 | case MACH_DS5000_1XX: | 164 | tc_bus.resource[0].name = tc_bus.name; |
215 | case MACH_DS5000_2X0: | 165 | tc_bus.resource[0].flags = IORESOURCE_MEM; |
216 | case MACH_DS5900: | 166 | if (request_resource(&iomem_resource, |
217 | num_tcslots = 3; | 167 | &tc_bus.resource[0]) < 0) { |
218 | break; | 168 | printk(KERN_ERR "tc: Cannot reserve resource\n"); |
219 | case MACH_DS5000_XX: | 169 | return 0; |
220 | default: | 170 | } |
221 | num_tcslots = 2; | 171 | if (tc_bus.ext_slot_size) { |
222 | break; | 172 | tc_bus.resource[1].start = tc_bus.ext_slot_base; |
223 | } | 173 | tc_bus.resource[1].end = tc_bus.ext_slot_base + |
224 | 174 | tc_bus.ext_slot_size * | |
225 | tc_clock = 10000 / info->clk_period; | 175 | tc_bus.num_tcslots - 1; |
226 | 176 | tc_bus.resource[1].name = tc_bus.name; | |
227 | if (info->slot_size && slot0addr) { | 177 | tc_bus.resource[1].flags = IORESOURCE_MEM; |
228 | pr_info("TURBOchannel rev. %d at %d.%d MHz (with%s parity)\n", | 178 | if (request_resource(&iomem_resource, |
229 | info->revision, tc_clock / 10, tc_clock % 10, | 179 | &tc_bus.resource[1]) < 0) { |
230 | info->parity ? "" : "out"); | 180 | printk(KERN_ERR |
231 | 181 | "tc: Cannot reserve resource\n"); | |
232 | slot_size = info->slot_size << 20; | 182 | release_resource(&tc_bus.resource[0]); |
233 | 183 | return 0; | |
234 | tc_probe(slot0addr, slot_size, num_tcslots); | 184 | } |
235 | |||
236 | for (i = 0; i < num_tcslots; i++) { | ||
237 | if (!tc_bus[i].base_addr) | ||
238 | continue; | ||
239 | pr_info(" slot %d: %s %s %s\n", i, tc_bus[i].vendor, | ||
240 | tc_bus[i].name, tc_bus[i].firmware); | ||
241 | } | 185 | } |
186 | |||
187 | tc_bus_add_devices(&tc_bus); | ||
242 | } | 188 | } |
243 | 189 | ||
244 | return 0; | 190 | return 0; |
245 | } | 191 | } |
246 | 192 | ||
247 | subsys_initcall(tc_init); | 193 | subsys_initcall(tc_init); |
248 | |||
249 | EXPORT_SYMBOL(search_tc_card); | ||
250 | EXPORT_SYMBOL(claim_tc_card); | ||
251 | EXPORT_SYMBOL(release_tc_card); | ||
252 | EXPORT_SYMBOL(get_tc_base_addr); | ||
253 | EXPORT_SYMBOL(get_tc_irq_nr); | ||
254 | EXPORT_SYMBOL(get_tc_speed); | ||
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 4e83f01e894e..45fe65d8d7a0 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1444,8 +1444,8 @@ config FB_PMAG_AA | |||
1444 | used mainly in the MIPS-based DECstation series. | 1444 | used mainly in the MIPS-based DECstation series. |
1445 | 1445 | ||
1446 | config FB_PMAG_BA | 1446 | config FB_PMAG_BA |
1447 | bool "PMAG-BA TURBOchannel framebuffer support" | 1447 | tristate "PMAG-BA TURBOchannel framebuffer support" |
1448 | depends on (FB = y) && TC | 1448 | depends on FB && TC |
1449 | select FB_CFB_FILLRECT | 1449 | select FB_CFB_FILLRECT |
1450 | select FB_CFB_COPYAREA | 1450 | select FB_CFB_COPYAREA |
1451 | select FB_CFB_IMAGEBLIT | 1451 | select FB_CFB_IMAGEBLIT |
@@ -1454,8 +1454,8 @@ config FB_PMAG_BA | |||
1454 | used mainly in the MIPS-based DECstation series. | 1454 | used mainly in the MIPS-based DECstation series. |
1455 | 1455 | ||
1456 | config FB_PMAGB_B | 1456 | config FB_PMAGB_B |
1457 | bool "PMAGB-B TURBOchannel framebuffer support" | 1457 | tristate "PMAGB-B TURBOchannel framebuffer support" |
1458 | depends on (FB = y) && TC | 1458 | depends on TC |
1459 | select FB_CFB_FILLRECT | 1459 | select FB_CFB_FILLRECT |
1460 | select FB_CFB_COPYAREA | 1460 | select FB_CFB_COPYAREA |
1461 | select FB_CFB_IMAGEBLIT | 1461 | select FB_CFB_IMAGEBLIT |
diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c index f5361cd8ccce..264d37243fad 100644 --- a/drivers/video/pmag-ba-fb.c +++ b/drivers/video/pmag-ba-fb.c | |||
@@ -15,7 +15,8 @@ | |||
15 | * Michael Engel <engel@unix-ag.org>, | 15 | * Michael Engel <engel@unix-ag.org>, |
16 | * Karsten Merker <merker@linuxtag.org> and | 16 | * Karsten Merker <merker@linuxtag.org> and |
17 | * Harald Koerfgen. | 17 | * Harald Koerfgen. |
18 | * Copyright (c) 2005 Maciej W. Rozycki | 18 | * Copyright (c) 2005, 2006 Maciej W. Rozycki |
19 | * Copyright (c) 2005 James Simmons | ||
19 | * | 20 | * |
20 | * This file is subject to the terms and conditions of the GNU General | 21 | * This file is subject to the terms and conditions of the GNU General |
21 | * Public License. See the file COPYING in the main directory of this | 22 | * Public License. See the file COPYING in the main directory of this |
@@ -28,26 +29,21 @@ | |||
28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
29 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/tc.h> | ||
31 | #include <linux/types.h> | 33 | #include <linux/types.h> |
32 | 34 | ||
33 | #include <asm/io.h> | 35 | #include <asm/io.h> |
34 | #include <asm/system.h> | 36 | #include <asm/system.h> |
35 | 37 | ||
36 | #include <asm/dec/tc.h> | ||
37 | |||
38 | #include <video/pmag-ba-fb.h> | 38 | #include <video/pmag-ba-fb.h> |
39 | 39 | ||
40 | 40 | ||
41 | struct pmagbafb_par { | 41 | struct pmagbafb_par { |
42 | struct fb_info *next; | ||
43 | volatile void __iomem *mmio; | 42 | volatile void __iomem *mmio; |
44 | volatile u32 __iomem *dac; | 43 | volatile u32 __iomem *dac; |
45 | int slot; | ||
46 | }; | 44 | }; |
47 | 45 | ||
48 | 46 | ||
49 | static struct fb_info *root_pmagbafb_dev; | ||
50 | |||
51 | static struct fb_var_screeninfo pmagbafb_defined __initdata = { | 47 | static struct fb_var_screeninfo pmagbafb_defined __initdata = { |
52 | .xres = 1024, | 48 | .xres = 1024, |
53 | .yres = 864, | 49 | .yres = 864, |
@@ -145,24 +141,19 @@ static void __init pmagbafb_erase_cursor(struct fb_info *info) | |||
145 | } | 141 | } |
146 | 142 | ||
147 | 143 | ||
148 | static int __init pmagbafb_init_one(int slot) | 144 | static int __init pmagbafb_probe(struct device *dev) |
149 | { | 145 | { |
146 | struct tc_dev *tdev = to_tc_dev(dev); | ||
147 | resource_size_t start, len; | ||
150 | struct fb_info *info; | 148 | struct fb_info *info; |
151 | struct pmagbafb_par *par; | 149 | struct pmagbafb_par *par; |
152 | unsigned long base_addr; | ||
153 | 150 | ||
154 | info = framebuffer_alloc(sizeof(struct pmagbafb_par), NULL); | 151 | info = framebuffer_alloc(sizeof(struct pmagbafb_par), dev); |
155 | if (!info) | 152 | if (!info) |
156 | return -ENOMEM; | 153 | return -ENOMEM; |
157 | 154 | ||
158 | par = info->par; | 155 | par = info->par; |
159 | par->slot = slot; | 156 | dev_set_drvdata(dev, info); |
160 | claim_tc_card(par->slot); | ||
161 | |||
162 | base_addr = get_tc_base_addr(par->slot); | ||
163 | |||
164 | par->next = root_pmagbafb_dev; | ||
165 | root_pmagbafb_dev = info; | ||
166 | 157 | ||
167 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) | 158 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) |
168 | goto err_alloc; | 159 | goto err_alloc; |
@@ -172,15 +163,21 @@ static int __init pmagbafb_init_one(int slot) | |||
172 | info->var = pmagbafb_defined; | 163 | info->var = pmagbafb_defined; |
173 | info->flags = FBINFO_DEFAULT; | 164 | info->flags = FBINFO_DEFAULT; |
174 | 165 | ||
166 | /* Request the I/O MEM resource. */ | ||
167 | start = tdev->resource.start; | ||
168 | len = tdev->resource.end - start + 1; | ||
169 | if (!request_mem_region(start, len, dev->bus_id)) | ||
170 | goto err_cmap; | ||
171 | |||
175 | /* MMIO mapping setup. */ | 172 | /* MMIO mapping setup. */ |
176 | info->fix.mmio_start = base_addr; | 173 | info->fix.mmio_start = start; |
177 | par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); | 174 | par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); |
178 | if (!par->mmio) | 175 | if (!par->mmio) |
179 | goto err_cmap; | 176 | goto err_resource; |
180 | par->dac = par->mmio + PMAG_BA_BT459; | 177 | par->dac = par->mmio + PMAG_BA_BT459; |
181 | 178 | ||
182 | /* Frame buffer mapping setup. */ | 179 | /* Frame buffer mapping setup. */ |
183 | info->fix.smem_start = base_addr + PMAG_BA_FBMEM; | 180 | info->fix.smem_start = start + PMAG_BA_FBMEM; |
184 | info->screen_base = ioremap_nocache(info->fix.smem_start, | 181 | info->screen_base = ioremap_nocache(info->fix.smem_start, |
185 | info->fix.smem_len); | 182 | info->fix.smem_len); |
186 | if (!info->screen_base) | 183 | if (!info->screen_base) |
@@ -192,8 +189,10 @@ static int __init pmagbafb_init_one(int slot) | |||
192 | if (register_framebuffer(info) < 0) | 189 | if (register_framebuffer(info) < 0) |
193 | goto err_smem_map; | 190 | goto err_smem_map; |
194 | 191 | ||
195 | pr_info("fb%d: %s frame buffer device in slot %d\n", | 192 | get_device(dev); |
196 | info->node, info->fix.id, par->slot); | 193 | |
194 | pr_info("fb%d: %s frame buffer device at %s\n", | ||
195 | info->node, info->fix.id, dev->bus_id); | ||
197 | 196 | ||
198 | return 0; | 197 | return 0; |
199 | 198 | ||
@@ -204,54 +203,68 @@ err_smem_map: | |||
204 | err_mmio_map: | 203 | err_mmio_map: |
205 | iounmap(par->mmio); | 204 | iounmap(par->mmio); |
206 | 205 | ||
206 | err_resource: | ||
207 | release_mem_region(start, len); | ||
208 | |||
207 | err_cmap: | 209 | err_cmap: |
208 | fb_dealloc_cmap(&info->cmap); | 210 | fb_dealloc_cmap(&info->cmap); |
209 | 211 | ||
210 | err_alloc: | 212 | err_alloc: |
211 | root_pmagbafb_dev = par->next; | ||
212 | release_tc_card(par->slot); | ||
213 | framebuffer_release(info); | 213 | framebuffer_release(info); |
214 | return -ENXIO; | 214 | return -ENXIO; |
215 | } | 215 | } |
216 | 216 | ||
217 | static void __exit pmagbafb_exit_one(void) | 217 | static int __exit pmagbafb_remove(struct device *dev) |
218 | { | 218 | { |
219 | struct fb_info *info = root_pmagbafb_dev; | 219 | struct tc_dev *tdev = to_tc_dev(dev); |
220 | struct fb_info *info = dev_get_drvdata(dev); | ||
220 | struct pmagbafb_par *par = info->par; | 221 | struct pmagbafb_par *par = info->par; |
222 | resource_size_t start, len; | ||
221 | 223 | ||
224 | put_device(dev); | ||
222 | unregister_framebuffer(info); | 225 | unregister_framebuffer(info); |
223 | iounmap(info->screen_base); | 226 | iounmap(info->screen_base); |
224 | iounmap(par->mmio); | 227 | iounmap(par->mmio); |
228 | start = tdev->resource.start; | ||
229 | len = tdev->resource.end - start + 1; | ||
230 | release_mem_region(start, len); | ||
225 | fb_dealloc_cmap(&info->cmap); | 231 | fb_dealloc_cmap(&info->cmap); |
226 | root_pmagbafb_dev = par->next; | ||
227 | release_tc_card(par->slot); | ||
228 | framebuffer_release(info); | 232 | framebuffer_release(info); |
233 | return 0; | ||
229 | } | 234 | } |
230 | 235 | ||
231 | 236 | ||
232 | /* | 237 | /* |
233 | * Initialise the framebuffer. | 238 | * Initialize the framebuffer. |
234 | */ | 239 | */ |
240 | static const struct tc_device_id pmagbafb_tc_table[] = { | ||
241 | { "DEC ", "PMAG-BA " }, | ||
242 | { } | ||
243 | }; | ||
244 | MODULE_DEVICE_TABLE(tc, pmagbafb_tc_table); | ||
245 | |||
246 | static struct tc_driver pmagbafb_driver = { | ||
247 | .id_table = pmagbafb_tc_table, | ||
248 | .driver = { | ||
249 | .name = "pmagbafb", | ||
250 | .bus = &tc_bus_type, | ||
251 | .probe = pmagbafb_probe, | ||
252 | .remove = __exit_p(pmagbafb_remove), | ||
253 | }, | ||
254 | }; | ||
255 | |||
235 | static int __init pmagbafb_init(void) | 256 | static int __init pmagbafb_init(void) |
236 | { | 257 | { |
237 | int count = 0; | 258 | #ifndef MODULE |
238 | int slot; | ||
239 | |||
240 | if (fb_get_options("pmagbafb", NULL)) | 259 | if (fb_get_options("pmagbafb", NULL)) |
241 | return -ENXIO; | 260 | return -ENXIO; |
242 | 261 | #endif | |
243 | while ((slot = search_tc_card("PMAG-BA")) >= 0) { | 262 | return tc_register_driver(&pmagbafb_driver); |
244 | if (pmagbafb_init_one(slot) < 0) | ||
245 | break; | ||
246 | count++; | ||
247 | } | ||
248 | return (count > 0) ? 0 : -ENXIO; | ||
249 | } | 263 | } |
250 | 264 | ||
251 | static void __exit pmagbafb_exit(void) | 265 | static void __exit pmagbafb_exit(void) |
252 | { | 266 | { |
253 | while (root_pmagbafb_dev) | 267 | tc_unregister_driver(&pmagbafb_driver); |
254 | pmagbafb_exit_one(); | ||
255 | } | 268 | } |
256 | 269 | ||
257 | 270 | ||
diff --git a/drivers/video/pmagb-b-fb.c b/drivers/video/pmagb-b-fb.c index a06a064ad757..7a0ce7d5af6b 100644 --- a/drivers/video/pmagb-b-fb.c +++ b/drivers/video/pmagb-b-fb.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * Michael Engel <engel@unix-ag.org>, | 11 | * Michael Engel <engel@unix-ag.org>, |
12 | * Karsten Merker <merker@linuxtag.org> and | 12 | * Karsten Merker <merker@linuxtag.org> and |
13 | * Harald Koerfgen. | 13 | * Harald Koerfgen. |
14 | * Copyright (c) 2005 Maciej W. Rozycki | 14 | * Copyright (c) 2005, 2006 Maciej W. Rozycki |
15 | * | 15 | * |
16 | * This file is subject to the terms and conditions of the GNU General | 16 | * This file is subject to the terms and conditions of the GNU General |
17 | * Public License. See the file COPYING in the main directory of this | 17 | * Public License. See the file COPYING in the main directory of this |
@@ -25,18 +25,16 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/tc.h> | ||
28 | #include <linux/types.h> | 29 | #include <linux/types.h> |
29 | 30 | ||
30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
31 | #include <asm/system.h> | 32 | #include <asm/system.h> |
32 | 33 | ||
33 | #include <asm/dec/tc.h> | ||
34 | |||
35 | #include <video/pmagb-b-fb.h> | 34 | #include <video/pmagb-b-fb.h> |
36 | 35 | ||
37 | 36 | ||
38 | struct pmagbbfb_par { | 37 | struct pmagbbfb_par { |
39 | struct fb_info *next; | ||
40 | volatile void __iomem *mmio; | 38 | volatile void __iomem *mmio; |
41 | volatile void __iomem *smem; | 39 | volatile void __iomem *smem; |
42 | volatile u32 __iomem *sfb; | 40 | volatile u32 __iomem *sfb; |
@@ -47,8 +45,6 @@ struct pmagbbfb_par { | |||
47 | }; | 45 | }; |
48 | 46 | ||
49 | 47 | ||
50 | static struct fb_info *root_pmagbbfb_dev; | ||
51 | |||
52 | static struct fb_var_screeninfo pmagbbfb_defined __initdata = { | 48 | static struct fb_var_screeninfo pmagbbfb_defined __initdata = { |
53 | .bits_per_pixel = 8, | 49 | .bits_per_pixel = 8, |
54 | .red.length = 8, | 50 | .red.length = 8, |
@@ -190,8 +186,9 @@ static void __init pmagbbfb_osc_setup(struct fb_info *info) | |||
190 | 69197, 66000, 65000, 50350, 36000, 32000, 25175 | 186 | 69197, 66000, 65000, 50350, 36000, 32000, 25175 |
191 | }; | 187 | }; |
192 | struct pmagbbfb_par *par = info->par; | 188 | struct pmagbbfb_par *par = info->par; |
189 | struct tc_bus *tbus = to_tc_dev(info->device)->bus; | ||
193 | u32 count0 = 8, count1 = 8, counttc = 16 * 256 + 8; | 190 | u32 count0 = 8, count1 = 8, counttc = 16 * 256 + 8; |
194 | u32 freq0, freq1, freqtc = get_tc_speed() / 250; | 191 | u32 freq0, freq1, freqtc = tc_get_speed(tbus) / 250; |
195 | int i, j; | 192 | int i, j; |
196 | 193 | ||
197 | gp0_write(par, 0); /* select Osc0 */ | 194 | gp0_write(par, 0); /* select Osc0 */ |
@@ -249,26 +246,21 @@ static void __init pmagbbfb_osc_setup(struct fb_info *info) | |||
249 | }; | 246 | }; |
250 | 247 | ||
251 | 248 | ||
252 | static int __init pmagbbfb_init_one(int slot) | 249 | static int __init pmagbbfb_probe(struct device *dev) |
253 | { | 250 | { |
254 | char freq0[12], freq1[12]; | 251 | struct tc_dev *tdev = to_tc_dev(dev); |
252 | resource_size_t start, len; | ||
255 | struct fb_info *info; | 253 | struct fb_info *info; |
256 | struct pmagbbfb_par *par; | 254 | struct pmagbbfb_par *par; |
257 | unsigned long base_addr; | 255 | char freq0[12], freq1[12]; |
258 | u32 vid_base; | 256 | u32 vid_base; |
259 | 257 | ||
260 | info = framebuffer_alloc(sizeof(struct pmagbbfb_par), NULL); | 258 | info = framebuffer_alloc(sizeof(struct pmagbbfb_par), dev); |
261 | if (!info) | 259 | if (!info) |
262 | return -ENOMEM; | 260 | return -ENOMEM; |
263 | 261 | ||
264 | par = info->par; | 262 | par = info->par; |
265 | par->slot = slot; | 263 | dev_set_drvdata(dev, info); |
266 | claim_tc_card(par->slot); | ||
267 | |||
268 | base_addr = get_tc_base_addr(par->slot); | ||
269 | |||
270 | par->next = root_pmagbbfb_dev; | ||
271 | root_pmagbbfb_dev = info; | ||
272 | 264 | ||
273 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) | 265 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) |
274 | goto err_alloc; | 266 | goto err_alloc; |
@@ -278,16 +270,22 @@ static int __init pmagbbfb_init_one(int slot) | |||
278 | info->var = pmagbbfb_defined; | 270 | info->var = pmagbbfb_defined; |
279 | info->flags = FBINFO_DEFAULT; | 271 | info->flags = FBINFO_DEFAULT; |
280 | 272 | ||
273 | /* Request the I/O MEM resource. */ | ||
274 | start = tdev->resource.start; | ||
275 | len = tdev->resource.end - start + 1; | ||
276 | if (!request_mem_region(start, len, dev->bus_id)) | ||
277 | goto err_cmap; | ||
278 | |||
281 | /* MMIO mapping setup. */ | 279 | /* MMIO mapping setup. */ |
282 | info->fix.mmio_start = base_addr; | 280 | info->fix.mmio_start = start; |
283 | par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); | 281 | par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); |
284 | if (!par->mmio) | 282 | if (!par->mmio) |
285 | goto err_cmap; | 283 | goto err_resource; |
286 | par->sfb = par->mmio + PMAGB_B_SFB; | 284 | par->sfb = par->mmio + PMAGB_B_SFB; |
287 | par->dac = par->mmio + PMAGB_B_BT459; | 285 | par->dac = par->mmio + PMAGB_B_BT459; |
288 | 286 | ||
289 | /* Frame buffer mapping setup. */ | 287 | /* Frame buffer mapping setup. */ |
290 | info->fix.smem_start = base_addr + PMAGB_B_FBMEM; | 288 | info->fix.smem_start = start + PMAGB_B_FBMEM; |
291 | par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); | 289 | par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); |
292 | if (!par->smem) | 290 | if (!par->smem) |
293 | goto err_mmio_map; | 291 | goto err_mmio_map; |
@@ -302,13 +300,15 @@ static int __init pmagbbfb_init_one(int slot) | |||
302 | if (register_framebuffer(info) < 0) | 300 | if (register_framebuffer(info) < 0) |
303 | goto err_smem_map; | 301 | goto err_smem_map; |
304 | 302 | ||
303 | get_device(dev); | ||
304 | |||
305 | snprintf(freq0, sizeof(freq0), "%u.%03uMHz", | 305 | snprintf(freq0, sizeof(freq0), "%u.%03uMHz", |
306 | par->osc0 / 1000, par->osc0 % 1000); | 306 | par->osc0 / 1000, par->osc0 % 1000); |
307 | snprintf(freq1, sizeof(freq1), "%u.%03uMHz", | 307 | snprintf(freq1, sizeof(freq1), "%u.%03uMHz", |
308 | par->osc1 / 1000, par->osc1 % 1000); | 308 | par->osc1 / 1000, par->osc1 % 1000); |
309 | 309 | ||
310 | pr_info("fb%d: %s frame buffer device in slot %d\n", | 310 | pr_info("fb%d: %s frame buffer device at %s\n", |
311 | info->node, info->fix.id, par->slot); | 311 | info->node, info->fix.id, dev->bus_id); |
312 | pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n", | 312 | pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n", |
313 | info->node, freq0, par->osc1 ? freq1 : "disabled", | 313 | info->node, freq0, par->osc1 ? freq1 : "disabled", |
314 | par->osc1 != 0); | 314 | par->osc1 != 0); |
@@ -322,54 +322,68 @@ err_smem_map: | |||
322 | err_mmio_map: | 322 | err_mmio_map: |
323 | iounmap(par->mmio); | 323 | iounmap(par->mmio); |
324 | 324 | ||
325 | err_resource: | ||
326 | release_mem_region(start, len); | ||
327 | |||
325 | err_cmap: | 328 | err_cmap: |
326 | fb_dealloc_cmap(&info->cmap); | 329 | fb_dealloc_cmap(&info->cmap); |
327 | 330 | ||
328 | err_alloc: | 331 | err_alloc: |
329 | root_pmagbbfb_dev = par->next; | ||
330 | release_tc_card(par->slot); | ||
331 | framebuffer_release(info); | 332 | framebuffer_release(info); |
332 | return -ENXIO; | 333 | return -ENXIO; |
333 | } | 334 | } |
334 | 335 | ||
335 | static void __exit pmagbbfb_exit_one(void) | 336 | static int __exit pmagbbfb_remove(struct device *dev) |
336 | { | 337 | { |
337 | struct fb_info *info = root_pmagbbfb_dev; | 338 | struct tc_dev *tdev = to_tc_dev(dev); |
339 | struct fb_info *info = dev_get_drvdata(dev); | ||
338 | struct pmagbbfb_par *par = info->par; | 340 | struct pmagbbfb_par *par = info->par; |
341 | resource_size_t start, len; | ||
339 | 342 | ||
343 | put_device(dev); | ||
340 | unregister_framebuffer(info); | 344 | unregister_framebuffer(info); |
341 | iounmap(par->smem); | 345 | iounmap(par->smem); |
342 | iounmap(par->mmio); | 346 | iounmap(par->mmio); |
347 | start = tdev->resource.start; | ||
348 | len = tdev->resource.end - start + 1; | ||
349 | release_mem_region(start, len); | ||
343 | fb_dealloc_cmap(&info->cmap); | 350 | fb_dealloc_cmap(&info->cmap); |
344 | root_pmagbbfb_dev = par->next; | ||
345 | release_tc_card(par->slot); | ||
346 | framebuffer_release(info); | 351 | framebuffer_release(info); |
352 | return 0; | ||
347 | } | 353 | } |
348 | 354 | ||
349 | 355 | ||
350 | /* | 356 | /* |
351 | * Initialise the framebuffer. | 357 | * Initialize the framebuffer. |
352 | */ | 358 | */ |
359 | static const struct tc_device_id pmagbbfb_tc_table[] = { | ||
360 | { "DEC ", "PMAGB-BA" }, | ||
361 | { } | ||
362 | }; | ||
363 | MODULE_DEVICE_TABLE(tc, pmagbbfb_tc_table); | ||
364 | |||
365 | static struct tc_driver pmagbbfb_driver = { | ||
366 | .id_table = pmagbbfb_tc_table, | ||
367 | .driver = { | ||
368 | .name = "pmagbbfb", | ||
369 | .bus = &tc_bus_type, | ||
370 | .probe = pmagbbfb_probe, | ||
371 | .remove = __exit_p(pmagbbfb_remove), | ||
372 | }, | ||
373 | }; | ||
374 | |||
353 | static int __init pmagbbfb_init(void) | 375 | static int __init pmagbbfb_init(void) |
354 | { | 376 | { |
355 | int count = 0; | 377 | #ifndef MODULE |
356 | int slot; | ||
357 | |||
358 | if (fb_get_options("pmagbbfb", NULL)) | 378 | if (fb_get_options("pmagbbfb", NULL)) |
359 | return -ENXIO; | 379 | return -ENXIO; |
360 | 380 | #endif | |
361 | while ((slot = search_tc_card("PMAGB-BA")) >= 0) { | 381 | return tc_register_driver(&pmagbbfb_driver); |
362 | if (pmagbbfb_init_one(slot) < 0) | ||
363 | break; | ||
364 | count++; | ||
365 | } | ||
366 | return (count > 0) ? 0 : -ENXIO; | ||
367 | } | 382 | } |
368 | 383 | ||
369 | static void __exit pmagbbfb_exit(void) | 384 | static void __exit pmagbbfb_exit(void) |
370 | { | 385 | { |
371 | while (root_pmagbbfb_dev) | 386 | tc_unregister_driver(&pmagbbfb_driver); |
372 | pmagbbfb_exit_one(); | ||
373 | } | 387 | } |
374 | 388 | ||
375 | 389 | ||
diff --git a/include/asm-mips/dec/system.h b/include/asm-mips/dec/system.h index 78af51fbc797..b2afaccd6831 100644 --- a/include/asm-mips/dec/system.h +++ b/include/asm-mips/dec/system.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Generic DECstation/DECsystem bits. | 4 | * Generic DECstation/DECsystem bits. |
5 | * | 5 | * |
6 | * Copyright (C) 2005 Maciej W. Rozycki | 6 | * Copyright (C) 2005, 2006 Maciej W. Rozycki |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License | 9 | * modify it under the terms of the GNU General Public License |
@@ -14,5 +14,6 @@ | |||
14 | #define __ASM_DEC_SYSTEM_H | 14 | #define __ASM_DEC_SYSTEM_H |
15 | 15 | ||
16 | extern unsigned long dec_kn_slot_base, dec_kn_slot_size; | 16 | extern unsigned long dec_kn_slot_base, dec_kn_slot_size; |
17 | extern int dec_tc_bus; | ||
17 | 18 | ||
18 | #endif /* __ASM_DEC_SYSTEM_H */ | 19 | #endif /* __ASM_DEC_SYSTEM_H */ |
diff --git a/include/asm-mips/dec/tc.h b/include/asm-mips/dec/tc.h deleted file mode 100644 index 9cb51f24d42c..000000000000 --- a/include/asm-mips/dec/tc.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | * Interface to the TURBOchannel related routines | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (c) 1998 Harald Koerfgen | ||
9 | */ | ||
10 | #ifndef __ASM_DEC_TC_H | ||
11 | #define __ASM_DEC_TC_H | ||
12 | |||
13 | /* | ||
14 | * Search for a TURBOchannel Option Module | ||
15 | * with a certain name. Returns slot number | ||
16 | * of the first card not in use or -ENODEV | ||
17 | * if none found. | ||
18 | */ | ||
19 | extern int search_tc_card(const char *); | ||
20 | /* | ||
21 | * Marks the card in slot as used | ||
22 | */ | ||
23 | extern void claim_tc_card(int); | ||
24 | /* | ||
25 | * Marks the card in slot as free | ||
26 | */ | ||
27 | extern void release_tc_card(int); | ||
28 | /* | ||
29 | * Return base address of card in slot | ||
30 | */ | ||
31 | extern unsigned long get_tc_base_addr(int); | ||
32 | /* | ||
33 | * Return interrupt number of slot | ||
34 | */ | ||
35 | extern unsigned long get_tc_irq_nr(int); | ||
36 | /* | ||
37 | * Return TURBOchannel clock frequency in Hz | ||
38 | */ | ||
39 | extern unsigned long get_tc_speed(void); | ||
40 | |||
41 | #endif /* __ASM_DEC_TC_H */ | ||
diff --git a/include/asm-mips/dec/tcinfo.h b/include/asm-mips/dec/tcinfo.h deleted file mode 100644 index cc23509ee77a..000000000000 --- a/include/asm-mips/dec/tcinfo.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * Various TURBOchannel related stuff | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Information obtained through the get_tcinfo prom call | ||
9 | * created from: | ||
10 | * | ||
11 | * TURBOchannel Firmware Specification | ||
12 | * | ||
13 | * EK-TCAAD-FS-004 | ||
14 | * from Digital Equipment Corporation | ||
15 | * | ||
16 | * Copyright (c) 1998 Harald Koerfgen | ||
17 | */ | ||
18 | |||
19 | typedef struct { | ||
20 | int revision; | ||
21 | int clk_period; | ||
22 | int slot_size; | ||
23 | int io_timeout; | ||
24 | int dma_range; | ||
25 | int max_dma_burst; | ||
26 | int parity; | ||
27 | int reserved[4]; | ||
28 | } tcinfo; | ||
29 | |||
30 | #define MAX_SLOT 7 | ||
31 | |||
32 | typedef struct { | ||
33 | unsigned long base_addr; | ||
34 | unsigned char name[9]; | ||
35 | unsigned char vendor[9]; | ||
36 | unsigned char firmware[9]; | ||
37 | int interrupt; | ||
38 | int flags; | ||
39 | } slot_info; | ||
40 | |||
41 | /* | ||
42 | * Values for flags | ||
43 | */ | ||
44 | #define FREE 1<<0 | ||
45 | #define IN_USE 1<<1 | ||
46 | |||
47 | |||
diff --git a/include/asm-mips/dec/tcmodule.h b/include/asm-mips/dec/tcmodule.h deleted file mode 100644 index 6268e8915d87..000000000000 --- a/include/asm-mips/dec/tcmodule.h +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Offsets for the ROM header locations for | ||
7 | * TURBOchannel cards | ||
8 | * | ||
9 | * created from: | ||
10 | * | ||
11 | * TURBOchannel Firmware Specification | ||
12 | * | ||
13 | * EK-TCAAD-FS-004 | ||
14 | * from Digital Equipment Corporation | ||
15 | * | ||
16 | * Jan.1998 Harald Koerfgen | ||
17 | */ | ||
18 | #ifndef __ASM_DEC_TCMODULE_H | ||
19 | #define __ASM_DEC_TCMODULE_H | ||
20 | |||
21 | #define OLDCARD 0x3c0000 | ||
22 | #define NEWCARD 0x000000 | ||
23 | |||
24 | #define TC_ROM_WIDTH 0x3e0 | ||
25 | #define TC_ROM_STRIDE 0x3e4 | ||
26 | #define TC_ROM_SIZE 0x3e8 | ||
27 | #define TC_SLOT_SIZE 0x3ec | ||
28 | #define TC_PATTERN0 0x3f0 | ||
29 | #define TC_PATTERN1 0x3f4 | ||
30 | #define TC_PATTERN2 0x3f8 | ||
31 | #define TC_PATTERN3 0x3fc | ||
32 | #define TC_FIRM_VER 0x400 | ||
33 | #define TC_VENDOR 0x420 | ||
34 | #define TC_MODULE 0x440 | ||
35 | #define TC_FIRM_TYPE 0x460 | ||
36 | #define TC_FLAGS 0x470 | ||
37 | #define TC_ROM_OBJECTS 0x480 | ||
38 | |||
39 | #endif /* __ASM_DEC_TCMODULE_H */ | ||
diff --git a/include/linux/eisa.h b/include/linux/eisa.h index 1ff7c1392525..fe806b6f030d 100644 --- a/include/linux/eisa.h +++ b/include/linux/eisa.h | |||
@@ -61,10 +61,20 @@ struct eisa_driver { | |||
61 | 61 | ||
62 | #define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver) | 62 | #define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver) |
63 | 63 | ||
64 | /* These external functions are only available when EISA support is enabled. */ | ||
65 | #ifdef CONFIG_EISA | ||
66 | |||
64 | extern struct bus_type eisa_bus_type; | 67 | extern struct bus_type eisa_bus_type; |
65 | int eisa_driver_register (struct eisa_driver *edrv); | 68 | int eisa_driver_register (struct eisa_driver *edrv); |
66 | void eisa_driver_unregister (struct eisa_driver *edrv); | 69 | void eisa_driver_unregister (struct eisa_driver *edrv); |
67 | 70 | ||
71 | #else /* !CONFIG_EISA */ | ||
72 | |||
73 | static inline int eisa_driver_register (struct eisa_driver *edrv) { return 0; } | ||
74 | static inline void eisa_driver_unregister (struct eisa_driver *edrv) { } | ||
75 | |||
76 | #endif /* !CONFIG_EISA */ | ||
77 | |||
68 | /* Mimics pci.h... */ | 78 | /* Mimics pci.h... */ |
69 | static inline void *eisa_get_drvdata (struct eisa_device *edev) | 79 | static inline void *eisa_get_drvdata (struct eisa_device *edev) |
70 | { | 80 | { |
diff --git a/include/linux/tc.h b/include/linux/tc.h new file mode 100644 index 000000000000..f92511e57cdb --- /dev/null +++ b/include/linux/tc.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * Interface to the TURBOchannel related routines. | ||
3 | * | ||
4 | * Copyright (c) 1998 Harald Koerfgen | ||
5 | * Copyright (c) 2005 James Simmons | ||
6 | * Copyright (c) 2006 Maciej W. Rozycki | ||
7 | * | ||
8 | * Based on: | ||
9 | * | ||
10 | * "TURBOchannel Firmware Specification", EK-TCAAD-FS-004 | ||
11 | * | ||
12 | * from Digital Equipment Corporation. | ||
13 | * | ||
14 | * This file is subject to the terms and conditions of the GNU | ||
15 | * General Public License. See the file "COPYING" in the main | ||
16 | * directory of this archive for more details. | ||
17 | */ | ||
18 | #ifndef _LINUX_TC_H | ||
19 | #define _LINUX_TC_H | ||
20 | |||
21 | #include <linux/compiler.h> | ||
22 | #include <linux/device.h> | ||
23 | #include <linux/ioport.h> | ||
24 | #include <linux/types.h> | ||
25 | |||
26 | /* | ||
27 | * Offsets for the ROM header locations for TURBOchannel cards. | ||
28 | */ | ||
29 | #define TC_OLDCARD 0x3c0000 | ||
30 | #define TC_NEWCARD 0x000000 | ||
31 | |||
32 | #define TC_ROM_WIDTH 0x3e0 | ||
33 | #define TC_ROM_STRIDE 0x3e4 | ||
34 | #define TC_ROM_SIZE 0x3e8 | ||
35 | #define TC_SLOT_SIZE 0x3ec | ||
36 | #define TC_PATTERN0 0x3f0 | ||
37 | #define TC_PATTERN1 0x3f4 | ||
38 | #define TC_PATTERN2 0x3f8 | ||
39 | #define TC_PATTERN3 0x3fc | ||
40 | #define TC_FIRM_VER 0x400 | ||
41 | #define TC_VENDOR 0x420 | ||
42 | #define TC_MODULE 0x440 | ||
43 | #define TC_FIRM_TYPE 0x460 | ||
44 | #define TC_FLAGS 0x470 | ||
45 | #define TC_ROM_OBJECTS 0x480 | ||
46 | |||
47 | /* | ||
48 | * Information obtained through the get_tcinfo() PROM call. | ||
49 | */ | ||
50 | struct tcinfo { | ||
51 | s32 revision; /* Hardware revision level. */ | ||
52 | s32 clk_period; /* Clock period in nanoseconds. */ | ||
53 | s32 slot_size; /* Slot size in megabytes. */ | ||
54 | s32 io_timeout; /* I/O timeout in cycles. */ | ||
55 | s32 dma_range; /* DMA address range in megabytes. */ | ||
56 | s32 max_dma_burst; /* Maximum DMA burst length. */ | ||
57 | s32 parity; /* System module supports TC parity. */ | ||
58 | s32 reserved[4]; | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * TURBOchannel bus. | ||
63 | */ | ||
64 | struct tc_bus { | ||
65 | struct list_head devices; /* List of devices on this bus. */ | ||
66 | struct resource resource[2]; /* Address space routed to this bus. */ | ||
67 | |||
68 | struct device dev; | ||
69 | char name[13]; | ||
70 | resource_size_t slot_base; | ||
71 | resource_size_t ext_slot_base; | ||
72 | resource_size_t ext_slot_size; | ||
73 | int num_tcslots; | ||
74 | struct tcinfo info; | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | * TURBOchannel device. | ||
79 | */ | ||
80 | struct tc_dev { | ||
81 | struct list_head node; /* Node in list of all TC devices. */ | ||
82 | struct tc_bus *bus; /* Bus this device is on. */ | ||
83 | struct tc_driver *driver; /* Which driver has allocated this | ||
84 | device. */ | ||
85 | struct device dev; /* Generic device interface. */ | ||
86 | struct resource resource; /* Address space of this device. */ | ||
87 | char vendor[9]; | ||
88 | char name[9]; | ||
89 | char firmware[9]; | ||
90 | int interrupt; | ||
91 | int slot; | ||
92 | }; | ||
93 | |||
94 | #define to_tc_dev(n) container_of(n, struct tc_dev, dev) | ||
95 | |||
96 | struct tc_device_id { | ||
97 | char vendor[9]; | ||
98 | char name[9]; | ||
99 | }; | ||
100 | |||
101 | /* | ||
102 | * TURBOchannel driver. | ||
103 | */ | ||
104 | struct tc_driver { | ||
105 | struct list_head node; | ||
106 | const struct tc_device_id *id_table; | ||
107 | struct device_driver driver; | ||
108 | }; | ||
109 | |||
110 | #define to_tc_driver(drv) container_of(drv, struct tc_driver, driver) | ||
111 | |||
112 | /* | ||
113 | * Return TURBOchannel clock frequency in Hz. | ||
114 | */ | ||
115 | static inline unsigned long tc_get_speed(struct tc_bus *tbus) | ||
116 | { | ||
117 | return 100000 * (10000 / (unsigned long)tbus->info.clk_period); | ||
118 | } | ||
119 | |||
120 | #ifdef CONFIG_TC | ||
121 | |||
122 | extern struct bus_type tc_bus_type; | ||
123 | |||
124 | extern int tc_register_driver(struct tc_driver *tdrv); | ||
125 | extern void tc_unregister_driver(struct tc_driver *tdrv); | ||
126 | |||
127 | #else /* !CONFIG_TC */ | ||
128 | |||
129 | static inline int tc_register_driver(struct tc_driver *tdrv) { return 0; } | ||
130 | static inline void tc_unregister_driver(struct tc_driver *tdrv) { } | ||
131 | |||
132 | #endif /* CONFIG_TC */ | ||
133 | |||
134 | /* | ||
135 | * These have to be provided by the architecture. | ||
136 | */ | ||
137 | extern int tc_preadb(u8 *valp, void __iomem *addr); | ||
138 | extern int tc_bus_get_info(struct tc_bus *tbus); | ||
139 | extern void tc_device_get_irq(struct tc_dev *tdev); | ||
140 | |||
141 | #endif /* _LINUX_TC_H */ | ||