@@ -128,67 +128,14 @@ void AmlUartV2::OnReceivedMetadata(
128128
129129zx_status_t AmlUartV2::GetPowerConfiguration (
130130 const fidl::WireSyncClient<fuchsia_hardware_platform_device::Device>& pdev) {
131- auto power_broker = incoming ()->Connect <fuchsia_power_broker::Topology >();
132- if (power_broker .is_error () || !power_broker ->is_valid ()) {
133- FDF_LOG (WARNING, " Failed to connect to power broker : %s" , power_broker .status_string ());
134- return power_broker .status_value ();
131+ auto sag = incoming ()->Connect <fuchsia_power_system::ActivityGovernor >();
132+ if (sag .is_error () || !sag ->is_valid ()) {
133+ FDF_LOG (WARNING, " Failed to connect to activity governor : %s" , sag .status_string ());
134+ return sag .status_value ();
135135 }
136136
137- // TODO(b/358361345): Use //sdk/lib/driver/platform-device/cpp to retrieve power configuration
138- // once it supports it.
139- const auto result_power_config = pdev->GetPowerConfiguration ();
140- if (!result_power_config.ok ()) {
141- FDF_LOG (ERROR, " Call to get power config failed: %s" , result_power_config.status_string ());
142- return result_power_config.status ();
143- }
144- if (result_power_config->is_error ()) {
145- FDF_LOG (INFO, " GetPowerConfiguration failed: %s" ,
146- zx_status_get_string (result_power_config->error_value ()));
147- return result_power_config->error_value ();
148- }
149- if (result_power_config->value ()->config .count () != 1 ) {
150- FDF_LOG (INFO, " Unexpected number of power configurations: %zu" ,
151- result_power_config->value ()->config .count ());
152- return ZX_ERR_NOT_SUPPORTED;
153- }
154-
155- const auto & wire_config = result_power_config->value ()->config [0 ];
156- if (wire_config.element ().name ().get () != " aml-uart-wake-on-interrupt" ) {
157- FDF_LOG (ERROR, " Unexpected power element: %s" ,
158- std::string (wire_config.element ().name ().get ()).c_str ());
159- return ZX_ERR_BAD_STATE;
160- }
161-
162- fuchsia_hardware_power::PowerElementConfiguration natural_config = fidl::ToNatural (wire_config);
163- zx::result config = fdf_power::PowerElementConfiguration::FromFidl (natural_config);
164- if (config.is_error ()) {
165- FDF_SLOG (ERROR, " Failed to convert power element configuration from fidl." ,
166- KV (" stauts" , config.status_string ()));
167- return config.status_value ();
168- }
169-
170- // Get dependency tokens from the config, these tokens represent the dependency from the current
171- // element to its parent(s).
172- auto tokens = fdf_power::GetDependencyTokens (*incoming (), config.value ());
173- if (tokens.is_error ()) {
174- FDF_LOG (ERROR, " Failed to get power dependency tokens: %u" ,
175- static_cast <uint8_t >(tokens.error_value ()));
176- return ZX_ERR_INTERNAL;
177- }
178-
179- fdf_power::ElementDesc description =
180- fdf_power::ElementDescBuilder (config.value (), std::move (tokens.value ())).Build ();
181- auto result_add_element = fdf_power::AddElement (power_broker.value (), description);
182- if (result_add_element.is_error ()) {
183- FDF_LOG (ERROR, " Failed to add power element: %u" ,
184- static_cast <uint8_t >(result_add_element.error_value ()));
185- return ZX_ERR_INTERNAL;
186- }
137+ sag_ = std::move (sag.value ());
187138
188- element_control_client_end_ = std::move (*description.element_control_client );
189- lessor_client_end_ = std::move (*description.lessor_client );
190- current_level_client_end_ = std::move (*description.current_level_client );
191- required_level_client_end_ = std::move (*description.required_level_client );
192139 return ZX_OK;
193140}
194141
@@ -264,9 +211,7 @@ void AmlUartV2::OnDeviceServerInitialized(zx::result<> device_server_init_result
264211 timer_dispatcher_.emplace (std::move (timer_dispatcher_result.value ()));
265212 aml_uart_.emplace (std::move (pdev), serial_port_info_, std::move (mmio.value ()),
266213 irq_dispatcher_->borrow (), timer_dispatcher_->borrow (),
267- driver_config_.enable_suspend () ? true : false , std::move (lessor_client_end_),
268- std::move (current_level_client_end_), std::move (required_level_client_end_),
269- std::move (element_control_client_end_));
214+ driver_config_.enable_suspend (), std::move (sag_));
270215
271216 // Default configuration for the case that serial_impl_config is not called.
272217 constexpr uint32_t kDefaultBaudRate = 115200 ;
0 commit comments