]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau/disp/nv50-: fetch mask of available sors during oneinit
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:20 +0000 (15:01 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
28 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gp102.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorg84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorg94.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm107.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sormcp77.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sormcp89.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c

index 9f31f04e4e58e82fdaa79a7c8898bb9d37a811a1..287ac5edc88ab4263879a59e822bd9c83320cee3 100644 (file)
@@ -34,7 +34,7 @@ g84_disp = {
        .root = &g84_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 2, .new = g84_sor_new },
+       .sor = { .cnt = nv50_sor_cnt, .new = g84_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 71fe26b2583549cc4b647c59cee491ad93e4eefc..e21f76d4e28e399bc68b380a7c78a1c372de5465 100644 (file)
@@ -34,7 +34,7 @@ g94_disp = {
        .root = &g94_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 4, .new = g94_sor_new },
+       .sor = { .cnt = g94_sor_cnt, .new = g94_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index c8495bcf289cff4fa9f96540f9a6e1cab5ca9a6a..0139d143c733b4fcc997ec87a3b42ee11c7c2b00 100644 (file)
@@ -173,7 +173,7 @@ gf119_disp = {
        .root = &gf119_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
        .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
-       .sor = { .nr = 4, .new = gf119_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gf119_sor_new },
 };
 
 int
index b948619818cc1bd28968e35969751bbef9c0e292..6a59a52468c1fce8829c64d685271093bc9d48ba 100644 (file)
@@ -35,7 +35,7 @@ gk104_disp = {
        .root = &gk104_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
        .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
-       .sor = { .nr = 4, .new = gk104_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gk104_sor_new },
 };
 
 int
index 0b4945703568ef793e557a4eb37c6ce656e157aa..f3b10dc4e67353b862703bd4db9c511a597197b8 100644 (file)
@@ -35,7 +35,7 @@ gk110_disp = {
        .root = &gk110_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
        .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
-       .sor = { .nr = 4, .new = gk104_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gk104_sor_new },
 };
 
 int
index 35ad965ffee27c1c66c08f93c1fed50023e7b4c9..068c5951efe38404fd0d4cfb500d093c9d18dc8f 100644 (file)
@@ -35,7 +35,7 @@ gm107_disp = {
        .root = &gm107_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
        .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
-       .sor = { .nr = 4, .new = gm107_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gm107_sor_new },
 };
 
 int
index b2a5d364ffaf4b5844a2deb3c3a83b487af46acc..1c27dbe6cceca792687cf94c26cd658b5dff63a2 100644 (file)
@@ -35,7 +35,7 @@ gm200_disp = {
        .root = &gm200_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
        .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new },
-       .sor = { .nr = 4, .new = gm200_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gm200_sor_new },
 };
 
 int
index 190d03025fc1b76166a7decf1ea95744d89ccdba..84933b6119f2cee1aa0df7fbdc93a9c494e43b6c 100644 (file)
@@ -34,7 +34,7 @@ gp100_disp = {
        .super = gf119_disp_super,
        .root = &gp100_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
-       .sor = { .nr = 4, .new = gm200_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gm200_sor_new },
 };
 
 int
index a059c65243a939a2b6ea0c7c1c1ef6727e59f01b..b36d926f0264242ef81fd85604771d2e021804ab 100644 (file)
@@ -60,7 +60,7 @@ gp102_disp = {
        .super = gf119_disp_super,
        .root = &gp102_disp_root_oclass,
        .head = { .cnt = gf119_head_cnt, .new = gf119_head_new },
-       .sor = { .nr = 4, .new = gm200_sor_new },
+       .sor = { .cnt = gf119_sor_cnt, .new = gm200_sor_new },
 };
 
 int
index 88b6a34e9df7ff38fdd0e7f3e556ce08ca3682b4..2ca92a23a62a46f8ea6ba9c41081cae2a9d5d46e 100644 (file)
@@ -34,7 +34,7 @@ gt200_disp = {
        .root = &gt200_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 2, .new = g84_sor_new },
+       .sor = { .cnt = nv50_sor_cnt, .new = g84_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 1519ca566d9f82617aa655d9737e4fec581b2a17..73b039069660016151dac06134ccbb24454f589d 100644 (file)
@@ -34,7 +34,7 @@ gt215_disp = {
        .root = &gt215_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 4, .new = gt215_sor_new },
+       .sor = { .cnt = g94_sor_cnt, .new = gt215_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 89d9ab154c4b6d36db76c1a61009766f4636482f..6432e0611deece482dfea46a2e2e67a53cb5efad 100644 (file)
@@ -106,7 +106,6 @@ nv50_sor_link(struct nvkm_ior *ior)
        return nv50_ior_base(ior) + ((ior->asy.link == 2) * 0x80);
 }
 
-int nv50_sor_new_(const struct nvkm_ior_func *, struct nvkm_disp *, int id);
 void nv50_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
 void nv50_sor_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
 void nv50_sor_clock(struct nvkm_ior *);
@@ -122,7 +121,6 @@ void g94_sor_dp_watermark(struct nvkm_ior *, int, u8);
 
 void gt215_sor_dp_audio(struct nvkm_ior *, int, bool);
 
-int gf119_sor_new_(const struct nvkm_ior_func *, struct nvkm_disp *, int id);
 void gf119_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
 void gf119_sor_clock(struct nvkm_ior *);
 int gf119_sor_dp_links(struct nvkm_ior *, struct nvkm_i2c_aux *);
@@ -161,13 +159,21 @@ int gf119_dac_new(struct nvkm_disp *, int);
 
 int nv50_pior_new(struct nvkm_disp *, int);
 
+int nv50_sor_cnt(struct nvkm_disp *, unsigned long *);
 int nv50_sor_new(struct nvkm_disp *, int);
+
 int g84_sor_new(struct nvkm_disp *, int);
+
+int g94_sor_cnt(struct nvkm_disp *, unsigned long *);
 int g94_sor_new(struct nvkm_disp *, int);
+
 int mcp77_sor_new(struct nvkm_disp *, int);
 int gt215_sor_new(struct nvkm_disp *, int);
 int mcp89_sor_new(struct nvkm_disp *, int);
+
+int gf119_sor_cnt(struct nvkm_disp *, unsigned long *);
 int gf119_sor_new(struct nvkm_disp *, int);
+
 int gk104_sor_new(struct nvkm_disp *, int);
 int gm107_sor_new(struct nvkm_disp *, int);
 int gm200_sor_new(struct nvkm_disp *, int);
index fb188546f5f8f60de8b849ec1917431e7aa9aa2e..c3f6504ea67d25c142ac179260b36086142230a7 100644 (file)
@@ -32,7 +32,7 @@ mcp77_disp = {
        .root = &g94_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 4, .new = mcp77_sor_new },
+       .sor = { .cnt = g94_sor_cnt, .new = mcp77_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index ae7fb9625674822a4663e47fb9d506e687213b61..2d1d9218d25387c0b340b1bbe009ceacfab89ba3 100644 (file)
@@ -32,7 +32,7 @@ mcp89_disp = {
        .root = &gt215_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 4, .new = mcp89_sor_new },
+       .sor = { .cnt = g94_sor_cnt, .new = mcp89_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 500ef8da696a01f73ddf27a48501f30061249b7c..1e32814488bf5e2d752cb6f1b2b59ef2f1f5ffec 100644 (file)
@@ -93,7 +93,10 @@ nv50_disp_oneinit_(struct nvkm_disp *base)
                        return ret;
        }
 
-       for (i = 0; func->sor.new && i < func->sor.nr; i++) {
+       disp->sor.nr = func->sor.cnt(&disp->base, &disp->sor.mask);
+       nvkm_debug(subdev, "   SOR(s): %d (%02lx)\n",
+                  disp->sor.nr, disp->sor.mask);
+       for_each_set_bit(i, &disp->sor.mask, disp->sor.nr) {
                ret = func->sor.new(&disp->base, i);
                if (ret)
                        return ret;
@@ -643,7 +646,7 @@ nv50_disp = {
        .root = &nv50_disp_root_oclass,
        .head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
        .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
-       .sor = { .nr = 2, .new = nv50_sor_new },
+       .sor = { .cnt = nv50_sor_cnt, .new = nv50_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
 
index 3415a52584927aa9a4bb5b192bb53d91aec7cb0d..ee2968b7aef16757c4fd6d733c3d0ae6ed15850e 100644 (file)
@@ -21,6 +21,8 @@ struct nv50_disp {
        } head, dac;
 
        struct {
+               unsigned long mask;
+               int nr;
                u32 lvdsconf;
        } sor;
 
@@ -53,12 +55,7 @@ struct nv50_disp_func {
        struct {
                int (*cnt)(struct nvkm_disp *, unsigned long *mask);
                int (*new)(struct nvkm_disp *, int id);
-       } head, dac;
-
-       struct {
-               int nr;
-               int (*new)(struct nvkm_disp *, int id);
-       } sor;
+       } head, dac, sor;
 
        struct {
                int nr;
index 7f22b875b9b3e82b646f092f45c9ea210baf08b3..4ba2d80db52ba303d82f21a31a557933ec1549f1 100644 (file)
@@ -70,7 +70,7 @@ gf119_disp_root_init(struct nv50_disp_root *root)
        }
 
        /* ... SOR caps */
-       for (i = 0; i < disp->func->sor.nr; i++) {
+       for (i = 0; i < disp->sor.nr; i++) {
                tmp = nvkm_rd32(device, 0x61c000 + (i * 0x800));
                nvkm_wr32(device, 0x6301c4 + (i * 0x800), tmp);
        }
index 3fbaccd9569bb6c6298aafb67b380283d0363675..9d0b5b71d38af3f689bb81405237f8bcea1bc804 100644 (file)
@@ -433,7 +433,7 @@ nv50_disp_root_init(struct nv50_disp_root *root)
        }
 
        /* ... SOR caps */
-       for (i = 0; i < disp->func->sor.nr; i++) {
+       for (i = 0; i < disp->sor.nr; i++) {
                tmp = nvkm_rd32(device, 0x61c000 + (i * 0x800));
                nvkm_wr32(device, 0x6101e0 + (i * 0x04), tmp);
        }
index f40b909b4ca2dc9f97f894c6841b6bdf3cf76f88..ec3a7db081188d6b46d206995ac08695d43af712 100644 (file)
@@ -34,5 +34,5 @@ g84_sor = {
 int
 g84_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&g84_sor, disp, id);
+       return nvkm_ior_new_(&g84_sor, disp, SOR, id);
 }
index 49aeafde0031efbc6c4f1bb9c475d9530ad3618b..4d59d02525d98c2672c12d4039f4bebe113736b5 100644 (file)
@@ -279,5 +279,13 @@ g94_sor = {
 int
 g94_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&g94_sor, disp, id);
+       return nvkm_ior_new_(&g94_sor, disp, SOR, id);
+}
+
+int
+g94_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask)
+{
+       struct nvkm_device *device = disp->engine.subdev.device;
+       *pmask = (nvkm_rd32(device, 0x610184) & 0x0f000000) >> 24;
+       return 4;
 }
index 700fc754f28a4c32a001c243822b5e97733ba0a7..e6e6dfbb1283d41f5937c48bc23c054c73f55066 100644 (file)
@@ -152,15 +152,6 @@ gf119_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state)
        state->head = ctrl & 0x0000000f;
 }
 
-int
-gf119_sor_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp, int id)
-{
-       struct nvkm_device *device = disp->engine.subdev.device;
-       if (!(nvkm_rd32(device, 0x612004) & (0x00000100 << id)))
-               return 0;
-       return nvkm_ior_new_(func, disp, SOR, id);
-}
-
 static const struct nvkm_ior_func
 gf119_sor = {
        .state = gf119_sor_state,
@@ -189,5 +180,13 @@ gf119_sor = {
 int
 gf119_sor_new(struct nvkm_disp *disp, int id)
 {
-       return gf119_sor_new_(&gf119_sor, disp, id);
+       return nvkm_ior_new_(&gf119_sor, disp, SOR, id);
+}
+
+int
+gf119_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask)
+{
+       struct nvkm_device *device = disp->engine.subdev.device;
+       *pmask = (nvkm_rd32(device, 0x612004) & 0x0000ff00) >> 8;
+       return 8;
 }
index a1547bdf490b865d846962abd4d5e5780c17254b..b94090edaebff2b7462499c18339790d01dbde91 100644 (file)
@@ -49,5 +49,5 @@ gk104_sor = {
 int
 gk104_sor_new(struct nvkm_disp *disp, int id)
 {
-       return gf119_sor_new_(&gk104_sor, disp, id);
+       return nvkm_ior_new_(&gk104_sor, disp, SOR, id);
 }
index 60230957d82bd224c6264961cb57fa4a179c832f..e6965dec09c968f6257649990c0eb78abec02b02 100644 (file)
@@ -63,5 +63,5 @@ gm107_sor = {
 int
 gm107_sor_new(struct nvkm_disp *disp, int id)
 {
-       return gf119_sor_new_(&gm107_sor, disp, id);
+       return nvkm_ior_new_(&gm107_sor, disp, SOR, id);
 }
index f9b8107aa2a293a83397b3118c9ff47ba15a4260..8bc019b6ffabaedd67126d0d120e528bedeb65bb 100644 (file)
@@ -120,5 +120,5 @@ gm200_sor = {
 int
 gm200_sor_new(struct nvkm_disp *disp, int id)
 {
-       return gf119_sor_new_(&gm200_sor, disp, id);
+       return nvkm_ior_new_(&gm200_sor, disp, SOR, id);
 }
index da228b54b43e40b2ba0e059772389d8b311e6fe7..54d134d4ca1d129e8035006a192e1916545b2509 100644 (file)
@@ -65,5 +65,5 @@ gt215_sor = {
 int
 gt215_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&gt215_sor, disp, id);
+       return nvkm_ior_new_(&gt215_sor, disp, SOR, id);
 }
index c0179ccb956d19225b170039e3f9cc16b22abde4..8a70dd25b13a9f1ddbeeb8de570dcd26579f43e0 100644 (file)
@@ -44,5 +44,5 @@ mcp77_sor = {
 int
 mcp77_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&mcp77_sor, disp, id);
+       return nvkm_ior_new_(&mcp77_sor, disp, SOR, id);
 }
index 9bb01cd96697123ce330adc9d310971b15cc8412..eac9c5be9166dd7e41d1cb9cf7cb3440567a884c 100644 (file)
@@ -49,5 +49,5 @@ mcp89_sor = {
 int
 mcp89_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&mcp89_sor, disp, id);
+       return nvkm_ior_new_(&mcp89_sor, disp, SOR, id);
 }
index f3ebd0c22e7d4569c4827a711ed26b6451cd12df..b4729f8798af234e8aac1b5b20ab3be67d5c524a 100644 (file)
@@ -84,15 +84,6 @@ nv50_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state)
        state->head = ctrl & 0x00000003;
 }
 
-int
-nv50_sor_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp, int id)
-{
-       struct nvkm_device *device = disp->engine.subdev.device;
-       if (!(nvkm_rd32(device, 0x610184) & (0x01000000 << id)))
-               return 0;
-       return nvkm_ior_new_(func, disp, SOR, id);
-}
-
 static const struct nvkm_ior_func
 nv50_sor = {
        .state = nv50_sor_state,
@@ -103,5 +94,13 @@ nv50_sor = {
 int
 nv50_sor_new(struct nvkm_disp *disp, int id)
 {
-       return nv50_sor_new_(&nv50_sor, disp, id);
+       return nvkm_ior_new_(&nv50_sor, disp, SOR, id);
+}
+
+int
+nv50_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask)
+{
+       struct nvkm_device *device = disp->engine.subdev.device;
+       *pmask = (nvkm_rd32(device, 0x610184) & 0x03000000) >> 24;
+       return 2;
 }