diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2011-04-24 09:18:48 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2011-04-24 09:18:48 -0400 |
commit | f33f6f0ccc5ff7415da3feb18b1ff966ed2d80d1 (patch) | |
tree | 5074abce8a7cffd69519194c8b5b627de1099dca /drivers/video/via/hw.c | |
parent | 75ec72f8c53b9f981e68704432a2e425a01f79b7 (diff) | |
parent | 2946294f9aa734efc5873ea2f34131d0a8c0f89a (diff) |
Merge branch 'viafb-pll' into viafb-next
Conflicts:
drivers/video/via/viamode.c
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/via/hw.c')
-rw-r--r-- | drivers/video/via/hw.c | 529 |
1 files changed, 144 insertions, 385 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index 3308f471b68a..47b13535ed2b 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -22,273 +22,82 @@ | |||
22 | #include <linux/via-core.h> | 22 | #include <linux/via-core.h> |
23 | #include <asm/olpc.h> | 23 | #include <asm/olpc.h> |
24 | #include "global.h" | 24 | #include "global.h" |
25 | 25 | #include "via_clock.h" | |
26 | static struct pll_config cle266_pll_config[] = { | 26 | |
27 | {19, 4, 0}, | 27 | static struct pll_limit cle266_pll_limits[] = { |
28 | {26, 5, 0}, | 28 | {19, 19, 4, 0}, |
29 | {28, 5, 0}, | 29 | {26, 102, 5, 0}, |
30 | {31, 5, 0}, | 30 | {53, 112, 6, 0}, |
31 | {33, 5, 0}, | 31 | {41, 100, 7, 0}, |
32 | {55, 5, 0}, | 32 | {83, 108, 8, 0}, |
33 | {102, 5, 0}, | 33 | {87, 118, 9, 0}, |
34 | {53, 6, 0}, | 34 | {95, 115, 12, 0}, |
35 | {92, 6, 0}, | 35 | {108, 108, 13, 0}, |
36 | {98, 6, 0}, | 36 | {83, 83, 17, 0}, |
37 | {112, 6, 0}, | 37 | {67, 98, 20, 0}, |
38 | {41, 7, 0}, | 38 | {121, 121, 24, 0}, |
39 | {60, 7, 0}, | 39 | {99, 99, 29, 0}, |
40 | {99, 7, 0}, | 40 | {33, 33, 3, 1}, |
41 | {100, 7, 0}, | 41 | {15, 23, 4, 1}, |
42 | {83, 8, 0}, | 42 | {37, 121, 5, 1}, |
43 | {86, 8, 0}, | 43 | {82, 82, 6, 1}, |
44 | {108, 8, 0}, | 44 | {31, 84, 7, 1}, |
45 | {87, 9, 0}, | 45 | {83, 83, 8, 1}, |
46 | {118, 9, 0}, | 46 | {76, 127, 9, 1}, |
47 | {95, 12, 0}, | 47 | {33, 121, 4, 2}, |
48 | {115, 12, 0}, | 48 | {91, 118, 5, 2}, |
49 | {108, 13, 0}, | 49 | {83, 109, 6, 2}, |
50 | {83, 17, 0}, | 50 | {90, 90, 7, 2}, |
51 | {67, 20, 0}, | 51 | {93, 93, 2, 3}, |
52 | {86, 20, 0}, | 52 | {53, 53, 3, 3}, |
53 | {98, 20, 0}, | 53 | {73, 117, 4, 3}, |
54 | {121, 24, 0}, | 54 | {101, 127, 5, 3}, |
55 | {99, 29, 0}, | 55 | {99, 99, 7, 3} |
56 | {33, 3, 1}, | ||
57 | {15, 4, 1}, | ||
58 | {23, 4, 1}, | ||
59 | {37, 5, 1}, | ||
60 | {83, 5, 1}, | ||
61 | {85, 5, 1}, | ||
62 | {94, 5, 1}, | ||
63 | {103, 5, 1}, | ||
64 | {109, 5, 1}, | ||
65 | {113, 5, 1}, | ||
66 | {121, 5, 1}, | ||
67 | {82, 6, 1}, | ||
68 | {31, 7, 1}, | ||
69 | {55, 7, 1}, | ||
70 | {84, 7, 1}, | ||
71 | {83, 8, 1}, | ||
72 | {76, 9, 1}, | ||
73 | {127, 9, 1}, | ||
74 | {33, 4, 2}, | ||
75 | {75, 4, 2}, | ||
76 | {119, 4, 2}, | ||
77 | {121, 4, 2}, | ||
78 | {91, 5, 2}, | ||
79 | {118, 5, 2}, | ||
80 | {83, 6, 2}, | ||
81 | {109, 6, 2}, | ||
82 | {90, 7, 2}, | ||
83 | {93, 2, 3}, | ||
84 | {53, 3, 3}, | ||
85 | {73, 4, 3}, | ||
86 | {89, 4, 3}, | ||
87 | {105, 4, 3}, | ||
88 | {117, 4, 3}, | ||
89 | {101, 5, 3}, | ||
90 | {121, 5, 3}, | ||
91 | {127, 5, 3}, | ||
92 | {99, 7, 3} | ||
93 | }; | 56 | }; |
94 | 57 | ||
95 | static struct pll_config k800_pll_config[] = { | 58 | static struct pll_limit k800_pll_limits[] = { |
96 | {22, 2, 0}, | 59 | {22, 22, 2, 0}, |
97 | {28, 3, 0}, | 60 | {28, 28, 3, 0}, |
98 | {81, 3, 1}, | 61 | {81, 112, 3, 1}, |
99 | {85, 3, 1}, | 62 | {86, 166, 4, 1}, |
100 | {98, 3, 1}, | 63 | {109, 153, 5, 1}, |
101 | {112, 3, 1}, | 64 | {66, 116, 3, 2}, |
102 | {86, 4, 1}, | 65 | {93, 137, 4, 2}, |
103 | {166, 4, 1}, | 66 | {117, 208, 5, 2}, |
104 | {109, 5, 1}, | 67 | {30, 30, 2, 3}, |
105 | {113, 5, 1}, | 68 | {69, 125, 3, 3}, |
106 | {121, 5, 1}, | 69 | {89, 161, 4, 3}, |
107 | {131, 5, 1}, | 70 | {121, 208, 5, 3}, |
108 | {143, 5, 1}, | 71 | {66, 66, 2, 4}, |
109 | {153, 5, 1}, | 72 | {85, 85, 3, 4}, |
110 | {66, 3, 2}, | 73 | {141, 161, 4, 4}, |
111 | {68, 3, 2}, | 74 | {177, 177, 5, 4} |
112 | {95, 3, 2}, | ||
113 | {106, 3, 2}, | ||
114 | {116, 3, 2}, | ||
115 | {93, 4, 2}, | ||
116 | {119, 4, 2}, | ||
117 | {121, 4, 2}, | ||
118 | {133, 4, 2}, | ||
119 | {137, 4, 2}, | ||
120 | {117, 5, 2}, | ||
121 | {118, 5, 2}, | ||
122 | {120, 5, 2}, | ||
123 | {124, 5, 2}, | ||
124 | {132, 5, 2}, | ||
125 | {137, 5, 2}, | ||
126 | {141, 5, 2}, | ||
127 | {166, 5, 2}, | ||
128 | {170, 5, 2}, | ||
129 | {191, 5, 2}, | ||
130 | {206, 5, 2}, | ||
131 | {208, 5, 2}, | ||
132 | {30, 2, 3}, | ||
133 | {69, 3, 3}, | ||
134 | {82, 3, 3}, | ||
135 | {83, 3, 3}, | ||
136 | {109, 3, 3}, | ||
137 | {114, 3, 3}, | ||
138 | {125, 3, 3}, | ||
139 | {89, 4, 3}, | ||
140 | {103, 4, 3}, | ||
141 | {117, 4, 3}, | ||
142 | {126, 4, 3}, | ||
143 | {150, 4, 3}, | ||
144 | {161, 4, 3}, | ||
145 | {121, 5, 3}, | ||
146 | {127, 5, 3}, | ||
147 | {131, 5, 3}, | ||
148 | {134, 5, 3}, | ||
149 | {148, 5, 3}, | ||
150 | {169, 5, 3}, | ||
151 | {172, 5, 3}, | ||
152 | {182, 5, 3}, | ||
153 | {195, 5, 3}, | ||
154 | {196, 5, 3}, | ||
155 | {208, 5, 3}, | ||
156 | {66, 2, 4}, | ||
157 | {85, 3, 4}, | ||
158 | {141, 4, 4}, | ||
159 | {146, 4, 4}, | ||
160 | {161, 4, 4}, | ||
161 | {177, 5, 4} | ||
162 | }; | 75 | }; |
163 | 76 | ||
164 | static struct pll_config cx700_pll_config[] = { | 77 | static struct pll_limit cx700_pll_limits[] = { |
165 | {98, 3, 1}, | 78 | {98, 98, 3, 1}, |
166 | {86, 4, 1}, | 79 | {86, 86, 4, 1}, |
167 | {109, 5, 1}, | 80 | {109, 208, 5, 1}, |
168 | {110, 5, 1}, | 81 | {68, 68, 2, 2}, |
169 | {113, 5, 1}, | 82 | {95, 116, 3, 2}, |
170 | {121, 5, 1}, | 83 | {93, 166, 4, 2}, |
171 | {131, 5, 1}, | 84 | {110, 206, 5, 2}, |
172 | {135, 5, 1}, | 85 | {174, 174, 7, 2}, |
173 | {142, 5, 1}, | 86 | {82, 109, 3, 3}, |
174 | {143, 5, 1}, | 87 | {117, 161, 4, 3}, |
175 | {153, 5, 1}, | 88 | {112, 208, 5, 3}, |
176 | {187, 5, 1}, | 89 | {141, 202, 5, 4} |
177 | {208, 5, 1}, | ||
178 | {68, 2, 2}, | ||
179 | {95, 3, 2}, | ||
180 | {116, 3, 2}, | ||
181 | {93, 4, 2}, | ||
182 | {119, 4, 2}, | ||
183 | {133, 4, 2}, | ||
184 | {137, 4, 2}, | ||
185 | {151, 4, 2}, | ||
186 | {166, 4, 2}, | ||
187 | {110, 5, 2}, | ||
188 | {112, 5, 2}, | ||
189 | {117, 5, 2}, | ||
190 | {118, 5, 2}, | ||
191 | {120, 5, 2}, | ||
192 | {132, 5, 2}, | ||
193 | {137, 5, 2}, | ||
194 | {141, 5, 2}, | ||
195 | {151, 5, 2}, | ||
196 | {166, 5, 2}, | ||
197 | {175, 5, 2}, | ||
198 | {191, 5, 2}, | ||
199 | {206, 5, 2}, | ||
200 | {174, 7, 2}, | ||
201 | {82, 3, 3}, | ||
202 | {109, 3, 3}, | ||
203 | {117, 4, 3}, | ||
204 | {150, 4, 3}, | ||
205 | {161, 4, 3}, | ||
206 | {112, 5, 3}, | ||
207 | {115, 5, 3}, | ||
208 | {121, 5, 3}, | ||
209 | {127, 5, 3}, | ||
210 | {129, 5, 3}, | ||
211 | {131, 5, 3}, | ||
212 | {134, 5, 3}, | ||
213 | {138, 5, 3}, | ||
214 | {148, 5, 3}, | ||
215 | {157, 5, 3}, | ||
216 | {169, 5, 3}, | ||
217 | {172, 5, 3}, | ||
218 | {190, 5, 3}, | ||
219 | {195, 5, 3}, | ||
220 | {196, 5, 3}, | ||
221 | {208, 5, 3}, | ||
222 | {141, 5, 4}, | ||
223 | {150, 5, 4}, | ||
224 | {166, 5, 4}, | ||
225 | {176, 5, 4}, | ||
226 | {177, 5, 4}, | ||
227 | {183, 5, 4}, | ||
228 | {202, 5, 4} | ||
229 | }; | 90 | }; |
230 | 91 | ||
231 | static struct pll_config vx855_pll_config[] = { | 92 | static struct pll_limit vx855_pll_limits[] = { |
232 | {86, 4, 1}, | 93 | {86, 86, 4, 1}, |
233 | {108, 5, 1}, | 94 | {108, 208, 5, 1}, |
234 | {110, 5, 1}, | 95 | {110, 208, 5, 2}, |
235 | {113, 5, 1}, | 96 | {83, 112, 3, 3}, |
236 | {121, 5, 1}, | 97 | {103, 161, 4, 3}, |
237 | {131, 5, 1}, | 98 | {112, 209, 5, 3}, |
238 | {135, 5, 1}, | 99 | {142, 161, 4, 4}, |
239 | {142, 5, 1}, | 100 | {141, 176, 5, 4} |
240 | {143, 5, 1}, | ||
241 | {153, 5, 1}, | ||
242 | {164, 5, 1}, | ||
243 | {187, 5, 1}, | ||
244 | {208, 5, 1}, | ||
245 | {110, 5, 2}, | ||
246 | {112, 5, 2}, | ||
247 | {117, 5, 2}, | ||
248 | {118, 5, 2}, | ||
249 | {124, 5, 2}, | ||
250 | {132, 5, 2}, | ||
251 | {137, 5, 2}, | ||
252 | {141, 5, 2}, | ||
253 | {149, 5, 2}, | ||
254 | {151, 5, 2}, | ||
255 | {159, 5, 2}, | ||
256 | {166, 5, 2}, | ||
257 | {167, 5, 2}, | ||
258 | {172, 5, 2}, | ||
259 | {189, 5, 2}, | ||
260 | {191, 5, 2}, | ||
261 | {194, 5, 2}, | ||
262 | {206, 5, 2}, | ||
263 | {208, 5, 2}, | ||
264 | {83, 3, 3}, | ||
265 | {88, 3, 3}, | ||
266 | {109, 3, 3}, | ||
267 | {112, 3, 3}, | ||
268 | {103, 4, 3}, | ||
269 | {105, 4, 3}, | ||
270 | {161, 4, 3}, | ||
271 | {112, 5, 3}, | ||
272 | {115, 5, 3}, | ||
273 | {121, 5, 3}, | ||
274 | {127, 5, 3}, | ||
275 | {134, 5, 3}, | ||
276 | {137, 5, 3}, | ||
277 | {148, 5, 3}, | ||
278 | {157, 5, 3}, | ||
279 | {169, 5, 3}, | ||
280 | {172, 5, 3}, | ||
281 | {182, 5, 3}, | ||
282 | {191, 5, 3}, | ||
283 | {195, 5, 3}, | ||
284 | {209, 5, 3}, | ||
285 | {142, 4, 4}, | ||
286 | {146, 4, 4}, | ||
287 | {161, 4, 4}, | ||
288 | {141, 5, 4}, | ||
289 | {150, 5, 4}, | ||
290 | {165, 5, 4}, | ||
291 | {176, 5, 4} | ||
292 | }; | 101 | }; |
293 | 102 | ||
294 | /* according to VIA Technologies these values are based on experiment */ | 103 | /* according to VIA Technologies these values are based on experiment */ |
@@ -713,6 +522,9 @@ static struct via_device_mapping device_mapping[] = { | |||
713 | {VIA_LVDS2, "LVDS2"} | 522 | {VIA_LVDS2, "LVDS2"} |
714 | }; | 523 | }; |
715 | 524 | ||
525 | /* structure with function pointers to support clock control */ | ||
526 | static struct via_clock clock; | ||
527 | |||
716 | static void load_fix_bit_crtc_reg(void); | 528 | static void load_fix_bit_crtc_reg(void); |
717 | static void __devinit init_gfx_chip_info(int chip_type); | 529 | static void __devinit init_gfx_chip_info(int chip_type); |
718 | static void __devinit init_tmds_chip_info(void); | 530 | static void __devinit init_tmds_chip_info(void); |
@@ -1634,69 +1446,54 @@ void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active) | |||
1634 | 1446 | ||
1635 | } | 1447 | } |
1636 | 1448 | ||
1637 | static u32 cle266_encode_pll(struct pll_config pll) | 1449 | static struct via_pll_config get_pll_config(struct pll_limit *limits, int size, |
1638 | { | ||
1639 | return (pll.multiplier << 8) | ||
1640 | | (pll.rshift << 6) | ||
1641 | | pll.divisor; | ||
1642 | } | ||
1643 | |||
1644 | static u32 k800_encode_pll(struct pll_config pll) | ||
1645 | { | ||
1646 | return ((pll.divisor - 2) << 16) | ||
1647 | | (pll.rshift << 10) | ||
1648 | | (pll.multiplier - 2); | ||
1649 | } | ||
1650 | |||
1651 | static u32 vx855_encode_pll(struct pll_config pll) | ||
1652 | { | ||
1653 | return (pll.divisor << 16) | ||
1654 | | (pll.rshift << 10) | ||
1655 | | pll.multiplier; | ||
1656 | } | ||
1657 | |||
1658 | static inline u32 get_pll_internal_frequency(u32 ref_freq, | ||
1659 | struct pll_config pll) | ||
1660 | { | ||
1661 | return ref_freq / pll.divisor * pll.multiplier; | ||
1662 | } | ||
1663 | |||
1664 | static inline u32 get_pll_output_frequency(u32 ref_freq, struct pll_config pll) | ||
1665 | { | ||
1666 | return get_pll_internal_frequency(ref_freq, pll)>>pll.rshift; | ||
1667 | } | ||
1668 | |||
1669 | static struct pll_config get_pll_config(struct pll_config *config, int size, | ||
1670 | int clk) | 1450 | int clk) |
1671 | { | 1451 | { |
1672 | struct pll_config best = config[0]; | 1452 | struct via_pll_config cur, up, down, best = {0, 1, 0}; |
1673 | const u32 f0 = 14318180; /* X1 frequency */ | 1453 | const u32 f0 = 14318180; /* X1 frequency */ |
1674 | int i; | 1454 | int i, f; |
1675 | 1455 | ||
1676 | for (i = 1; i < size; i++) { | 1456 | for (i = 0; i < size; i++) { |
1677 | if (abs(get_pll_output_frequency(f0, config[i]) - clk) | 1457 | cur.rshift = limits[i].rshift; |
1678 | < abs(get_pll_output_frequency(f0, best) - clk)) | 1458 | cur.divisor = limits[i].divisor; |
1679 | best = config[i]; | 1459 | cur.multiplier = clk / ((f0 / cur.divisor)>>cur.rshift); |
1460 | f = abs(get_pll_output_frequency(f0, cur) - clk); | ||
1461 | up = down = cur; | ||
1462 | up.multiplier++; | ||
1463 | down.multiplier--; | ||
1464 | if (abs(get_pll_output_frequency(f0, up) - clk) < f) | ||
1465 | cur = up; | ||
1466 | else if (abs(get_pll_output_frequency(f0, down) - clk) < f) | ||
1467 | cur = down; | ||
1468 | |||
1469 | if (cur.multiplier < limits[i].multiplier_min) | ||
1470 | cur.multiplier = limits[i].multiplier_min; | ||
1471 | else if (cur.multiplier > limits[i].multiplier_max) | ||
1472 | cur.multiplier = limits[i].multiplier_max; | ||
1473 | |||
1474 | f = abs(get_pll_output_frequency(f0, cur) - clk); | ||
1475 | if (f < abs(get_pll_output_frequency(f0, best) - clk)) | ||
1476 | best = cur; | ||
1680 | } | 1477 | } |
1681 | 1478 | ||
1682 | return best; | 1479 | return best; |
1683 | } | 1480 | } |
1684 | 1481 | ||
1685 | u32 viafb_get_clk_value(int clk) | 1482 | static struct via_pll_config get_best_pll_config(int clk) |
1686 | { | 1483 | { |
1687 | u32 value = 0; | 1484 | struct via_pll_config config; |
1688 | 1485 | ||
1689 | switch (viaparinfo->chip_info->gfx_chip_name) { | 1486 | switch (viaparinfo->chip_info->gfx_chip_name) { |
1690 | case UNICHROME_CLE266: | 1487 | case UNICHROME_CLE266: |
1691 | case UNICHROME_K400: | 1488 | case UNICHROME_K400: |
1692 | value = cle266_encode_pll(get_pll_config(cle266_pll_config, | 1489 | config = get_pll_config(cle266_pll_limits, |
1693 | ARRAY_SIZE(cle266_pll_config), clk)); | 1490 | ARRAY_SIZE(cle266_pll_limits), clk); |
1694 | break; | 1491 | break; |
1695 | case UNICHROME_K800: | 1492 | case UNICHROME_K800: |
1696 | case UNICHROME_PM800: | 1493 | case UNICHROME_PM800: |
1697 | case UNICHROME_CN700: | 1494 | case UNICHROME_CN700: |
1698 | value = k800_encode_pll(get_pll_config(k800_pll_config, | 1495 | config = get_pll_config(k800_pll_limits, |
1699 | ARRAY_SIZE(k800_pll_config), clk)); | 1496 | ARRAY_SIZE(k800_pll_limits), clk); |
1700 | break; | 1497 | break; |
1701 | case UNICHROME_CX700: | 1498 | case UNICHROME_CX700: |
1702 | case UNICHROME_CN750: | 1499 | case UNICHROME_CN750: |
@@ -1704,92 +1501,28 @@ u32 viafb_get_clk_value(int clk) | |||
1704 | case UNICHROME_P4M890: | 1501 | case UNICHROME_P4M890: |
1705 | case UNICHROME_P4M900: | 1502 | case UNICHROME_P4M900: |
1706 | case UNICHROME_VX800: | 1503 | case UNICHROME_VX800: |
1707 | value = k800_encode_pll(get_pll_config(cx700_pll_config, | 1504 | config = get_pll_config(cx700_pll_limits, |
1708 | ARRAY_SIZE(cx700_pll_config), clk)); | 1505 | ARRAY_SIZE(cx700_pll_limits), clk); |
1709 | break; | 1506 | break; |
1710 | case UNICHROME_VX855: | 1507 | case UNICHROME_VX855: |
1711 | case UNICHROME_VX900: | 1508 | case UNICHROME_VX900: |
1712 | value = vx855_encode_pll(get_pll_config(vx855_pll_config, | 1509 | config = get_pll_config(vx855_pll_limits, |
1713 | ARRAY_SIZE(vx855_pll_config), clk)); | 1510 | ARRAY_SIZE(vx855_pll_limits), clk); |
1714 | break; | 1511 | break; |
1715 | } | 1512 | } |
1716 | 1513 | ||
1717 | return value; | 1514 | return config; |
1718 | } | 1515 | } |
1719 | 1516 | ||
1720 | /* Set VCLK*/ | 1517 | /* Set VCLK*/ |
1721 | void viafb_set_vclock(u32 clk, int set_iga) | 1518 | void viafb_set_vclock(u32 clk, int set_iga) |
1722 | { | 1519 | { |
1723 | /* H.W. Reset : ON */ | 1520 | struct via_pll_config config = get_best_pll_config(clk); |
1724 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); | ||
1725 | |||
1726 | if (set_iga == IGA1) { | ||
1727 | /* Change D,N FOR VCLK */ | ||
1728 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
1729 | case UNICHROME_CLE266: | ||
1730 | case UNICHROME_K400: | ||
1731 | via_write_reg(VIASR, SR46, (clk & 0x00FF)); | ||
1732 | via_write_reg(VIASR, SR47, (clk & 0xFF00) >> 8); | ||
1733 | break; | ||
1734 | |||
1735 | case UNICHROME_K800: | ||
1736 | case UNICHROME_PM800: | ||
1737 | case UNICHROME_CN700: | ||
1738 | case UNICHROME_CX700: | ||
1739 | case UNICHROME_CN750: | ||
1740 | case UNICHROME_K8M890: | ||
1741 | case UNICHROME_P4M890: | ||
1742 | case UNICHROME_P4M900: | ||
1743 | case UNICHROME_VX800: | ||
1744 | case UNICHROME_VX855: | ||
1745 | case UNICHROME_VX900: | ||
1746 | via_write_reg(VIASR, SR44, (clk & 0x0000FF)); | ||
1747 | via_write_reg(VIASR, SR45, (clk & 0x00FF00) >> 8); | ||
1748 | via_write_reg(VIASR, SR46, (clk & 0xFF0000) >> 16); | ||
1749 | break; | ||
1750 | } | ||
1751 | } | ||
1752 | |||
1753 | if (set_iga == IGA2) { | ||
1754 | /* Change D,N FOR LCK */ | ||
1755 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
1756 | case UNICHROME_CLE266: | ||
1757 | case UNICHROME_K400: | ||
1758 | via_write_reg(VIASR, SR44, (clk & 0x00FF)); | ||
1759 | via_write_reg(VIASR, SR45, (clk & 0xFF00) >> 8); | ||
1760 | break; | ||
1761 | 1521 | ||
1762 | case UNICHROME_K800: | 1522 | if (set_iga == IGA1) |
1763 | case UNICHROME_PM800: | 1523 | clock.set_primary_pll(config); |
1764 | case UNICHROME_CN700: | 1524 | if (set_iga == IGA2) |
1765 | case UNICHROME_CX700: | 1525 | clock.set_secondary_pll(config); |
1766 | case UNICHROME_CN750: | ||
1767 | case UNICHROME_K8M890: | ||
1768 | case UNICHROME_P4M890: | ||
1769 | case UNICHROME_P4M900: | ||
1770 | case UNICHROME_VX800: | ||
1771 | case UNICHROME_VX855: | ||
1772 | case UNICHROME_VX900: | ||
1773 | via_write_reg(VIASR, SR4A, (clk & 0x0000FF)); | ||
1774 | via_write_reg(VIASR, SR4B, (clk & 0x00FF00) >> 8); | ||
1775 | via_write_reg(VIASR, SR4C, (clk & 0xFF0000) >> 16); | ||
1776 | break; | ||
1777 | } | ||
1778 | } | ||
1779 | |||
1780 | /* H.W. Reset : OFF */ | ||
1781 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); | ||
1782 | |||
1783 | /* Reset PLL */ | ||
1784 | if (set_iga == IGA1) { | ||
1785 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); | ||
1786 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); | ||
1787 | } | ||
1788 | |||
1789 | if (set_iga == IGA2) { | ||
1790 | viafb_write_reg_mask(SR40, VIASR, 0x04, BIT2); | ||
1791 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT2); | ||
1792 | } | ||
1793 | 1526 | ||
1794 | /* Fire! */ | 1527 | /* Fire! */ |
1795 | via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */ | 1528 | via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */ |
@@ -2035,7 +1768,7 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
2035 | int i; | 1768 | int i; |
2036 | int index = 0; | 1769 | int index = 0; |
2037 | int h_addr, v_addr; | 1770 | int h_addr, v_addr; |
2038 | u32 pll_D_N, clock, refresh = viafb_refresh; | 1771 | u32 clock, refresh = viafb_refresh; |
2039 | 1772 | ||
2040 | if (viafb_SAMM_ON && set_iga == IGA2) | 1773 | if (viafb_SAMM_ON && set_iga == IGA2) |
2041 | refresh = viafb_refresh1; | 1774 | refresh = viafb_refresh1; |
@@ -2089,14 +1822,13 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
2089 | 1822 | ||
2090 | clock = crt_reg.hor_total * crt_reg.ver_total | 1823 | clock = crt_reg.hor_total * crt_reg.ver_total |
2091 | * crt_table[index].refresh_rate; | 1824 | * crt_table[index].refresh_rate; |
2092 | pll_D_N = viafb_get_clk_value(clock); | 1825 | viafb_set_vclock(clock, set_iga); |
2093 | DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N); | ||
2094 | viafb_set_vclock(pll_D_N, set_iga); | ||
2095 | 1826 | ||
2096 | } | 1827 | } |
2097 | 1828 | ||
2098 | void __devinit viafb_init_chip_info(int chip_type) | 1829 | void __devinit viafb_init_chip_info(int chip_type) |
2099 | { | 1830 | { |
1831 | via_clock_init(&clock, chip_type); | ||
2100 | init_gfx_chip_info(chip_type); | 1832 | init_gfx_chip_info(chip_type); |
2101 | init_tmds_chip_info(); | 1833 | init_tmds_chip_info(); |
2102 | init_lvds_chip_info(); | 1834 | init_lvds_chip_info(); |
@@ -2584,6 +2316,33 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, | |||
2584 | get_sync(viafbinfo1)); | 2316 | get_sync(viafbinfo1)); |
2585 | } | 2317 | } |
2586 | 2318 | ||
2319 | clock.set_engine_pll_state(VIA_STATE_ON); | ||
2320 | clock.set_primary_clock_source(VIA_CLKSRC_X1, true); | ||
2321 | clock.set_secondary_clock_source(VIA_CLKSRC_X1, true); | ||
2322 | |||
2323 | #ifdef CONFIG_FB_VIA_X_COMPATIBILITY | ||
2324 | clock.set_primary_pll_state(VIA_STATE_ON); | ||
2325 | clock.set_primary_clock_state(VIA_STATE_ON); | ||
2326 | clock.set_secondary_pll_state(VIA_STATE_ON); | ||
2327 | clock.set_secondary_clock_state(VIA_STATE_ON); | ||
2328 | #else | ||
2329 | if (viaparinfo->shared->iga1_devices) { | ||
2330 | clock.set_primary_pll_state(VIA_STATE_ON); | ||
2331 | clock.set_primary_clock_state(VIA_STATE_ON); | ||
2332 | } else { | ||
2333 | clock.set_primary_pll_state(VIA_STATE_OFF); | ||
2334 | clock.set_primary_clock_state(VIA_STATE_OFF); | ||
2335 | } | ||
2336 | |||
2337 | if (viaparinfo->shared->iga2_devices) { | ||
2338 | clock.set_secondary_pll_state(VIA_STATE_ON); | ||
2339 | clock.set_secondary_clock_state(VIA_STATE_ON); | ||
2340 | } else { | ||
2341 | clock.set_secondary_pll_state(VIA_STATE_OFF); | ||
2342 | clock.set_secondary_clock_state(VIA_STATE_OFF); | ||
2343 | } | ||
2344 | #endif /*CONFIG_FB_VIA_X_COMPATIBILITY*/ | ||
2345 | |||
2587 | via_set_state(devices, VIA_STATE_ON); | 2346 | via_set_state(devices, VIA_STATE_ON); |
2588 | device_screen_on(); | 2347 | device_screen_on(); |
2589 | return 1; | 2348 | return 1; |