Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2015 Red Hat Inc.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs
0023  */
0024 #define gf119_pmu_code gk110_pmu_code
0025 #define gf119_pmu_data gk110_pmu_data
0026 #include "priv.h"
0027 #include "fuc/gf119.fuc4.h"
0028 
0029 #include <subdev/timer.h>
0030 
0031 void
0032 gk110_pmu_pgob(struct nvkm_pmu *pmu, bool enable)
0033 {
0034     struct nvkm_device *device = pmu->subdev.device;
0035     static const struct {
0036         u32 addr;
0037         u32 data;
0038     } magic[] = {
0039         { 0x020520, 0xfffffffc },
0040         { 0x020524, 0xfffffffe },
0041         { 0x020524, 0xfffffffc },
0042         { 0x020524, 0xfffffff8 },
0043         { 0x020524, 0xffffffe0 },
0044         { 0x020530, 0xfffffffe },
0045         { 0x02052c, 0xfffffffa },
0046         { 0x02052c, 0xfffffff0 },
0047         { 0x02052c, 0xffffffc0 },
0048         { 0x02052c, 0xffffff00 },
0049         { 0x02052c, 0xfffffc00 },
0050         { 0x02052c, 0xfffcfc00 },
0051         { 0x02052c, 0xfff0fc00 },
0052         { 0x02052c, 0xff80fc00 },
0053         { 0x020528, 0xfffffffe },
0054         { 0x020528, 0xfffffffc },
0055     };
0056     int i;
0057 
0058     nvkm_mask(device, 0x000200, 0x00001000, 0x00000000);
0059     nvkm_rd32(device, 0x000200);
0060     nvkm_mask(device, 0x000200, 0x08000000, 0x08000000);
0061     msleep(50);
0062 
0063     nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000002);
0064     nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
0065     nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
0066 
0067     nvkm_mask(device, 0x0206b4, 0x00000000, 0x00000000);
0068     for (i = 0; i < ARRAY_SIZE(magic); i++) {
0069         nvkm_wr32(device, magic[i].addr, magic[i].data);
0070         nvkm_msec(device, 2000,
0071             if (!(nvkm_rd32(device, magic[i].addr) & 0x80000000))
0072                 break;
0073         );
0074     }
0075 
0076     nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000000);
0077     nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
0078     nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
0079 
0080     nvkm_mask(device, 0x000200, 0x08000000, 0x00000000);
0081     nvkm_mask(device, 0x000200, 0x00001000, 0x00001000);
0082     nvkm_rd32(device, 0x000200);
0083 }
0084 
0085 static const struct nvkm_pmu_func
0086 gk110_pmu = {
0087     .flcn = &gt215_pmu_flcn,
0088     .code.data = gk110_pmu_code,
0089     .code.size = sizeof(gk110_pmu_code),
0090     .data.data = gk110_pmu_data,
0091     .data.size = sizeof(gk110_pmu_data),
0092     .enabled = gf100_pmu_enabled,
0093     .reset = gf100_pmu_reset,
0094     .init = gt215_pmu_init,
0095     .fini = gt215_pmu_fini,
0096     .intr = gt215_pmu_intr,
0097     .send = gt215_pmu_send,
0098     .recv = gt215_pmu_recv,
0099     .pgob = gk110_pmu_pgob,
0100 };
0101 
0102 static const struct nvkm_pmu_fwif
0103 gk110_pmu_fwif[] = {
0104     { -1, gf100_pmu_nofw, &gk110_pmu },
0105     {}
0106 };
0107 
0108 int
0109 gk110_pmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0110           struct nvkm_pmu **ppmu)
0111 {
0112     return nvkm_pmu_new_(gk110_pmu_fwif, device, type, inst, ppmu);
0113 }