1 #ifndef __NVKM_BUS_HWSQ_H__
2 #define __NVKM_BUS_HWSQ_H__
3 #include <subdev/bus.h>
6 struct nvkm_subdev
*subdev
;
7 struct nvkm_hwsq
*hwsq
;
18 static inline struct hwsq_reg
19 hwsq_reg2(u32 addr1
, u32 addr2
)
21 return (struct hwsq_reg
) {
24 .addr
= { addr1
, addr2
},
29 static inline struct hwsq_reg
32 return hwsq_reg2(addr
, addr
);
36 hwsq_init(struct hwsq
*ram
, struct nvkm_subdev
*subdev
)
38 struct nvkm_bus
*pbus
= nvkm_bus(subdev
);
41 ret
= nvkm_hwsq_init(pbus
, &ram
->hwsq
);
51 hwsq_exec(struct hwsq
*ram
, bool exec
)
55 ret
= nvkm_hwsq_fini(&ram
->hwsq
, exec
);
62 hwsq_rd32(struct hwsq
*ram
, struct hwsq_reg
*reg
)
64 if (reg
->sequence
!= ram
->sequence
)
65 reg
->data
= nv_rd32(ram
->subdev
, reg
->addr
[0]);
70 hwsq_wr32(struct hwsq
*ram
, struct hwsq_reg
*reg
, u32 data
)
72 reg
->sequence
= ram
->sequence
;
74 if (reg
->addr
[0] != reg
->addr
[1])
75 nvkm_hwsq_wr32(ram
->hwsq
, reg
->addr
[1], reg
->data
);
76 nvkm_hwsq_wr32(ram
->hwsq
, reg
->addr
[0], reg
->data
);
80 hwsq_nuke(struct hwsq
*ram
, struct hwsq_reg
*reg
)
86 hwsq_mask(struct hwsq
*ram
, struct hwsq_reg
*reg
, u32 mask
, u32 data
)
88 u32 temp
= hwsq_rd32(ram
, reg
);
89 if (temp
!= ((temp
& ~mask
) | data
) || reg
->force
)
90 hwsq_wr32(ram
, reg
, (temp
& ~mask
) | data
);
95 hwsq_setf(struct hwsq
*ram
, u8 flag
, int data
)
97 nvkm_hwsq_setf(ram
->hwsq
, flag
, data
);
101 hwsq_wait(struct hwsq
*ram
, u8 flag
, u8 data
)
103 nvkm_hwsq_wait(ram
->hwsq
, flag
, data
);
107 hwsq_nsec(struct hwsq
*ram
, u32 nsec
)
109 nvkm_hwsq_nsec(ram
->hwsq
, nsec
);