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.
24 #include <core/subdev.h>
25 #include <core/device.h>
26 #include <core/option.h>
29 nvkm_subdev(void *obj
, int idx
)
31 struct nvkm_object
*object
= nv_object(obj
);
32 while (object
&& !nv_iclass(object
, NV_SUBDEV_CLASS
))
33 object
= object
->parent
;
34 if (object
== NULL
|| !object
->parent
|| nv_subidx(nv_subdev(object
)) != idx
)
35 object
= nv_device(obj
)->subdev
[idx
];
36 return object
? nv_subdev(object
) : NULL
;
40 nvkm_subdev_reset(struct nvkm_object
*obj
)
42 struct nvkm_subdev
*subdev
= container_of(obj
, typeof(*subdev
), object
);
43 nvkm_trace(subdev
, "resetting...\n");
44 nv_ofuncs(subdev
)->fini(&subdev
->object
, false);
45 nvkm_trace(subdev
, "reset\n");
49 nvkm_subdev_init(struct nvkm_subdev
*subdev
)
51 int ret
= nvkm_object_init(&subdev
->object
);
55 nvkm_subdev_reset(&subdev
->object
);
60 _nvkm_subdev_init(struct nvkm_object
*object
)
62 return nvkm_subdev_init(nv_subdev(object
));
66 nvkm_subdev_fini(struct nvkm_subdev
*subdev
, bool suspend
)
68 struct nvkm_device
*device
= subdev
->device
;
71 nvkm_mask(device
, 0x000200, subdev
->unit
, 0x00000000);
72 nvkm_mask(device
, 0x000200, subdev
->unit
, subdev
->unit
);
75 return nvkm_object_fini(&subdev
->object
, suspend
);
79 _nvkm_subdev_fini(struct nvkm_object
*object
, bool suspend
)
81 return nvkm_subdev_fini(nv_subdev(object
), suspend
);
85 nvkm_subdev_destroy(struct nvkm_subdev
*subdev
)
87 int subidx
= nv_hclass(subdev
) & 0xff;
88 nv_device(subdev
)->subdev
[subidx
] = NULL
;
89 nvkm_object_destroy(&subdev
->object
);
93 _nvkm_subdev_dtor(struct nvkm_object
*object
)
95 nvkm_subdev_destroy(nv_subdev(object
));
99 nvkm_subdev_create_(struct nvkm_object
*parent
, struct nvkm_object
*engine
,
100 struct nvkm_oclass
*oclass
, u32 pclass
,
101 const char *subname
, const char *sysname
,
102 int size
, void **pobject
)
104 struct nvkm_subdev
*subdev
;
107 ret
= nvkm_object_create_(parent
, engine
, oclass
, pclass
|
108 NV_SUBDEV_CLASS
, size
, pobject
);
113 __mutex_init(&subdev
->mutex
, subname
, &oclass
->lock_class_key
);
114 subdev
->name
= subname
;
115 subdev
->sname
= sysname
;
118 struct nvkm_device
*device
= nv_device(parent
);
119 subdev
->debug
= nvkm_dbgopt(device
->dbgopt
, subname
);
120 subdev
->device
= device
;
122 subdev
->device
= nv_device(subdev
);
This page took 0.034777 seconds and 5 git commands to generate.