Skip to content

Commit 9ce1745

Browse files
Hai BiCQ Bot
authored andcommitted
[power] Remove bt-uart element
Removing the element and change the code to use TakeWakeLease. Bug: b/356674003 Test: CQ, on device test Change-Id: Ic6960385ca80bd4594de184d65fef5e71ceab3c8 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1143979 Reviewed-by: Andres Oportus <[email protected]> Reviewed-by: Michael Brunson <[email protected]> Commit-Queue: Hai Bi <[email protected]> Reviewed-by: Zhiyi Chen <[email protected]> Reviewed-by: Ruby Zhuang <[email protected]>
1 parent ef955fe commit 9ce1745

File tree

8 files changed

+80
-382
lines changed

8 files changed

+80
-382
lines changed

src/devices/board/drivers/vim3-devicetree/dts/vim3-power-config.dtsi

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,6 @@
6464
};
6565
};
6666

67-
&bt_uart {
68-
power-elements {
69-
aml-uart-wake-on-interrupt-element {
70-
power-levels {
71-
off-level {
72-
level = <0>;
73-
level-transition-table {
74-
transition-to-handling {
75-
target-level = <1>;
76-
latency-us = <0>;
77-
};
78-
};
79-
};
80-
handling-level {
81-
level = <1>;
82-
level-dependencies = <&sag_wake_active 1>;
83-
level-transition-table {
84-
transition-to-off {
85-
target-level = <0>;
86-
latency-us = <0>;
87-
};
88-
};
89-
};
90-
};
91-
};
92-
};
93-
};
94-
9567
&audio {
9668
power-elements {
9769
audio-hw-element {
@@ -108,7 +80,6 @@
10880
};
10981
};
11082

111-
11283
&sd_emmc_c {
11384
power-elements {
11485
aml-sdmmc-hardware-element {

src/devices/board/drivers/vim3-devicetree/dts/vim3.golden.dts

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,6 @@
3030
pwm-init = <0x21>;
3131
reg = <0x00 0xffd24000 0x00 0x18>;
3232
serial-port = <0x02 0x06 0x03>;
33-
34-
power-elements {
35-
36-
aml-uart-wake-on-interrupt-element {
37-
38-
power-levels {
39-
40-
handling-level {
41-
level = <0x01>;
42-
level-dependencies = <0x37 0x01>;
43-
44-
level-transition-table {
45-
46-
transition-to-off {
47-
latency-us = <0x00>;
48-
target-level = <0x00>;
49-
};
50-
};
51-
};
52-
53-
off-level {
54-
level = <0x00>;
55-
56-
level-transition-table {
57-
58-
transition-to-handling {
59-
latency-us = <0x00>;
60-
target-level = <0x01>;
61-
};
62-
};
63-
};
64-
};
65-
};
66-
};
6733
};
6834

6935
canvas@ff638000 {
@@ -215,7 +181,7 @@
215181
compatible = "fuchsia,gpio-buttons";
216182
gpio-names = "POWER";
217183
gpios = <0x06 0x5c 0x00>;
218-
pinctrl-0 = <0x38>;
184+
pinctrl-0 = <0x37>;
219185
};
220186

221187
gpio_header {
@@ -646,7 +612,7 @@
646612
gpio-buttons-pins {
647613
bias-disable;
648614
function = <0x00 0x00>;
649-
phandle = <0x38>;
615+
phandle = <0x37>;
650616
pins = <0x5c>;
651617
};
652618

@@ -739,7 +705,7 @@
739705

740706
wifi-pins {
741707
bias-disable;
742-
phandle = <0x39>;
708+
phandle = <0x38>;
743709
pins = <0x3f>;
744710
};
745711
};
@@ -1019,7 +985,6 @@
1019985

1020986
active-level {
1021987
level = <0x01>;
1022-
phandle = <0x37>;
1023988
};
1024989

1025990
inactive-level {
@@ -1061,6 +1026,6 @@
10611026
compatible = "broadcom,bcm4359";
10621027
gpio-names = "WIFI_WAKE_HOST";
10631028
gpios = <0x06 0x3f 0x00>;
1064-
pinctrl-0 = <0x39>;
1029+
pinctrl-0 = <0x38>;
10651030
};
10661031
};

src/devices/serial/drivers/aml-uart/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ source_set("aml-uart-source") {
5959
public_deps = [
6060
"//sdk/fidl/fuchsia.hardware.power:fuchsia.hardware.power_cpp",
6161
"//sdk/fidl/fuchsia.hardware.serialimpl:fuchsia.hardware.serialimpl_cpp",
62+
"//sdk/fidl/fuchsia.power.system:fuchsia.power.system_cpp",
6263
"//sdk/lib/async:async-cpp",
6364
"//sdk/lib/driver/platform-device/cpp",
6465
"//sdk/lib/driver/power/cpp",

src/devices/serial/drivers/aml-uart/aml-uart-dfv2.cc

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -128,67 +128,14 @@ void AmlUartV2::OnReceivedMetadata(
128128

129129
zx_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;

src/devices/serial/drivers/aml-uart/aml-uart-dfv2.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ class AmlUartV2 : public fdf::DriverBase {
5252
fdf::ServerBindingGroup<fuchsia_hardware_serialimpl::Device> serial_impl_bindings_;
5353

5454
aml_uart_dfv2_config::Config driver_config_;
55-
56-
// Client ends for talking to power broker.
57-
std::optional<fidl::ClientEnd<fuchsia_power_broker::CurrentLevel>> current_level_client_end_;
58-
std::optional<fidl::ClientEnd<fuchsia_power_broker::RequiredLevel>> required_level_client_end_;
59-
std::optional<fidl::ClientEnd<fuchsia_power_broker::ElementControl>> element_control_client_end_;
60-
std::optional<fidl::ClientEnd<fuchsia_power_broker::Lessor>> lessor_client_end_;
55+
std::optional<fidl::ClientEnd<fuchsia_power_system::ActivityGovernor>> sag_;
6156
};
6257

6358
} // namespace serial

0 commit comments

Comments
 (0)