diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2014-11-03 22:04:35 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2014-12-02 00:44:05 -0500 |
commit | 1a72f2bd1e2e5e52de5f2f3e6f7876d6decc4caa (patch) | |
tree | 1beffa5612f650c98bbb81c567a13f90e4ba4249 | |
parent | 4766ec53945f14f134fc51de782b362a51351cb1 (diff) |
drm/nouveau/fb: make use of M0203 routines for ram type determination
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/fb/base.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/base.c b/drivers/gpu/drm/nouveau/core/subdev/fb/base.c index f009d8a39d9d..c866148c440f 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/fb/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/base.c | |||
@@ -23,37 +23,30 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <subdev/bios.h> | 25 | #include <subdev/bios.h> |
26 | #include <subdev/bios/bit.h> | 26 | #include <subdev/bios/M0203.h> |
27 | 27 | ||
28 | #include "priv.h" | 28 | #include "priv.h" |
29 | 29 | ||
30 | int | 30 | int |
31 | nouveau_fb_bios_memtype(struct nouveau_bios *bios) | 31 | nouveau_fb_bios_memtype(struct nouveau_bios *bios) |
32 | { | 32 | { |
33 | struct bit_entry M; | 33 | const u8 ramcfg = (nv_rd32(bios, 0x101000) & 0x0000003c) >> 2; |
34 | u8 ramcfg; | 34 | struct nvbios_M0203E M0203E; |
35 | 35 | u8 ver, hdr; | |
36 | ramcfg = (nv_rd32(bios, 0x101000) & 0x0000003c) >> 2; | 36 | |
37 | if (!bit_entry(bios, 'M', &M) && M.version == 2 && M.length >= 5) { | 37 | if (nvbios_M0203Em(bios, ramcfg, &ver, &hdr, &M0203E)) { |
38 | u16 table = nv_ro16(bios, M.offset + 3); | 38 | switch (M0203E.type) { |
39 | u8 version = nv_ro08(bios, table + 0); | 39 | case M0203E_TYPE_DDR2 : return NV_MEM_TYPE_DDR2; |
40 | u8 header = nv_ro08(bios, table + 1); | 40 | case M0203E_TYPE_DDR3 : return NV_MEM_TYPE_DDR3; |
41 | u8 record = nv_ro08(bios, table + 2); | 41 | case M0203E_TYPE_GDDR3: return NV_MEM_TYPE_GDDR3; |
42 | u8 entries = nv_ro08(bios, table + 3); | 42 | case M0203E_TYPE_GDDR5: return NV_MEM_TYPE_GDDR5; |
43 | if (table && version == 0x10 && ramcfg < entries) { | 43 | default: |
44 | u16 entry = table + header + (ramcfg * record); | 44 | nv_warn(bios, "M0203E type %02x\n", M0203E.type); |
45 | switch (nv_ro08(bios, entry) & 0x0f) { | 45 | return NV_MEM_TYPE_UNKNOWN; |
46 | case 0: return NV_MEM_TYPE_DDR2; | ||
47 | case 1: return NV_MEM_TYPE_DDR3; | ||
48 | case 2: return NV_MEM_TYPE_GDDR3; | ||
49 | case 3: return NV_MEM_TYPE_GDDR5; | ||
50 | default: | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | } | 46 | } |
55 | } | 47 | } |
56 | 48 | ||
49 | nv_warn(bios, "M0203E not matched!\n"); | ||
57 | return NV_MEM_TYPE_UNKNOWN; | 50 | return NV_MEM_TYPE_UNKNOWN; |
58 | } | 51 | } |
59 | 52 | ||