aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-05-19 03:50:58 -0400
committerJonathan Corbet <corbet@lwn.net>2010-04-20 16:23:18 -0400
commitb72a5070c74f5ca9a45a03c2d625daab66d0a820 (patch)
treef388d41f100b0c4a3b7ef6c41066201f8f9ed895 /drivers/video
parent109771a68bedda77606500dc14455eca92df6769 (diff)
viafb: use proper pci config API
This patch alters viafb to use the proper Linux in-kernel API to access PCI configuration space, rather than poking at I/O ports by itself. Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: ScottFang@viatech.com.cn Cc: JosephChan@via.com.tw Signed-off-by: Harald Welte <HaraldWelte@viatech.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/via/hw.c62
-rw-r--r--drivers/video/via/hw.h4
-rw-r--r--drivers/video/via/viafbdev.c4
3 files changed, 44 insertions, 26 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index f2583b1b527f..c94bcce71eaf 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -2473,24 +2473,37 @@ static void disable_second_display_channel(void)
2473 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); 2473 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
2474} 2474}
2475 2475
2476static u_int16_t via_function3[] = {
2477 CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
2478 CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
2479 P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3,
2480};
2481
2482/* Get the BIOS-configured framebuffer size from PCI configuration space
2483 * of function 3 in the respective chipset */
2476int viafb_get_fb_size_from_pci(void) 2484int viafb_get_fb_size_from_pci(void)
2477{ 2485{
2478 unsigned long configid, deviceid, FBSize = 0; 2486 int i;
2479 int VideoMemSize; 2487 u_int8_t offset = 0;
2480 int DeviceFound = false; 2488 u_int32_t FBSize;
2481 2489 u_int32_t VideoMemSize;
2482 for (configid = 0x80000000; configid < 0x80010800; configid += 0x100) { 2490
2483 outl(configid, (unsigned long)0xCF8); 2491 /* search for the "FUNCTION3" device in this chipset */
2484 deviceid = (inl((unsigned long)0xCFC) >> 16) & 0xffff; 2492 for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
2485 2493 struct pci_dev *pdev;
2486 switch (deviceid) { 2494
2487 case CLE266: 2495 pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
2488 case KM400: 2496 NULL);
2489 outl(configid + 0xE0, (unsigned long)0xCF8); 2497 if (!pdev)
2490 FBSize = inl((unsigned long)0xCFC); 2498 continue;
2491 DeviceFound = true; /* Found device id */ 2499
2492 break; 2500 DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
2493 2501
2502 switch (pdev->device) {
2503 case CLE266_FUNCTION3:
2504 case KM400_FUNCTION3:
2505 offset = 0xE0;
2506 break;
2494 case CN400_FUNCTION3: 2507 case CN400_FUNCTION3:
2495 case CN700_FUNCTION3: 2508 case CN700_FUNCTION3:
2496 case CX700_FUNCTION3: 2509 case CX700_FUNCTION3:
@@ -2500,21 +2513,22 @@ int viafb_get_fb_size_from_pci(void)
2500 case P4M900_FUNCTION3: 2513 case P4M900_FUNCTION3:
2501 case VX800_FUNCTION3: 2514 case VX800_FUNCTION3:
2502 case VX855_FUNCTION3: 2515 case VX855_FUNCTION3:
2503 /*case CN750_FUNCTION3: */ 2516 /*case CN750_FUNCTION3: */
2504 outl(configid + 0xA0, (unsigned long)0xCF8); 2517 offset = 0xA0;
2505 FBSize = inl((unsigned long)0xCFC);
2506 DeviceFound = true; /* Found device id */
2507 break;
2508
2509 default:
2510 break; 2518 break;
2511 } 2519 }
2512 2520
2513 if (DeviceFound) 2521 if (!offset)
2514 break; 2522 break;
2523
2524 pci_read_config_dword(pdev, offset, &FBSize);
2525 pci_dev_put(pdev);
2515 } 2526 }
2516 2527
2517 DEBUG_MSG(KERN_INFO "Device ID = %lx\n", deviceid); 2528 if (!offset) {
2529 printk(KERN_ERR "cannot determine framebuffer size\n");
2530 return -EIO;
2531 }
2518 2532
2519 FBSize = FBSize & 0x00007000; 2533 FBSize = FBSize & 0x00007000;
2520 DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize); 2534 DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index 12ef32d334cb..d6b25acd4a99 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -823,8 +823,8 @@ struct iga2_crtc_timing {
823}; 823};
824 824
825/* device ID */ 825/* device ID */
826#define CLE266 0x3123 826#define CLE266_FUNCTION3 0x3123
827#define KM400 0x3205 827#define KM400_FUNCTION3 0x3205
828#define CN400_FUNCTION2 0x2259 828#define CN400_FUNCTION2 0x2259
829#define CN400_FUNCTION3 0x3259 829#define CN400_FUNCTION3 0x3259
830/* support VT3314 chipset */ 830/* support VT3314 chipset */
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index b7018ef69778..8af405bf077b 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1782,6 +1782,10 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
1782 viafb_init_chip_info(pdev, ent); 1782 viafb_init_chip_info(pdev, ent);
1783 viaparinfo->fbmem = pci_resource_start(pdev, 0); 1783 viaparinfo->fbmem = pci_resource_start(pdev, 0);
1784 viaparinfo->memsize = viafb_get_fb_size_from_pci(); 1784 viaparinfo->memsize = viafb_get_fb_size_from_pci();
1785 if (viaparinfo->memsize < 0) {
1786 rc = viaparinfo->memsize;
1787 goto out_delete_i2c;
1788 }
1785 viaparinfo->fbmem_free = viaparinfo->memsize; 1789 viaparinfo->fbmem_free = viaparinfo->memsize;
1786 viaparinfo->fbmem_used = 0; 1790 viaparinfo->fbmem_used = 0;
1787 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem, 1791 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem,