diff options
author | Harald Welte <laforge@gnumonks.org> | 2009-09-22 19:47:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:53 -0400 |
commit | 2d280f758b2044151cb77fdd9c59d1903bbb6a19 (patch) | |
tree | adb973c31e8d061e7f4cabe30c81a34497fdab04 /drivers/video/via/hw.c | |
parent | 3a32456909380150a92ed207c160a3a0bd687e14 (diff) |
viafb: make viafb a first-class citizen using pci_driver
Signed-off-by: Harald Welte <HaraldWelte@viatech.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Scott Fang <ScottFang@viatech.com.cn>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/via/hw.c')
-rw-r--r-- | drivers/video/via/hw.c | 115 |
1 files changed, 9 insertions, 106 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index 95faf8be47aa..3e083ff67ae2 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -21,22 +21,6 @@ | |||
21 | 21 | ||
22 | #include "global.h" | 22 | #include "global.h" |
23 | 23 | ||
24 | static const struct pci_device_id_info pciidlist[] = { | ||
25 | {PCI_VIA_VENDOR_ID, UNICHROME_CLE266_DID, UNICHROME_CLE266}, | ||
26 | {PCI_VIA_VENDOR_ID, UNICHROME_PM800_DID, UNICHROME_PM800}, | ||
27 | {PCI_VIA_VENDOR_ID, UNICHROME_K400_DID, UNICHROME_K400}, | ||
28 | {PCI_VIA_VENDOR_ID, UNICHROME_K800_DID, UNICHROME_K800}, | ||
29 | {PCI_VIA_VENDOR_ID, UNICHROME_CN700_DID, UNICHROME_CN700}, | ||
30 | {PCI_VIA_VENDOR_ID, UNICHROME_P4M890_DID, UNICHROME_P4M890}, | ||
31 | {PCI_VIA_VENDOR_ID, UNICHROME_K8M890_DID, UNICHROME_K8M890}, | ||
32 | {PCI_VIA_VENDOR_ID, UNICHROME_CX700_DID, UNICHROME_CX700}, | ||
33 | {PCI_VIA_VENDOR_ID, UNICHROME_P4M900_DID, UNICHROME_P4M900}, | ||
34 | {PCI_VIA_VENDOR_ID, UNICHROME_CN750_DID, UNICHROME_CN750}, | ||
35 | {PCI_VIA_VENDOR_ID, UNICHROME_VX800_DID, UNICHROME_VX800}, | ||
36 | {PCI_VIA_VENDOR_ID, UNICHROME_VX855_DID, UNICHROME_VX855}, | ||
37 | {0, 0, 0} | ||
38 | }; | ||
39 | |||
40 | static struct pll_map pll_value[] = { | 24 | static struct pll_map pll_value[] = { |
41 | {CLK_25_175M, CLE266_PLL_25_175M, K800_PLL_25_175M, | 25 | {CLK_25_175M, CLE266_PLL_25_175M, K800_PLL_25_175M, |
42 | CX700_25_175M, VX855_25_175M}, | 26 | CX700_25_175M, VX855_25_175M}, |
@@ -542,7 +526,8 @@ static void set_dvi_output_path(int set_iga, int output_interface); | |||
542 | static void set_lcd_output_path(int set_iga, int output_interface); | 526 | static void set_lcd_output_path(int set_iga, int output_interface); |
543 | static int search_mode_setting(int ModeInfoIndex); | 527 | static int search_mode_setting(int ModeInfoIndex); |
544 | static void load_fix_bit_crtc_reg(void); | 528 | static void load_fix_bit_crtc_reg(void); |
545 | static void init_gfx_chip_info(void); | 529 | static void init_gfx_chip_info(struct pci_dev *pdev, |
530 | const struct pci_device_id *pdi); | ||
546 | static void init_tmds_chip_info(void); | 531 | static void init_tmds_chip_info(void); |
547 | static void init_lvds_chip_info(void); | 532 | static void init_lvds_chip_info(void); |
548 | static void device_screen_off(void); | 533 | static void device_screen_off(void); |
@@ -552,7 +537,6 @@ static void device_off(void); | |||
552 | static void device_on(void); | 537 | static void device_on(void); |
553 | static void enable_second_display_channel(void); | 538 | static void enable_second_display_channel(void); |
554 | static void disable_second_display_channel(void); | 539 | static void disable_second_display_channel(void); |
555 | static int get_fb_size_from_pci(void); | ||
556 | 540 | ||
557 | void viafb_write_reg(u8 index, u16 io_port, u8 data) | 541 | void viafb_write_reg(u8 index, u16 io_port, u8 data) |
558 | { | 542 | { |
@@ -1937,9 +1921,10 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
1937 | 1921 | ||
1938 | } | 1922 | } |
1939 | 1923 | ||
1940 | void viafb_init_chip_info(void) | 1924 | void viafb_init_chip_info(struct pci_dev *pdev, |
1925 | const struct pci_device_id *pdi) | ||
1941 | { | 1926 | { |
1942 | init_gfx_chip_info(); | 1927 | init_gfx_chip_info(pdev, pdi); |
1943 | init_tmds_chip_info(); | 1928 | init_tmds_chip_info(); |
1944 | init_lvds_chip_info(); | 1929 | init_lvds_chip_info(); |
1945 | 1930 | ||
@@ -2012,24 +1997,12 @@ void viafb_update_device_setting(int hres, int vres, | |||
2012 | } | 1997 | } |
2013 | } | 1998 | } |
2014 | 1999 | ||
2015 | static void init_gfx_chip_info(void) | 2000 | static void init_gfx_chip_info(struct pci_dev *pdev, |
2001 | const struct pci_device_id *pdi) | ||
2016 | { | 2002 | { |
2017 | struct pci_dev *pdev = NULL; | ||
2018 | u32 i; | ||
2019 | u8 tmp; | 2003 | u8 tmp; |
2020 | 2004 | ||
2021 | /* Indentify GFX Chip Name */ | 2005 | viaparinfo->chip_info->gfx_chip_name = pdi->driver_data; |
2022 | for (i = 0; pciidlist[i].vendor != 0; i++) { | ||
2023 | pdev = pci_get_device(pciidlist[i].vendor, | ||
2024 | pciidlist[i].device, 0); | ||
2025 | if (pdev) | ||
2026 | break; | ||
2027 | } | ||
2028 | |||
2029 | if (!pciidlist[i].vendor) | ||
2030 | return ; | ||
2031 | |||
2032 | viaparinfo->chip_info->gfx_chip_name = pciidlist[i].chip_index; | ||
2033 | 2006 | ||
2034 | /* Check revision of CLE266 Chip */ | 2007 | /* Check revision of CLE266 Chip */ |
2035 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { | 2008 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { |
@@ -2060,8 +2033,6 @@ static void init_gfx_chip_info(void) | |||
2060 | CX700_REVISION_700; | 2033 | CX700_REVISION_700; |
2061 | } | 2034 | } |
2062 | } | 2035 | } |
2063 | |||
2064 | pci_dev_put(pdev); | ||
2065 | } | 2036 | } |
2066 | 2037 | ||
2067 | static void init_tmds_chip_info(void) | 2038 | static void init_tmds_chip_info(void) |
@@ -2554,37 +2525,6 @@ void viafb_crt_enable(void) | |||
2554 | viafb_write_reg_mask(CR36, VIACR, 0x0, BIT5 + BIT4); | 2525 | viafb_write_reg_mask(CR36, VIACR, 0x0, BIT5 + BIT4); |
2555 | } | 2526 | } |
2556 | 2527 | ||
2557 | void viafb_get_mmio_info(unsigned long *mmio_base, u32 *mmio_len) | ||
2558 | { | ||
2559 | struct pci_dev *pdev = NULL; | ||
2560 | u32 vendor, device; | ||
2561 | u32 i; | ||
2562 | |||
2563 | for (i = 0; pciidlist[i].vendor != 0; i++) | ||
2564 | if (viaparinfo->chip_info->gfx_chip_name == | ||
2565 | pciidlist[i].chip_index) | ||
2566 | break; | ||
2567 | |||
2568 | if (!pciidlist[i].vendor) | ||
2569 | return ; | ||
2570 | |||
2571 | vendor = pciidlist[i].vendor; | ||
2572 | device = pciidlist[i].device; | ||
2573 | |||
2574 | pdev = pci_get_device(vendor, device, NULL); | ||
2575 | |||
2576 | if (!pdev) { | ||
2577 | *mmio_base = 0; | ||
2578 | *mmio_len = 0; | ||
2579 | return ; | ||
2580 | } | ||
2581 | |||
2582 | *mmio_base = pci_resource_start(pdev, 1); | ||
2583 | *mmio_len = pci_resource_len(pdev, 1); | ||
2584 | |||
2585 | pci_dev_put(pdev); | ||
2586 | } | ||
2587 | |||
2588 | static void enable_second_display_channel(void) | 2528 | static void enable_second_display_channel(void) |
2589 | { | 2529 | { |
2590 | /* to enable second display channel. */ | 2530 | /* to enable second display channel. */ |
@@ -2601,44 +2541,7 @@ static void disable_second_display_channel(void) | |||
2601 | viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); | 2541 | viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); |
2602 | } | 2542 | } |
2603 | 2543 | ||
2604 | void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len) | 2544 | int viafb_get_fb_size_from_pci(void) |
2605 | { | ||
2606 | struct pci_dev *pdev = NULL; | ||
2607 | u32 vendor, device; | ||
2608 | u32 i; | ||
2609 | |||
2610 | for (i = 0; pciidlist[i].vendor != 0; i++) | ||
2611 | if (viaparinfo->chip_info->gfx_chip_name == | ||
2612 | pciidlist[i].chip_index) | ||
2613 | break; | ||
2614 | |||
2615 | if (!pciidlist[i].vendor) | ||
2616 | return ; | ||
2617 | |||
2618 | vendor = pciidlist[i].vendor; | ||
2619 | device = pciidlist[i].device; | ||
2620 | |||
2621 | pdev = pci_get_device(vendor, device, NULL); | ||
2622 | |||
2623 | if (!pdev) { | ||
2624 | *fb_base = viafb_read_reg(VIASR, SR30) << 24; | ||
2625 | *fb_len = viafb_get_memsize(); | ||
2626 | DEBUG_MSG(KERN_INFO "Get FB info from SR30!\n"); | ||
2627 | DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base); | ||
2628 | DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len); | ||
2629 | return ; | ||
2630 | } | ||
2631 | |||
2632 | *fb_base = (unsigned int)pci_resource_start(pdev, 0); | ||
2633 | *fb_len = get_fb_size_from_pci(); | ||
2634 | DEBUG_MSG(KERN_INFO "Get FB info from PCI system!\n"); | ||
2635 | DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base); | ||
2636 | DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len); | ||
2637 | |||
2638 | pci_dev_put(pdev); | ||
2639 | } | ||
2640 | |||
2641 | static int get_fb_size_from_pci(void) | ||
2642 | { | 2545 | { |
2643 | unsigned long configid, deviceid, FBSize = 0; | 2546 | unsigned long configid, deviceid, FBSize = 0; |
2644 | int VideoMemSize; | 2547 | int VideoMemSize; |