27 static struct pll_limit cle266_pll_limits[] = {
58 static struct pll_limit k800_pll_limits[] = {
77 static struct pll_limit cx700_pll_limits[] = {
92 static struct pll_limit vx855_pll_limits[] = {
104 static struct io_reg scaling_parameters[] = {
121 static struct io_reg common_vga[] = {
194 static struct rgbLUT palLUT_table[] = {
197 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x2A}, {0x00, 0x2A, 0x00}, {0x00,
201 {0x2A, 0x00, 0x00}, {0x2A, 0x00, 0x2A}, {0x2A, 0x15, 0x00}, {0x2A,
205 {0x15, 0x15, 0x15}, {0x15, 0x15, 0x3F}, {0x15, 0x3F, 0x15}, {0x15,
209 {0x3F, 0x15, 0x15}, {0x3F, 0x15, 0x3F}, {0x3F, 0x3F, 0x15}, {0x3F,
213 {0x00, 0x00, 0x00}, {0x05, 0x05, 0x05}, {0x08, 0x08, 0x08}, {0x0B,
217 {0x0E, 0x0E, 0x0E}, {0x11, 0x11, 0x11}, {0x14, 0x14, 0x14}, {0x18,
221 {0x1C, 0x1C, 0x1C}, {0x20, 0x20, 0x20}, {0x24, 0x24, 0x24}, {0x28,
225 {0x2D, 0x2D, 0x2D}, {0x32, 0x32, 0x32}, {0x38, 0x38, 0x38}, {0x3F,
229 {0x00, 0x00, 0x3F}, {0x10, 0x00, 0x3F}, {0x1F, 0x00, 0x3F}, {0x2F,
233 {0x3F, 0x00, 0x3F}, {0x3F, 0x00, 0x2F}, {0x3F, 0x00, 0x1F}, {0x3F,
237 {0x3F, 0x00, 0x00}, {0x3F, 0x10, 0x00}, {0x3F, 0x1F, 0x00}, {0x3F,
241 {0x3F, 0x3F, 0x00}, {0x2F, 0x3F, 0x00}, {0x1F, 0x3F, 0x00}, {0x10,
245 {0x00, 0x3F, 0x00}, {0x00, 0x3F, 0x10}, {0x00, 0x3F, 0x1F}, {0x00,
249 {0x00, 0x3F, 0x3F}, {0x00, 0x2F, 0x3F}, {0x00, 0x1F, 0x3F}, {0x00,
253 {0x1F, 0x1F, 0x3F}, {0x27, 0x1F, 0x3F}, {0x2F, 0x1F, 0x3F}, {0x37,
257 {0x3F, 0x1F, 0x3F}, {0x3F, 0x1F, 0x37}, {0x3F, 0x1F, 0x2F}, {0x3F,
261 {0x3F, 0x1F, 0x1F}, {0x3F, 0x27, 0x1F}, {0x3F, 0x2F, 0x1F}, {0x3F,
265 {0x3F, 0x3F, 0x1F}, {0x37, 0x3F, 0x1F}, {0x2F, 0x3F, 0x1F}, {0x27,
269 {0x1F, 0x3F, 0x1F}, {0x1F, 0x3F, 0x27}, {0x1F, 0x3F, 0x2F}, {0x1F,
273 {0x1F, 0x3F, 0x3F}, {0x1F, 0x37, 0x3F}, {0x1F, 0x2F, 0x3F}, {0x1F,
277 {0x2D, 0x2D, 0x3F}, {0x31, 0x2D, 0x3F}, {0x36, 0x2D, 0x3F}, {0x3A,
281 {0x3F, 0x2D, 0x3F}, {0x3F, 0x2D, 0x3A}, {0x3F, 0x2D, 0x36}, {0x3F,
285 {0x3F, 0x2D, 0x2D}, {0x3F, 0x31, 0x2D}, {0x3F, 0x36, 0x2D}, {0x3F,
289 {0x3F, 0x3F, 0x2D}, {0x3A, 0x3F, 0x2D}, {0x36, 0x3F, 0x2D}, {0x31,
293 {0x2D, 0x3F, 0x2D}, {0x2D, 0x3F, 0x31}, {0x2D, 0x3F, 0x36}, {0x2D,
297 {0x2D, 0x3F, 0x3F}, {0x2D, 0x3A, 0x3F}, {0x2D, 0x36, 0x3F}, {0x2D,
301 {0x00, 0x00, 0x1C}, {0x07, 0x00, 0x1C}, {0x0E, 0x00, 0x1C}, {0x15,
305 {0x1C, 0x00, 0x1C}, {0x1C, 0x00, 0x15}, {0x1C, 0x00, 0x0E}, {0x1C,
309 {0x1C, 0x00, 0x00}, {0x1C, 0x07, 0x00}, {0x1C, 0x0E, 0x00}, {0x1C,
313 {0x1C, 0x1C, 0x00}, {0x15, 0x1C, 0x00}, {0x0E, 0x1C, 0x00}, {0x07,
317 {0x00, 0x1C, 0x00}, {0x00, 0x1C, 0x07}, {0x00, 0x1C, 0x0E}, {0x00,
321 {0x00, 0x1C, 0x1C}, {0x00, 0x15, 0x1C}, {0x00, 0x0E, 0x1C}, {0x00,
325 {0x0E, 0x0E, 0x1C}, {0x11, 0x0E, 0x1C}, {0x15, 0x0E, 0x1C}, {0x18,
329 {0x1C, 0x0E, 0x1C}, {0x1C, 0x0E, 0x18}, {0x1C, 0x0E, 0x15}, {0x1C,
333 {0x1C, 0x0E, 0x0E}, {0x1C, 0x11, 0x0E}, {0x1C, 0x15, 0x0E}, {0x1C,
337 {0x1C, 0x1C, 0x0E}, {0x18, 0x1C, 0x0E}, {0x15, 0x1C, 0x0E}, {0x11,
341 {0x0E, 0x1C, 0x0E}, {0x0E, 0x1C, 0x11}, {0x0E, 0x1C, 0x15}, {0x0E,
345 {0x0E, 0x1C, 0x1C}, {0x0E, 0x18, 0x1C}, {0x0E, 0x15, 0x1C}, {0x0E,
349 {0x14, 0x14, 0x1C}, {0x16, 0x14, 0x1C}, {0x18, 0x14, 0x1C}, {0x1A,
353 {0x1C, 0x14, 0x1C}, {0x1C, 0x14, 0x1A}, {0x1C, 0x14, 0x18}, {0x1C,
357 {0x1C, 0x14, 0x14}, {0x1C, 0x16, 0x14}, {0x1C, 0x18, 0x14}, {0x1C,
361 {0x1C, 0x1C, 0x14}, {0x1A, 0x1C, 0x14}, {0x18, 0x1C, 0x14}, {0x16,
365 {0x14, 0x1C, 0x14}, {0x14, 0x1C, 0x16}, {0x14, 0x1C, 0x18}, {0x14,
369 {0x14, 0x1C, 0x1C}, {0x14, 0x1A, 0x1C}, {0x14, 0x18, 0x1C}, {0x14,
373 {0x00, 0x00, 0x10}, {0x04, 0x00, 0x10}, {0x08, 0x00, 0x10}, {0x0C,
377 {0x10, 0x00, 0x10}, {0x10, 0x00, 0x0C}, {0x10, 0x00, 0x08}, {0x10,
381 {0x10, 0x00, 0x00}, {0x10, 0x04, 0x00}, {0x10, 0x08, 0x00}, {0x10,
385 {0x10, 0x10, 0x00}, {0x0C, 0x10, 0x00}, {0x08, 0x10, 0x00}, {0x04,
389 {0x00, 0x10, 0x00}, {0x00, 0x10, 0x04}, {0x00, 0x10, 0x08}, {0x00,
393 {0x00, 0x10, 0x10}, {0x00, 0x0C, 0x10}, {0x00, 0x08, 0x10}, {0x00,
397 {0x08, 0x08, 0x10}, {0x0A, 0x08, 0x10}, {0x0C, 0x08, 0x10}, {0x0E,
401 {0x10, 0x08, 0x10}, {0x10, 0x08, 0x0E}, {0x10, 0x08, 0x0C}, {0x10,
405 {0x10, 0x08, 0x08}, {0x10, 0x0A, 0x08}, {0x10, 0x0C, 0x08}, {0x10,
409 {0x10, 0x10, 0x08}, {0x0E, 0x10, 0x08}, {0x0C, 0x10, 0x08}, {0x0A,
413 {0x08, 0x10, 0x08}, {0x08, 0x10, 0x0A}, {0x08, 0x10, 0x0C}, {0x08,
417 {0x08, 0x10, 0x10}, {0x08, 0x0E, 0x10}, {0x08, 0x0C, 0x10}, {0x08,
421 {0x0B, 0x0B, 0x10}, {0x0C, 0x0B, 0x10}, {0x0D, 0x0B, 0x10}, {0x0F,
425 {0x10, 0x0B, 0x10}, {0x10, 0x0B, 0x0F}, {0x10, 0x0B, 0x0D}, {0x10,
429 {0x10, 0x0B, 0x0B}, {0x10, 0x0C, 0x0B}, {0x10, 0x0D, 0x0B}, {0x10,
433 {0x10, 0x10, 0x0B}, {0x0F, 0x10, 0x0B}, {0x0D, 0x10, 0x0B}, {0x0C,
437 {0x0B, 0x10, 0x0B}, {0x0B, 0x10, 0x0C}, {0x0B, 0x10, 0x0D}, {0x0B,
441 {0x0B, 0x10, 0x10}, {0x0B, 0x0F, 0x10}, {0x0B, 0x0D, 0x10}, {0x0B,
445 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00,
449 {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00,
467 static void load_fix_bit_crtc_reg(
void);
469 static void __devinit init_tmds_chip_info(
void);
470 static void __devinit init_lvds_chip_info(
void);
471 static void device_screen_off(
void);
472 static void device_screen_on(
void);
473 static void set_display_channel(
void);
474 static void device_off(
void);
475 static void device_on(
void);
476 static void enable_second_display_channel(
void);
477 static void disable_second_display_channel(
void);
498 static u32 get_dvi_devices(
int output_interface)
500 switch (output_interface) {
529 static u32 get_lcd_devices(
int output_interface)
531 switch (output_interface) {
561 int crt_iga_path = 0;
584 lvds_setting_info->iga_path =
IGA2;
587 tmds_setting_info->iga_path =
IGA1;
590 lvds_setting_info->iga_path =
IGA1;
628 if (crt_iga_path ==
IGA1)
636 viaparinfo->shared->iga1_devices |= get_dvi_devices(
638 tmds_chip_info.output_interface);
640 viaparinfo->shared->iga2_devices |= get_dvi_devices(
642 tmds_chip_info.output_interface);
647 viaparinfo->shared->iga1_devices |= get_lcd_devices(
649 lvds_chip_info.output_interface);
651 viaparinfo->shared->iga2_devices |= get_lcd_devices(
653 lvds_chip_info.output_interface);
658 viaparinfo->shared->iga1_devices |= get_lcd_devices(
660 lvds_chip_info2.output_interface);
662 viaparinfo->shared->iga2_devices |= get_lcd_devices(
664 lvds_chip_info2.output_interface);
668 if (machine_is_olpc())
684 set_color_register(index, red, green, blue);
690 set_color_register(index, red, green, blue);
709 via_write_reg_mask(
VIACR, index, value, mask);
712 static void set_crt_source(
u8 iga)
728 via_write_reg_mask(
VIASR, 0x16, value, 0x40);
731 static inline void set_ldvp0_source(
u8 iga)
733 set_source_common(0x6C, 7, iga);
736 static inline void set_ldvp1_source(
u8 iga)
738 set_source_common(0x93, 7, iga);
741 static inline void set_dvp0_source(
u8 iga)
743 set_source_common(0x96, 4, iga);
746 static inline void set_dvp1_source(
u8 iga)
748 set_source_common(0x9B, 4, iga);
751 static inline void set_lvds1_source(
u8 iga)
753 set_source_common(0x99, 4, iga);
756 static inline void set_lvds2_source(
u8 iga)
758 set_source_common(0x97, 4, iga);
764 set_ldvp0_source(iga);
766 set_ldvp1_source(iga);
768 set_dvp0_source(iga);
772 set_dvp1_source(iga);
774 set_lvds1_source(iga);
776 set_lvds2_source(iga);
779 static void set_crt_state(
u8 state)
800 via_write_reg_mask(
VIACR, 0x36, value, 0x30);
803 static void set_dvp0_state(
u8 state)
818 via_write_reg_mask(
VIASR, 0x1E, value, 0xC0);
821 static void set_dvp1_state(
u8 state)
836 via_write_reg_mask(
VIASR, 0x1E, value, 0x30);
839 static void set_lvds1_state(
u8 state)
854 via_write_reg_mask(
VIASR, 0x2A, value, 0x03);
857 static void set_lvds2_state(
u8 state)
872 via_write_reg_mask(
VIASR, 0x2A, value, 0x0C);
883 set_dvp0_state(state);
885 set_crt_state(state);
887 set_dvp1_state(state);
889 set_lvds1_state(state);
891 set_lvds2_state(state);
903 via_write_misc_reg_mask(polarity << 6, 0xC0);
905 via_write_reg_mask(
VIACR, 0x9B, polarity << 5, 0x60);
907 via_write_reg_mask(
VIACR, 0x99, polarity << 5, 0x60);
909 via_write_reg_mask(
VIACR, 0x97, polarity << 5, 0x60);
921 for (i = 0; i <
ARRAY_SIZE(device_mapping); i++) {
923 if (!
strncmp(ptr, device_mapping[i].name, len)) {
924 odev |= device_mapping[
i].
device;
942 for (i = 0; i <
ARRAY_SIZE(device_mapping); i++) {
943 if (odev & device_mapping[i].
device) {
955 static void load_fix_bit_crtc_reg(
void)
988 int start_index, end_index, cr_index;
991 for (i = 0; i < viafb_load_reg_num; i++) {
998 shift_next_reg = bit_num;
999 for (j = start_index; j <= end_index; j++) {
1001 reg_mask = reg_mask | (
BIT0 <<
j);
1002 get_bit = (timing_value & (
BIT0 << bit_num));
1004 data | ((get_bit >> shift_next_reg) << start_index);
1007 if (io_type ==
VIACR)
1022 for (i = 0; i < ItemNum; i++)
1023 via_write_reg_mask(RegTable[i].
port, RegTable[i].index,
1024 RegTable[i].value, RegTable[i].mask);
1030 int viafb_load_reg_num;
1036 viafb_load_reg_num = fetch_count_reg.
1037 iga1_fetch_count_reg.reg_num;
1043 viafb_load_reg_num = fetch_count_reg.
1044 iga2_fetch_count_reg.reg_num;
1055 int viafb_load_reg_num;
1057 int iga1_fifo_max_depth = 0, iga1_fifo_threshold =
1059 int iga2_fifo_max_depth = 0, iga2_fifo_threshold =
1062 if (set_iga ==
IGA1) {
1066 iga1_fifo_high_threshold =
1070 if ((hor_active > 1280) && (ver_active > 1024))
1081 iga1_fifo_high_threshold =
1088 if ((hor_active > 1280) && (ver_active > 1024))
1098 iga1_fifo_high_threshold =
1103 if ((hor_active > 1280) && (ver_active > 1024))
1113 iga1_fifo_high_threshold =
1122 iga1_fifo_high_threshold =
1131 iga1_fifo_high_threshold =
1140 iga1_fifo_high_threshold =
1149 iga1_fifo_high_threshold =
1158 iga1_fifo_high_threshold =
1167 iga1_fifo_high_threshold =
1175 viafb_load_reg_num =
1182 viafb_load_reg_num =
1183 fifo_threshold_select_reg.
1184 iga1_fifo_threshold_select_reg.reg_num;
1186 fifo_threshold_select_reg.
1187 iga1_fifo_threshold_select_reg.reg;
1193 viafb_load_reg_num =
1194 fifo_high_threshold_select_reg.
1195 iga1_fifo_high_threshold_select_reg.reg_num;
1197 fifo_high_threshold_select_reg.
1198 iga1_fifo_high_threshold_select_reg.reg;
1205 viafb_load_reg_num =
1206 display_queue_expire_num_reg.
1207 iga1_display_queue_expire_num_reg.reg_num;
1209 display_queue_expire_num_reg.
1210 iga1_display_queue_expire_num_reg.reg;
1217 iga2_fifo_high_threshold =
1222 if ((hor_active > 1280) && (ver_active > 1024))
1232 iga2_fifo_high_threshold =
1237 if ((hor_active > 1280) && (ver_active > 1024))
1247 iga2_fifo_high_threshold =
1252 if ((hor_active > 1280) && (ver_active > 1024))
1262 iga2_fifo_high_threshold =
1271 iga2_fifo_high_threshold =
1280 iga2_fifo_high_threshold =
1289 iga2_fifo_high_threshold =
1298 iga2_fifo_high_threshold =
1307 iga2_fifo_high_threshold =
1316 iga2_fifo_high_threshold =
1328 viafb_load_reg_num =
1329 display_fifo_depth_reg.
1330 iga2_fifo_depth_select_reg.reg_num;
1332 display_fifo_depth_reg.
1333 iga2_fifo_depth_select_reg.reg;
1335 viafb_load_reg_num, reg,
VIACR);
1341 viafb_load_reg_num =
1342 display_fifo_depth_reg.
1343 iga2_fifo_depth_select_reg.reg_num;
1345 display_fifo_depth_reg.
1346 iga2_fifo_depth_select_reg.reg;
1348 viafb_load_reg_num, reg,
VIACR);
1353 viafb_load_reg_num =
1354 fifo_threshold_select_reg.
1355 iga2_fifo_threshold_select_reg.reg_num;
1357 fifo_threshold_select_reg.
1358 iga2_fifo_threshold_select_reg.reg;
1364 viafb_load_reg_num =
1365 fifo_high_threshold_select_reg.
1366 iga2_fifo_high_threshold_select_reg.reg_num;
1368 fifo_high_threshold_select_reg.
1369 iga2_fifo_high_threshold_select_reg.reg;
1376 viafb_load_reg_num =
1377 display_queue_expire_num_reg.
1378 iga2_display_queue_expire_num_reg.reg_num;
1380 display_queue_expire_num_reg.
1381 iga2_display_queue_expire_num_reg.reg;
1392 const u32 f0 = 14318180;
1395 for (i = 0; i <
size; i++) {
1398 cur.multiplier =
clk / ((f0 /
cur.divisor)>>
cur.rshift);
1399 f =
abs(get_pll_output_frequency(f0,
cur) -
clk);
1403 if (
abs(get_pll_output_frequency(f0,
up) -
clk) < f)
1405 else if (
abs(get_pll_output_frequency(f0,
down) -
clk) < f)
1408 if (
cur.multiplier < limits[i].multiplier_min)
1409 cur.multiplier = limits[
i].multiplier_min;
1410 else if (
cur.multiplier > limits[i].multiplier_max)
1411 cur.multiplier = limits[
i].multiplier_max;
1413 f =
abs(get_pll_output_frequency(f0,
cur) -
clk);
1414 if (f <
abs(get_pll_output_frequency(f0, best) -
clk))
1425 switch (
viaparinfo->chip_info->gfx_chip_name) {
1428 config = get_pll_config(cle266_pll_limits,
1434 config = get_pll_config(k800_pll_limits,
1443 config = get_pll_config(cx700_pll_limits,
1448 config = get_pll_config(vx855_pll_limits,
1461 if (set_iga ==
IGA1)
1462 clock.set_primary_pll(config);
1463 if (set_iga ==
IGA2)
1464 clock.set_secondary_pll(config);
1467 via_write_misc_reg_mask(0x0C, 0x0C);
1474 u16 dx = (var->xres - cxres) / 2, dy = (var->yres - cyres) / 2;
1492 u16 cxres,
u16 cyres,
int iga)
1495 cxres ? cxres : var->
xres, cyres ? cyres : var->
yres);
1499 else if (iga ==
IGA2)
1513 init_gfx_chip_info(chip_type);
1514 init_tmds_chip_info();
1515 init_lvds_chip_info();
1522 viaparinfo->lvds_setting_info2->display_method =
1523 viaparinfo->lvds_setting_info->display_method;
1531 viaparinfo->tmds_setting_info->h_active = hres;
1532 viaparinfo->tmds_setting_info->v_active = vres;
1536 viaparinfo->tmds_setting_info->h_active = hres;
1537 viaparinfo->tmds_setting_info->v_active = vres;
1570 }
else if (tmp & 0x40) {
1580 switch (
viaparinfo->chip_info->gfx_chip_name) {
1596 static void __devinit init_tmds_chip_info(
void)
1602 switch (
viaparinfo->chip_info->gfx_chip_name) {
1623 viaparinfo->chip_info->tmds_chip_info.output_interface =
1636 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
1641 static void __devinit init_lvds_chip_info(
void)
1647 if (
viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1649 lvds_chip_info2,
viaparinfo->lvds_setting_info2);
1658 lvds_chip_info2.lvds_chip_name)) {
1659 viaparinfo->chip_info->lvds_chip_info.output_interface =
1668 viaparinfo->chip_info->lvds_chip_info.lvds_chip_name);
1670 viaparinfo->chip_info->lvds_chip_info.output_interface);
1672 viaparinfo->chip_info->lvds_chip_info.output_interface);
1680 if (set_iga ==
IGA1) {
1685 for (i = 0; i < 256; i++) {
1686 write_dac_reg(i, palLUT_table[i].
red,
1687 palLUT_table[i].
green,
1688 palLUT_table[i].
blue);
1697 for (i = 0; i < 256; i++) {
1698 write_dac_reg(i, palLUT_table[i].
red,
1699 palLUT_table[i].
green,
1700 palLUT_table[i].
blue);
1708 static void device_screen_off(
void)
1714 static void device_screen_on(
void)
1720 static void set_display_channel(
void)
1725 viaparinfo->lvds_setting_info2->device_lcd_dualedge) {
1737 if (
viaparinfo->lvds_setting_info->device_lcd_dualedge) {
1759 static void hw_init(
void)
1768 switch (
viaparinfo->chip_info->gfx_chip_name) {
1801 via_write_reg_mask(
VIACR, 0x45, 0x00, 0x01);
1804 via_write_reg_mask(
VIACR, 0xFD, 0, 0x80);
1812 for (i = 1; i <=
StdSR; i++)
1813 via_write_reg(
VIASR, i,
VPIT.SR[i - 1]);
1818 for (i = 0; i <
StdGR; i++)
1822 for (i = 0; i <
StdAR; i++) {
1831 load_fix_bit_crtc_reg();
1836 int j, cxres = 0, cyres = 0;
1843 device_screen_off();
1872 enable_second_display_channel();
1874 disable_second_display_channel();
1929 viaparinfo->lvds_setting_info->display_method =
1946 viaparinfo->lvds_setting_info2->display_method =
1957 set_display_channel();
1985 #ifdef CONFIG_FB_VIA_X_COMPATIBILITY
2022 if (hres == 1200 && vres == 900)
2031 static void device_off(
void)
2037 static void device_on(
void)
2045 static void enable_second_display_channel(
void)
2053 static void disable_second_display_channel(
void)
2064 switch (output_interface) {
2069 p_gfx_dpa_setting->
DVP0, 0x0F);
2088 p_gfx_dpa_setting->
DVP1, 0x0F);
2099 p_gfx_dpa_setting->
DFPHigh, 0x0F);
2106 p_gfx_dpa_setting->
DFPLow, 0x0F);
2113 p_gfx_dpa_setting->
DFPHigh, 0x0F);
2115 p_gfx_dpa_setting->
DFPLow, 0x0F);