These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / gpu / drm / nouveau / nvkm / subdev / bios / pll.c
index ebd402e..125ec2e 100644 (file)
@@ -27,7 +27,6 @@
 #include <subdev/bios/pll.h>
 #include <subdev/vga.h>
 
-#include <core/device.h>
 
 struct pll_mapping {
        u8  type;
@@ -84,20 +83,20 @@ pll_limits_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
        struct bit_entry bit_C;
 
        if (!bit_entry(bios, 'C', &bit_C) && bit_C.length >= 10) {
-               u16 data = nv_ro16(bios, bit_C.offset + 8);
+               u16 data = nvbios_rd16(bios, bit_C.offset + 8);
                if (data) {
-                       *ver = nv_ro08(bios, data + 0);
-                       *hdr = nv_ro08(bios, data + 1);
-                       *len = nv_ro08(bios, data + 2);
-                       *cnt = nv_ro08(bios, data + 3);
+                       *ver = nvbios_rd08(bios, data + 0);
+                       *hdr = nvbios_rd08(bios, data + 1);
+                       *len = nvbios_rd08(bios, data + 2);
+                       *cnt = nvbios_rd08(bios, data + 3);
                        return data;
                }
        }
 
        if (bmp_version(bios) >= 0x0524) {
-               u16 data = nv_ro16(bios, bios->bmp_offset + 142);
+               u16 data = nvbios_rd16(bios, bios->bmp_offset + 142);
                if (data) {
-                       *ver = nv_ro08(bios, data + 0);
+                       *ver = nvbios_rd08(bios, data + 0);
                        *hdr = 1;
                        *cnt = 1;
                        *len = 0x18;
@@ -112,7 +111,8 @@ pll_limits_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
 static struct pll_mapping *
 pll_map(struct nvkm_bios *bios)
 {
-       switch (nv_device(bios)->card_type) {
+       struct nvkm_device *device = bios->subdev.device;
+       switch (device->card_type) {
        case NV_04:
        case NV_10:
        case NV_11:
@@ -123,12 +123,12 @@ pll_map(struct nvkm_bios *bios)
        case NV_40:
                return nv40_pll_mapping;
        case NV_50:
-               if (nv_device(bios)->chipset == 0x50)
+               if (device->chipset == 0x50)
                        return nv50_pll_mapping;
                else
-               if (nv_device(bios)->chipset <  0xa3 ||
-                   nv_device(bios)->chipset == 0xaa ||
-                   nv_device(bios)->chipset == 0xac)
+               if (device->chipset <  0xa3 ||
+                   device->chipset == 0xaa ||
+                   device->chipset == 0xac)
                        return g84_pll_mapping;
        default:
                return NULL;
@@ -146,8 +146,8 @@ pll_map_reg(struct nvkm_bios *bios, u32 reg, u32 *type, u8 *ver, u8 *len)
        if (data && *ver >= 0x30) {
                data += hdr;
                while (cnt--) {
-                       if (nv_ro32(bios, data + 3) == reg) {
-                               *type = nv_ro08(bios, data + 0);
+                       if (nvbios_rd32(bios, data + 3) == reg) {
+                               *type = nvbios_rd08(bios, data + 0);
                                return data;
                        }
                        data += *len;
@@ -161,7 +161,7 @@ pll_map_reg(struct nvkm_bios *bios, u32 reg, u32 *type, u8 *ver, u8 *len)
                        u16 addr = (data += hdr);
                        *type = map->type;
                        while (cnt--) {
-                               if (nv_ro32(bios, data) == map->reg)
+                               if (nvbios_rd32(bios, data) == map->reg)
                                        return data;
                                data += *len;
                        }
@@ -188,8 +188,8 @@ pll_map_type(struct nvkm_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len)
        if (data && *ver >= 0x30) {
                data += hdr;
                while (cnt--) {
-                       if (nv_ro08(bios, data + 0) == type) {
-                               *reg = nv_ro32(bios, data + 3);
+                       if (nvbios_rd08(bios, data + 0) == type) {
+                               *reg = nvbios_rd32(bios, data + 3);
                                return data;
                        }
                        data += *len;
@@ -203,7 +203,7 @@ pll_map_type(struct nvkm_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len)
                        u16 addr = (data += hdr);
                        *reg = map->reg;
                        while (cnt--) {
-                               if (nv_ro32(bios, data) == map->reg)
+                               if (nvbios_rd32(bios, data) == map->reg)
                                        return data;
                                data += *len;
                        }
@@ -222,6 +222,8 @@ pll_map_type(struct nvkm_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len)
 int
 nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
 {
+       struct nvkm_subdev *subdev = &bios->subdev;
+       struct nvkm_device *device = subdev->device;
        u8  ver, len;
        u32 reg = type;
        u16 data;
@@ -245,12 +247,12 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
                break;
        case 0x10:
        case 0x11:
-               info->vco1.min_freq = nv_ro32(bios, data + 0);
-               info->vco1.max_freq = nv_ro32(bios, data + 4);
-               info->vco2.min_freq = nv_ro32(bios, data + 8);
-               info->vco2.max_freq = nv_ro32(bios, data + 12);
-               info->vco1.min_inputfreq = nv_ro32(bios, data + 16);
-               info->vco2.min_inputfreq = nv_ro32(bios, data + 20);
+               info->vco1.min_freq = nvbios_rd32(bios, data + 0);
+               info->vco1.max_freq = nvbios_rd32(bios, data + 4);
+               info->vco2.min_freq = nvbios_rd32(bios, data + 8);
+               info->vco2.max_freq = nvbios_rd32(bios, data + 12);
+               info->vco1.min_inputfreq = nvbios_rd32(bios, data + 16);
+               info->vco2.min_inputfreq = nvbios_rd32(bios, data + 20);
                info->vco1.max_inputfreq = INT_MAX;
                info->vco2.max_inputfreq = INT_MAX;
 
@@ -291,82 +293,82 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
                break;
        case 0x20:
        case 0x21:
-               info->vco1.min_freq = nv_ro16(bios, data + 4) * 1000;
-               info->vco1.max_freq = nv_ro16(bios, data + 6) * 1000;
-               info->vco2.min_freq = nv_ro16(bios, data + 8) * 1000;
-               info->vco2.max_freq = nv_ro16(bios, data + 10) * 1000;
-               info->vco1.min_inputfreq = nv_ro16(bios, data + 12) * 1000;
-               info->vco2.min_inputfreq = nv_ro16(bios, data + 14) * 1000;
-               info->vco1.max_inputfreq = nv_ro16(bios, data + 16) * 1000;
-               info->vco2.max_inputfreq = nv_ro16(bios, data + 18) * 1000;
-               info->vco1.min_n = nv_ro08(bios, data + 20);
-               info->vco1.max_n = nv_ro08(bios, data + 21);
-               info->vco1.min_m = nv_ro08(bios, data + 22);
-               info->vco1.max_m = nv_ro08(bios, data + 23);
-               info->vco2.min_n = nv_ro08(bios, data + 24);
-               info->vco2.max_n = nv_ro08(bios, data + 25);
-               info->vco2.min_m = nv_ro08(bios, data + 26);
-               info->vco2.max_m = nv_ro08(bios, data + 27);
-
-               info->max_p = nv_ro08(bios, data + 29);
+               info->vco1.min_freq = nvbios_rd16(bios, data + 4) * 1000;
+               info->vco1.max_freq = nvbios_rd16(bios, data + 6) * 1000;
+               info->vco2.min_freq = nvbios_rd16(bios, data + 8) * 1000;
+               info->vco2.max_freq = nvbios_rd16(bios, data + 10) * 1000;
+               info->vco1.min_inputfreq = nvbios_rd16(bios, data + 12) * 1000;
+               info->vco2.min_inputfreq = nvbios_rd16(bios, data + 14) * 1000;
+               info->vco1.max_inputfreq = nvbios_rd16(bios, data + 16) * 1000;
+               info->vco2.max_inputfreq = nvbios_rd16(bios, data + 18) * 1000;
+               info->vco1.min_n = nvbios_rd08(bios, data + 20);
+               info->vco1.max_n = nvbios_rd08(bios, data + 21);
+               info->vco1.min_m = nvbios_rd08(bios, data + 22);
+               info->vco1.max_m = nvbios_rd08(bios, data + 23);
+               info->vco2.min_n = nvbios_rd08(bios, data + 24);
+               info->vco2.max_n = nvbios_rd08(bios, data + 25);
+               info->vco2.min_m = nvbios_rd08(bios, data + 26);
+               info->vco2.max_m = nvbios_rd08(bios, data + 27);
+
+               info->max_p = nvbios_rd08(bios, data + 29);
                info->max_p_usable = info->max_p;
                if (bios->version.chip < 0x60)
                        info->max_p_usable = 0x6;
-               info->bias_p = nv_ro08(bios, data + 30);
+               info->bias_p = nvbios_rd08(bios, data + 30);
 
                if (len > 0x22)
-                       info->refclk = nv_ro32(bios, data + 31);
+                       info->refclk = nvbios_rd32(bios, data + 31);
                break;
        case 0x30:
-               data = nv_ro16(bios, data + 1);
-
-               info->vco1.min_freq = nv_ro16(bios, data + 0) * 1000;
-               info->vco1.max_freq = nv_ro16(bios, data + 2) * 1000;
-               info->vco2.min_freq = nv_ro16(bios, data + 4) * 1000;
-               info->vco2.max_freq = nv_ro16(bios, data + 6) * 1000;
-               info->vco1.min_inputfreq = nv_ro16(bios, data + 8) * 1000;
-               info->vco2.min_inputfreq = nv_ro16(bios, data + 10) * 1000;
-               info->vco1.max_inputfreq = nv_ro16(bios, data + 12) * 1000;
-               info->vco2.max_inputfreq = nv_ro16(bios, data + 14) * 1000;
-               info->vco1.min_n = nv_ro08(bios, data + 16);
-               info->vco1.max_n = nv_ro08(bios, data + 17);
-               info->vco1.min_m = nv_ro08(bios, data + 18);
-               info->vco1.max_m = nv_ro08(bios, data + 19);
-               info->vco2.min_n = nv_ro08(bios, data + 20);
-               info->vco2.max_n = nv_ro08(bios, data + 21);
-               info->vco2.min_m = nv_ro08(bios, data + 22);
-               info->vco2.max_m = nv_ro08(bios, data + 23);
-               info->max_p_usable = info->max_p = nv_ro08(bios, data + 25);
-               info->bias_p = nv_ro08(bios, data + 27);
-               info->refclk = nv_ro32(bios, data + 28);
+               data = nvbios_rd16(bios, data + 1);
+
+               info->vco1.min_freq = nvbios_rd16(bios, data + 0) * 1000;
+               info->vco1.max_freq = nvbios_rd16(bios, data + 2) * 1000;
+               info->vco2.min_freq = nvbios_rd16(bios, data + 4) * 1000;
+               info->vco2.max_freq = nvbios_rd16(bios, data + 6) * 1000;
+               info->vco1.min_inputfreq = nvbios_rd16(bios, data + 8) * 1000;
+               info->vco2.min_inputfreq = nvbios_rd16(bios, data + 10) * 1000;
+               info->vco1.max_inputfreq = nvbios_rd16(bios, data + 12) * 1000;
+               info->vco2.max_inputfreq = nvbios_rd16(bios, data + 14) * 1000;
+               info->vco1.min_n = nvbios_rd08(bios, data + 16);
+               info->vco1.max_n = nvbios_rd08(bios, data + 17);
+               info->vco1.min_m = nvbios_rd08(bios, data + 18);
+               info->vco1.max_m = nvbios_rd08(bios, data + 19);
+               info->vco2.min_n = nvbios_rd08(bios, data + 20);
+               info->vco2.max_n = nvbios_rd08(bios, data + 21);
+               info->vco2.min_m = nvbios_rd08(bios, data + 22);
+               info->vco2.max_m = nvbios_rd08(bios, data + 23);
+               info->max_p_usable = info->max_p = nvbios_rd08(bios, data + 25);
+               info->bias_p = nvbios_rd08(bios, data + 27);
+               info->refclk = nvbios_rd32(bios, data + 28);
                break;
        case 0x40:
-               info->refclk = nv_ro16(bios, data + 9) * 1000;
-               data = nv_ro16(bios, data + 1);
-
-               info->vco1.min_freq = nv_ro16(bios, data + 0) * 1000;
-               info->vco1.max_freq = nv_ro16(bios, data + 2) * 1000;
-               info->vco1.min_inputfreq = nv_ro16(bios, data + 4) * 1000;
-               info->vco1.max_inputfreq = nv_ro16(bios, data + 6) * 1000;
-               info->vco1.min_m = nv_ro08(bios, data + 8);
-               info->vco1.max_m = nv_ro08(bios, data + 9);
-               info->vco1.min_n = nv_ro08(bios, data + 10);
-               info->vco1.max_n = nv_ro08(bios, data + 11);
-               info->min_p = nv_ro08(bios, data + 12);
-               info->max_p = nv_ro08(bios, data + 13);
+               info->refclk = nvbios_rd16(bios, data + 9) * 1000;
+               data = nvbios_rd16(bios, data + 1);
+
+               info->vco1.min_freq = nvbios_rd16(bios, data + 0) * 1000;
+               info->vco1.max_freq = nvbios_rd16(bios, data + 2) * 1000;
+               info->vco1.min_inputfreq = nvbios_rd16(bios, data + 4) * 1000;
+               info->vco1.max_inputfreq = nvbios_rd16(bios, data + 6) * 1000;
+               info->vco1.min_m = nvbios_rd08(bios, data + 8);
+               info->vco1.max_m = nvbios_rd08(bios, data + 9);
+               info->vco1.min_n = nvbios_rd08(bios, data + 10);
+               info->vco1.max_n = nvbios_rd08(bios, data + 11);
+               info->min_p = nvbios_rd08(bios, data + 12);
+               info->max_p = nvbios_rd08(bios, data + 13);
                break;
        default:
-               nv_error(bios, "unknown pll limits version 0x%02x\n", ver);
+               nvkm_error(subdev, "unknown pll limits version 0x%02x\n", ver);
                return -EINVAL;
        }
 
        if (!info->refclk) {
-               info->refclk = nv_device(bios)->crystal;
+               info->refclk = device->crystal;
                if (bios->version.chip == 0x51) {
-                       u32 sel_clk = nv_rd32(bios, 0x680524);
+                       u32 sel_clk = nvkm_rd32(device, 0x680524);
                        if ((info->reg == 0x680508 && sel_clk & 0x20) ||
                            (info->reg == 0x680520 && sel_clk & 0x80)) {
-                               if (nv_rdvgac(bios, 0, 0x27) < 0xa3)
+                               if (nvkm_rdvgac(device, 0, 0x27) < 0xa3)
                                        info->refclk = 200000;
                                else
                                        info->refclk = 25000;
@@ -380,8 +382,8 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
         * with an empty limit table (seen on nv18)
         */
        if (!info->vco1.max_freq) {
-               info->vco1.max_freq = nv_ro32(bios, bios->bmp_offset + 67);
-               info->vco1.min_freq = nv_ro32(bios, bios->bmp_offset + 71);
+               info->vco1.max_freq = nvbios_rd32(bios, bios->bmp_offset + 67);
+               info->vco1.min_freq = nvbios_rd32(bios, bios->bmp_offset + 71);
                if (bmp_version(bios) < 0x0506) {
                        info->vco1.max_freq = 256000;
                        info->vco1.min_freq = 128000;
@@ -393,7 +395,7 @@ nvbios_pll_parse(struct nvkm_bios *bios, u32 type, struct nvbios_pll *info)
                info->vco1.max_n = 0xff;
                info->vco1.min_m = 0x1;
 
-               if (nv_device(bios)->crystal == 13500) {
+               if (device->crystal == 13500) {
                        /* nv05 does this, nv11 doesn't, nv10 unknown */
                        if (bios->version.chip < 0x11)
                                info->vco1.min_m = 0x7;