1#ifndef __NOUVEAU_PWR_H__
2#define __NOUVEAU_PWR_H__
3
4#include <core/subdev.h>
5#include <core/device.h>
6#include <linux/workqueue.h> /* XXX */
7#include <drm/drmP.h> /* XXX */
8
9struct nouveau_pwr {
10 struct nouveau_subdev base;
11
12 struct {
13 u32 limit;
14 u32 *data;
15 u32 size;
16 } code;
17
18 struct {
19 u32 limit;
20 u32 *data;
21 u32 size;
22 } data;
23
24 struct {
25 u32 base;
26 u32 size;
27 } send;
28
29 struct {
30 u32 base;
31 u32 size;
32
33 struct work_struct work;
34#ifdef __NetBSD__
35 drm_waitqueue_t wait;
36#else
37 wait_queue_head_t wait;
38#endif
39 u32 process;
40 u32 message;
41 u32 data[2];
42 } recv;
43
44 int (*message)(struct nouveau_pwr *, u32[2], u32, u32, u32, u32);
45};
46
47static inline struct nouveau_pwr *
48nouveau_pwr(void *obj)
49{
50 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_PWR];
51}
52
53#define nouveau_pwr_create(p, e, o, d) \
54 nouveau_pwr_create_((p), (e), (o), sizeof(**d), (void **)d)
55#define nouveau_pwr_destroy(p) \
56 nouveau_subdev_destroy(&(p)->base)
57#define nouveau_pwr_init(p) ({ \
58 struct nouveau_pwr *ppwr = (p); \
59 _nouveau_pwr_init(nv_object(ppwr)); \
60})
61#define nouveau_pwr_fini(p,s) ({ \
62 struct nouveau_pwr *ppwr = (p); \
63 _nouveau_pwr_fini(nv_object(ppwr), (s)); \
64})
65
66int nouveau_pwr_create_(struct nouveau_object *, struct nouveau_object *,
67 struct nouveau_oclass *, int, void **);
68#ifdef __NetBSD__
69void _nouveau_pwr_dtor(struct nouveau_object *);
70#else
71#define _nouveau_pwr_dtor _nouveau_subdev_dtor
72#endif
73int _nouveau_pwr_init(struct nouveau_object *);
74int _nouveau_pwr_fini(struct nouveau_object *, bool);
75
76extern struct nouveau_oclass nva3_pwr_oclass;
77extern struct nouveau_oclass nvc0_pwr_oclass;
78extern struct nouveau_oclass nvd0_pwr_oclass;
79extern struct nouveau_oclass nv108_pwr_oclass;
80
81/* interface to MEMX process running on PPWR */
82struct nouveau_memx;
83int nouveau_memx_init(struct nouveau_pwr *, struct nouveau_memx **);
84int nouveau_memx_fini(struct nouveau_memx **, bool exec);
85void nouveau_memx_wr32(struct nouveau_memx *, u32 addr, u32 data);
86void nouveau_memx_wait(struct nouveau_memx *,
87 u32 addr, u32 mask, u32 data, u32 nsec);
88void nouveau_memx_nsec(struct nouveau_memx *, u32 nsec);
89
90#endif
91