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 | |
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')
-rw-r--r-- | drivers/video/via/hw.c | 115 | ||||
-rw-r--r-- | drivers/video/via/hw.h | 5 | ||||
-rw-r--r-- | drivers/video/via/viafbdev.c | 52 |
3 files changed, 56 insertions, 116 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; |
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h index 4e54b2f92d0f..b874d952b446 100644 --- a/drivers/video/via/hw.h +++ b/drivers/video/via/hw.h | |||
@@ -901,14 +901,15 @@ void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ | |||
901 | int viafb_setmode(int vmode_index, int hor_res, int ver_res, | 901 | int viafb_setmode(int vmode_index, int hor_res, int ver_res, |
902 | int video_bpp, int vmode_index1, int hor_res1, | 902 | int video_bpp, int vmode_index1, int hor_res1, |
903 | int ver_res1, int video_bpp1); | 903 | int ver_res1, int video_bpp1); |
904 | void viafb_init_chip_info(void); | 904 | void viafb_init_chip_info(struct pci_dev *pdev, |
905 | const struct pci_device_id *pdi); | ||
905 | void viafb_init_dac(int set_iga); | 906 | void viafb_init_dac(int set_iga); |
906 | int viafb_get_pixclock(int hres, int vres, int vmode_refresh); | 907 | int viafb_get_pixclock(int hres, int vres, int vmode_refresh); |
907 | int viafb_get_refresh(int hres, int vres, u32 float_refresh); | 908 | int viafb_get_refresh(int hres, int vres, u32 float_refresh); |
908 | void viafb_update_device_setting(int hres, int vres, int bpp, | 909 | void viafb_update_device_setting(int hres, int vres, int bpp, |
909 | int vmode_refresh, int flag); | 910 | int vmode_refresh, int flag); |
910 | void viafb_get_mmio_info(unsigned long *mmio_base, u32 *mmio_len); | ||
911 | 911 | ||
912 | int viafb_get_fb_size_from_pci(void); | ||
912 | void viafb_set_iga_path(void); | 913 | void viafb_set_iga_path(void); |
913 | void viafb_set_primary_address(u32 addr); | 914 | void viafb_set_primary_address(u32 addr); |
914 | void viafb_set_secondary_address(u32 addr); | 915 | void viafb_set_secondary_address(u32 addr); |
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 3815a9b07195..c661ab62c057 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c | |||
@@ -1842,7 +1842,8 @@ out_default: | |||
1842 | *yres = 480; | 1842 | *yres = 480; |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | static int __devinit via_pci_probe(void) | 1845 | static int __devinit via_pci_probe(struct pci_dev *pdev, |
1846 | const struct pci_device_id *ent) | ||
1846 | { | 1847 | { |
1847 | u32 default_xres, default_yres; | 1848 | u32 default_xres, default_yres; |
1848 | int vmode_index; | 1849 | int vmode_index; |
@@ -1885,8 +1886,9 @@ static int __devinit via_pci_probe(void) | |||
1885 | /* Set up I2C bus stuff */ | 1886 | /* Set up I2C bus stuff */ |
1886 | viafb_create_i2c_bus(viaparinfo); | 1887 | viafb_create_i2c_bus(viaparinfo); |
1887 | 1888 | ||
1888 | viafb_init_chip_info(); | 1889 | viafb_init_chip_info(pdev, ent); |
1889 | viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize); | 1890 | viaparinfo->fbmem = pci_resource_start(pdev, 0); |
1891 | viaparinfo->memsize = viafb_get_fb_size_from_pci(); | ||
1890 | viaparinfo->fbmem_free = viaparinfo->memsize; | 1892 | viaparinfo->fbmem_free = viaparinfo->memsize; |
1891 | viaparinfo->fbmem_used = 0; | 1893 | viaparinfo->fbmem_used = 0; |
1892 | viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem, | 1894 | viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem, |
@@ -1896,8 +1898,8 @@ static int __devinit via_pci_probe(void) | |||
1896 | return -ENOMEM; | 1898 | return -ENOMEM; |
1897 | } | 1899 | } |
1898 | 1900 | ||
1899 | viafb_get_mmio_info(&viafbinfo->fix.mmio_start, | 1901 | viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1); |
1900 | &viafbinfo->fix.mmio_len); | 1902 | viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1); |
1901 | viafbinfo->node = 0; | 1903 | viafbinfo->node = 0; |
1902 | viafbinfo->fbops = &viafb_ops; | 1904 | viafbinfo->fbops = &viafb_ops; |
1903 | viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; | 1905 | viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; |
@@ -2065,7 +2067,7 @@ static int __devinit via_pci_probe(void) | |||
2065 | return 0; | 2067 | return 0; |
2066 | } | 2068 | } |
2067 | 2069 | ||
2068 | static void __devexit via_pci_remove(void) | 2070 | static void __devexit via_pci_remove(struct pci_dev *pdev) |
2069 | { | 2071 | { |
2070 | DEBUG_MSG(KERN_INFO "via_pci_remove!\n"); | 2072 | DEBUG_MSG(KERN_INFO "via_pci_remove!\n"); |
2071 | fb_dealloc_cmap(&viafbinfo->cmap); | 2073 | fb_dealloc_cmap(&viafbinfo->cmap); |
@@ -2157,6 +2159,40 @@ static int __init viafb_setup(char *options) | |||
2157 | } | 2159 | } |
2158 | #endif | 2160 | #endif |
2159 | 2161 | ||
2162 | static struct pci_device_id viafb_pci_table[] __devinitdata = { | ||
2163 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID), | ||
2164 | .driver_data = UNICHROME_CLE266 }, | ||
2165 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID), | ||
2166 | .driver_data = UNICHROME_PM800 }, | ||
2167 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID), | ||
2168 | .driver_data = UNICHROME_K400 }, | ||
2169 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID), | ||
2170 | .driver_data = UNICHROME_K800 }, | ||
2171 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID), | ||
2172 | .driver_data = UNICHROME_CN700 }, | ||
2173 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID), | ||
2174 | .driver_data = UNICHROME_K8M890 }, | ||
2175 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID), | ||
2176 | .driver_data = UNICHROME_CX700 }, | ||
2177 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID), | ||
2178 | .driver_data = UNICHROME_P4M900 }, | ||
2179 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID), | ||
2180 | .driver_data = UNICHROME_CN750 }, | ||
2181 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID), | ||
2182 | .driver_data = UNICHROME_VX800 }, | ||
2183 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID), | ||
2184 | .driver_data = UNICHROME_VX855 }, | ||
2185 | { } | ||
2186 | }; | ||
2187 | MODULE_DEVICE_TABLE(pci, viafb_pci_table); | ||
2188 | |||
2189 | static struct pci_driver viafb_driver = { | ||
2190 | .name = "viafb", | ||
2191 | .id_table = viafb_pci_table, | ||
2192 | .probe = via_pci_probe, | ||
2193 | .remove = __devexit_p(via_pci_remove), | ||
2194 | }; | ||
2195 | |||
2160 | static int __init viafb_init(void) | 2196 | static int __init viafb_init(void) |
2161 | { | 2197 | { |
2162 | #ifndef MODULE | 2198 | #ifndef MODULE |
@@ -2168,13 +2204,13 @@ static int __init viafb_init(void) | |||
2168 | printk(KERN_INFO | 2204 | printk(KERN_INFO |
2169 | "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", | 2205 | "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", |
2170 | VERSION_MAJOR, VERSION_MINOR); | 2206 | VERSION_MAJOR, VERSION_MINOR); |
2171 | return via_pci_probe(); | 2207 | return pci_register_driver(&viafb_driver); |
2172 | } | 2208 | } |
2173 | 2209 | ||
2174 | static void __exit viafb_exit(void) | 2210 | static void __exit viafb_exit(void) |
2175 | { | 2211 | { |
2176 | DEBUG_MSG(KERN_INFO "viafb_exit!\n"); | 2212 | DEBUG_MSG(KERN_INFO "viafb_exit!\n"); |
2177 | via_pci_remove(); | 2213 | pci_unregister_driver(&viafb_driver); |
2178 | } | 2214 | } |
2179 | 2215 | ||
2180 | static struct fb_ops viafb_ops = { | 2216 | static struct fb_ops viafb_ops = { |