| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | A FORE Systems 200E-series driver for ATM on Linux. |
|---|
| 3 | 4 | Christophe Lizzi (lizzi@cnam.fr), October 1999-March 2003. |
|---|
| .. | .. |
|---|
| 7 | 8 | This driver simultaneously supports PCA-200E and SBA-200E adapters |
|---|
| 8 | 9 | on i386, alpha (untested), powerpc, sparc and sparc64 architectures. |
|---|
| 9 | 10 | |
|---|
| 10 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | | - (at your option) any later version. |
|---|
| 14 | | - |
|---|
| 15 | | - This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - GNU General Public License for more details. |
|---|
| 19 | | - |
|---|
| 20 | | - You should have received a copy of the GNU General Public License |
|---|
| 21 | | - along with this program; if not, write to the Free Software |
|---|
| 22 | | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | 11 | */ |
|---|
| 24 | 12 | |
|---|
| 25 | 13 | |
|---|
| .. | .. |
|---|
| 37 | 25 | #include <linux/dma-mapping.h> |
|---|
| 38 | 26 | #include <linux/delay.h> |
|---|
| 39 | 27 | #include <linux/firmware.h> |
|---|
| 28 | +#include <linux/pgtable.h> |
|---|
| 40 | 29 | #include <asm/io.h> |
|---|
| 41 | 30 | #include <asm/string.h> |
|---|
| 42 | 31 | #include <asm/page.h> |
|---|
| .. | .. |
|---|
| 52 | 41 | #include <asm/idprom.h> |
|---|
| 53 | 42 | #include <asm/openprom.h> |
|---|
| 54 | 43 | #include <asm/oplib.h> |
|---|
| 55 | | -#include <asm/pgtable.h> |
|---|
| 56 | 44 | #endif |
|---|
| 57 | 45 | |
|---|
| 58 | 46 | #if defined(CONFIG_ATM_FORE200E_USE_TASKLET) /* defer interrupt work to a tasklet */ |
|---|
| .. | .. |
|---|
| 106 | 94 | |
|---|
| 107 | 95 | |
|---|
| 108 | 96 | static const struct atmdev_ops fore200e_ops; |
|---|
| 109 | | -static const struct fore200e_bus fore200e_bus[]; |
|---|
| 110 | 97 | |
|---|
| 111 | 98 | static LIST_HEAD(fore200e_boards); |
|---|
| 112 | 99 | |
|---|
| .. | .. |
|---|
| 183 | 170 | alignment = 0; |
|---|
| 184 | 171 | |
|---|
| 185 | 172 | chunk->alloc_size = size + alignment; |
|---|
| 186 | | - chunk->align_size = size; |
|---|
| 187 | 173 | chunk->direction = direction; |
|---|
| 188 | 174 | |
|---|
| 189 | | - chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA); |
|---|
| 175 | + chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL); |
|---|
| 190 | 176 | if (chunk->alloc_addr == NULL) |
|---|
| 191 | 177 | return -ENOMEM; |
|---|
| 192 | 178 | |
|---|
| .. | .. |
|---|
| 195 | 181 | |
|---|
| 196 | 182 | chunk->align_addr = chunk->alloc_addr + offset; |
|---|
| 197 | 183 | |
|---|
| 198 | | - chunk->dma_addr = fore200e->bus->dma_map(fore200e, chunk->align_addr, chunk->align_size, direction); |
|---|
| 199 | | - |
|---|
| 184 | + chunk->dma_addr = dma_map_single(fore200e->dev, chunk->align_addr, |
|---|
| 185 | + size, direction); |
|---|
| 186 | + if (dma_mapping_error(fore200e->dev, chunk->dma_addr)) { |
|---|
| 187 | + kfree(chunk->alloc_addr); |
|---|
| 188 | + return -ENOMEM; |
|---|
| 189 | + } |
|---|
| 200 | 190 | return 0; |
|---|
| 201 | 191 | } |
|---|
| 202 | 192 | |
|---|
| .. | .. |
|---|
| 206 | 196 | static void |
|---|
| 207 | 197 | fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk) |
|---|
| 208 | 198 | { |
|---|
| 209 | | - fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction); |
|---|
| 210 | | - |
|---|
| 199 | + dma_unmap_single(fore200e->dev, chunk->dma_addr, chunk->dma_size, |
|---|
| 200 | + chunk->direction); |
|---|
| 211 | 201 | kfree(chunk->alloc_addr); |
|---|
| 212 | 202 | } |
|---|
| 213 | 203 | |
|---|
| 204 | +/* |
|---|
| 205 | + * Allocate a DMA consistent chunk of memory intended to act as a communication |
|---|
| 206 | + * mechanism (to hold descriptors, status, queues, etc.) shared by the driver |
|---|
| 207 | + * and the adapter. |
|---|
| 208 | + */ |
|---|
| 209 | +static int |
|---|
| 210 | +fore200e_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, |
|---|
| 211 | + int size, int nbr, int alignment) |
|---|
| 212 | +{ |
|---|
| 213 | + /* returned chunks are page-aligned */ |
|---|
| 214 | + chunk->alloc_size = size * nbr; |
|---|
| 215 | + chunk->alloc_addr = dma_alloc_coherent(fore200e->dev, chunk->alloc_size, |
|---|
| 216 | + &chunk->dma_addr, GFP_KERNEL); |
|---|
| 217 | + if (!chunk->alloc_addr) |
|---|
| 218 | + return -ENOMEM; |
|---|
| 219 | + chunk->align_addr = chunk->alloc_addr; |
|---|
| 220 | + return 0; |
|---|
| 221 | +} |
|---|
| 222 | + |
|---|
| 223 | +/* |
|---|
| 224 | + * Free a DMA consistent chunk of memory. |
|---|
| 225 | + */ |
|---|
| 226 | +static void |
|---|
| 227 | +fore200e_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk) |
|---|
| 228 | +{ |
|---|
| 229 | + dma_free_coherent(fore200e->dev, chunk->alloc_size, chunk->alloc_addr, |
|---|
| 230 | + chunk->dma_addr); |
|---|
| 231 | +} |
|---|
| 214 | 232 | |
|---|
| 215 | 233 | static void |
|---|
| 216 | 234 | fore200e_spin(int msecs) |
|---|
| .. | .. |
|---|
| 303 | 321 | struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block; |
|---|
| 304 | 322 | |
|---|
| 305 | 323 | if (status->alloc_addr) |
|---|
| 306 | | - fore200e->bus->dma_chunk_free(fore200e, status); |
|---|
| 324 | + fore200e_dma_chunk_free(fore200e, status); |
|---|
| 307 | 325 | |
|---|
| 308 | 326 | if (rbd_block->alloc_addr) |
|---|
| 309 | | - fore200e->bus->dma_chunk_free(fore200e, rbd_block); |
|---|
| 327 | + fore200e_dma_chunk_free(fore200e, rbd_block); |
|---|
| 310 | 328 | } |
|---|
| 311 | 329 | } |
|---|
| 312 | 330 | } |
|---|
| .. | .. |
|---|
| 358 | 376 | case FORE200E_STATE_COMPLETE: |
|---|
| 359 | 377 | kfree(fore200e->stats); |
|---|
| 360 | 378 | |
|---|
| 361 | | - /* fall through */ |
|---|
| 379 | + fallthrough; |
|---|
| 362 | 380 | case FORE200E_STATE_IRQ: |
|---|
| 363 | 381 | free_irq(fore200e->irq, fore200e->atm_dev); |
|---|
| 364 | 382 | |
|---|
| 365 | | - /* fall through */ |
|---|
| 383 | + fallthrough; |
|---|
| 366 | 384 | case FORE200E_STATE_ALLOC_BUF: |
|---|
| 367 | 385 | fore200e_free_rx_buf(fore200e); |
|---|
| 368 | 386 | |
|---|
| 369 | | - /* fall through */ |
|---|
| 387 | + fallthrough; |
|---|
| 370 | 388 | case FORE200E_STATE_INIT_BSQ: |
|---|
| 371 | 389 | fore200e_uninit_bs_queue(fore200e); |
|---|
| 372 | 390 | |
|---|
| 373 | | - /* fall through */ |
|---|
| 391 | + fallthrough; |
|---|
| 374 | 392 | case FORE200E_STATE_INIT_RXQ: |
|---|
| 375 | | - fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.status); |
|---|
| 376 | | - fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.rpd); |
|---|
| 393 | + fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.status); |
|---|
| 394 | + fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.rpd); |
|---|
| 377 | 395 | |
|---|
| 378 | | - /* fall through */ |
|---|
| 396 | + fallthrough; |
|---|
| 379 | 397 | case FORE200E_STATE_INIT_TXQ: |
|---|
| 380 | | - fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.status); |
|---|
| 381 | | - fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.tpd); |
|---|
| 398 | + fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.status); |
|---|
| 399 | + fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.tpd); |
|---|
| 382 | 400 | |
|---|
| 383 | | - /* fall through */ |
|---|
| 401 | + fallthrough; |
|---|
| 384 | 402 | case FORE200E_STATE_INIT_CMDQ: |
|---|
| 385 | | - fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_cmdq.status); |
|---|
| 403 | + fore200e_dma_chunk_free(fore200e, &fore200e->host_cmdq.status); |
|---|
| 386 | 404 | |
|---|
| 387 | | - /* fall through */ |
|---|
| 405 | + fallthrough; |
|---|
| 388 | 406 | case FORE200E_STATE_INITIALIZE: |
|---|
| 389 | 407 | /* nothing to do for that state */ |
|---|
| 390 | 408 | |
|---|
| .. | .. |
|---|
| 397 | 415 | case FORE200E_STATE_MAP: |
|---|
| 398 | 416 | fore200e->bus->unmap(fore200e); |
|---|
| 399 | 417 | |
|---|
| 400 | | - /* fall through */ |
|---|
| 418 | + fallthrough; |
|---|
| 401 | 419 | case FORE200E_STATE_CONFIGURE: |
|---|
| 402 | 420 | /* nothing to do for that state */ |
|---|
| 403 | 421 | |
|---|
| .. | .. |
|---|
| 428 | 446 | the endianess of slave RAM accesses */ |
|---|
| 429 | 447 | writel(cpu_to_le32(val), addr); |
|---|
| 430 | 448 | } |
|---|
| 431 | | - |
|---|
| 432 | | - |
|---|
| 433 | | -static u32 |
|---|
| 434 | | -fore200e_pca_dma_map(struct fore200e* fore200e, void* virt_addr, int size, int direction) |
|---|
| 435 | | -{ |
|---|
| 436 | | - u32 dma_addr = dma_map_single(&((struct pci_dev *) fore200e->bus_dev)->dev, virt_addr, size, direction); |
|---|
| 437 | | - |
|---|
| 438 | | - DPRINTK(3, "PCI DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d, --> dma_addr = 0x%08x\n", |
|---|
| 439 | | - virt_addr, size, direction, dma_addr); |
|---|
| 440 | | - |
|---|
| 441 | | - return dma_addr; |
|---|
| 442 | | -} |
|---|
| 443 | | - |
|---|
| 444 | | - |
|---|
| 445 | | -static void |
|---|
| 446 | | -fore200e_pca_dma_unmap(struct fore200e* fore200e, u32 dma_addr, int size, int direction) |
|---|
| 447 | | -{ |
|---|
| 448 | | - DPRINTK(3, "PCI DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d\n", |
|---|
| 449 | | - dma_addr, size, direction); |
|---|
| 450 | | - |
|---|
| 451 | | - dma_unmap_single(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); |
|---|
| 452 | | -} |
|---|
| 453 | | - |
|---|
| 454 | | - |
|---|
| 455 | | -static void |
|---|
| 456 | | -fore200e_pca_dma_sync_for_cpu(struct fore200e* fore200e, u32 dma_addr, int size, int direction) |
|---|
| 457 | | -{ |
|---|
| 458 | | - DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); |
|---|
| 459 | | - |
|---|
| 460 | | - dma_sync_single_for_cpu(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); |
|---|
| 461 | | -} |
|---|
| 462 | | - |
|---|
| 463 | | -static void |
|---|
| 464 | | -fore200e_pca_dma_sync_for_device(struct fore200e* fore200e, u32 dma_addr, int size, int direction) |
|---|
| 465 | | -{ |
|---|
| 466 | | - DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); |
|---|
| 467 | | - |
|---|
| 468 | | - dma_sync_single_for_device(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); |
|---|
| 469 | | -} |
|---|
| 470 | | - |
|---|
| 471 | | - |
|---|
| 472 | | -/* allocate a DMA consistent chunk of memory intended to act as a communication mechanism |
|---|
| 473 | | - (to hold descriptors, status, queues, etc.) shared by the driver and the adapter */ |
|---|
| 474 | | - |
|---|
| 475 | | -static int |
|---|
| 476 | | -fore200e_pca_dma_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, |
|---|
| 477 | | - int size, int nbr, int alignment) |
|---|
| 478 | | -{ |
|---|
| 479 | | - /* returned chunks are page-aligned */ |
|---|
| 480 | | - chunk->alloc_size = size * nbr; |
|---|
| 481 | | - chunk->alloc_addr = dma_alloc_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev, |
|---|
| 482 | | - chunk->alloc_size, |
|---|
| 483 | | - &chunk->dma_addr, |
|---|
| 484 | | - GFP_KERNEL); |
|---|
| 485 | | - |
|---|
| 486 | | - if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) |
|---|
| 487 | | - return -ENOMEM; |
|---|
| 488 | | - |
|---|
| 489 | | - chunk->align_addr = chunk->alloc_addr; |
|---|
| 490 | | - |
|---|
| 491 | | - return 0; |
|---|
| 492 | | -} |
|---|
| 493 | | - |
|---|
| 494 | | - |
|---|
| 495 | | -/* free a DMA consistent chunk of memory */ |
|---|
| 496 | | - |
|---|
| 497 | | -static void |
|---|
| 498 | | -fore200e_pca_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk) |
|---|
| 499 | | -{ |
|---|
| 500 | | - dma_free_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev, |
|---|
| 501 | | - chunk->alloc_size, |
|---|
| 502 | | - chunk->alloc_addr, |
|---|
| 503 | | - chunk->dma_addr); |
|---|
| 504 | | -} |
|---|
| 505 | | - |
|---|
| 506 | 449 | |
|---|
| 507 | 450 | static int |
|---|
| 508 | 451 | fore200e_pca_irq_check(struct fore200e* fore200e) |
|---|
| .. | .. |
|---|
| 571 | 514 | |
|---|
| 572 | 515 | static int fore200e_pca_configure(struct fore200e *fore200e) |
|---|
| 573 | 516 | { |
|---|
| 574 | | - struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev; |
|---|
| 517 | + struct pci_dev *pci_dev = to_pci_dev(fore200e->dev); |
|---|
| 575 | 518 | u8 master_ctrl, latency; |
|---|
| 576 | 519 | |
|---|
| 577 | 520 | DPRINTK(2, "device %s being configured\n", fore200e->name); |
|---|
| .. | .. |
|---|
| 623 | 566 | opcode.opcode = OPCODE_GET_PROM; |
|---|
| 624 | 567 | opcode.pad = 0; |
|---|
| 625 | 568 | |
|---|
| 626 | | - prom_dma = fore200e->bus->dma_map(fore200e, prom, sizeof(struct prom_data), DMA_FROM_DEVICE); |
|---|
| 569 | + prom_dma = dma_map_single(fore200e->dev, prom, sizeof(struct prom_data), |
|---|
| 570 | + DMA_FROM_DEVICE); |
|---|
| 571 | + if (dma_mapping_error(fore200e->dev, prom_dma)) |
|---|
| 572 | + return -ENOMEM; |
|---|
| 627 | 573 | |
|---|
| 628 | 574 | fore200e->bus->write(prom_dma, &entry->cp_entry->cmd.prom_block.prom_haddr); |
|---|
| 629 | 575 | |
|---|
| .. | .. |
|---|
| 635 | 581 | |
|---|
| 636 | 582 | *entry->status = STATUS_FREE; |
|---|
| 637 | 583 | |
|---|
| 638 | | - fore200e->bus->dma_unmap(fore200e, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE); |
|---|
| 584 | + dma_unmap_single(fore200e->dev, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE); |
|---|
| 639 | 585 | |
|---|
| 640 | 586 | if (ok == 0) { |
|---|
| 641 | 587 | printk(FORE200E "unable to get PROM data from device %s\n", fore200e->name); |
|---|
| .. | .. |
|---|
| 658 | 604 | static int |
|---|
| 659 | 605 | fore200e_pca_proc_read(struct fore200e* fore200e, char *page) |
|---|
| 660 | 606 | { |
|---|
| 661 | | - struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev; |
|---|
| 607 | + struct pci_dev *pci_dev = to_pci_dev(fore200e->dev); |
|---|
| 662 | 608 | |
|---|
| 663 | 609 | return sprintf(page, " PCI bus/slot/function:\t%d/%d/%d\n", |
|---|
| 664 | 610 | pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); |
|---|
| 665 | 611 | } |
|---|
| 666 | 612 | |
|---|
| 613 | +static const struct fore200e_bus fore200e_pci_ops = { |
|---|
| 614 | + .model_name = "PCA-200E", |
|---|
| 615 | + .proc_name = "pca200e", |
|---|
| 616 | + .descr_alignment = 32, |
|---|
| 617 | + .buffer_alignment = 4, |
|---|
| 618 | + .status_alignment = 32, |
|---|
| 619 | + .read = fore200e_pca_read, |
|---|
| 620 | + .write = fore200e_pca_write, |
|---|
| 621 | + .configure = fore200e_pca_configure, |
|---|
| 622 | + .map = fore200e_pca_map, |
|---|
| 623 | + .reset = fore200e_pca_reset, |
|---|
| 624 | + .prom_read = fore200e_pca_prom_read, |
|---|
| 625 | + .unmap = fore200e_pca_unmap, |
|---|
| 626 | + .irq_check = fore200e_pca_irq_check, |
|---|
| 627 | + .irq_ack = fore200e_pca_irq_ack, |
|---|
| 628 | + .proc_read = fore200e_pca_proc_read, |
|---|
| 629 | +}; |
|---|
| 667 | 630 | #endif /* CONFIG_PCI */ |
|---|
| 668 | | - |
|---|
| 669 | 631 | |
|---|
| 670 | 632 | #ifdef CONFIG_SBUS |
|---|
| 671 | 633 | |
|---|
| .. | .. |
|---|
| 677 | 639 | static void fore200e_sba_write(u32 val, volatile u32 __iomem *addr) |
|---|
| 678 | 640 | { |
|---|
| 679 | 641 | sbus_writel(val, addr); |
|---|
| 680 | | -} |
|---|
| 681 | | - |
|---|
| 682 | | -static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int size, int direction) |
|---|
| 683 | | -{ |
|---|
| 684 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 685 | | - u32 dma_addr; |
|---|
| 686 | | - |
|---|
| 687 | | - dma_addr = dma_map_single(&op->dev, virt_addr, size, direction); |
|---|
| 688 | | - |
|---|
| 689 | | - DPRINTK(3, "SBUS DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d --> dma_addr = 0x%08x\n", |
|---|
| 690 | | - virt_addr, size, direction, dma_addr); |
|---|
| 691 | | - |
|---|
| 692 | | - return dma_addr; |
|---|
| 693 | | -} |
|---|
| 694 | | - |
|---|
| 695 | | -static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int size, int direction) |
|---|
| 696 | | -{ |
|---|
| 697 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 698 | | - |
|---|
| 699 | | - DPRINTK(3, "SBUS DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d,\n", |
|---|
| 700 | | - dma_addr, size, direction); |
|---|
| 701 | | - |
|---|
| 702 | | - dma_unmap_single(&op->dev, dma_addr, size, direction); |
|---|
| 703 | | -} |
|---|
| 704 | | - |
|---|
| 705 | | -static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_addr, int size, int direction) |
|---|
| 706 | | -{ |
|---|
| 707 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 708 | | - |
|---|
| 709 | | - DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); |
|---|
| 710 | | - |
|---|
| 711 | | - dma_sync_single_for_cpu(&op->dev, dma_addr, size, direction); |
|---|
| 712 | | -} |
|---|
| 713 | | - |
|---|
| 714 | | -static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_addr, int size, int direction) |
|---|
| 715 | | -{ |
|---|
| 716 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 717 | | - |
|---|
| 718 | | - DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); |
|---|
| 719 | | - |
|---|
| 720 | | - dma_sync_single_for_device(&op->dev, dma_addr, size, direction); |
|---|
| 721 | | -} |
|---|
| 722 | | - |
|---|
| 723 | | -/* Allocate a DVMA consistent chunk of memory intended to act as a communication mechanism |
|---|
| 724 | | - * (to hold descriptors, status, queues, etc.) shared by the driver and the adapter. |
|---|
| 725 | | - */ |
|---|
| 726 | | -static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, |
|---|
| 727 | | - int size, int nbr, int alignment) |
|---|
| 728 | | -{ |
|---|
| 729 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 730 | | - |
|---|
| 731 | | - chunk->alloc_size = chunk->align_size = size * nbr; |
|---|
| 732 | | - |
|---|
| 733 | | - /* returned chunks are page-aligned */ |
|---|
| 734 | | - chunk->alloc_addr = dma_alloc_coherent(&op->dev, chunk->alloc_size, |
|---|
| 735 | | - &chunk->dma_addr, GFP_ATOMIC); |
|---|
| 736 | | - |
|---|
| 737 | | - if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) |
|---|
| 738 | | - return -ENOMEM; |
|---|
| 739 | | - |
|---|
| 740 | | - chunk->align_addr = chunk->alloc_addr; |
|---|
| 741 | | - |
|---|
| 742 | | - return 0; |
|---|
| 743 | | -} |
|---|
| 744 | | - |
|---|
| 745 | | -/* free a DVMA consistent chunk of memory */ |
|---|
| 746 | | -static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk) |
|---|
| 747 | | -{ |
|---|
| 748 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 749 | | - |
|---|
| 750 | | - dma_free_coherent(&op->dev, chunk->alloc_size, |
|---|
| 751 | | - chunk->alloc_addr, chunk->dma_addr); |
|---|
| 752 | 642 | } |
|---|
| 753 | 643 | |
|---|
| 754 | 644 | static void fore200e_sba_irq_enable(struct fore200e *fore200e) |
|---|
| .. | .. |
|---|
| 777 | 667 | |
|---|
| 778 | 668 | static int __init fore200e_sba_map(struct fore200e *fore200e) |
|---|
| 779 | 669 | { |
|---|
| 780 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 670 | + struct platform_device *op = to_platform_device(fore200e->dev); |
|---|
| 781 | 671 | unsigned int bursts; |
|---|
| 782 | 672 | |
|---|
| 783 | 673 | /* gain access to the SBA specific registers */ |
|---|
| .. | .. |
|---|
| 807 | 697 | |
|---|
| 808 | 698 | static void fore200e_sba_unmap(struct fore200e *fore200e) |
|---|
| 809 | 699 | { |
|---|
| 810 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 700 | + struct platform_device *op = to_platform_device(fore200e->dev); |
|---|
| 811 | 701 | |
|---|
| 812 | 702 | of_iounmap(&op->resource[0], fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH); |
|---|
| 813 | 703 | of_iounmap(&op->resource[1], fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH); |
|---|
| .. | .. |
|---|
| 823 | 713 | |
|---|
| 824 | 714 | static int __init fore200e_sba_prom_read(struct fore200e *fore200e, struct prom_data *prom) |
|---|
| 825 | 715 | { |
|---|
| 826 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 716 | + struct platform_device *op = to_platform_device(fore200e->dev); |
|---|
| 827 | 717 | const u8 *prop; |
|---|
| 828 | 718 | int len; |
|---|
| 829 | 719 | |
|---|
| .. | .. |
|---|
| 847 | 737 | |
|---|
| 848 | 738 | static int fore200e_sba_proc_read(struct fore200e *fore200e, char *page) |
|---|
| 849 | 739 | { |
|---|
| 850 | | - struct platform_device *op = fore200e->bus_dev; |
|---|
| 740 | + struct platform_device *op = to_platform_device(fore200e->dev); |
|---|
| 851 | 741 | const struct linux_prom_registers *regs; |
|---|
| 852 | 742 | |
|---|
| 853 | 743 | regs = of_get_property(op->dev.of_node, "reg", NULL); |
|---|
| 854 | 744 | |
|---|
| 855 | | - return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n", |
|---|
| 856 | | - (regs ? regs->which_io : 0), op->dev.of_node->name); |
|---|
| 745 | + return sprintf(page, " SBUS slot/device:\t\t%d/'%pOFn'\n", |
|---|
| 746 | + (regs ? regs->which_io : 0), op->dev.of_node); |
|---|
| 857 | 747 | } |
|---|
| 858 | | -#endif /* CONFIG_SBUS */ |
|---|
| 859 | 748 | |
|---|
| 749 | +static const struct fore200e_bus fore200e_sbus_ops = { |
|---|
| 750 | + .model_name = "SBA-200E", |
|---|
| 751 | + .proc_name = "sba200e", |
|---|
| 752 | + .descr_alignment = 32, |
|---|
| 753 | + .buffer_alignment = 64, |
|---|
| 754 | + .status_alignment = 32, |
|---|
| 755 | + .read = fore200e_sba_read, |
|---|
| 756 | + .write = fore200e_sba_write, |
|---|
| 757 | + .configure = fore200e_sba_configure, |
|---|
| 758 | + .map = fore200e_sba_map, |
|---|
| 759 | + .reset = fore200e_sba_reset, |
|---|
| 760 | + .prom_read = fore200e_sba_prom_read, |
|---|
| 761 | + .unmap = fore200e_sba_unmap, |
|---|
| 762 | + .irq_enable = fore200e_sba_irq_enable, |
|---|
| 763 | + .irq_check = fore200e_sba_irq_check, |
|---|
| 764 | + .irq_ack = fore200e_sba_irq_ack, |
|---|
| 765 | + .proc_read = fore200e_sba_proc_read, |
|---|
| 766 | +}; |
|---|
| 767 | +#endif /* CONFIG_SBUS */ |
|---|
| 860 | 768 | |
|---|
| 861 | 769 | static void |
|---|
| 862 | 770 | fore200e_tx_irq(struct fore200e* fore200e) |
|---|
| .. | .. |
|---|
| 884 | 792 | kfree(entry->data); |
|---|
| 885 | 793 | |
|---|
| 886 | 794 | /* remove DMA mapping */ |
|---|
| 887 | | - fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, |
|---|
| 795 | + dma_unmap_single(fore200e->dev, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, |
|---|
| 888 | 796 | DMA_TO_DEVICE); |
|---|
| 889 | 797 | |
|---|
| 890 | 798 | vc_map = entry->vc_map; |
|---|
| .. | .. |
|---|
| 1105 | 1013 | buffer = FORE200E_HDL2BUF(rpd->rsd[ i ].handle); |
|---|
| 1106 | 1014 | |
|---|
| 1107 | 1015 | /* Make device DMA transfer visible to CPU. */ |
|---|
| 1108 | | - fore200e->bus->dma_sync_for_cpu(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE); |
|---|
| 1016 | + dma_sync_single_for_cpu(fore200e->dev, buffer->data.dma_addr, |
|---|
| 1017 | + rpd->rsd[i].length, DMA_FROM_DEVICE); |
|---|
| 1109 | 1018 | |
|---|
| 1110 | 1019 | skb_put_data(skb, buffer->data.align_addr, rpd->rsd[i].length); |
|---|
| 1111 | 1020 | |
|---|
| 1112 | 1021 | /* Now let the device get at it again. */ |
|---|
| 1113 | | - fore200e->bus->dma_sync_for_device(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE); |
|---|
| 1022 | + dma_sync_single_for_device(fore200e->dev, buffer->data.dma_addr, |
|---|
| 1023 | + rpd->rsd[i].length, DMA_FROM_DEVICE); |
|---|
| 1114 | 1024 | } |
|---|
| 1115 | 1025 | |
|---|
| 1116 | 1026 | DPRINTK(3, "rx skb: len = %d, truesize = %d\n", skb->len, skb->truesize); |
|---|
| .. | .. |
|---|
| 1622 | 1532 | } |
|---|
| 1623 | 1533 | |
|---|
| 1624 | 1534 | if (tx_copy) { |
|---|
| 1625 | | - data = kmalloc(tx_len, GFP_ATOMIC | GFP_DMA); |
|---|
| 1535 | + data = kmalloc(tx_len, GFP_ATOMIC); |
|---|
| 1626 | 1536 | if (data == NULL) { |
|---|
| 1627 | 1537 | if (vcc->pop) { |
|---|
| 1628 | 1538 | vcc->pop(vcc, skb); |
|---|
| .. | .. |
|---|
| 1690 | 1600 | entry->data = tx_copy ? data : NULL; |
|---|
| 1691 | 1601 | |
|---|
| 1692 | 1602 | tpd = entry->tpd; |
|---|
| 1693 | | - tpd->tsd[ 0 ].buffer = fore200e->bus->dma_map(fore200e, data, tx_len, DMA_TO_DEVICE); |
|---|
| 1603 | + tpd->tsd[ 0 ].buffer = dma_map_single(fore200e->dev, data, tx_len, |
|---|
| 1604 | + DMA_TO_DEVICE); |
|---|
| 1605 | + if (dma_mapping_error(fore200e->dev, tpd->tsd[0].buffer)) { |
|---|
| 1606 | + if (tx_copy) |
|---|
| 1607 | + kfree(data); |
|---|
| 1608 | + spin_unlock_irqrestore(&fore200e->q_lock, flags); |
|---|
| 1609 | + return -ENOMEM; |
|---|
| 1610 | + } |
|---|
| 1694 | 1611 | tpd->tsd[ 0 ].length = tx_len; |
|---|
| 1695 | 1612 | |
|---|
| 1696 | 1613 | FORE200E_NEXT_ENTRY(txq->head, QUEUE_SIZE_TX); |
|---|
| .. | .. |
|---|
| 1758 | 1675 | u32 stats_dma_addr; |
|---|
| 1759 | 1676 | |
|---|
| 1760 | 1677 | if (fore200e->stats == NULL) { |
|---|
| 1761 | | - fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA); |
|---|
| 1678 | + fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL); |
|---|
| 1762 | 1679 | if (fore200e->stats == NULL) |
|---|
| 1763 | 1680 | return -ENOMEM; |
|---|
| 1764 | 1681 | } |
|---|
| 1765 | 1682 | |
|---|
| 1766 | | - stats_dma_addr = fore200e->bus->dma_map(fore200e, fore200e->stats, |
|---|
| 1767 | | - sizeof(struct stats), DMA_FROM_DEVICE); |
|---|
| 1683 | + stats_dma_addr = dma_map_single(fore200e->dev, fore200e->stats, |
|---|
| 1684 | + sizeof(struct stats), DMA_FROM_DEVICE); |
|---|
| 1685 | + if (dma_mapping_error(fore200e->dev, stats_dma_addr)) |
|---|
| 1686 | + return -ENOMEM; |
|---|
| 1768 | 1687 | |
|---|
| 1769 | 1688 | FORE200E_NEXT_ENTRY(cmdq->head, QUEUE_SIZE_CMD); |
|---|
| 1770 | 1689 | |
|---|
| .. | .. |
|---|
| 1781 | 1700 | |
|---|
| 1782 | 1701 | *entry->status = STATUS_FREE; |
|---|
| 1783 | 1702 | |
|---|
| 1784 | | - fore200e->bus->dma_unmap(fore200e, stats_dma_addr, sizeof(struct stats), DMA_FROM_DEVICE); |
|---|
| 1703 | + dma_unmap_single(fore200e->dev, stats_dma_addr, sizeof(struct stats), DMA_FROM_DEVICE); |
|---|
| 1785 | 1704 | |
|---|
| 1786 | 1705 | if (ok == 0) { |
|---|
| 1787 | 1706 | printk(FORE200E "unable to get statistics from device %s\n", fore200e->name); |
|---|
| .. | .. |
|---|
| 1790 | 1709 | |
|---|
| 1791 | 1710 | return 0; |
|---|
| 1792 | 1711 | } |
|---|
| 1793 | | - |
|---|
| 1794 | | - |
|---|
| 1795 | | -static int |
|---|
| 1796 | | -fore200e_getsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, int optlen) |
|---|
| 1797 | | -{ |
|---|
| 1798 | | - /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */ |
|---|
| 1799 | | - |
|---|
| 1800 | | - DPRINTK(2, "getsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n", |
|---|
| 1801 | | - vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen); |
|---|
| 1802 | | - |
|---|
| 1803 | | - return -EINVAL; |
|---|
| 1804 | | -} |
|---|
| 1805 | | - |
|---|
| 1806 | | - |
|---|
| 1807 | | -static int |
|---|
| 1808 | | -fore200e_setsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, unsigned int optlen) |
|---|
| 1809 | | -{ |
|---|
| 1810 | | - /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */ |
|---|
| 1811 | | - |
|---|
| 1812 | | - DPRINTK(2, "setsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n", |
|---|
| 1813 | | - vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen); |
|---|
| 1814 | | - |
|---|
| 1815 | | - return -EINVAL; |
|---|
| 1816 | | -} |
|---|
| 1817 | | - |
|---|
| 1818 | 1712 | |
|---|
| 1819 | 1713 | #if 0 /* currently unused */ |
|---|
| 1820 | 1714 | static int |
|---|
| .. | .. |
|---|
| 2060 | 1954 | |
|---|
| 2061 | 1955 | static int fore200e_get_esi(struct fore200e *fore200e) |
|---|
| 2062 | 1956 | { |
|---|
| 2063 | | - struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA); |
|---|
| 1957 | + struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL); |
|---|
| 2064 | 1958 | int ok, i; |
|---|
| 2065 | 1959 | |
|---|
| 2066 | 1960 | if (!prom) |
|---|
| .. | .. |
|---|
| 2167 | 2061 | bsq = &fore200e->host_bsq[ scheme ][ magn ]; |
|---|
| 2168 | 2062 | |
|---|
| 2169 | 2063 | /* allocate and align the array of status words */ |
|---|
| 2170 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2064 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2171 | 2065 | &bsq->status, |
|---|
| 2172 | 2066 | sizeof(enum status), |
|---|
| 2173 | 2067 | QUEUE_SIZE_BS, |
|---|
| .. | .. |
|---|
| 2176 | 2070 | } |
|---|
| 2177 | 2071 | |
|---|
| 2178 | 2072 | /* allocate and align the array of receive buffer descriptors */ |
|---|
| 2179 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2073 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2180 | 2074 | &bsq->rbd_block, |
|---|
| 2181 | 2075 | sizeof(struct rbd_block), |
|---|
| 2182 | 2076 | QUEUE_SIZE_BS, |
|---|
| 2183 | 2077 | fore200e->bus->descr_alignment) < 0) { |
|---|
| 2184 | 2078 | |
|---|
| 2185 | | - fore200e->bus->dma_chunk_free(fore200e, &bsq->status); |
|---|
| 2079 | + fore200e_dma_chunk_free(fore200e, &bsq->status); |
|---|
| 2186 | 2080 | return -ENOMEM; |
|---|
| 2187 | 2081 | } |
|---|
| 2188 | 2082 | |
|---|
| .. | .. |
|---|
| 2223 | 2117 | DPRINTK(2, "receive queue is being initialized\n"); |
|---|
| 2224 | 2118 | |
|---|
| 2225 | 2119 | /* allocate and align the array of status words */ |
|---|
| 2226 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2120 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2227 | 2121 | &rxq->status, |
|---|
| 2228 | 2122 | sizeof(enum status), |
|---|
| 2229 | 2123 | QUEUE_SIZE_RX, |
|---|
| .. | .. |
|---|
| 2232 | 2126 | } |
|---|
| 2233 | 2127 | |
|---|
| 2234 | 2128 | /* allocate and align the array of receive PDU descriptors */ |
|---|
| 2235 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2129 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2236 | 2130 | &rxq->rpd, |
|---|
| 2237 | 2131 | sizeof(struct rpd), |
|---|
| 2238 | 2132 | QUEUE_SIZE_RX, |
|---|
| 2239 | 2133 | fore200e->bus->descr_alignment) < 0) { |
|---|
| 2240 | 2134 | |
|---|
| 2241 | | - fore200e->bus->dma_chunk_free(fore200e, &rxq->status); |
|---|
| 2135 | + fore200e_dma_chunk_free(fore200e, &rxq->status); |
|---|
| 2242 | 2136 | return -ENOMEM; |
|---|
| 2243 | 2137 | } |
|---|
| 2244 | 2138 | |
|---|
| .. | .. |
|---|
| 2282 | 2176 | DPRINTK(2, "transmit queue is being initialized\n"); |
|---|
| 2283 | 2177 | |
|---|
| 2284 | 2178 | /* allocate and align the array of status words */ |
|---|
| 2285 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2179 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2286 | 2180 | &txq->status, |
|---|
| 2287 | 2181 | sizeof(enum status), |
|---|
| 2288 | 2182 | QUEUE_SIZE_TX, |
|---|
| .. | .. |
|---|
| 2291 | 2185 | } |
|---|
| 2292 | 2186 | |
|---|
| 2293 | 2187 | /* allocate and align the array of transmit PDU descriptors */ |
|---|
| 2294 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2188 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2295 | 2189 | &txq->tpd, |
|---|
| 2296 | 2190 | sizeof(struct tpd), |
|---|
| 2297 | 2191 | QUEUE_SIZE_TX, |
|---|
| 2298 | 2192 | fore200e->bus->descr_alignment) < 0) { |
|---|
| 2299 | 2193 | |
|---|
| 2300 | | - fore200e->bus->dma_chunk_free(fore200e, &txq->status); |
|---|
| 2194 | + fore200e_dma_chunk_free(fore200e, &txq->status); |
|---|
| 2301 | 2195 | return -ENOMEM; |
|---|
| 2302 | 2196 | } |
|---|
| 2303 | 2197 | |
|---|
| .. | .. |
|---|
| 2344 | 2238 | DPRINTK(2, "command queue is being initialized\n"); |
|---|
| 2345 | 2239 | |
|---|
| 2346 | 2240 | /* allocate and align the array of status words */ |
|---|
| 2347 | | - if (fore200e->bus->dma_chunk_alloc(fore200e, |
|---|
| 2241 | + if (fore200e_dma_chunk_alloc(fore200e, |
|---|
| 2348 | 2242 | &cmdq->status, |
|---|
| 2349 | 2243 | sizeof(enum status), |
|---|
| 2350 | 2244 | QUEUE_SIZE_CMD, |
|---|
| .. | .. |
|---|
| 2498 | 2392 | static int fore200e_load_and_start_fw(struct fore200e *fore200e) |
|---|
| 2499 | 2393 | { |
|---|
| 2500 | 2394 | const struct firmware *firmware; |
|---|
| 2501 | | - struct device *device; |
|---|
| 2502 | 2395 | const struct fw_header *fw_header; |
|---|
| 2503 | 2396 | const __le32 *fw_data; |
|---|
| 2504 | 2397 | u32 fw_size; |
|---|
| 2505 | 2398 | u32 __iomem *load_addr; |
|---|
| 2506 | 2399 | char buf[48]; |
|---|
| 2507 | | - int err = -ENODEV; |
|---|
| 2508 | | - |
|---|
| 2509 | | - if (strcmp(fore200e->bus->model_name, "PCA-200E") == 0) |
|---|
| 2510 | | - device = &((struct pci_dev *) fore200e->bus_dev)->dev; |
|---|
| 2511 | | -#ifdef CONFIG_SBUS |
|---|
| 2512 | | - else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0) |
|---|
| 2513 | | - device = &((struct platform_device *) fore200e->bus_dev)->dev; |
|---|
| 2514 | | -#endif |
|---|
| 2515 | | - else |
|---|
| 2516 | | - return err; |
|---|
| 2400 | + int err; |
|---|
| 2517 | 2401 | |
|---|
| 2518 | 2402 | sprintf(buf, "%s%s", fore200e->bus->proc_name, FW_EXT); |
|---|
| 2519 | | - if ((err = request_firmware(&firmware, buf, device)) < 0) { |
|---|
| 2403 | + if ((err = request_firmware(&firmware, buf, fore200e->dev)) < 0) { |
|---|
| 2520 | 2404 | printk(FORE200E "problem loading firmware image %s\n", fore200e->bus->model_name); |
|---|
| 2521 | 2405 | return err; |
|---|
| 2522 | 2406 | } |
|---|
| .. | .. |
|---|
| 2642 | 2526 | static int fore200e_sba_probe(struct platform_device *op) |
|---|
| 2643 | 2527 | { |
|---|
| 2644 | 2528 | const struct of_device_id *match; |
|---|
| 2645 | | - const struct fore200e_bus *bus; |
|---|
| 2646 | 2529 | struct fore200e *fore200e; |
|---|
| 2647 | 2530 | static int index = 0; |
|---|
| 2648 | 2531 | int err; |
|---|
| .. | .. |
|---|
| 2650 | 2533 | match = of_match_device(fore200e_sba_match, &op->dev); |
|---|
| 2651 | 2534 | if (!match) |
|---|
| 2652 | 2535 | return -EINVAL; |
|---|
| 2653 | | - bus = match->data; |
|---|
| 2654 | 2536 | |
|---|
| 2655 | 2537 | fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); |
|---|
| 2656 | 2538 | if (!fore200e) |
|---|
| 2657 | 2539 | return -ENOMEM; |
|---|
| 2658 | 2540 | |
|---|
| 2659 | | - fore200e->bus = bus; |
|---|
| 2660 | | - fore200e->bus_dev = op; |
|---|
| 2541 | + fore200e->bus = &fore200e_sbus_ops; |
|---|
| 2542 | + fore200e->dev = &op->dev; |
|---|
| 2661 | 2543 | fore200e->irq = op->archdata.irqs[0]; |
|---|
| 2662 | 2544 | fore200e->phys_base = op->resource[0].start; |
|---|
| 2663 | 2545 | |
|---|
| 2664 | | - sprintf(fore200e->name, "%s-%d", bus->model_name, index); |
|---|
| 2546 | + sprintf(fore200e->name, "SBA-200E-%d", index); |
|---|
| 2665 | 2547 | |
|---|
| 2666 | 2548 | err = fore200e_init(fore200e, &op->dev); |
|---|
| 2667 | 2549 | if (err < 0) { |
|---|
| .. | .. |
|---|
| 2689 | 2571 | static const struct of_device_id fore200e_sba_match[] = { |
|---|
| 2690 | 2572 | { |
|---|
| 2691 | 2573 | .name = SBA200E_PROM_NAME, |
|---|
| 2692 | | - .data = (void *) &fore200e_bus[1], |
|---|
| 2693 | 2574 | }, |
|---|
| 2694 | 2575 | {}, |
|---|
| 2695 | 2576 | }; |
|---|
| .. | .. |
|---|
| 2709 | 2590 | static int fore200e_pca_detect(struct pci_dev *pci_dev, |
|---|
| 2710 | 2591 | const struct pci_device_id *pci_ent) |
|---|
| 2711 | 2592 | { |
|---|
| 2712 | | - const struct fore200e_bus* bus = (struct fore200e_bus*) pci_ent->driver_data; |
|---|
| 2713 | 2593 | struct fore200e* fore200e; |
|---|
| 2714 | 2594 | int err = 0; |
|---|
| 2715 | 2595 | static int index = 0; |
|---|
| .. | .. |
|---|
| 2730 | 2610 | goto out_disable; |
|---|
| 2731 | 2611 | } |
|---|
| 2732 | 2612 | |
|---|
| 2733 | | - fore200e->bus = bus; |
|---|
| 2734 | | - fore200e->bus_dev = pci_dev; |
|---|
| 2613 | + fore200e->bus = &fore200e_pci_ops; |
|---|
| 2614 | + fore200e->dev = &pci_dev->dev; |
|---|
| 2735 | 2615 | fore200e->irq = pci_dev->irq; |
|---|
| 2736 | 2616 | fore200e->phys_base = pci_resource_start(pci_dev, 0); |
|---|
| 2737 | 2617 | |
|---|
| 2738 | | - sprintf(fore200e->name, "%s-%d", bus->model_name, index - 1); |
|---|
| 2618 | + sprintf(fore200e->name, "PCA-200E-%d", index - 1); |
|---|
| 2739 | 2619 | |
|---|
| 2740 | 2620 | pci_set_master(pci_dev); |
|---|
| 2741 | 2621 | |
|---|
| 2742 | | - printk(FORE200E "device %s found at 0x%lx, IRQ %s\n", |
|---|
| 2743 | | - fore200e->bus->model_name, |
|---|
| 2622 | + printk(FORE200E "device PCA-200E found at 0x%lx, IRQ %s\n", |
|---|
| 2744 | 2623 | fore200e->phys_base, fore200e_irq_itoa(fore200e->irq)); |
|---|
| 2745 | 2624 | |
|---|
| 2746 | | - sprintf(fore200e->name, "%s-%d", bus->model_name, index); |
|---|
| 2625 | + sprintf(fore200e->name, "PCA-200E-%d", index); |
|---|
| 2747 | 2626 | |
|---|
| 2748 | 2627 | err = fore200e_init(fore200e, &pci_dev->dev); |
|---|
| 2749 | 2628 | if (err < 0) { |
|---|
| .. | .. |
|---|
| 2778 | 2657 | |
|---|
| 2779 | 2658 | |
|---|
| 2780 | 2659 | static const struct pci_device_id fore200e_pca_tbl[] = { |
|---|
| 2781 | | - { PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_PCA200E, PCI_ANY_ID, PCI_ANY_ID, |
|---|
| 2782 | | - 0, 0, (unsigned long) &fore200e_bus[0] }, |
|---|
| 2660 | + { PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_PCA200E, PCI_ANY_ID, PCI_ANY_ID }, |
|---|
| 2783 | 2661 | { 0, } |
|---|
| 2784 | 2662 | }; |
|---|
| 2785 | 2663 | |
|---|
| .. | .. |
|---|
| 3119 | 2997 | module_exit(fore200e_module_cleanup); |
|---|
| 3120 | 2998 | |
|---|
| 3121 | 2999 | |
|---|
| 3122 | | -static const struct atmdev_ops fore200e_ops = |
|---|
| 3123 | | -{ |
|---|
| 3000 | +static const struct atmdev_ops fore200e_ops = { |
|---|
| 3124 | 3001 | .open = fore200e_open, |
|---|
| 3125 | 3002 | .close = fore200e_close, |
|---|
| 3126 | 3003 | .ioctl = fore200e_ioctl, |
|---|
| 3127 | | - .getsockopt = fore200e_getsockopt, |
|---|
| 3128 | | - .setsockopt = fore200e_setsockopt, |
|---|
| 3129 | 3004 | .send = fore200e_send, |
|---|
| 3130 | 3005 | .change_qos = fore200e_change_qos, |
|---|
| 3131 | 3006 | .proc_read = fore200e_proc_read, |
|---|
| 3132 | 3007 | .owner = THIS_MODULE |
|---|
| 3133 | | -}; |
|---|
| 3134 | | - |
|---|
| 3135 | | - |
|---|
| 3136 | | -static const struct fore200e_bus fore200e_bus[] = { |
|---|
| 3137 | | -#ifdef CONFIG_PCI |
|---|
| 3138 | | - { "PCA-200E", "pca200e", 32, 4, 32, |
|---|
| 3139 | | - fore200e_pca_read, |
|---|
| 3140 | | - fore200e_pca_write, |
|---|
| 3141 | | - fore200e_pca_dma_map, |
|---|
| 3142 | | - fore200e_pca_dma_unmap, |
|---|
| 3143 | | - fore200e_pca_dma_sync_for_cpu, |
|---|
| 3144 | | - fore200e_pca_dma_sync_for_device, |
|---|
| 3145 | | - fore200e_pca_dma_chunk_alloc, |
|---|
| 3146 | | - fore200e_pca_dma_chunk_free, |
|---|
| 3147 | | - fore200e_pca_configure, |
|---|
| 3148 | | - fore200e_pca_map, |
|---|
| 3149 | | - fore200e_pca_reset, |
|---|
| 3150 | | - fore200e_pca_prom_read, |
|---|
| 3151 | | - fore200e_pca_unmap, |
|---|
| 3152 | | - NULL, |
|---|
| 3153 | | - fore200e_pca_irq_check, |
|---|
| 3154 | | - fore200e_pca_irq_ack, |
|---|
| 3155 | | - fore200e_pca_proc_read, |
|---|
| 3156 | | - }, |
|---|
| 3157 | | -#endif |
|---|
| 3158 | | -#ifdef CONFIG_SBUS |
|---|
| 3159 | | - { "SBA-200E", "sba200e", 32, 64, 32, |
|---|
| 3160 | | - fore200e_sba_read, |
|---|
| 3161 | | - fore200e_sba_write, |
|---|
| 3162 | | - fore200e_sba_dma_map, |
|---|
| 3163 | | - fore200e_sba_dma_unmap, |
|---|
| 3164 | | - fore200e_sba_dma_sync_for_cpu, |
|---|
| 3165 | | - fore200e_sba_dma_sync_for_device, |
|---|
| 3166 | | - fore200e_sba_dma_chunk_alloc, |
|---|
| 3167 | | - fore200e_sba_dma_chunk_free, |
|---|
| 3168 | | - fore200e_sba_configure, |
|---|
| 3169 | | - fore200e_sba_map, |
|---|
| 3170 | | - fore200e_sba_reset, |
|---|
| 3171 | | - fore200e_sba_prom_read, |
|---|
| 3172 | | - fore200e_sba_unmap, |
|---|
| 3173 | | - fore200e_sba_irq_enable, |
|---|
| 3174 | | - fore200e_sba_irq_check, |
|---|
| 3175 | | - fore200e_sba_irq_ack, |
|---|
| 3176 | | - fore200e_sba_proc_read, |
|---|
| 3177 | | - }, |
|---|
| 3178 | | -#endif |
|---|
| 3179 | | - {} |
|---|
| 3180 | 3008 | }; |
|---|
| 3181 | 3009 | |
|---|
| 3182 | 3010 | MODULE_LICENSE("GPL"); |
|---|