| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: nouveau_engine_device_base.c,v 1.4 2015/03/06 13:44:18 riastradh Exp $ */ | | 1 | /* $NetBSD: nouveau_engine_device_base.c,v 1.5 2015/10/17 21:13:38 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2012 Red Hat Inc. | | 4 | * Copyright 2012 Red Hat Inc. |
5 | * | | 5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), | | 7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation | | 8 | * to deal in the Software without restriction, including without limitation |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the | | 10 | * and/or sell copies of the Software, and to permit persons to whom the |
11 | * Software is furnished to do so, subject to the following conditions: | | 11 | * Software is furnished to do so, subject to the following conditions: |
12 | * | | 12 | * |
13 | * The above copyright notice and this permission notice shall be included in | | 13 | * The above copyright notice and this permission notice shall be included in |
14 | * all copies or substantial portions of the Software. | | 14 | * all copies or substantial portions of the Software. |
15 | * | | 15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | | 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | | 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | * OTHER DEALINGS IN THE SOFTWARE. | | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * | | 23 | * |
24 | * Authors: Ben Skeggs | | 24 | * Authors: Ben Skeggs |
25 | */ | | 25 | */ |
26 | | | 26 | |
27 | #include <sys/cdefs.h> | | 27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.4 2015/03/06 13:44:18 riastradh Exp $"); | | 28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.5 2015/10/17 21:13:38 jmcneill Exp $"); |
29 | | | 29 | |
30 | #include <core/object.h> | | 30 | #include <core/object.h> |
31 | #include <core/device.h> | | 31 | #include <core/device.h> |
32 | #include <core/client.h> | | 32 | #include <core/client.h> |
33 | #include <core/option.h> | | 33 | #include <core/option.h> |
34 | | | 34 | |
35 | #include <core/class.h> | | 35 | #include <core/class.h> |
36 | | | 36 | |
37 | #include "priv.h" | | 37 | #include "priv.h" |
38 | | | 38 | |
39 | #ifdef __NetBSD__ | | 39 | #ifdef __NetBSD__ |
40 | static struct mutex nv_devices_mutex; | | 40 | static struct mutex nv_devices_mutex; |
41 | static struct list_head nv_devices = LIST_HEAD_INIT(nv_devices); | | 41 | static struct list_head nv_devices = LIST_HEAD_INIT(nv_devices); |
| @@ -518,61 +518,63 @@ nouveau_device_dtor(struct nouveau_objec | | | @@ -518,61 +518,63 @@ nouveau_device_dtor(struct nouveau_objec |
518 | | | 518 | |
519 | #ifdef __NetBSD__ | | 519 | #ifdef __NetBSD__ |
520 | bus_space_tag_t | | 520 | bus_space_tag_t |
521 | nv_device_resource_tag(struct nouveau_device *device, unsigned int bar) | | 521 | nv_device_resource_tag(struct nouveau_device *device, unsigned int bar) |
522 | { | | 522 | { |
523 | if (nv_device_is_pci(device)) { | | 523 | if (nv_device_is_pci(device)) { |
524 | const struct pci_attach_args *const pa = &device->pdev->pd_pa; | | 524 | const struct pci_attach_args *const pa = &device->pdev->pd_pa; |
525 | if (PCI_MAPREG_TYPE(pci_mapreg_type(pa->pa_pc, pa->pa_tag, | | 525 | if (PCI_MAPREG_TYPE(pci_mapreg_type(pa->pa_pc, pa->pa_tag, |
526 | PCI_BAR(bar))) == PCI_MAPREG_TYPE_MEM) | | 526 | PCI_BAR(bar))) == PCI_MAPREG_TYPE_MEM) |
527 | return pa->pa_memt; | | 527 | return pa->pa_memt; |
528 | else | | 528 | else |
529 | return pa->pa_iot; | | 529 | return pa->pa_iot; |
530 | } else { | | 530 | } else { |
531 | /* XXX nouveau platform device */ | | 531 | KASSERT(bar < device->platformdev->nresource); |
532 | panic("can't handle non-PCI nouveau devices"); | | 532 | return device->platformdev->resource[bar].tag; |
533 | } | | 533 | } |
534 | } | | 534 | } |
535 | #endif | | 535 | #endif |
536 | | | 536 | |
537 | resource_size_t | | 537 | resource_size_t |
538 | nv_device_resource_start(struct nouveau_device *device, unsigned int bar) | | 538 | nv_device_resource_start(struct nouveau_device *device, unsigned int bar) |
539 | { | | 539 | { |
540 | if (nv_device_is_pci(device)) { | | 540 | if (nv_device_is_pci(device)) { |
541 | return pci_resource_start(device->pdev, bar); | | 541 | return pci_resource_start(device->pdev, bar); |
542 | } else { | | 542 | } else { |
543 | #ifdef __NetBSD__ | | 543 | #ifdef __NetBSD__ |
544 | /* XXX nouveau platform device */ | | 544 | if (bar >= device->platformdev->nresource) |
545 | panic("can't handle non-PCI nouveau devices"); | | 545 | return 0; |
| | | 546 | return device->platformdev->resource[bar].start; |
546 | #else | | 547 | #else |
547 | struct resource *res; | | 548 | struct resource *res; |
548 | res = platform_get_resource(device->platformdev, | | 549 | res = platform_get_resource(device->platformdev, |
549 | IORESOURCE_MEM, bar); | | 550 | IORESOURCE_MEM, bar); |
550 | if (!res) | | 551 | if (!res) |
551 | return 0; | | 552 | return 0; |
552 | return res->start; | | 553 | return res->start; |
553 | #endif | | 554 | #endif |
554 | } | | 555 | } |
555 | } | | 556 | } |
556 | | | 557 | |
557 | resource_size_t | | 558 | resource_size_t |
558 | nv_device_resource_len(struct nouveau_device *device, unsigned int bar) | | 559 | nv_device_resource_len(struct nouveau_device *device, unsigned int bar) |
559 | { | | 560 | { |
560 | if (nv_device_is_pci(device)) { | | 561 | if (nv_device_is_pci(device)) { |
561 | return pci_resource_len(device->pdev, bar); | | 562 | return pci_resource_len(device->pdev, bar); |
562 | } else { | | 563 | } else { |
563 | #ifdef __NetBSD__ | | 564 | #ifdef __NetBSD__ |
564 | /* XXX nouveau platform device */ | | 565 | if (bar >= device->platformdev->nresource) |
565 | panic("can't handle non-PCI nouveau devices"); | | 566 | return 0; |
| | | 567 | return device->platformdev->resource[bar].len; |
566 | #else | | 568 | #else |
567 | struct resource *res; | | 569 | struct resource *res; |
568 | res = platform_get_resource(device->platformdev, | | 570 | res = platform_get_resource(device->platformdev, |
569 | IORESOURCE_MEM, bar); | | 571 | IORESOURCE_MEM, bar); |
570 | if (!res) | | 572 | if (!res) |
571 | return 0; | | 573 | return 0; |
572 | return resource_size(res); | | 574 | return resource_size(res); |
573 | #endif | | 575 | #endif |
574 | } | | 576 | } |
575 | } | | 577 | } |
576 | | | 578 | |
577 | #ifndef __NetBSD__ | | 579 | #ifndef __NetBSD__ |
578 | dma_addr_t | | 580 | dma_addr_t |