| Nico Huber | 27d2627 | 2026-05-27 19:01:09 +0200 | [diff] [blame^] | 1 | -- |
| 2 | -- Copyright (C) 2022 Google, LLC |
| 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 | |
| 15 | with GNAT.Source_Info; |
| 16 | with HW.Debug; |
| 17 | with HW.GFX.GMA.Config_Helpers; |
| 18 | with HW.GFX.GMA.Connectors.TC.Ownership; |
| 19 | with HW.GFX.GMA.Power_Domains_Common; |
| 20 | use HW.GFX.GMA.Power_Domains_Common; |
| 21 | |
| 22 | package body HW.GFX.GMA.Power_Domains is |
| 23 | |
| 24 | function Need_PW (PW : Dynamic_Well; Configs : Pipe_Configs) return Boolean |
| 25 | is |
| 26 | function Any_TC_Port return Boolean is |
| 27 | (for some Pipe in Pipe_Index => |
| 28 | Configs (Pipe).Port /= Disabled and then |
| 29 | Config_Helpers.To_GPU_Port (Pipe, Configs (Pipe).Port) in USBC_Port); |
| 30 | |
| 31 | function Any_Pipe_From (First : Pipe_Index) return Boolean is |
| 32 | (for some Pipe in First .. Pipe_Index'Last => Configs (Pipe).Port /= Disabled); |
| 33 | |
| 34 | function VGA return Boolean is |
| 35 | (Configs (Primary).Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET); |
| 36 | begin |
| 37 | case PW is |
| 38 | when PW2 | PW3 => |
| 39 | return Any_Pipe_From (Secondary) or Any_TC_Port or VGA; |
| 40 | when PW4 => |
| 41 | return Any_Pipe_From (Tertiary); |
| 42 | when PW5 => |
| 43 | return False; -- Fourth pipe not supported yet. |
| 44 | end case; |
| 45 | end Need_PW; |
| 46 | |
| 47 | ---------------------------------------------------------------------------- |
| 48 | |
| 49 | procedure Power_Up (Port : Active_Port_Type; Success : out Boolean) |
| 50 | is |
| 51 | GPU_Port : constant GMA.GPU_Port := |
| 52 | Config_Helpers.To_GPU_Port (Pipe_Index'First, Port); |
| 53 | |
| 54 | procedure On (Aux : AUX_Domain; DDI : DDI_Domain) is |
| 55 | begin |
| 56 | PD_On (PW1); |
| 57 | if GPU_Port in USBC_Port then |
| 58 | PD_On (PW2); |
| 59 | PD_On (PW3); |
| 60 | end if; |
| 61 | PD_On (DDI); |
| 62 | |
| 63 | if GPU_Port in USBC_Port then |
| 64 | Connectors.TC.Ownership.Claim |
| 65 | (Port => GPU_Port, |
| 66 | DP_Alt => Port in Physical_USBC_Ports, |
| 67 | Success => Success); |
| 68 | if not Success then |
| 69 | return; |
| 70 | end if; |
| 71 | end if; |
| 72 | PD_On (Aux); |
| 73 | |
| 74 | Success := True; |
| 75 | end On; |
| 76 | begin |
| 77 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 78 | |
| 79 | case GPU_Port is |
| 80 | when GMA.DIGI_A => On (AUX_A, DDI_A); |
| 81 | when GMA.DIGI_B => On (AUX_B, DDI_B); |
| 82 | when GMA.DIGI_C => On (AUX_C, DDI_C); |
| 83 | when GMA.DDI_TC1 => On (AUX_USBC1, DDI_USBC1); |
| 84 | when GMA.DDI_TC2 => On (AUX_USBC2, DDI_USBC2); |
| 85 | when GMA.DDI_TC3 => On (AUX_USBC3, DDI_USBC3); |
| 86 | when GMA.DDI_TC4 => On (AUX_USBC4, DDI_USBC4); |
| 87 | when GMA.DDI_TC5 => On (AUX_USBC5, DDI_USBC5); |
| 88 | when GMA.DDI_TC6 => On (AUX_USBC6, DDI_USBC6); |
| 89 | when others => Success := True; |
| 90 | end case; |
| 91 | end Power_Up; |
| 92 | |
| 93 | end HW.GFX.GMA.Power_Domains; |