Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'viafb-next' of git://github.com/schandinat/linux-2.6

* 'viafb-next' of git://github.com/schandinat/linux-2.6: (24 commits)
viafb: Automatic OLPC XO-1.5 configuration
viafb: remove unused CEA mode
viafb: try to map less memory in case of failure
viafb: use write combining for video ram
viafb: add X server compatibility mode
viafb: reduce OLPC refresh a bit
viafb: fix OLPC XO 1.5 device connection
viafb: fix OLPC DCON refresh rate
viafb: delete clock and PLL initialization
viafb: replace custom return values
viafb: some small cleanup for global variables
viafb: gather common good, old VGA initialization in one place
viafb: add engine clock support
viafb: add VIA slapping capability
viafb: split clock and PLL code to an extra file
viafb: add primary/secondary clock on/off switches
viafb: add clock source selection and PLL power management support
viafb: prepare for PLL separation
viafb: call viafb_get_clk_value only in viafb_set_vclock
viafb: remove unused max_hres/vres
...

+721 -704
+11
drivers/video/Kconfig
··· 1562 1562 correct output device configuration. 1563 1563 Its use is strongly discouraged. 1564 1564 1565 + config FB_VIA_X_COMPATIBILITY 1566 + bool "X server compatibility" 1567 + depends on FB_VIA 1568 + default n 1569 + help 1570 + This option reduces the functionality (power saving, ...) of the 1571 + framebuffer to avoid negative impact on the OpenChrome X server. 1572 + If you use any X server other than fbdev you should enable this 1573 + otherwise it should be safe to disable it and allow using all 1574 + features. 1575 + 1565 1576 endif 1566 1577 1567 1578 config FB_NEOMAGIC
+1 -1
drivers/video/via/Makefile
··· 6 6 7 7 viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o \ 8 8 via_utility.o vt1636.o global.o tblDPASetting.o viamode.o \ 9 - via-core.o via-gpio.o via_modesetting.o 9 + via-core.o via-gpio.o via_modesetting.o via_clock.o
-6
drivers/video/via/chip.h
··· 137 137 struct lvds_chip_information lvds_chip_info2; 138 138 }; 139 139 140 - struct crt_setting_information { 141 - int iga_path; 142 - }; 143 - 144 140 struct tmds_setting_information { 145 141 int iga_path; 146 142 int h_active; 147 143 int v_active; 148 144 int max_pixel_clock; 149 - int max_hres; 150 - int max_vres; 151 145 }; 152 146 153 147 struct lvds_setting_information {
+12 -148
drivers/video/via/dvi.c
··· 28 28 static void __devinit dvi_get_panel_size_from_DDCv1( 29 29 struct tmds_chip_information *tmds_chip, 30 30 struct tmds_setting_information *tmds_setting); 31 - static void __devinit dvi_get_panel_size_from_DDCv2( 32 - struct tmds_chip_information *tmds_chip, 33 - struct tmds_setting_information *tmds_setting); 34 31 static int viafb_dvi_query_EDID(void); 35 32 36 - static int check_tmds_chip(int device_id_subaddr, int device_id) 33 + static inline bool check_tmds_chip(int device_id_subaddr, int device_id) 37 34 { 38 - if (tmds_register_read(device_id_subaddr) == device_id) 39 - return OK; 40 - else 41 - return FAIL; 35 + return tmds_register_read(device_id_subaddr) == device_id; 42 36 } 43 37 44 38 void __devinit viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, ··· 41 47 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); 42 48 43 49 viafb_dvi_sense(); 44 - switch (viafb_dvi_query_EDID()) { 45 - case 1: 50 + if (viafb_dvi_query_EDID() == 1) 46 51 dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting); 47 - break; 48 - case 2: 49 - dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting); 50 - break; 51 - default: 52 - printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n"); 53 - break; 54 - } 55 52 56 53 return; 57 54 } 58 55 59 - int __devinit viafb_tmds_trasmitter_identify(void) 56 + bool __devinit viafb_tmds_trasmitter_identify(void) 60 57 { 61 58 unsigned char sr2a = 0, sr1e = 0, sr3e = 0; 62 59 ··· 86 101 viaparinfo->chip_info-> 87 102 tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR; 88 103 viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_31; 89 - if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) { 104 + if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)) { 90 105 /* 91 106 * Currently only support 12bits,dual edge,add 24bits mode later 92 107 */ ··· 97 112 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); 98 113 DEBUG_MSG(KERN_INFO "\n %2d", 99 114 viaparinfo->chip_info->tmds_chip_info.i2c_port); 100 - return OK; 115 + return true; 101 116 } else { 102 117 viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_2C; 103 - if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) 104 - != FAIL) { 118 + if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)) { 105 119 tmds_register_write(0x08, 0x3b); 106 120 DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n"); 107 121 DEBUG_MSG(KERN_INFO "\n %2d", ··· 109 125 DEBUG_MSG(KERN_INFO "\n %2d", 110 126 viaparinfo->chip_info-> 111 127 tmds_chip_info.i2c_port); 112 - return OK; 128 + return true; 113 129 } 114 130 } 115 131 ··· 119 135 ((viafb_display_hardware_layout == HW_LAYOUT_DVI_ONLY) || 120 136 (viafb_display_hardware_layout == HW_LAYOUT_LCD_DVI))) { 121 137 DEBUG_MSG(KERN_INFO "\n Integrated TMDS ! \n"); 122 - return OK; 138 + return true; 123 139 } 124 140 125 141 switch (viaparinfo->chip_info->gfx_chip_name) { ··· 143 159 tmds_chip_info.tmds_chip_name = NON_TMDS_TRANSMITTER; 144 160 viaparinfo->chip_info->tmds_chip_info. 145 161 tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR; 146 - return FAIL; 162 + return false; 147 163 } 148 164 149 165 static void tmds_register_write(int index, u8 data) ··· 290 306 return EDID_VERSION_1; /* Found EDID1 Table */ 291 307 } 292 308 293 - data0 = (u8) tmds_register_read(0x00); 294 - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 295 - if (data0 == 0x20) 296 - return EDID_VERSION_2; /* Found EDID2 Table */ 297 - else 298 - return false; 309 + return false; 299 310 } 300 311 301 312 /* Get Panel Size Using EDID1 Table */ ··· 298 319 struct tmds_chip_information *tmds_chip, 299 320 struct tmds_setting_information *tmds_setting) 300 321 { 301 - int i, max_h = 0, tmp, restore; 302 - unsigned char rData; 322 + int i, restore; 303 323 unsigned char EDID_DATA[18]; 304 324 305 325 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n"); 306 326 307 327 restore = tmds_chip->tmds_chip_slave_addr; 308 328 tmds_chip->tmds_chip_slave_addr = 0xA0; 309 - 310 - rData = tmds_register_read(0x23); 311 - if (rData & 0x3C) 312 - max_h = 640; 313 - if (rData & 0xC0) 314 - max_h = 720; 315 - if (rData & 0x03) 316 - max_h = 800; 317 - 318 - rData = tmds_register_read(0x24); 319 - if (rData & 0xC0) 320 - max_h = 800; 321 - if (rData & 0x1E) 322 - max_h = 1024; 323 - if (rData & 0x01) 324 - max_h = 1280; 325 - 326 329 for (i = 0x25; i < 0x6D; i++) { 327 330 switch (i) { 328 - case 0x26: 329 - case 0x28: 330 - case 0x2A: 331 - case 0x2C: 332 - case 0x2E: 333 - case 0x30: 334 - case 0x32: 335 - case 0x34: 336 - rData = tmds_register_read(i); 337 - if (rData == 1) 338 - break; 339 - /* data = (data + 31) * 8 */ 340 - tmp = (rData + 31) << 3; 341 - if (tmp > max_h) 342 - max_h = tmp; 343 - break; 344 - 345 331 case 0x36: 346 332 case 0x48: 347 333 case 0x5A: ··· 327 383 } 328 384 } 329 385 330 - tmds_setting->max_hres = max_h; 331 - switch (max_h) { 332 - case 640: 333 - tmds_setting->max_vres = 480; 334 - break; 335 - case 800: 336 - tmds_setting->max_vres = 600; 337 - break; 338 - case 1024: 339 - tmds_setting->max_vres = 768; 340 - break; 341 - case 1280: 342 - tmds_setting->max_vres = 1024; 343 - break; 344 - case 1400: 345 - tmds_setting->max_vres = 1050; 346 - break; 347 - case 1440: 348 - tmds_setting->max_vres = 1050; 349 - break; 350 - case 1600: 351 - tmds_setting->max_vres = 1200; 352 - break; 353 - case 1920: 354 - tmds_setting->max_vres = 1080; 355 - break; 356 - default: 357 - DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! " 358 - "set default panel size.\n", max_h); 359 - break; 360 - } 361 - 362 386 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", 363 387 tmds_setting->max_pixel_clock); 364 - tmds_chip->tmds_chip_slave_addr = restore; 365 - } 366 - 367 - /* Get Panel Size Using EDID2 Table */ 368 - static void __devinit dvi_get_panel_size_from_DDCv2( 369 - struct tmds_chip_information *tmds_chip, 370 - struct tmds_setting_information *tmds_setting) 371 - { 372 - int restore; 373 - unsigned char R_Buffer[2]; 374 - 375 - DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); 376 - 377 - restore = tmds_chip->tmds_chip_slave_addr; 378 - tmds_chip->tmds_chip_slave_addr = 0xA2; 379 - 380 - /* Horizontal: 0x76, 0x77 */ 381 - tmds_register_read_bytes(0x76, R_Buffer, 2); 382 - tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8); 383 - 384 - switch (tmds_setting->max_hres) { 385 - case 640: 386 - tmds_setting->max_vres = 480; 387 - break; 388 - case 800: 389 - tmds_setting->max_vres = 600; 390 - break; 391 - case 1024: 392 - tmds_setting->max_vres = 768; 393 - break; 394 - case 1280: 395 - tmds_setting->max_vres = 1024; 396 - break; 397 - case 1400: 398 - tmds_setting->max_vres = 1050; 399 - break; 400 - case 1440: 401 - tmds_setting->max_vres = 1050; 402 - break; 403 - case 1600: 404 - tmds_setting->max_vres = 1200; 405 - break; 406 - default: 407 - DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! " 408 - "set default panel size.\n", tmds_setting->max_hres); 409 - break; 410 - } 411 - 412 388 tmds_chip->tmds_chip_slave_addr = restore; 413 389 } 414 390
+1 -1
drivers/video/via/dvi.h
··· 56 56 int viafb_dvi_sense(void); 57 57 void viafb_dvi_disable(void); 58 58 void viafb_dvi_enable(void); 59 - int __devinit viafb_tmds_trasmitter_identify(void); 59 + bool __devinit viafb_tmds_trasmitter_identify(void); 60 60 void __devinit viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, 61 61 struct tmds_setting_information *tmds_setting); 62 62 void viafb_dvi_set_mode(struct VideoModeTable *videoMode, int mode_bpp,
-4
drivers/video/via/global.c
··· 40 40 int viafb_hotplug_bpp = 32; 41 41 int viafb_hotplug_refresh = 60; 42 42 int viafb_primary_dev = None_Device; 43 - unsigned int viafb_second_xres = 640; 44 - unsigned int viafb_second_yres = 480; 45 - unsigned int viafb_second_virtual_xres; 46 - unsigned int viafb_second_virtual_yres; 47 43 int viafb_lcd_panel_id = LCD_PANEL_ID_MAXIMUM + 1; 48 44 struct fb_info *viafbinfo; 49 45 struct fb_info *viafbinfo1;
-2
drivers/video/via/global.h
··· 73 73 extern int viafb_hotplug_refresh; 74 74 extern int viafb_primary_dev; 75 75 76 - extern unsigned int viafb_second_xres; 77 - extern unsigned int viafb_second_yres; 78 76 extern int viafb_lcd_panel_id; 79 77 80 78 #endif /* __GLOBAL_H__ */
+208 -418
drivers/video/via/hw.c
··· 20 20 */ 21 21 22 22 #include <linux/via-core.h> 23 + #include <asm/olpc.h> 23 24 #include "global.h" 25 + #include "via_clock.h" 24 26 25 - static struct pll_config cle266_pll_config[] = { 26 - {19, 4, 0}, 27 - {26, 5, 0}, 28 - {28, 5, 0}, 29 - {31, 5, 0}, 30 - {33, 5, 0}, 31 - {55, 5, 0}, 32 - {102, 5, 0}, 33 - {53, 6, 0}, 34 - {92, 6, 0}, 35 - {98, 6, 0}, 36 - {112, 6, 0}, 37 - {41, 7, 0}, 38 - {60, 7, 0}, 39 - {99, 7, 0}, 40 - {100, 7, 0}, 41 - {83, 8, 0}, 42 - {86, 8, 0}, 43 - {108, 8, 0}, 44 - {87, 9, 0}, 45 - {118, 9, 0}, 46 - {95, 12, 0}, 47 - {115, 12, 0}, 48 - {108, 13, 0}, 49 - {83, 17, 0}, 50 - {67, 20, 0}, 51 - {86, 20, 0}, 52 - {98, 20, 0}, 53 - {121, 24, 0}, 54 - {99, 29, 0}, 55 - {33, 3, 1}, 56 - {15, 4, 1}, 57 - {23, 4, 1}, 58 - {37, 5, 1}, 59 - {83, 5, 1}, 60 - {85, 5, 1}, 61 - {94, 5, 1}, 62 - {103, 5, 1}, 63 - {109, 5, 1}, 64 - {113, 5, 1}, 65 - {121, 5, 1}, 66 - {82, 6, 1}, 67 - {31, 7, 1}, 68 - {55, 7, 1}, 69 - {84, 7, 1}, 70 - {83, 8, 1}, 71 - {76, 9, 1}, 72 - {127, 9, 1}, 73 - {33, 4, 2}, 74 - {75, 4, 2}, 75 - {119, 4, 2}, 76 - {121, 4, 2}, 77 - {91, 5, 2}, 78 - {118, 5, 2}, 79 - {83, 6, 2}, 80 - {109, 6, 2}, 81 - {90, 7, 2}, 82 - {93, 2, 3}, 83 - {53, 3, 3}, 84 - {73, 4, 3}, 85 - {89, 4, 3}, 86 - {105, 4, 3}, 87 - {117, 4, 3}, 88 - {101, 5, 3}, 89 - {121, 5, 3}, 90 - {127, 5, 3}, 91 - {99, 7, 3} 27 + static struct pll_limit cle266_pll_limits[] = { 28 + {19, 19, 4, 0}, 29 + {26, 102, 5, 0}, 30 + {53, 112, 6, 0}, 31 + {41, 100, 7, 0}, 32 + {83, 108, 8, 0}, 33 + {87, 118, 9, 0}, 34 + {95, 115, 12, 0}, 35 + {108, 108, 13, 0}, 36 + {83, 83, 17, 0}, 37 + {67, 98, 20, 0}, 38 + {121, 121, 24, 0}, 39 + {99, 99, 29, 0}, 40 + {33, 33, 3, 1}, 41 + {15, 23, 4, 1}, 42 + {37, 121, 5, 1}, 43 + {82, 82, 6, 1}, 44 + {31, 84, 7, 1}, 45 + {83, 83, 8, 1}, 46 + {76, 127, 9, 1}, 47 + {33, 121, 4, 2}, 48 + {91, 118, 5, 2}, 49 + {83, 109, 6, 2}, 50 + {90, 90, 7, 2}, 51 + {93, 93, 2, 3}, 52 + {53, 53, 3, 3}, 53 + {73, 117, 4, 3}, 54 + {101, 127, 5, 3}, 55 + {99, 99, 7, 3} 92 56 }; 93 57 94 - static struct pll_config k800_pll_config[] = { 95 - {22, 2, 0}, 96 - {28, 3, 0}, 97 - {81, 3, 1}, 98 - {85, 3, 1}, 99 - {98, 3, 1}, 100 - {112, 3, 1}, 101 - {86, 4, 1}, 102 - {166, 4, 1}, 103 - {109, 5, 1}, 104 - {113, 5, 1}, 105 - {121, 5, 1}, 106 - {131, 5, 1}, 107 - {143, 5, 1}, 108 - {153, 5, 1}, 109 - {66, 3, 2}, 110 - {68, 3, 2}, 111 - {95, 3, 2}, 112 - {106, 3, 2}, 113 - {116, 3, 2}, 114 - {93, 4, 2}, 115 - {119, 4, 2}, 116 - {121, 4, 2}, 117 - {133, 4, 2}, 118 - {137, 4, 2}, 119 - {117, 5, 2}, 120 - {118, 5, 2}, 121 - {120, 5, 2}, 122 - {124, 5, 2}, 123 - {132, 5, 2}, 124 - {137, 5, 2}, 125 - {141, 5, 2}, 126 - {166, 5, 2}, 127 - {170, 5, 2}, 128 - {191, 5, 2}, 129 - {206, 5, 2}, 130 - {208, 5, 2}, 131 - {30, 2, 3}, 132 - {69, 3, 3}, 133 - {82, 3, 3}, 134 - {83, 3, 3}, 135 - {109, 3, 3}, 136 - {114, 3, 3}, 137 - {125, 3, 3}, 138 - {89, 4, 3}, 139 - {103, 4, 3}, 140 - {117, 4, 3}, 141 - {126, 4, 3}, 142 - {150, 4, 3}, 143 - {161, 4, 3}, 144 - {121, 5, 3}, 145 - {127, 5, 3}, 146 - {131, 5, 3}, 147 - {134, 5, 3}, 148 - {148, 5, 3}, 149 - {169, 5, 3}, 150 - {172, 5, 3}, 151 - {182, 5, 3}, 152 - {195, 5, 3}, 153 - {196, 5, 3}, 154 - {208, 5, 3}, 155 - {66, 2, 4}, 156 - {85, 3, 4}, 157 - {141, 4, 4}, 158 - {146, 4, 4}, 159 - {161, 4, 4}, 160 - {177, 5, 4} 58 + static struct pll_limit k800_pll_limits[] = { 59 + {22, 22, 2, 0}, 60 + {28, 28, 3, 0}, 61 + {81, 112, 3, 1}, 62 + {86, 166, 4, 1}, 63 + {109, 153, 5, 1}, 64 + {66, 116, 3, 2}, 65 + {93, 137, 4, 2}, 66 + {117, 208, 5, 2}, 67 + {30, 30, 2, 3}, 68 + {69, 125, 3, 3}, 69 + {89, 161, 4, 3}, 70 + {121, 208, 5, 3}, 71 + {66, 66, 2, 4}, 72 + {85, 85, 3, 4}, 73 + {141, 161, 4, 4}, 74 + {177, 177, 5, 4} 161 75 }; 162 76 163 - static struct pll_config cx700_pll_config[] = { 164 - {98, 3, 1}, 165 - {86, 4, 1}, 166 - {109, 5, 1}, 167 - {110, 5, 1}, 168 - {113, 5, 1}, 169 - {121, 5, 1}, 170 - {131, 5, 1}, 171 - {135, 5, 1}, 172 - {142, 5, 1}, 173 - {143, 5, 1}, 174 - {153, 5, 1}, 175 - {187, 5, 1}, 176 - {208, 5, 1}, 177 - {68, 2, 2}, 178 - {95, 3, 2}, 179 - {116, 3, 2}, 180 - {93, 4, 2}, 181 - {119, 4, 2}, 182 - {133, 4, 2}, 183 - {137, 4, 2}, 184 - {151, 4, 2}, 185 - {166, 4, 2}, 186 - {110, 5, 2}, 187 - {112, 5, 2}, 188 - {117, 5, 2}, 189 - {118, 5, 2}, 190 - {120, 5, 2}, 191 - {132, 5, 2}, 192 - {137, 5, 2}, 193 - {141, 5, 2}, 194 - {151, 5, 2}, 195 - {166, 5, 2}, 196 - {175, 5, 2}, 197 - {191, 5, 2}, 198 - {206, 5, 2}, 199 - {174, 7, 2}, 200 - {82, 3, 3}, 201 - {109, 3, 3}, 202 - {117, 4, 3}, 203 - {150, 4, 3}, 204 - {161, 4, 3}, 205 - {112, 5, 3}, 206 - {115, 5, 3}, 207 - {121, 5, 3}, 208 - {127, 5, 3}, 209 - {129, 5, 3}, 210 - {131, 5, 3}, 211 - {134, 5, 3}, 212 - {138, 5, 3}, 213 - {148, 5, 3}, 214 - {157, 5, 3}, 215 - {169, 5, 3}, 216 - {172, 5, 3}, 217 - {190, 5, 3}, 218 - {195, 5, 3}, 219 - {196, 5, 3}, 220 - {208, 5, 3}, 221 - {141, 5, 4}, 222 - {150, 5, 4}, 223 - {166, 5, 4}, 224 - {176, 5, 4}, 225 - {177, 5, 4}, 226 - {183, 5, 4}, 227 - {202, 5, 4} 77 + static struct pll_limit cx700_pll_limits[] = { 78 + {98, 98, 3, 1}, 79 + {86, 86, 4, 1}, 80 + {109, 208, 5, 1}, 81 + {68, 68, 2, 2}, 82 + {95, 116, 3, 2}, 83 + {93, 166, 4, 2}, 84 + {110, 206, 5, 2}, 85 + {174, 174, 7, 2}, 86 + {82, 109, 3, 3}, 87 + {117, 161, 4, 3}, 88 + {112, 208, 5, 3}, 89 + {141, 202, 5, 4} 228 90 }; 229 91 230 - static struct pll_config vx855_pll_config[] = { 231 - {86, 4, 1}, 232 - {108, 5, 1}, 233 - {110, 5, 1}, 234 - {113, 5, 1}, 235 - {121, 5, 1}, 236 - {131, 5, 1}, 237 - {135, 5, 1}, 238 - {142, 5, 1}, 239 - {143, 5, 1}, 240 - {153, 5, 1}, 241 - {164, 5, 1}, 242 - {187, 5, 1}, 243 - {208, 5, 1}, 244 - {110, 5, 2}, 245 - {112, 5, 2}, 246 - {117, 5, 2}, 247 - {118, 5, 2}, 248 - {124, 5, 2}, 249 - {132, 5, 2}, 250 - {137, 5, 2}, 251 - {141, 5, 2}, 252 - {149, 5, 2}, 253 - {151, 5, 2}, 254 - {159, 5, 2}, 255 - {166, 5, 2}, 256 - {167, 5, 2}, 257 - {172, 5, 2}, 258 - {189, 5, 2}, 259 - {191, 5, 2}, 260 - {194, 5, 2}, 261 - {206, 5, 2}, 262 - {208, 5, 2}, 263 - {83, 3, 3}, 264 - {88, 3, 3}, 265 - {109, 3, 3}, 266 - {112, 3, 3}, 267 - {103, 4, 3}, 268 - {105, 4, 3}, 269 - {161, 4, 3}, 270 - {112, 5, 3}, 271 - {115, 5, 3}, 272 - {121, 5, 3}, 273 - {127, 5, 3}, 274 - {134, 5, 3}, 275 - {137, 5, 3}, 276 - {148, 5, 3}, 277 - {157, 5, 3}, 278 - {169, 5, 3}, 279 - {172, 5, 3}, 280 - {182, 5, 3}, 281 - {191, 5, 3}, 282 - {195, 5, 3}, 283 - {209, 5, 3}, 284 - {142, 4, 4}, 285 - {146, 4, 4}, 286 - {161, 4, 4}, 287 - {141, 5, 4}, 288 - {150, 5, 4}, 289 - {165, 5, 4}, 290 - {176, 5, 4} 92 + static struct pll_limit vx855_pll_limits[] = { 93 + {86, 86, 4, 1}, 94 + {108, 208, 5, 1}, 95 + {110, 208, 5, 2}, 96 + {83, 112, 3, 3}, 97 + {103, 161, 4, 3}, 98 + {112, 209, 5, 3}, 99 + {142, 161, 4, 4}, 100 + {141, 176, 5, 4} 291 101 }; 292 102 293 103 /* according to VIA Technologies these values are based on experiment */ ··· 116 306 {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ 117 307 {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ 118 308 {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ 309 + }; 310 + 311 + static struct io_reg common_vga[] = { 312 + {VIACR, CR07, 0x10, 0x10}, /* [0] vertical total (bit 8) 313 + [1] vertical display end (bit 8) 314 + [2] vertical retrace start (bit 8) 315 + [3] start vertical blanking (bit 8) 316 + [4] line compare (bit 8) 317 + [5] vertical total (bit 9) 318 + [6] vertical display end (bit 9) 319 + [7] vertical retrace start (bit 9) */ 320 + {VIACR, CR08, 0xFF, 0x00}, /* [0-4] preset row scan 321 + [5-6] byte panning */ 322 + {VIACR, CR09, 0xDF, 0x40}, /* [0-4] max scan line 323 + [5] start vertical blanking (bit 9) 324 + [6] line compare (bit 9) 325 + [7] scan doubling */ 326 + {VIACR, CR0A, 0xFF, 0x1E}, /* [0-4] cursor start 327 + [5] cursor disable */ 328 + {VIACR, CR0B, 0xFF, 0x00}, /* [0-4] cursor end 329 + [5-6] cursor skew */ 330 + {VIACR, CR0E, 0xFF, 0x00}, /* [0-7] cursor location (high) */ 331 + {VIACR, CR0F, 0xFF, 0x00}, /* [0-7] cursor location (low) */ 332 + {VIACR, CR11, 0xF0, 0x80}, /* [0-3] vertical retrace end 333 + [6] memory refresh bandwidth 334 + [7] CRTC register protect enable */ 335 + {VIACR, CR14, 0xFF, 0x00}, /* [0-4] underline location 336 + [5] divide memory address clock by 4 337 + [6] double word addressing */ 338 + {VIACR, CR17, 0xFF, 0x63}, /* [0-1] mapping of display address 13-14 339 + [2] divide scan line clock by 2 340 + [3] divide memory address clock by 2 341 + [5] address wrap 342 + [6] byte mode select 343 + [7] sync enable */ 344 + {VIACR, CR18, 0xFF, 0xFF}, /* [0-7] line compare */ 119 345 }; 120 346 121 347 static struct fifo_depth_select display_fifo_depth_reg = { ··· 522 676 {VIA_LVDS2, "LVDS2"} 523 677 }; 524 678 679 + /* structure with function pointers to support clock control */ 680 + static struct via_clock clock; 681 + 525 682 static void load_fix_bit_crtc_reg(void); 526 683 static void __devinit init_gfx_chip_info(int chip_type); 527 684 static void __devinit init_tmds_chip_info(void); ··· 619 770 /*Set IGA path for each device*/ 620 771 void viafb_set_iga_path(void) 621 772 { 773 + int crt_iga_path = 0; 622 774 623 775 if (viafb_SAMM_ON == 1) { 624 776 if (viafb_CRT_ON) { 625 777 if (viafb_primary_dev == CRT_Device) 626 - viaparinfo->crt_setting_info->iga_path = IGA1; 778 + crt_iga_path = IGA1; 627 779 else 628 - viaparinfo->crt_setting_info->iga_path = IGA2; 780 + crt_iga_path = IGA2; 629 781 } 630 782 631 783 if (viafb_DVI_ON) { ··· 643 793 UNICHROME_CLE266)) { 644 794 viaparinfo-> 645 795 lvds_setting_info->iga_path = IGA2; 646 - viaparinfo-> 647 - crt_setting_info->iga_path = IGA1; 796 + crt_iga_path = IGA1; 648 797 viaparinfo-> 649 798 tmds_setting_info->iga_path = IGA1; 650 799 } else ··· 663 814 viafb_SAMM_ON = 0; 664 815 665 816 if (viafb_CRT_ON && viafb_LCD_ON) { 666 - viaparinfo->crt_setting_info->iga_path = IGA1; 817 + crt_iga_path = IGA1; 667 818 viaparinfo->lvds_setting_info->iga_path = IGA2; 668 819 } else if (viafb_CRT_ON && viafb_DVI_ON) { 669 - viaparinfo->crt_setting_info->iga_path = IGA1; 820 + crt_iga_path = IGA1; 670 821 viaparinfo->tmds_setting_info->iga_path = IGA2; 671 822 } else if (viafb_LCD_ON && viafb_DVI_ON) { 672 823 viaparinfo->tmds_setting_info->iga_path = IGA1; ··· 675 826 viaparinfo->lvds_setting_info->iga_path = IGA2; 676 827 viaparinfo->lvds_setting_info2->iga_path = IGA2; 677 828 } else if (viafb_CRT_ON) { 678 - viaparinfo->crt_setting_info->iga_path = IGA1; 829 + crt_iga_path = IGA1; 679 830 } else if (viafb_LCD_ON) { 680 831 viaparinfo->lvds_setting_info->iga_path = IGA2; 681 832 } else if (viafb_DVI_ON) { ··· 686 837 viaparinfo->shared->iga1_devices = 0; 687 838 viaparinfo->shared->iga2_devices = 0; 688 839 if (viafb_CRT_ON) { 689 - if (viaparinfo->crt_setting_info->iga_path == IGA1) 840 + if (crt_iga_path == IGA1) 690 841 viaparinfo->shared->iga1_devices |= VIA_CRT; 691 842 else 692 843 viaparinfo->shared->iga2_devices |= VIA_CRT; ··· 724 875 viaparinfo->chip_info-> 725 876 lvds_chip_info2.output_interface); 726 877 } 878 + 879 + /* looks like the OLPC has its display wired to DVP1 and LVDS2 */ 880 + if (machine_is_olpc()) 881 + viaparinfo->shared->iga2_devices = VIA_DVP1 | VIA_LVDS2; 727 882 } 728 883 729 884 static void set_color_register(u8 index, u8 red, u8 green, u8 blue) ··· 1015 1162 1016 1163 static void load_fix_bit_crtc_reg(void) 1017 1164 { 1165 + viafb_unlock_crt(); 1166 + 1018 1167 /* always set to 1 */ 1019 1168 viafb_write_reg_mask(CR03, VIACR, 0x80, BIT7); 1020 - /* line compare should set all bits = 1 (extend modes) */ 1021 - viafb_write_reg(CR18, VIACR, 0xff); 1022 - /* line compare should set all bits = 1 (extend modes) */ 1023 - viafb_write_reg_mask(CR07, VIACR, 0x10, BIT4); 1024 - /* line compare should set all bits = 1 (extend modes) */ 1025 - viafb_write_reg_mask(CR09, VIACR, 0x40, BIT6); 1026 1169 /* line compare should set all bits = 1 (extend modes) */ 1027 1170 viafb_write_reg_mask(CR35, VIACR, 0x10, BIT4); 1028 1171 /* line compare should set all bits = 1 (extend modes) */ 1029 1172 viafb_write_reg_mask(CR33, VIACR, 0x06, BIT0 + BIT1 + BIT2); 1030 1173 /*viafb_write_reg_mask(CR32, VIACR, 0x01, BIT0); */ 1031 - /* extend mode always set to e3h */ 1032 - viafb_write_reg(CR17, VIACR, 0xe3); 1033 - /* extend mode always set to 0h */ 1034 - viafb_write_reg(CR08, VIACR, 0x00); 1035 - /* extend mode always set to 0h */ 1036 - viafb_write_reg(CR14, VIACR, 0x00); 1174 + 1175 + viafb_lock_crt(); 1037 1176 1038 1177 /* If K8M800, enable Prefetch Mode. */ 1039 1178 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) ··· 1446 1601 1447 1602 } 1448 1603 1449 - static u32 cle266_encode_pll(struct pll_config pll) 1450 - { 1451 - return (pll.multiplier << 8) 1452 - | (pll.rshift << 6) 1453 - | pll.divisor; 1454 - } 1455 - 1456 - static u32 k800_encode_pll(struct pll_config pll) 1457 - { 1458 - return ((pll.divisor - 2) << 16) 1459 - | (pll.rshift << 10) 1460 - | (pll.multiplier - 2); 1461 - } 1462 - 1463 - static u32 vx855_encode_pll(struct pll_config pll) 1464 - { 1465 - return (pll.divisor << 16) 1466 - | (pll.rshift << 10) 1467 - | pll.multiplier; 1468 - } 1469 - 1470 - static inline u32 get_pll_internal_frequency(u32 ref_freq, 1471 - struct pll_config pll) 1472 - { 1473 - return ref_freq / pll.divisor * pll.multiplier; 1474 - } 1475 - 1476 - static inline u32 get_pll_output_frequency(u32 ref_freq, struct pll_config pll) 1477 - { 1478 - return get_pll_internal_frequency(ref_freq, pll)>>pll.rshift; 1479 - } 1480 - 1481 - static struct pll_config get_pll_config(struct pll_config *config, int size, 1604 + static struct via_pll_config get_pll_config(struct pll_limit *limits, int size, 1482 1605 int clk) 1483 1606 { 1484 - struct pll_config best = config[0]; 1607 + struct via_pll_config cur, up, down, best = {0, 1, 0}; 1485 1608 const u32 f0 = 14318180; /* X1 frequency */ 1486 - int i; 1609 + int i, f; 1487 1610 1488 - for (i = 1; i < size; i++) { 1489 - if (abs(get_pll_output_frequency(f0, config[i]) - clk) 1490 - < abs(get_pll_output_frequency(f0, best) - clk)) 1491 - best = config[i]; 1611 + for (i = 0; i < size; i++) { 1612 + cur.rshift = limits[i].rshift; 1613 + cur.divisor = limits[i].divisor; 1614 + cur.multiplier = clk / ((f0 / cur.divisor)>>cur.rshift); 1615 + f = abs(get_pll_output_frequency(f0, cur) - clk); 1616 + up = down = cur; 1617 + up.multiplier++; 1618 + down.multiplier--; 1619 + if (abs(get_pll_output_frequency(f0, up) - clk) < f) 1620 + cur = up; 1621 + else if (abs(get_pll_output_frequency(f0, down) - clk) < f) 1622 + cur = down; 1623 + 1624 + if (cur.multiplier < limits[i].multiplier_min) 1625 + cur.multiplier = limits[i].multiplier_min; 1626 + else if (cur.multiplier > limits[i].multiplier_max) 1627 + cur.multiplier = limits[i].multiplier_max; 1628 + 1629 + f = abs(get_pll_output_frequency(f0, cur) - clk); 1630 + if (f < abs(get_pll_output_frequency(f0, best) - clk)) 1631 + best = cur; 1492 1632 } 1493 1633 1494 1634 return best; 1495 1635 } 1496 1636 1497 - u32 viafb_get_clk_value(int clk) 1637 + static struct via_pll_config get_best_pll_config(int clk) 1498 1638 { 1499 - u32 value = 0; 1639 + struct via_pll_config config; 1500 1640 1501 1641 switch (viaparinfo->chip_info->gfx_chip_name) { 1502 1642 case UNICHROME_CLE266: 1503 1643 case UNICHROME_K400: 1504 - value = cle266_encode_pll(get_pll_config(cle266_pll_config, 1505 - ARRAY_SIZE(cle266_pll_config), clk)); 1644 + config = get_pll_config(cle266_pll_limits, 1645 + ARRAY_SIZE(cle266_pll_limits), clk); 1506 1646 break; 1507 1647 case UNICHROME_K800: 1508 1648 case UNICHROME_PM800: 1509 1649 case UNICHROME_CN700: 1510 - value = k800_encode_pll(get_pll_config(k800_pll_config, 1511 - ARRAY_SIZE(k800_pll_config), clk)); 1650 + config = get_pll_config(k800_pll_limits, 1651 + ARRAY_SIZE(k800_pll_limits), clk); 1512 1652 break; 1513 1653 case UNICHROME_CX700: 1514 1654 case UNICHROME_CN750: ··· 1501 1671 case UNICHROME_P4M890: 1502 1672 case UNICHROME_P4M900: 1503 1673 case UNICHROME_VX800: 1504 - value = k800_encode_pll(get_pll_config(cx700_pll_config, 1505 - ARRAY_SIZE(cx700_pll_config), clk)); 1674 + config = get_pll_config(cx700_pll_limits, 1675 + ARRAY_SIZE(cx700_pll_limits), clk); 1506 1676 break; 1507 1677 case UNICHROME_VX855: 1508 1678 case UNICHROME_VX900: 1509 - value = vx855_encode_pll(get_pll_config(vx855_pll_config, 1510 - ARRAY_SIZE(vx855_pll_config), clk)); 1679 + config = get_pll_config(vx855_pll_limits, 1680 + ARRAY_SIZE(vx855_pll_limits), clk); 1511 1681 break; 1512 1682 } 1513 1683 1514 - return value; 1684 + return config; 1515 1685 } 1516 1686 1517 1687 /* Set VCLK*/ 1518 1688 void viafb_set_vclock(u32 clk, int set_iga) 1519 1689 { 1520 - /* H.W. Reset : ON */ 1521 - viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); 1690 + struct via_pll_config config = get_best_pll_config(clk); 1522 1691 1523 - if (set_iga == IGA1) { 1524 - /* Change D,N FOR VCLK */ 1525 - switch (viaparinfo->chip_info->gfx_chip_name) { 1526 - case UNICHROME_CLE266: 1527 - case UNICHROME_K400: 1528 - via_write_reg(VIASR, SR46, (clk & 0x00FF)); 1529 - via_write_reg(VIASR, SR47, (clk & 0xFF00) >> 8); 1530 - break; 1531 - 1532 - case UNICHROME_K800: 1533 - case UNICHROME_PM800: 1534 - case UNICHROME_CN700: 1535 - case UNICHROME_CX700: 1536 - case UNICHROME_CN750: 1537 - case UNICHROME_K8M890: 1538 - case UNICHROME_P4M890: 1539 - case UNICHROME_P4M900: 1540 - case UNICHROME_VX800: 1541 - case UNICHROME_VX855: 1542 - case UNICHROME_VX900: 1543 - via_write_reg(VIASR, SR44, (clk & 0x0000FF)); 1544 - via_write_reg(VIASR, SR45, (clk & 0x00FF00) >> 8); 1545 - via_write_reg(VIASR, SR46, (clk & 0xFF0000) >> 16); 1546 - break; 1547 - } 1548 - } 1549 - 1550 - if (set_iga == IGA2) { 1551 - /* Change D,N FOR LCK */ 1552 - switch (viaparinfo->chip_info->gfx_chip_name) { 1553 - case UNICHROME_CLE266: 1554 - case UNICHROME_K400: 1555 - via_write_reg(VIASR, SR44, (clk & 0x00FF)); 1556 - via_write_reg(VIASR, SR45, (clk & 0xFF00) >> 8); 1557 - break; 1558 - 1559 - case UNICHROME_K800: 1560 - case UNICHROME_PM800: 1561 - case UNICHROME_CN700: 1562 - case UNICHROME_CX700: 1563 - case UNICHROME_CN750: 1564 - case UNICHROME_K8M890: 1565 - case UNICHROME_P4M890: 1566 - case UNICHROME_P4M900: 1567 - case UNICHROME_VX800: 1568 - case UNICHROME_VX855: 1569 - case UNICHROME_VX900: 1570 - via_write_reg(VIASR, SR4A, (clk & 0x0000FF)); 1571 - via_write_reg(VIASR, SR4B, (clk & 0x00FF00) >> 8); 1572 - via_write_reg(VIASR, SR4C, (clk & 0xFF0000) >> 16); 1573 - break; 1574 - } 1575 - } 1576 - 1577 - /* H.W. Reset : OFF */ 1578 - viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); 1579 - 1580 - /* Reset PLL */ 1581 - if (set_iga == IGA1) { 1582 - viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); 1583 - viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); 1584 - } 1585 - 1586 - if (set_iga == IGA2) { 1587 - viafb_write_reg_mask(SR40, VIASR, 0x04, BIT2); 1588 - viafb_write_reg_mask(SR40, VIASR, 0x00, BIT2); 1589 - } 1692 + if (set_iga == IGA1) 1693 + clock.set_primary_pll(config); 1694 + if (set_iga == IGA2) 1695 + clock.set_secondary_pll(config); 1590 1696 1591 1697 /* Fire! */ 1592 1698 via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */ ··· 1768 2002 int i; 1769 2003 int index = 0; 1770 2004 int h_addr, v_addr; 1771 - u32 pll_D_N, clock, refresh = viafb_refresh; 2005 + u32 clock, refresh = viafb_refresh; 1772 2006 1773 2007 if (viafb_SAMM_ON && set_iga == IGA2) 1774 2008 refresh = viafb_refresh1; ··· 1799 2033 v_addr = crt_reg.ver_addr; 1800 2034 if (set_iga == IGA1) { 1801 2035 viafb_unlock_crt(); 1802 - viafb_write_reg(CR09, VIACR, 0x00); /*initial CR09=0 */ 1803 - viafb_write_reg_mask(CR11, VIACR, 0x00, BIT4 + BIT5 + BIT6); 1804 2036 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); 1805 2037 } 1806 2038 ··· 1811 2047 break; 1812 2048 } 1813 2049 1814 - load_fix_bit_crtc_reg(); 1815 2050 viafb_lock_crt(); 1816 2051 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); 1817 2052 viafb_load_fetch_count_reg(h_addr, bpp_byte, set_iga); ··· 1822 2059 1823 2060 clock = crt_reg.hor_total * crt_reg.ver_total 1824 2061 * crt_table[index].refresh_rate; 1825 - pll_D_N = viafb_get_clk_value(clock); 1826 - DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N); 1827 - viafb_set_vclock(pll_D_N, set_iga); 2062 + viafb_set_vclock(clock, set_iga); 1828 2063 1829 2064 } 1830 2065 1831 2066 void __devinit viafb_init_chip_info(int chip_type) 1832 2067 { 2068 + via_clock_init(&clock, chip_type); 1833 2069 init_gfx_chip_info(chip_type); 1834 2070 init_tmds_chip_info(); 1835 2071 init_lvds_chip_info(); 1836 - 1837 - viaparinfo->crt_setting_info->iga_path = IGA1; 1838 2072 1839 2073 /*Set IGA path for each device */ 1840 2074 viafb_set_iga_path(); ··· 2114 2354 outb(0x00, VIAAR); 2115 2355 2116 2356 /* Write Common Setting for Video Mode */ 2357 + viafb_write_regx(common_vga, ARRAY_SIZE(common_vga)); 2117 2358 switch (viaparinfo->chip_info->gfx_chip_name) { 2118 2359 case UNICHROME_CLE266: 2119 2360 viafb_write_regx(CLE266_ModeXregs, NUM_TOTAL_CLE266_ModeXregs); ··· 2161 2400 2162 2401 viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2); 2163 2402 2164 - /* Write CRTC */ 2165 - viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1); 2166 - 2167 2403 /* Write Graphic Controller */ 2168 2404 for (i = 0; i < StdGR; i++) 2169 2405 via_write_reg(VIAGR, i, VPIT.GR[i]); ··· 2190 2432 } 2191 2433 } 2192 2434 2435 + load_fix_bit_crtc_reg(); 2193 2436 via_set_primary_pitch(viafbinfo->fix.line_length); 2194 2437 via_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length 2195 2438 : viafbinfo->fix.line_length); ··· 2210 2451 2211 2452 /* CRT set mode */ 2212 2453 if (viafb_CRT_ON) { 2213 - if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == 2214 - IGA2)) { 2454 + if (viafb_SAMM_ON && 2455 + viaparinfo->shared->iga2_devices & VIA_CRT) { 2215 2456 viafb_fill_crtc_timing(crt_timing1, vmode_tbl1, 2216 - video_bpp1 / 8, 2217 - viaparinfo->crt_setting_info->iga_path); 2457 + video_bpp1 / 8, IGA2); 2218 2458 } else { 2219 2459 viafb_fill_crtc_timing(crt_timing, vmode_tbl, 2220 2460 video_bpp / 8, 2221 - viaparinfo->crt_setting_info->iga_path); 2461 + (viaparinfo->shared->iga1_devices & VIA_CRT) 2462 + ? IGA1 : IGA2); 2222 2463 } 2223 2464 2224 2465 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode ··· 2316 2557 get_sync(viafbinfo1)); 2317 2558 } 2318 2559 2560 + clock.set_engine_pll_state(VIA_STATE_ON); 2561 + clock.set_primary_clock_source(VIA_CLKSRC_X1, true); 2562 + clock.set_secondary_clock_source(VIA_CLKSRC_X1, true); 2563 + 2564 + #ifdef CONFIG_FB_VIA_X_COMPATIBILITY 2565 + clock.set_primary_pll_state(VIA_STATE_ON); 2566 + clock.set_primary_clock_state(VIA_STATE_ON); 2567 + clock.set_secondary_pll_state(VIA_STATE_ON); 2568 + clock.set_secondary_clock_state(VIA_STATE_ON); 2569 + #else 2570 + if (viaparinfo->shared->iga1_devices) { 2571 + clock.set_primary_pll_state(VIA_STATE_ON); 2572 + clock.set_primary_clock_state(VIA_STATE_ON); 2573 + } else { 2574 + clock.set_primary_pll_state(VIA_STATE_OFF); 2575 + clock.set_primary_clock_state(VIA_STATE_OFF); 2576 + } 2577 + 2578 + if (viaparinfo->shared->iga2_devices) { 2579 + clock.set_secondary_pll_state(VIA_STATE_ON); 2580 + clock.set_secondary_clock_state(VIA_STATE_ON); 2581 + } else { 2582 + clock.set_secondary_pll_state(VIA_STATE_OFF); 2583 + clock.set_secondary_clock_state(VIA_STATE_OFF); 2584 + } 2585 + #endif /*CONFIG_FB_VIA_X_COMPATIBILITY*/ 2586 + 2319 2587 via_set_state(devices, VIA_STATE_ON); 2320 2588 device_screen_on(); 2321 2589 return 1; ··· 2384 2598 best = &vmode->crtc[i]; 2385 2599 } 2386 2600 2387 - if (abs(best->refresh_rate - long_refresh) > 3) 2388 - return 60; 2601 + if (abs(best->refresh_rate - long_refresh) > 3) { 2602 + if (hres == 1200 && vres == 900) 2603 + return 49; /* OLPC DCON only supports 50 Hz */ 2604 + else 2605 + return 60; 2606 + } 2389 2607 2390 2608 return best->refresh_rate; 2391 2609 }
+3 -12
drivers/video/via/hw.h
··· 732 732 struct _lcd_ver_scaling_factor lcd_ver_scaling_factor; 733 733 }; 734 734 735 - struct pll_config { 736 - u16 multiplier; 735 + struct pll_limit { 736 + u16 multiplier_min; 737 + u16 multiplier_max; 737 738 u8 divisor; 738 739 u8 rshift; 739 - }; 740 - 741 - struct pll_map { 742 - u32 clk; 743 - struct pll_config cle266_pll; 744 - struct pll_config k800_pll; 745 - struct pll_config cx700_pll; 746 - struct pll_config vx855_pll; 747 740 }; 748 741 749 742 struct rgbLUT { ··· 903 910 const char *name; 904 911 }; 905 912 906 - extern unsigned int viafb_second_virtual_xres; 907 913 extern int viafb_SAMM_ON; 908 914 extern int viafb_dual_fb; 909 915 extern int viafb_LCD2_ON; ··· 928 936 void viafb_unlock_crt(void); 929 937 void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); 930 938 void viafb_write_regx(struct io_reg RegTable[], int ItemNum); 931 - u32 viafb_get_clk_value(int clk); 932 939 void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active); 933 940 void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ 934 941 *p_gfx_dpa_setting);
+8 -15
drivers/video/via/lcd.c
··· 48 48 {LCD_VER_SCALING_FACTOR_REG_NUM_CLE, {{CR78, 0, 7}, {CR79, 6, 7} } } 49 49 }; 50 50 51 - static int check_lvds_chip(int device_id_subaddr, int device_id); 52 51 static bool lvds_identify_integratedlvds(void); 53 52 static void __devinit fp_id_to_vindex(int panel_id); 54 53 static int lvds_register_read(int index); ··· 83 84 mode_crt_reg, 84 85 struct display_timing panel_crt_reg); 85 86 86 - static int check_lvds_chip(int device_id_subaddr, int device_id) 87 + static inline bool check_lvds_chip(int device_id_subaddr, int device_id) 87 88 { 88 - if (lvds_register_read(device_id_subaddr) == device_id) 89 - return OK; 90 - else 91 - return FAIL; 89 + return lvds_register_read(device_id_subaddr) == device_id; 92 90 } 93 91 94 92 void __devinit viafb_init_lcd_size(void) ··· 146 150 return true; 147 151 } 148 152 149 - int __devinit viafb_lvds_trasmitter_identify(void) 153 + bool __devinit viafb_lvds_trasmitter_identify(void) 150 154 { 151 155 if (viafb_lvds_identify_vt1636(VIA_PORT_31)) { 152 156 viaparinfo->chip_info->lvds_chip_info.i2c_port = VIA_PORT_31; ··· 171 175 viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = 172 176 VT1631_LVDS_I2C_ADDR; 173 177 174 - if (check_lvds_chip(VT1631_DEVICE_ID_REG, VT1631_DEVICE_ID) != FAIL) { 178 + if (check_lvds_chip(VT1631_DEVICE_ID_REG, VT1631_DEVICE_ID)) { 175 179 DEBUG_MSG(KERN_INFO "\n VT1631 LVDS ! \n"); 176 180 DEBUG_MSG(KERN_INFO "\n %2d", 177 181 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); 178 182 DEBUG_MSG(KERN_INFO "\n %2d", 179 183 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); 180 - return OK; 184 + return true; 181 185 } 182 186 183 187 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = 184 188 NON_LVDS_TRANSMITTER; 185 189 viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = 186 190 VT1631_LVDS_I2C_ADDR; 187 - return FAIL; 191 + return false; 188 192 } 189 193 190 194 static void __devinit fp_id_to_vindex(int panel_id) ··· 558 562 int set_vres = plvds_setting_info->v_active; 559 563 int panel_hres = plvds_setting_info->lcd_panel_hres; 560 564 int panel_vres = plvds_setting_info->lcd_panel_vres; 561 - u32 pll_D_N, clock; 565 + u32 clock; 562 566 struct display_timing mode_crt_reg, panel_crt_reg; 563 567 struct crt_mode_table *panel_crt_table = NULL; 564 568 struct VideoModeTable *vmode_tbl = viafb_get_mode(panel_hres, ··· 609 613 viafb_load_FIFO_reg(set_iga, set_hres, set_vres); 610 614 611 615 fill_lcd_format(); 612 - 613 - pll_D_N = viafb_get_clk_value(clock); 614 - DEBUG_MSG(KERN_INFO "PLL=0x%x", pll_D_N); 615 - viafb_set_vclock(pll_D_N, set_iga); 616 + viafb_set_vclock(clock, set_iga); 616 617 lcd_patch_skew(plvds_setting_info, plvds_chip_info); 617 618 618 619 /* If K8M800, enable LCD Prefetch Mode. */
+1 -1
drivers/video/via/lcd.h
··· 79 79 void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, 80 80 struct lvds_setting_information *plvds_setting_info, 81 81 struct lvds_chip_information *plvds_chip_info); 82 - int __devinit viafb_lvds_trasmitter_identify(void); 82 + bool __devinit viafb_lvds_trasmitter_identify(void); 83 83 void viafb_init_lvds_output_interface(struct lvds_chip_information 84 84 *plvds_chip_info, 85 85 struct lvds_setting_information
+1 -16
drivers/video/via/share.h
··· 22 22 #ifndef __SHARE_H__ 23 23 #define __SHARE_H__ 24 24 25 - /* Define Return Value */ 26 - #define FAIL -1 27 - #define OK 1 28 - 29 - #ifndef NULL 30 - #define NULL 0 31 - #endif 32 - 33 25 /* Define Bit Field */ 34 26 #define BIT0 0x01 35 27 #define BIT1 0x02 ··· 282 290 #define HW_LAYOUT_LCD_EXTERNAL_LCD2 0x10 283 291 284 292 /* Definition Refresh Rate */ 293 + #define REFRESH_49 49 285 294 #define REFRESH_50 50 286 295 #define REFRESH_60 60 287 296 #define REFRESH_75 75 ··· 568 575 #define M1280X720_R50_HSP NEGATIVE 569 576 #define M1280X720_R50_VSP POSITIVE 570 577 571 - /* 1280x720@60 Sync Polarity (CEA Mode) */ 572 - #define M1280X720_CEA_R60_HSP POSITIVE 573 - #define M1280X720_CEA_R60_VSP POSITIVE 574 - 575 578 /* 1440x900@60 Sync Polarity (CVT Mode) */ 576 579 #define M1440X900_R60_HSP NEGATIVE 577 580 #define M1440X900_R60_VSP POSITIVE ··· 607 618 /* 1920x1200@60 Sync Polarity (CVT Reduce Blanking Mode) */ 608 619 #define M1920X1200_RB_R60_HSP POSITIVE 609 620 #define M1920X1200_RB_R60_VSP NEGATIVE 610 - 611 - /* 1920x1080@60 Sync Polarity (CEA Mode) */ 612 - #define M1920X1080_CEA_R60_HSP POSITIVE 613 - #define M1920X1080_CEA_R60_VSP POSITIVE 614 621 615 622 /* 2048x1536@60 Sync Polarity (CVT Mode) */ 616 623 #define M2048x1536_R60_HSP NEGATIVE
+8 -1
drivers/video/via/via-core.c
··· 505 505 ret = vdev->fbmem_len = viafb_get_fb_size_from_pci(vdev->chip_type); 506 506 if (ret < 0) 507 507 goto out_unmap; 508 - vdev->fbmem = ioremap_nocache(vdev->fbmem_start, vdev->fbmem_len); 508 + 509 + /* try to map less memory on failure, 8 MB should be still enough */ 510 + for (; vdev->fbmem_len >= 8 << 20; vdev->fbmem_len /= 2) { 511 + vdev->fbmem = ioremap_wc(vdev->fbmem_start, vdev->fbmem_len); 512 + if (vdev->fbmem) 513 + break; 514 + } 515 + 509 516 if (vdev->fbmem == NULL) { 510 517 ret = -ENOMEM; 511 518 goto out_unmap;
+349
drivers/video/via/via_clock.c
··· 1 + /* 2 + * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. 3 + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. 4 + * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public 8 + * License as published by the Free Software Foundation; 9 + * either version 2, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even 13 + * the implied warranty of MERCHANTABILITY or FITNESS FOR 14 + * A PARTICULAR PURPOSE.See the GNU General Public License 15 + * for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 20 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 + */ 22 + /* 23 + * clock and PLL management functions 24 + */ 25 + 26 + #include <linux/kernel.h> 27 + #include <linux/via-core.h> 28 + #include "via_clock.h" 29 + #include "global.h" 30 + #include "debug.h" 31 + 32 + const char *via_slap = "Please slap VIA Technologies to motivate them " 33 + "releasing full documentation for your platform!\n"; 34 + 35 + static inline u32 cle266_encode_pll(struct via_pll_config pll) 36 + { 37 + return (pll.multiplier << 8) 38 + | (pll.rshift << 6) 39 + | pll.divisor; 40 + } 41 + 42 + static inline u32 k800_encode_pll(struct via_pll_config pll) 43 + { 44 + return ((pll.divisor - 2) << 16) 45 + | (pll.rshift << 10) 46 + | (pll.multiplier - 2); 47 + } 48 + 49 + static inline u32 vx855_encode_pll(struct via_pll_config pll) 50 + { 51 + return (pll.divisor << 16) 52 + | (pll.rshift << 10) 53 + | pll.multiplier; 54 + } 55 + 56 + static inline void cle266_set_primary_pll_encoded(u32 data) 57 + { 58 + via_write_reg_mask(VIASR, 0x40, 0x02, 0x02); /* enable reset */ 59 + via_write_reg(VIASR, 0x46, data & 0xFF); 60 + via_write_reg(VIASR, 0x47, (data >> 8) & 0xFF); 61 + via_write_reg_mask(VIASR, 0x40, 0x00, 0x02); /* disable reset */ 62 + } 63 + 64 + static inline void k800_set_primary_pll_encoded(u32 data) 65 + { 66 + via_write_reg_mask(VIASR, 0x40, 0x02, 0x02); /* enable reset */ 67 + via_write_reg(VIASR, 0x44, data & 0xFF); 68 + via_write_reg(VIASR, 0x45, (data >> 8) & 0xFF); 69 + via_write_reg(VIASR, 0x46, (data >> 16) & 0xFF); 70 + via_write_reg_mask(VIASR, 0x40, 0x00, 0x02); /* disable reset */ 71 + } 72 + 73 + static inline void cle266_set_secondary_pll_encoded(u32 data) 74 + { 75 + via_write_reg_mask(VIASR, 0x40, 0x04, 0x04); /* enable reset */ 76 + via_write_reg(VIASR, 0x44, data & 0xFF); 77 + via_write_reg(VIASR, 0x45, (data >> 8) & 0xFF); 78 + via_write_reg_mask(VIASR, 0x40, 0x00, 0x04); /* disable reset */ 79 + } 80 + 81 + static inline void k800_set_secondary_pll_encoded(u32 data) 82 + { 83 + via_write_reg_mask(VIASR, 0x40, 0x04, 0x04); /* enable reset */ 84 + via_write_reg(VIASR, 0x4A, data & 0xFF); 85 + via_write_reg(VIASR, 0x4B, (data >> 8) & 0xFF); 86 + via_write_reg(VIASR, 0x4C, (data >> 16) & 0xFF); 87 + via_write_reg_mask(VIASR, 0x40, 0x00, 0x04); /* disable reset */ 88 + } 89 + 90 + static inline void set_engine_pll_encoded(u32 data) 91 + { 92 + via_write_reg_mask(VIASR, 0x40, 0x01, 0x01); /* enable reset */ 93 + via_write_reg(VIASR, 0x47, data & 0xFF); 94 + via_write_reg(VIASR, 0x48, (data >> 8) & 0xFF); 95 + via_write_reg(VIASR, 0x49, (data >> 16) & 0xFF); 96 + via_write_reg_mask(VIASR, 0x40, 0x00, 0x01); /* disable reset */ 97 + } 98 + 99 + static void cle266_set_primary_pll(struct via_pll_config config) 100 + { 101 + cle266_set_primary_pll_encoded(cle266_encode_pll(config)); 102 + } 103 + 104 + static void k800_set_primary_pll(struct via_pll_config config) 105 + { 106 + k800_set_primary_pll_encoded(k800_encode_pll(config)); 107 + } 108 + 109 + static void vx855_set_primary_pll(struct via_pll_config config) 110 + { 111 + k800_set_primary_pll_encoded(vx855_encode_pll(config)); 112 + } 113 + 114 + static void cle266_set_secondary_pll(struct via_pll_config config) 115 + { 116 + cle266_set_secondary_pll_encoded(cle266_encode_pll(config)); 117 + } 118 + 119 + static void k800_set_secondary_pll(struct via_pll_config config) 120 + { 121 + k800_set_secondary_pll_encoded(k800_encode_pll(config)); 122 + } 123 + 124 + static void vx855_set_secondary_pll(struct via_pll_config config) 125 + { 126 + k800_set_secondary_pll_encoded(vx855_encode_pll(config)); 127 + } 128 + 129 + static void k800_set_engine_pll(struct via_pll_config config) 130 + { 131 + set_engine_pll_encoded(k800_encode_pll(config)); 132 + } 133 + 134 + static void vx855_set_engine_pll(struct via_pll_config config) 135 + { 136 + set_engine_pll_encoded(vx855_encode_pll(config)); 137 + } 138 + 139 + static void set_primary_pll_state(u8 state) 140 + { 141 + u8 value; 142 + 143 + switch (state) { 144 + case VIA_STATE_ON: 145 + value = 0x20; 146 + break; 147 + case VIA_STATE_OFF: 148 + value = 0x00; 149 + break; 150 + default: 151 + return; 152 + } 153 + 154 + via_write_reg_mask(VIASR, 0x2D, value, 0x30); 155 + } 156 + 157 + static void set_secondary_pll_state(u8 state) 158 + { 159 + u8 value; 160 + 161 + switch (state) { 162 + case VIA_STATE_ON: 163 + value = 0x08; 164 + break; 165 + case VIA_STATE_OFF: 166 + value = 0x00; 167 + break; 168 + default: 169 + return; 170 + } 171 + 172 + via_write_reg_mask(VIASR, 0x2D, value, 0x0C); 173 + } 174 + 175 + static void set_engine_pll_state(u8 state) 176 + { 177 + u8 value; 178 + 179 + switch (state) { 180 + case VIA_STATE_ON: 181 + value = 0x02; 182 + break; 183 + case VIA_STATE_OFF: 184 + value = 0x00; 185 + break; 186 + default: 187 + return; 188 + } 189 + 190 + via_write_reg_mask(VIASR, 0x2D, value, 0x03); 191 + } 192 + 193 + static void set_primary_clock_state(u8 state) 194 + { 195 + u8 value; 196 + 197 + switch (state) { 198 + case VIA_STATE_ON: 199 + value = 0x20; 200 + break; 201 + case VIA_STATE_OFF: 202 + value = 0x00; 203 + break; 204 + default: 205 + return; 206 + } 207 + 208 + via_write_reg_mask(VIASR, 0x1B, value, 0x30); 209 + } 210 + 211 + static void set_secondary_clock_state(u8 state) 212 + { 213 + u8 value; 214 + 215 + switch (state) { 216 + case VIA_STATE_ON: 217 + value = 0x80; 218 + break; 219 + case VIA_STATE_OFF: 220 + value = 0x00; 221 + break; 222 + default: 223 + return; 224 + } 225 + 226 + via_write_reg_mask(VIASR, 0x1B, value, 0xC0); 227 + } 228 + 229 + static inline u8 set_clock_source_common(enum via_clksrc source, bool use_pll) 230 + { 231 + u8 data = 0; 232 + 233 + switch (source) { 234 + case VIA_CLKSRC_X1: 235 + data = 0x00; 236 + break; 237 + case VIA_CLKSRC_TVX1: 238 + data = 0x02; 239 + break; 240 + case VIA_CLKSRC_TVPLL: 241 + data = 0x04; /* 0x06 should be the same */ 242 + break; 243 + case VIA_CLKSRC_DVP1TVCLKR: 244 + data = 0x0A; 245 + break; 246 + case VIA_CLKSRC_CAP0: 247 + data = 0xC; 248 + break; 249 + case VIA_CLKSRC_CAP1: 250 + data = 0x0E; 251 + break; 252 + } 253 + 254 + if (!use_pll) 255 + data |= 1; 256 + 257 + return data; 258 + } 259 + 260 + static void set_primary_clock_source(enum via_clksrc source, bool use_pll) 261 + { 262 + u8 data = set_clock_source_common(source, use_pll) << 4; 263 + via_write_reg_mask(VIACR, 0x6C, data, 0xF0); 264 + } 265 + 266 + static void set_secondary_clock_source(enum via_clksrc source, bool use_pll) 267 + { 268 + u8 data = set_clock_source_common(source, use_pll); 269 + via_write_reg_mask(VIACR, 0x6C, data, 0x0F); 270 + } 271 + 272 + static void dummy_set_clock_state(u8 state) 273 + { 274 + printk(KERN_INFO "Using undocumented set clock state.\n%s", via_slap); 275 + } 276 + 277 + static void dummy_set_clock_source(enum via_clksrc source, bool use_pll) 278 + { 279 + printk(KERN_INFO "Using undocumented set clock source.\n%s", via_slap); 280 + } 281 + 282 + static void dummy_set_pll_state(u8 state) 283 + { 284 + printk(KERN_INFO "Using undocumented set PLL state.\n%s", via_slap); 285 + } 286 + 287 + static void dummy_set_pll(struct via_pll_config config) 288 + { 289 + printk(KERN_INFO "Using undocumented set PLL.\n%s", via_slap); 290 + } 291 + 292 + void via_clock_init(struct via_clock *clock, int gfx_chip) 293 + { 294 + switch (gfx_chip) { 295 + case UNICHROME_CLE266: 296 + case UNICHROME_K400: 297 + clock->set_primary_clock_state = dummy_set_clock_state; 298 + clock->set_primary_clock_source = dummy_set_clock_source; 299 + clock->set_primary_pll_state = dummy_set_pll_state; 300 + clock->set_primary_pll = cle266_set_primary_pll; 301 + 302 + clock->set_secondary_clock_state = dummy_set_clock_state; 303 + clock->set_secondary_clock_source = dummy_set_clock_source; 304 + clock->set_secondary_pll_state = dummy_set_pll_state; 305 + clock->set_secondary_pll = cle266_set_secondary_pll; 306 + 307 + clock->set_engine_pll_state = dummy_set_pll_state; 308 + clock->set_engine_pll = dummy_set_pll; 309 + break; 310 + case UNICHROME_K800: 311 + case UNICHROME_PM800: 312 + case UNICHROME_CN700: 313 + case UNICHROME_CX700: 314 + case UNICHROME_CN750: 315 + case UNICHROME_K8M890: 316 + case UNICHROME_P4M890: 317 + case UNICHROME_P4M900: 318 + case UNICHROME_VX800: 319 + clock->set_primary_clock_state = set_primary_clock_state; 320 + clock->set_primary_clock_source = set_primary_clock_source; 321 + clock->set_primary_pll_state = set_primary_pll_state; 322 + clock->set_primary_pll = k800_set_primary_pll; 323 + 324 + clock->set_secondary_clock_state = set_secondary_clock_state; 325 + clock->set_secondary_clock_source = set_secondary_clock_source; 326 + clock->set_secondary_pll_state = set_secondary_pll_state; 327 + clock->set_secondary_pll = k800_set_secondary_pll; 328 + 329 + clock->set_engine_pll_state = set_engine_pll_state; 330 + clock->set_engine_pll = k800_set_engine_pll; 331 + break; 332 + case UNICHROME_VX855: 333 + case UNICHROME_VX900: 334 + clock->set_primary_clock_state = set_primary_clock_state; 335 + clock->set_primary_clock_source = set_primary_clock_source; 336 + clock->set_primary_pll_state = set_primary_pll_state; 337 + clock->set_primary_pll = vx855_set_primary_pll; 338 + 339 + clock->set_secondary_clock_state = set_secondary_clock_state; 340 + clock->set_secondary_clock_source = set_secondary_clock_source; 341 + clock->set_secondary_pll_state = set_secondary_pll_state; 342 + clock->set_secondary_pll = vx855_set_secondary_pll; 343 + 344 + clock->set_engine_pll_state = set_engine_pll_state; 345 + clock->set_engine_pll = vx855_set_engine_pll; 346 + break; 347 + 348 + } 349 + }
+76
drivers/video/via/via_clock.h
··· 1 + /* 2 + * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. 3 + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. 4 + * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public 8 + * License as published by the Free Software Foundation; 9 + * either version 2, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even 13 + * the implied warranty of MERCHANTABILITY or FITNESS FOR 14 + * A PARTICULAR PURPOSE.See the GNU General Public License 15 + * for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 20 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 + */ 22 + /* 23 + * clock and PLL management functions 24 + */ 25 + 26 + #ifndef __VIA_CLOCK_H__ 27 + #define __VIA_CLOCK_H__ 28 + 29 + #include <linux/types.h> 30 + 31 + enum via_clksrc { 32 + VIA_CLKSRC_X1 = 0, 33 + VIA_CLKSRC_TVX1, 34 + VIA_CLKSRC_TVPLL, 35 + VIA_CLKSRC_DVP1TVCLKR, 36 + VIA_CLKSRC_CAP0, 37 + VIA_CLKSRC_CAP1, 38 + }; 39 + 40 + struct via_pll_config { 41 + u16 multiplier; 42 + u8 divisor; 43 + u8 rshift; 44 + }; 45 + 46 + struct via_clock { 47 + void (*set_primary_clock_state)(u8 state); 48 + void (*set_primary_clock_source)(enum via_clksrc src, bool use_pll); 49 + void (*set_primary_pll_state)(u8 state); 50 + void (*set_primary_pll)(struct via_pll_config config); 51 + 52 + void (*set_secondary_clock_state)(u8 state); 53 + void (*set_secondary_clock_source)(enum via_clksrc src, bool use_pll); 54 + void (*set_secondary_pll_state)(u8 state); 55 + void (*set_secondary_pll)(struct via_pll_config config); 56 + 57 + void (*set_engine_pll_state)(u8 state); 58 + void (*set_engine_pll)(struct via_pll_config config); 59 + }; 60 + 61 + 62 + static inline u32 get_pll_internal_frequency(u32 ref_freq, 63 + struct via_pll_config pll) 64 + { 65 + return ref_freq / pll.divisor * pll.multiplier; 66 + } 67 + 68 + static inline u32 get_pll_output_frequency(u32 ref_freq, 69 + struct via_pll_config pll) 70 + { 71 + return get_pll_internal_frequency(ref_freq, pll) >> pll.rshift; 72 + } 73 + 74 + void via_clock_init(struct via_clock *clock, int gfx_chip); 75 + 76 + #endif /* __VIA_CLOCK_H__ */
+39 -23
drivers/video/via/viafbdev.c
··· 24 24 #include <linux/slab.h> 25 25 #include <linux/stat.h> 26 26 #include <linux/via-core.h> 27 + #include <asm/olpc.h> 27 28 28 29 #define _MASTER_FILE 29 30 #include "global.h" ··· 38 37 static int viafb_bpp = 32; 39 38 static int viafb_bpp1 = 32; 40 39 40 + static unsigned int viafb_second_xres = 640; 41 + static unsigned int viafb_second_yres = 480; 41 42 static unsigned int viafb_second_offset; 42 43 static int viafb_second_size; 43 44 ··· 443 440 if (viafb_SAMM_ON == 1) { 444 441 u.viamode.xres_sec = viafb_second_xres; 445 442 u.viamode.yres_sec = viafb_second_yres; 446 - u.viamode.virtual_xres_sec = viafb_second_virtual_xres; 447 - u.viamode.virtual_yres_sec = viafb_second_virtual_yres; 443 + u.viamode.virtual_xres_sec = viafb_dual_fb ? viafbinfo1->var.xres_virtual : viafbinfo->var.xres_virtual; 444 + u.viamode.virtual_yres_sec = viafb_dual_fb ? viafbinfo1->var.yres_virtual : viafbinfo->var.yres_virtual; 448 445 u.viamode.refresh_sec = viafb_refresh1; 449 446 u.viamode.bpp_sec = viafb_bpp1; 450 447 } else { ··· 933 930 /* Rule: device on iga1 path are the primary device. */ 934 931 if (viafb_SAMM_ON) { 935 932 if (viafb_CRT_ON) { 936 - if (viaparinfo->crt_setting_info->iga_path == IGA1) { 937 - DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", 938 - viaparinfo-> 939 - crt_setting_info->iga_path); 933 + if (viaparinfo->shared->iga1_devices & VIA_CRT) { 934 + DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", IGA1); 940 935 primary_device = CRT_Device; 941 936 } 942 937 } ··· 1012 1011 /* Note: The previous of active_dev is primary device, 1013 1012 and the following is secondary device. */ 1014 1013 if (!viafb_active_dev) { 1015 - viafb_CRT_ON = STATE_ON; 1016 - viafb_SAMM_ON = STATE_OFF; 1014 + if (machine_is_olpc()) { /* LCD only */ 1015 + viafb_LCD_ON = STATE_ON; 1016 + viafb_SAMM_ON = STATE_OFF; 1017 + } else { 1018 + viafb_CRT_ON = STATE_ON; 1019 + viafb_SAMM_ON = STATE_OFF; 1020 + } 1017 1021 } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { 1018 1022 /* CRT+DVI */ 1019 1023 viafb_CRT_ON = STATE_ON; ··· 1671 1665 char *ptr; 1672 1666 1673 1667 if (!str) { 1674 - *xres = 640; 1675 - *yres = 480; 1668 + if (machine_is_olpc()) { 1669 + *xres = 1200; 1670 + *yres = 900; 1671 + } else { 1672 + *xres = 640; 1673 + *yres = 480; 1674 + } 1676 1675 return 0; 1677 1676 } 1678 1677 ··· 1757 1746 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info; 1758 1747 viaparinfo->lvds_setting_info2 = 1759 1748 &viaparinfo->shared->lvds_setting_info2; 1760 - viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info; 1761 1749 viaparinfo->chip_info = &viaparinfo->shared->chip_info; 1762 1750 1763 1751 if (viafb_dual_fb) ··· 1803 1793 1804 1794 parse_mode(viafb_mode, &default_xres, &default_yres); 1805 1795 vmode_entry = viafb_get_mode(default_xres, default_yres); 1806 - if (viafb_SAMM_ON == 1) { 1796 + if (viafb_SAMM_ON == 1) 1807 1797 parse_mode(viafb_mode1, &viafb_second_xres, 1808 1798 &viafb_second_yres); 1809 - 1810 - viafb_second_virtual_xres = viafb_second_xres; 1811 - viafb_second_virtual_yres = viafb_second_yres; 1812 - } 1813 1799 1814 1800 default_var.xres = default_xres; 1815 1801 default_var.yres = default_yres; ··· 1850 1844 1851 1845 default_var.xres = viafb_second_xres; 1852 1846 default_var.yres = viafb_second_yres; 1853 - default_var.xres_virtual = viafb_second_virtual_xres; 1854 - default_var.yres_virtual = viafb_second_virtual_yres; 1847 + default_var.xres_virtual = viafb_second_xres; 1848 + default_var.yres_virtual = viafb_second_yres; 1855 1849 default_var.bits_per_pixel = viafb_bpp1; 1856 1850 viafb_fill_var_timing_info(&default_var, viafb_get_refresh( 1857 1851 default_var.xres, default_var.yres, viafb_refresh1), ··· 1933 1927 } 1934 1928 1935 1929 #ifndef MODULE 1936 - static int __init viafb_setup(char *options) 1930 + static int __init viafb_setup(void) 1937 1931 { 1938 1932 char *this_opt; 1933 + char *options; 1934 + 1939 1935 DEBUG_MSG(KERN_INFO "viafb_setup!\n"); 1936 + 1937 + if (fb_get_options("viafb", &options)) 1938 + return -ENODEV; 1940 1939 1941 1940 if (!options || !*options) 1942 1941 return 0; ··· 2016 2005 int __init viafb_init(void) 2017 2006 { 2018 2007 u32 dummy_x, dummy_y; 2008 + int r; 2009 + 2010 + if (machine_is_olpc()) 2011 + /* Apply XO-1.5-specific configuration. */ 2012 + viafb_lcd_panel_id = 23; 2013 + 2019 2014 #ifndef MODULE 2020 - char *option = NULL; 2021 - if (fb_get_options("viafb", &option)) 2022 - return -ENODEV; 2023 - viafb_setup(option); 2015 + r = viafb_setup(); 2016 + if (r < 0) 2017 + return r; 2024 2018 #endif 2025 2019 if (parse_mode(viafb_mode, &dummy_x, &dummy_y) 2026 2020 || !viafb_get_mode(dummy_x, dummy_y)
-4
drivers/video/via/viafbdev.h
··· 50 50 51 51 /* All the information will be needed to set engine */ 52 52 struct tmds_setting_information tmds_setting_info; 53 - struct crt_setting_information crt_setting_info; 54 53 struct lvds_setting_information lvds_setting_info; 55 54 struct lvds_setting_information lvds_setting_info2; 56 55 struct chip_information chip_info; ··· 78 79 /* All the information will be needed to set engine */ 79 80 /* depreciated, use the ones in shared directly */ 80 81 struct tmds_setting_information *tmds_setting_info; 81 - struct crt_setting_information *crt_setting_info; 82 82 struct lvds_setting_information *lvds_setting_info; 83 83 struct lvds_setting_information *lvds_setting_info2; 84 84 struct chip_information *chip_info; 85 85 }; 86 86 87 - extern unsigned int viafb_second_virtual_yres; 88 - extern unsigned int viafb_second_virtual_xres; 89 87 extern int viafb_SAMM_ON; 90 88 extern int viafb_dual_fb; 91 89 extern int viafb_LCD2_ON;
+3 -43
drivers/video/via/viamode.c
··· 30 30 {VIASR, SR1A, 0xFB, 0x08}, 31 31 {VIASR, SR1E, 0x0F, 0x01}, 32 32 {VIASR, SR2A, 0xFF, 0x00}, 33 - {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ 34 - {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ 35 - {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ 36 - {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ 37 33 {VIACR, CR32, 0xFF, 0x00}, 38 34 {VIACR, CR33, 0xFF, 0x00}, 39 35 {VIACR, CR35, 0xFF, 0x00}, ··· 37 41 {VIACR, CR69, 0xFF, 0x00}, 38 42 {VIACR, CR6A, 0xFF, 0x40}, 39 43 {VIACR, CR6B, 0xFF, 0x00}, 40 - {VIACR, CR6C, 0xFF, 0x00}, 41 44 {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 42 45 {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 43 46 {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ ··· 82 87 {VIACR, CR69, 0xFF, 0x00}, 83 88 {VIACR, CR6A, 0xFD, 0x40}, 84 89 {VIACR, CR6B, 0xFF, 0x00}, 85 - {VIACR, CR6C, 0xFF, 0x00}, 86 90 {VIACR, CR77, 0xFF, 0x00}, /* LCD scaling Factor */ 87 91 {VIACR, CR78, 0xFF, 0x00}, /* LCD scaling Factor */ 88 92 {VIACR, CR79, 0xFF, 0x00}, /* LCD scaling Factor */ ··· 119 125 {VIASR, SR2A, 0xFF, 0x00}, /* Power Management Control 5 */ 120 126 {VIASR, SR2D, 0xFF, 0xFF}, /* Power Management Control 1 */ 121 127 {VIASR, SR2E, 0xFF, 0xFF}, /* Power Management Control 2 */ 122 - {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ 123 - {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ 124 - {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ 125 - {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ 126 128 {VIACR, CR33, 0xFF, 0x00}, 127 129 {VIACR, CR55, 0x80, 0x00}, 128 130 {VIACR, CR5D, 0x80, 0x00}, ··· 151 161 {VIASR, SR1B, 0xFF, 0xF0}, 152 162 {VIASR, SR1E, 0xFF, 0x01}, 153 163 {VIASR, SR2A, 0xFF, 0x00}, 154 - {VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ 155 - {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ 156 - {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ 157 - {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ 158 - {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ 164 + {VIASR, SR2D, 0xC0, 0xC0}, /* delayed E3_ECK */ 159 165 {VIACR, CR32, 0xFF, 0x00}, 160 166 {VIACR, CR33, 0xFF, 0x00}, 161 167 {VIACR, CR35, 0xFF, 0x00}, ··· 160 174 {VIACR, CR69, 0xFF, 0x00}, 161 175 {VIACR, CR6A, 0xFF, 0x40}, 162 176 {VIACR, CR6B, 0xFF, 0x00}, 163 - {VIACR, CR6C, 0xFF, 0x00}, 164 177 {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 165 178 {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 166 179 {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ ··· 189 204 {VIASR, SR2A, 0xF0, 0x00}, 190 205 {VIASR, SR58, 0xFF, 0x00}, 191 206 {VIASR, SR59, 0xFF, 0x00}, 192 - {VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ 193 - {VIACR, CR09, 0xFF, 0x00}, /* Initial CR09=0*/ 194 - {VIACR, CR11, 0x8F, 0x00}, /* IGA1 initial Vertical end */ 195 - {VIACR, CR17, 0x7F, 0x00}, /* IGA1 CRT Mode control init */ 196 - {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ 197 - {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ 198 - {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ 199 - {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ 207 + {VIASR, SR2D, 0xC0, 0xC0}, /* delayed E3_ECK */ 200 208 {VIACR, CR32, 0xFF, 0x00}, 201 209 {VIACR, CR33, 0x7F, 0x00}, 202 210 {VIACR, CR35, 0xFF, 0x00}, ··· 197 219 {VIACR, CR69, 0xFF, 0x00}, 198 220 {VIACR, CR6A, 0xFD, 0x60}, 199 221 {VIACR, CR6B, 0xFF, 0x00}, 200 - {VIACR, CR6C, 0xFF, 0x00}, 201 222 {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ 202 223 {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ 203 224 {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ ··· 583 606 /* 1200x900 (DCON) */ 584 607 static struct crt_mode_table DCON1200x900[] = { 585 608 /* r_rate, hsp, vsp */ 586 - {REFRESH_60, M1200X900_R60_HSP, M1200X900_R60_VSP, 609 + {REFRESH_49, M1200X900_R60_HSP, M1200X900_R60_VSP, 587 610 /* The correct htotal is 1240, but this doesn't raster on VX855. */ 588 611 /* Via suggested changing to a multiple of 16, hence 1264. */ 589 612 /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ ··· 854 877 {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)} 855 878 }; 856 879 857 - struct crt_mode_table CEAM1280x720[] = { 858 - {REFRESH_60, M1280X720_CEA_R60_HSP, M1280X720_CEA_R60_VSP, 859 - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ 860 - {1650, 1280, 1280, 370, 1390, 40, 750, 720, 720, 30, 725, 5} } 861 - }; 862 - struct crt_mode_table CEAM1920x1080[] = { 863 - {REFRESH_60, M1920X1080_CEA_R60_HSP, M1920X1080_CEA_R60_VSP, 864 - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ 865 - {2200, 1920, 1920, 300, 2008, 44, 1125, 1080, 1080, 45, 1084, 5} } 866 - }; 867 - struct VideoModeTable CEA_HDMI_Modes[] = { 868 - /* Display : 1280x720 */ 869 - {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, 870 - {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} 871 - }; 872 - 873 - int NUM_TOTAL_CEA_MODES = ARRAY_SIZE(CEA_HDMI_Modes); 874 880 int NUM_TOTAL_CN400_ModeXregs = ARRAY_SIZE(CN400_ModeXregs); 875 881 int NUM_TOTAL_CN700_ModeXregs = ARRAY_SIZE(CN700_ModeXregs); 876 882 int NUM_TOTAL_KM400_ModeXregs = ARRAY_SIZE(KM400_ModeXregs);
-9
drivers/video/via/viamode.h
··· 41 41 struct io_reg *io_reg_table; 42 42 }; 43 43 44 - extern int NUM_TOTAL_CEA_MODES; 45 44 extern int NUM_TOTAL_CN400_ModeXregs; 46 45 extern int NUM_TOTAL_CN700_ModeXregs; 47 46 extern int NUM_TOTAL_KM400_ModeXregs; ··· 48 49 extern int NUM_TOTAL_VX855_ModeXregs; 49 50 extern int NUM_TOTAL_CLE266_ModeXregs; 50 51 extern int NUM_TOTAL_PATCH_MODE; 51 - 52 - /********************/ 53 - /* Mode Table */ 54 - /********************/ 55 - 56 - extern struct crt_mode_table CEAM1280x720[]; 57 - extern struct crt_mode_table CEAM1920x1080[]; 58 - extern struct VideoModeTable CEA_HDMI_Modes[]; 59 52 60 53 extern struct io_reg CN400_ModeXregs[]; 61 54 extern struct io_reg CN700_ModeXregs[];