aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyuw@linux.intel.com>2009-11-10 12:25:25 -0500
committerEric Anholt <eric@anholt.net>2010-02-26 16:23:19 -0500
commit14bc490bbdf1b194ad1f5f3d2a0a27edfdf78986 (patch)
treeec3aa6b118d7f9750bdb12e45af122748978a6d6 /drivers/char
parent21099537dbacc5c8999d833e6bfd1b72edd89189 (diff)
drm/i915, agp/intel: Fix stolen memory size on Sandybridge
New memory control config reg at 0x50 should be used for stolen memory size detection on Sandybridge. Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/intel-agp.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index c3c870bf5678..9a551bc34c39 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -150,6 +150,25 @@ extern int agp_memory_reserved;
150#define INTEL_I7505_AGPCTRL 0x70 150#define INTEL_I7505_AGPCTRL 0x70
151#define INTEL_I7505_MCHCFG 0x50 151#define INTEL_I7505_MCHCFG 0x50
152 152
153#define SNB_GMCH_CTRL 0x50
154#define SNB_GMCH_GMS_STOLEN_MASK 0xF8
155#define SNB_GMCH_GMS_STOLEN_32M (1 << 3)
156#define SNB_GMCH_GMS_STOLEN_64M (2 << 3)
157#define SNB_GMCH_GMS_STOLEN_96M (3 << 3)
158#define SNB_GMCH_GMS_STOLEN_128M (4 << 3)
159#define SNB_GMCH_GMS_STOLEN_160M (5 << 3)
160#define SNB_GMCH_GMS_STOLEN_192M (6 << 3)
161#define SNB_GMCH_GMS_STOLEN_224M (7 << 3)
162#define SNB_GMCH_GMS_STOLEN_256M (8 << 3)
163#define SNB_GMCH_GMS_STOLEN_288M (9 << 3)
164#define SNB_GMCH_GMS_STOLEN_320M (0xa << 3)
165#define SNB_GMCH_GMS_STOLEN_352M (0xb << 3)
166#define SNB_GMCH_GMS_STOLEN_384M (0xc << 3)
167#define SNB_GMCH_GMS_STOLEN_416M (0xd << 3)
168#define SNB_GMCH_GMS_STOLEN_448M (0xe << 3)
169#define SNB_GMCH_GMS_STOLEN_480M (0xf << 3)
170#define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3)
171
153static const struct aper_size_info_fixed intel_i810_sizes[] = 172static const struct aper_size_info_fixed intel_i810_sizes[] =
154{ 173{
155 {64, 16384, 4}, 174 {64, 16384, 4},
@@ -621,7 +640,7 @@ static struct aper_size_info_fixed intel_i830_sizes[] =
621static void intel_i830_init_gtt_entries(void) 640static void intel_i830_init_gtt_entries(void)
622{ 641{
623 u16 gmch_ctrl; 642 u16 gmch_ctrl;
624 int gtt_entries; 643 int gtt_entries = 0;
625 u8 rdct; 644 u8 rdct;
626 int local = 0; 645 int local = 0;
627 static const int ddt[4] = { 0, 16, 32, 64 }; 646 static const int ddt[4] = { 0, 16, 32, 64 };
@@ -715,10 +734,61 @@ static void intel_i830_init_gtt_entries(void)
715 } 734 }
716 } else if (agp_bridge->dev->device == 735 } else if (agp_bridge->dev->device ==
717 PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB) { 736 PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB) {
718 /* XXX: This is what my A1 silicon has. What's the right 737 /*
719 * answer? 738 * SandyBridge has new memory control reg at 0x50.w
720 */ 739 */
721 gtt_entries = MB(64) - KB(size); 740 u16 snb_gmch_ctl;
741 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
742 switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) {
743 case SNB_GMCH_GMS_STOLEN_32M:
744 gtt_entries = MB(32) - KB(size);
745 break;
746 case SNB_GMCH_GMS_STOLEN_64M:
747 gtt_entries = MB(64) - KB(size);
748 break;
749 case SNB_GMCH_GMS_STOLEN_96M:
750 gtt_entries = MB(96) - KB(size);
751 break;
752 case SNB_GMCH_GMS_STOLEN_128M:
753 gtt_entries = MB(128) - KB(size);
754 break;
755 case SNB_GMCH_GMS_STOLEN_160M:
756 gtt_entries = MB(160) - KB(size);
757 break;
758 case SNB_GMCH_GMS_STOLEN_192M:
759 gtt_entries = MB(192) - KB(size);
760 break;
761 case SNB_GMCH_GMS_STOLEN_224M:
762 gtt_entries = MB(224) - KB(size);
763 break;
764 case SNB_GMCH_GMS_STOLEN_256M:
765 gtt_entries = MB(256) - KB(size);
766 break;
767 case SNB_GMCH_GMS_STOLEN_288M:
768 gtt_entries = MB(288) - KB(size);
769 break;
770 case SNB_GMCH_GMS_STOLEN_320M:
771 gtt_entries = MB(320) - KB(size);
772 break;
773 case SNB_GMCH_GMS_STOLEN_352M:
774 gtt_entries = MB(352) - KB(size);
775 break;
776 case SNB_GMCH_GMS_STOLEN_384M:
777 gtt_entries = MB(384) - KB(size);
778 break;
779 case SNB_GMCH_GMS_STOLEN_416M:
780 gtt_entries = MB(416) - KB(size);
781 break;
782 case SNB_GMCH_GMS_STOLEN_448M:
783 gtt_entries = MB(448) - KB(size);
784 break;
785 case SNB_GMCH_GMS_STOLEN_480M:
786 gtt_entries = MB(480) - KB(size);
787 break;
788 case SNB_GMCH_GMS_STOLEN_512M:
789 gtt_entries = MB(512) - KB(size);
790 break;
791 }
722 } else { 792 } else {
723 switch (gmch_ctrl & I855_GMCH_GMS_MASK) { 793 switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
724 case I855_GMCH_GMS_STOLEN_1M: 794 case I855_GMCH_GMS_STOLEN_1M: