2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <core/object.h>
26 #include <core/subdev.h>
27 #include <core/device.h>
28 #include <core/option.h>
31 nouveau_subdev_reset(struct nouveau_object *subdev)
33 nv_trace(subdev, "resetting...\n");
34 nv_ofuncs(subdev)->fini(subdev, false);
35 nv_debug(subdev, "reset\n");
39 nouveau_subdev_init(struct nouveau_subdev *subdev)
41 int ret = nouveau_object_init(&subdev->base);
45 nouveau_subdev_reset(&subdev->base);
50 _nouveau_subdev_init(struct nouveau_object *object)
52 return nouveau_subdev_init(nv_subdev(object));
56 nouveau_subdev_fini(struct nouveau_subdev *subdev, bool suspend)
59 nv_mask(subdev, 0x000200, subdev->unit, 0x00000000);
60 nv_mask(subdev, 0x000200, subdev->unit, subdev->unit);
63 return nouveau_object_fini(&subdev->base, suspend);
67 _nouveau_subdev_fini(struct nouveau_object *object, bool suspend)
69 return nouveau_subdev_fini(nv_subdev(object), suspend);
73 nouveau_subdev_destroy(struct nouveau_subdev *subdev)
75 int subidx = nv_hclass(subdev) & 0xff;
76 nv_device(subdev)->subdev[subidx] = NULL;
77 nouveau_object_destroy(&subdev->base);
81 _nouveau_subdev_dtor(struct nouveau_object *object)
83 nouveau_subdev_destroy(nv_subdev(object));
87 nouveau_subdev_create_(struct nouveau_object *parent,
88 struct nouveau_object *engine,
89 struct nouveau_oclass *oclass, u32 pclass,
90 const char *subname, const char *sysname,
91 int size, void **pobject)
93 struct nouveau_subdev *subdev;
96 ret = nouveau_object_create_(parent, engine, oclass, pclass |
97 NV_SUBDEV_CLASS, size, pobject);
102 __mutex_init(&subdev->mutex, subname, &oclass->lock_class_key);
103 subdev->name = subname;
106 struct nouveau_device *device = nv_device(parent);
107 int subidx = nv_hclass(subdev) & 0xff;
109 subdev->debug = nouveau_dbgopt(device->dbgopt, subname);
110 subdev->mmio = nv_subdev(device)->mmio;
111 device->subdev[subidx] = *pobject;