132932281SBen Skeggs /* 232932281SBen Skeggs * Copyright 2015 Red Hat Inc. 332932281SBen Skeggs * 432932281SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 532932281SBen Skeggs * copy of this software and associated documentation files (the "Software"), 632932281SBen Skeggs * to deal in the Software without restriction, including without limitation 732932281SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 832932281SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 932932281SBen Skeggs * Software is furnished to do so, subject to the following conditions: 1032932281SBen Skeggs * 1132932281SBen Skeggs * The above copyright notice and this permission notice shall be included in 1232932281SBen Skeggs * all copies or substantial portions of the Software. 1332932281SBen Skeggs * 1432932281SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1532932281SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1632932281SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1732932281SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1832932281SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1932932281SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2032932281SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 2132932281SBen Skeggs * 2232932281SBen Skeggs * Authors: Ben Skeggs <bskeggs@redhat.com> 2332932281SBen Skeggs */ 2432932281SBen Skeggs #include "nv50.h" 2532932281SBen Skeggs 2632932281SBen Skeggs #include <subdev/timer.h> 2732932281SBen Skeggs 2832932281SBen Skeggs void 2932932281SBen Skeggs g84_bar_flush(struct nvkm_bar *bar) 3032932281SBen Skeggs { 3132932281SBen Skeggs struct nvkm_device *device = bar->subdev.device; 3232932281SBen Skeggs unsigned long flags; 3332932281SBen Skeggs spin_lock_irqsave(&bar->lock, flags); 3432932281SBen Skeggs nvkm_wr32(device, 0x070000, 0x00000001); 3532932281SBen Skeggs nvkm_msec(device, 2000, 3632932281SBen Skeggs if (!(nvkm_rd32(device, 0x070000) & 0x00000002)) 3732932281SBen Skeggs break; 3832932281SBen Skeggs ); 3932932281SBen Skeggs spin_unlock_irqrestore(&bar->lock, flags); 4032932281SBen Skeggs } 4132932281SBen Skeggs 4232932281SBen Skeggs static const struct nvkm_bar_func 4332932281SBen Skeggs g84_bar_func = { 4432932281SBen Skeggs .dtor = nv50_bar_dtor, 4532932281SBen Skeggs .oneinit = nv50_bar_oneinit, 4632932281SBen Skeggs .init = nv50_bar_init, 477313cfa4SBen Skeggs .bar1.init = nv50_bar_bar1_init, 487313cfa4SBen Skeggs .bar1.wait = nv50_bar_bar1_wait, 4932932281SBen Skeggs .kmap = nv50_bar_kmap, 5032932281SBen Skeggs .umap = nv50_bar_umap, 5132932281SBen Skeggs .flush = g84_bar_flush, 5232932281SBen Skeggs }; 5332932281SBen Skeggs 5432932281SBen Skeggs int 5532932281SBen Skeggs g84_bar_new(struct nvkm_device *device, int index, struct nvkm_bar **pbar) 5632932281SBen Skeggs { 5732932281SBen Skeggs return nv50_bar_new_(&g84_bar_func, device, index, 0x200, pbar); 5832932281SBen Skeggs } 59