109e1b78aSBen Skeggs /*
209e1b78aSBen Skeggs * Copyright 2018 Red Hat Inc.
309e1b78aSBen Skeggs *
409e1b78aSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
509e1b78aSBen Skeggs * copy of this software and associated documentation files (the "Software"),
609e1b78aSBen Skeggs * to deal in the Software without restriction, including without limitation
709e1b78aSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
809e1b78aSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
909e1b78aSBen Skeggs * Software is furnished to do so, subject to the following conditions:
1009e1b78aSBen Skeggs *
1109e1b78aSBen Skeggs * The above copyright notice and this permission notice shall be included in
1209e1b78aSBen Skeggs * all copies or substantial portions of the Software.
1309e1b78aSBen Skeggs *
1409e1b78aSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1509e1b78aSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1609e1b78aSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1709e1b78aSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1809e1b78aSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1909e1b78aSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2009e1b78aSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
2109e1b78aSBen Skeggs */
2209e1b78aSBen Skeggs #include "core.h"
2309e1b78aSBen Skeggs #include "head.h"
2409e1b78aSBen Skeggs
2524d9422eSLyude Paul #include <nvif/push507c.h>
2624d9422eSLyude Paul #include <nvif/timer.h>
2724d9422eSLyude Paul
2824d9422eSLyude Paul #include <nvhw/class/cl907d.h>
2924d9422eSLyude Paul
3024d9422eSLyude Paul #include "nouveau_bo.h"
3124d9422eSLyude Paul
3224d9422eSLyude Paul int
core907d_caps_init(struct nouveau_drm * drm,struct nv50_disp * disp)3324d9422eSLyude Paul core907d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
3424d9422eSLyude Paul {
3524d9422eSLyude Paul struct nv50_core *core = disp->core;
3624d9422eSLyude Paul struct nouveau_bo *bo = disp->sync;
3724d9422eSLyude Paul s64 time;
3824d9422eSLyude Paul int ret;
3924d9422eSLyude Paul
4024d9422eSLyude Paul NVBO_WR32(bo, NV50_DISP_CORE_NTFY, NV907D_CORE_NOTIFIER_3, CAPABILITIES_4,
4124d9422eSLyude Paul NVDEF(NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, FALSE));
4224d9422eSLyude Paul
4324d9422eSLyude Paul ret = core507d_read_caps(disp);
4424d9422eSLyude Paul if (ret < 0)
4524d9422eSLyude Paul return ret;
4624d9422eSLyude Paul
4724d9422eSLyude Paul time = nvif_msec(core->chan.base.device, 2000ULL,
4824d9422eSLyude Paul if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
4924d9422eSLyude Paul NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, ==, TRUE))
5024d9422eSLyude Paul break;
5124d9422eSLyude Paul usleep_range(1, 2);
5224d9422eSLyude Paul );
5324d9422eSLyude Paul if (time < 0)
5424d9422eSLyude Paul NV_ERROR(drm, "core caps notifier timeout\n");
5524d9422eSLyude Paul
5624d9422eSLyude Paul return 0;
5724d9422eSLyude Paul }
5824d9422eSLyude Paul
5909e1b78aSBen Skeggs static const struct nv50_core_func
6009e1b78aSBen Skeggs core907d = {
6109e1b78aSBen Skeggs .init = core507d_init,
6209e1b78aSBen Skeggs .ntfy_init = core507d_ntfy_init,
6324d9422eSLyude Paul .caps_init = core907d_caps_init,
6409e1b78aSBen Skeggs .ntfy_wait_done = core507d_ntfy_wait_done,
6509e1b78aSBen Skeggs .update = core507d_update,
6609e1b78aSBen Skeggs .head = &head907d,
6712885ecbSLyude Paul #if IS_ENABLED(CONFIG_DEBUG_FS)
6812885ecbSLyude Paul .crc = &crc907d,
6912885ecbSLyude Paul #endif
7009e1b78aSBen Skeggs .dac = &dac907d,
7109e1b78aSBen Skeggs .sor = &sor907d,
7209e1b78aSBen Skeggs };
7309e1b78aSBen Skeggs
7409e1b78aSBen Skeggs int
core907d_new(struct nouveau_drm * drm,s32 oclass,struct nv50_core ** pcore)7509e1b78aSBen Skeggs core907d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
7609e1b78aSBen Skeggs {
7709e1b78aSBen Skeggs return core507d_new_(&core907d, drm, oclass, pcore);
7809e1b78aSBen Skeggs }
79