Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2017 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 <bskeggs@redhat.com>
0023  */
0024 #include "ram.h"
0025 
0026 u32
0027 gm200_ram_probe_fbp_amount(const struct nvkm_ram_func *func, u32 fbpao,
0028                struct nvkm_device *device, int fbp, int *pltcs)
0029 {
0030     u32 ltcs  = nvkm_rd32(device, 0x022450);
0031     u32 fbpas = nvkm_rd32(device, 0x022458);
0032     u32 fbpa  = fbp * fbpas;
0033     u32 size  = 0;
0034     if (!(nvkm_rd32(device, 0x021d38) & BIT(fbp))) {
0035         u32 ltco = nvkm_rd32(device, 0x021d70 + (fbp * 4));
0036         u32 ltcm = ~ltco & ((1 << ltcs) - 1);
0037 
0038         while (fbpas--) {
0039             if (!(fbpao & (1 << fbpa)))
0040                 size += func->probe_fbpa_amount(device, fbpa);
0041             fbpa++;
0042         }
0043 
0044         *pltcs = hweight32(ltcm);
0045     }
0046     return size;
0047 }
0048 
0049 static const struct nvkm_ram_func
0050 gm200_ram = {
0051     .upper = 0x1000000000ULL,
0052     .probe_fbp = gm107_ram_probe_fbp,
0053     .probe_fbp_amount = gm200_ram_probe_fbp_amount,
0054     .probe_fbpa_amount = gf100_ram_probe_fbpa_amount,
0055     .dtor = gk104_ram_dtor,
0056     .init = gk104_ram_init,
0057     .calc = gk104_ram_calc,
0058     .prog = gk104_ram_prog,
0059     .tidy = gk104_ram_tidy,
0060 };
0061 
0062 int
0063 gm200_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
0064 {
0065     return gk104_ram_new_(&gm200_ram, fb, pram);
0066 }