Sat Oct 17 21:13:38 2015 UTC ()
support for non-PCI devices


(jmcneill)
diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c
diff -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/platform_device.h

cvs diff -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/Attic/nouveau_engine_device_base.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/Attic/nouveau_engine_device_base.c 2015/03/06 13:44:18 1.4
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/Attic/nouveau_engine_device_base.c 2015/10/17 21:13:38 1.5
@@ -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__
40static struct mutex nv_devices_mutex; 40static struct mutex nv_devices_mutex;
41static struct list_head nv_devices = LIST_HEAD_INIT(nv_devices); 41static 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__
520bus_space_tag_t 520bus_space_tag_t
521nv_device_resource_tag(struct nouveau_device *device, unsigned int bar) 521nv_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
537resource_size_t 537resource_size_t
538nv_device_resource_start(struct nouveau_device *device, unsigned int bar) 538nv_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
557resource_size_t 558resource_size_t
558nv_device_resource_len(struct nouveau_device *device, unsigned int bar) 559nv_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__
578dma_addr_t 580dma_addr_t

cvs diff -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/platform_device.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/platform_device.h 2014/08/06 15:01:33 1.4
+++ src/sys/external/bsd/drm2/include/linux/platform_device.h 2015/10/17 21:13:38 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: platform_device.h,v 1.4 2014/08/06 15:01:33 riastradh Exp $ */ 1/* $NetBSD: platform_device.h,v 1.5 2015/10/17 21:13:38 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -23,20 +23,30 @@ @@ -23,20 +23,30 @@
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _LINUX_PLATFORM_DEVICE_H_ 32#ifndef _LINUX_PLATFORM_DEVICE_H_
33#define _LINUX_PLATFORM_DEVICE_H_ 33#define _LINUX_PLATFORM_DEVICE_H_
34 34
35#include <sys/device.h> 35#include <sys/device.h>
 36#include <sys/bus.h>
 37
 38#define NUM_PLATFORM_RESOURCE 2
36 39
37struct platform_device { 40struct platform_device {
38 struct device dev; /* XXX DON'T BELIEVE ME */ 41 struct device dev; /* XXX DON'T BELIEVE ME */
39 uint64_t id; 42 uint64_t id;
 43
 44 unsigned int nresource;
 45 struct {
 46 bus_space_tag_t tag;
 47 bus_addr_t start;
 48 bus_size_t len;
 49 } resource[NUM_PLATFORM_RESOURCE];
40}; 50};
41 51
42#endif /* _LINUX_PLATFORM_DEVICE_H_ */ 52#endif /* _LINUX_PLATFORM_DEVICE_H_ */