diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-08-29 11:27:36 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-08 16:20:17 -0400 |
commit | f67eab664c47b261517b09812477de9a1780b426 (patch) | |
tree | 84b2cf266d05f16aff57f27e76f2f3363e327c24 /drivers/char | |
parent | fdfb58a965486d2afea4ef0f9b8153dab9b98b2e (diff) |
intel-gtt: consolidate the gtt ioremap calls
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 7359fbe94428..73082ef09dc1 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -94,6 +94,7 @@ static struct _intel_private { | |||
94 | struct pci_dev *pcidev; /* device one */ | 94 | struct pci_dev *pcidev; /* device one */ |
95 | struct pci_dev *bridge_dev; | 95 | struct pci_dev *bridge_dev; |
96 | u8 __iomem *registers; | 96 | u8 __iomem *registers; |
97 | phys_addr_t gtt_bus_addr; | ||
97 | u32 __iomem *gtt; /* I915G */ | 98 | u32 __iomem *gtt; /* I915G */ |
98 | int num_dcache_entries; | 99 | int num_dcache_entries; |
99 | union { | 100 | union { |
@@ -799,10 +800,27 @@ static unsigned int intel_gtt_mappable_entries(void) | |||
799 | 800 | ||
800 | static int intel_gtt_init(void) | 801 | static int intel_gtt_init(void) |
801 | { | 802 | { |
803 | u32 gtt_map_size; | ||
804 | |||
805 | intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries(); | ||
806 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); | ||
807 | |||
808 | gtt_map_size = intel_private.base.gtt_total_entries * 4; | ||
809 | |||
810 | intel_private.gtt = ioremap(intel_private.gtt_bus_addr, | ||
811 | gtt_map_size); | ||
812 | if (!intel_private.gtt) { | ||
813 | iounmap(intel_private.registers); | ||
814 | return -ENOMEM; | ||
815 | } | ||
816 | |||
817 | global_cache_flush(); /* FIXME: ? */ | ||
818 | |||
802 | /* we have to call this as early as possible after the MMIO base address is known */ | 819 | /* we have to call this as early as possible after the MMIO base address is known */ |
803 | intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); | 820 | intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); |
804 | if (intel_private.base.gtt_stolen_entries == 0) { | 821 | if (intel_private.base.gtt_stolen_entries == 0) { |
805 | iounmap(intel_private.registers); | 822 | iounmap(intel_private.registers); |
823 | iounmap(intel_private.gtt); | ||
806 | return -ENOMEM; | 824 | return -ENOMEM; |
807 | } | 825 | } |
808 | 826 | ||
@@ -883,7 +901,6 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge) | |||
883 | int page_order, ret; | 901 | int page_order, ret; |
884 | struct aper_size_info_fixed *size; | 902 | struct aper_size_info_fixed *size; |
885 | int num_entries; | 903 | int num_entries; |
886 | int gtt_map_size; | ||
887 | u32 temp; | 904 | u32 temp; |
888 | 905 | ||
889 | size = agp_bridge->current_size; | 906 | size = agp_bridge->current_size; |
@@ -898,17 +915,8 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge) | |||
898 | if (!intel_private.registers) | 915 | if (!intel_private.registers) |
899 | return -ENOMEM; | 916 | return -ENOMEM; |
900 | 917 | ||
901 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); | 918 | intel_private.gtt_bus_addr = temp + I810_PTE_BASE; |
902 | gtt_map_size = intel_private.base.gtt_total_entries * 4; | ||
903 | |||
904 | intel_private.gtt = ioremap(temp + I810_PTE_BASE, gtt_map_size); | ||
905 | if (!intel_private.gtt) { | ||
906 | iounmap(intel_private.registers); | ||
907 | return -ENOMEM; | ||
908 | } | ||
909 | |||
910 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; | 919 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
911 | global_cache_flush(); /* FIXME: ?? */ | ||
912 | 920 | ||
913 | ret = intel_gtt_init(); | 921 | ret = intel_gtt_init(); |
914 | if (ret != 0) | 922 | if (ret != 0) |
@@ -1278,7 +1286,6 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) | |||
1278 | struct aper_size_info_fixed *size; | 1286 | struct aper_size_info_fixed *size; |
1279 | int num_entries; | 1287 | int num_entries; |
1280 | u32 temp, temp2; | 1288 | u32 temp, temp2; |
1281 | int gtt_map_size; | ||
1282 | 1289 | ||
1283 | size = agp_bridge->current_size; | 1290 | size = agp_bridge->current_size; |
1284 | page_order = size->page_order; | 1291 | page_order = size->page_order; |
@@ -1294,23 +1301,12 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) | |||
1294 | if (!intel_private.registers) | 1301 | if (!intel_private.registers) |
1295 | return -ENOMEM; | 1302 | return -ENOMEM; |
1296 | 1303 | ||
1297 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); | 1304 | intel_private.gtt_bus_addr = temp2; |
1298 | gtt_map_size = intel_private.base.gtt_total_entries * 4; | ||
1299 | |||
1300 | intel_private.gtt = ioremap(temp2, gtt_map_size); | ||
1301 | if (!intel_private.gtt) { | ||
1302 | iounmap(intel_private.registers); | ||
1303 | return -ENOMEM; | ||
1304 | } | ||
1305 | |||
1306 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; | 1305 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
1307 | global_cache_flush(); /* FIXME: ? */ | ||
1308 | 1306 | ||
1309 | ret = intel_gtt_init(); | 1307 | ret = intel_gtt_init(); |
1310 | if (ret != 0) { | 1308 | if (ret != 0) |
1311 | iounmap(intel_private.gtt); | ||
1312 | return ret; | 1309 | return ret; |
1313 | } | ||
1314 | 1310 | ||
1315 | agp_bridge->gatt_table = NULL; | 1311 | agp_bridge->gatt_table = NULL; |
1316 | 1312 | ||
@@ -1348,7 +1344,7 @@ static unsigned long intel_gen6_mask_memory(struct agp_bridge_data *bridge, | |||
1348 | return addr | bridge->driver->masks[type].mask; | 1344 | return addr | bridge->driver->masks[type].mask; |
1349 | } | 1345 | } |
1350 | 1346 | ||
1351 | static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | 1347 | static void intel_i965_get_gtt_range(int *gtt_offset) |
1352 | { | 1348 | { |
1353 | switch (INTEL_GTT_GEN) { | 1349 | switch (INTEL_GTT_GEN) { |
1354 | case 5: | 1350 | case 5: |
@@ -1360,8 +1356,6 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | |||
1360 | *gtt_offset = KB(512); | 1356 | *gtt_offset = KB(512); |
1361 | break; | 1357 | break; |
1362 | } | 1358 | } |
1363 | |||
1364 | *gtt_size = intel_private.base.gtt_total_entries * 4; | ||
1365 | } | 1359 | } |
1366 | 1360 | ||
1367 | /* The intel i965 automatically initializes the agp aperture during POST. | 1361 | /* The intel i965 automatically initializes the agp aperture during POST. |
@@ -1373,7 +1367,7 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) | |||
1373 | struct aper_size_info_fixed *size; | 1367 | struct aper_size_info_fixed *size; |
1374 | int num_entries; | 1368 | int num_entries; |
1375 | u32 temp; | 1369 | u32 temp; |
1376 | int gtt_offset, gtt_size; | 1370 | int gtt_offset; |
1377 | 1371 | ||
1378 | size = agp_bridge->current_size; | 1372 | size = agp_bridge->current_size; |
1379 | page_order = size->page_order; | 1373 | page_order = size->page_order; |
@@ -1388,25 +1382,13 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) | |||
1388 | if (!intel_private.registers) | 1382 | if (!intel_private.registers) |
1389 | return -ENOMEM; | 1383 | return -ENOMEM; |
1390 | 1384 | ||
1391 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); | 1385 | intel_i965_get_gtt_range(>t_offset); |
1392 | 1386 | intel_private.gtt_bus_addr = temp + gtt_offset; | |
1393 | intel_i965_get_gtt_range(>t_offset, >t_size); | ||
1394 | |||
1395 | intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size); | ||
1396 | |||
1397 | if (!intel_private.gtt) { | ||
1398 | iounmap(intel_private.gtt); | ||
1399 | return -ENOMEM; | ||
1400 | } | ||
1401 | |||
1402 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; | 1387 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
1403 | global_cache_flush(); /* FIXME: ? */ | ||
1404 | 1388 | ||
1405 | ret = intel_gtt_init(); | 1389 | ret = intel_gtt_init(); |
1406 | if (ret != 0) { | 1390 | if (ret != 0) |
1407 | iounmap(intel_private.gtt); | ||
1408 | return ret; | 1391 | return ret; |
1409 | } | ||
1410 | 1392 | ||
1411 | agp_bridge->gatt_table = NULL; | 1393 | agp_bridge->gatt_table = NULL; |
1412 | 1394 | ||