157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs/* 257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * Copyright 2012 Red Hat Inc. 357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * 457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * copy of this software and associated documentation files (the "Software"), 657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * to deal in the Software without restriction, including without limitation 757f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 857f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * and/or sell copies of the Software, and to permit persons to whom the 957f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * Software is furnished to do so, subject to the following conditions: 1057f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * 1157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * The above copyright notice and this permission notice shall be included in 1257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * all copies or substantial portions of the Software. 1357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * 1457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1757f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1857f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1957f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2057f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * OTHER DEALINGS IN THE SOFTWARE. 2157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * 2257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs * Authors: Ben Skeggs 2357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs */ 2457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 2557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs#include "nv04.h" 2657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 2757f7422016c5289baf906cdad55b326d05c26519Ben Skeggsstatic int 2857f7422016c5289baf906cdad55b326d05c26519Ben Skeggsgk20a_timer_init(struct nouveau_object *object) 2957f7422016c5289baf906cdad55b326d05c26519Ben Skeggs{ 3057f7422016c5289baf906cdad55b326d05c26519Ben Skeggs struct nv04_timer_priv *priv = (void *)object; 3157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs u32 hi = upper_32_bits(priv->suspend_time); 3257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs u32 lo = lower_32_bits(priv->suspend_time); 3357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs int ret; 3457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 3557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs ret = nouveau_timer_init(&priv->base); 3657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs if (ret) 3757f7422016c5289baf906cdad55b326d05c26519Ben Skeggs return ret; 3857f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 3957f7422016c5289baf906cdad55b326d05c26519Ben Skeggs nv_debug(priv, "time low : 0x%08x\n", lo); 4057f7422016c5289baf906cdad55b326d05c26519Ben Skeggs nv_debug(priv, "time high : 0x%08x\n", hi); 4157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 4257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs /* restore the time before suspend */ 4357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs nv_wr32(priv, NV04_PTIMER_TIME_1, hi); 4457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs nv_wr32(priv, NV04_PTIMER_TIME_0, lo); 4557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs return 0; 4657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs} 4757f7422016c5289baf906cdad55b326d05c26519Ben Skeggs 4857f7422016c5289baf906cdad55b326d05c26519Ben Skeggsstruct nouveau_oclass 4957f7422016c5289baf906cdad55b326d05c26519Ben Skeggsgk20a_timer_oclass = { 5057f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .handle = NV_SUBDEV(TIMER, 0xff), 5157f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .ofuncs = &(struct nouveau_ofuncs) { 5257f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .ctor = nv04_timer_ctor, 5357f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .dtor = nv04_timer_dtor, 5457f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .init = gk20a_timer_init, 5557f7422016c5289baf906cdad55b326d05c26519Ben Skeggs .fini = nv04_timer_fini, 5657f7422016c5289baf906cdad55b326d05c26519Ben Skeggs } 5757f7422016c5289baf906cdad55b326d05c26519Ben Skeggs}; 58