0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "core.h"
0023 #include "head.h"
0024
0025 #include <nvif/if0014.h>
0026 #include <nvif/push507c.h>
0027 #include <nvif/timer.h>
0028
0029 #include <nvhw/class/cl507d.h>
0030
0031 #include "nouveau_bo.h"
0032
0033 int
0034 core507d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
0035 {
0036 struct nvif_push *push = core->chan.push;
0037 int ret;
0038
0039 if ((ret = PUSH_WAIT(push, (ntfy ? 2 : 0) + 3)))
0040 return ret;
0041
0042 if (ntfy) {
0043 PUSH_MTHD(push, NV507D, SET_NOTIFIER_CONTROL,
0044 NVDEF(NV507D, SET_NOTIFIER_CONTROL, MODE, WRITE) |
0045 NVVAL(NV507D, SET_NOTIFIER_CONTROL, OFFSET, NV50_DISP_CORE_NTFY >> 2) |
0046 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, ENABLE));
0047 }
0048
0049 PUSH_MTHD(push, NV507D, UPDATE, interlock[NV50_DISP_INTERLOCK_BASE] |
0050 interlock[NV50_DISP_INTERLOCK_OVLY] |
0051 NVDEF(NV507D, UPDATE, NOT_DRIVER_FRIENDLY, FALSE) |
0052 NVDEF(NV507D, UPDATE, NOT_DRIVER_UNFRIENDLY, FALSE) |
0053 NVDEF(NV507D, UPDATE, INHIBIT_INTERRUPTS, FALSE),
0054
0055 SET_NOTIFIER_CONTROL,
0056 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
0057
0058 return PUSH_KICK(push);
0059 }
0060
0061 int
0062 core507d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset,
0063 struct nvif_device *device)
0064 {
0065 s64 time = nvif_msec(device, 2000ULL,
0066 if (NVBO_TD32(bo, offset, NV_DISP_CORE_NOTIFIER_1, COMPLETION_0, DONE, ==, TRUE))
0067 break;
0068 usleep_range(1, 2);
0069 );
0070 return time < 0 ? time : 0;
0071 }
0072
0073 void
0074 core507d_ntfy_init(struct nouveau_bo *bo, u32 offset)
0075 {
0076 NVBO_WR32(bo, offset, NV_DISP_CORE_NOTIFIER_1, COMPLETION_0,
0077 NVDEF(NV_DISP_CORE_NOTIFIER_1, COMPLETION_0, DONE, FALSE));
0078 }
0079
0080 int
0081 core507d_read_caps(struct nv50_disp *disp)
0082 {
0083 struct nvif_push *push = disp->core->chan.push;
0084 int ret;
0085
0086 ret = PUSH_WAIT(push, 6);
0087 if (ret)
0088 return ret;
0089
0090 PUSH_MTHD(push, NV507D, SET_NOTIFIER_CONTROL,
0091 NVDEF(NV507D, SET_NOTIFIER_CONTROL, MODE, WRITE) |
0092 NVVAL(NV507D, SET_NOTIFIER_CONTROL, OFFSET, NV50_DISP_CORE_NTFY >> 2) |
0093 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, ENABLE));
0094
0095 PUSH_MTHD(push, NV507D, GET_CAPABILITIES, 0x00000000);
0096
0097 PUSH_MTHD(push, NV507D, SET_NOTIFIER_CONTROL,
0098 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
0099
0100 return PUSH_KICK(push);
0101 }
0102
0103 int
0104 core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
0105 {
0106 struct nv50_core *core = disp->core;
0107 struct nouveau_bo *bo = disp->sync;
0108 s64 time;
0109 int ret;
0110
0111 NVBO_WR32(bo, NV50_DISP_CORE_NTFY, NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1,
0112 NVDEF(NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, FALSE));
0113
0114 ret = core507d_read_caps(disp);
0115 if (ret < 0)
0116 return ret;
0117
0118 time = nvif_msec(core->chan.base.device, 2000ULL,
0119 if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
0120 NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, ==, TRUE))
0121 break;
0122 usleep_range(1, 2);
0123 );
0124 if (time < 0)
0125 NV_ERROR(drm, "core caps notifier timeout\n");
0126
0127 return 0;
0128 }
0129
0130 int
0131 core507d_init(struct nv50_core *core)
0132 {
0133 struct nvif_push *push = core->chan.push;
0134 int ret;
0135
0136 if ((ret = PUSH_WAIT(push, 2)))
0137 return ret;
0138
0139 PUSH_MTHD(push, NV507D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
0140 return PUSH_KICK(push);
0141 }
0142
0143 static const struct nv50_core_func
0144 core507d = {
0145 .init = core507d_init,
0146 .ntfy_init = core507d_ntfy_init,
0147 .caps_init = core507d_caps_init,
0148 .ntfy_wait_done = core507d_ntfy_wait_done,
0149 .update = core507d_update,
0150 .head = &head507d,
0151 .dac = &dac507d,
0152 .sor = &sor507d,
0153 .pior = &pior507d,
0154 };
0155
0156 int
0157 core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm,
0158 s32 oclass, struct nv50_core **pcore)
0159 {
0160 struct nvif_disp_chan_v0 args = {};
0161 struct nv50_disp *disp = nv50_disp(drm->dev);
0162 struct nv50_core *core;
0163 int ret;
0164
0165 if (!(core = *pcore = kzalloc(sizeof(*core), GFP_KERNEL)))
0166 return -ENOMEM;
0167 core->func = func;
0168
0169 ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
0170 &oclass, 0, &args, sizeof(args),
0171 disp->sync->offset, &core->chan);
0172 if (ret) {
0173 NV_ERROR(drm, "core%04x allocation failed: %d\n", oclass, ret);
0174 return ret;
0175 }
0176
0177 return 0;
0178 }
0179
0180 int
0181 core507d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
0182 {
0183 return core507d_new_(&core507d, drm, oclass, pcore);
0184 }