Commit 1a72f2bd authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fb: make use of M0203 routines for ram type determination

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 4766ec53
...@@ -23,37 +23,30 @@ ...@@ -23,37 +23,30 @@
*/ */
#include <subdev/bios.h> #include <subdev/bios.h>
#include <subdev/bios/bit.h> #include <subdev/bios/M0203.h>
#include "priv.h" #include "priv.h"
int int
nouveau_fb_bios_memtype(struct nouveau_bios *bios) nouveau_fb_bios_memtype(struct nouveau_bios *bios)
{ {
struct bit_entry M; const u8 ramcfg = (nv_rd32(bios, 0x101000) & 0x0000003c) >> 2;
u8 ramcfg; struct nvbios_M0203E M0203E;
u8 ver, hdr;
ramcfg = (nv_rd32(bios, 0x101000) & 0x0000003c) >> 2;
if (!bit_entry(bios, 'M', &M) && M.version == 2 && M.length >= 5) { if (nvbios_M0203Em(bios, ramcfg, &ver, &hdr, &M0203E)) {
u16 table = nv_ro16(bios, M.offset + 3); switch (M0203E.type) {
u8 version = nv_ro08(bios, table + 0); case M0203E_TYPE_DDR2 : return NV_MEM_TYPE_DDR2;
u8 header = nv_ro08(bios, table + 1); case M0203E_TYPE_DDR3 : return NV_MEM_TYPE_DDR3;
u8 record = nv_ro08(bios, table + 2); case M0203E_TYPE_GDDR3: return NV_MEM_TYPE_GDDR3;
u8 entries = nv_ro08(bios, table + 3); case M0203E_TYPE_GDDR5: return NV_MEM_TYPE_GDDR5;
if (table && version == 0x10 && ramcfg < entries) { default:
u16 entry = table + header + (ramcfg * record); nv_warn(bios, "M0203E type %02x\n", M0203E.type);
switch (nv_ro08(bios, entry) & 0x0f) { return NV_MEM_TYPE_UNKNOWN;
case 0: return NV_MEM_TYPE_DDR2;
case 1: return NV_MEM_TYPE_DDR3;
case 2: return NV_MEM_TYPE_GDDR3;
case 3: return NV_MEM_TYPE_GDDR5;
default:
break;
}
} }
} }
nv_warn(bios, "M0203E not matched!\n");
return NV_MEM_TYPE_UNKNOWN; return NV_MEM_TYPE_UNKNOWN;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment