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 gf108_ram_probe_fbp_amount(const struct nvkm_ram_func *func, u32 fbpao,
0028                struct nvkm_device *device, int fbp, int *pltcs)
0029 {
0030     u32 fbpt  = nvkm_rd32(device, 0x022438);
0031     u32 fbpat = nvkm_rd32(device, 0x02243c);
0032     u32 fbpas = fbpat / fbpt;
0033     u32 fbpa  = fbp * fbpas;
0034     u32 size  = 0;
0035     while (fbpas--) {
0036         if (!(fbpao & BIT(fbpa)))
0037             size += func->probe_fbpa_amount(device, fbpa);
0038         fbpa++;
0039     }
0040     *pltcs = 1;
0041     return size;
0042 }
0043 
0044 static const struct nvkm_ram_func
0045 gf108_ram = {
0046     .upper = 0x0200000000ULL,
0047     .probe_fbp = gf100_ram_probe_fbp,
0048     .probe_fbp_amount = gf108_ram_probe_fbp_amount,
0049     .probe_fbpa_amount = gf100_ram_probe_fbpa_amount,
0050     .init = gf100_ram_init,
0051     .calc = gf100_ram_calc,
0052     .prog = gf100_ram_prog,
0053     .tidy = gf100_ram_tidy,
0054 };
0055 
0056 int
0057 gf108_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
0058 {
0059     return gf100_ram_new_(&gf108_ram, fb, pram);
0060 }