blob: 67242f2d5bd36ad5578ee0cf5373a597466977a7 [file] [log] [blame]
Arthur Heymans73ea0322018-03-28 17:17:07 +02001--
2-- Copyright (C) 2015-2016 secunet Security Networks AG
3--
4-- This program is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
6-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
8--
9-- This program is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-- GNU General Public License for more details.
13--
14
15with HW.Time;
16with HW.GFX.GMA.Config;
17with HW.GFX.GMA.Registers;
18
19with HW.Debug;
20with GNAT.Source_Info;
21
22package body HW.GFX.GMA.PLLs
23with
24 Refined_State => (State => PLLs)
25is
26
27 Debug_Clocks : constant Boolean := False;
28
29 type Count_Range is new Natural range 0 .. 2;
30
31 type PLL_State is record
32 Use_Count : Count_Range;
33 Used_For_DP : Boolean;
34 Link_Rate : DP_Bandwidth;
35 Mode : Mode_Type;
36 end record;
37
38 type PLL_State_Array is array (DPLLs) of PLL_State;
39
40 PLLs : PLL_State_Array;
41
42 ----------------------------------------------------------------------------
43
44 subtype N_Range is Int64 range 3 .. 8;
45 subtype M_Range is Int64 range 70 .. 138;
46 subtype M1_Range is Int64 range 10 .. 25;
47 subtype M2_Range is Int64 range 4 .. 13;
48 subtype P_Range is Int64 range 5 .. 112;
49 subtype P1_Range is Int64 range 1 .. 8;
50 subtype P2_Range is Int64 range 5 .. 14;
51 subtype VCO_Range is Int64 range 1400000000 .. 3500000000;
52 subtype Clock_Range is HW.GFX.Frequency_Type;
53
54 type Clock_Type is
55 record
56 N : N_Range;
57 M1 : M1_Range;
58 M2 : M2_Range;
59 P1 : P1_Range;
60 P2 : P2_Range;
61 M : M_Range;
62 P : P_Range;
63 VCO : VCO_Range;
64 Reference_Clock : Clock_Range;
65 Dotclock : Clock_Range;
66 end record;
67
68 Invalid_Clock : constant Clock_Type := Clock_Type'
69 (N => N_Range'Last,
70 M1 => M1_Range'Last,
71 M2 => M2_Range'Last,
72 P1 => P1_Range'Last,
73 P2 => P2_Range'Last,
74 Reference_Clock => Clock_Range'Last,
75 M => M_Range'Last,
76 P => P_Range'Last,
77 VCO => VCO_Range'Last,
78 Dotclock => Clock_Range'Last);
79
80 type Limits_Type is
81 record
82 N_Lower : N_Range;
83 N_Upper : N_Range;
84 M_Lower : M_Range;
85 M_Upper : M_Range;
86 M1_Lower : M1_Range;
87 M1_Upper : M1_Range;
88 M2_Lower : M2_Range;
89 M2_Upper : M2_Range;
90 P_Lower : P_Range;
91 P_Upper : P_Range;
92 P1_Lower : P1_Range;
93 P1_Upper : P1_Range;
94 P2_Fast : P2_Range;
95 P2_Slow : P2_Range;
96 P2_Threshold : Clock_Range;
97 VCO_Lower : VCO_Range;
98 VCO_Upper : VCO_Range;
99 end record;
100
101 LVDS_Single_Limits : constant Limits_Type := Limits_Type'
102 (N_Lower => 3, N_Upper => 5,
103 M_Lower => 104, M_Upper => 138,
104 M1_Lower => 19, M1_Upper => 25, -- this is capped by M_Upper >= 5 * M1 + M2_Lower
105 M2_Lower => 7, M2_Upper => 13,
106 P_Lower => 28, P_Upper => 112,
107 P1_Lower => 2, P1_Upper => 8,
108 P2_Fast => 14, P2_Slow => 14,
109 P2_Threshold => Clock_Range'First,
110 VCO_Lower => 1_750_000_000, VCO_Upper => 3_500_000_000);
111 LVDS_Dual_Limits : constant Limits_Type := Limits_Type'
112 (N_Lower => 3, N_Upper => 5,
113 M_Lower => 104, M_Upper => 138,
114 M1_Lower => 19, M1_Upper => 25,
115 M2_Lower => 7, M2_Upper => 13,
116 P_Lower => 14, P_Upper => 56,
117 P1_Lower => 2, P1_Upper => 6,
118 P2_Fast => 7, P2_Slow => 7,
119 P2_Threshold => Clock_Range'First,
120 VCO_Lower => 1_750_000_000, VCO_Upper => 3_500_000_000);
121 SDVO_Limits : constant Limits_Type := Limits_Type'
122 (N_Lower => 3, N_Upper => 6,
123 M_Lower => 104, M_Upper => 138,
124 M1_Lower => 16, M1_Upper => 25,
125 M2_Lower => 7, M2_Upper => 13,
126 P_Lower => 10, P_Upper => 30,
127 P1_Lower => 1, P1_Upper => 3,
128 -- use P2_Slow if Dotclock <= P2_Threshold, P2_Fast otherwise
129 P2_Fast => 5, P2_Slow => 10,
130 P2_Threshold => 270_000_000,
131 VCO_Lower => 1_750_000_000, VCO_Upper => 3_500_000_000);
132 HDMI_Analog_Limits : constant Limits_Type := Limits_Type'
133 (N_Lower => 3, N_Upper => 6,
134 M_Lower => 104, M_Upper => 138,
135 M1_Lower => 18, M1_Upper => 25,
136 M2_Lower => 7, M2_Upper => 13,
137 P_Lower => 5, P_Upper => 80,
138 P1_Lower => 1, P1_Upper => 8,
139 -- use P2_Slow if Dotclock <= P2_Threshold, P2_Fast otherwise
140 P2_Fast => 5, P2_Slow => 10,
141 P2_Threshold => 165_000_000,
142 VCO_Lower => 1_750_000_000, VCO_Upper => 3_500_000_000);
143 All_Other_Limits : constant Limits_Type := Limits_Type'
144 (N_Lower => 3, N_Upper => 8,
145 M_Lower => 70, M_Upper => 120,
146 M1_Lower => 10, M1_Upper => 20,
147 M2_Lower => 5, M2_Upper => 9,
148 P_Lower => 5, P_Upper => 80,
149 P1_Lower => 1, P1_Upper => 8,
150 -- use P2_Slow if Dotclock <= P2_Threshold, P2_Fast otherwise
151 P2_Fast => 5, P2_Slow => 10,
152 P2_Threshold => 200_000_000,
153 VCO_Lower => 1_400_000_000, VCO_Upper => 2_800_000_000);
154
155 ----------------------------------------------------------------------------
156
157 type Regs is array (DPLLs) of Registers.Registers_Index;
158
159 DPLL : constant Regs := Regs'(Registers.GMCH_DPLL_A, Registers.GMCH_DPLL_B);
160 DPLL_VCO_ENABLE : constant := 1 * 2 ** 31;
161 DPLL_VGA_MODE_DIS : constant := 1 * 2 ** 28;
162 DPLL_P2_10_OR_14 : constant := 0 * 2 ** 24;
163 DPLL_P2_5_OR_7 : constant := 1 * 2 ** 24;
164 DPLL_P1_DIVIDER_SHIFT : constant := 16;
165 DPLL_SDVOCLK : constant := 2 * 2 ** 13;
166 DPLL_PULSE_PHASE_MASK : constant := 15 * 2 ** 9;
167 DPLL_PULSE_PHASE_6 : constant := 6 * 2 ** 9;
168
169 DPLL_HIGH_SPEED : constant := 1 * 2 ** 30;
170 DPLL_MODE_LVDS : constant := 2 * 2 ** 26;
171 DPLL_MODE_DAC : constant := 1 * 2 ** 26;
172 DPLL_DREFCLK : constant := 0 * 2 ** 13;
173 DPLL_SSC : constant := 3 * 2 ** 13;
174
175 MODE_DPLL_DAC : constant Word32 := Word32'
176 (DPLL_MODE_DAC or DPLL_DREFCLK);
177
178 MODE_DPLL_HDMI : constant Word32 := Word32'
179 (DPLL_MODE_DAC or DPLL_DREFCLK or DPLL_HIGH_SPEED);
180
181 MODE_DPLL_LVDS : constant Word32 := Word32'
182 (DPLL_MODE_LVDS or DPLL_SSC);
183
184 MODE_DPLL_DP : constant Word32 := Word32'
185 (DPLL_MODE_DAC or DPLL_SSC or DPLL_HIGH_SPEED);
186
187 type DPLL_Mode_Array is array (Display_Type) of Word32;
188
189 DPLL_Mode : constant DPLL_Mode_Array := DPLL_Mode_Array'
190 (LVDS => MODE_DPLL_LVDS,
191 DP => MODE_DPLL_DP,
192 HDMI => MODE_DPLL_HDMI,
193 VGA => MODE_DPLL_DAC,
194 Others => MODE_DPLL_HDMI); --TODO Add SDVO
195
196 FP0 : constant Regs := Regs'(Registers.GMCH_FPA0, Registers.GMCH_FPB0);
197 FP1 : constant Regs := Regs'(Registers.GMCH_FPA1, Registers.GMCH_FPB1);
198 FP_DOUBLE_CLOCK : constant := 1 * 2 ** 27;
199 FP_N_SHIFT : constant := 16;
200 FP_M1_SHIFT : constant := 8;
201 FP_M2_SHIFT : constant := 0;
202
203 ----------------------------------------------------------------------------
204
205 procedure Verify_Parameters
206 (N : in N_Range;
207 M1 : in M1_Range;
208 M2 : in M2_Range;
209 P1 : in P1_Range;
210 P2 : in P2_Range;
211 Reference_Clock : in Clock_Range;
212 Current_Limits : in Limits_Type;
213 Result : out Clock_Type;
214 Valid : out Boolean)
215 with
216 Global => null,
217 Pre => True,
218 Post => True
219 is
220 M : Int64;
221 P : Int64;
222 VCO : Int64;
223 Dotclock : Int64;
224 begin
225 pragma Debug (Debug_Clocks, Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
226
227 M := 5 * M1 + M2;
228 P := P1 * P2;
229 VCO := (Int64 (Reference_Clock) * M) / N;
230 Dotclock := VCO / P;
231
232 pragma Debug (Debug_Clocks and not (Current_Limits.P1_Lower <= P1 and P1 <= Current_Limits.P1_Upper ), Debug.Put_Line ("P1 out of range."));
233 pragma Debug (Debug_Clocks and (Current_Limits.P2_Fast /= P2 and P2 /= Current_Limits.P2_Slow ), Debug.Put_Line ("P2 out of range."));
234 pragma Debug (Debug_Clocks and not (Current_Limits.P_Lower <= P and P <= Current_Limits.P_Upper ), Debug.Put_Line ("P out of range."));
235 pragma Debug (Debug_Clocks and not (Current_Limits.M1_Lower <= M1 and M1 <= Current_Limits.M1_Upper ), Debug.Put_Line ("M1 out of range."));
236 pragma Debug (Debug_Clocks and not (Current_Limits.M2_Lower <= M2 and M2 <= Current_Limits.M2_Upper ), Debug.Put_Line ("M2 out of range."));
237 -- pragma Debug (Debug_Clocks and not (M2 <= M1 ), Debug.Put_Line ("M1 greater thant M2."));
238 pragma Debug (Debug_Clocks and not (Current_Limits.N_Lower <= N and N <= Current_Limits.N_Upper ), Debug.Put_Line ("N out of range."));
239 pragma Debug (Debug_Clocks and not (Current_Limits.M_Lower <= M and M <= Current_Limits.M_Upper ), Debug.Put_Line ("M out of range."));
240 pragma Debug (Debug_Clocks and not (Current_Limits.VCO_Lower <= VCO and VCO <= Current_Limits.VCO_Upper), Debug.Put_Line ("VCO out of range."));
241
242 pragma Debug (Debug_Clocks and not (Int64 (Clock_Range'First) <= Dotclock), Debug.Put_Line ("Dotclock too low."));
243 pragma Debug (Debug_Clocks and not (Int64 (Clock_Range'First) <= Dotclock), Debug.Put_Int64 (Dotclock));
244 pragma Debug (Debug_Clocks and not (Int64 (Clock_Range'First) <= Dotclock), Debug.New_Line);
245
246 pragma Debug (Debug_Clocks and not (Dotclock <= Int64 (Clock_Range'Last)), Debug.Put_Line ("Dotclock too high."));
247 pragma Debug (Debug_Clocks and not (Dotclock <= Int64 (Clock_Range'Last)), Debug.Put_Int64 (Dotclock));
248 pragma Debug (Debug_Clocks and not (Dotclock <= Int64 (Clock_Range'Last)), Debug.New_Line);
249
250 Valid :=
251 Current_Limits.P1_Lower <= P1 and P1 <= Current_Limits.P1_Upper and
252 (Current_Limits.P2_Fast = P2 or P2 = Current_Limits.P2_Slow) and
253 Current_Limits.P_Lower <= P and P <= Current_Limits.P_Upper and
254 Current_Limits.M1_Lower <= M1 and M1 <= Current_Limits.M1_Upper and
255 Current_Limits.M2_Lower <= M2 and M2 <= Current_Limits.M2_Upper and
256 Current_Limits.N_Lower <= N and N <= Current_Limits.N_Upper and
257 Current_Limits.M_Lower <= M and M <= Current_Limits.M_Upper and
258 Current_Limits.VCO_Lower <= VCO and VCO <= Current_Limits.VCO_Upper and
259 Int64 (Clock_Range'First) <= Dotclock and
260 Dotclock <= Int64 (Clock_Range'Last);
261
262 if Valid
263 then
264 Result := Clock_Type'
265 (N => N,
266 M1 => M1,
267 M2 => M2,
268 P1 => P1,
269 P2 => P2,
270 Reference_Clock => Reference_Clock,
271 M => M,
272 P => P,
273 VCO => VCO,
274 Dotclock => Clock_Range (Dotclock));
275 else
276 Result := Invalid_Clock;
277 end if;
278
279 end Verify_Parameters;
280
281 procedure Calculate_Clock_Parameters
282 (Display : in Display_Type;
283 Target_Dotclock : in Clock_Range;
284 Reference_Clock : in Clock_Range;
285 Best_Clock : out Clock_Type;
286 Valid : out Boolean)
287 with
288 Global => null,
289 Pre => True,
290 Post => True
291 is
292 Limits : constant Limits_Type :=
293 (case Display is
294 when LVDS =>
295 (if Target_Dotclock >= Config.LVDS_Dual_Threshold then
296 LVDS_Dual_Limits
297 else
298 LVDS_Single_Limits),
299 when HDMI => HDMI_Analog_Limits,
300 when VGA => HDMI_Analog_Limits,
301 when others => All_Other_Limits); --TODO add SDVO type, needs other limits
302
303 P2 : P2_Range;
304 Best_Delta : Int64 := Int64'Last;
305 Current_Delta : Int64;
306 Current_Clock : Clock_Type;
307 Registers_Valid : Boolean;
308 begin
309 pragma Debug (Debug_Clocks, Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
310
311 Valid := False;
312 Best_Clock := Invalid_Clock;
313
314 if Target_Dotclock <= Limits.P2_Threshold then
315 P2 := Limits.P2_Slow;
316 else
317 P2 := Limits.P2_Fast;
318 end if;
319
320 for N in N_Range range Limits.N_Lower .. Limits.N_Upper
321 loop
322 -- reverse loops as hardware prefers higher values
323 for M1 in reverse M1_Range range Limits.M1_Lower .. Limits.M1_Upper
324 loop
325 for M2 in reverse M2_Range range Limits.M2_Lower .. Int64'Min (Limits.M2_Upper, M1)
326 loop
327 for P1 in reverse P1_Range range Limits.P1_Lower .. Limits.P1_Upper
328 loop
329 Verify_Parameters
330 (N => N,
331 M1 => M1,
332 M2 => M2,
333 P1 => P1,
334 P2 => P2,
335 Reference_Clock => Reference_Clock,
336 Current_Limits => Limits,
337 Result => Current_Clock,
338 Valid => Registers_Valid);
339
340 if Registers_Valid
341 then
342 if Current_Clock.Dotclock > Target_Dotclock
343 then
344 Current_Delta := Current_Clock.Dotclock - Target_Dotclock;
345 else
346 Current_Delta := Target_Dotclock - Current_Clock.Dotclock;
347 end if;
348
349 if Current_Delta < Best_Delta
350 then
351 Best_Delta := Current_Delta;
352 Best_Clock := Current_Clock;
353 Valid := True;
354 end if;
355
356 pragma Debug (Debug_Clocks, Debug.Put ("Current/Target/Best_Delta: "));
357 pragma Debug (Debug_Clocks, Debug.Put_Int64 (Current_Clock.Dotclock));
358 pragma Debug (Debug_Clocks, Debug.Put ("/"));
359 pragma Debug (Debug_Clocks, Debug.Put_Int64 (Target_Dotclock));
360 pragma Debug (Debug_Clocks, Debug.Put ("/"));
361 pragma Debug (Debug_Clocks, Debug.Put_Int64 (Best_Delta));
362 pragma Debug (Debug_Clocks, Debug.Put_Line ("."));
363
364 end if;
365 end loop;
366 end loop;
367 end loop;
368 end loop;
369
370 pragma Debug (Valid, Debug.Put_Line ("Valid clock found."));
371 pragma Debug (Valid, Debug.Put ("Best/Target/Delta: "));
372 pragma Debug (Valid, Debug.Put_Int64 (Best_Clock.Dotclock));
373 pragma Debug (Valid, Debug.Put ("/"));
374 pragma Debug (Valid, Debug.Put_Int64 (Target_Dotclock));
375 pragma Debug (Valid, Debug.Put ("/"));
376 pragma Debug (Valid, Debug.Put_Int64 (Best_Delta));
377 pragma Debug (Valid, Debug.Put_Line ("."));
378 pragma Debug (not Valid, Debug.Put_Line ("No valid clock found."));
379
380 end Calculate_Clock_Parameters;
381
382 procedure Program_DPLL
383 (PLL : DPLLs;
384 Display : Display_Type;
385 Clk : Clock_Type)
386 with
387 Global => (In_Out => Registers.Register_State),
388 Pre => True,
389 Post => True
390 is
391 FP, Encoded_P1, Encoded_P2 : Word32;
392 begin
393 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
394
395 FP :=
396 Shift_Left (Word32 (Clk.N - 2), FP_N_SHIFT) or
397 Shift_Left (Word32 (Clk.M1 - 2), FP_M1_SHIFT) or
398 Shift_Left (Word32 (Clk.M2 - 2), FP_M2_SHIFT);
399
400 Registers.Write (FP0 (PLL), FP);
401 Registers.Write (FP1 (PLL), FP);
402
403 Encoded_P1 := Shift_Left (1, Natural (Clk.P1) - 1);
404
405 if Clk.P2 = 5 or Clk.P2 = 7
406 then
407 Encoded_P2 := DPLL_P2_5_OR_7;
408 else
409 Encoded_P2 := DPLL_P2_10_OR_14;
410 end if;
411
412 Registers.Write
413 (Register => DPLL (PLL),
414 Value => DPLL_Mode (Display) or
415 DPLL_VGA_MODE_DIS or
416 DPLL_PULSE_PHASE_6 or
417 Encoded_P2 or
418 Shift_Left (Encoded_P1, DPLL_P1_DIVIDER_SHIFT));
419 end Program_DPLL;
420
421 procedure On
422 (PLL : in T;
423 Port_Cfg : in Port_Config;
424 Success : out Boolean)
425 is
426 Target_Clock : constant Frequency_Type :=
427 (if Port_Cfg.Display = DP then
428 DP_Symbol_Rate (Port_Cfg.DP.Bandwidth)
429 else
430 Port_Cfg.Mode.Dotclock);
431 Clk : Clock_Type;
432 begin
433 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
434
435 Success := PLL in DPLLs;
436 Clk := Invalid_Clock;
437
438 if Success then
439 if Port_Cfg.Display = DP then
440 Success := True;
441 -- we use static values for DP
442 case Port_Cfg.DP.Bandwidth is
443 when DP_Bandwidth_1_62 =>
444 Clk.N := 4;
445 Clk.M1 := 25;
446 Clk.M2 := 10;
447 Clk.P1 := 2;
448 Clk.P2 := 10;
449 when DP_Bandwidth_2_7 =>
450 Clk.N := 3;
451 Clk.M1 := 16;
452 Clk.M2 := 4;
453 Clk.P1 := 1;
454 Clk.P2 := 10;
455 when others =>
456 Success := False;
457 end case;
458 elsif Target_Clock <= 340_000_000 then
459 Calculate_Clock_Parameters
460 (Display => Port_Cfg.Display,
461 Target_Dotclock => Target_Clock,
462 -- should be, but doesn't has to be always the same:
463 Reference_Clock => 96_000_000,
464 Best_Clock => Clk,
465 Valid => Success);
466 else
467 Success := False;
468 pragma Debug (Debug.Put ("WARNING: Targeted clock too high: "));
469 pragma Debug (Debug.Put_Int64 (Target_Clock));
470 pragma Debug (Debug.Put (" > "));
471 pragma Debug (Debug.Put_Int32 (340_000_000));
472 pragma Debug (Debug.New_Line);
473 pragma Debug (Debug.New_Line);
474 end if;
475 end if;
476
477 if Success then
478 Program_DPLL (PLL, Port_Cfg.Display, Clk);
479
480 Registers.Set_Mask (DPLL (PLL), DPLL_VCO_ENABLE);
481 Registers.Posting_Read (DPLL (PLL));
482 Time.U_Delay (150);
483 end if;
484 end On;
485
486 procedure Off (PLL : T)
487 is
488 begin
489 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
490
491 if PLL in DPLLs then
492 Registers.Unset_Mask (DPLL (PLL), DPLL_VCO_ENABLE);
493 end if;
494 end Off;
495
496 ----------------------------------------------------------------------------
497
498 procedure Initialize
499 is
500 begin
501 PLLs :=
502 (DPLLs =>
503 (Use_Count => 0,
504 Used_For_DP => False,
505 Link_Rate => DP_Bandwidth'First,
506 Mode => Invalid_Mode));
507 end Initialize;
508
509 procedure Alloc_Configurable
510 (Port_Cfg : in Port_Config;
511 PLL : out T;
512 Success : out Boolean)
513 with
514 Pre => True
515 is
516 function Config_Matches (PE : PLL_State) return Boolean
517 is
518 begin
519 return
520 PE.Used_For_DP = (Port_Cfg.Display = DP) and
521 ((PE.Used_For_DP and PE.Link_Rate = Port_Cfg.DP.Bandwidth) or
522 (not PE.Used_For_DP and PE.Mode = Port_Cfg.Mode));
523 end Config_Matches;
524 begin
525 -- try to find shareable PLL
526 for P in DPLLs loop
527 Success := PLLs (P).Use_Count /= 0 and
528 PLLs (P).Use_Count /= Count_Range'Last and
529 Config_Matches (PLLs (P));
530 if Success then
531 PLL := P;
532 PLLs (PLL).Use_Count := PLLs (PLL).Use_Count + 1;
533 return;
534 end if;
535 end loop;
536
537 -- try to find free PLL
538 for P in DPLLs loop
539 if PLLs (P).Use_Count = 0 then
540 PLL := P;
541 On (PLL, Port_Cfg, Success);
542 if Success then
543 PLLs (PLL) :=
544 (Use_Count => 1,
545 Used_For_DP => Port_Cfg.Display = DP,
546 Link_Rate => Port_Cfg.DP.Bandwidth,
547 Mode => Port_Cfg.Mode);
548 end if;
549 return;
550 end if;
551 end loop;
552
553 PLL := Invalid;
554 end Alloc_Configurable;
555
556 procedure Alloc
557 (Port_Cfg : in Port_Config;
558 PLL : out T;
559 Success : out Boolean)
560 is
561 begin
562 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
563
564 if Port_Cfg.Port = DIGI_A then
565 PLL := Invalid;
566 Success := True;
567 else
568 Alloc_Configurable (Port_Cfg, PLL, Success);
569 end if;
570 end Alloc;
571
572 procedure Free (PLL : T)
573 is
574 begin
575 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
576
577 if PLL in DPLLs then
578 if PLLs (PLL).Use_Count /= 0 then
579 PLLs (PLL).Use_Count := PLLs (PLL).Use_Count - 1;
580 if PLLs (PLL).Use_Count = 0 then
581 Off (PLL);
582 end if;
583 end if;
584 end if;
585 end Free;
586
587 procedure All_Off
588 is
589 begin
590 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
591
592 for PLL in DPLLs loop
593 Off (PLL);
594 end loop;
595 end All_Off;
596
597 function Register_Value (PLL : T) return Word32
598 is
599 begin
600 return (if PLL = DPLL_B then 1 else 0);
601 end Register_Value;
602
603end HW.GFX.GMA.PLLs;