Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0019  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0020  * DEALINGS IN THE SOFTWARE.
0021  */
0022 #include <subdev/privring.h>
0023 #include <subdev/timer.h>
0024 
0025 static void
0026 gk20a_privring_init_privring_ring(struct nvkm_subdev *privring)
0027 {
0028     struct nvkm_device *device = privring->device;
0029     nvkm_mask(device, 0x137250, 0x3f, 0);
0030 
0031     nvkm_mask(device, 0x000200, 0x20, 0);
0032     udelay(20);
0033     nvkm_mask(device, 0x000200, 0x20, 0x20);
0034 
0035     nvkm_wr32(device, 0x12004c, 0x4);
0036     nvkm_wr32(device, 0x122204, 0x2);
0037     nvkm_rd32(device, 0x122204);
0038 
0039     /*
0040      * Bug: increase clock timeout to avoid operation failure at high
0041      * gpcclk rate.
0042      */
0043     nvkm_wr32(device, 0x122354, 0x800);
0044     nvkm_wr32(device, 0x128328, 0x800);
0045     nvkm_wr32(device, 0x124320, 0x800);
0046 }
0047 
0048 static void
0049 gk20a_privring_intr(struct nvkm_subdev *privring)
0050 {
0051     struct nvkm_device *device = privring->device;
0052     u32 status0 = nvkm_rd32(device, 0x120058);
0053 
0054     if (status0 & 0x7) {
0055         nvkm_debug(privring, "resetting privring ring\n");
0056         gk20a_privring_init_privring_ring(privring);
0057     }
0058 
0059     /* Acknowledge interrupt */
0060     nvkm_mask(device, 0x12004c, 0x2, 0x2);
0061     nvkm_msec(device, 2000,
0062         if (!(nvkm_rd32(device, 0x12004c) & 0x0000003f))
0063             break;
0064     );
0065 }
0066 
0067 static int
0068 gk20a_privring_init(struct nvkm_subdev *privring)
0069 {
0070     gk20a_privring_init_privring_ring(privring);
0071     return 0;
0072 }
0073 
0074 static const struct nvkm_subdev_func
0075 gk20a_privring = {
0076     .init = gk20a_privring_init,
0077     .intr = gk20a_privring_intr,
0078 };
0079 
0080 int
0081 gk20a_privring_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0082            struct nvkm_subdev **pprivring)
0083 {
0084     return nvkm_subdev_new_(&gk20a_privring, device, type, inst, pprivring);
0085 }